I am using labelImg to draw a rectangle on the rows of image. Which gives me the xml file . With the help of this xml how to extract that text from the image table . To extract the text I have used the horizontal and vertical ine detection but do not get good result. Now I am using the labelImg which gives me the points of that text which want to extract but I do not know how to apply the method for this .Please tell me how to do that ?
My xml file :
<annotation>
<folder>Test Images</folder>
<filename>FreKa.jpg</filename>
<path>/home/sumit/Desktop/office_works/Fusion_Code/BIS_Final/Test Images/FreKa.jpg</path>
<source>
<database>Unknown</database>
</source>
<size>
<width>679</width>
<height>341</height>
<depth>3</depth>
</size>
<segmented>0</segmented>
<object>
<name>Contact Type</name>
<pose>Unspecified</pose>
<truncated>1</truncated>
<difficult>0</difficult>
<bndbox>
<xmin>1</xmin>
<ymin>100</ymin>
<xmax>678</xmax>
<ymax>157</ymax>
</bndbox>
</object>
</annotation>
My input images :
how to extract the contract type from the table with the help of the xml file ? Thanks...
To get
xmin
you can usexpath()
with'//annotation/object/bndbox/xmin'
or even shorter'//xmin'
It always gives list (even if there is only one element or there are no elements) so it will need
[0]
to get first element orfor
-loop to work with all elements.Using
if list_of_elelemts: ...
you can run code only when list has some elements.You can also use
len()
to check how many elements you get.