如何从 opencv 2.2 中的文件中读取内在矩阵和畸变矩阵

发布于 2024-11-23 15:00:02 字数 388 浏览 2 评论 0原文

我已经有了为我的相机制作的“instinsic.xml”和“ Distortion.xml”。现在我正在使用 OpenCV 2.2 接口编写一个程序,因此我主要使用 cv::Mat 数据结构而不是 CvMat。我想将这两个文件加载到相应的 cv::Mat 结构中。对于以前的 OpenCV API,我会写:

CvMat* intrinsic = (CvMat*) cvLoad("Intrinsics.xml");
CvMat* distortion = (CvMat*) cvLoad("Distortions.xml");

如何在 OpenCV 2.2 中实现这一点?是否有一个函数可以将 xml 文件加载到 cv::Mat 中?我查遍了 API 文档,但没有找到。

谢谢,

I already have "instinsic.xml" and "distortion.xml" which was produced for my camera. Now I am writing a program using OpenCV 2.2 interface and therefore I am mainly working with cv::Mat data structure as opposed to CvMat. I want to load these two files into corresponding cv::Mat structure. With previous API for OpenCV I would write:

CvMat* intrinsic = (CvMat*) cvLoad("Intrinsics.xml");
CvMat* distortion = (CvMat*) cvLoad("Distortions.xml");

How can I achieve this in OpenCV 2.2? Is there a function that would load the xml file into a cv::Mat for me? I looked all over the API documentation but could not find it.

Thanks,

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不喜欢何必死缠烂打 2024-11-30 15:00:02

像这样的东西应该对你有好处:

代码是某种示例。 OpenCV 的示例目录中还有其他一些非常相关的内容,并且对这些类型的操作有很大帮助...

//TO WRITE
Mat myMat;
FileStorage fs(filename,FileStorage::WRITE);
fs << "MY_MAT_NAME_IN_THE_XML" << myMat;
fs.release();

//TO READ
Mat myMat;
FileStorage fs(filename,FileStorage::READ);
fs["MY_MAT_NAME_IN_THE_XML"] >> myMat;
fs.release();

我热烈建议您也使用 fs.isOpened() 测试打开,代码可以完成...

< a href="http://opencv.willowgarage.com/documentation/cpp/core_xml_yaml_persistence.html" rel="noreferrer">有关更多信息,这是文档

Julien,

Something like this should be good for you :

The code is some sort of a sample. There are others in the samples directory of OpenCV which are really relevant and help a lot in these types of manipulations...

//TO WRITE
Mat myMat;
FileStorage fs(filename,FileStorage::WRITE);
fs << "MY_MAT_NAME_IN_THE_XML" << myMat;
fs.release();

//TO READ
Mat myMat;
FileStorage fs(filename,FileStorage::READ);
fs["MY_MAT_NAME_IN_THE_XML"] >> myMat;
fs.release();

I warmly advise you to test the opening with fs.isOpened() aswell, the code could be completed...

For more info, here is the doc

Julien,

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文