/*
//------------CvMat存储与读取-----------------------------
//-------写入数据 cvWrite( fs_write,"CvMat",mat,cvAttrList(NULL,NULL) ); //
//-------读入数据 mat_read = (CvMat*)cvRead( fs_read,mat_node);
#include "cxcore.h"
#include <iostream>
using namespace std ;
void main() { CvMat* mat = cvCreateMat( 3,3,CV_32SC1); cvSetIdentity(mat); //生成单位矩阵 CvMemStorage* memstorage = cvCreateMemStorage(0);//内存存储器(数据写入文件时需要) //文件存储结构 CvFileStorage* fs_write_xml = cvOpenFileStorage( "mat_xml.xml",memstorage,CV_STORAGE_WRITE ); CvFileStorage* fs_write_yml = cvOpenFileStorage( "max_yml.yml",CV_STORAGE_WRITE ); //-----------把mat写入xml文件------------- cvWriteComment( fs_write_xml,"mat_xml",1 ); // 注释 cvWrite( fs_write_xml,NULL) ); //写入数据到文件 cvReleaseFileStorage (&fs_write_xml); //释放文件存储器 //-----------把mat写入yml文件------------- cvWriteComment( fs_write_yml,"mat_yml",1 ); // 注释 cvWrite( fs_write_yml,NULL) ); //写入数据到文件 cvReleaseFileStorage (&fs_write_yml); //释放文件存储器 //-----释放内存存储器-------- cvReleaseMemStorage( &memstorage ); cvReleaseMat(&mat); } 原文链接:https://www.f2er.com/xml/300222.html