### Navigation

- index
- next |
- previous |
- OpenCV 3.0.0-dev documentation »
- OpenCV API Reference »
- cudabgsegm. CUDA-accelerated Background Segmentation »

# Background Segmentation

## cuda::BackgroundSubtractorMOG

Gaussian Mixture-based Background/Foreground Segmentation Algorithm.

class `cuda::``BackgroundSubtractorMOG` : public `cv::``BackgroundSubtractorMOG`

The class discriminates between foreground and background pixels by building and maintaining a model of the background. Any pixel which does not fit this model is then deemed to be foreground. The class implements algorithm described in [MOG2001].

See also

`BackgroundSubtractorMOG`

Note

- An example on gaussian mixture based background/foreground segmantation can be found at opencv_source_code/samples/gpu/bgfg_segm.cpp

## cuda::createBackgroundSubtractorMOG

Creates mixture-of-gaussian background subtractor

C++:`` Ptr<cuda::BackgroundSubtractorMOG> `cuda::``createBackgroundSubtractorMOG`(int history=200, int nmixtures=5, double backgroundRatio=0.7, double noiseSigma=0)

  Parameters: | history – Length of the history. nmixtures – Number of Gaussian mixtures. backgroundRatio – Background ratio. noiseSigma – Noise strength (standard deviation of the brightness or each color channel). 0 means some automatic value.

## cuda::BackgroundSubtractorMOG2

Gaussian Mixture-based Background/Foreground Segmentation Algorithm.

class `cuda::``BackgroundSubtractorMOG2` : public `cv::``BackgroundSubtractorMOG2`

The class discriminates between foreground and background pixels by building and maintaining a model of the background. Any pixel which does not fit this model is then deemed to be foreground. The class implements algorithm described in [MOG2004].

See also

`BackgroundSubtractorMOG2`

## cuda::createBackgroundSubtractorMOG2

Creates MOG2 Background Subtractor

C++:`` Ptr<cuda::BackgroundSubtractorMOG2> `cuda::``createBackgroundSubtractorMOG2`(int history=500, double varThreshold=16, bool detectShadows=true )

  Parameters: | history – Length of the history. varThreshold – Threshold on the squared Mahalanobis distance between the pixel and the model to decide whether a pixel is well described by the background model. This parameter does not affect the background update. detectShadows – If true, the algorithm will detect shadows and mark them. It decreases the speed a bit, so if you do not need this feature, set the parameter to false.

## cuda::BackgroundSubtractorGMG

Background/Foreground Segmentation Algorithm.

class `cuda::``BackgroundSubtractorGMG` : public `cv::``BackgroundSubtractorGMG`

The class discriminates between foreground and background pixels by building and maintaining a model of the background. Any pixel which does not fit this model is then deemed to be foreground. The class implements algorithm described in [GMG2012].

## cuda::createBackgroundSubtractorGMG

Creates GMG Background Subtractor

C++:`` Ptr<cuda::BackgroundSubtractorGMG> `cuda::``createBackgroundSubtractorGMG`(int initializationFrames=120, double decisionThreshold=0.8)

  Parameters: | initializationFrames – Number of frames of video to use to initialize histograms. decisionThreshold – Value above which pixel is determined to be FG.

## cuda::BackgroundSubtractorFGD

class `cuda::``BackgroundSubtractorFGD` : public `cv::``BackgroundSubtractor`

The class discriminates between foreground and background pixels by building and maintaining a model of the background. Any pixel which does not fit this model is then deemed to be foreground. The class implements algorithm described in [FGD2003].

    class CV_EXPORTS BackgroundSubtractorFGD : public cv::BackgroundSubtractor
    {
    public:
        virtual void getForegroundRegions(OutputArrayOfArrays foreground_regions) = 0;
    };

See also

`BackgroundSubtractor`

## cuda::BackgroundSubtractorFGD::getForegroundRegions

Returns the output foreground regions calculated by `findContours()`.

C++:`` void `cuda::BackgroundSubtractorFGD::``getForegroundRegions`(OutputArrayOfArrays foreground_regions)

  Params foreground_regions:
  | Output array (CPU memory).

## cuda::createBackgroundSubtractorFGD

Creates FGD Background Subtractor

C++:`` Ptr<cuda::BackgroundSubtractorGMG> `cuda::``createBackgroundSubtractorFGD`(const FGDParams& params=FGDParams())

  Parameters: | params – Algorithm’s parameters. See [FGD2003] for explanation.

[FGD2003] | (1, 2) Liyuan Li, Weimin Huang, Irene Y.H. Gu, and Qi Tian. Foreground Object Detection from Videos Containing Complex Background. ACM MM2003 9p, 2003.

[MOG2001] | KadewTraKuPong and R. Bowden. An improved adaptive background mixture model for real-time tracking with shadow detection. Proc. 2nd European Workshop on Advanced Video-Based Surveillance Systems, 2001

[MOG2004] | Zivkovic. Improved adaptive Gausian mixture model for background subtraction. International Conference Pattern Recognition, UK, August, 2004

[GMG2012] | Godbehere, A. Matsukawa and K. Goldberg. Visual Tracking of Human Visitors under Variable-Lighting Conditions for a Responsive Audio Art Installation. American Control Conference, Montreal, June 2012

## Help and Feedback

You did not find what you were looking for?

- Ask a question on the Q&A forum.
- If you think something is missing or wrong in the documentation, please file a bug report.

### Navigation

- index
- next |
- previous |
- OpenCV 3.0.0-dev documentation »
- OpenCV API Reference »
- cudabgsegm. CUDA-accelerated Background Segmentation »