23 nargchk(nrhs>=2 && (nrhs%2)==0 && nlhs<=3);
32 for (
int i=2; i<nrhs; i+=2) {
33 string key(rhs[i].toString());
34 if (key ==
"DistType")
35 distType = (rhs[i+1].isChar()) ?
36 DistType[rhs[i+1].toString()] : rhs[i+1].toInt();
37 else if (key ==
"Cost")
38 cost = rhs[i+1].toMat(
CV_32F);
39 else if (key ==
"LowerBound")
40 lowerBound = rhs[i+1].toFloat();
43 "Unrecognized option %s", key.
c_str());
47 "In case of user-defined distance, cost matrix must be defined");
53 float emd =
EMD(signature1, signature2, distType, cost,
54 (nlhs>1 && cost.
empty() ? &lowerBound : NULL),
struct mxArray_tag mxArray
Forward declaration for mxArray.
InputOutputArray noArray()
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
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.
const ConstMap< std::string, int > DistType
Distance types for Distance Transform and M-estimators.
Global constant definitions.
float EMD(InputArray signature1, InputArray signature2, int distType, InputArray cost=noArray(), float *lowerBound=0, OutputArray flow=noArray())