/* compile with rm liblagrcv.a gcc -c lagrcv.cpp ar rc liblagrcv.a lagrcv.o ranlib liblagrcv.a mex7 calcTextureMex.cc -L/home/ikkjin/LagrMatlab/opencv/matlab -llagrcv -I/home/ikkjin/LagrMatlab/opencv/matlab/ */ #include "mex.h" #include "lagrcv.h" #include #include #ifndef MAX_LEVEL # define MAX_LEVEL 5 #endif // TODO: add number of corners parameter void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { // usage: [newFeaturePnt validFlag ] = // calcOptFlowPyrLKMex(Ipyr, IdxPyr, IdyPyr, Jpyr, featurePnt, winSize, accuracy_th, max_iter) // Ipyr, IdxPyr, IdyPyr, Jpyr: levelx1 size cell. // featurePnt 2xn int // winSize c_level int // c_xx c_xy c_yy: image size double* // image must be double const mxArray* imgArray; int* imdims; const int *curImgDims; const int *nFeatures; //double **iP, **iDxP, **iDyP, **jP; double *iP[MAX_LEVEL], *iDxP[MAX_LEVEL], *iDyP[MAX_LEVEL], *jP[MAX_LEVEL]; double *fPnt, *newFPnt; char* valid; double accuracy_th; int winSize, max_iter; const int *cellDims = mxGetDimensions(prhs[0]); if (nrhs > 6) { accuracy_th=(double)mxGetScalar(prhs[6]); max_iter=(int)mxGetScalar(prhs[7]); } winSize = (int)mxGetScalar(prhs[5]); fPnt=(double*)mxGetPr(prhs[4]); nFeatures=mxGetDimensions(prhs[4]); imdims=(int*)malloc(sizeof(int)*cellDims[0]*2); //iP=(double**)malloc(sizeof(double*)*cellDims[0]); //iDxP=(double**)malloc(sizeof(double*)*cellDims[0]); //iDyP=(double**)malloc(sizeof(double*)*cellDims[0]); //jP=(double**)malloc(sizeof(double*)*cellDims[0]); for(int i=0; i6){ calcPyrLKTrack( iP, iDxP, iDyP, jP, imdims, cellDims[0], fPnt, nFeatures[1], winSize, newFPnt, valid, accuracy_th, max_iter); }else{ calcPyrLKTrack( iP, iDxP, iDyP, jP, imdims, cellDims[0], fPnt, nFeatures[1], winSize, newFPnt, valid); } //idx convert from matlab to c for(int i=0; i