3

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!

black
  • 1,151
  • 3
  • 18
  • 46

1 Answers1

2

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.

Miki
  • 40,887
  • 13
  • 123
  • 202
  • Thanks! Could you write an example line how to change an value (e.g. noiseSigma) and which command to use? `pMog.set` does not work. Maybe it's because of the ? – black Nov 29 '15 at 14:53