mexopencv  0.1
mex interface for opencv library
calcOpticalFlowDF.cpp
Go to the documentation of this file.
1 
8 #include "mexopencv.hpp"
9 #include "opencv2/video.hpp"
10 #include "opencv2/optflow.hpp"
11 using namespace std;
12 using namespace cv;
13 using namespace cv::optflow;
14 
22 void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
23 {
24  // Check the number of arguments
25  nargchk(nrhs==2 && nlhs<=1);
26 
27  // Argument vector
28  vector<MxArray> rhs(prhs, prhs+nrhs);
29 
30  // Process
31  Mat from(rhs[0].toMat(CV_8U)), to(rhs[1].toMat(CV_8U)), flow;
32  Ptr<DenseOpticalFlow> p = createOptFlow_DeepFlow();
33  if (p.empty())
34  mexErrMsgIdAndTxt("mexopencv:error",
35  "Failed to create OpticalFlowDeepFlow");
36  p->calc(from, to, flow);
37  plhs[0] = MxArray(flow);
38 }
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
mxArray object wrapper for data conversion and manipulation.
Definition: MxArray.hpp:123
void nargchk(bool cond)
Alias for input/ouput arguments number check.
Definition: mexopencv.hpp:166
Global constant definitions.