更改图像及xml名称,并移动图形及对应xml

 

 

 


from xml.etree.ElementTree import ElementTree
import cv2
import os

def read_xml(in_path):
tree = ElementTree()
tree.parse(in_path)
return tree

def write_xml(tree, out_path):
tree.write(out_path)

path_input='C:/Users/51102/Desktop/STR01'
path_out='C:/Users/51102/Desktop/456'

names=os.listdir(path_input)
for name in names:
a, b = os.path.splitext(name)
if b == '.jpg':
if a+'.jpg' in names and a+'.xml' in names:
img=cv2.imread(path_input+'/'+a+'.jpg')
cv2.imwrite(path_out+'/'+a+'_repeat.jpg',img)
tree=read_xml(path_input+'/'+a+'.xml')
write_xml(tree,path_out+'/'+a+'_repeat.xml')
print(a)




posted @ 2020-06-03 23:41  tangjunjun  阅读(343)  评论(0编辑  收藏  举报
https://rpc.cnblogs.com/metaweblog/tangjunjun