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);
29 Scalar color(Scalar::all(255));
31 int lineType = cv::LINE_8;
32 vector<Vec4i> hierarchy;
33 int maxLevel = INT_MAX;
35 for (
int i=2; i<nrhs; i+=2) {
36 string key(rhs[i].toString());
37 if (key==
"ContourIdx")
38 contourIdx = rhs[i+1].toInt();
39 else if (key==
"Color")
40 color = rhs[i+1].toScalar();
41 else if (key==
"Thickness")
42 thickness = (rhs[i+1].isChar()) ?
44 else if (key==
"LineType")
45 lineType = (rhs[i+1].isChar()) ?
46 LineType[rhs[i+1].toString()] : rhs[i+1].toInt();
47 else if (key==
"Hierarchy")
49 hierarchy = rhs[i+1].toVector<Vec4i>();
50 else if (key==
"MaxLevel")
51 maxLevel = rhs[i+1].toInt();
52 else if (key==
"Offset")
53 offset = rhs[i+1].toPoint();
55 mexErrMsgIdAndTxt(
"mexopencv:error",
"Unrecognized option");
59 Mat image(rhs[0].toMat());
60 vector<vector<Point> > contours(MxArrayToVectorVectorPoint<int>(rhs[1]));
61 drawContours(image, contours, contourIdx, color, thickness, lineType,
62 hierarchy, maxLevel, offset);
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
const ConstMap< std::string, int > LineType
Line type for drawing.
mxArray object wrapper for data conversion and manipulation.
void nargchk(bool cond)
Alias for input/ouput arguments number check.
const ConstMap< std::string, int > ThicknessType
Thickness type for drawing.
Global constant definitions.