#coding:utf-8
import os
import argparse
import sys
try:
import cv2
except:
print("Need to install OpenCV:")
print("pip install OpenCV")
def readVideo(videoFile, folder, videoName, timeF):
vc=cv2.VideoCapture(videoFile)
c=1
if vc.isOpened():#判断是否正常打开
rval,frame=vc.read()
else:
rval=False
while rval:#循环读取视频
rval,frame=vc.read()
if (c%timeF == 0):#每隔timeF帧进行存储操作
writefile = folder + videoName + '_' + str(c) + '.jpg'
cv2.imwrite(writefile,frame)#存储为图像
print(writefile)
c = c + 1
cv2.waitKey(1)
vc.release()
if __name__ == '__main__':
print('\nPython Version:\n',sys.version)
ap = argparse.ArgumentParser()
ap.add_argument("-i","--videoFile_in", required=True, help="path to input video file")
ap.add
按帧率进行视频切图脚本
最新推荐文章于 2023-03-03 23:30:46 发布