我正在用 emgucv 库编写 ac# 程序。我使用 emgucv 中的图像框从网络摄像头捕获图像。我想通过鼠标单击图像框使用 bitmap.Getpixel() 来获取图像的颜色像素。但是,它包含错误错误是..它无法将类型“Emgu.CV.IImage”隐式转换为“System.Drawing.Bitmap”
谁能给我解决这个问题的想法?
Bitmap bitmap = newdetectimageBox.Image; //error
请使用此代码
Image<Bgr, Byte> ImageFrame = newdetectimageBox.Image ; //Capture the cam Image
Bitmap BmpInput = ImageFrame.ToBitmap(); //Convert the emgu Image to BitmapImage
这是您的操作方法(图像数据不与位图共享) - 请参阅 emgu 网站上有关IImage的文档:
Bitmap bitmap = new Bitmap(newdetectimageBox.Image.Bitmap);
IImage 接口包含属性 Bitmap。
但是,如果您使用的是 Image 类,那么您应该使用 ToBitmap 方法。