15 (
"InitWithRect", cv::GC_INIT_WITH_RECT)
16 (
"InitWithMask", cv::GC_INIT_WITH_MASK)
17 (
"Eval", cv::GC_EVAL);
27 void mexFunction(
int nlhs, mxArray *plhs[],
int nrhs,
const mxArray *prhs[])
30 nargchk(nrhs>=2 && (nrhs%2)==0 && nlhs<=3);
33 vector<MxArray> rhs(prhs, prhs+nrhs);
34 bool rect_variant = (rhs[1].numel() == 4 &&
35 (rhs[1].rows()==1 || rhs[1].cols()==1));
38 Mat bgdModel, fgdModel;
40 int mode = cv::GC_EVAL;
41 for (
int i=2; i<nrhs; i+=2) {
42 string key(rhs[i].toString());
44 bgdModel = rhs[i+1].toMat(CV_64F);
45 else if (key==
"FgdModel")
46 fgdModel = rhs[i+1].toMat(CV_64F);
47 else if (key==
"IterCount")
48 iterCount = rhs[i+1].toInt();
50 mode = GrabCutType[rhs[i+1].toString()];
52 mexErrMsgIdAndTxt(
"mexopencv:error",
"Unrecognized option");
59 rect = rhs[1].toRect();
60 mode = cv::GC_INIT_WITH_RECT;
63 mask = rhs[1].toMat(CV_8U);
66 Mat img(rhs[0].toMat(CV_8U));
67 grabCut(img, mask, rect, bgdModel, fgdModel, iterCount, mode);
mxArray object wrapper for data conversion and manipulation.
void nargchk(bool cond)
Alias for input/ouput arguments number check.
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
Global constant definitions.
std::map wrapper with one-line initialization and lookup method.