From f618466c25d43f3bae9e40920273bf77de1e1149 Mon Sep 17 00:00:00 2001 From: leochanj105 Date: Mon, 19 Oct 2020 23:09:30 -0400 Subject: initial sd-vbs initial sd-vbs add sd-vbs sd-vbs --- .../common/toolbox/lagrcv/calcOptFlowLKPyrMex.cc | 99 ++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100755 SD-VBS/common/toolbox/lagrcv/calcOptFlowLKPyrMex.cc (limited to 'SD-VBS/common/toolbox/lagrcv/calcOptFlowLKPyrMex.cc') diff --git a/SD-VBS/common/toolbox/lagrcv/calcOptFlowLKPyrMex.cc b/SD-VBS/common/toolbox/lagrcv/calcOptFlowLKPyrMex.cc new file mode 100755 index 0000000..56ab3d0 --- /dev/null +++ b/SD-VBS/common/toolbox/lagrcv/calcOptFlowLKPyrMex.cc @@ -0,0 +1,99 @@ + +/* 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