Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Read and write Mat to xml file un root node

Hello,

I am trying to save Mat to a xml file. I follow this tutorial and its works very well : link

The problem I have a xml with some value before and if I tried to write in this file, It will erase all my data to remplace with a root node <opencv_storage>. For example if tried to write in a xml like this :

<?xml version="1.0"?>
<hello>
<world>hello world</world>
</hello>

If I tried to write in this file the program will with a error :

OpenCV Error: Parsing error (test.xml(2): <opencv_storage> tag is missing) in icvXMLParse, file ..\..\..\..\opencv\modules\core\src\persistence.cpp, line 2281

I can resolve this problem creating an empty node <\opencv_storage> in the xml file, like this :

<?xml version="1.0"?>
<hello>
<world>hello world</world>
<opencv_storage></opencv_storage>

And then close the root node (don't why if I put the </hello> in the xml file it will be after <opencv_storage>).

But I still have problems to read the mat, because I think FileStorage is waiting a root node <opencv_storage>, so I was wondering is somebody have an idea to resolve this problem.

Best regards

Read and write Mat to xml file un under root node

Hello,

I am trying to save Mat to a xml file. I follow this tutorial and its works very well : link

The problem I have a xml with some value before and if I tried to write in this file, It will erase all my data to remplace with a root node <opencv_storage>. For example if tried to write in a xml like this :

<?xml version="1.0"?>
<hello>
<world>hello world</world>
</hello>

If I tried to write in this file the program will with a error :

OpenCV Error: Parsing error (test.xml(2): <opencv_storage> tag is missing) in icvXMLParse, file ..\..\..\..\opencv\modules\core\src\persistence.cpp, line 2281

I can resolve this problem creating an empty node <\opencv_storage> in the xml file, like this :

<?xml version="1.0"?>
<hello>
<world>hello world</world>
<opencv_storage></opencv_storage>

And then close the root node (don't why if I put the </hello> in the xml file it will be after <opencv_storage>).

But I still have problems to read the mat, because I think FileStorage is waiting a root node <opencv_storage>, so I was wondering is somebody have an idea to resolve this problem.

Best regards