BackgroundSubtractorMOG2
Objective-C
@interface BackgroundSubtractorMOG2 : BackgroundSubtractor
Swift
class BackgroundSubtractorMOG2 : BackgroundSubtractor
Gaussian Mixture-based Background/Foreground Segmentation Algorithm.
The class implements the Gaussian mixture model background subtraction described in CITE: Zivkovic2004 and CITE: Zivkovic2006 .
Member of Video
-
Returns the shadow detection flag
If true, the algorithm detects shadows and marks them. See createBackgroundSubtractorMOG2 for details.
Declaration
Objective-C
- (BOOL)getDetectShadows;
Swift
func getDetectShadows() -> Bool
-
Returns 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
Objective-C
- (double)getBackgroundRatio;
Swift
func getBackgroundRatio() -> Double
-
Returns 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
Objective-C
- (double)getComplexityReductionThreshold;
Swift
func getComplexityReductionThreshold() -> Double
-
Returns 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
Objective-C
- (double)getShadowThreshold;
Swift
func getShadowThreshold() -> Double
-
Returns the initial variance of each gaussian component
Declaration
Objective-C
- (double)getVarInit;
Swift
func getVarInit() -> Double
-
Declaration
Objective-C
- (double)getVarMax NS_SWIFT_NAME(getVarMax());
Swift
func getVarMax() -> Double
-
Declaration
Objective-C
- (double)getVarMin NS_SWIFT_NAME(getVarMin());
Swift
func getVarMin() -> Double
-
Returns 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
Objective-C
- (double)getVarThreshold;
Swift
func getVarThreshold() -> Double
-
Returns 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
Objective-C
- (double)getVarThresholdGen;
Swift
func getVarThresholdGen() -> Double
-
Returns the number of last frames that affect the background model
Declaration
Objective-C
- (int)getHistory;
Swift
func getHistory() -> Int32
-
Returns the number of gaussian components in the background model
Declaration
Objective-C
- (int)getNMixtures;
Swift
func getNMixtures() -> Int32
-
Returns 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
Objective-C
- (int)getShadowValue;
Swift
func getShadowValue() -> Int32
-
Computes a foreground mask.
Declaration
Parameters
image
Next video frame. Floating point frame will be used without scaling and should be in range
[0,255].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.
-
Computes a foreground mask.
Declaration
Parameters
image
Next video frame. Floating point frame will be used without scaling and should be in range
[0,255].fgmask
The output foreground mask as an 8-bit binary image. 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.
-
Sets the “background ratio” parameter of the algorithm
Declaration
Objective-C
- (void)setBackgroundRatio:(double)ratio;
Swift
func setBackgroundRatio(ratio: Double)
-
Sets the complexity reduction threshold
Declaration
Objective-C
- (void)setComplexityReductionThreshold:(double)ct;
Swift
func setComplexityReductionThreshold(ct: Double)
-
Enables or disables shadow detection
Declaration
Objective-C
- (void)setDetectShadows:(BOOL)detectShadows;
Swift
func setDetectShadows(detectShadows: Bool)
-
Sets the number of last frames that affect the background model
Declaration
Objective-C
- (void)setHistory:(int)history;
Swift
func setHistory(history: Int32)
-
Sets the number of gaussian components in the background model.
The model needs to be reinitalized to reserve memory.
Declaration
Objective-C
- (void)setNMixtures:(int)nmixtures;
Swift
func setNMixtures(nmixtures: Int32)
-
Sets the shadow threshold
Declaration
Objective-C
- (void)setShadowThreshold:(double)threshold;
Swift
func setShadowThreshold(threshold: Double)
-
Sets the shadow value
Declaration
Objective-C
- (void)setShadowValue:(int)value;
Swift
func setShadowValue(value: Int32)
-
Sets the initial variance of each gaussian component
Declaration
Objective-C
- (void)setVarInit:(double)varInit;
Swift
func setVarInit(varInit: Double)
-
Declaration
Objective-C
- (void)setVarMax:(double)varMax NS_SWIFT_NAME(setVarMax(varMax:));
Swift
func setVarMax(varMax: Double)
-
Declaration
Objective-C
- (void)setVarMin:(double)varMin NS_SWIFT_NAME(setVarMin(varMin:));
Swift
func setVarMin(varMin: Double)
-
Sets the variance threshold for the pixel-model match
Declaration
Objective-C
- (void)setVarThreshold:(double)varThreshold;
Swift
func setVarThreshold(varThreshold: Double)
-
Sets the variance threshold for the pixel-model match used for new mixture component generation
Declaration
Objective-C
- (void)setVarThresholdGen:(double)varThresholdGen;
Swift
func setVarThresholdGen(varThresholdGen: Double)