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

조회 수: 15 (최근 30일)
SUKUMAR NAGINENI
SUKUMAR NAGINENI 2021년 7월 22일
댓글: SUKUMAR NAGINENI 2021년 7월 23일
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
Sukumar.
  댓글 수: 2
Rik
Rik 2021년 7월 22일
There are many ways to read text files, and there are many ways to parse XML text to a struct. What did you try already? How did the results differ from what you expect or want?
Mario Malic
Mario Malic 2021년 7월 22일
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 https://uk.mathworks.com/help/matlab/ref/xmlread.html

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2021년 7월 22일
편집: Walter Roberson 2021년 7월 22일
(tested)
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]);
imshow(img2)
  댓글 수: 3
Walter Roberson
Walter Roberson 2021년 7월 23일
Is it possible that you forgot to mention that you are using an older MATLAB version? I tested the code before I posted. I would have shown the output but it was a nuisance to attach an XML file.
SUKUMAR NAGINENI
SUKUMAR NAGINENI 2021년 7월 23일
I completely agree with you that code will work.
I am currently using MATLAB 2019a version. Is that okay?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Environment and Settings에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by