Reading xml file with opencv image type_id using opencv

Hi I tried a lot of searching in reading xml file with type_id "opencv-image", all I look at here is "opencv-matrix" and all the help available is useless to me. Please help me in reading the image matrix from xml file.

I am pasting the top of my xml file here for some idea.

<?xml version="1.0"?>
<opencv_storage>
<depthImg190 type_id="opencv-image">
<width>320</width>
<height>240</height>
<origin>top-left</origin>
<layout>interleaved</layout>
<dt>w</dt>
<data>
0 0 0 0 27120 27384 27120 27120 27384 27120 27120 27120 27120 27384
27384 27664 27664 27944 27944 27664 27664 27944 27944 27944 28224
27944 27944 28224 28224 28224 28224 28520 28816 29120 29120 29120
29120 29120 29120 29120 29432 29744 30072 30072 29744 29744 30072
30072 30072 30400 30400 30736 30736 31080 31080 31080 31440 31440
31440 31440 31800 31800 31800 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 27120 27120 27120 27120 27384 27384 27384 27384 27384 27384
</depthImg190>
</opencv_storage>

      

I used code

FileStorage f;
Mat m;
f.open("temp.xml", FileStorage::READ);
f["depthImg190"] >> m;
f.release();

      

but I ran into the exception "Opencv Errorr: Bad argument <Unknown array type> in cv :: read, file ........ \ opencv \ modules \ core \ persistence.cpp, line 5535".

Any help would be appreciated

-3


source to share


1 answer


There is actually some documentation you can use for example: http://docs.opencv.org/modules/core/doc/xml_yaml_persistence.html

Anyway, the answer to your problem is easy:



FileStorage fs("file.xml", FileStorage::READ);
Mat image;

fs["depthImg190"] >> image;

(...)

fs.release();

      

It should work!

+2


source







All Articles