mexopencv  0.1
mex interface for opencv library
ellipse2Poly.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<=1);
23 
24  // Argument vector
25  vector<MxArray> rhs(prhs, prhs+nrhs);
26 
27  // Option processing
28  int angle = 0;
29  int arcStart = 0;
30  int arcEnd = 360;
31  int delta = 5;
32  for (int i=2; i<nrhs; i+=2) {
33  string key(rhs[i].toString());
34  if (key=="Angle")
35  angle = rhs[i+1].toInt();
36  else if (key=="StartAngle")
37  arcStart = rhs[i+1].toInt();
38  else if (key=="EndAngle")
39  arcEnd = rhs[i+1].toInt();
40  else if (key=="Delta")
41  delta = rhs[i+1].toInt();
42  else
43  mexErrMsgIdAndTxt("mexopencv:error","Unrecognized option");
44  }
45 
46  // Process
47  Point center(rhs[0].toPoint());
48  Size axes(rhs[1].toSize());
49  vector<Point> pts;
50  ellipse2Poly(center, axes, angle, arcStart, arcEnd, delta, pts);
51  plhs[0] = MxArray(pts);
52 }
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.