I wrote some code to generate an .xml file that contains the RGB data from a Mat file in OpenCV. I would like to recreate this image in MATLAB from the data points in the xml file. I am however unsure of the formatting of the xml file, since when I open it it looks something like this:
<?xml version="1.0?>
<opencv_storage>
<myMatrix type_id="opencv-matrix">
<rows>116</rows>
<cols>116</cols>
<dt>u</dt>
<data>
97 101 97 98 99 97 ...
</data>
</myMatrix>
</opencv_storage>
you can convert it to matlab format within opencv.
read it in using the Filestorage:
Mat m;
Filestorage fs("m.xml", Filestorage::READ);
fs["myMatrix"] >> m;
then print it out (or write to a file) in matlab format:
// 2.4 version
cerr << format(m,"MATLAB") << endl;
// 3.0 version
cerr << format(m,cv::Formatter::FMT_MATLAB) << endl;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With