Ask Your Question

Revision history [back]

FileStorage fs("test.xml", FileStorage::WRITE);
Mat myMatrix = (Mat_<int>(3,3) << 1,2,3,4,5,6,7,8,9);
fs << "myMatrix" << myMatrix;
fs.release();

Mat myMatrix2;
FileStorage fs2("test.xml", FileStorage::READ);
fs2["myMatrix"] >> myMatrix2;
fs2.release();

Content of "test.xml":

 <?xml version="1.0"?>
 <opencv_storage>
 <myMatrix type_id="opencv-matrix">
   <rows>3</rows>
   <cols>3</cols>
   <dt>i</dt>
   <data>
     1 2 3 4 5 6 7 8 9</data></myMatrix>
 </opencv_storage>

http://docs.opencv.org/modules/core/doc/xml_yaml_persistence.html#