0

I am developing Application in C# about OCR.

I use Tessnet2 as OCR engine, here is my code:

Bitmap image = new Bitmap(pictureBox1.Image);
tessnet2.Tesseract ocr = new tessnet2.Tesseract();
ocr.SetVariable("tessedit_char_whitelist", "0123456789"); // If digit only
ocr.Init(@"C:\Users\Mari\Documents\Visual Studio 2010\Projects\ocr\ocr\bin\Release", "eng", false); // To use correct tessdata
List<tessnet2.Word> result = ocr.DoOCR(image, Rectangle.Empty);

        foreach (tessnet2.Word word in result)
        {
            richTextBox1.Text = string.Format("{0} : {1}", word.Confidence, word.Text);
        }

When this code is executed, Application closes immediatly, without any error. Could anyone please advice what to do? Thanks

  • Did you try step-by-step to identify which line is the problem ? If it's the Init(), check the accepted answer here http://stackoverflow.com/questions/15617979/tessnet2-init-method-crashes-with-certain-tessdata-path – Mickael V. Jan 31 '15 at 23:02
  • the following line closes application: List result = ocr.DoOCR(image, Rectangle.Empty); what should be wrong with that? –  Feb 01 '15 at 09:27
  • 1
    You should try the exact same code with a hardcoded image path like : `Bitmap image = new Bitmap(@"c:\some\test\pic.tif");` to make sure it's not your image that is the problem – Mickael V. Feb 01 '15 at 12:29
  • @MickaelV thank you for advice. I use now following code and it solved my problem. string path1 = @"C:\\temp\\sample1.tif"; Bitmap image = new Bitmap(path1); –  Feb 01 '15 at 12:45

0 Answers0