Converting cv::Mat to IplImage*(将 cv::Mat 转换为 IplImage*)
问题描述
关于此的文档似乎非常参差不齐.
The documentation on this seems incredibly spotty.
我基本上有一个 IplImage*s (IplImage** imageArray) 的空数组,我正在调用一个函数来导入一个 cv::Mats 数组 - 我想将我的 cv::Mat 转换为 IplImage* 这样我就可以将其复制到数组中.
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.
目前我正在尝试这个:
while(loop over cv::Mat array)
{
IplImage* xyz = &(IplImage(array[i]));
cvCopy(iplimagearray[i], xyz);
}
产生段错误.
也在尝试:
while(loop over cv::Mat array)
{
IplImage* xyz;
xyz = &array[i];
cvCopy(iplimagearray[i], xyz);
}
这给了我一个编译时错误:错误:无法在赋值中将‘cv::Mat*’转换为‘IplImage*’
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
是 OpenCV2.X 中引入的新类型,而 IplImage*
是遗留"图像结构.
cv::Mat
is the new type introduce in OpenCV2.X while the IplImage*
is the "legacy" image structure.
虽然cv::Mat
确实支持在构造函数参数中使用IplImage
,但默认库不提供其他方式的功能.您将需要手动提取图像标题信息.(请记住,您需要分配 IplImage 结构,这在您的示例中是缺失的).
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*的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:将 cv::Mat 转换为 IplImage*
基础教程推荐
- 您如何将 CreateThread 用于属于类成员的函数? 2021-01-01
- 什么是T&&(双与号)在 C++11 中是什么意思? 2022-11-04
- 运算符重载的基本规则和习语是什么? 2022-10-31
- 如何在 C++ 中处理或避免堆栈溢出 2022-01-01
- 调用std::Package_TASK::Get_Future()时可能出现争用情况 2022-12-17
- 设计字符串本地化的最佳方法 2022-01-01
- C++ 程序在执行 std::string 分配时总是崩溃 2022-01-01
- 如何定义双括号/双迭代器运算符,类似于向量的向量? 2022-01-01
- C++ 标准:取消引用 NULL 指针以获取引用? 2021-01-01
- C++,'if' 表达式中的变量声明 2021-01-01