diff options
Diffstat (limited to 'SD-VBS/common/toolbox/lagrcv/calcGradientPyrMex.cc')
| -rwxr-xr-x | SD-VBS/common/toolbox/lagrcv/calcGradientPyrMex.cc | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/SD-VBS/common/toolbox/lagrcv/calcGradientPyrMex.cc b/SD-VBS/common/toolbox/lagrcv/calcGradientPyrMex.cc new file mode 100755 index 0000000..d94130b --- /dev/null +++ b/SD-VBS/common/toolbox/lagrcv/calcGradientPyrMex.cc | |||
| @@ -0,0 +1,45 @@ | |||
| 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: [dxPye dyPyr] = | ||
| 18 | // calcGradientPyrMex(imagePyr) | ||
| 19 | |||
| 20 | const int *cellDims = mxGetDimensions(prhs[0]); | ||
| 21 | double *image; | ||
| 22 | const mxArray* imgArray; | ||
| 23 | mxArray *dxArray, *dyArray; | ||
| 24 | double *dx, *dy; | ||
| 25 | const int *imdims; | ||
| 26 | |||
| 27 | plhs[0] = mxCreateCellArray(1, cellDims); | ||
| 28 | plhs[1] = mxCreateCellArray(1, cellDims); | ||
| 29 | |||
| 30 | for(int i=0; i<cellDims[0];i++){ | ||
| 31 | imgArray= mxGetCell(prhs[0],i); | ||
| 32 | image=mxGetPr(imgArray); | ||
| 33 | imdims = mxGetDimensions(imgArray); | ||
| 34 | |||
| 35 | dxArray = mxCreateNumericMatrix(imdims[0], imdims[1], mxDOUBLE_CLASS, mxREAL); | ||
| 36 | dyArray = mxCreateNumericMatrix(imdims[0], imdims[1], mxDOUBLE_CLASS, mxREAL); | ||
| 37 | mxSetCell(plhs[0], i, dxArray); | ||
| 38 | mxSetCell(plhs[1], i, dyArray); | ||
| 39 | dx=mxGetPr(dxArray); | ||
| 40 | dy=mxGetPr(dyArray); | ||
| 41 | |||
| 42 | calcGradient(image, imdims[0], imdims[1], dx, dy); | ||
| 43 | //calcSobel(image, imdims[0], imdims[1], dx, dy); | ||
| 44 | } | ||
| 45 | } | ||
