How to solve AttributeError: 'module' object has no attribute 'createBackgroundSubtractorMOG' in opencv?
When this code is executed, I get the result: AttributeError: 'module' object has no attribute 'createBackgroundSubtractorMOG'. The OpenCV tutorial for Background Subtraction used this object, so I would guess it worked for them.
import numpy as np
import cv2
cap = cv2.VideoCapture('camera17.h264')
fgbg = cv2.createBackgroundSubtractorMOG()
while(1):
ret, frame = cap.read()
fgmask = fgbg.apply(frame)
cv2.imshow('frame', fgmask)
k = cv2.waitKey(30) & 0xff
if k == 27:
break
cap.release()
cv2.destroyAllWindows()
+3
source to share