How to convert Bitmap to Image<Bgr, Byte>

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); 

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.


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.

Tags:

C#

.Net

Opencv