I am annotating a dataset for computer vision application. I have normalised coordinates(xmin,ymin,xmax,ymax) in form of xml file
The complete xml looks like this:
<annotation>
<folder>image</folder>
<filename>100_icdar13.png</filename>
<path>/Users/image/100_icdar13.png</path>
<source>
<database>Unknown</database>
</source>
<size>
<width>816</width>
<height>608</height>
<depth>3</depth>
</size>
<segmented>0</segmented>
<object>
<name>text</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>192</xmin>
<ymin>157</ymin>
<xmax>530</xmax>
<ymax>223</ymax>
</bndbox>
</object>
<object>
<name>text</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>561</xmin>
<ymin>159</ymin>
<xmax>645</xmax>
<ymax>219</ymax>
</bndbox>
</object>
<object>
<name>text</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>74</xmin>
<ymin>247</ymin>
<xmax>465</xmax>
<ymax>311</ymax>
</bndbox>
</object>
<object>
<name>text</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>493</xmin>
<ymin>255</ymin>
<xmax>625</xmax>
<ymax>305</ymax>
</bndbox>
</object>
<object>
<name>text</name>
<pose>Unspecified</pose>
<truncated>0</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>85</xmin>
<ymin>339</ymin>
<xmax>496</xmax>
<ymax>400</ymax>
</bndbox>
</object>
</annotation>
I want to denormalise this dataset and export all the boxes it in following format
x1, y1, x2, y2, x3, y3, x4, y4, text
How do I do this, what algorithm can I use to achieve this?
You can use
ElementTree
to parse XML and extract coordinates:which outputs:
This is the answer :
output: