123456789101112131415161718 |
- import os
- import cv2
- import numpy as np
- def main():
- data_dir_path ="C:\\Users\\User\\Desktop\\test"
- file_list = os.listdir(r'C:\Users\User\Desktop\test')
- count = 0
- for file_name in file_list:
- root, ext = os.path.splitext(file_name)
- if ext == '.png' or '.jpeg' or '.jpg':
- abs_name = data_dir_path + '/' + file_name
- image = cv2.imread(abs_name)
- #在下面寫要做的處理 在這邊是做修改圖片大小的處理
- img = cv2.resize(image, (10, 10)) #把圖片的大小改成150*150
- cv2.imwrite(abs_name, img)
- if __name__ == '__main__':
- main()
|