Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenCV2 Python createBackgroundSubtractor module not found

I am trying to use cv2.createBackgroundSubtractorMOG2 () method in Python. I have tried both on my Mac and on my Raspberry Pi, and get the same error when running the following line of code:

fgbg = cv2.createBackgroundSubtractorMOG2()

The code I am using is taken from https://github.com/abidrahmank/OpenCV2-Python-Tutorials/blob/master/source/py_tutorials/py_video/py_bg_subtraction/py_bg_subtraction.rst

I get the following error when running this code:

fgbg = cv2.createBackgroundSubtractorMOG2() AttributeError: 'module' object has no attribute 'createBackgroundSubtractorMOG2'

I can't seem to use any of the createBackgroundSubtractor methods.

I have been trying to solve this for the past day, but I have had no luck searching online, as there is limited support for cv2 on Python.

Thanks in advance

like image 786
user2765323 Avatar asked Sep 10 '13 14:09

user2765323


2 Answers

Replace the create.... with

fgbg = cv2.BackgroundSubtractorMOG()

like image 91
user2897775 Avatar answered Oct 07 '22 00:10

user2897775


cv2.createbackgroundSubstractor() works in cv 3.0 for 2.4.x use cv2.BackgroundSubstractor()

like image 34
fury Avatar answered Oct 07 '22 00:10

fury