[英]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.PictureBox
像cameraBox1
不直接接受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.