OpenCV 3 Computer Vision with Python Cookbook
上QQ阅读APP看书,第一时间看更新

How to do it...

The following are the steps for this recipe:

  1. Create a VideoCapture object for video file:
import cv2

capture = cv2.VideoCapture('../data/drop.avi')
  1. Replay all the frames in the video:
while True:
has_frame, frame = capture.read()
if not has_frame:
print('Reached the end of the video')
break

cv2.imshow('frame', frame)
key = cv2.waitKey(50)
if key == 27:
print('Pressed Esc')
break

cv2.destroyAllWindows()