0
private void GetOCRValue(Bitmap image)
    {
        string ocrValue = "";
        try
        {
            using (var engine = new TesseractEngine(Application.StartupPath + "\\tessdata", "eng", EngineMode.Default))
            {
                using (var imager = new System.Drawing.Bitmap(image))
                {
                    using (var pix = PixConverter.ToPix(imager))
                    {
                        using (var page = engine.Process(pix))
                        {
                            ocrValue = page.GetText();
                        }
                    }
                }
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }

I'm trying to retrieve values from a bitmap.But Tesseract not returning the single number values and some other numbers like "13".I'm using Tesseract 3.3.0 Nuget package.How can I resolve this problem?

thilim9
  • 227
  • 2
  • 8
  • 17
  • 1
    OCR isn't always perfect. General rule is if you want the most accurate results right out of the box you should look at a paid library. That said, try identifying your text, make it pop in the bitmap. You can do this by converting to gray scale, turning every non text pixel to black and turning every text pixel to white. Even doing this won't get you 100% accuracy but it'll get you closer. – Mikael Nov 10 '20 at 15:20
  • 1
    See the ColorMatrix usage here: [Replacing Colour of an Image](https://stackoverflow.com/a/47529000/7444103) to convert the Image to Black&White, with a Threshold to fine tune (to an extent) the brightness of the text. The OCR needs to be *trained*. A grayscale conversion [here](https://stackoverflow.com/a/61584671/7444103) (B&W may be a better option when recognizing text only) – Jimi Nov 10 '20 at 16:26
  • @Jimi I tried converting image to B&W,But still engine unable to identify single values.Is there any advanced configuration to perform? – thilim9 Nov 12 '20 at 05:22

0 Answers0