将cv :: Mat转换为IplImage * [英] Converting cv::Mat to IplImage*

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

问题描述

关于这个文件似乎令人难以置信的多斑点。



我基本上有一个空数组的IplImage * s(IplImage ** imageArray),我调用一个函数来导入一个数组cv :: Mats - 我想把我的cv :: Mat转换成一个IplImage *,所以我可以将它复制到数组。



目前我试试这个:

  while(循环遍历cv :: Mat数组)
{
IplImage * xyz =& ));
cvCopy(iplimagearray [i],xyz);
}

这会产生一个segfault。



同时尝试:

  while(循环遍历cv :: Mat数组)
{
IplImage * xyz;
xyz =& array [i];
cvCopy(iplimagearray [i],xyz);
}

这给我一个编译时错误:
错误:无法在赋值

中将'cv :: Mat *'转换为'IplImage *'

cv :: Mat

是在OpenCV2.X中引入的新类型,而 IplImage * 是传统图像结构。



虽然 cv :: Mat 支持 IplImage 在构造函数的参数中,默认库不提供其他方式的函数。您将需要手动提取图像头信息。 (记住,你需要分配IplImage结构,这是你的例子中缺少的)。


The documentation on this seems incredibly spotty.

I've basically got an empty array of IplImage*s (IplImage** imageArray) and I'm calling a function to import an array of cv::Mats - I want to convert my cv::Mat into an IplImage* so I can copy it into the array.

Currently I'm trying this:

while(loop over cv::Mat array)
{
    IplImage* xyz = &(IplImage(array[i]));
    cvCopy(iplimagearray[i], xyz);
}

Which generates a segfault.

Also trying:

while(loop over cv::Mat array)
{
    IplImage* xyz;
    xyz = &array[i];
    cvCopy(iplimagearray[i], xyz);
}

Which gives me a compile time error of: error: cannot convert ‘cv::Mat*’ to ‘IplImage*’ in assignment

Stuck as to how I can go further and would appreciate some advice :)

解决方案

cv::Mat is the new type introduce in OpenCV2.X while the IplImage* is the "legacy" image structure.

Although, cv::Mat does support the usage of IplImage in the constructor parameters, the default library does not provide function for the other way. You will need to extract the image header information manually. (Do remember that you need to allocate the IplImage structure, which is lack in your example).

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

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