import os import cv2 from tqdm import tqdm #总数据集图像路径 imgway_1="E:/data-temporary/zhongtian_nianhou/shoes/del" #符合要求图像的路径 imgway_2="E:/data-temporary/zhongtian_nianhou/shoes/0216_dataset/background" #不符合要求图像的路径. imgway_3="G:/zhongtian_second/hangche/images background" #误触 imgway_7='G:/zhongtian_second/hangche/images background' for filename in tqdm(os.listdir(r"%s" % imgway_1)): img = cv2.imread("%s/%s"%(imgway_1,filename)) h, w, c = img.shape resize_width = int(w * 2) resize_height = int(h * 2) # cv2.namedWindow(img, cv2.WINDOW_NORMAL) # cv2.resizeWindow(img, resize_width, resize_height) #缩小显示 img = cv2.resize(img,(resize_width,resize_height)) #更改图片大小,设定为指定大小o # # h = 640 # # w = 300 # cv2.resizeWindow(img, resize_height, resize_width) # cv2.namedWindow('datasets',0) cv2.imshow('datasets', img) k=cv2.waitKey(0)& 0xFF if k == ord('o'): cv2.imwrite('%s/%s' % (imgway_2, filename),img) print('%s符合要求!' % filename) cv2.destroyAllWindows() elif k == ord('k'): pass # cv2.imwrite('%s/%s' % (imgway_3, filename),img) # print('%s不符合要求!' % filename) # cv2.destroyAllWindows() else: cv2.imwrite('%s/%s' % (imgway_7, filename),img) print('误触错误的键!背景图%s保存至mistake文件夹!' % filename) cv2.destroyAllWindows()