请python大神看看我这个代码是哪里出错了
程序员文章站
2024-03-22 15:09:22
...
#coding:utf8
import os
import cv2.cv as cv
import cv2
# 遍历指定目录,显示目录下的所有文件名
width_scale = 128 #缩放尺寸宽度
height_scale = 128#缩放尺寸高度
write_path = "F:/all_data/1/"#要写入的图片路径
#遍历每一张图片进行处理
def eachFile(filepath):
pathDir = os.listdir(filepath)
for allDir in pathDir:
child = os.path.join('%s%s' % (filepath,allDir))
write_child = os.path.join('%s%s' % (write_path,allDir))
image = cv.LoadImage(child,0)
des_image = cv.CreateImage((width_scale,height_scale),image.depth,1)
cv.Resize(image,des_image,cv2.INTER_AREA)
# cv.ShowImage('afe',des_image)
cv.SaveImage(write_child,des_image)
# break
if __name__ == '__main__':
filePathC = "F:/all_data/train/"
eachFile(filePathC)
运行了以后,就只处理了train文件夹的最后一张图片,请问是哪里出了问题呢