Jump to content

Recommended Posts

AutoIT-OCRSpace-UDF1.3.zip

This tiny yet powerful UDF will help you to convert Images to text with the help of  OCRSpace API version 3.50 .

Detect text from a local file.

; =========================================================
; Example 2 : Gets text from an image from a local path reference
;           : Searchable PDF is not requested by default.
;           : Processes it using a basic OCR logic.
; =========================================================

$b_Create_Searchable_PDF = True

; Use a table logic for receipt OCR
$b_Table = True

; Set your key here.
$v_OCRSpaceAPIKey = ""

$OCROptions = _OCRSpace_SetUpOCR($v_OCRSpaceAPIKey, 1, $b_Table, True, "eng", True, Default, Default, $b_Create_Searchable_PDF)
$sText_Detected = _OCRSpace_ImageGetText($OCROptions, @scriptdir & "\receipt.jpg", 0, "SEARCHABLE_URL")

ConsoleWrite( _
        " Detected text   : " & $sText_Detected & @CRLF & _
        " Error Returned  : " & @error & @CRLF & _
        " PDF URL         : " & Eval("SEARCHABLE_URL") & @CRLF)

 

Detect text from a URL reference.

; =========================================================
; Example 1 : Gets text from an image using a url reference
;           : Searchable PDF is not requested.
;           : Processes it using a basic OCR logic.
; =========================================================

$v_OCRSpaceAPIKey = ""

; SetUp some preferences..
$OCROptions = _OCRSpace_SetUpOCR($v_OCRSpaceAPIKey, 1, False, True, "eng", True, Default, Default, False)
; Make the request..
$sText_Detected = _OCRSpace_ImageGetText($OCROptions, "https://i.imgur.com/vbYXwJm.png", 0)

ConsoleWrite( _
        " Detected text   : " & $sText_Detected & @CRLF & _
        " Error Returned  : " & @error & @CRLF)
 

 

Detect text from a URL reference to an array

#include "OCRSpaceUDF\_OCRSpace_UDF.au3"
#include <array.au3>

; Set your key here.
$v_OCRSpaceAPIKey = ""
    
$OCROptions = _OCRSpace_SetUpOCR($v_OCRSpaceAPIKey, 1, $b_Table, True, "eng", True, Default, Default, False)
    
; Below, the return type is set to 1 to return an array containing the coordinates of the bounding boxes for each word detected,
; in the format : #WordDetected , #Left , #Top , 3Height, #Width
    
$aText_Detected = _OCRSpace_ImageGetText($OCROptions, "https://i.imgur.com/Z1enogD.jpeg", 1)

_ArrayDisplay($aText_Detected, "")

 

 

 

 

 

https://github.com/KabueMurage/AutoIT-OCRSpace-UDF

Download Latest Version

 

Edited by MrKm
New Version 1.3
Link to post
Share on other sites
  • 5 months later...

hi, thank you for this! I have had problems with accuracy with Tesseract (specifically numbers). I found this to be more reliable. Although sometimes it works better with Engine 1, sometimes Engine 2.

Also, sometimes I get what I assume to be a timeout message. Any idea on how to handle this:

"C:\Program Files (x86)\AutoIt3\Include\_OCRSpace_UDF.au3" (508) : ==> Unknown function name.:
If Not _WinAPI_IsInternetConnected() Then
If Not ^ ERROR

Link to post
Share on other sites
  • Moderators

Hi,

Please make sure you read the  OCRSpace API link before you get too involved in this UDF. This is NOT a stand-alone OCR solution and requires internet linkage to the host server with various limits on frequency and size for the free subscription. I do not want to put anyone off, but this is not clear from the OP.

M23

 

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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

    No registered users viewing this page.

  • Similar Content

    • By Danyfirex
      Hello guys.  I recently saw some posts that Windows 10 provides OCR API. So I decided to create a UDF.
       
       
      What's UWPOCR?
      UWPOCR UDF is a simple library to use Universal Windows Platform Optical character recognition API.
      Features.
      Get Text From Image File. Get Text From GDI+ Bitmap. Easy to use.  Usage:
      #include "..\UWPOCR.au3" _Example() Func _Example() Local $sOCRTextResult = _UWPOCR_GetText(FileOpenDialog("Select Image", @ScriptDir & "\", "Images (*.jpg;*.bmp;*.png;*.tif;*.gif)")) MsgBox(0,"",$sOCRTextResult) EndFunc  
      More examples here.
       
      Check UWPOCR UDF on GitHub.
       
      Saludos
    • By nacerbaaziz
      hello evrybody
      here is an example about how to split your texts using a delimiter with the ability to select how much of delimiters shows in each colum  with $i_number
      e.g
      you have a long text and you want to split it in an array
      that evry colum have a number (n) of lines
      i made a function that do that for you
      just call it with a three params
      $s_text
      your text
      $i_number
      the number that you want to put in each col
      $s_siparator
      the siparator
      default is "|"
      here is the function with example
      i hope that it will be useful for you
       
      ****
       
      #include <Array.au3> $s_txt = "some text1some text2|some text3|some text4|some text5|some text6" $array = splitText($s_txt, 2) _ArrayDisplay($array) Func splitText($s_text, $i_number, $s_siparator = "|") Local $a_TXT = StringSplit($s_text, $s_siparator) Local $a_Return[$a_TXT[0] + 1] If ($a_TXT[0] <= $i_number) Or ($i_number <= 0) Then ReDim $a_Return[2] $a_Return[0] = 1 $a_Return[1] = $s_text Return $a_Return EndIf Local $i_Processed = 1, $i_arrayProcessed = 1 Do For $i = $i_Processed To ($i_Processed + $i_number) - 1 If ($a_TXT[0] < $i) Then ExitLoop If Not ($a_Return[$i_arrayProcessed]) Then $a_Return[$i_arrayProcessed] = $a_TXT[$i] Else $a_Return[$i_arrayProcessed] &= $s_siparator & $a_TXT[$i] EndIf $i_Processed += 1 Next $i_arrayProcessed += 1 Until ($a_TXT[0] < $i_Processed) ReDim $a_Return[$i_arrayProcessed] $a_Return[0] = $i_arrayProcessed - 1 Return $a_Return EndFunc ;==>splitText
      accept my greetings
      thanks to
      @Dan_555
      for his notes
       
    • By nacerbaaziz
      hello autoit team
      please i've a question for you.
      am creating a audio player
      and in this audio player i want to show the current trac info
      such as the total time and the position ... etc
      i know i can show it as label
      but the screen reader for the blind read the text every change
      because it have a screen scan
      what i want is to show this informations but such image or icon
      i mean i need to create
      GUICtrlCreatepic or GUICtrlCreateicon ....
      or some thing as that
      and show this informations as image on it
      i think that i can do that with the 
      _GDIPlus functions
      but i couldn't find the currect way to do it
      i tried the _GDIPlus_GraphicsDrawString
      but i couldn't know how it work
      what i need is a small example that create a GUI
      and add a multy line text to it as graphic or image.
      so i need a simple way because it will changed every sec
      i hope any one can help me to do that
      global $GUI = GUICreate("text", 400, 400) global $label = GUICtrlCreateLabel(GetText(), 10, 10, 380, 380) GUISetState() do sleep(100) until GUIGetMSG() = -3 exit func GetText() return StringFormat("file name is test.mp3 \r\n total time is 00:30:00 \r\n position is 00:05:50") endFunc  
    • By nacerbaaziz
      hello autoit group
      please i've a question
      i had make a function that put some thing into the clipBoard and paste it
      using the send function
      e.g
      ClipPut("hello")
      send("^v")
       
      when the keyboard is english all things work fine
      but when the keyboard is arabic the send command write the ltr v insted of the text in clipboard
      i was tryed to use
      send("{ctrldown}v{ctrlUp}")
      but the same
      please can any one help me
       
    • By Kiko745
      Hello!
      I am new to autoit so please if someone could help me. I am trying to combine multiple .txt files but I can't get it right. In every file are the exact amout of lines ( for example here are 2 ) ,            I don't want to make it for just 2 lines for each txt files but for all the lines the txt files contains. The thing I want to do is :
      Text File 1
      Hello my name
      I am a big
      ...
      Text File 2
      is Fred,
      Potato head for
      ...
      Text File 3
      and I like to eat pizza.
      Not getting this right.
      ...
      ------------------- Combine them all into one txt file like here ------------------------------
      Final Text file
      Hello my name is Fred, and I like to eat pizza.
      I am a big Potato head for Not getting this right.
      ...
       
      Thanks for any advice!
      P.S. Sorry for my English, not my first language.
       
×
×
  • Create New...