How to create Emgu Image from System.Drawing.Image?

前端 未结 3 1599
没有蜡笔的小新
没有蜡笔的小新 2021-01-15 05:32

I have a source that gives me a jpeg in memory stream (Bytes).
I can convert it to System.Drawing.Image but I don\'t know how
to convert it to Emgu Image.

M

3条回答
  •  耶瑟儿~
    2021-01-15 06:16

    You can first convert System.Drawing.Image object to a Bitmap and then create an Emgu.CV.Image with that bitmap. The code is as follows:

    System.Drawing.Image image;
    Bitmap bmpImage = new Bitmap(image);
    Emgu.CV.Image = new Emgu.CV.Image(bmpImage);
    

    Better, if you have a memory stream, you can get a bitmap directly from the memory stream

    MemoryStream ms;
    Bitmap bmpImage = new Bitmap(ms);
    Emgu.CV.Image = new Emgu.CV.Image(bmpImage);
    

提交回复
热议问题