Jump to content
JohnOne

Tesseract Simple Example

Recommended Posts

Blaxxun

That URL is.... exactly from the Github page you refer to.

https://github.com/tesseract-ocr/tesseract/wiki/Downloads

Under "3rd party Windows exe's/installer"

The URL is from a German Univercity i guess.

I tested it with your Autoit script but changed the Filepath to the install path.

Works perfectly.

Thanks for that.

  • Like 1

Share this post


Link to post
Share on other sites
robertocm

Just another simple example for using tesseract with an image file:

#Include <File.au3>
#include <WindowsConstants.au3>

Local $img_filename = FileOpenDialog("Image file", @DesktopDir & "\", "Images (*.tif;*.png;*.jpg)", $FD_FILEMUSTEXIST)
$ocr_filename = StringLeft($img_filename, StringLen($img_filename) - 4)
$ocr_filename_and_ext = $ocr_filename & ".txt"

;Double quotation marks are for paths containing spaces (tested on Tesseract V3.02)
Local $iPID = Run(@ComSpec & " /C " & "tesseract.exe """ & $img_filename & """ """ & $ocr_filename & """", @ProgramFilesDir & "\Tesseract-OCR", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
ProcessWaitClose($iPID)
;This also works:
;ShellExecuteWait(@ProgramFilesDir & "\Tesseract-OCR\tesseract.exe", " """ & $img_filename & """ """ & $ocr_filename & """")

;Display text in SciTe editor
Run(@ProgramFilesDir & "\AutoIt3\SciTE\SciTE.exe """ & $ocr_filename_and_ext & """", "", @SW_SHOWMAXIMIZED)

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Similar Content

    • PuneetTewani
      By PuneetTewani
      #include <IE.au3>
      #include <Tesseract.au3>
      #include <MsgBoxConstants.au3>
      #include <Math.au3>
      #include <FileConstants.au3>
      #include <StringConstants.au3>
      #include <File.au3>
      #include <ScreenCapture.au3>
      #include <sound.au3>
      #Include <WinAPI.au3>
      #include <Date.au3>
       
      $OCR_Result = _TesseractScreenCapture(0,"",1,2,220,660,500,730,1)
      $OCR_Result1 = _TesseractScreenCapture(0,"",1,2,220,660,500,730,1)
      $OCR_Result2 = _TesseractScreenCapture(0,"",1,2,220,660,500,730,1)
      $OCR_Result3 = _TesseractScreenCapture(0,"",1,2,220,660,500,730,1)

      $sound = _SoundStatus("C:\ExpertAdvisorBuyAlert.wav")
      while _nowtime < 3.30 pm
          If $sound = True Then
             if $OCR_Result1 > $OCR_Result2
             
          EndIf
      EndIf
      Wend
      Trying to ocr some values on chart in real time(once per minute) and buy/sell securities on basis of alert generated in my software.
      I am struck onto few steps.
      1. On Tesseract Screen Capture indentation parameters. How can we determine the exact parameters if I just want numeric values only.
      2. The Tesseract Screen Capture generates and error Obj1 on line 185 which needs to be resolved.
      3. Sometimes lines get overlapped with values. What to do in that case.
      3. Detecting the sound as and when it approaches and then comparing the ocr values to decide on either buy or sell.
      The values that needs to be fetched are encircled.

    • Simpel
      By Simpel
      Hi.
      When I click 'open this script' in AutoIt Help the example isn't opening. I tried this (FixHelpFileExamples.au3):
      https://www.autoitscript.com/forum/topic/68828-opening-an-example-inside-autoitchm-in-scite/?do=findComment&comment=506522
      All is set. But 'open this script' not working. I tried that (batchfile):
      https://www.autoitscript.com/forum/topic/188272-resolved-random-failure-of-help-to-open-examples/
      This isn't working too.
      What I wonder if my mouse is over 'Copy to clipboard' my cursor is changing to a hand, showing there is a link. If I do the same over 'Open this Script' then mouse is showing the hand for very short time and then getting back to show the arrow. So if I move slowly the cursor over this link it's 'blinking' hand and arrow. What could this be?
      Regards, Conrad
    • newITman
      By newITman
      HI All!
      Im new here and interested in  tesseract ocr.
      There are many examples in the forum but too difficult to me .
      I just want to see how its working in few line cod .
      I have installed  tesseract and microsoft office 2003 .
      My cod:
      $ImageToReadPath = @MyDocumentsDir & "\GDIPlus_Image10.jpg"
      $ResultTextPath = @MyDocumentsDir & "\Result"
      $OutPutPath = $ResultTextPath & "auto.txt"
      ;$TesseractExePath = @ProgramsDir & "\Tesseract.exe"
      $TesseractExePath =@ProgramFilesDir & "\Tesseract-OCR\tesseract.exe"
      ShellExecuteWait($TesseractExePath, '"' & $ImageToReadPath & '" "' & $ResultTextPath & '"', "", "", @SW_HIDE)
      If @error Then
          Exit MsgBox(0, "Error", @error)
      EndIf
      MsgBox(0, "Result", FileRead($OutPutPath))
      FileDelete($OutPutPath)
       
      Please help me.
      my picture:

    • nbg15
      By nbg15
      Hello everybody..
       
      i have this picture here *attached* and this script here: 
       
      $ImageToReadPath = @MyDocumentsDir & "\GDIPlus_Image2.jpg" $ResultTextPath = @MyDocumentsDir & "\Result" $OutPutPath = $ResultTextPath & ".txt" $TesseractExePath = @MyDocumentsDir & "\Tesseract.exe" ShellExecuteWait($TesseractExePath, '"' & $ImageToReadPath & '" "' & $ResultTextPath & '"', "", "", @SW_HIDE) If @error Then Exit MsgBox(0, "Error", @error) EndIf MsgBox(0, "Result", FileRead($OutPutPath)) FileDelete($OutPutPath)  
      but tesseract doesnt recognized the correct word... and gives me trash back...

      this is the image >> 
      and the result was >> "samm" 

      the image was an normal jpg and generated with this code here:
       
      _ScreenCapture_Capture(@MyDocumentsDir & "\GDIPlus_Image2.jpg", 712,268,853,284)
      Could anybody give me a hint what i can do better to get this easy image to text?
       
      thank u very much!!!
       
       
      Edit: i also tried to capture the screen as bmp with a higher resolution... nothing changed... 
       
       
      _ScreenCapture_SetBMPFormat(4) _ScreenCapture_Capture(@MyDocumentsDir & "\GDIPlus_Image.bmp", 712,279,853,295)  
    • Skysnake
      By Skysnake
      Several questions around the forum get asked repeatedly:
      How to avoid false-positive Anti-Virus detection? Answered by AutoIt god himself How to make AutoIt software safe from hacking? How to prevent AutoIt software being de-compiled? How to prevent exposure of native AutoIt code? The general answers all go in the direction of (a) can't be done or (b) make it an .a3x script.
      The Wiki contains a single entry under "compiler directives" and the Help File  contains mainly compiler info, with this note
       
      Also see this thread.
       
      So I thought I would make a little demo to actually show how it works.
      Here are the 2 scripts.  The a3x_demo.zip file contains these 2, plus the compiled .a3x file and the .EXE
       
      The body
      #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Outfile_type=a3x #AutoIt3Wrapper_Outfile=a3x_demo.a3x #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.14.2 Author: Skysnake Script Function: Demonstates working of a3x Instructions Code as normal Set Compiler option to .a3x as per Help File Compile Note output is (a) .a3x file, (b) now compile wrapper to make .exe file The compiled .a3x is included inside the .exe. To demonstrate, copy .exe to any new location and run. :) #ce ---------------------------------------------------------------------------- ; Script Start #include <MsgBoxConstants.au3> MsgBox($MB_SYSTEMMODAL, "a3x demo", "This message box is called from an a3x pre-compiled script " & @CRLF & "will timeout after 10 seconds or select the OK button.", 10) ; code ends  
      The wrapper
      #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Outfile=a3x_wrapper.exe #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.14.2 Author: Skysnake Script Function: Wrapper for .a3x demo the INCLUDE line below forces the .a3x to be included in the new .EXE other option is to use FileIsntall and then run the a3x_demo.a3x as an external file NOTE: required in order are the following steps 1. body .au3 script 2. compile body .au3 as .a3x file, include in wrapper 3. wrapper .au3 script, to become the .exe -> compile as .EXE #ce ---------------------------------------------------------------------------- ; Script Start - #include "a3x_demo.a3x" ; code ends DOWNLOAD: The ax3_demo.zip file
       
      EDIT:
      2016.07.08 Fixed typos
×