Reputation: 59
import cv2
fgbg = cv2.createBackgroundSubtractorMOG()
fgbg1 = cv2.createBackgroundSubtractorGMG()
AttributeError: 'module' object has no attribute 'createBackgroundSubtractorMOG()'
AttributeError: 'module' object has no attribute 'createBackgroundSubtractorMOG()'
Enviroment:
What should I do?
Upvotes: 4
Views: 7089
Reputation: 1
Try one of the following solutions:
cv2.bgsegm.createBackgroundSubtractorMOG()
or:
cv2.bgsegm.createBackgroundSubtractorMOG2()
Upvotes: 0
Reputation: 71
Use cv2.BackgroundSubtractorMOG()
because cv2.createBackgroundSubtractorMOG2
was replaced in the latest versions of opencv.
Upvotes: 0
Reputation: 12627
You may be interested in BackgroundSubtractorMOG2, which, although not documented, has a python binding in opencv 3.0.0-beta.
import cv2
fgbg = cv2.createBackgroundSubtractorMOG2(detectShadows=True)
Upvotes: 7
Reputation: 39796
both were moved in 3.0 to the opencv_contrib repo
you will need to build it along with your main opencv repo using cmake. (no prebuild versions of this available) then running the INSTALL project (or make install) will copy your new cv2.pyd to the python folder.
then:
>>> import cv2
>>> cv2.bgsegm.createBackgroundSubtractorMOG # note additional bgsegm namespace !
<built-in function createBackgroundSubtractorMOG>
Upvotes: 4