当前位置: 代码迷 >> 综合 >> opencv BackgroundSubtractorMOG2重要方法
  详细解决方案

opencv BackgroundSubtractorMOG2重要方法

热度:8   发布时间:2024-01-20 09:56:21.0

BackgroundSubtractorMOG2 重要方法

1. BackgroundSubtractorMOG2 的构造函数

    C++: BackgroundSubtractorMOG2::BackgroundSubtractorMOG2()

  采用默认值进行构造BackgroundSubtractorMOG2的对象。

   C++: BackgroundSubtractorMOG2:: BackgroundSubtractorMOG2(int history, float varThreshold, bool bShadowDetection=true)

    采用指定值进行构造BackgroundSubtractorMOG2的对象。

    参数说明:  

Parameters:
  • history – Length of the history.
  • varThreshold – Threshold on the squared Mahalanobis distance to decide whether it is well described by the background model (see Cthr??). This parameter does not affect the background update. A typical value could be 4 sigma, that is, varThreshold=4*4=16; (see Tb??).
  • bShadowDetection – Parameter defining whether shadow detection should be enabled (true or false).

 

 

2. BackgroundSubtractorMOG2 的operate

    C++: void BackgroundSubtractorMOG2::operator()(InputArray image, OutputArray fgmask, double learningRate=-1)

  参数说明:  参数image为待处理的图像;fgmask得到的前景图像(二值化都的);learningRate(0~1)配置背景更新方法,0表示不更新,1表示根据最后一帧更新,负数表示自动更新,(0~1)数字越大,背景更新越快。

Parameters:
  • image – Next video frame.
  • fgmask – The output foreground mask as an 8-bit binary image.
  • learningRate – The value between 0 and 1 that indicates how fast the background model is learnt. Negative parameter value makes the algorithm to use some automatically chosen learning rate. 0 means that the background model is not updated at all, 1 means that the background model is completely reinitialized from the last frame.

以上理解如果做错,欢迎交流。