black
black

Reputation: 1241

OpenCV Background Substraction c++

I've create a background Subsctractor (MOG) and now, I want to change some parameters:

Ptr< BackgroundSubtractor> pMOG, pMOG2;
pMOG = new BackgroundSubtractorMOG();
pMOG.set("varThreshold",5); //does't work
pMOG->operator()(inputImage, outputImage); //works, but the output is not enought "sensitive"

Has anyone an idea how I could deal with this? I want to change the threshold value, because it returns an mask, that does not always detect my moving objects (e.g. if their color is nearly the backgrounds color).

Thanks!

Upvotes: 3

Views: 450

Answers (1)

Miki
Miki

Reputation: 41765

That's because BackgroundSubtractorMOG doesn't have a parameter named varThreshold. You probably wanted to set this parameter on BackgroundSubtractorMOG2.

The parameters for BackgroundSubtractorMOG are:

"history"
"nmixtures"
"backgroundRatio"
"noiseSigma"

while for BackgroundSubtractorMOG2 are:

"history"
"nmixtures"
"varThreshold"
"detectShadows"
"backgroundRatio"
"varThresholdGen"
"fVarInit"
"fVarMin"
"fVarMax"
"fCT"
"nShadowDetection"
"fTau"

You can find these info in video_init.cpp (checked for OpenCV version 2.4.9).


You can also set some parameters directly into the constructor, which is probably the safest way.

Upvotes: 2

Related Questions