Author: gnuhpc
Source: http://www.cnblogs.com/gnuhpc/
# Include "highgui. H "# include" CV. H "# include" cxcore. H "# include <iostream> # include <iomanip> using namespace STD; int main (void) {cvmat * MAT = cvcreatemat (3,3, cv_32sc1); cvsetidentity (MAT ); cvmemstorage * memstorage = cvcreatememstorage (0); // memory (required for Data Writing) cvfilestorage * fs_write_xml = cvopenfilestorage ("mat. XML ", memstorage, cv_storage_write); cvfilestorage * fs_write_yml = cvopenfilestorage (" mat. yml ", memstorage, cv_storage_write); // file storage structure cvwritecomment (fs_write_xml," mat_xml ", 1); // Add comments cvwrite (fs_write_xml," cvmat ", mat, cvattrlist (null, null); // write data to cvreleasefilestorage (& fs_write_xml) in the XML file; cvwritecomment (fs_write_yml, "mat_yml", 1 ); // Add comments cvwrite (fs_write_yml, "cvmat", mat, cvattrlist (null, null); // write data to the XML file cvreleasefilestorage (& fs_write_yml ); cvreleasememstorage (& memstorage); cvreleasemat (& mat); Return 0 ;}