diff options
Diffstat (limited to 'SD-VBS/common/toolbox/lagrcv/calcTextureMex.cc')
| -rwxr-xr-x | SD-VBS/common/toolbox/lagrcv/calcTextureMex.cc | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/SD-VBS/common/toolbox/lagrcv/calcTextureMex.cc b/SD-VBS/common/toolbox/lagrcv/calcTextureMex.cc new file mode 100755 index 0000000..f91d184 --- /dev/null +++ b/SD-VBS/common/toolbox/lagrcv/calcTextureMex.cc | |||
| @@ -0,0 +1,53 @@ | |||
| 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: [ lambda tr det c_xx c_xy c_yy] = | ||
| 18 | // goodFeaturesToTrack(image, winSize) | ||
| 19 | // image must be single-channel, 8-bit | ||
| 20 | |||
| 21 | double *image; | ||
| 22 | int winSize = (int)mxGetScalar(prhs[1]); | ||
| 23 | double *lambda, *tr, *det, *c_xx, *c_xy, *c_yy; | ||
| 24 | const int *imdims; | ||
| 25 | //double dx[360000];//[MAX_IMAGE_SIZE_1D]; | ||
| 26 | //double dy[360000];//[MAX_IMAGE_SIZE_1D]; | ||
| 27 | double *dx, *dy; | ||
| 28 | |||
| 29 | image = (double*)mxGetPr(prhs[0]); | ||
| 30 | imdims = mxGetDimensions(prhs[0]); | ||
| 31 | dx=(double*)malloc(sizeof(double)*imdims[0]*imdims[1]); | ||
| 32 | dy=(double*)malloc(sizeof(double)*imdims[0]*imdims[1]); | ||
| 33 | |||
| 34 | plhs[0] = mxCreateNumericMatrix(imdims[0], imdims[1], mxDOUBLE_CLASS, mxREAL); | ||
| 35 | plhs[1] = mxCreateNumericMatrix(imdims[0], imdims[1], mxDOUBLE_CLASS, mxREAL); | ||
| 36 | plhs[2] = mxCreateNumericMatrix(imdims[0], imdims[1], mxDOUBLE_CLASS, mxREAL); | ||
| 37 | plhs[3] = mxCreateNumericMatrix(imdims[0], imdims[1], mxDOUBLE_CLASS, mxREAL); | ||
| 38 | plhs[4] = mxCreateNumericMatrix(imdims[0], imdims[1], mxDOUBLE_CLASS, mxREAL); | ||
| 39 | plhs[5] = mxCreateNumericMatrix(imdims[0], imdims[1], mxDOUBLE_CLASS, mxREAL); | ||
| 40 | |||
| 41 | lambda = (double*)mxGetPr(plhs[0]); | ||
| 42 | tr = (double*)mxGetPr(plhs[1]); | ||
| 43 | det = (double*)mxGetPr(plhs[2]); | ||
| 44 | c_xx = (double*)mxGetPr(plhs[3]); | ||
| 45 | c_xy = (double*)mxGetPr(plhs[4]); | ||
| 46 | c_yy = (double*)mxGetPr(plhs[5]); | ||
| 47 | |||
| 48 | calcSobel(image, imdims[0], imdims[1], dx, dy); | ||
| 49 | calcGoodFeature(dx, dy, imdims[0], imdims[1], winSize, | ||
| 50 | lambda, tr, det, c_xx, c_xy, c_yy); | ||
| 51 | free(dx); | ||
| 52 | free(dy); | ||
| 53 | } | ||
