天天看點

opencv 改變圖像大小

import os
import cv2



if __name__ == '__main__':
    dataDir = 'D:/F/Desktop/ROMACESHI/img/'#讀取路徑
    saveDir = 'D:/F/Desktop/ROMACESHI/img_80_160/'#存儲路徑
    
    for file in os.listdir(dataDir):
      img= cv2.imread(dataDir+file)
      img=cv2.resize(img,(160,80),interpolation=cv2.INTER_LINEAR)
      cv2.imwrite(saveDir+file,img)