Valid XML should start with '<?xml ...?>' in function icvXMLParse
I am reading the following yaml file, converted from the xml of pascal VOC 2007:
annotation:
filename: 000001.jpg
folder: VOC2007
object:
- bndbox: {xmax: '195', xmin: '48', ymax: '371', ymin: '240'}
difficult: '0'
name: dog
pose: Left
truncated: '1'
- bndbox: {xmax: '352', xmin: '8', ymax: '498', ymin: '12'}
difficult: '0'
name: person
pose: Left
truncated: '1'
owner: {flickrid: Fried Camels, name: Jinky the Fruit Bat}
segmented: '0'
size: {depth: '3', height: '500', width: '353'}
source: {annotation: PASCAL VOC2007, database: The VOC2007 Database, flickrid: '341012865',
image: flickr}
using
FileStorage fs(fName, FileStorage::READ);
I get this error:
OpenCV Error: Parsing error (/opt/Datasets/VOCdevkit_test/VOC2007/Annotations/000001.yml(1): Valid XML should start with '<?xml ...?>'
) in icvXMLParse, file /home/alessandro/OpenCV/opencv-2.4.10.x-prep/modules/core/src/persistence.cpp, line 2252
terminate called after throwing an instance of 'cv::Exception'
what(): /home/alessandro/OpenCV/opencv-2.4.10.x-prep/modules/core/src/persistence.cpp:2252: error: (-212) /opt/Datasets/VOCdevkit_test/VOC2007/Annotations/000001.yml(1): Valid XML should start with '<?xml ...?>'
in function icvXMLParse
Aborted (core dumped) It is from an existing open source code that has worked in others settings. Does anyone idea of the problem? Is something related with OpenCv version? I am using 2.4.10
* how did you convert it from xml to yaml ? * can you try to insert a `%YAML:1.0` line at the top ?
I'm getting the same error. It works fine with an xml file, but in order to be consistent with the other part of our system, I needed to read in the data in yaml format. I do the same thing as you, and get the same error :-( It's trying to read it as an xml though it's supposed to know it's yaml from the extension!
Hmm somehow hes parsing the yaml file as xml - maybe you need to use a yaml parser instead of xml one.
Look at the error "...in icvXMLParse..." So look abit around the api to find the correct configuration. Esp look at the FileStorage class
https://docs.opencv.org/3.1.0/da/d56/... You can use an enum mode for the FileStorage Constructor telling the format. I think the rest you can do by yourself.
i guess, the op simply forgot to rename the files to
.yml
(cv::FileStorage is actually looking at the extension first)Ahh - so you dont even have to configure explicitly. Thats convenient :-) Berak most likely gave the solution to the problem. Upvoted. If its working please close the thread as solved.
look at the date. q. from 2014
Oh man - thats the 2nd time it happens. That also explains opencv2.4.1... Sorry :-)