I am using the OpenCV library for image processing.
I want to convert a System.Drawing.Bitmap
to an Image
. How can I do th
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.
I'm using Emgu 4.3.0.3890 and I had the same problem I integrated my code with my team. The line that gave me trouble was:
Image<Bgr, byte> img = bitmap.ToImage<Bgr, byte>();
I didn't see that the build created two new directories named x86 and x64. When I discovered it, I added these two directories to the location of my binary files and every thing worked. I didn't have the time to to elimination to see which one of the files in these directories is responsible for it but hey, it worked. :-)
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.
for whom to be concern: you should add dependency dll into project and change 'copy to output directory' property to 'copy always' (add -> existing item) from Emgu\emgucv-windows-universal-cuda 2.9.0.1922\bin\x86
in my project add : opencv_core290.dll , opencv_highgui290.dll , opencv_ffmpeg290.dll , opencv_imageproc290.dll and cudart32_55.dll
from: The type initializer for 'Emgu.CV.CvInvoke' threw an exception