2015-11-28 117 views
3

我已经创建背景Subsctractor(MOG),现在,我想改变一些参数:OpenCV的背景减法C++

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" 

有没有人一个想法如何,我可以解决这个问题?我想更改阈值,因为它会返回一个遮罩,但它并不总能检测到我的移动对象(例如,如果它们的颜色几乎是背景颜色)。

谢谢!

回答

2

这是因为BackgroundSubtractorMOG没有名为varThreshold的参数。您可能想要在BackgroundSubtractorMOG2上设置此参数。

BackgroundSubtractorMOG的参数是:

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

BackgroundSubtractorMOG2是:

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

你可以找到video_init.cpp这些信息(检查OpenCV的版本2.4.9)。


您也可以直接在构造函数中设置一些参数,这可能是最安全的方法。

+0

谢谢!你能写一个例子如何改变一个值(例如noiseSigma)和使用哪个命令? 'pMog.set'不起作用。也许是因为? – black

+0

'pMog-> set(...)' – Miki