Difference between foreground-background segmentation methods in OpenCV
Asked Answered
C

1

8

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?

Cruise answered 22/4, 2013 at 21:47 Comment(0)
C
5

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
Cruise answered 25/4, 2013 at 16:15 Comment(2)
@nkint True, the accuracy depends on your application and on the parameters chosen for a given algorithm. I didn't do an extensive research.Cruise
@nkint I didn't do the extensive research and I didn't fine tune all the algorithms. I just liked GMG_GPU algorithm for my application. It's my subjective opinion. Let me know if you know of a better and more detailed comparison of these OpenCV algorithms.Cruise

© 2022 - 2024 — McMap. All rights reserved.