MrKm Posted June 27, 2021 Posted June 27, 2021 (edited) 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, "") Download Latest Version : https://github.com/MurageKabui/AutoIT-OCRSpace-UDF Edited December 16, 2022 by MrKm Updated project URL. mLipok and Hashim 1 1 AutoIT OCR UDF with OCRSpace
drrehak Posted January 28, 2022 Posted January 28, 2022 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
Moderators Melba23 Posted January 28, 2022 Moderators Posted January 28, 2022 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 Hashim 1 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
drrehak Posted January 30, 2022 Posted January 30, 2022 Yes. I have the free account. I am far from the daily/monthly limit testing. So the error is not because of that…
MrKm Posted February 1, 2022 Author Posted February 1, 2022 On 1/28/2022 at 10:02 PM, drrehak said: 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 You're welcome and thanks too for feedback ! _WinAPI_IsInternetConnected() is declared in WinAPIDiag.au3. My bad, I forgot to include it in the udf. You can include it in your script or in the OCRSpace UDF by : #include <WinAPIDiag.au3> AutoIT OCR UDF with OCRSpace
Deathdn Posted April 8, 2022 Posted April 8, 2022 Too much Error and Warning. And I'm not sure about this test 😐 yutijang 1
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now