Jump to content

Recommended Posts

  • 4 months later...
  • 2 months later...
  • 3 months later...

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)

 

Link to post
Share on other sites
  • 2 years later...

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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By iAmNewbe
      This may or may not be useful and comes in play if you are not using a UDF or the built-in methods or 3rd party code for creating menus and layouts.

      I wrote this with the assumption the reader is new to the language and doesn't have a lot of experience yet.

      Possible Reasons
      1: You are writing Gui elements yourself from scratch.  Why?  because you just desire to.
      2: Need for something to work a specific way that the built-in methods do not allow for.
      3: You just want a learning exercise.

      I was trying to figure out how to recreate the separators you see in tray menus with that same style inside a GUI using Label Controls.
      You know those single lines that separate menu items when you use  
       
      TrayCreateItem("") ; Create a separator line. See Attached Image

      Either there is no single GUI control to allow for the exact styling of separator lines seen in the Tray Menu OR I haven't discovered it yet.
      My solution:


      The color codes in RGB HEX
       
      0xD5DFE5  ;~  A light blue grey color 0xFFFFFF  ;~  Color white
      When you insert your Label Control leave the "text" part empty and do not use any option flags.
      Some of the Style and Ex Style options prevent coloring and sizing the control. 
       
      GUICtrlCreateLabel("", LEFT, TOP, WIDTH, HEIGHT)  
      You need TWO controls and TWO background color settings 
       
      Horizontal Separator  - White Color goes on bottom
      GUICtrlCreateLabel("", LEFT, TOP, WIDTH, HEIGHT)         ;~  Empty Label Control GUICtrlSetBKColor(-1, 0xD5DFE5)                          ;~  Background Color Setting for previous Label Control GUICtrlCreateLabel("", LEFT, TOP + 1, WIDTH, HEIGHT) ;~ Second Label Control needs to be distanced one away from previous Label Control GUICtrlSetBKColor(-1, 0xFFFFFF)  
      Vertical Separator - White Color is on INSIDE or to the Right of the grey line
      GUICtrlCreateLabel("", LEFT, TOP, HEIGHT, WIDTH)         ;~ Reverse Width and Height GUICtrlSetBKColor(-1, 0xD5DFE5)                           GUICtrlCreateLabel("", LEFT + 1, TOP, HEIGHT, WIDTH)     ;~ Add ONE to the LEFT not the TOP GUICtrlSetBKColor(-1, 0xFFFFFF)

      This will MATCH the Tray Menu separators in color and look.  
       

    • By Miliardsto
      Hello I wondering how to read more complicated text from image with Tesseract or other method.
      I used this script and it works with simple text on white background
       
      I need to read text which looks like this

      What I need to do?
      Download fonts or something from there https://github.com/tesseract-ocr/tesseract
      gimme some info please
       
       
    • 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.

    • 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
    • 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:

×
×
  • Create New...