yolo数据集txt标注格式为:
0 0.159375 0.552083 0.121875 0.381944
0 0.776953 0.747222 0.099219 0.361111
代码如下:
import cv2
import os
xml_head = '''<annotation>
<folder>VOC2007</folder>
<!--文件名-->
<filename>{}</filename>
<source>
<database>The VOC2007 Database</database>
<annotation>PASCAL VOC2007</annotation>
<image>flickr</image>
<flickrid>325991873</flickrid>
</source>
<owner>
<flickrid>null</flickrid>
<name>null</name>
</owner>
<size>
<width>{}</width>
<height>{}</height>
<depth>{}</depth>
</size>
<segmented>0</segmented>
'''
xml_obj = '''
<object>
<name>{}</name>
<pose>Rear</pose>