import xml.etree.ElementTree as ET
def parse_rec(filename):
"""Parse a PASCAL VOC xml file."""
tree = ET.parse(filename)
objects = []
for obj in tree.findall('object'):
obj_struct = {}
obj_struct['name'] = obj.find('name').text
rbox = obj.find('rbox')
obj_struct['rbox'] = [float(rbox.find('cx').text),
float(rbox.find('cx').text),
float(rbox.find('w').text),
float(rbox.find('h').text),
float(rbox.find('angle').text)]
objects.append(obj_struct)
return objects
python读取和解析xml文件
猜你喜欢
转载自blog.csdn.net/li4692625/article/details/127475573
今日推荐
周排行