import os
import xml.dom.minidom
AnnoPath = r'./fracture/train/annotations/'
Annolist = os.listdir(AnnoPath)
sum = 0
for annotation in Annolist:
filename = AnnoPath + annotation
dom = xml.dom.minidom.parse(filename) # 打开XML文件
collection = dom.documentElement # 获取元素对象
objectlist = collection.getElementsByTagName('bndbox') # 获取标签名为box的信息
count = objectlist.length
sum = sum + count
print("文件名:", filename,"标注数:", count)
print(sum)
查找xml文件中标签出现次数
最新推荐文章于 2022-07-29 17:09:07 发布