Skip to content

Instantly share code, notes, and snippets.

View agirault's full-sized avatar
👨‍💻

Alexis Girault agirault

👨‍💻
View GitHub Profile
#!/bin/bash
# Download MacOSX SDK and link them into XCode
# Make sure to update XCode beforehand (xcode-select --install)
mkdir SDKs
cd SDKs
git clone https://github.com/phracker/MacOSX-SDKs.git MacOSX.platform
cd ..
git clone https://gist.github.com/f213c737c0b2b581b13c.git
@agirault
agirault / add-sdks.py
Last active December 17, 2015 22:28
Links all your SDKs to XCode
#!/usr/bin/python
# add-sdks.py
# Rob Napier <[email protected]>
# Alexis girault <[email protected]>
# Script to link in all your old SDKs to Xcode
# Needs to be run every time you update Xcode
#
# 1. Create a directory and store the SDKs:
@agirault
agirault / exportScreenshot.cxx
Last active November 16, 2015 15:15
Example of vtkRenderWindow OffScreenRendering for Image export
// Enable OffScreen Rendering
renderWindow->OffScreenRenderingOn();
// Set renderWindow size
const int* windowSize = renderWindow->GetSize();
int W = windowSize[0];
int H = windowSize[1];
renderWindow->SetSize(d->exportWidthSpinBox->value(),d->exportHeightSpinBox->value());
// Get Image
@agirault
agirault / homography_screenreality
Created December 11, 2014 00:40
homography screenReality
//-- Matrix
float modelview[16];
float projection[16];
glGetFloatv (GL_MODELVIEW_MATRIX, modelview);
glGetFloatv (GL_PROJECTION_MATRIX, projection);
cv::Mat modelM(4,4,CV_32FC2,modelview);
cv::Mat projM(4,4,CV_32FC2,projection);
cv::Mat M = projM*modelM;
std::cout<<M<<std::endl;
function [histout,costdata, x] = linesearch(x0,f,g,tolPos,tolGrad,maxit)
% LINESEARCH finds the minimum of an objective function using
% - Steepest descent Algorithm
% - Armijo as a condition for sufficient decrease (could try Wolf?)
% - Step length selection
%
% INPUT:
% - x0 = initial iterate position
% - f = objective function,
% - g = grad f (COLUMN vector)
template <class T, unsigned int VImageDimension >
void VectorImageUtils< T, VImageDimension >::HFieldToDeformationFieldImageFilter(typename DeformationImageType::Pointer itkImage)
{
ImageRegionConstIteratorWithIndex<DeformationImageType> it = ImageRegionConstIteratorWithIndex<DeformationImageType>(
itkImage, itkImage->GetRequestedRegion());
for(it.GoToBegin();!it.IsAtEnd(); ++it)
{
typename DeformationImageType::PixelType displacementValue;
//
// to ITK 3D
//
template <class T, unsigned int VImageDimension >
typename DeformationImageType::Pointer VectorImageUtils< T, VImageDimension >::convertToITK( const VectorImageType3D* im)
{
/* DeformationImageType instead of ITKVectorImage<T,VImageDimension>::Type
**
** We defined DeformationImageType like this in VectorImageUtils.h :
//PolyData
ShapePopulationData * Mesh = new ShapePopulationData;
Mesh->ReadMesh(a_filePath);
m_meshList.push_back(Mesh);
//Polydata Mapper
vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
#if (VTK_MAJOR_VERSION < 6)
mapper->SetInputConnection(Mesh->GetPolyData()->GetProducerPort());
#else
@agirault
agirault / PhiCubicModel.m
Created March 26, 2014 15:20
minimize phi(alpha) using a cubic model - linesearch with step length selection
M1 = [alpha_prev^2, -alpha_cur^2; -alpha_prev^3, alpha_cur^3];
M2 = [phi_alpha - phi_0 - phiP_0*alpha_cur; phi_prev - phi_0 - phiP_0*alpha_prev];
M = M1 * M2 * 1/(alpha_prev^2 * alpha_cur^2 * (alpha_cur - alpha_prev));
a = M(1);
b = M(2);
alpha = (-b + sqrt(b*b - 3*a*phiP_0))/(3*a);
#ifndef C_SOLVER_STEP_LENGTH_SELECTION_TXX
#define C_SOLVER_STEP_LENGTH_SELECTION_TXX
template < class TState >
CSolverStepLengthSelection< TState>::CSolverStepLengthSelection()
: DefaultMinGradAllowed( 0.0001 ),
DefaultMinDisplacementAllowed( 0.001 ),
DefaultDecreaseConstant( 0.0001 ),