Help with Tessnet2

I need an advice. I am trying to use Tessnet2 lib to recognize image text.

The image consists of a string with five characters (characters and numbers).

The data definition file is in the same directory as the exe file.

Here is my code:

try { //download image from server System.Net.WebRequest request = System.Net.WebRequest.Create( textBox1.Text); System.Net.WebResponse response = request.GetResponse(); System.IO.Stream responseStream = response.GetResponseStream(); Bitmap image = new Bitmap(responseStream); pictureBox1.Image =image; tessnet2.Tesseract ocr = new tessnet2.Tesseract(); ocr.SetVariable("tessedit_char_whitelist", "0123456789"); ocr.Init(@"C:\Users\Tan\Documents\Visual Studio 2010\Projects\TestProject\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); } } catch (System.Net.WebException) { MessageBox.Show("There was an error opening the image file." + "Check the URL"); } 

The problem is that if I call this code, the application closes. I received nothing error message. I do not know why. Can anybody help me? Thanks.

+4
source share
5 answers

Have you installed Tesseract 3?

If it is to delete it and delete the environment variable that named something with tessdata, and restart.

+3
source

I think the error is in the ocr.Init line, make sure the path is correct. Also try passing null, because I remember that it doesnโ€™t need this path, because you always need to put all the data in the tessdata directory in the same folder that contains your exe file.

0
source

Try using the Debug solution configuration in the Visual Studio configuration for the Release version. Some debugging information is not included in the Release configuration. And shoots such errors.

0
source

The problem is your ocr.Init (). Make sure that the directory "C: \ Users \ Tan \ Documents \ Visual Studio 2010 \ Projects \ TestProject \ bin \ Release" contains the necessary files:

eng.DangAmbigs

eng.freq-dawg

eng.inttemp

eng.normproto

eng.pffmtable

eng.unicharset

eng.user-words

eng.word-dawg

0
source

If someone still wants to know what to do in this case:

I had the same problem and I could fix it using this link and pass the tessdata directory in the init function. (There is one in the main function and two in the OCR class.) The link mentioned above helped me, since I had to download the v2.00 language files instead of the last v3.0x ...

Best wishes

0
source

All Articles