summaryrefslogtreecommitdiffstats
path: root/SD-VBS/common/toolbox/lagrcv/findCornerSubPix.cc
diff options
context:
space:
mode:
Diffstat (limited to 'SD-VBS/common/toolbox/lagrcv/findCornerSubPix.cc')
-rwxr-xr-xSD-VBS/common/toolbox/lagrcv/findCornerSubPix.cc39
1 files changed, 39 insertions, 0 deletions
diff --git a/SD-VBS/common/toolbox/lagrcv/findCornerSubPix.cc b/SD-VBS/common/toolbox/lagrcv/findCornerSubPix.cc
new file mode 100755
index 0000000..3e8659c
--- /dev/null
+++ b/SD-VBS/common/toolbox/lagrcv/findCornerSubPix.cc
@@ -0,0 +1,39 @@
1
2/* compile with
3 mex findCornerSubPix.cc -I/usr/local/opencv/include -L/usr/local/opencv/lib -lcxcore -lcv
4*/
5
6#include "mex.h"
7#include "opencv/cv.h"
8#include "opencv/highgui.h"
9#include <stdio.h>
10#include <math.h>
11
12//#define MAX_CORNERS 500
13#define WIN_SIZE 5
14
15void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) {
16 // usage: [ features ] =
17 // findCornerSubPix(image, features)
18 // image must be single-channel, 8-bit
19
20 char *image_pr = (char*)mxGetPr(prhs[0]);
21 const int *imdims = mxGetDimensions(prhs[0]);
22 IplImage *image =
23 cvCreateImageHeader(cvSize(imdims[0], imdims[1]), IPL_DEPTH_8U, 1);
24 image->imageData = image_pr;
25
26 const int *feature_dims = mxGetDimensions(prhs[1]);
27 int nfeatures = feature_dims[1];
28 plhs[0] = mxCreateNumericMatrix(2, nfeatures, mxSINGLE_CLASS, mxREAL);
29 CvPoint2D32f *newfeatures = (CvPoint2D32f*)mxGetPr(plhs[0]);
30 CvPoint2D32f *oldfeatures = (CvPoint2D32f*)mxGetPr(prhs[1]);
31 // plhs[0] = mxDuplicateArray(prhs[1]);
32 // CvPoint2D32f *newfeatures = (CvPoint2D32f*)mxGetPr(plhs[0]);
33 memcpy(newfeatures, oldfeatures, sizeof(float)*2*nfeatures);
34
35 cvFindCornerSubPix(image, newfeatures, nfeatures,
36 cvSize(WIN_SIZE,WIN_SIZE),
37 cvSize(-1,-1),
38 cvTermCriteria(CV_TERMCRIT_ITER|CV_TERMCRIT_EPS,20,0.03));
39}