简体   繁体   中英

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 (eg if their color is nearly the backgrounds color).

Thanks!

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM