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 --- SD-VBS/common/toolbox/lagrcv/findCornerSubPix.cc | 39 ++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100755 SD-VBS/common/toolbox/lagrcv/findCornerSubPix.cc (limited to 'SD-VBS/common/toolbox/lagrcv/findCornerSubPix.cc') 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 @@ + +/* compile with + mex findCornerSubPix.cc -I/usr/local/opencv/include -L/usr/local/opencv/lib -lcxcore -lcv +*/ + +#include "mex.h" +#include "opencv/cv.h" +#include "opencv/highgui.h" +#include +#include + +//#define MAX_CORNERS 500 +#define WIN_SIZE 5 + +void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { + // usage: [ features ] = + // findCornerSubPix(image, features) + // image must be single-channel, 8-bit + + char *image_pr = (char*)mxGetPr(prhs[0]); + const int *imdims = mxGetDimensions(prhs[0]); + IplImage *image = + cvCreateImageHeader(cvSize(imdims[0], imdims[1]), IPL_DEPTH_8U, 1); + image->imageData = image_pr; + + const int *feature_dims = mxGetDimensions(prhs[1]); + int nfeatures = feature_dims[1]; + plhs[0] = mxCreateNumericMatrix(2, nfeatures, mxSINGLE_CLASS, mxREAL); + CvPoint2D32f *newfeatures = (CvPoint2D32f*)mxGetPr(plhs[0]); + CvPoint2D32f *oldfeatures = (CvPoint2D32f*)mxGetPr(prhs[1]); + // plhs[0] = mxDuplicateArray(prhs[1]); + // CvPoint2D32f *newfeatures = (CvPoint2D32f*)mxGetPr(plhs[0]); + memcpy(newfeatures, oldfeatures, sizeof(float)*2*nfeatures); + + cvFindCornerSubPix(image, newfeatures, nfeatures, + cvSize(WIN_SIZE,WIN_SIZE), + cvSize(-1,-1), + cvTermCriteria(CV_TERMCRIT_ITER|CV_TERMCRIT_EPS,20,0.03)); +} -- cgit v1.2.2