为了计算map值,需要提供ground truth txt和detection txt两个文件,而第一个需要将xml中的xmin xmax ymin ymax写入到txt文件中,代码如下
# -*- coding:utf8 -*-
import os
import xml.dom.minidom
import re
def read_xml(filepath ,name):
dom = xml.dom.minidom.parse(filepath)
root = dom.documentElement
faces = dom.getElementsByTagName('name')
face_n = len(faces)
if face_n > 0:
#
# # write filename
# itemlist = root.getElementsByTagName('path')
# item = itemlist[0]
# filepath = item.firstChild.data
# filename_1 = re.split('Desktop\\\\', filepath)[1]
# filepath_1 = re.sub('\\\\', '/', filename_1)
# line = re.sub('_full.jpg', '.xml', filepath_1) + '\n'
# print(filepath_1)
# list.write(line)
# write face number
# print(face_n