diff options
Diffstat (limited to 'SD-VBS/common/toolbox/lagrcv/dummyMex.cc')
| -rwxr-xr-x | SD-VBS/common/toolbox/lagrcv/dummyMex.cc | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/SD-VBS/common/toolbox/lagrcv/dummyMex.cc b/SD-VBS/common/toolbox/lagrcv/dummyMex.cc new file mode 100755 index 0000000..0799182 --- /dev/null +++ b/SD-VBS/common/toolbox/lagrcv/dummyMex.cc | |||
| @@ -0,0 +1,58 @@ | |||
| 1 | |||
| 2 | /* compile with | ||
| 3 | rm liblagrcv.a | ||
| 4 | gcc -c lagrcv.cpp | ||
| 5 | ar rc liblagrcv.a lagrcv.o | ||
| 6 | ranlib liblagrcv.a | ||
| 7 | mex7 calcTextureMex.cc -L/home/ikkjin/LagrMatlab/opencv/matlab -llagrcv -I/home/ikkjin/LagrMatlab/opencv/matlab/ | ||
| 8 | */ | ||
| 9 | |||
| 10 | #include "mex.h" | ||
| 11 | #include "lagrcv.h" | ||
| 12 | #include <stdio.h> | ||
| 13 | #include <math.h> | ||
| 14 | |||
| 15 | // TODO: add number of corners parameter | ||
| 16 | void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { | ||
| 17 | // usage: [newFeaturePnt validFlag ] = | ||
| 18 | // calcOptFlowPyrLKMex(Ipyr, IdxPyr, IdyPyr, Jpyr, featurePnt, winSize, c_level, c_det, c_xx, c_xy, c_yy) | ||
| 19 | // Ipyr, IdxPyr, IdyPyr, Jpyr: levelx1 size cell. | ||
| 20 | // featurePnt 2xn int | ||
| 21 | // winSize c_level int | ||
| 22 | // c_xx c_xy c_yy: image size double* | ||
| 23 | // image must be single-channel, 8-bit | ||
| 24 | |||
| 25 | |||
| 26 | double* fPntDouble; | ||
| 27 | const int *nFeatures; | ||
| 28 | char* valid; | ||
| 29 | int *fPnt, *newFPnt; | ||
| 30 | |||
| 31 | fPntDouble=(double*)mxGetPr(prhs[0]); | ||
| 32 | nFeatures=mxGetDimensions(prhs[0]); | ||
| 33 | fPnt=(int*)malloc(sizeof(int)*nFeatures[0]*nFeatures[1]); | ||
| 34 | |||
| 35 | printf("nFeatures %d, %d", nFeatures[0], nFeatures[1]); | ||
| 36 | //plhs[0] = mxCreateNumericMatrix(nFeatures[0], nFeatures[1], mxINT32_CLASS, mxREAL); | ||
| 37 | plhs[0] = mxCreateNumericArray(2,nFeatures,mxINT32_CLASS, mxREAL); | ||
| 38 | //plhs[1] = mxCreateNumericMatrix(1, nFeatures[1], mxINT32_CLASS, mxREAL); | ||
| 39 | plhs[1] = mxCreateNumericArray(1,nFeatures+1,mxUINT8_CLASS, mxREAL); | ||
| 40 | |||
| 41 | newFPnt = (int*)mxGetPr(plhs[0]); | ||
| 42 | valid = (char*)mxGetPr(plhs[1]); | ||
| 43 | |||
| 44 | //idx convert from matlab to c | ||
| 45 | for(int i=0; i<nFeatures[1]; i++){ | ||
| 46 | fPnt[i*2]=(int)fPntDouble[i*2]-1; | ||
| 47 | fPnt[i*2+1]=(int)fPntDouble[i*2+1]-1; | ||
| 48 | valid[i]=1; | ||
| 49 | } | ||
| 50 | |||
| 51 | //printf("v %d %d %d", valid[0], valid[1], valid[2]); | ||
| 52 | |||
| 53 | //idx convert from matlab to c | ||
| 54 | for(int i=0; i<nFeatures[1]*2; i++){ | ||
| 55 | newFPnt[i]=fPnt[i]+1; | ||
| 56 | } | ||
| 57 | free(fPnt); | ||
| 58 | } | ||
