1 | initial version |
You need to check that your video is finished. 'ret' from cap.read() is always True whenever there is a frame, False when we reach to the end of the video and there is no frame to read.
import cv2
cap = cv2.VideoCapture('C:\Users\wg\174037210.avi')
while(cap.isOpened()):
ret, frame = cap.read()
if not ret:
break
cv2.imshow('Video', frame)
if cv2.waitKey(75) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
2 | No.2 Revision |
You need to check that your video is finished.
'ret' ret from cap.read() cap.read() is always True whenever there is a frame, False when we reach to the end of the video and there is no frame to read.
import cv2
cap = cv2.VideoCapture('C:\Users\wg\174037210.avi')
while(cap.isOpened()):
ret, frame = cap.read()
if not ret:
break
cv2.imshow('Video', frame)
if cv2.waitKey(75) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()