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<SparsePyrLKOpticalFlow>(rhs[2].toString(), objname) :
80 Algorithm::load<SparsePyrLKOpticalFlow>(rhs[2].toString(), objname));
82 else if (method ==
"empty") {
86 else if (method ==
"getDefaultName") {
90 else if (method ==
"calc") {
91 nargchk(nrhs>=5 && (nrhs%2)==1 && nlhs<=3);
93 for (
int i=5; i<nrhs; i+=2) {
94 string key(rhs[i].toString());
95 if (key ==
"InitialFlow")
96 nextPts = rhs[i+1].toVector<
Point2f>();
99 "Unrecognized option %s", key.
c_str());
105 obj->
calc(prevImg, nextImg, prevPts, nextPts, status,
113 else if (method ==
"get") {
115 string prop(rhs[2].toString());
116 if (prop ==
"WinSize")
118 else if (prop ==
"MaxLevel")
120 else if (prop ==
"TermCriteria")
122 else if (prop ==
"Flags")
124 else if (prop ==
"MinEigThreshold")
128 "Unrecognized property %s", prop.
c_str());
130 else if (method ==
"set") {
132 string prop(rhs[2].toString());
133 if (prop ==
"WinSize")
135 else if (prop ==
"MaxLevel")
137 else if (prop ==
"TermCriteria") {
144 else if (prop ==
"Flags")
146 else if (prop ==
"MinEigThreshold")
150 "Unrecognized property %s", prop.
c_str());
154 "Unrecognized operation %s", method.
c_str());
virtual Size getWinSize() const=0
virtual int getMaxLevel() const=0
LIBMWMEX_API_EXTERN_C void mexLock(void)
Lock a MEX-function so that it cannot be cleared from memory.
virtual void calc(InputArray prevImg, InputArray nextImg, InputArray prevPts, InputOutputArray nextPts, OutputArray status, OutputArray err=cv::noArray())=0
virtual void setTermCriteria(TermCriteria &crit)=0
virtual double getMinEigThreshold() const=0
struct mxArray_tag mxArray
Forward declaration for mxArray.
virtual void setMinEigThreshold(double minEigThreshold)=0
int last_id
Last object id to allocate.
InputOutputArray noArray()
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.
virtual int getFlags() const=0
mxArray object wrapper for data conversion and manipulation.
void nargchk(bool cond)
Alias for input/output arguments number check.
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
map< int, Ptr< SparsePyrLKOpticalFlow > > obj_
Object container.
virtual TermCriteria getTermCriteria() const=0
virtual void setWinSize(Size winSize)=0
virtual void setFlags(int flags)=0
virtual String getDefaultName() const
Global constant definitions.
virtual void save(const String &filename) const
virtual bool empty() const
virtual void setMaxLevel(int maxLevel)=0
void create(int arows, int acols, int atype, Target target=ARRAY_BUFFER, bool autoRelease=false)