import cv2
import os
for item in os.listdir('data/video'):
video = 'data/video/' + '/' + item
vc = cv2.VideoCapture(video) # 读入视频文件
ret, frame = vc.read()
name = 1
timeF = 5 # 5帧采取一次
while ret:
cv2.imshow("video", frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
vc.release()
break
if name % timeF == 0:
cv2.imwrite("data/crop_ok_video/" + item.split('.')[0] + '_' +str(name) + '.jpg', frame) # 写入文件夹
name += 1
ret, frame = vc.read()
01-01
02-02
4864