将cv :: Mat转换为const CvMat *或CvMat * [英] convert cv::Mat to const CvMat* or 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 *mat
与cv::Mat
和Mat
之间的区别. 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
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::Mat
和Mat
之间的区别,它们是相同的.在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屋!