I have the current code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Bitmap As New Bitmap("image.png")
Dim ocr As tessnet2.Tesseract = New tessnet2.Tesseract()
ocr.SetVariable("tessedit_char_whitelit", "0123456789")
ocr.Init("c:\", "fra", False)
Dim result As List(Of tessnet2.Word) = ocr.DoOCR(Bitmap, Rectangle.Empty)
For Each word As tessnet2.Word In result
RichTextBox1.Text &= word.Text & "(" & word.Confidence & ") "
Next
End Sub
I just have a normal RichTextBox and a button on the form. I also have an image in the debug directory called “image.png”.
Every time I run this, the program just closes. I did a step through and all of a sudden a file locater came up asking for “tessnet2.cpp”
I have a reference to the dll. I also don’t know what the ocr.Init(…) line is for.
Any help would be nice!
First of all, thank you very much for your simple but effective code. After 3 days search I found this code for VB (not VC). Of course I copied and pasted it immediately and the same problem occured for me, too. Then:
Copied tessdll.dll in the same folder.
The main problem is:
ocr.Init("c:\", "fra", False)it should be something like this:ocr.Init("c:\tessdata", "fra", False)in fact my real line is:ocr.Init(Application.StartupPath & "\tessdata", "eng", False)Noticed that in the folder “…\Visual Studio 2008\Projects….” I still had the same problem and then copied all folder in “D:\Test” folder (of course in this folder I have one more folder: tessdata)
It worked!!!
Hope it helps for you or anyone searching for this problem like me 🙂
Nes