Article directory
1、cv2.VideoCapture()
- Enter the video path and create a VideoCapture object
cv2.VideoCapture(filename)
filename: 视频文件的路径+视频名+扩展名
- The functions of this class are:
1) video.isOpened: Check whether the video capture is successful
2) video.read(): Read the video frame, return ret, frame, ret is a bool type, indicating whether it is successful
3) video.release(): Close the video
4) video .get(prop): Get the properties of video
- If you want to read each frame of the video and then perform related processing, you can achieve it through the following code:
video = cv2.VideoCapture(video_path)
while video.isOpened():
ret, frmae = video.read()
if ret:
# 对每一帧进行处理
else:
video.release()