一、视频转图片(这个不太可以,转得太细了,见8.23)
代码来源:https://zhuanlan.zhihu.com/p/108213045
import cv2
import os
def save_img():
video_path = 'C:/Users/NJX/Desktop/test'
videos = os.listdir(video_path)
for video_name in videos:
file_name = video_name.split('.')[0]
folder_name = video_path + file_name
os.makedirs(folder_name, exist_ok=True)
vc = cv2.VideoCapture(video_path+'/'+video_name)
c=0
rval=vc.isOpened()
while rval:
c = c + 1
rval, frame = vc.read()
pic_path = folder_name+'/'
if rval:
cv2.imwrite(pic_path + str(c) + '.png', frame)
cv2.waitKey(1)
else:
break
vc.release()
print('save_success')
print(folder_name)
save_img()
二、图片数量
训练集、验证集、测试集=6:2:2
留3000张(白天前2万,黑天50282~60282=2500+500)