import xml.etree.ElementTree as ET import os import matplotlib.pyplot as plt def get_center(filepath,sku): num_x = [] num_y = [] for root, folder, files in os.walk(filepath): for file in files: if file.endswith('xml'): dir = os.path.join(root,file) tree = ET.parse(dir) rt = tree.getroot() for object1 in rt.findall('object'): sku_name = object1.find('name').text if (sku_name == str(sku)): bndbox1 = object1.find('bndbox') x1 = bndbox1.find('xmin') x2 = bndbox1.find('xmax') y1 = bndbox1.find('ymin') y2 = bndbox1.find('ymax') x = (float(x1.text) + float(x2.text))/2
读取xml数据,绘制直方图和散点图
最新推荐文章于 2023-05-06 14:44:43 发布