python将pascal_voc xml转化为txt

本文介绍如何使用Python将Pascal VOC XML格式的图像标注文件转换成简单的TXT格式,每行包含图片路径及物体的边界框坐标和类别编号。
摘要由CSDN通过智能技术生成
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import os
import os.path
import xml.etree.ElementTree as ET 
import xml.dom.minidom as xdm
import sys 

xml_path='/Users/chenhonghu/Downloads/data/xml/'
txt_path='/Users/chenhonghu/Downloads/data/txt/'
img_path='/work/traffic/data2/chenhonghu/tf-faster-rcnn-master/data/VOCdevkit2007/VOC2007/JPEGImages/'

f=open(os.path.join(txt_path, 'train.txt'), 'a')

xml_list=os.listdir(xml_path)

class_num={'car_region':'0', 'front_win':'1', 'rear_mirror':'2', 'wheel':'3', 
           'front_light':'4', 'car_logo':'5', 'car_head':'6', 'text':'7', 'rear_light':'8',
           'trunk':'9', 'car_tail':'10', 'car_type_logo':'11', 'front_windsheild':&
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值