19 void mexFunction(
int nlhs, mxArray *plhs[],
int nrhs,
const mxArray *prhs[])
22 nargchk(nrhs>=2 && (nrhs%2)==0 && nlhs<=1);
25 vector<MxArray> rhs(prhs, prhs+nrhs);
30 TermCriteria criteria(TermCriteria::COUNT+TermCriteria::EPS, 50, 0.001);
31 for (
int i=2; i<nrhs; i+=2) {
32 string key(rhs[i].toString());
34 winSize = rhs[i+1].toSize();
35 else if (key==
"ZeroZone")
36 zeroZone = rhs[i+1].toSize();
37 else if (key==
"Criteria")
38 criteria = rhs[i+1].toTermCriteria();
40 mexErrMsgIdAndTxt(
"mexopencv:error",
"Unrecognized option");
44 Mat image(rhs[0].toMat(rhs[0].isUint8() ? CV_8U : CV_32F));
45 if (rhs[1].isNumeric()) {
46 Mat corners(rhs[1].toMat(CV_32F));
47 cornerSubPix(image, corners, winSize, zeroZone, criteria);
50 else if (rhs[1].isCell()) {
51 vector<Point2f> corners(rhs[1].toVector<Point2f>());
52 cornerSubPix(image, corners, winSize, zeroZone, criteria);
56 mexErrMsgIdAndTxt(
"mexopencv:error",
"Invalid input");
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
mxArray object wrapper for data conversion and manipulation.
void nargchk(bool cond)
Alias for input/ouput arguments number check.
Global constant definitions.