Search code examples
python-3.xopencvbackground-subtraction

OpenCV2 createBackgroundSubtractorMOG Attribute not found


I am using cv2 version 4.0.0 and python version 3.7.2.

I am trying to subtract Background using this method cv2.createBackgroundSubtractorMOG2() and its working well.

But when I use cv2.createBackgroundSubtractorMOG() its not working its showing me

AttributeError: module 'cv2.cv2' has no attribute 'createBackgroundSubtractorMOG '.

I also tried cv2.BackgroundSubtractorMOG() but i got same error

AttributeError: module 'cv2.cv2' has no attribute 'BackgroundSubtractorMOG'.

and another subtraction method cv2.createBackgroundSubtractorGMG() also not working.

I also refer other stackoverflow answers but I didn't get solution.


Solution

  • MOG2 containts in main opencv repository. MOG and GMG are from opencv_contrib: https://github.com/opencv/opencv_contrib/tree/master/modules/bgsegm