Click or drag to resize

BackgroundSubtractorMOG2 Class

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 Hierarchy

Namespace:  OpenCvSharp
Assembly:  OpenCvSharp (in OpenCvSharp.dll) Version: 1.0.0
Syntax
public class BackgroundSubtractorMOG2 : BackgroundSubtractor

The BackgroundSubtractorMOG2 type exposes the following members.

Properties
  NameDescription
Protected propertyAllocatedMemory
Gets or sets a memory address allocated by AllocMemory.
(Inherited from DisposableObject.)
Protected propertyAllocatedMemorySize
Gets or sets the byte length of the allocated memory
(Inherited from DisposableObject.)
Public propertyBackgroundRatio
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.
Public propertyComplexityReductionThreshold
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.
Public propertyCvPtr
Native pointer of OpenCV structure
(Inherited from DisposableCvObject.)
Protected propertyDataHandle
Gets or sets a handle which allocates using cvSetData.
(Inherited from DisposableObject.)
Public propertyDetectShadows
Gets or sets the shadow detection flag. If true, the algorithm detects shadows and marks them. See createBackgroundSubtractorKNN for details.
Public propertyEmpty
Returns true if the Algorithm is empty (e.g. in the very beginning or after unsuccessful read
(Inherited from Algorithm.)
Public propertyHistory
Gets or sets the number of last frames that affect the background model.
Public propertyIsDisposed
Gets a value indicating whether this instance has been disposed.
(Inherited from DisposableObject.)
Public propertyIsEnabledDispose
Gets or sets a value indicating whether you permit disposing this instance.
(Inherited from DisposableObject.)
Public propertyNMixtures
Gets or sets the number of gaussian components in the background model.
Public propertyShadowThreshold
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.
Public propertyShadowValue
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.
Public propertyVarInit
Gets or sets the initial variance of each gaussian component.
Public propertyVarMax
Public propertyVarMin
Public propertyVarThreshold
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.
Public propertyVarThresholdGen
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.
Top
Methods
  NameDescription
Protected methodAllocGCHandle
Pins the object to be allocated by cvSetData.
(Inherited from DisposableObject.)
Protected methodAllocMemory
Allocates the specified size of memory.
(Inherited from DisposableObject.)
Public methodApply
the update operator that takes the next video frame and returns the current foreground mask as 8-bit binary image.
(Inherited from BackgroundSubtractor.)
Public methodStatic memberCreate
Creates MOG2 Background Subtractor.
Public methodDispose
Releases the resources
(Inherited from DisposableObject.)
Protected methodDispose(Boolean)
Releases the resources
(Inherited from DisposableObject.)
Protected methodDisposeManaged
Releases managed resources
(Overrides DisposableObjectDisposeManaged.)
Protected methodDisposeUnmanaged
releases unmanaged resources
(Inherited from DisposableCvObject.)
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Destructor
(Inherited from DisposableObject.)
Public methodGetBackgroundImage
computes a background image
(Inherited from BackgroundSubtractor.)
Public methodGetDefaultName
Returns the algorithm string identifier. This string is used as top level xml/yml node tag when the object is saved to a file or string.
(Inherited from Algorithm.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Protected methodNotifyMemoryPressure
Notifies the allocated size of memory.
(Inherited from DisposableObject.)
Public methodRead
Reads algorithm parameters from a file storage
(Inherited from Algorithm.)
Public methodSave
Saves the algorithm to a file. In order to make this method work, the derived class must implement Algorithm::write(FileStorage fs).
(Inherited from Algorithm.)
Public methodThrowIfDisposed
If this object is disposed, then ObjectDisposedException is thrown.
(Inherited from DisposableObject.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Public methodWrite
Stores algorithm parameters in a file storage
(Inherited from Algorithm.)
Top
Fields
  NameDescription
Protected fieldptr
Data pointer
(Inherited from DisposableCvObject.)
Top
See Also