I am using the OpenCV library for image processing.
I want to convert a System.Drawing.Bitmap to an Image<Bgr, Byte>. How can I do this?
The Image constructor has a Bitmap overload (assuming you're using the Emgu CV wrapper since you've marked it .NET).
Image<Bgr, Byte> myImage = new Image<Bgr, Byte>(myBitmap);
In .NET Emgu.CV 4.4.0.4099 I had to install Emgu.CV.Bitmap 4.4.0.4099 and Emgu.CV.runtime.windows in order to use the bitmap.ToImage<Bgr, byte>() extension method.
The constructor for Image<Bgr, byte> no longer accepts Bitmap as parameter. I had to use the following code for Emgu version 4.3:
Image<Bgr, byte> emguImage = bitmap.ToImage<Bgr, byte>();
I found it on github and in patch notes. The official documentation tutorials were not properly updated.
I am using Emgu.CV 4.5.1.4349 on NetStandard 2.1 Need to install Emgu.CV.Bitmap and Emgu.CV.runtime.windows in order to convert your Bitmap to Image<Bgr, byte>
var myImage = myBitmap.ToImage<Bgr, byte>()
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