@Namespace(value="cv") @Properties(inherit=opencv_video.class) public class BackgroundSubtractorMOG2 extends BackgroundSubtractor
The class implements the Gaussian mixture model background subtraction described in \cite Zivkovic2004 and \cite Zivkovic2006 .
Pointer.CustomDeallocator, Pointer.Deallocator, Pointer.NativeDeallocator, Pointer.ReferenceCounter
Constructor and Description |
---|
BackgroundSubtractorMOG2(Algorithm pointer)
Downcast constructor.
|
BackgroundSubtractorMOG2(Pointer p)
Pointer cast constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
apply(GpuMat image,
GpuMat fgmask) |
void |
apply(GpuMat image,
GpuMat fgmask,
double learningRate) |
void |
apply(Mat image,
Mat fgmask) |
void |
apply(Mat image,
Mat fgmask,
double learningRate)
\brief Computes a foreground mask.
|
void |
apply(UMat image,
UMat fgmask) |
void |
apply(UMat image,
UMat fgmask,
double learningRate) |
double |
getBackgroundRatio()
\brief Returns the "background ratio" parameter of the algorithm
|
double |
getComplexityReductionThreshold()
\brief Returns the complexity reduction threshold
|
boolean |
getDetectShadows()
\brief Returns the shadow detection flag
|
int |
getHistory()
\brief Returns the number of last frames that affect the background model
|
int |
getNMixtures()
\brief Returns the number of gaussian components in the background model
|
double |
getShadowThreshold()
\brief Returns the shadow threshold
|
int |
getShadowValue()
\brief Returns the shadow value
|
double |
getVarInit()
\brief Returns the initial variance of each gaussian component
|
double |
getVarMax() |
double |
getVarMin() |
double |
getVarThreshold()
\brief Returns the variance threshold for the pixel-model match
|
double |
getVarThresholdGen()
\brief Returns the variance threshold for the pixel-model match used for new mixture component generation
|
void |
setBackgroundRatio(double ratio)
\brief Sets the "background ratio" parameter of the algorithm
|
void |
setComplexityReductionThreshold(double ct)
\brief Sets the complexity reduction threshold
|
void |
setDetectShadows(boolean detectShadows)
\brief Enables or disables shadow detection
|
void |
setHistory(int history)
\brief Sets the number of last frames that affect the background model
|
void |
setNMixtures(int nmixtures)
\brief Sets the number of gaussian components in the background model.
|
void |
setShadowThreshold(double threshold)
\brief Sets the shadow threshold
|
void |
setShadowValue(int value)
\brief Sets the shadow value
|
void |
setVarInit(double varInit)
\brief Sets the initial variance of each gaussian component
|
void |
setVarMax(double varMax) |
void |
setVarMin(double varMin) |
void |
setVarThreshold(double varThreshold)
\brief Sets the variance threshold for the pixel-model match
|
void |
setVarThresholdGen(double varThresholdGen)
\brief Sets the variance threshold for the pixel-model match used for new mixture component generation
|
asAlgorithm, asAlgorithm, getBackgroundImage, getBackgroundImage, getBackgroundImage
clear, empty, getDefaultName, getPointer, position, read, save, save, write, write, write
address, asBuffer, asByteBuffer, availablePhysicalBytes, calloc, capacity, capacity, close, deallocate, deallocate, deallocateReferences, deallocator, deallocator, equals, fill, formatBytes, free, getDirectBufferAddress, getPointer, getPointer, getPointer, hashCode, interruptDeallocatorThread, isNull, isNull, limit, limit, malloc, maxBytes, maxPhysicalBytes, memchr, memcmp, memcpy, memmove, memset, offsetAddress, offsetof, offsetof, parseBytes, physicalBytes, physicalBytesInaccurate, position, put, realloc, referenceCount, releaseReference, retainReference, setNull, sizeof, sizeof, toString, totalBytes, totalCount, totalPhysicalBytes, withDeallocator, zero
public BackgroundSubtractorMOG2(Pointer p)
Pointer(Pointer)
.public BackgroundSubtractorMOG2(Algorithm pointer)
public int getHistory()
public void setHistory(int history)
public int getNMixtures()
public void setNMixtures(int nmixtures)
The model needs to be reinitalized to reserve memory.
public double getBackgroundRatio()
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 void setBackgroundRatio(double ratio)
public double getVarThreshold()
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 void setVarThreshold(double varThreshold)
public double getVarThresholdGen()
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.
public void setVarThresholdGen(double varThresholdGen)
public double getVarInit()
public void setVarInit(double varInit)
public double getVarMin()
public void setVarMin(double varMin)
public double getVarMax()
public void setVarMax(double varMax)
public double getComplexityReductionThreshold()
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 void setComplexityReductionThreshold(double ct)
@Cast(value="bool") public boolean getDetectShadows()
If true, the algorithm detects shadows and marks them. See createBackgroundSubtractorMOG2 for details.
public void setDetectShadows(@Cast(value="bool") boolean detectShadows)
public int getShadowValue()
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 void setShadowValue(int value)
public double getShadowThreshold()
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 void setShadowThreshold(double threshold)
public void apply(@ByVal Mat image, @ByVal Mat fgmask, double learningRate)
apply
in class BackgroundSubtractor
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.public void apply(@ByVal Mat image, @ByVal Mat fgmask)
apply
in class BackgroundSubtractor
public void apply(@ByVal UMat image, @ByVal UMat fgmask, double learningRate)
apply
in class BackgroundSubtractor
public void apply(@ByVal UMat image, @ByVal UMat fgmask)
apply
in class BackgroundSubtractor
public void apply(@ByVal GpuMat image, @ByVal GpuMat fgmask, double learningRate)
apply
in class BackgroundSubtractor
Copyright © 2024. All rights reserved.