import re
import cv2 as cv
import numpy as np
import os
import os.path
import glob
SourceImgPath = "C:\\RenameImgToVoc\\output"+'\\'
SacePath = "C:\\RenameImgToVoc\\input"+'\\'
total_sou = os.listdir(SourceImgPath)
img_start = 86
ImageNameFormat = '.jpg'
for img_source in total_sou:
ImgPath = os.path.join('%s%s' % (SourceImgPath, img_source))
print("ImgPath"+ImgPath)
ImageNameNumStart = str(img_start ).zfill(6)
ImageName = ImageNameNumStart + ImageNameFormat
img = cv.imread(ImgPath, 1)
print(SacePath + ImageName)
cv.imwrite(os.path.join('%s%s' % (SacePath, ImageName)), img)
img_start = img_start + 1
'''
去掉字符串中的括号
s= '(001).jpg'
re.sub('[\(\)]','',s)
数字字符串获取固定长度的数值,不够的左边补0
stk_code = 1
stk_code = str(stk_code).zfill(6)
print(stk_code )
输出结果:000001
'''