Vis2 - Simple OCR

Post your working scripts, libraries and tools
iseahound
Posts: 104
Joined: 13 Aug 2016, 21:04
GitHub: iseahound

Vis2 - Simple OCR

20 Aug 2017, 00:18

Vis2 - Simple OCR

[Download]



Add the following lines to your main script.

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

#^c:: Vis2.OCR()
#g:: Vis2.google.OCR() ;Googles the text instead of saving it to clipboard.


* When your cursor turns into a crosshair, drag to select a portion of the screen.
* Release LButton when you are satisfied with the preview text.

Press any of the modifier keys, Ctrl, Alt, or Shift to access Advanced Mode.

* Ctrl + LButton: Resize Corners.
* Shift + LButton: Resize Edges
* Alt + LButton: Draw a new rectangle
* Ctrl + Space: Show image preview.
* Space: EXIT and copy text to keyboard!

Press Escape at anytime to cancel.



Full Script. Adds the only class "Vis2". Depends on Gdip_All by tic. You need tesseract and leptonica provided in the download link above.

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



Reminder: You will always find the latest version on my GitHub.

If you have any suggestions or features, please let me know below. I'll implement them along with some other fixes---No definite timeline!
Script is still incomplete and needs work as of 2017-10-18.

If anyone can post a gif or image of this in action, I'd appreciate it!
Last edited by iseahound on 18 Oct 2017, 21:51, edited 7 times in total.
wolf_II
Posts: 1579
Joined: 08 Feb 2015, 20:55

Re: Vis2 - Simple OCR

20 Aug 2017, 01:21

Very nice!! Thanks for sharing. :thumbup:

Image
iseahound
Posts: 104
Joined: 13 Aug 2016, 21:04
GitHub: iseahound

Re: Vis2 - Simple OCR

20 Aug 2017, 03:53

TY, wolf_II.

One thing you might not know, you can hold down RButton to reposition the grey box.

Mini-rant: GUI objects are hellish to code in AHK. Had to rewrite my original AHK GUI commands to Gdip. I also rewrote tics Gdip_TextToGraphics, will release it standalone at a later date.

If anyone is curious, try this:

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

Vis2.Graphics.Subtitle.Render("Matcha Ice Cream & Strawberry Chocolate", "xCenter y:83% w900; time: 4000", {"x":"center", "y":"Bottom", "color":"A6e5b7"})

It accepts objects or strings as inputs and the RegEx is very lenient. (Untested)

EDIT: If anyone is interested in the Subtitle Object (text thing) check it out here
Last edited by iseahound on 31 Aug 2017, 06:41, edited 1 time in total.
rommmcek
Posts: 255
Joined: 15 Aug 2014, 15:18

Re: Vis2 - Simple OCR

20 Aug 2017, 06:02

Pretty accurate for regular text if not too blur or extra tiny!
neokix wrote:Script is still incomplete and needs work as of 2017-08-20.
Any chance for diacritics on the horizon?
iseahound
Posts: 104
Joined: 13 Aug 2016, 21:04
GitHub: iseahound

Re: Vis2 - Simple OCR

28 Aug 2017, 01:35

Refined Subtitle Object, making background transparent black and margins consistent. Should feel better to use now.
guest3456
Posts: 2024
Joined: 09 Oct 2013, 10:31

Re: Vis2 - Simple OCR

31 Aug 2017, 01:55

excellent

Notus
Posts: 7
Joined: 14 Jun 2016, 19:58

Re: Vis2 - Simple OCR

31 Aug 2017, 03:05

Really Nice... wow. I've been looking for this type of OCR! :) Thank you for sharing!
Helgef
Posts: 2246
Joined: 17 Jul 2016, 01:02
Contact:

Re: Vis2 - Simple OCR

31 Aug 2017, 05:50

Really nice script iseahound, it looks very nice and is easy to use. Great job! :clap:
mankvl
Posts: 7
Joined: 23 Sep 2016, 03:58

Re: Vis2 - Simple OCR

31 Aug 2017, 14:58

I'am having problem with this, do I need administrative privileges for this to work? Can I add more language?
User avatar
AlphaBravo
Posts: 314
Joined: 29 Sep 2013, 22:59

Re: Vis2 - Simple OCR

01 Sep 2017, 11:03

didn't work for me
---------------------------
OCR.ahk
---------------------------
Error: Failed attempt to launch program or document:
Action: <.\bin\leptonica_util\leptonica_util.exe>
Params: <C:\Users\xxxx\AppData\Local\Temp\Vis2_screenshot.bmp C:\Users\xxxx\AppData\Local\Temp\Vis2_preprocess.tif 2 0.5 1 3.5 1 5 2.5 1 2000 2000 0 0 0.0>

Specifically: The system cannot find the file specified.



Line#
074: {
075: Vis2.obj.dialogue_past := Vis2.obj.dialogue
076: Vis2.obj.background.y := (Vis2.obj.background.y == "83%") ? "2.07%" : "83%"
077: Vis2.obj.Subtitle.Render(Vis2.obj.dialogue, Vis2.obj.background, Vis2.obj.text)
078: }
079: if (Vis2.obj.Area != "")
080: SetTimer,selectImage,-10
---> 081: Return
082: }
083: {
084: if (GetKeyState("LButton", "P"))
084: {
085: if (GetKeyState("Control", "P") || GetKeyState("Alt", "P") || GetKeyState("Shift", "P"))
086: Vis2.core.process.selectImageTransition()
087: Else

The current thread will exit.
---------------------------
OK
---------------------------
iseahound
Posts: 104
Joined: 13 Aug 2016, 21:04
GitHub: iseahound

Re: Vis2 - Simple OCR

01 Sep 2017, 19:06

AlphaBravo wrote:didn't work for me


Re-download. Open Vis2.ahk. Add this line to the top.

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

#^c:: Vis2.OCR()


Run Vis2.ahk.

For future reference, double check your folder structure. A_workingDir must be A_ScriptDir, folder hierarchy should look like this: mainscript.ahk, lib, bin. Inside lib should be Vis2.ahk and Gdip_All.ahk. Your includes in mainscript.ahk should be #include <Vis2>
User avatar
AlphaBravo
Posts: 314
Joined: 29 Sep 2013, 22:59

Re: Vis2 - Simple OCR

01 Sep 2017, 19:41

iseahound wrote:You need tesseract and leptonica provided in the download link above.

brain fart moment, DUHHHH.
jim7181812
Posts: 14
Joined: 10 Jun 2016, 10:46

Re: Vis2 - Simple OCR

20 Sep 2017, 14:38

Is there any way I can get someone to explain this, I could use OCR. I would need someone to explain it the way you would to an unintelligent newbie in order to make it simple enough for me to understand. Is that possible?
iseahound
Posts: 104
Joined: 13 Aug 2016, 21:04
GitHub: iseahound

Re: Vis2 - Simple OCR

20 Sep 2017, 15:24

Small Update: Bugfix.

The only thing this script does is wrap actual OCR utilities in a manner that makes it accessible to AutoHotkey users. It does not perform computationally expensive neural net operations; those need to be compiled in a lower level language and are included in the download.
jim7181812
Posts: 14
Joined: 10 Jun 2016, 10:46

Re: Vis2 - Simple OCR

20 Sep 2017, 16:58

iseahound wrote:Small Update: Bugfix.

The only thing this script does is wrap actual OCR utilities in a manner that makes it accessible to AutoHotkey users. It does not perform computationally expensive neural net operations; those need to be compiled in a lower level language and are included in the download.


So I download tesseract for the OCR, then your script gives me the objects to use in my script in order to call tesseract? Is my understanding of this remotely close to correct?
Croq
Posts: 7
Joined: 27 Sep 2017, 16:32

Re: Vis2 - Simple OCR

27 Sep 2017, 16:37

How would I go about passing coords to search an area for text?
iseahound
Posts: 104
Joined: 13 Aug 2016, 21:04
GitHub: iseahound

Re: Vis2 - Simple OCR

18 Oct 2017, 21:58

Croq wrote:How would I go about passing coords to search an area for text?


Update: You can now pass coordinates to Vis2.OCR(x, y, w, h) where x, y are the coordinates of the top left corner, and w, h are width and height. Many people have requested this so here it is.

Syntax Change: Please update your hotkeys.

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

#^c:: Vis2.OCR()
#g:: Vis2.google.OCR() ;Googles the text instead of saving it to clipboard.
Croq
Posts: 7
Joined: 27 Sep 2017, 16:32

Re: Vis2 - Simple OCR

19 Oct 2017, 13:32

Much appreciated!!!
burque505
Posts: 73
Joined: 22 Jan 2017, 19:37

Re: Vis2 - Simple OCR

19 Oct 2017, 14:31

Thank you very much, iseahound. This should come in quite handy.
burque505
Posts: 73
Joined: 22 Jan 2017, 19:37

Re: Vis2 - Simple OCR

19 Oct 2017, 14:50

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

Return to “Scripts and Functions”

Who is online

Users browsing this forum: No registered users and 12 guests