C# 转换位图图像

C# 转换位图图像,c#,emgucv,C#,Emgucv,翻转位图后,我想将其放入ImageBox: //set cam Mat m = new Mat(); m = capture.QuerySmallFrame(); //Flip picture Image img = m.ToImage<Bgr, byte>().Bitmap; img.RotateFlip(RotateFlipType.Rotate180FlipY); // show it imageBox1.Image = img 当我运行此程序时,我得到: 无法将类型S

翻转位图后,我想将其放入ImageBox:

//set cam
Mat m = new Mat();
m = capture.QuerySmallFrame();

//Flip picture
Image img = m.ToImage<Bgr, byte>().Bitmap;
img.RotateFlip(RotateFlipType.Rotate180FlipY);

// show it 
imageBox1.Image = img
当我运行此程序时,我得到:

无法将类型System.Drawing.Image隐式转换为Emgu.CV.IImage


ImageBox.Image需要Emgu.CV.World.IImage,因此我建议使用IImage的方法进行旋转,避免将其转换为System.Drawing.Bitmap。下面的代码应该可以做到这一点:

//Flip picture
var img = m.ToImage<Bgr, byte>();
img = img.Rotate(180, new Bgr(Color.Red)).Flip(Emgu.CV.CvEnum.FlipType.Vertical);
// show it 
imageBox1.Image = img;

谢谢你的回答。我改为var img=m.ToImage.Bitmap;而且它没有工作仍然得到相同的错误!我懂了。我的错。ImageBox也由Emgu提供。在这种情况下,Emgu.CV.World.IImage进入imageBox1.Image属性。我已经更新了答案。我试过了,它的效果是var img=m.ToImage.Bitmap;this.imageBox1.Image=新图像img;