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);
55 float Rincdec = 0.005f;
56 float noiseRemovalThresholdFacBG = 0.0004f;
57 float noiseRemovalThresholdFacFG = 0.0008f;
58 int LSBPthreshold = 8;
60 for (
int i=2; i<nrhs; i+=2) {
61 string key(rhs[i].toString());
62 if (key ==
"MotionCompensation")
64 else if (key ==
"NSamples")
65 nSamples = rhs[i+1].toInt();
66 else if (key ==
"LSBPRadius")
67 LSBPRadius = rhs[i+1].toInt();
68 else if (key ==
"TLower")
69 Tlower = rhs[i+1].toFloat();
70 else if (key ==
"TUpper")
71 Tupper = rhs[i+1].toFloat();
72 else if (key ==
"TInc")
73 Tinc = rhs[i+1].toFloat();
74 else if (key ==
"TDec")
75 Tdec = rhs[i+1].toFloat();
76 else if (key ==
"RScale")
77 Rscale = rhs[i+1].toFloat();
78 else if (key ==
"RIncDec")
79 Rincdec = rhs[i+1].toFloat();
80 else if (key ==
"NoiseRemovalThresholdFacBG")
81 noiseRemovalThresholdFacBG = rhs[i+1].toFloat();
82 else if (key ==
"NoiseRemovalThresholdFacFG")
83 noiseRemovalThresholdFacFG = rhs[i+1].toFloat();
84 else if (key ==
"LSBPThreshold")
85 LSBPthreshold = rhs[i+1].toInt();
86 else if (key ==
"MinCount")
87 minCount = rhs[i+1].toInt();
90 "Unrecognized option %s", key.
c_str());
93 LSBPRadius, Tlower, Tupper, Tinc, Tdec, Rscale, Rincdec,
94 noiseRemovalThresholdFacBG, noiseRemovalThresholdFacFG,
95 LSBPthreshold, minCount);
101 else if (method ==
"computeLSBPDesc") {
106 if (LSBPSamplePoints.
size() != 32)
108 BackgroundSubtractorLSBPDesc::compute(desc, frame, &LSBPSamplePoints[0]);
117 if (method ==
"delete") {
122 else if (method ==
"clear") {
126 else if (method ==
"save") {
128 obj->
save(rhs[2].toString());
130 else if (method ==
"load") {
131 nargchk(nrhs>=3 && (nrhs%2)==1 && nlhs==0);
133 bool loadFromString =
false;
134 for (
int i=3; i<nrhs; i+=2) {
135 string key(rhs[i].toString());
136 if (key ==
"ObjName")
137 objname = rhs[i+1].toString();
138 else if (key ==
"FromString")
139 loadFromString = rhs[i+1].toBool();
142 "Unrecognized option %s", key.
c_str());
151 FileStorage fs(rhs[2].toString(), FileStorage::READ +
152 (loadFromString ? FileStorage::MEMORY : 0));
161 else if (method ==
"empty") {
165 else if (method ==
"getDefaultName") {
169 else if (method ==
"apply") {
170 nargchk(nrhs>=3 && (nrhs%2)==1 && nlhs<=1);
171 double learningRate = -1;
172 for (
int i=3; i<nrhs; i+=2) {
173 string key(rhs[i].toString());
174 if (key ==
"LearningRate")
175 learningRate = rhs[i+1].toDouble();
178 "Unrecognized option %s", key.
c_str());
182 obj->
apply(image, fgmask, learningRate);
185 else if (method ==
"getBackgroundImage") {
189 plhs[0] =
MxArray(backgroundImage);
193 "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 bool isOpened() const
struct mxArray_tag mxArray
Forward declaration for mxArray.
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
const ConstMap< string, int > MotionCompensationsMap
motion compensation types for option processing
virtual void read(const FileNode &fn)
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< BackgroundSubtractorLSBP > createBackgroundSubtractorLSBP(int mc=LSBP_CAMERA_MOTION_COMPENSATION_NONE, int nSamples=20, int LSBPRadius=16, float Tlower=2.0f, float Tupper=32.0f, float Tinc=1.0f, float Tdec=0.05f, float Rscale=10.0f, float Rincdec=0.005f, float noiseRemovalThresholdFacBG=0.0004f, float noiseRemovalThresholdFacFG=0.0008f, int LSBPthreshold=8, int minCount=2)
LSBP_CAMERA_MOTION_COMPENSATION_NONE
LSBP_CAMERA_MOTION_COMPENSATION_LK
virtual void apply(InputArray image, OutputArray fgmask, double learningRate=-1)=0
virtual void save(const String &filename) const
virtual bool empty() const
virtual void getBackgroundImage(OutputArray backgroundImage) const=0
std::map wrapper with one-line initialization and lookup method.
map< int, Ptr< BackgroundSubtractorLSBP > > obj_
Object container.
int last_id
Last object id to allocate.