How to convert Bitmap to Image

后端 未结 5 1081
我寻月下人不归
我寻月下人不归 2021-01-01 22:17

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

相关标签:
5条回答
  • 2021-01-01 22:57

    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.

    0 讨论(0)
  • 2021-01-01 23:11

    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. :-)

    0 讨论(0)
  • 2021-01-01 23:13

    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); 
    
    0 讨论(0)
  • 2021-01-01 23:20

    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.

    0 讨论(0)
  • 2021-01-01 23:21

    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

    0 讨论(0)
提交回复
热议问题