36 int id = rhs[0].toInt();
37 string method(rhs[1].toString());
40 if (method ==
"new") {
41 nargchk(nrhs>=2 && (nrhs%2)==0 && nlhs<=1);
43 Size basisSize(18,14);
44 float sparseRate = 0.024f;
45 float retainedCornersFraction = 0.2f;
46 float occlusionsThreshold = 0.0003f;
47 float dampingFactor = 0.00002f;
49 for (
int i=2; i<nrhs; i+=2) {
50 string key(rhs[i].toString());
52 pathToPrior = rhs[i+1].toString();
53 else if (key ==
"BasisSize")
54 basisSize = rhs[i+1].toSize();
55 else if (key ==
"SparseRate")
56 sparseRate = rhs[i+1].toFloat();
57 else if (key ==
"RetainedCornersFraction")
58 retainedCornersFraction = rhs[i+1].toFloat();
59 else if (key ==
"OcclusionsThreshold")
60 occlusionsThreshold = rhs[i+1].toFloat();
61 else if (key ==
"DampingFactor")
62 dampingFactor = rhs[i+1].toFloat();
63 else if (key ==
"ClaheClip")
64 claheClip = rhs[i+1].toFloat();
67 "Unrecognized option %s", key.
c_str());
70 if (!pathToPrior.
empty())
71 prior = makePtr<PCAPrior>(pathToPrior.
c_str());
72 obj_[++
last_id] = makePtr<OpticalFlowPCAFlow>(prior, basisSize,
73 sparseRate, retainedCornersFraction, occlusionsThreshold,
74 dampingFactor, claheClip);
85 if (method ==
"delete") {
90 else if (method ==
"clear") {
94 else if (method ==
"save") {
96 obj->
save(rhs[2].toString());
98 else if (method ==
"load") {
99 nargchk(nrhs>=3 && (nrhs%2)!=0 && nlhs==0);
101 bool loadFromString =
false;
102 for (
int i=3; i<nrhs; i+=2) {
103 string key(rhs[i].toString());
104 if (key ==
"ObjName")
105 objname = rhs[i+1].toString();
106 else if (key ==
"FromString")
107 loadFromString = rhs[i+1].toBool();
110 "Unrecognized option %s", key.
c_str());
119 FileStorage fs(rhs[2].toString(), FileStorage::READ +
120 (loadFromString ? FileStorage::MEMORY : 0));
129 else if (method ==
"empty") {
133 else if (method ==
"getDefaultName") {
137 else if (method ==
"calc") {
138 nargchk(nrhs>=4 && (nrhs%2)==0 && nlhs<=1);
140 for (
int i=4; i<nrhs; i+=2) {
141 string key(rhs[i].toString());
142 if (key ==
"InitialFlow")
143 flow = rhs[i+1].toMat(
CV_32F);
146 "Unrecognized option %s", key.
c_str());
150 obj->
calc(I0, I1, flow);
153 else if (method ==
"collectGarbage") {
159 "Unrecognized operation %s", method.
c_str());
map< int, Ptr< OpticalFlowPCAFlow > > obj_
Object container.
LIBMWMEX_API_EXTERN_C void mexLock(void)
Lock a MEX-function so that it cannot be cleared from memory.
int last_id
Last object id to allocate.
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
virtual bool isOpened() const
struct mxArray_tag mxArray
Forward declaration for mxArray.
virtual void read(const FileNode &fn)
void calc(InputArray I0, InputArray I1, InputOutputArray flow)
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.
FileNode getFirstTopLevelNode() const
virtual String getDefaultName() const
Global constant definitions.
virtual void save(const String &filename) const
virtual bool empty() const