说明
本代码本意用于初学者裁剪和扩充自己的数据集用,练手时我这个懒人最喜欢这么干.
代码
def cut_done_func(source_path, output_path, file_type, cut_size, step):
# 读取并遍历文件夹中的图片
path_files = os.listdir(source_path)
for item_name in path_files:
if item_name.endswith(file_type): # 扩展名是图片
# 调用cv2.imread读入图片,读入格式为IMREAD_COLOR
full_name = source_path + "/" + item_name