Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

This happens when for some reason cap.read() returns empty frame. just add a check: while(True): # Capture frame-by-frame ret, frame = cap.read()

# Our operations on the frame come here

gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)

Display the resulting frame

cv2.imshow('frame',gray) if cv2.waitKey(1) & 0xFF == ord('q'): break

This happens when for some reason cap.read() returns empty frame. just add a check: check:

while(True):
    ret, frame = cap.read()
    if frame:
 while(True): # Capture frame-by-frame ret, frame = cap.read()

# Our operations on the frame come here

gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)

Display the resulting frame

cv2.COLOR_BGR2GRAY) cv2.imshow('frame',gray) if cv2.waitKey(1) & 0xFF == ord('q'): break

break

This happens when for some reason cap.read() returns empty frame. just add a check:

while(True):
while True:
    ret, frame = cap.read()
    if frame:
        gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
        cv2.imshow('frame',gray)
cv2.imshow('frame', gray)
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break