[英]how to convert from cv::Mat to CvArr?
我已经花了很多时间搜索如何从cv :: Mat或CvMat转换为CvArr,但没有任何收获,请帮助我,谢谢。
Mat img = imread("C:\MyPic.jpg",CV_LOAD_IMAGE_GRAYSCALE);
IplImage tmp=img;
cvErode(&tmp, &tmp, 0, 2);
Mat laser=&tmp;
imshow("Eroded",laser);
I converted cv::Mat
to CvArr
by this way. 我通过这种方式将
cv::Mat
转换为CvArr
。 Instead of using tmp
directly use &tmp
. 而不是使用
tmp
直接使用&tmp
。
When I need to do that I just use : 当我需要这样做时,我只是使用:
IplImage tmp = image;
With image a Mat variable. 使用图像Mat变量。
如果我没记错的话,CvMat是一个CvArr所以你可以把它转换成CvArr,现在CvArr的第一个字节告诉函数它实际上是一个CvMat: http ://opencv.willowgarage.com/documentation/basic_structures 的.html#cvarr
Are you sure you want to convert it? 你确定要转换吗? sometimes there is equivalent function that use what you have.
有时会有相同的功能使用你拥有的东西。 For example
cvMorphologyEx
is using CvArr
but morphologyEx
is using cv::Mat
. 例如
cvMorphologyEx
使用CvArr
但morphologyEx
使用cv::Mat
。
convert first the image using the following: 首先使用以下内容转换图像:
IplImage* oldstyleimg = &matimg.operator IplImage()
I don t remember if it only create the header for the image or it makes a copy 我不记得它是否只为图像创建标题或者它是否复制
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.