user1994617
user1994617

Reputation: 125

Convert EmguCV image to system drawing bitmap

I am writing a c# program with emgucv library. I use the imagebox in emgucv to capture image from webcam. And I want to get the color pixel of the image by using bitmap.Getpixel() by mouse clicking the imagebox. However, it contain error The error is..it cannot implicitly convert type 'Emgu.CV.IImage' to 'System.Drawing.Bitmap'

Can anyone give me idea to solve this problem?

      Bitmap bitmap = newdetectimageBox.Image; //error

Upvotes: 5

Views: 20227

Answers (3)

vikas singh aswal
vikas singh aswal

Reputation: 202

Please use this code

 Image<Bgr, Byte> ImageFrame = newdetectimageBox.Image ; //Capture the cam Image 
 Bitmap BmpInput = ImageFrame.ToBitmap(); //Convert the emgu Image to BitmapImage 

Upvotes: 6

Oliver
Oliver

Reputation: 696

Here's how you do it (image data is NOT shared with the bitmap) - see documentation on emgu website about IImage :

Bitmap bitmap = new Bitmap(newdetectimageBox.Image.Bitmap);

Upvotes: 2

hoonzis
hoonzis

Reputation: 1737

The IImage interface contains property Bitmap.

However if you are using the Image class than you should maybe use the ToBitmap method.

Upvotes: 1

Related Questions