opencv && xml

来源:互联网 发布:mac轻量级虚拟机 编辑:程序博客网 时间:2024/06/16 09:22
#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;}
0 0
原创粉丝点击