Click here to Skip to main content
15,887,676 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello

I am trying to make ocr using Tessnet2 but it exit when "tessocr.Init" called.

C#
ocr = new Ocr();
using (Bitmap bmp = new Bitmap(@"C:\OCR\IMG.jpg"))
            {
                tessnet2.Tesseract tessocr = new tessnet2.Tesseract();
                tessocr.Init(null, "eng", false); //Application exit after this line.

                tessocr.GetThresholdedImage(bmp, Rectangle.Empty).Save("elo.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);

                Console.WriteLine("dsadasdasd");
                ocr.DoOCRNormal(bmp, "eng");

            }
 public class Ocr
        {
            public void DumpResult(List<tessnet2.Word> result)
            {
                foreach (tessnet2.Word word in result)
                {
                    Console.WriteLine("{0} {1}", word.Confidence, word.Text);
                }
            }

            public List<tessnet2.Word> DoOCRNormal(Bitmap image, string lang)
            {
                tessnet2.Tesseract ocr = new tessnet2.Tesseract();
                ocr.Init(null, lang, false);

                List<tessnet2.Word> result = ocr.DoOCR(image, Rectangle.Empty);
                DumpResult(result);
                return result;
            }
        }
Posted
Updated 11-Mar-13 23:56pm
v2

Have a look at the responses to this post http://stackoverflow.com/questions/2053575/tessnet2-fails-to-load[^] - in particular the 2nd response
It's likely to be a problem with your Tesseract install
 
Share this answer
 
Try this it works for me.

Add testdata folder in your bin\debug folder. Problem solved.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900