简体   繁体   中英

Tesseract c# : Find nothing in my case

I've add the C# wrapper for tesseract : TesseractEngine

I've two types of images to read :

在此处输入图片说明

And the second type (one letter only) :

在此处输入图片说明

But in both case, Tesseract return empty string.

Here is my code (found in docs) :

    public static void Main(string[] args)
        {
        var testImagePath = @"C:\plate\ExtractLicensePlate-0.jpg";
        if (args.Length > 0)
        {
            testImagePath = args[0];
        }

        try
        {
            using (var engine = new TesseractEngine(@"./tessdata", "eng", EngineMode.Default))
            {
                engine.SetVariable("tessedit_char_whitelist", "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");

                using (var img = Pix.LoadFromFile(testImagePath))
                {
                    using (var page = engine.Process(img))
                    {
                        var text = page.GetText();//<-- empty :(

                    }
                }
            }
        }
        catch (Exception e)
        {                
            Console.WriteLine(e.ToString());
            Console.Read();
        }
        Console.Write("Press any key to continue . . . ");
        Console.ReadKey(true);
    }

Maybe I miss an option or something else?

EDIT : I've try this kind but no success to :

在此处输入图片说明

EDIT 2 : I've try Gray and Black and White and Tesseract Give me : EEEEEEE

在此处输入图片说明

I don't know what I can do better... :

  1. I would recommend converting the image to greyscale
  2. Try setting the PageSegMode to SingleChar or SingleWord

      using (var page = engine.Process(img, PageSegMode.SingleChar)) { var text = page.GetText(); } 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM