15 (
"External", cv::RETR_EXTERNAL)
16 (
"List", cv::RETR_LIST)
17 (
"CComp", cv::RETR_CCOMP)
18 (
"Tree", cv::RETR_TREE)
19 (
"FloodFill", cv::RETR_FLOODFILL);
23 (
"None", cv::CHAIN_APPROX_NONE)
24 (
"Simple", cv::CHAIN_APPROX_SIMPLE)
25 (
"TC89_L1", cv::CHAIN_APPROX_TC89_L1)
26 (
"TC89_KCOS", cv::CHAIN_APPROX_TC89_KCOS);
36 void mexFunction(
int nlhs, mxArray *plhs[],
int nrhs,
const mxArray *prhs[])
39 nargchk(nrhs>=1 && (nrhs%2)==1 && nlhs<=2);
42 vector<MxArray> rhs(prhs, prhs+nrhs);
45 int mode = cv::RETR_EXTERNAL;
46 int method = cv::CHAIN_APPROX_NONE;
48 for (
int i=1; i<nrhs; i+=2) {
49 string key(rhs[i].toString());
51 mode = ContourMode[rhs[i+1].toString()];
52 else if (key==
"Method")
53 method = ContourType[rhs[i+1].toString()];
54 else if (key==
"Offset")
55 offset = rhs[i+1].toPoint();
57 mexErrMsgIdAndTxt(
"mexopencv:error",
"Unrecognized option");
61 Mat image(rhs[0].toMat(rhs[0].isInt32() ? CV_32S : CV_8U));
62 vector<vector<Point> > contours;
63 vector<Vec4i> hierarchy;
64 findContours(image, contours, ((nlhs>1) ? hierarchy : noArray()),
65 mode, method, offset);
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.
std::map wrapper with one-line initialization and lookup method.