35 int id = rhs[0].toInt();
36 string method(rhs[1].toString());
39 if (method ==
"new") {
51 if (method ==
"delete") {
56 else if (method ==
"clear") {
60 else if (method ==
"save") {
62 obj->
save(rhs[2].toString());
64 else if (method ==
"load") {
65 nargchk(nrhs>=3 && (nrhs%2)!=0 && nlhs==0);
67 bool loadFromString =
false;
68 for (
int i=3; i<nrhs; i+=2) {
69 string key(rhs[i].toString());
71 objname = rhs[i+1].toString();
72 else if (key ==
"FromString")
73 loadFromString = rhs[i+1].toBool();
76 "Unrecognized option %s", key.
c_str());
78 obj_[id] = (loadFromString ?
79 Algorithm::loadFromString<FarnebackOpticalFlow>(rhs[2].toString(), objname) :
80 Algorithm::load<FarnebackOpticalFlow>(rhs[2].toString(), objname));
82 else if (method ==
"empty") {
86 else if (method ==
"getDefaultName") {
90 else if (method ==
"calc") {
91 nargchk(nrhs>=4 && (nrhs%2)==0 && nlhs<=1);
93 for (
int i=4; i<nrhs; i+=2) {
94 string key(rhs[i].toString());
95 if (key ==
"InitialFlow")
96 flow = rhs[i+1].toMat(
CV_32F);
99 "Unrecognized option %s", key.
c_str());
103 obj->
calc(I0, I1, flow);
106 else if (method ==
"collectGarbage") {
110 else if (method ==
"get") {
112 string prop(rhs[2].toString());
113 if (prop ==
"NumLevels")
115 else if (prop ==
"PyrScale")
117 else if (prop ==
"FastPyramids")
119 else if (prop ==
"WinSize")
121 else if (prop ==
"NumIters")
123 else if (prop ==
"PolyN")
125 else if (prop ==
"PolySigma")
127 else if (prop ==
"Flags")
131 "Unrecognized property %s", prop.
c_str());
133 else if (method ==
"set") {
135 string prop(rhs[2].toString());
136 if (prop ==
"NumLevels")
138 else if (prop ==
"PyrScale")
140 else if (prop ==
"FastPyramids")
142 else if (prop ==
"WinSize")
144 else if (prop ==
"NumIters")
146 else if (prop ==
"PolyN")
148 else if (prop ==
"PolySigma")
150 else if (prop ==
"Flags")
154 "Unrecognized property %s", prop.
c_str());
158 "Unrecognized operation %s", method.
c_str());
virtual void setFastPyramids(bool fastPyramids)=0
virtual int getPolyN() const=0
virtual double getPyrScale() const=0
virtual void collectGarbage()=0
LIBMWMEX_API_EXTERN_C void mexLock(void)
Lock a MEX-function so that it cannot be cleared from memory.
virtual int getNumLevels() const=0
virtual void setWinSize(int winSize)=0
virtual void setNumLevels(int numLevels)=0
map< int, Ptr< FarnebackOpticalFlow > > obj_
Object container.
int last_id
Last object id to allocate.
struct mxArray_tag mxArray
Forward declaration for mxArray.
virtual double getPolySigma() const=0
virtual void setPolyN(int polyN)=0
virtual void setNumIters(int numIters)=0
virtual void setPyrScale(double pyrScale)=0
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...
LIBMWMEX_API_EXTERN_C void mexUnlock(void)
Unlock a locked MEX-function so that it can be cleared from memory.
mxArray object wrapper for data conversion and manipulation.
void nargchk(bool cond)
Alias for input/output arguments number check.
virtual int getWinSize() const=0
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
virtual void setFlags(int flags)=0
virtual String getDefaultName() const
Global constant definitions.
virtual int getFlags() const=0
virtual void save(const String &filename) const
virtual bool empty() const
virtual void calc(InputArray I0, InputArray I1, InputOutputArray flow)=0
virtual void setPolySigma(double polySigma)=0
void create(int arows, int acols, int atype, Target target=ARRAY_BUFFER, bool autoRelease=false)
virtual int getNumIters() const=0
virtual bool getFastPyramids() const=0