How to extract the annotation file of XML data using MATLAB?

24 views (last 30 days)
Dear all,
We have downloaded the road dataset online, in that, they have created annotation (Ground truth) for all the original images. The annotated images are in XML format, and we could open the XML data in notepad.
How to extract the information of annotated data (XML) file in MATLAB. How to view the information of annotated data (XML) as an image format.
One sample original image (000001.jpg) and its annotations (Ground truth (000001.xml)) files are attached here.
Would you please let us know that how to proceed further? Any help would be highly appreciable.
Thanks and regards
Mario Malic
Mario Malic on 22 Jul 2021
It's impolite to tag people like that. There isn't much information about processing XML files, but there should be enough to get you started. See here

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 22 Jul 2021
Edited: Walter Roberson on 22 Jul 2021
T = readtable('000001.xml');
img = imread('000001.jpg');
x = T.xmin;
width = T.xmax - x + 1;
y = T.ymin;
high = T.ymax - y + 1;
img2 = insertShape(img, 'rectangle', [x, y, width, high]);
I completely agree with you that code will work.
I am currently using MATLAB 2019a version. Is that okay?

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by