mexopencv  0.1
mex interface for opencv library
minEnclosingCircle.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==1 && nlhs<=2);
23 
24  // Argument vector
25  vector<MxArray> rhs(prhs, prhs+nrhs);
26 
27  // Process
28  Point2f center;
29  float radius = 0;
30  if (rhs[0].isNumeric()) {
31  Mat points(rhs[0].toMat(rhs[0].isInt32() ? CV_32S : CV_32F));
32  minEnclosingCircle(points, center, radius);
33  }
34  else if (rhs[0].isCell()) {
35  vector<Point2f> points(rhs[0].toVector<Point2f>());
36  minEnclosingCircle(points, center, radius);
37  }
38  else
39  mexErrMsgIdAndTxt("mexopencv:error","Invalid argument");
40  plhs[0] = MxArray(center);
41  if (nlhs>1)
42  plhs[1] = MxArray(radius);
43 }
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
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
Global constant definitions.