从视频中每隔固定帧进行提取图片

import cv2 as cv

def video_demo():
    """
    打开视频
    """
    capture = cv.VideoCapture("./pic/video/double_one.MP4") #修改为自己路径
    flag = 1
    while True:
        ret, frame = capture.read()
        if flag % 60 == 0 and ret is True:
            cv.imshow("frame", frame)
            cv.imwrite("./pic/double_one_frame/20200918" + str(flag) + ".png", frame) # 修改为自己路径
            flag += 1
        c = cv.waitKey(50)
        if c == 27:
            break


cv.namedWindow("frame", 0)
video_demo()
cv.destroyAllWindows()

我是每60帧进行计时的

猜你喜欢

转载自blog.csdn.net/qq_41542989/article/details/108670490