Converting System.Drawing.Bitmap into Emgu Image

General Discussion
Post Reply
rnousa
Posts: 1
Joined: Fri Feb 07, 2020 11:32 pm

Converting System.Drawing.Bitmap into Emgu Image

Post by rnousa » Fri Feb 07, 2020 11:36 pm

Has anyone been able to convert a System.Drawing.Bitmap into an Emgu Image with version 4.2.0?

JoeBlack42
Posts: 2
Joined: Mon Feb 24, 2020 4:48 pm

Re: Converting System.Drawing.Bitmap into Emgu Image

Post by JoeBlack42 » Mon Feb 24, 2020 5:43 pm

Hi, I'm having the same issue. I installed 4.2.0.3636 Emgu using NuGet in Visual Studio 2017, and am trying to OCR. I'm trying to convert a bitmap which is just a screen grab to an image so I can OCR it.

OCRit.Recognize(New Image(Of Bgr, Byte)(pic))

I've tried separating the image creating on a different line and it still doesnt work. When I've searched online, all the code examples seem to do something similar either in VB.NET or C#. I've seen one post where there was a missing "opencv_core231.dll" but I dont see any emgu dll's in my project which it looks like is because there is a package file. I was thinking about downloading Emgu and trying to manually copy and pasting Emgu files and see if that sorts it.

I also tried to see if there was an alternative way to do it, eg by converting the bitmap to Mat, but I couldnt find any decent documentation or coding examples to show me how I'd do that. So, if anyone has any ideas, that would be great!


JoeBlack42
Posts: 2
Joined: Mon Feb 24, 2020 4:48 pm

Re: Converting System.Drawing.Bitmap into Emgu Image

Post by JoeBlack42 » Thu Mar 19, 2020 8:03 pm

Oberuks you genius! :D

Read the link and related material and managed to get it working, thank you. For anyone else trying, I installed the cuda NuGet package, then used

"toImage" to convert my bitmap, so like:

OCR.SetImage(pic.ToImage(Of Bgr, Byte))
OCR.Recognize()
Print(OCR.GetUTF8Text)

Where "OCR" is my imaginatively named tesseract, "pic" is my bitmap screenshot, and print is just a small print class that prints to a textbox. Et voila!

Post Reply