Show / Hide Table of Contents

Class BackgroundSubtractorMOG2

The Base Class for Background/Foreground Segmentation. The class is only used to define the common interface for the whole family of background/foreground segmentation algorithms.

Inheritance
System.Object
DisposableObject
DisposableCvObject
Algorithm
BackgroundSubtractor
BackgroundSubtractorMOG2
Implements
ICvPtrHolder
Inherited Members
BackgroundSubtractor.Apply(InputArray, OutputArray, Double)
BackgroundSubtractor.GetBackgroundImage(OutputArray)
Algorithm.Write(FileStorage)
Algorithm.Read(FileNode)
Algorithm.Empty
Algorithm.Save(String)
Algorithm.GetDefaultName()
DisposableCvObject.ptr
DisposableCvObject.CvPtr
DisposableObject.DataHandle
DisposableObject.IsDisposed
DisposableObject.IsEnabledDispose
DisposableObject.AllocatedMemory
DisposableObject.AllocatedMemorySize
DisposableObject.Dispose()
DisposableObject.Dispose(Boolean)
DisposableObject.AllocGCHandle(Object)
DisposableObject.AllocMemory(Int32)
DisposableObject.NotifyMemoryPressure(Int64)
DisposableObject.ThrowIfDisposed()
Namespace: OpenCvSharp
Assembly: OpenCvSharp.dll
Syntax
public class BackgroundSubtractorMOG2 : BackgroundSubtractor, ICvPtrHolder

Properties

| Improve this Doc View Source

BackgroundRatio

Gets or sets the "background ratio" parameter of the algorithm. If a foreground pixel keeps semi-constant value for about backgroundRatio*history frames, it's considered background and added to the model as a center of a new component. It corresponds to TB parameter in the paper.

Declaration
public double BackgroundRatio { get; set; }
Property Value
Type Description
System.Double
| Improve this Doc View Source

ComplexityReductionThreshold

Gets or sets the complexity reduction threshold. 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.

Declaration
public double ComplexityReductionThreshold { get; set; }
Property Value
Type Description
System.Double
| Improve this Doc View Source

DetectShadows

Gets or sets the shadow detection flag. If true, the algorithm detects shadows and marks them. See createBackgroundSubtractorKNN for details.

Declaration
public bool DetectShadows { get; set; }
Property Value
Type Description
System.Boolean
| Improve this Doc View Source

History

Gets or sets the number of last frames that affect the background model.

Declaration
public int History { get; set; }
Property Value
Type Description
System.Int32
| Improve this Doc View Source

NMixtures

Gets or sets the number of gaussian components in the background model.

Declaration
public int NMixtures { get; set; }
Property Value
Type Description
System.Int32
| Improve this Doc View Source

ShadowThreshold

Gets or sets the shadow threshold. A shadow is detected if pixel is a darker version of the background. The shadow threshold (Tau in the paper) 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 and Cucchiara, Detecting Moving Shadows..., IEEE PAMI,2003.

Declaration
public double ShadowThreshold { get; set; }
Property Value
Type Description
System.Double
| Improve this Doc View Source

ShadowValue

Gets or sets the shadow value. Shadow value is the value used to mark shadows in the foreground mask. Default value is 127. Value 0 in the mask always means background, 255 means foreground.

Declaration
public int ShadowValue { get; set; }
Property Value
Type Description
System.Int32
| Improve this Doc View Source

VarInit

Gets or sets the initial variance of each gaussian component.

Declaration
public double VarInit { get; set; }
Property Value
Type Description
System.Double
| Improve this Doc View Source

VarMax

Declaration
public double VarMax { get; set; }
Property Value
Type Description
System.Double
| Improve this Doc View Source

VarMin

Declaration
public double VarMin { get; set; }
Property Value
Type Description
System.Double
| Improve this Doc View Source

VarThreshold

Gets or sets the variance threshold for the pixel-model match. The main threshold on the squared Mahalanobis distance to decide if the sample is well described by the background model or not. Related to Cthr from the paper.

Declaration
public double VarThreshold { get; set; }
Property Value
Type Description
System.Double
| Improve this Doc View Source

VarThresholdGen

Gets or sets the variance threshold for the pixel-model match used for new mixture component generation. Threshold for the squared Mahalanobis distance that helps decide when a sample is close to the existing components (corresponds to Tg in the paper). If a pixel is not close to any component, it is considered foreground or added as a new component. 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.

Declaration
public double VarThresholdGen { get; set; }
Property Value
Type Description
System.Double

Methods

| Improve this Doc View Source

Create(Int32, Double, Boolean)

Creates MOG2 Background Subtractor.

Declaration
public static BackgroundSubtractorMOG2 Create(int history = 500, double varThreshold = 16, bool detectShadows = true)
Parameters
Type Name Description
System.Int32 history

Length of the history.

System.Double varThreshold

Threshold on the squared Mahalanobis distance between the pixel and the model to decide whether a pixel is well described by the background model. This parameter does not affect the background update.

System.Boolean detectShadows

If true, the algorithm will detect shadows and mark them. It decreases the speed a bit, so if you do not need this feature, set the parameter to false.

Returns
Type Description
BackgroundSubtractorMOG2
| Improve this Doc View Source

DisposeManaged()

Releases managed resources

Declaration
protected override void DisposeManaged()
Overrides
DisposableObject.DisposeManaged()
| Improve this Doc View Source

DisposeUnmanaged()

Declaration
protected override void DisposeUnmanaged()
Overrides
DisposableCvObject.DisposeUnmanaged()
| Improve this Doc View Source

Get()

Declaration
public override IntPtr Get()
Returns
Type Description
IntPtr

Implements

ICvPtrHolder
  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX