# -*- coding: utf-8 -*-
import os
def file_name(file_dir):
for root, dirs, files in os.walk(file_dir):
#print(root) #当前目录路径
#print(dirs) #当前路径下所有子目录
#print(files) #当前路径下所有非目录子文件
return files
imgpath="C:/Users/dongdong/Desktop/标定图/img/"
files=file_name(imgpath)
'''
for path_i in files:
print(path_i)
'''
import cv2
i=0
for path_i in files:
#imgpath_i=imgpath+path_i
imgpath_i="./img/"+path_i
#print(imgpath_i)
img = cv2.imread(str(imgpath_i), 1) # 参数1表示以彩色图像读取
if img is None: # 检查路径是否正确
print(imgpath_i +' is not exist!')
continue
i=i+1
img_resize_name ="./img_resize/" +str(i)+".jpg"
img_resize = cv2.resize(img, (1920, 1080)) # 注意x,y的顺序不要写满
cv2.imwrite(img_resize_name, img_resize)
print(img_resize_name,"保存完毕")