2015-11-28 120 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