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.
source share