如何解决使用 opencv
有没有办法从 opencv 中获取帧格式,但大约是视频的一半(例如,如果视频是 10 分钟,我想在 5:00 分钟保存一个帧)。我已经在互联网上看到了一些东西,但每个人都只是一帧一帧地前进。感谢您的帮助
解决方法
我相信您正在寻找这样的东西:
import cv2
# Read the Video (Change the filename as per your file)
cap = cv2.VideoCapture("video.mp4")
# Get the total number of frames
length = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))
half_point = length//2 # Approximately half if number of frames are odd
# Set the reader to the given frame number (half_point)
cap.set(cv2.CAP_PROP_POS_FRAMES,half_point)
# Read the frame
ret,frame = cap.read()
# Release the file pointer
cap.release()
你应该得到变量 frame
中的半点坐标系。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。