我需要更改图片下方的文件夹名称,以下是我的代码:
# encoding: UTF-8
import glob as gb
import cv2
import os.path as osp
import os
#Returns a list of all folders with participant numbers
img_path = gb.glob("/home/xieyangyang/Downloads/dataset/Grayscale_Thermal/FastCarNig/v/*png")
img_path.sort()
i = 1
for path in img_path:
rename = osp.join(osp.split(path)[0], str(i) + '.png')
os.rename(path, rename)
i = i + 1
此代码可以工作,但是我反复运行了几次,发现图像缩小了。我不知道发生了什么,这让我很困惑。