OpenCV 2.4.8

org.opencv.video
Class BackgroundSubtractorMOG2

java.lang.Object
  extended by org.opencv.core.Algorithm
      extended by org.opencv.video.BackgroundSubtractor
          extended by org.opencv.video.BackgroundSubtractorMOG2

public class BackgroundSubtractorMOG2
extends BackgroundSubtractor

Gaussian Mixture-based Background/Foreground Segmentation Algorithm.

Here are important members of the class that control the algorithm, which you can set after constructing the class instance:

Maximum allowed number of mixture components. Actual number is determined dynamically per pixel.

Threshold defining whether the component is significant enough to be included into the background model (corresponds to TB=1-cf from the paper??which paper??). cf=0.1 => TB=0.9 is default. For alpha=0.001, it means that the mode should exist for approximately 105 frames before it is considered foreground.

// C++ code:

Threshold for the squared Mahalanobis distance that helps decide when a sample is close to the existing components (corresponds to Tg). If it is not close to any component, a new component is generated. 3 sigma => Tg=3*3=9 is default. A smaller Tg value generates more components. A higher Tg value may result in a small number of components but they can grow too large.

Initial variance for the newly generated components. It affects the speed of adaptation. The parameter value is based on your estimate of the typical standard deviation from the images. OpenCV uses 15 as a reasonable value.

Parameter used to further control the variance.

Parameter used to further control the variance.

Complexity reduction parameter. This parameter defines the number of samples needed to accept to prove the component exists. CT=0.05 is a default value for all the samples. By setting CT=0 you get an algorithm very similar to the standard Stauffer&Grimson algorithm.

The value for marking shadow pixels in the output foreground mask. Default value is 127.

Shadow threshold. The shadow is detected if the pixel is a darker version of the background. Tau is a threshold defining how much darker the shadow can be. Tau= 0.5 means that if a pixel is more than twice darker then it is not shadow. See Prati,Mikic,Trivedi,Cucchiarra, *Detecting Moving Shadows...*, IEEE PAMI,2003.

The class implements the Gaussian mixture model background subtraction described in:

See Also:
org.opencv.video.BackgroundSubtractorMOG2 : public BackgroundSubtractor

Constructor Summary
BackgroundSubtractorMOG2()
          The constructors.
BackgroundSubtractorMOG2(int history, float varThreshold)
          The constructors.
BackgroundSubtractorMOG2(int history, float varThreshold, boolean bShadowDetection)
          The constructors.
 
Method Summary
 
Methods inherited from class org.opencv.video.BackgroundSubtractor
apply, apply
 
Methods inherited from class org.opencv.core.Algorithm
getBool, getDouble, getInt, getMat, getMatVector, getString, paramHelp, paramType, setBool, setDouble, setInt, setMat, setMatVector, setString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BackgroundSubtractorMOG2

public BackgroundSubtractorMOG2()

The constructors.

See Also:
org.opencv.video.BackgroundSubtractorMOG2.BackgroundSubtractorMOG2

BackgroundSubtractorMOG2

public BackgroundSubtractorMOG2(int history,
                                float varThreshold)

The constructors.

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??).
See Also:
org.opencv.video.BackgroundSubtractorMOG2.BackgroundSubtractorMOG2

BackgroundSubtractorMOG2

public BackgroundSubtractorMOG2(int history,
                                float varThreshold,
                                boolean bShadowDetection)

The constructors.

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).
See Also:
org.opencv.video.BackgroundSubtractorMOG2.BackgroundSubtractorMOG2

OpenCV 2.4.8 Documentation