简体   繁体   English

转换 'Emgu.CV.Image<emgu.cv.structure.bgr,byte> ' 到 'System.Drawing.Image'</emgu.cv.structure.bgr,byte>

[英]Converting 'Emgu.CV.Image<Emgu.CV.Structure.Bgr,byte>' to 'System.Drawing.Image'

I'm making a face recognition in C#.我正在 C# 中进行人脸识别。 How can I solve this error?我该如何解决这个错误?

Error 4 Cannot implicitly convert type 'Emgu.CV.Image' to 'System.Drawing.Image'错误 4 无法将类型“Emgu.CV.Image”隐式转换为“System.Drawing.Image”

for this code:对于此代码:

cameraBox1.Image = Frame;
names = "" ;
User.Clear();

System.Windows.Forms.PictureBox like cameraBox1 doesn't accept Emgu.CV.Image directly. System.Windows.Forms.PictureBoxcameraBox1不直接接受Emgu.CV.Image You must convert it to System.Drawing.Image like this cameraBox1.Image = Frame.ToBitmap();您必须将其转换为System.Drawing.Image像这样cameraBox1.Image = Frame.ToBitmap();

There are two ways:有两种方法:

a) Image class Bitmap Property : a) 图像 class Bitmap 属性

cameraBox1.Image = Frame.Bitmap;

Wraps Bitmap around Image pixel data.将 Bitmap 包裹在图像像素数据周围。 No copy involved.不涉及副本。

b) Image class ToBitmap() method : b) 图像 class ToBitmap() 方法

cameraBox1.Image = Frame.ToBitmap();

Copies pixel data from Image into new Bitmap.将 Image 中的像素数据复制到新的 Bitmap 中。

Which way you choose depends on your needs.您选择哪种方式取决于您的需求。 a) is faster but creates shared memory which is more difficult to deal with. a) 速度更快,但会创建更难以处理的共享 memory。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 不能隐式转换类型 &#39;Emgu.CV.Image<Emgu.CV.Structure.Bgr, byte> &#39; 到 &#39;System.Drawing.Image&#39; - Cannot implicitly convert type 'Emgu.CV.Image<Emgu.CV.Structure.Bgr, byte>' to 'System.Drawing.Image' 将类型“Emgu.CV.Mat”转换为“Emgu.CV.Image”<emgu.cv.structure.bgr, byte> '</emgu.cv.structure.bgr,> - Convert type 'Emgu.CV.Mat' to 'Emgu.CV.Image<Emgu.CV.Structure.Bgr, byte>' 如何将.NET图像或字节数组转换为Emgu.CV.Image <Emgu.CV.Structure.Bgr , byte > - How can I convert .NET Image or Byte Array to Emgu.CV.Image<Emgu.CV.Structure.Bgr , byte > EmguCV捕获错误:无法将类型&#39;Emgu.CV.Mat&#39;隐式转换为&#39;Emgu.CV.Image <Emgu.CV.Structure.Bgr,byte> - EmguCV capture error: Cannot implicitly convert type 'Emgu.CV.Mat' to 'Emgu.CV.Image<Emgu.CV.Structure.Bgr,byte> 将 System.Drawing.Image 转换为 Emgu.CV.Image<Gray,byte> - Convert System.Drawing.Image to Emgu.CV.Image<Gray,byte> 无法从“Emgu.CV.Image”转换<Emgu.CV.Structure.Gray, byte> []”到“Emgu.CV.IInputArray” - Can't convert from "Emgu.CV.Image<Emgu.CV.Structure.Gray, byte>[]" to "Emgu.CV.IInputArray" 将Emgu.CV.mat转换为System.drawing.image? - convert Emgu.CV.mat into System.drawing.image? System.Drawing.Image到Emgu.CV.Mat - System.Drawing.Image to Emgu.CV.Mat 使用 WarpAffine() 将 Emgu.CV.Image 向右移动 - Shift Emgu.CV.Image to the right using WarpAffine() 使用Emgu CV扫描图像 - Scan a image with emgu cv
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM