如何在OpenCV 2.0中的IplImage变量类型中转换Mat变量类型? [英] How to convert a Mat variable type in an IplImage variable type in OpenCV 2.0?

查看:93
本文介绍了如何在OpenCV 2.0中的IplImage变量类型中转换Mat变量类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在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 ++接口中,确实没有必要在MatIplImage之间来回切换,但是如果您愿意,可以使用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屋!

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