Ask Your Question

Revision history [back]

Why is the null type expected error occurs if VideoCapture('vtest.avi') is replaced by VideoCapture(0) in BackgroundSubtractorMOG2 tutorial?

import numpy as np import cv2

cap = cv2.VideoCapture(0)

fgbg = cv2.createBackgroundSubtractorMOG2()

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()

click to hide/show revision 2
No.2 Revision

updated 2017-01-25 03:41:05 -0600

berak gravatar image

Why is the null type expected error occurs if VideoCapture('vtest.avi') is replaced by VideoCapture(0) in BackgroundSubtractorMOG2 tutorial?

import numpy as np
import cv2

cv2

cap = cv2.VideoCapture(0)

cv2.VideoCapture(0)

fgbg = cv2.createBackgroundSubtractorMOG2()

cv2.createBackgroundSubtractorMOG2()

while(1): ret, frame = cap.read()

cap.read()
 fgmask = fgbg.apply(frame)

 cv2.imshow('frame',fgmask)
 k = cv2.waitKey(30) & 0xff
 if k == 27:
     break

cap.release()
cv2.destroyAllWindows()

cap.release() cv2.destroyAllWindows()