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);
42 int minPixelStability = 15;
43 int maxPixelStability = 15*60;
44 bool useHistory =
true;
45 bool isParallel =
true;
46 for (
int i=2; i<nrhs; i+=2) {
47 string key(rhs[i].toString());
48 if (key ==
"MinPixelStability")
49 minPixelStability = rhs[i+1].toInt();
50 else if (key ==
"MaxPixelStability")
51 maxPixelStability = rhs[i+1].toInt();
52 else if (key ==
"UseHistory")
53 useHistory = rhs[i+1].toBool();
54 else if (key ==
"IsParallel")
55 isParallel = rhs[i+1].toBool();
58 "Unrecognized option %s", key.
c_str());
61 minPixelStability, maxPixelStability, useHistory, isParallel);
71 if (method ==
"delete") {
76 else if (method ==
"clear") {
80 else if (method ==
"save") {
82 obj->
save(rhs[2].toString());
84 else if (method ==
"load") {
85 nargchk(nrhs>=3 && (nrhs%2)==1 && nlhs==0);
87 bool loadFromString =
false;
88 for (
int i=3; i<nrhs; i+=2) {
89 string key(rhs[i].toString());
91 objname = rhs[i+1].toString();
92 else if (key ==
"FromString")
93 loadFromString = rhs[i+1].toBool();
96 "Unrecognized option %s", key.
c_str());
105 FileStorage fs(rhs[2].toString(), FileStorage::READ +
106 (loadFromString ? FileStorage::MEMORY : 0));
115 else if (method ==
"empty") {
119 else if (method ==
"getDefaultName") {
123 else if (method ==
"apply") {
124 nargchk(nrhs>=3 && (nrhs%2)==1 && nlhs<=1);
125 double learningRate = -1;
126 for (
int i=3; i<nrhs; i+=2) {
127 string key(rhs[i].toString());
128 if (key ==
"LearningRate")
129 learningRate = rhs[i+1].toDouble();
132 "Unrecognized option %s", key.
c_str());
135 obj->
apply(image, fgmask, learningRate);
138 else if (method ==
"getBackgroundImage") {
142 plhs[0] =
MxArray(backgroundImage);
144 else if (method ==
"get") {
146 string prop(rhs[2].toString());
147 if (prop ==
"MinPixelStability")
149 else if (prop ==
"MaxPixelStability")
151 else if (prop ==
"UseHistory")
153 else if (prop ==
"IsParallel")
157 "Unrecognized property %s", prop.
c_str());
159 else if (method ==
"set") {
161 string prop(rhs[2].toString());
162 if (prop ==
"MinPixelStability")
164 else if (prop ==
"MaxPixelStability")
166 else if (prop ==
"UseHistory")
168 else if (prop ==
"IsParallel")
172 "Unrecognized property %s", prop.
c_str());
176 "Unrecognized operation %s", method.
c_str());
LIBMWMEX_API_EXTERN_C void mexLock(void)
Lock a MEX-function so that it cannot be cleared from memory.
virtual void getBackgroundImage(OutputArray backgroundImage) const=0
map< int, Ptr< BackgroundSubtractorCNT > > obj_
Object container.
virtual bool getIsParallel() const=0
int last_id
Last object id to allocate.
Ptr< BackgroundSubtractorCNT > createBackgroundSubtractorCNT(int minPixelStability=15, bool useHistory=true, int maxPixelStability=15 *60, bool isParallel=true)
virtual bool isOpened() const
struct mxArray_tag mxArray
Forward declaration for mxArray.
virtual void setMaxPixelStability(int value)=0
virtual void read(const FileNode &fn)
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
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...
virtual void apply(InputArray image, OutputArray fgmask, double learningRate=-1)=0
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 void setUseHistory(bool value)=0
virtual int getMaxPixelStability() const=0
virtual String getDefaultName() const
Global constant definitions.
virtual void save(const String &filename) const
virtual bool empty() const
virtual void setIsParallel(bool value)=0
virtual int getMinPixelStability() const=0
virtual void setMinPixelStability(int value)=0
virtual bool getUseHistory() const=0