如何从System.Drawing.Image创建Emgu图像? [英] How to create Emgu Image from System.Drawing.Image?
问题描述
我有一个源代码,它在内存流(字节)中给了我一个jpeg。
我可以将它转换为System.Drawing.Image但我不知道怎么样
将它转换为Emgu Image。
也许可以直接转换为Emgu Image?
我在VS2010下使用C#。
谢谢。
SW
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.
Maybe a direct conversion to Emgu Image is possible ?
I'm working in C# under VS2010.
Thanks.
SW
推荐答案
您可以先将System.Drawing.Image对象转换为Bitmap然后使用该位图创建一个Emgu.CV.Image。
代码如下:
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<Bgr, Byte>(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<Bgr, Byte>(bmpImage);
这篇关于如何从System.Drawing.Image创建Emgu图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!