mexopencv  0.1
mex interface for opencv library
find4QuadCornerSubpix.cpp
Go to the documentation of this file.
1 
8 #include "mexopencv.hpp"
9 using namespace std;
10 using namespace cv;
11 
19 void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
20 {
21  // Check the number of arguments
22  nargchk(nrhs>=2 && (nrhs%2)==0 && nlhs<=2);
23 
24  // Argument vector
25  vector<MxArray> rhs(prhs, prhs+nrhs);
26 
27  // Option processing
28  Size region_size(3,3);
29  for (int i=2; i<nrhs; i+=2) {
30  string key(rhs[i].toString());
31  if (key == "RegionSize")
32  region_size = rhs[i+1].toSize();
33  else
34  mexErrMsgIdAndTxt("mexopencv:error",
35  "Unrecognized option %s",key.c_str());
36  }
37 
38  // Process
39  Mat img(rhs[0].toMat(CV_8U));
40  bool success = false;
41  if (rhs[1].isNumeric()) {
42  Mat corners(rhs[1].toMat(CV_32F));
43  success = find4QuadCornerSubpix(img, corners, region_size);
44  plhs[0] = MxArray(corners);
45  }
46  else if (rhs[1].isCell()) {
47  vector<Point2f> corners(rhs[1].toVector<Point2f>());
48  success = find4QuadCornerSubpix(img, corners, region_size);
49  plhs[0] = MxArray(corners);
50  }
51  else
52  mexErrMsgIdAndTxt("mexopencv:error", "Invalid input");
53  if (nlhs > 1)
54  plhs[1] = MxArray(success);
55 }
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
mxArray object wrapper for data conversion and manipulation.
Definition: MxArray.hpp:123
void nargchk(bool cond)
Alias for input/ouput arguments number check.
Definition: mexopencv.hpp:166
Global constant definitions.