19 void mexFunction(
int nlhs, mxArray *plhs[],
int nrhs,
const mxArray *prhs[])
25 vector<MxArray> rhs(prhs, prhs+nrhs);
28 bool diff_variant = (nrhs>1 && rhs[1].isNumeric());
29 nargchk((nrhs%2) == (diff_variant ? 0 : 1));
32 int normType = cv::NORM_L2;
33 bool relative =
false;
35 for (
int i=(diff_variant ? 2 : 1); i<nrhs; i+=2) {
36 string key(rhs[i].toString());
37 if (key ==
"NormType")
38 normType =
NormType[rhs[i+1].toString()];
39 else if (key ==
"Relative")
40 relative = rhs[i+1].toBool();
41 else if (key ==
"Mask")
42 mask = rhs[i+1].toMat(CV_8U);
44 mexErrMsgIdAndTxt(
"mexopencv:error",
45 "Unrecognized option %s", key.c_str());
47 normType |= (relative ? cv::NORM_RELATIVE : 0);
51 Mat src1(rhs[0].toMat());
53 Mat src2(rhs[1].toMat());
54 nrm = norm(src1, src2, normType, mask);
57 nrm = norm(src1, normType, mask);
mxArray object wrapper for data conversion and manipulation.
void nargchk(bool cond)
Alias for input/ouput arguments number check.
Global constant definitions.
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
const ConstMap< std::string, int > NormType
Norm type map for option processing.