1 import os 2 import cv2 as cv 3 4 path = "E:/codePro/python_pro/Yolo-Faster-XL_QR_pro/QR_Data/test/" 5 6 imgSavePath = "E:/codePro/python_pro/Yolo-Faster-XL_QR_pro/QR_Data/test_bmp/" 7 filelist = os.listdir(path) 8 9 nameTxt = "file.txt" 10 txtPathName = path + nameTxt 11 12 print(txtPathName) 13 14 f=open(txtPathName,"w") 15 16 cnt = 0 17 18 for item in filelist: 19 20 print(item) 21 imgName = path +item 22 img = cv.imread(imgName) 23 24 imgSaveName = imgSavePath + str(cnt)+".bmp" 25 cnt +=1 26 27 cv.imwrite(imgSaveName, img) 28 29 f.write( imgSaveName ) 30 31 f.write('\n') 32 f.close()View Code