OpenCV version 2.4.5 offers several different implementations that can be used for tracking moving objects that use statistical methods to estimate background. OpenCV has BackgroundSubtractorMOG
, BackgroundSubtractorMOG2
classes implemented on CPU. In addition, it has GPU implementations of BackgroundSubtractorMOG
and BackgroundSubtractorMOG2
, namely gpu::MOG_GPU
and gpu::MOG2_GPU
respectively. There are also two other algorithms gpu::GMG_GPU
and gpu::FGDStatModel
.
In my application I want to segment out moving objects as soon as they enter the scene. I'd like to avoid false positives such as shadows. These 4 algorithms seem to focus on the same goal -- they separate background from foreground by creating a model of the background over time. I was wandering if someone who had experience with these implementations can help me to decide which (GPU) implementation to use. How these algorithms -- MOG, MOG2, GMG and FGDStatModel -- differ from each other? What are the advantages of using one or the other algorithm? How do these implementations compare in terms of speed, ability to configure their parameters, accuracy, shadow detection (false positive), etc?
The foreground contains the applications the user is working on, and the background contains the applications that are behind the scenes, such as certain operating system functions, printing a document or accessing the network.
Step #1: Estimating the color distribution of the foreground and background via a Gaussian Mixture Model (GMM) Step #2: Constructing a Markov random field over the pixels labels (i.e., foreground vs. background) Step #3: Applying a graph cut optimization to arrive at the final segmentation.
Foreground-background separation is a segmentation task, where the goal is to split the image into foreground and background. In semi-interactive settings, the user marks some pixels as “foreground”, a few others as “background”, and it's up to the algorithm to classify the rest of the pixels.
Compatibility. OpenCV >= 3.0. Background subtraction (BS) is a common and widely used technique for generating a foreground mask (namely, a binary image containing the pixels belonging to moving objects in the scene) by using static cameras.
I stumbled upon a demo source code bgfg_segm.cpp
located in {opencv_folder}\samples\gpu
. The demo shows usage and displays output for the following background-foreground segmentation classes
FGDStatModel
MOG_GPU
MOG2_GPU
VIBE_GPU <- listed under `non-free functionality` in OpenCV documentation
GMG_GPU
This is exactly what I needed to compare the algorithms. Obviously, one needs to tune up parameters for the algorithms to find the one algorithm (along with a set of parameters) that fits a given application.
Speed comparison:
FGDStatModel ~60 frames per second (fps) <-slowest
MOG_GPU ~650 fps
MOG2_GPU ~650 fps
VIBE_GPU ~1000 fps <- fastest
GMG_GPU ~190 fps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With