data为图片汇总文件夹
import os
import glob
import cv2
import shutil
seq_dir = os.path.expanduser('./data/')
img_files=glob.glob(seq_dir + '*.jpg')
size = []
for f, img_file in enumerate(img_files):
img = cv2.imread(img_file,0)
shape = img.shape
if shape not in size:
size.append(shape)
index = size.index(shape)
if not os.path.exists(str(index)): #判断是否存在文件夹如果不存在则创建为文件夹
os.makedirs(str(index))
shutil.copyfile(img_file, './'+ str(index)+'/'+img_file[6:]) # 复制文件