Vis2 - OCR(), ImageIdentify()

Post your working scripts, libraries and tools
Croq
Posts: 8
Joined: 27 Sep 2017, 16:32

Re: Vis2 - Simple OCR

19 Oct 2017, 15:48

Not sure what I'm doing wrong but when i try to run it i get:

>"C:\Program Files\AutoHotkey\AutoHotkey.exe" /ErrorStdOut "\\READYSHARE\USB_Storage\Backups\AHK Scripts\BitHero\test.ahk"
\\READYSHARE\USB_Storage\Backups\AHK Scripts\Gdip_All.ahk (66) : ==> Expected ":="
Specifically: ="", y="", w="", h="", Alpha=255)
>Exit code: 2 Time: 0.1808
iseahound
Posts: 235
Joined: 13 Aug 2016, 21:04
GitHub: iseahound

Re: Vis2 - Simple OCR

19 Oct 2017, 17:48

Try asking around in the Ask For Help forum. It's because Gdip_All uses the old assignment operator "=" (equals sign) instead of the modern one ":=". This error has never happened to me.

Perhaps you have #Warn on the top of your script? (remove it.) Try adding #NoEnv as well.

You could fix it by replacing all equals sign assignments with the ":=" operator. Try updating your Gdip_All to see if that helps.

This isn't an error within Vis2.
iseahound
Posts: 235
Joined: 13 Aug 2016, 21:04
GitHub: iseahound

Re: Vis2 - Simple OCR

19 Oct 2017, 17:51

burque505 wrote:Thank you very much, iseahound. This should come in quite handy. Needs AHK_L, correct?


Yes. Ahk_L
Croq
Posts: 8
Joined: 27 Sep 2017, 16:32

Re: Vis2 - Simple OCR

19 Oct 2017, 18:56

Perfect, thanks iseahound
Croq
Posts: 8
Joined: 27 Sep 2017, 16:32

Re: Vis2 - Simple OCR

19 Oct 2017, 19:21

Could you post your Gdip_all.ahk?
iseahound
Posts: 235
Joined: 13 Aug 2016, 21:04
GitHub: iseahound

Re: Vis2 - Simple OCR

19 Oct 2017, 20:07

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



Official Link | Forum | Gdip Tutorials

Side Note: A large part of the script is still under development - Syntax will change!
Croq
Posts: 8
Joined: 27 Sep 2017, 16:32

Re: Vis2 - Simple OCR

20 Oct 2017, 07:11

thanks! It's awesome!
Croq
Posts: 8
Joined: 27 Sep 2017, 16:32

Re: Vis2 - Simple OCR

20 Oct 2017, 07:26

for some reason it appears to be getting more than what is in my x,y,w,h.
Johana
Posts: 184
Joined: 02 May 2017, 02:34

Re: Vis2 - Simple OCR

20 Oct 2017, 14:36

Anyway to make it support ÅÄÖ an other special chars?
iseahound
Posts: 235
Joined: 13 Aug 2016, 21:04
GitHub: iseahound

Re: Vis2 - OCR()

08 Nov 2017, 21:54

Update: Now supports multiple data sources, including Files, URLs, Rectangle Array (screenshot coordinates), Windows, Base 64 encoded images, and GDI Bitmaps/hBitmaps.

Of course if you leave the input blank ^#c:: OCR() then you will still be able to access the nice GUI.
Croq
Posts: 8
Joined: 27 Sep 2017, 16:32

Re: Vis2 - OCR()

03 Dec 2017, 10:28

with the latest vis2 on 11/6 did the COORDINATE search get removed?

EDIT: Never mind i see it on GitHub

Code: [Select all] [Download] GeSHi © Codebox Plus

OCR([0, 0, 430, 150])
chenzhipeng
Posts: 1
Joined: 19 Dec 2015, 06:52

Re: Vis2 - OCR()

23 Dec 2017, 21:41

Thank you very much, iseahound , But there is some question, how to change the language if I want to use it in Chinese?
songdg
Posts: 50
Joined: 04 Oct 2017, 20:04

Re: Vis2 - OCR()

28 Dec 2017, 02:29

Error at line 128 in #include file "D:\Vis2\Lib\Gdip_All.ahk".
Line Text:Features</a> </li><li class="ml-4"><a href="/business" class="js-selected-navigation....
Error:This line does not contain a recognized action.

Could somebody help me fix this problem,I really need this tool.
iseahound
Posts: 235
Joined: 13 Aug 2016, 21:04
GitHub: iseahound

Re: Vis2 - OCR()

29 Dec 2017, 16:21

Croq wrote:with the latest vis2 on 11/6 did the COORDINATE search get removed?

EDIT: Never mind i see it on GitHub

Code: [Select all] [Download] GeSHi © Codebox Plus

OCR([0, 0, 430, 150])


I added the ability to use OCR on URLs, File Paths, and Windows, etc. The older syntax had to be changed.


songdg wrote:Error at line 128 in #include file "D:\Vis2\Lib\Gdip_All.ahk".
Line Text:Features</a> </li><li class="ml-4"><a href="/business" class="js-selected-navigation....
Error:This line does not contain a recognized action.

Could somebody help me fix this problem,I really need this tool.


Hey, I think I fixed your problem. Could you redownload it from here and try again? https://github.com/iseahound/Vis2/archive/master.zip Let me know if the tutorial on GitHub is unclear.
songdg
Posts: 50
Joined: 04 Oct 2017, 20:04

Re: Vis2 - OCR()

31 Dec 2017, 00:12

iseahound wrote:
Croq wrote:with the latest vis2 on 11/6 did the COORDINATE search get removed?

EDIT: Never mind i see it on GitHub

Code: [Select all] [Download] GeSHi © Codebox Plus

OCR([0, 0, 430, 150])


I added the ability to use OCR on URLs, File Paths, and Windows, etc. The older syntax had to be changed.


songdg wrote:Error at line 128 in #include file "D:\Vis2\Lib\Gdip_All.ahk".
Line Text:Features</a> </li><li class="ml-4"><a href="/business" class="js-selected-navigation....
Error:This line does not contain a recognized action.

Could somebody help me fix this problem,I really need this tool.


Hey, I think I fixed your problem. Could you redownload it from here and try again? https://github.com/iseahound/Vis2/archive/master.zip Let me know if the tutorial on GitHub is unclear.

Thanks,but still didn't worked.When I run your scrip,it shows that below.

Script lines most recently executed (oldest first). Press [F5] to refresh. The seconds elapsed between a line and the one after it is in parentheses to the right (if not 0). The bottommost line's elapsed time is the number of seconds since it executed.
---- C:\Vis2-master\Lib\Gdip_All.ahk
705: FName := "ObjRelease"
---- C:\Vis2-master\Vis2.ahk
054: Vis2.GoogleCloudVision.api_key := "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
128: Vis2.Tesseract.leptonica := ".\bin\leptonica_util\leptonica_util.exe"
129: Vis2.Tesseract.tesseract := ".\bin\tesseract\tesseract.exe"
130: Vis2.Tesseract.tessdata := ".\bin\tesseract\tessdata"
133: fileBitmap := A_Temp "\Vis2_screenshot.bmp"
134: fileProcessedImage := A_Temp "\Vis2_preprocess.tif"
135: fileConvert := A_Temp "\Vis2_text"
136: fileConvertedText := A_Temp "\Vis2_text.txt"
182: req := ComObjCreate("WinHttp.WinHttpRequest.5.1")
258: req := ComObjCreate("WinHttp.WinHttpRequest.5.1")
332: null := ObjBindMethod({}, {})
362: escape := ObjBindMethod(Vis2.core.ux, "escape")
363: waitForUserInput := ObjBindMethod(Vis2.core.ux, "waitForUserInput")
364: selectImage := ObjBindMethod(Vis2.core.ux.process, "selectImage")
365: textPreview := ObjBindMethod(Vis2.core.ux.process, "textPreview")
389: selectImage := ObjBindMethod(Vis2.core.ux.process, "selectImage")
430: null := ObjBindMethod({}, {})
444: null := ObjBindMethod({}, {})
517: textPreview := ObjBindMethod(Vis2.core.ux.process, "textPreview")
576: escape := ObjBindMethod(Vis2.core.ux, "escape")
601: escape := ObjBindMethod(Vis2.core.ux, "escape")
602: null := ObjBindMethod({}, {})
667: SystemCursors := "32512,32513,32514,32515,32516,32640,32641,32642,32643,32644,32645,32646,32648,32649,32650,32651"
693: BCRYPT_MD5_ALGORITHM := "MD5"
694: BCRYPT_OBJECT_LENGTH := "ObjectLength"
695: BCRYPT_HASH_LENGTH := "HashDigestLength"
748: ocrPreProcessing := 1
749: negateArg := 2
750: performScaleArg := 1
751: scaleFactor := 3.5
786: Vis2.Graphics.Gdip := 0
857: WM_KEYDOWN := 0x100
858: WM_KEYUP := 0x101
859: vk_to_use := 7
1250: Vis2.Graphics.CustomFont.FR_PRIVATE := 0x10
1266: FW_NORMAL := 400
1266: DEFAULT_CHARSET := 0x1
1464: q1 := "i)^.*?(?<!-|:|:\s)\b(?![^\(]*\))"
1465: q2 := "(:\s?)?\(?(?<value>(?<=\()[\s\-\da-z\.#%]+(?=\))|[\-\da-z\.#%]+).*$"
1478: alpha := "^[A-Za-z]+$"
1479: decimal := "^(\-?\d+(\.\d*)?)$"
1480: integer := "^\d+$"
1481: percentage := "^(\-?\d+(?:\.\d*)?)%$"
1482: positive := "^\d+(\.\d*)?$"
1886: colorRGB := "^0x([0-9A-Fa-f]{6})$"
1887: colorARGB := "^0x([0-9A-Fa-f]{8})$"
1888: hex6 := "^([0-9A-Fa-f]{6})$"
1889: hex8 := "^([0-9A-Fa-f]{8})$"
1901: percentage := "^(\-?\d+(?:\.\d*)?)%$"
1902: positive := "^\d+(\.\d*)?$"
1938: percentage := "^(\-?\d+(?:\.\d*)?)%$"
1939: positive := "^\d+(\.\d*)?$"
1966: decimal := "^(\-?\d+(\.\d*)?)$"
1967: percentage := "^(\-?\d+(?:\.\d*)?)%$"
1968: positive := "^\d+(\.\d*)?$"
2226: CryptStringToBinary := "crypt32\CryptStringToBinary" (A_IsUnicode ? "W" : "A")
---- C:\Vis2-master\Lib\Gdip_All.ahk
070: {
......
2672: {
---- C:\Vis2-master\Vis2.ahk
010: {
......
2456: {
2473: Exit (1.81)

Press [F5] to refresh.
iseahound
Posts: 235
Joined: 13 Aug 2016, 21:04
GitHub: iseahound

Re: Vis2 - OCR()

31 Dec 2017, 15:38

songdg wrote:.


Ah the script is working perfectly.

Here is an introductory guide taken from my GitHub:

1. Download Vis2.
2. Create a new AHK script in the same folder as Vis2.ahk, copying the code below.

Code: [Select all] [Download] GeSHi © Codebox Plus

    #include Vis2.ahk
MsgBox % OCR("https://i.stack.imgur.com/sFPWe.png")

3. Press Enter to exit. Visit the image link to confirm the OCR is working correctly.


To summarize: You need to create a second .ahk file, and paste the code from Step 2. The second file will "import" Vis2 library and let you use the OCR.

The log you posted is the script initializing variables on its first run. Double clicking the Vis2.ahk file will do nothing, since libaries do nothing.

Let me know if you have more questions!

Also try this code:
songdg
Posts: 50
Joined: 04 Oct 2017, 20:04

Re: Vis2 - OCR()

02 Jan 2018, 01:52

iseahound wrote:
songdg wrote:.


Ah the script is working perfectly.

Here is an introductory guide taken from my GitHub:

1. Download Vis2.
2. Create a new AHK script in the same folder as Vis2.ahk, copying the code below.

Code: [Select all] [Download] GeSHi © Codebox Plus

    #include Vis2.ahk
MsgBox % OCR("https://i.stack.imgur.com/sFPWe.png")

3. Press Enter to exit. Visit the image link to confirm the OCR is working correctly.


To summarize: You need to create a second .ahk file, and paste the code from Step 2. The second file will "import" Vis2 library and let you use the OCR.

The log you posted is the script initializing variables on its first run. Double clicking the Vis2.ahk file will do nothing, since libaries do nothing.

Let me know if you have more questions!

Also try this code:


Thank you very much it works,this tool is awesome!
songdg
Posts: 50
Joined: 04 Oct 2017, 20:04

Re: Vis2 - OCR()

04 Jan 2018, 01:07

If it is possible to conbine the syntax text := OCR("C:\image.png") and text := OCR([0, 0, 430, 150]) to scan an image file in specific region.
iseahound
Posts: 235
Joined: 13 Aug 2016, 21:04
GitHub: iseahound

Re: Vis2 - OCR()

04 Jan 2018, 04:56

songdg wrote:If it is possible to conbine the syntax text := OCR("C:\image.png") and text := OCR([0, 0, 430, 150]) to scan an image file in specific region.


I just updated a new version on my GitHub. Redownload it please.

Code: [Select all] [Download] GeSHi © Codebox Plus

    #include Vis2.ahk
MsgBox % OCR("https://i.stack.imgur.com/sFPWe.png", , [0,120,999,999]) ; [x, y, width, height]

^ There is a blank parameter, that is for a feature I have not created yet.
BoBo
Posts: 2515
Joined: 13 May 2014, 17:15

Re: Vis2 - OCR()

06 Jan 2018, 17:42

GOSH, that looks like a promising toy! :thumbup: A day ago I would have named you a genius, unfortunately that term has been burned today by someone who proclaimed himself a 'stable genius' :crazy: :wtf: :lolno:

I've had a try to start it the way you've advised on GitHub. It starts but it hasn't shown anything (AHKU64 1.1.27 | Win10), and its icon disappears once I hover over it (AFAIK that means the script is collapsing).
I've changed the path to a local copy of your image. Didn't work either :arrow: "~ not the correct URL format."
Ran it 'blank' OCR(). Cursor changed to crosshair, once I've tried to select text, booooom windows returned a msgbox pointing out that AHK has died (and the cross-haired mouse is still active :lolno: )

Now I'm a bit frustrated. Just like a man with tiny hands and a big button :mrgreen:

Return to “Scripts and Functions”

Who is online

Users browsing this forum: Bing [Bot], feiyue and 17 guests