import numpy as np import cv2 cap = cv2.VideoCapture(\'vtest.avi\') fgbg = cv2.bgsegm.createBackgroundSubtractorMOG() while(1): ret, frame = cap.read() fgmask =
If you are using python3, write:
fgbg =cv2.createBackgroundSubtractorMOG2() #For python3
And not:
fgbg = cv2.bgsegm.createBackgroundSubtractorMOG()