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

烂漫一生 提交于 2019-12-12 16:15:14

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/29429863/why-is-createbackgroundsubtractorgmg-considered-obsolete-and-how-can-i-use-it

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!