Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

OCR.ahk - Library for recognizing text in images


  • Please log in to reply
88 replies to this topic
Rizzo
  • Members
  • 3 posts
  • Last active: Nov 10 2014 03:01 AM
  • Joined: 27 Nov 2012
EDIT: nvm, I solved my problem, post can be deleted

side
  • Members
  • 168 posts
  • Last active: Nov 30 2014 03:41 PM
  • Joined: 01 Nov 2012
nice work dude.now checking.you will have my feedback soon

rajk
  • Members
  • 4 posts
  • Last active: Jan 04 2013 07:48 AM
  • Joined: 27 Dec 2012
Hi, I was looking at your OCR.ahk script. When I run the preview, the pink rectangle shows up but no tooltip occurs. I have updated gdip.ahk and gocr.exe, but nothing happens. Can you help me fix this?
I am using the latest version of AutoHotKey_L on Windows 7 64 bit.


camerb
  • Moderators
  • 573 posts
  • Last active: Sep 14 2015 03:32 PM
  • Joined: 19 Mar 2009
rajk: Did you unzip the zip file before running the AHK? Also, can you tell where the AHK stopped by opening up the "Lines most recently executed" debug panel in AHK? Can you tell if the PNM and JPG files were generated?

Aren't you glad that I didn't put an annoying gif here?

vehementi
  • Members
  • 4 posts
  • Last active: Aug 31 2013 05:09 AM
  • Joined: 20 Jan 2013

I am having the same issue as rajk.  I extracted the zip and ran OCR-preview.ahk, which made a solid pink rectangle appear briefly, and then a transparent pink rectangle with nothing in it appears at my mouse.  Here is a screenshot in which you can see the transparent pink rectangle over your post, the last lines of the script executed, and my directory containing unzipped files with no PNM or JPG files at that time: http://i.imgur.com/PwcbC1N.png

 

I am also on Win 7 64 bit with latest AutoHotKey_L.  Running as administrator and turning off UAC (not that that's a solution) doesn't affect this.

 

I appear to be having the same issue as you had in http://www.autohotke...gdip-and-ahk-l/ because that code hangs for me as well, even if I use an absolute path.
 
edit: solved by using AHK_L 32 bit unicode library.


camerb
  • Moderators
  • 573 posts
  • Last active: Sep 14 2015 03:32 PM
  • Joined: 19 Mar 2009
New version posted. v0.96 should function properly with 64-bit AHK_L installations. Please let me know if there are any issues.

This extends support to:
AHK_basic
AHK_L ANSI 32-bit
AHK_L ANSI 64-bit
AHK_L Unicode 32-bit
AHK_L Unicode 64-bit

Tested on AHK_L v1.1.09.04

In addition, I removed the dependency upon the CmdRet library. Not sure if anybody else will care about that, but I am happy I did it.
Aren't you glad that I didn't put an annoying gif here?

woonsik
  • Members
  • 15 posts
  • Last active: Apr 12 2013 08:32 AM
  • Joined: 15 Jan 2013
nice script!
but, how to ocr korean language?
It is possible?

trend747
  • Members
  • 10 posts
  • Last active: Dec 30 2013 03:29 AM
  • Joined: 10 Jun 2013

Is there any way to take a snapshot of a screen, find a letter, and store the coordinates in a variable?



Lazylimey
  • Members
  • 9 posts
  • Last active: Jun 27 2013 11:13 PM
  • Joined: 30 May 2013

Hi

 

I bee this works on Screen Coords - anyway to get it working on Window Coords - I tried and it seems to screw up



Lazylimey
  • Members
  • 9 posts
  • Last active: Jun 27 2013 11:13 PM
  • Joined: 30 May 2013

sorry about the 'bee' lol - should be 'see' of course



FishStik
  • Members
  • 3 posts
  • Last active: Jul 19 2013 03:52 PM
  • Joined: 15 Nov 2012

Nice work, camrb! Works great for the command prompt. One suggestion to make is possibly 'training' the OCR for a specific font/color/size. Since most of the time the user knows the style of text to be read, you could make it so the user can specify a sample image of glyphs (a-z, 0-9, symbols) in a specific font and color, then save these settings to give theoretically 100% accurate readings as long as the text style is known. Just a thought happy.png



camerb
  • Moderators
  • 573 posts
  • Last active: Sep 14 2015 03:32 PM
  • Joined: 19 Mar 2009
Sorry it took me so long to reply to your posts. Unfortunately, the "follow topic" feature on the forum was still broken. Here are my replies to each of you:

woonsik: No, this OCR lib uses GOCR, which assumes English is the only language present. You may want to search the internet for OCR tools that can read Korean characters.

trend747: I don't quite follow what you are asking. If you look at the OCR-example.ahk file provided, the function takes a snapshot, and returns a string containing the text that was found in that screenshot.

Lazylimey: In the "options" parameter (the fifth one), be sure to specify "activeWindow" somewhere in there. This will allow the script to work using coordinates relative to the active window, and not the screen. PM me with an example of the issue if you can't get it figured out.

FishStik: Yes, you can make your own by taking screenshots of each character, but that is not a very sophisticated OCR, and it would require extensive configuration for each font and color. This method requires minimal configuration, and ranges between 85%-95% accuracy (that figure depends on a lot of factors). Feel free to make your own lib using your suggested method and post it on the forums to make it available to others (your suggestion would probably prove sufficient for woonsik's request posted above). Further reading: http://en.wikipedia....ter_recognition
Aren't you glad that I didn't put an annoying gif here?

Duffer
  • Members
  • 2 posts
  • Last active: Jan 01 2014 08:12 PM
  • Joined: 27 Dec 2013

Hello there.

 

I found your tool yesterday, and I have had VERY good luck with it.  It's working very well.  GOCR does a fine job, and I spent some time training it, but it was still pretty hit or miss.

 

I made one modification to your OCR.ahk script that helped ME a lot - may be worth adding an option.

 

I added "-colors 2" to the djpeg command

   convertCmd=djpeg.exe -pnm -colors 2 -grayscale %filenameJpg% %filenamePnm%
 
What this does is take a LOT of the guesswork out of the high-contrast/low-contrast issues that GOCR can have from time to time.
 
It's probably helped MY hit rate a fair bit.  A bunch of letters it's catching that it didn't catch before.
 
Thanks for a GREAT tool, camerb!


Duffer
  • Members
  • 2 posts
  • Last active: Jan 01 2014 08:12 PM
  • Joined: 27 Dec 2013

OOPS - one more detail I left out...

You also need "-dither none" in there

   convertCmd=djpeg.exe -pnm -colors 2 -grayscale -dither none %filenameJpg% %filenamePnm%


farfaraway
  • Members
  • 89 posts
  • Last active: Sep 18 2015 04:52 PM
  • Joined: 13 Nov 2013

great tool! but i have a question, OCR can find my numbers but i can not store the number into a variable? or use it in an expression?