0

现在我正在尝试使用 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;
}

我该怎么解决这个内存异常错误?

更新 1

你好。我使用如下初始化它。

        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.

有谁知道热来解决这个问题?我错过了什么?

4

0 回答 0