Ask Your Question
0

Cannot find BackgroundSubtractorMOG() and BackgroundSubtractorGMG() in OpenCV 3.0 with Python 2.7

asked 2015-11-26 08:29:25 -0600

isaacsales gravatar image

I was trying to make some codes following the tutorial, but when I use these functions as suggested in the doc it appears this error: AttributeError: 'module' object has no attribute 'createBackgroundSubtractorMOG'.

What should I do? Thanks!

edit retag flag offensive close merge delete

Comments

BackgroundSubtractorMOG() and BackgroundSubtractorGMG() have been moved to the bgsegm module of the contrib repository. As far as I know, no Python wrappers are available for such repository, so you just can't use those classes.

Please, point out what tutorial you've followed, so we can fix it/add a note about this issue

LorenaGdL gravatar imageLorenaGdL ( 2015-11-26 09:23:57 -0600 )edit

Thanks Lorena. It was very helpful. I've followed this tutorial here: https://opencv-python-tutroals.readth...

isaacsales gravatar imageisaacsales ( 2015-11-26 09:33:10 -0600 )edit

I've checked and the official Python tutorial in the OpenCV3.0 docs says nothing about this. I'll add a note if I find some spare time

LorenaGdL gravatar imageLorenaGdL ( 2015-11-26 09:42:18 -0600 )edit

well, once one builds the opencv_contrib repo, they are avaliable from python:

>>> help(cv2.bgsegm)
Help on module cv2.bgsegm in cv2:

NAME
    cv2.bgsegm

FILE
    (built-in)

FUNCTIONS
    createBackgroundSubtractorGMG(...)
        createBackgroundSubtractorGMG([, initializationFrames[, decisionThreshol
d]]) -> retval

    createBackgroundSubtractorMOG(...)
        createBackgroundSubtractorMOG([, history[, nmixtures[, backgroundRatio[,
 noiseSigma]]]]) -> retval
berak gravatar imageberak ( 2015-11-26 09:56:15 -0600 )edit

My bad then, though I saw this issue and thought it was unresolved https://github.com/Itseez/opencv/issu...

LorenaGdL gravatar imageLorenaGdL ( 2015-11-26 10:10:03 -0600 )edit

2 answers

Sort by ยป oldest newest most voted
0

answered 2015-11-27 04:53:55 -0600

Known issue: https://github.com/Itseez/opencv/issu.... Still on TODO list to fix :D

edit flag offensive delete link more
-1

answered 2017-08-03 12:32:43 -0600

I had the same problem with the same set-up. If you have compiled with --with-contrib flag, you should be fine once you use the bgsegm namespace.

e.g.

fgbg = cv2.bgsegm.createBackgroundSubtractorMOG()

this worked for me.

edit flag offensive delete link more

Comments

@manielec, if you would have taken the time to click the link, then you would know this was already given as a solution...

StevenPuttemans gravatar imageStevenPuttemans ( 2017-08-04 06:07:52 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2015-11-26 08:29:25 -0600

Seen: 6,631 times

Last updated: Aug 03 '17