OPENCV中XML的处理

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

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

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

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

   CvFileStorage *fs = cvOpenFileStorage( xmlfile, 0, CV_STORAGE_READ );

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

   cvReleaseFileStorage (&fs);

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值