vlfeat / matconvnet

MatConvNet: CNNs for MATLAB
Other
1.4k stars 752 forks source link

Error using VOCxml2struct>parse (line 16) <annotation> closed with <folder> #808

Open HaziqRazali opened 7 years ago

HaziqRazali commented 7 years ago

I am getting the error mentioned in the title when I try to pass in my own xml files for parsing. I have modified my xml files such that it is similar to that of VOC's but I am still having problems. I am using TinyXML-2

This is my xml file

<annotation>
    <folder>train</folder>
    <filename>004213</filename>
    <source>
        <database>KITTI database</database>
        <annotation>KITTI database</annotation>
        <image>KITTI database</image>
        <flickrid>1337</flickrid>
    </source>
    <owner>
        <flickrid>1337</flickrid>
        <name>test</name>
    </owner>
    <size>
        <width>1242</width>
        <height>375</height>
        <depth>3</depth>
    </size>
    <segmented>0</segmented>
    <object>
        <name>Car</name>
        <pose>unspecified</pose>
        <truncated>0</truncated>
        <difficult>0</difficult>
        <bndbox>
            <xmin>550.82000000000005</xmin>
            <ymin>175.00999999999999</ymin>
            <xmax>611.14999999999998</xmax>
            <ymax>235.13999999999999</ymax>
        </bndbox>
    </object>
</annotation>

this is VOC's

<annotation>
    <folder>VOC2007</folder>
    <filename>000001.jpg</filename>
    <source>
        <database>The VOC2007 Database</database>
        <annotation>PASCAL VOC2007</annotation>
        <image>flickr</image>
        <flickrid>341012865</flickrid>
    </source>
    <owner>
        <flickrid>Fried Camels</flickrid>
        <name>Jinky the Fruit Bat</name>
    </owner>
    <size>
        <width>353</width>
        <height>500</height>
        <depth>3</depth>
    </size>
    <segmented>0</segmented>
    <object>
        <name>dog</name>
        <pose>Left</pose>
        <truncated>1</truncated>
        <difficult>0</difficult>
        <bndbox>
            <xmin>48</xmin>
            <ymin>240</ymin>
            <xmax>195</xmax>
            <ymax>371</ymax>
        </bndbox>
    </object>
    <object>
        <name>person</name>
        <pose>Left</pose>
        <truncated>1</truncated>
        <difficult>0</difficult>
        <bndbox>
            <xmin>8</xmin>
            <ymin>12</ymin>
            <xmax>352</xmax>
            <ymax>498</ymax>
        </bndbox>
    </object>
</annotation>
albanie commented 7 years ago

It normally arises from the interpretation of tabs and spaces in your file (I've been burnt by this before :( ). The reason is that the original xml parser is very sensitive to the input format (you can see a bit of this here).

When generating your xml files, they need to be indented with tabs (if you are a vim user, you can check this by running :set list which will show the type of indentations used - I'm not too knowledgeable about other editors but they will have equivalent tricks).

nuoma commented 7 years ago

I encountered the same problem. Have you solved that?

rizwanasif commented 7 years ago

@albanie i was creating the annotations using your wider2pascal but it gives me the same error. I have used the website to check for error it shows me no error..

rizwanasif commented 7 years ago

in VOCxml2struct function, we have xml(xml==9|xml==10|xml==13) = []; which removes the \n and spaces from the xml file. When i checked the result of this line, the XML generated using pascal2wider, the same line of code does not remove the additional spacing from the XML file. So, i changed it to xml(xml==9|xml==10|xml==13|xml==32)=[]; and it worked.

Hope it helps