代码拉取完成,页面将自动刷新
import lxml.etree as ET
import os
filePath = '../data/Annotations/'
# tmp = os.listdir(filePath)
for f in os.listdir(filePath):
tree = ET.parse('{}{}'.format(filePath,f))
# tree = ET.parse('/usr/repository/Python/xmltest/test.xml')
objs = [tree.getroot()[3]]
# objs = tree.findall('object')
# objs = [root[3]]
with open('./model/ship_gt/labels_withoutname/{}.txt'.format(f.split('.')[0]),"w") as f:
for ix, obj in enumerate(objs):
# name = obj[0].text.lower()
quad = obj[1]
x0 = float(quad[0].text)
y0 = float(quad[2].text)
x1 = float(quad[1].text)
y1 = float(quad[2].text)
x2 = float(quad[1].text)
y2 = float(quad[3].text)
x3 = float(quad[0].text)
y3 = float(quad[3].text)
# f.write("{},{},{},{},{},{},{},{},{}".format(x0,y0,x1,y1,x2,y2,x3,y3,name))
f.write("{},{},{},{},{},{},{},{}".format(x0,y0,x1,y1,x2,y2,x3,y3))
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。