I am trying to OCR the image

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
liij
Posts: 51
Joined: 23 Apr 2016, 13:25

I am trying to OCR the image

21 Sep 2017, 08:13

Image is in the same directory as .bat and.ahk

Code: Select all

q::
TempFile := A_Temp . "\temp_capture.txt"
FileDelete, %TempFile%
;RunWait, Capture2Text_CLI.exe -s "1805 22 1897 33" -d --whitelist 1234056789/ ,,Hide
;RunWait, supplyandblackonwhite.bat,,Hide
RunWait, Capture2Text_CLI.exe -i black_on_white.png --whitelist 1234056789/ -o %TempFile%
sleep 1
FileRead, CaptureText, %TempFile%
FileDelete, %TempFile%
var := StrSplit(CaptureText,"/","`r`n")
var1 := var[1]
var2 := var[2]
MsgBox % var[1] "-" var1 "`n" var[2] "-" var2
if ((var1 < var2) && (var1 > 9) && (var1 < 201) && (var2 > 2) && (var2 < 201)) 
	{
    sbflag := 0
   ; Loop 3 {
     ;  SoundBeep
    ;    Sleep 50
    ;    }
	}
Return
Image
Capture2Text_CLI.exe and this script works perfectly whenOCR-ing screen rectangle, but I can not OCR the image placed in the same directory. I am sure that image with the name black_on_white.png exist.
liij
Posts: 51
Joined: 23 Apr 2016, 13:25

Re: I am trying to OCR the image

21 Sep 2017, 10:59

I already have ready script that is preparing images for OCR black_on_white.png
Image
I just want to put this image into OCR with ahk or .bat script
This command in ahk OCR-s part of the screen (this command works excellent)

Code: Select all

RunWait, Capture2Text_CLI.exe -s "1805 22 1897 33" -d --whitelist 1234056789/ ,,Hide
This command (that is not working) is supossed to OCR image, but it fails for unknown me reason, I am trying to find that reason

Code: Select all

RunWait, Capture2Text_CLI.exe -i black_on_white.png --whitelist 1234056789/ -o %TempFile%
edit
I also was trying .bat batch command

Code: Select all

Capture2Text_CLI.exe -i black_on_white.png -o result.txt
result.txt

Code: Select all

<Error>
liij
Posts: 51
Joined: 23 Apr 2016, 13:25

Re: I am trying to OCR the image

21 Sep 2017, 14:13

I tried version from Capture2Text_v4.3.0_64bit.zip, does not work either.
User avatar
JoeWinograd
Posts: 2198
Joined: 10 Feb 2014, 20:00
Location: U.S. Central Time Zone

Re: I am trying to OCR the image

22 Sep 2017, 21:55

I think it's a bug in the Capture2Text CLI version. As you know, the Capture2Text on-screen version handles it fine, but the CLI gives this error:

Error, pre-processing failure:
"black_on_white.png"
<Error>


Other CLI OCR packages handle it fine. For example, here are the results of using a different CLI OCR package:

C:\Program Files (x86)\Nuance\Power PDF 21>BatchConverter.com -Ic:\temp\black_on_white.png -Oc:\temp\result.txt -TTXT -K -Leng
Converting c:\temp\black_on_white.png to c:\temp\result.txt
Done.


Here's the contents of c:\temp\result.txt after that command:

12/38

Regards, Joe

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Descolada, Google [Bot] and 240 guests