OpenCV背景减法C++

3

我创建了一个背景减法器(MOG),现在我想更改一些参数:

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"

有人知道我应该如何处理这个问题吗?我想要更改阈值,因为它返回一个掩码,不能总是检测到我移动的对象(例如,如果它们的颜色接近背景颜色)。

谢谢!

1个回答

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进行检查)。


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


谢谢!你能写一行示例代码来改变一个值(例如noiseSigma),并说明使用哪个命令吗?pMog.set不起作用。也许是因为<Ptr>的缘故? - black

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接