opencv && xml

前端之家收集整理的这篇文章主要介绍了opencv && xml前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
#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",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,NULL));
    //将数据写到XML文件中
    cvReleaseFileStorage(&fs_write_yml);

    cvReleaseMemStorage(&memstorage);
    cvReleaseMat(&mat);

    return 0;
}

猜你在找的XML相关文章