9 #include "opencv2/optflow.hpp" 21 void mexFunction(
int nlhs, mxArray *plhs[],
int nrhs,
const mxArray *prhs[])
24 nargchk(nrhs>=2 && (nrhs%2)==0 && nlhs<=1);
27 vector<MxArray> rhs(prhs, prhs+nrhs);
33 bool use_post_proc =
true;
34 float fgs_lambda = 500.0f;
35 float fgs_sigma = 1.5f;
36 for (
int i=2; i<nrhs; i+=2) {
37 string key(rhs[i].toString());
38 if (key ==
"GridStep")
39 grid_step = rhs[i+1].toInt();
42 else if (key ==
"Sigma")
43 sigma = rhs[i+1].toFloat();
44 else if (key ==
"UsePostProcessing")
45 use_post_proc = rhs[i+1].toBool();
46 else if (key ==
"FGSLambda")
47 fgs_lambda = rhs[i+1].toFloat();
48 else if (key ==
"FGSSigma")
49 fgs_sigma = rhs[i+1].toFloat();
51 mexErrMsgIdAndTxt(
"mexopencv:error",
52 "Unrecognized option %s", key.c_str());
56 Mat from(rhs[0].toMat(CV_8U)), to(rhs[1].toMat(CV_8U)), flow;
57 calcOpticalFlowSparseToDense(from, to, flow,
58 grid_step, k, sigma, use_post_proc, fgs_lambda, fgs_sigma);
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.