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

# -*- 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()

 

你可能感兴趣的:(工具)