31 nargchk(nrhs>=2 && (nrhs%2)==0 && nlhs<=3);
35 bool rect_variant = (rhs[1].numel() == 4 &&
36 (rhs[1].rows()==1 || rhs[1].cols()==1));
39 Mat bgdModel, fgdModel;
42 for (
int i=2; i<nrhs; i+=2) {
43 string key(rhs[i].toString());
44 if (key ==
"BgdModel")
45 bgdModel = rhs[i+1].toMat(
CV_64F);
46 else if (key ==
"FgdModel")
47 fgdModel = rhs[i+1].toMat(
CV_64F);
48 else if (key ==
"IterCount")
49 iterCount = rhs[i+1].toInt();
50 else if (key ==
"Mode")
54 "Unrecognized option %s", key.
c_str());
61 rect = rhs[1].toRect();
65 mask = rhs[1].toMat(
CV_8U);
69 grabCut(img, mask, rect, bgdModel, fgdModel, iterCount, mode);
const ConstMap< string, int > GrabCutType
GrabCut algorithm types for option processing.
struct mxArray_tag mxArray
Forward declaration for mxArray.
void grabCut(InputArray img, InputOutputArray mask, Rect rect, InputOutputArray bgdModel, InputOutputArray fgdModel, int iterCount, int mode=GC_EVAL)
LIBMWMEX_API_EXTERN_C void mexErrMsgIdAndTxt(const char *identifier, const char *err_msg,...)
Issue formatted error message with corresponding error identifier and return to MATLAB prompt...
mxArray object wrapper for data conversion and manipulation.
void nargchk(bool cond)
Alias for input/output 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.