I am attempting to convert an OpenCV C++ cv::Mat
to an ImageMagick Magick::Image
. The only examples I can find use the older, C OpenCV iplImage
(see, for example, here).
Is there a simple way of achieving this?
I am attempting to convert an OpenCV C++ cv::Mat
to an ImageMagick Magick::Image
. The only examples I can find use the older, C OpenCV iplImage
(see, for example, here).
Is there a simple way of achieving this?
It's as simple as this:
Image Mat2Magick(Mat& src)
{
Image mgk(src.cols, src.rows, "BGR", CharPixel, (char *)src.data);
return mgk;
}
Note that the function does not copy the data. If the magik image is released before you use the Mat image, result is SEGFAULT
mat is always bigger then the image itself. The width is changed to multiple of 2 for sake of more efficient accessing the image data.