Cv::BackgroundSubtractorMOG2
Gaussian Mixture-based Background/Foreground Segmentation Algorithm.
Default parameters
// default parameters of gaussian background detection algorithm
static const int defaultHistory2 = 500; ///< Learning rate; alpha = 1/defaultHistory2
static const float defaultVarThreshold2 = 4.0f * 4.0f;
static const int defaultNMixtures2 = 5; ///< maximal number of Gaussians in mixture
static const float defaultBackgroundRatio2 = 0.9f; ///< threshold sum of weights for background test
static const float defaultVarThresholdGen2 = 3.0f * 3.0f;
static const float defaultVarInit2 = 15.0f; ///< initial variance for new components
static const float defaultVarMax2 = 5 * defaultVarInit2;
static const float defaultVarMin2 = 4.0f;
// additional parameters
/// @brief complexity reduction prior constant 0 - no reduction of number of components
static const float defaultfCT2 = 0.05f;
/// @brief value to use in the segmentation mask for shadows, set 0 not to do shadow detection
static const unsigned char defaultnShadowDetection2 = (unsigned char) 127;
/// @brief Tau - shadow threshold, see the paper for explanation
static const float defaultfTau = 0.5f;
Example
OpenCV 2.x
pMOG2 = new BackgroundSubtractorMOG2(history, varThreshold, bShadowDetection); //MOG2 approach
pMOG2->setInt("nmixtures", 3);
pMOG2->setDouble("fTau", 0.5);
pMOG2->operator()(src, fgMaskMOG2);
OpenCV 3.x version
cv::Ptr<BackgroundSubtractorMOG2> bg = createBackgroundSubtractorMOG2(...)
bg->setNMixtures(3);
bg->apply(img,mask);
See also
- 배경 추출 (Background subtraction)
- 수신자 조작 특성 (Receiver operating characteristic)
- 확률밀도함수 (Probability density function; PDF)
- 가우시안 혼합 모델 (Gaussian mixture model)
Favorite site
- [추천] Tutorial: Background detection with OpenCV 1
- [추천] Improved Adaptive Gaussian Mixture Model for Background Subtraction
- opencv 2.4.11 - cv::BackgroundSubtractorMOG2 Class Reference
- How to change BackgroundSubtractorMOG2 options
- BackgroundSubtractorMOG2 returns a white image
- OpenCV - Gauss mixed background modeling
- Motion Analysis and Object Tracking (OpenCV 2.4.12.0 documentation)
OpenCV 3.x version
- cv::BackgroundSubtractorMOG2 Class Reference
- Motion Analysis and Object Tracking (OpenCV 3.0.0-dev documentation)
- [추천] How to Use Background Subtraction Methods
References
-
Tutorial_-_Background_detection_with_OpenCV.pdf ↩