现在我尝试使用ImagemagicK并将其转换为Intel IPL格式。 但我有这样的异常错误。
Unhandled exception at 0x59596706 in mfc_test5.exe: 0xC0000005: Access violation writing location 0x02c30000.
这样使用的代码。
m_image.read("abc.jpg");
IplImage* gray;
Magick2Ipl(m_image,gray);
void Cmfc_test5Dlg::Magick2Ipl(Image magicImage, IplImage* cvImage)
{
int width= magicImage.size().width();
int height = magicImage.size().height();
byte* blob= new byte[cvImage->imageSize];
magicImage.write(0,0, width, height, "BGRA", MagickCore::CharPixel, blob);
memcpy(cvImage->imageData, blob, cvImage->imageSize);
delete [] blob;
}
我该怎么做才能解决这个内存异常错误?
您好。我使用初始化如下。
m_image.read("abc.jpg");
IplImage* IPL_image = iplCreateImageHeader(
3, // number of channels
0, // alpha channel
IPL_DEPTH_8U, // data of byte type
"RGB", "BGR", // color model and channel seq
IPL_DATA_ORDER_PIXEL, // channel arrangement
IPL_ORIGIN_BL, // bottom left orientation
IPL_ALIGN_DWORD, // 4 bytes align
m_image.columns(),
m_image.rows(), // image width and height
NULL, // ROI
NULL, NULL, NULL // no mask ROI, image ID, not tiled
);
iplAllocateImage(IPL_image,0,0);
Magick2Ipl(m_image,IPL_image);
void Cmfc_test5Dlg::Magick2Ipl(Image magicImage, IplImage* cvImage)
{
int width= magicImage.size().width();
int height = magicImage.size().height();
byte* blob= new byte[cvImage->imageSize];
magicImage.write(0,0, width, height, "BGRA", MagickCore::CharPixel, blob);
memcpy(cvImage->imageData, blob, cvImage->imageSize);
delete [] blob;
}
但它仍然会出现这样的错误。
Unhandled exception at 0x595a6706 in mfc_test5.exe: 0xC0000005: Access violation writing location 0x038c1000.
有谁知道热解决这个问题?我错过了什么?