OpenCV 4.12.0
开源计算机视觉
加载中...
搜索中...
无匹配项
cv::BackgroundSubtractorMOG2 类参考abstract

基于高斯混合模型的背景/前景分割算法更多...

#include <opencv2/video/background_segm.hpp>

cv::BackgroundSubtractorMOG2 协作图

公共成员函数

virtual void apply (InputArray image, OutputArray fgmask, double learningRate=-1) CV_OVERRIDE=0
 计算前景掩码。
 
virtual double getBackgroundRatio () const =0
 返回算法的“背景比率”参数。
 
virtual double getComplexityReductionThreshold () const =0
 返回复杂度降低阈值。
 
virtual bool getDetectShadows () const =0
 返回阴影检测标志。
 
virtual int getHistory () const =0
 返回影响背景模型的最后帧数。
 
virtual int getNMixtures () const =0
 返回背景模型中的高斯分量数量。
 
virtual double getShadowThreshold () const =0
 返回阴影阈值。
 
virtual int getShadowValue () const =0
 返回阴影值。
 
virtual double getVarInit () const =0
 返回每个高斯分量的初始方差。
 
virtual double getVarMax () const =0
 
virtual double getVarMin () const =0
 
virtual double getVarThreshold () const =0
 返回像素-模型匹配的方差阈值。
 
virtual double getVarThresholdGen () const =0
 返回用于生成新混合分量的像素模型匹配的方差阈值。
 
virtual void setBackgroundRatio (double ratio)=0
 设置算法的“背景比率”参数。
 
virtual void setComplexityReductionThreshold (double ct)=0
 设置复杂度降低阈值。
 
virtual void setDetectShadows (bool detectShadows)=0
 启用或禁用阴影检测。
 
virtual void setHistory (int history)=0
 设置影响背景模型的最后帧数。
 
virtual void setNMixtures (int nmixtures)=0
 设置背景模型中的高斯分量数量。
 
virtual void setShadowThreshold (double threshold)=0
 设置阴影阈值。
 
virtual void setShadowValue (int value)=0
 设置阴影值。
 
virtual void setVarInit (double varInit)=0
 设置每个高斯分量的初始方差。
 
virtual void setVarMax (double varMax)=0
 
virtual void setVarMin (double varMin)=0
 
virtual void setVarThreshold (double varThreshold)=0
 设置像素-模型匹配的方差阈值。
 
virtual void setVarThresholdGen (double varThresholdGen)=0
 设置用于生成新混合分量的像素模型匹配的方差阈值。
 
- 从 cv::BackgroundSubtractor 继承的公共成员函数
virtual void getBackgroundImage (OutputArray backgroundImage) const =0
 计算背景图像。
 
- 从 cv::Algorithm 继承的公共成员函数
 Algorithm ()
 
virtual ~Algorithm ()
 
virtual void clear ()
 清除算法状态。
 
virtual bool empty () const
 如果算法为空(例如,在最开始或读取失败后),则返回 true。
 
virtual String getDefaultName () const
 
virtual void read (const FileNode &fn)
 从文件存储中读取算法参数。
 
virtual void save (const String &filename) const
 
void write (const Ptr< FileStorage > &fs, const String &name=String()) const
 
virtual void write (FileStorage &fs) const
 将算法参数存储到文件存储中。
 
void write (FileStorage &fs, const String &name) const
 

附加继承成员

- 从 cv::Algorithm 继承的静态公共成员函数
template<typename _Tp >
static Ptr< _Tpload (const String &filename, const String &objname=String())
 从文件中加载算法。
 
template<typename _Tp >
static Ptr< _TploadFromString (const String &strModel, const String &objname=String())
 从字符串加载算法。
 
template<typename _Tp >
static Ptr< _Tpread (const FileNode &fn)
 从文件节点读取算法。
 
- 从 cv::Algorithm 继承的保护成员函数
void writeFormat (FileStorage &fs) const
 

详细描述

基于高斯混合模型的背景/前景分割算法

该类实现了 [327][326] 中描述的高斯混合模型背景减除算法。

成员函数文档

◆ apply()

virtual void cv::BackgroundSubtractorMOG2::apply ( InputArray image,
OutputArray fgmask,
double learningRate = -1 )
纯虚函数
Python
cv.BackgroundSubtractorMOG2.apply(image[, fgmask[, learningRate]]) -> fgmask

计算前景掩码。

参数
image下一视频帧。浮点帧将不进行缩放使用,其范围应在 \([0,255]\) 内。
fgmask作为 8 位二进制图像的输出前景掩码。
learningRate介于 0 和 1 之间的值,表示背景模型的学习速度。负参数值表示算法将使用自动选择的学习率。0 表示背景模型完全不更新,1 表示背景模型从最后一帧完全重新初始化。

实现 cv::BackgroundSubtractor

◆ getBackgroundRatio()

virtual double cv::BackgroundSubtractorMOG2::getBackgroundRatio ( ) const
纯虚函数
Python
cv.BackgroundSubtractorMOG2.getBackgroundRatio() -> retval

返回算法的“背景比率”参数。

如果一个前景像素在约 backgroundRatio*history 帧内保持半恒定值,则被视为背景,并作为新分量的中心添加到模型中。这对应于论文中的 TB 参数。

◆ getComplexityReductionThreshold()

virtual double cv::BackgroundSubtractorMOG2::getComplexityReductionThreshold ( ) const
纯虚函数
Python
cv.BackgroundSubtractorMOG2.getComplexityReductionThreshold() -> retval

返回复杂度降低阈值。

此参数定义了接受以证明组件存在的样本数量。CT=0.05 是所有样本的默认值。通过设置 CT=0,您将获得与标准 Stauffer&Grimson 算法非常相似的算法。

◆ getDetectShadows()

virtual bool cv::BackgroundSubtractorMOG2::getDetectShadows ( ) const
纯虚函数
Python
cv.BackgroundSubtractorMOG2.getDetectShadows() -> retval

返回阴影检测标志。

如果为 true,算法将检测并标记阴影。详情请参见 createBackgroundSubtractorMOG2。

◆ getHistory()

virtual int cv::BackgroundSubtractorMOG2::getHistory ( ) const
纯虚函数
Python
cv.BackgroundSubtractorMOG2.getHistory() -> retval

返回影响背景模型的最后帧数。

◆ getNMixtures()

virtual int cv::BackgroundSubtractorMOG2::getNMixtures ( ) const
纯虚函数
Python
cv.BackgroundSubtractorMOG2.getNMixtures() -> retval

返回背景模型中的高斯分量数量。

◆ getShadowThreshold()

virtual double cv::BackgroundSubtractorMOG2::getShadowThreshold ( ) const
纯虚函数
Python
cv.BackgroundSubtractorMOG2.getShadowThreshold() -> retval

返回阴影阈值。

如果像素是背景的较暗版本,则检测到阴影。阴影阈值(论文中的 Tau)定义了阴影可以有多暗。Tau=0.5 意味着如果像素暗度超过两倍,则它不是阴影。参见 Prati, Mikic, Trivedi and Cucchiara, Detecting Moving Shadows...*, IEEE PAMI,2003。

◆ getShadowValue()

virtual int cv::BackgroundSubtractorMOG2::getShadowValue ( ) const
纯虚函数
Python
cv.BackgroundSubtractorMOG2.getShadowValue() -> retval

返回阴影值。

阴影值是用于在前景掩码中标记阴影的值。默认值为 127。掩码中的值 0 始终表示背景,255 表示前景。

◆ getVarInit()

virtual double cv::BackgroundSubtractorMOG2::getVarInit ( ) const
纯虚函数
Python
cv.BackgroundSubtractorMOG2.getVarInit() -> retval

返回每个高斯分量的初始方差。

◆ getVarMax()

virtual double cv::BackgroundSubtractorMOG2::getVarMax ( ) const
纯虚函数
Python
cv.BackgroundSubtractorMOG2.getVarMax() -> retval

◆ getVarMin()

virtual double cv::BackgroundSubtractorMOG2::getVarMin ( ) const
纯虚函数
Python
cv.BackgroundSubtractorMOG2.getVarMin() -> retval

◆ getVarThreshold()

virtual double cv::BackgroundSubtractorMOG2::getVarThreshold ( ) const
纯虚函数
Python
cv.BackgroundSubtractorMOG2.getVarThreshold() -> retval

返回像素-模型匹配的方差阈值。

马氏距离平方上的主要阈值,用于判断样本是否被背景模型很好地描述。与论文中的 Cthr 相关。

◆ getVarThresholdGen()

virtual double cv::BackgroundSubtractorMOG2::getVarThresholdGen ( ) const
纯虚函数
Python
cv.BackgroundSubtractorMOG2.getVarThresholdGen() -> retval

返回用于生成新混合分量的像素模型匹配的方差阈值。

马氏距离平方的阈值,用于帮助判断样本何时接近现有分量(对应于论文中的 Tg)。如果像素不接近任何分量,则被视为前景或作为新分量添加。3 sigma => Tg=3*3=9 是默认值。较小的 Tg 值会生成更多分量。较大的 Tg 值可能会导致分量数量较少,但它们可能变得太大。

◆ setBackgroundRatio()

virtual void cv::BackgroundSubtractorMOG2::setBackgroundRatio ( double ratio)
纯虚函数
Python
cv.BackgroundSubtractorMOG2.setBackgroundRatio(ratio) ->

设置算法的“背景比率”参数。

◆ setComplexityReductionThreshold()

virtual void cv::BackgroundSubtractorMOG2::setComplexityReductionThreshold ( double ct)
纯虚函数
Python
cv.BackgroundSubtractorMOG2.setComplexityReductionThreshold(ct) ->

设置复杂度降低阈值。

◆ setDetectShadows()

virtual void cv::BackgroundSubtractorMOG2::setDetectShadows ( bool detectShadows)
纯虚函数
Python
cv.BackgroundSubtractorMOG2.setDetectShadows(detectShadows) ->

启用或禁用阴影检测。

◆ setHistory()

virtual void cv::BackgroundSubtractorMOG2::setHistory ( int history)
纯虚函数
Python
cv.BackgroundSubtractorMOG2.setHistory(history) ->

设置影响背景模型的最后帧数。

◆ setNMixtures()

virtual void cv::BackgroundSubtractorMOG2::setNMixtures ( int nmixtures)
纯虚函数
Python
cv.BackgroundSubtractorMOG2.setNMixtures(nmixtures) ->

设置背景模型中的高斯分量数量。

需要重新初始化模型以保留内存。

◆ setShadowThreshold()

virtual void cv::BackgroundSubtractorMOG2::setShadowThreshold ( double RANSAC参数。它是点到像素中对极线的最大距离,超过此距离的点将被视为异常值,不用于计算最终的基本矩阵。它可以设置为1-3左右,具体取决于点定位的精度、图像分辨率和图像噪声。)
纯虚函数
Python
cv.BackgroundSubtractorMOG2.setShadowThreshold(RANSAC参数。它是点到像素中对极线的最大距离,超过此距离的点将被视为异常值,不用于计算最终的基本矩阵。它可以设置为1-3左右,具体取决于点定位的精度、图像分辨率和图像噪声。) ->

设置阴影阈值。

◆ setShadowValue()

virtual void cv::BackgroundSubtractorMOG2::setShadowValue ( int )
纯虚函数
Python
cv.BackgroundSubtractorMOG2.setShadowValue() ->

设置阴影值。

◆ setVarInit()

virtual void cv::BackgroundSubtractorMOG2::setVarInit ( double varInit)
纯虚函数
Python
cv.BackgroundSubtractorMOG2.setVarInit(varInit) ->

设置每个高斯分量的初始方差。

◆ setVarMax()

virtual void cv::BackgroundSubtractorMOG2::setVarMax ( double varMax)
纯虚函数
Python
cv.BackgroundSubtractorMOG2.setVarMax(varMax) ->

◆ setVarMin()

virtual void cv::BackgroundSubtractorMOG2::setVarMin ( double varMin)
纯虚函数
Python
cv.BackgroundSubtractorMOG2.setVarMin(varMin) ->

◆ setVarThreshold()

virtual void cv::BackgroundSubtractorMOG2::setVarThreshold ( double varThreshold)
纯虚函数
Python
cv.BackgroundSubtractorMOG2.setVarThreshold(varThreshold) ->

设置像素-模型匹配的方差阈值。

◆ setVarThresholdGen()

virtual void cv::BackgroundSubtractorMOG2::setVarThresholdGen ( double varThresholdGen)
纯虚函数
Python
cv.BackgroundSubtractorMOG2.setVarThresholdGen(varThresholdGen) ->

设置用于生成新混合分量的像素模型匹配的方差阈值。


此类的文档生成自以下文件