将cv :: Mat转换为const CvMat *或CvMat * [英] convert cv::Mat to const CvMat* or CvMat*

查看:558
本文介绍了将cv :: Mat转换为const CvMat *或CvMat *的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只知道 C 语言,所以我感到困惑/不理解openCV数据类型的语法,尤其是在cv::Mat, CvMat*, Mat.

I know only C language, so I am getting confusion/not understanding the syntax of the openCV data types particularly in cv::Mat, CvMat*, Mat.

我的问题是如何将cv::Mat转换为const CvMat *或CvMat*,并且任何人都可以提供文档链接以了解 opencv2中CvMat *matcv::MatMat之间的区别. 4 .

My question is How can I convert cv::Mat to const CvMat* or CvMat*, and can any one provide documentation link for difference between CvMat *mat and cv::Mat and Mat in opencv2.4.

以及如何在CvMat中将int数据转换为float数据? 谢谢

and How can I convert my int data to float data in CvMat ? Thank you

推荐答案

cv::Mat具有

cv::Mat has a operator CvMat() so simple assignment works:

cv::Mat mat = ....;
CvMat cvMat = mat;

这使用相同的基础数据,因此您必须注意,cv::Mat不会超出CvMat范围.

This uses the same underlying data so you have to be careful that the cv::Mat doesn't go out of scope before the CvMat.

如果需要在使用CvMat*的API中使用CvMat,则传递对象的地址:

If you need to use the CvMat in an API that takes a CvMat*, then pass the address of the object:

functionTakingCmMatptr(&cvMat);

关于cv::MatMat之间的区别,它们是相同的.在OpenCV示例中,通常假定使用using namespace cv(我认为这不是一个好主意).

As for the difference between cv::Mat and Mat, they are the same. In OpenCV examples, it is often assumed (and I don't think this is a good idea) that using namespace cv is used.

这篇关于将cv :: Mat转换为const CvMat *或CvMat *的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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