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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With