Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emgu CV bitmap to image no longer working

Tags:

c#

emgucv

I am working with emguCV pretty often. But now, I downloaded latest CV3 libs for .Net and never had problem with converting bitmap to image. Now my code is no longer working and constructor Image no longer takes bitmap as paramter.

        Bitmap bitmap = Sources.GetBitmap();
        Image<Bgr, byte> source = new Image<Bgr, byte>(bitmap);

Is there any workaround?

like image 739
110mat110 Avatar asked Sep 02 '25 14:09

110mat110


2 Answers

Since Emgu version 4.2.0 there is no Image constructor with bitmap as parameter.

Now, according to changelog ( http://www.emgu.com/wiki/index.php/Version_History ) there is Extension method for bitmap. So now, you have to convert bitmap to Image like this:

    Bitmap bitmap = Sources.GetBitmap();
    var Image = bitmap.ToImage<Bgr, byte>();
like image 144
110mat110 Avatar answered Sep 05 '25 16:09

110mat110


You need to reference the separate package Emgu.CV.Bitmap, then 110mat110's answer will work.

like image 24
edwardforgacs Avatar answered Sep 05 '25 16:09

edwardforgacs