41 int id = rhs[0].toInt();
42 string method(rhs[1].toString());
45 if (method ==
"new") {
46 nargchk(nrhs>=2 && (nrhs%2)==0 && nlhs<=1);
49 float replaceRate = 0.003f;
50 float propagationRate = 0.01f;
51 int hitsThreshold = 32;
54 float blinkingSupressionDecay = 0.1f;
55 float blinkingSupressionMultiplier = 0.1f;
56 float noiseRemovalThresholdFacBG = 0.0004f;
57 float noiseRemovalThresholdFacFG = 0.0008f;
58 for (
int i=2; i<nrhs; i+=2) {
59 string key(rhs[i].toString());
60 if (key ==
"MotionCompensation")
62 else if (key ==
"NSamples")
63 nSamples = rhs[i+1].toInt();
64 else if (key ==
"ReplaceRate")
65 replaceRate = rhs[i+1].toFloat();
66 else if (key ==
"PropagationRate")
67 propagationRate = rhs[i+1].toFloat();
68 else if (key ==
"HitsThreshold")
69 hitsThreshold = rhs[i+1].toInt();
70 else if (key ==
"Alpha")
71 alpha = rhs[i+1].toFloat();
72 else if (key ==
"Beta")
73 beta = rhs[i+1].toFloat();
74 else if (key ==
"BlinkingSupressionDecay")
75 blinkingSupressionDecay = rhs[i+1].toFloat();
76 else if (key ==
"BlinkingSupressionMultiplier")
77 blinkingSupressionMultiplier = rhs[i+1].toFloat();
78 else if (key ==
"NoiseRemovalThresholdFacBG")
79 noiseRemovalThresholdFacBG = rhs[i+1].toFloat();
80 else if (key ==
"NoiseRemovalThresholdFacFG")
81 noiseRemovalThresholdFacFG = rhs[i+1].toFloat();
84 "Unrecognized option %s", key.
c_str());
87 replaceRate, propagationRate, hitsThreshold, alpha, beta,
88 blinkingSupressionDecay, blinkingSupressionMultiplier,
89 noiseRemovalThresholdFacBG, noiseRemovalThresholdFacFG);
99 if (method ==
"delete") {
104 else if (method ==
"clear") {
108 else if (method ==
"save") {
110 obj->
save(rhs[2].toString());
112 else if (method ==
"load") {
113 nargchk(nrhs>=3 && (nrhs%2)==1 && nlhs==0);
115 bool loadFromString =
false;
116 for (
int i=3; i<nrhs; i+=2) {
117 string key(rhs[i].toString());
118 if (key ==
"ObjName")
119 objname = rhs[i+1].toString();
120 else if (key ==
"FromString")
121 loadFromString = rhs[i+1].toBool();
124 "Unrecognized option %s", key.
c_str());
133 FileStorage fs(rhs[2].toString(), FileStorage::READ +
134 (loadFromString ? FileStorage::MEMORY : 0));
143 else if (method ==
"empty") {
147 else if (method ==
"getDefaultName") {
151 else if (method ==
"apply") {
152 nargchk(nrhs>=3 && (nrhs%2)==1 && nlhs<=1);
153 double learningRate = -1;
154 for (
int i=3; i<nrhs; i+=2) {
155 string key(rhs[i].toString());
156 if (key ==
"LearningRate")
157 learningRate = rhs[i+1].toDouble();
160 "Unrecognized option %s", key.
c_str());
164 obj->
apply(image, fgmask, learningRate);
167 else if (method ==
"getBackgroundImage") {
171 plhs[0] =
MxArray(backgroundImage);
175 "Unrecognized operation %s", method.
c_str());
map< int, Ptr< BackgroundSubtractorGSOC > > obj_
Object container.
virtual void apply(InputArray image, OutputArray fgmask, double learningRate=-1)=0
LIBMWMEX_API_EXTERN_C void mexLock(void)
Lock a MEX-function so that it cannot be cleared from memory.
virtual bool isOpened() const
struct mxArray_tag mxArray
Forward declaration for mxArray.
int last_id
Last object id to allocate.
const ConstMap< string, int > MotionCompensationsMap
motion compensation types for option processing
virtual void read(const FileNode &fn)
virtual void getBackgroundImage(OutputArray backgroundImage) const=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.
FileNode getFirstTopLevelNode() const
virtual String getDefaultName() const
Global constant definitions.
Ptr< BackgroundSubtractorGSOC > createBackgroundSubtractorGSOC(int mc=LSBP_CAMERA_MOTION_COMPENSATION_NONE, int nSamples=20, float replaceRate=0.003f, float propagationRate=0.01f, int hitsThreshold=32, float alpha=0.01f, float beta=0.0022f, float blinkingSupressionDecay=0.1f, float blinkingSupressionMultiplier=0.1f, float noiseRemovalThresholdFacBG=0.0004f, float noiseRemovalThresholdFacFG=0.0008f)
LSBP_CAMERA_MOTION_COMPENSATION_NONE
LSBP_CAMERA_MOTION_COMPENSATION_LK
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
virtual void save(const String &filename) const
virtual bool empty() const
std::map wrapper with one-line initialization and lookup method.