Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python opencv3.0.0-beta 'module' object has no attribute 'createBackgroundSubtractorMOG()'

Tags:

python

opencv

import cv2
fgbg = cv2.createBackgroundSubtractorMOG()
fgbg1 = cv2.createBackgroundSubtractorGMG()

AttributeError: 'module' object has no attribute 'createBackgroundSubtractorMOG()'
AttributeError: 'module' object has no attribute 'createBackgroundSubtractorMOG()'

Enviroment:

  • x64 win7
  • win32 python 2.7.3
  • opencv 3.0.0-beta

What should I do?

like image 655
VictorLin Avatar asked Dec 20 '22 08:12

VictorLin


2 Answers

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)
like image 187
Arnaud P Avatar answered Dec 21 '22 21:12

Arnaud P


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>
like image 25
berak Avatar answered Dec 21 '22 23:12

berak