作者:gnuhpc
出处: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); //内存存储器(数据写入时需要) CvFileStorage *fs_write_xml = cvOpenFileStorage("mat.xml",memstorage,CV_STORAGE_WRITE); CvFileStorage *fs_write_yml = cvOpenFileStorage("mat.yml",memstorage,CV_STORAGE_WRITE); //文件存储结构 cvWriteComment(fs_write_xml,"mat_xml",1); //添加注释 cvWrite(fs_write_xml,"CvMat",mat,cvAttrList(NULL,NULL)); //将数据写到XML文件中 cvReleaseFileStorage(&fs_write_xml); cvWriteComment(fs_write_yml,"mat_yml",1); //添加注释 cvWrite(fs_write_yml,"CvMat",mat,cvAttrList(NULL,NULL)); //将数据写到XML文件中 cvReleaseFileStorage(&fs_write_yml); cvReleaseMemStorage(&memstorage); cvReleaseMat(&mat); return 0; }
作者:gnuhpc
出处:http://www.cnblogs.com/gnuhpc/
除非另有声明,本网站采用知识共享“署名 2.5 中国大陆”许可协议授权。