OPENCV中XML的处理

前端之家收集整理的这篇文章主要介绍了OPENCV中XML的处理前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

@H_502_1@@H_502_1@<?xml version="1.0" ?>
@H_502_1@- <opencv_storage>
@H_502_1@- <Record1>
@H_502_1@+ <ImageDescriptors type_id="opencv-matrix">
@H_502_1@ </Record1>
@H_502_1@- <Record2>
@H_502_1@+ <ImageDescriptors type_id="opencv-matrix">
@H_502_1@ </Record2>
@H_502_1@- <Record3>
@H_502_1@+ <ImageDescriptors type_id="opencv-matrix">
@H_502_1@ </Record3>
@H_502_1@- <Record4>
@H_502_1@+ <ImageDescriptors type_id="opencv-matrix">
@H_502_1@ </Record4>
@H_502_1@- <Record5>
@H_502_1@+ <ImageDescriptors type_id="opencv-matrix">
@H_502_1@ </Record5>
@H_502_1@- <Record6>
@H_502_1@+ <ImageDescriptors type_id="opencv-matrix">
@H_502_1@ </Record6>

@H_502_1@我现在想通过循环一条一条地将记录数据读取出来,比如先读取<record1>下的<mageDescriptors>里面的数据,进行处理,再接着读取<record2>下的<mageDescriptors>里面的数据,进行处理,。。。以此类推。现在我在一个循环里面写了下面的代码,但是调试的时候,始终无法获取,不知道怎么回事,希望您能给我指点一下,谢谢!

@H_502_1@@H_502_1@对结构体中的“opencv-matrix”加以区别,用下面的思路就可以了

@H_502_1@@H_502_1@ CvFileNode *node;
@H_502_1@ const char* xmlfile = "your.xml";

@H_502_1@ CvFileStorage *fs = cvOpenFileStorage( xmlfile,CV_STORAGE_READ );

@H_502_1@ node = cvGetFileNodeByName (fs,NULL,"opencv-matrix_1");
@H_502_1@ imageMat_1= (CvMat *) cvRead (fs,node);
@H_502_1@ node = cvGetFileNodeByName (fs,"opencv-matrix_2");
@H_502_1@ imageMat_2 = (CvMat *) cvRead (fs,node);
@H_502_1@ ...
@H_502_1@ node = cvGetFileNodeByName (fs,"opencv-matrix_n");
@H_502_1@ imageMat_n = (CvMat *) cvRead (fs,node);

@H_502_1@ cvReleaseFileStorage (&fs);

转载网站为http://www.opencv.org.cn/forum/viewtopic.php?f=1&t=8516

猜你在找的XML相关文章