如何在OpenCV 2.0中的IplImage变量类型中转换Mat变量类型? [英] How to convert a Mat variable type in an IplImage variable type in OpenCV 2.0?
问题描述
我正在尝试在OpenCV中旋转图像.
I am trying to rotate an image in OpenCV.
我使用了我在Stack Overflow上找到的这段代码:
I've used this code that I found here on Stack Overflow:
Mat source(img);
Point2f src_center(source.cols/2.0, source.rows/2.0);
Mat rot_mat = getRotationMatrix2D(src_center, 40.0, 1.0);
Mat dst;
warpAffine(source, dst, rot_mat, source.size());
一旦我填写了dst
Mat
变量类型,我想将其放回IplImage
变量类型,关于如何执行此操作的任何想法?
Once I have my dst
Mat
variable type filled up I would like to put it back to an IplImage
variable type, any idea about how to do this?
推荐答案
在新的OpenCV 2.0 C ++接口中,确实没有必要在Mat
和IplImage
之间来回切换,但是如果您愿意,可以使用IplImage
运算符:
In the new OpenCV 2.0 C++ interface it's not really necessary to change from back and forth between Mat
and IplImage
, but if you want to you can use the IplImage
operator:
IplImage dst_img = dst;
请注意,仅创建了IplImage标头,并且将共享数据(像素).有关更多信息,请参见 OpenCV C ++接口或image.cpp
示例在OpenCV-2.0/samples/c
目录中.
Note that only the IplImage header is created and the data (pixels) will be shared. For more info see the OpenCV C++ interface or the image.cpp
example in the OpenCV-2.0/samples/c
directory.
这篇关于如何在OpenCV 2.0中的IplImage变量类型中转换Mat变量类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!