It works, I did that for my project (I posted part of the code below).
The biggest problem I ran into is the tesseract.exe does not seem to
accept spaces in the filename or path. (Does anyone know how to
escape them so tesseract will accept it?)
Anyways for the code below, have the tesseract.exe in your executable
directory and pass the function ReadImage the absolute path with the
filename, i.e. ReadImage("C:/tmp/test.tif")
Let me know if that works for you.
Public Class GoogleOCR
Private Shared GoogleOCRFilename As New String("tesseract.exe")
Public Shared Function ReadImage(ByVal filename As String) As String
If filename = "" Then
Return ""
End If
Try
If File.Exists("results.txt") Then
File.Delete("results.txt")
End If
'Initialize and execute Goole's Tesseract executable
Dim googleProcess As System.Diagnostics.Process = New
System.Diagnostics.Process()
googleProcess.StartInfo.Arguments = filename + " results"
googleProcess.StartInfo.FileName = GoogleOCRFilename
googleProcess.StartInfo.WindowStyle =
System.Diagnostics.ProcessWindowStyle.Hidden
googleProcess.StartInfo.CreateNoWindow = True
googleProcess.Start()
googleProcess.WaitForExit()
'Read in and return the results
If File.Exists("results.txt") Then
Using filehandler As System.IO.StreamReader = New
System.IO.StreamReader("results.txt")
Return filehandler.ReadToEnd()
End Using
Else
Return ""
End If
Catch ex As Exception
Return ex.Message
End Try
End Function
End Class
On Mar 7, 12:52 pm, "[email protected]"
<[email protected]> wrote:
> Hi,
>
> I'm looking to use VB to pass commands to tesseract.exe and tell it to
> convert files when a user presses a button but the process.start
> function does not seem to work for this even though I can it working
> in command prompt. Any suggestiosn on how to do this or another way
> oround it?
>
> Thanks
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"tesseract-ocr" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/tesseract-ocr?hl=en
-~----------~----~----~----~------~----~------~--~---