-
1、官网BackgroundSubtractorMOG:
BackgroundSubtractorMOG::BackgroundSubtractorMOG
The constructors.
C++: BackgroundSubtractorMOG::BackgroundSubtractorMOG()
C++: BackgroundSubtractorMOG::BackgroundSubtractorMOG(int history, int nmixtures, double backgroundRatio, double noiseSigma=0)
Python: cv2.BackgroundSubtractorMOG([history, nmixtures, backgroundRatio[, noiseSigma]]) → <BackgroundSubtractorMOG object>
Parameters:
history – Length of the history.
nmixtures – Number of Gaussian mixtures.
backgroundRatio – Background ratio.
noiseSigma – Noise strength.
Default constructor sets all parameters to default values.
BackgroundSubtractorMOG::operator()
Updates the background model and returns the foreground mask
C++: void BackgroundSubtractorMOG::operator()(InputArray image, OutputArray fgmask, double learningRate=0)
Parameters are the same as in BackgroundSubtractor::operator()
2、BackgroundSubtractorMOG2:
BackgroundSubtractorMOG2::BackgroundSubtractorMOG2
The constructors.
C++: BackgroundSubtractorMOG2::BackgroundSubtractorMOG2()
C++: BackgroundSubtractorMOG2::BackgroundSubtractorMOG2(int history, float varThreshold, bool bShadowDetection=true )
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).
BackgroundSubtractorMOG2::operator()
Updates the background model and computes the foreground mask
C++: void BackgroundSubtractorMOG2::operator()(InputArray image, OutputArray fgmask, double learningRate=-1)
See BackgroundSubtractor::operator().
3、两者参数有点不同,比较坑的是两者都有提取背景的函数
C++: void BackgroundSubtractor::getBackgroundImage(OutputArray backgroundImage) const
-
C++: void BackgroundSubtractorMOG2::getBackgroundImage(OutputArray
backgroundImage)
BackgroundSubtractorMOG2可以获得背景