i have been going through opencv mog and gmg background subtraction, i have installed opencv 3.3.0 from
https://github.com/Itseez/opencv_contrib
and also opencv from the same version, but still i couldn't find MOG not working, where as mog 2 is working,
import numpy as np
import cv2
cap = cv2.VideoCapture(0)
fgbg = cv2.BackgroundSubtractorMOG()
while(1):
ret, frame = cap.read()
fgmask = fgbg.apply(frame)
cv2.imshow('frame',fgmask)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
i get the following error message
Traceback (most recent call last):
File "back.py", line 6, in <module>
fgbg = cv2.BackgroundSubtractorMOG()
AttributeError: 'module' object has no attribute 'BackgroundSubtractorMOG'
fgbg = cv.createBackgroundSubtractorMOG() didn't work for me too but there is another improved version of background subtraction which works similar fgbg = cv2.createBackgroundSubtractorMOG2()