import os
import cv2
import shutil
cut_frame = 10 # 多少帧截一次,自己设置就行
srcimg_path = "D:/video/train2/images/"
srclabel_path = "D:/video/train2/labels/"
train_img = "D:/video/datasets4/images/train/"
val_img = "D:/video/datasets4/images/val/"
train_label = "D:/video/water-bottle/datasets4/labels/train/"
val_label = "D:/video/water-bottle/datasets4/labels/val/"
ii = 0
for root, dirs, files in os.walk(srcimg_path): # 这里就填文件夹目录就可以了
for file in files:
# 获取文件路径
if ('.jpg' in file):
ii = ii +1
print("\n")
print(file)
srcfile = srcimg_path+file
index = file.find(".")
str0 = file[0:index]+".txt"
srclabel = srclabel_path + str0
if ii%4==0:
dstfile = val_img+file
shutil.copy(srcfile, dstfile)
dstlabel = val_label + str0
shutil.copy(srclabel, dstlabel)
else:
dstfile = train_img+file
shutil.copy(srcfile, dstfile)
dstlabel = train_label + str0
shutil.copy(srclabel, dstlabel)