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)
cv2.imshow('frame',gray) if cv2.waitKey(1) & 0xFF == ord('q'): break
2 | No.2 Revision |
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
3 | No.3 Revision |
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