python,opencv逐帧读取视频并保存为图片

版权声明:如无允许,请勿转载 https://blog.csdn.net/agq358/article/details/90209776
# -*- encoding: utf-8 -*-
import cv2
import os

images = './image/'
if not os.path.exists(images):
    os.mkdir(images)

cap = cv2.VideoCapture("20190514_134006.mp4")
c=0
while(1):
    success, frame = cap.read()
    if success:
        cv2.imwrite(images+str(c) + '.jpg',frame)
        c=c+1
    else:
        break
cap.release()

猜你喜欢

转载自blog.csdn.net/agq358/article/details/90209776