使用opencv使用type_id opencv-image读取xml文件 [英] Read xml file with type_id opencv-image using opencv

查看:76
本文介绍了使用opencv使用type_id opencv-image读取xml文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,我在尝试使用type_id"opencv-image"读取xml文件时尝试了很多搜索,我在这里看到的只是"opencv-matrix",所有可用的帮助对我来说都是无用的. 请帮助我从xml文件读取图像矩阵.

Hey i have tried a lot search in reading xml file with type_id "opencv-image", all i am looking here is "opencv-matrix" and all help available is useless for me. Please help me out in reading an image matrix from xml file.

出于某些想法,我在这里粘贴了xml文件的上半部分.

I am pasting here an upper portion of my xml file for some idea.

<?xml version="1.0"?>
<opencv_storage>
<depthImg190 type_id="opencv-image">
<width>320</width>
<height>240</height>
<origin>top-left</origin>
<layout>interleaved</layout>
<dt>w</dt>
<data>
0 0 0 0 27120 27384 27120 27120 27384 27120 27120 27120 27120 27384
27384 27664 27664 27944 27944 27664 27664 27944 27944 27944 28224
27944 27944 28224 28224 28224 28224 28520 28816 29120 29120 29120
29120 29120 29120 29120 29432 29744 30072 30072 29744 29744 30072
30072 30072 30400 30400 30736 30736 31080 31080 31080 31440 31440
31440 31440 31800 31800 31800 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 27120 27120 27120 27120 27384 27384 27384 27384 27384 27384
</depthImg190>
</opencv_storage>

我已经使用了代码

FileStorage f;
Mat m;
f.open("temp.xml", FileStorage::READ);
f["depthImg190"] >> m;
f.release();

但是我正面临一个异常"Opencv错误:错误的参数<未知数组类型>在cv :: read中,文件........ \ opencv \ modules \ core \ persistence.cpp,第5535行"

but i am facing an exception "Opencv Errorr: Bad argument < Unknown array type > in cv::read, file ........\opencv\modules\core\persistence.cpp, line 5535".

任何帮助都会被申请

推荐答案

实际上,您可以使用一些文档,例如:

Actually there is some documentation that you could use like: http://docs.opencv.org/modules/core/doc/xml_yaml_persistence.html

无论如何,解决问题的方法都很简单:

In any case the answer to your problem is easy:

FileStorage fs("file.xml", FileStorage::READ);
Mat image;

fs["depthImg190"] >> image;

(...)

fs.release();

应该可以!

这篇关于使用opencv使用type_id opencv-image读取xml文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆