問題描述
關于此的文檔似乎非常參差不齊.
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*的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!