I have some images, which I annotated using MATLAB's imageLabler tool. As a result I got gtruth.mat file (which contains annotations of all of the images).
Now I would like to train a simple object detector using these annotations. However, the object detector that I am using (dlib object detector), only accepts XML format.
Is it possible to convert that .mat file into an XML file, so that my all annotations remain intact and I can train my custom object detector? If so, how can I do that?
It appears that this question deals with converting a
groundTruthobject into dlib-friendly XML.So first we need to ask ourselves, what is a
groundTruthobject? I have made a toy example using the Image Labeler and some images available in the MATLAB installation folder. Here's what I got:(The above contains 2 of the 3 available types of labels, the 3rd being Pixel Labels, which I decided to skip here.)
Now, what does a dlib-friendly XML look like? I'm not entirely sure, so I'll go with this one:
So the mapping you need appears to be:
<image>node whosefileattribute points togTruth.DataSource.Source{1...n}.Rectangle-type label, create a<box>node.gTruth.LabelDataneeds to be transformed into e.g.top='26' left='33' width='78' height='73'.<label>node.<label>node.Scene-type label, will not have a<box>node enclosing<label>.<part>node is for.Creating a converter based on the above should be straightforward. You could use
struct2xmlto help you, and/orxmlwrite.