Why is createBackgroundSubtractorGMG considered obsolete, and how can I use it
Asked Answered
Z

1

3

I am rather new to OpenCV and image processing in general. I am looking into background subtraction to facilitate motion tracking (people counting). Looking at the openCV documentation on background subtracting, GMG gives rather nice results. Also when looking at a video comparing the methods, I feel that GMG gives the best results, at least for my purpose.

I installed the latest version of opencv to use with python3 thus:

git clone --depth=1 https://github.com/Itseez/opencv.git
cd opencv
mkdir build
cd build
cmake -DBUILD_opencv_python3=YES -DBUILD_opencv_python2=NO -DINSTALL_PYTHON_EXAMPLES=YES -DPYTHON3_EXECUTABLE=/usr/local/bin/python3 -DPYTHON3_INCLUDE_DIR=/usr/local/Cellar/python3/3.4.2_1/Frameworks/Python.framework/Versions/3.4/include/python3.4m -DPYTHON3_LIBRARY=/usr/local/Cellar/python3/3.4.2_1/Frameworks/Python.framework/Versions/3.4/lib/libpython3.4.dylib -DPYTHON3_NUMPY_INCLUDE_DIRS=/usr/local/lib/python3.4/site-packages/numpy/core/include/ -DPYTHON3_PACKAGES_PATH=/usr/local/lib/python3.4/site-packages/ ..
make -j8
make install
python3 -c "import cv2; print(cv2.__version__)"

the last line tells me I'm now running 3.0.0-dev. According to this question, cv2.createBackgroundSubtractorGMG ought to be available in this version, however it's not; and indeed, it seems to have been moved to obsolete in opencv master.

Interestingly enough, in my own tests the current (3.0.0-dev) versions of createBackgroundSubtractorKNN and createBackgroundSubtractorMOG2 work much better than the ones I tested before (MOG and MOG2) in opencv2. So possibly the GMG algorithm got moved into those. Or, if not, why is the GMG version considered obsolete now? And how can I get the obsolete version to work (on python3), to compare the results?

Zusman answered 3/4, 2015 at 9:50 Comment(0)
F
3

I don't think it is obsolete... it was just moved to the contrib repository. You have to install it with OpenCV and then it is available under cv2.bgsegm. Follow the link for build instructions.

Fatigue answered 30/6, 2015 at 9:20 Comment(1)
Somebody should specify this into the tutorials on their documentation, as they are not reproducible. docs.opencv.org/3.4.0/db/d5c/tutorial_py_bg_subtraction.htmlLesbos

© 2022 - 2024 — McMap. All rights reserved.