19 void mexFunction(
int nlhs, mxArray *plhs[],
int nrhs,
const mxArray *prhs[])
22 nargchk(nrhs>=1 && (nrhs%2)!=0 && nlhs<=2);
25 vector<MxArray> rhs(prhs, prhs+nrhs);
30 bool withDerivatives =
true;
31 int pyrBorder = cv::BORDER_REFLECT_101;
32 int derivBorder = cv::BORDER_CONSTANT;
33 bool tryReuseInputImage =
true;
34 for (
int i=1; i<nrhs; i+=2) {
35 string key(rhs[i].toString());
37 winSize = rhs[i+1].toSize();
38 else if (key ==
"MaxLevel")
39 maxLevel = rhs[i+1].toInt();
40 else if (key ==
"WithDerivatives")
41 withDerivatives = rhs[i+1].toBool();
42 else if (key ==
"PyrBorder")
43 pyrBorder = (rhs[i+1].isChar()) ?
44 BorderType[rhs[i+1].toString()] : rhs[i+1].toInt();
45 else if (key ==
"DerivBorder")
46 derivBorder = (rhs[i+1].isChar()) ?
47 BorderType[rhs[i+1].toString()] : rhs[i+1].toInt();
48 else if (key ==
"TryReuseInputImage")
49 tryReuseInputImage = rhs[i+1].toBool();
51 mexErrMsgIdAndTxt(
"mexopencv:error",
52 "Unrecognized option %s", key.c_str());
56 Mat img(rhs[0].toMat(CV_8U));
58 int maxLvl = buildOpticalFlowPyramid(img, pyramid, winSize, maxLevel,
59 withDerivatives, pyrBorder, derivBorder, tryReuseInputImage);
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
const ConstMap< std::string, int > BorderType
Border type map for option processing.
mxArray object wrapper for data conversion and manipulation.
void nargchk(bool cond)
Alias for input/ouput arguments number check.
Global constant definitions.