作者:微信小助手
发布时间:2020-04-22T00:29:33
效果展示
这是如何实现的?
import cv2
import os
import numpy as np
from PIL import Image
import paddlehub as hub
def CutVideo2Image(video_path, img_path):
cap = cv2.VideoCapture(video_path)
index = 0
while(True):
ret,frame = cap.read()
if ret:
cv2.imwrite(img_path + '%d.jpg' % index, frame)
index += 1
else:
break
cap.release()
print( 'Video cut finish, all %d frame' % index)
该步骤将会把每一帧图像保存到本地目录。