Jump to content


Photo

Optical Digit Recognition


  • Please log in to reply
18 replies to this topic

#1 Xander

Xander
  • Members
  • 140 posts

Posted 04 October 2007 - 01:51 AM

100% pure AHK for recognizing the characters $.,0123456789

Download: ODR.ahk [ SKAN's Dropbox ]

Note that spaces are put in place of whatever character that doesn't map properly. To see the "signature" of unrecognized characters, uncomment the println(signature) line and include the following:
Print(str) { 
   static create = true, output 
   if create { 
      create = 
      Gui, 99: -Caption 
      Gui, 99:Margin, 0, 0 
      Gui, 99:Add, Edit, w500 r5 voutput 
      x := A_ScreenWidth - 500 
      Gui, 99:Show, NoActivate x%x% y0 
   } else 
      GuiControlGet, output, 99: 
   GuiControl, 99: , output, %output%%str% 
   Gui, 99:Show, NoActivate 
} 
PrintLn(str) { 
   Print(str . "`n") 
}


#2 BoBo¨

BoBo¨
  • Guests

Posted 05 October 2007 - 07:39 AM

Looks like a promising tool/concept. Thx for sharing it :)
Unfortuantely I've no idea how to use it. There's no sample scenario/HowTo/advise.
I've 'implemented' the Gui-snippet you've provided, just to get some output, without success. Eg. there's no 'str' variable set to be used with that PrintLn(str)-function. You might shed some light on this.
Thx for listening. 8)

#3 Xander

Xander
  • Members
  • 140 posts

Posted 05 October 2007 - 02:35 PM

I've put documenting it on my Todo list. Probably would be best as the source (Java code I wrote quite awhile ago) wasn't documented at all either. Well actually I never really finished the Java version because I meant for it to recognize all characters and this method is not good for that. But it works fine for recognizing a subset of characters.

About the PrintLn(str) function... I don't understand your assigning str statement. str is just the parameter passed to the function. PrintLn(signature) is a line that is commented out in the ODR.ahk file.

The signature of what is read works like this:

First the first few columns are scanned and the number and position of of pixels are marked (depending on the size, sometimes it only scans the first column). For example, the number 7 has the following signature for the first column: 2AC. 2 means it has 2 hits, A tells you the first hit starts at the top of the character and ends somewhere in the middle. C signifies that the hit starts somewhere in the middle and ends at the bottom of the character. Similarly B would signify that the hit starts in the middle and ends in the middle, and D would signify that the hit starts at the top and ends at the bottom. Then the last column is scanned and that signature is appended to the previous, and similarly the top row and bottom row are scanned in that order.

So the number 7 has the signature of 2AC1A1D1A. Another font of 7 may also have the signature of 1A1A1D1B so both of those have to be accounted for...

Hope that helps for now.

#4 Xander

Xander
  • Members
  • 140 posts

Posted 05 October 2007 - 07:33 PM

Documentation has now been included. Also here is an example:
#Include ODR.ahk
#NoEnv

Gui, +LastFound
Gui, Add, Text, w100 HwndTextID, $123,456.7890
Gui, Show
ControlGetPos, x, y, w, h, , ahk_id %TextID%
text := ODR_ReadArea(x, y, w, h)
MsgBox, Read text area as: %text%


#5 BoBo¨

BoBo¨
  • Guests

Posted 05 October 2007 - 09:03 PM

Impressing. :D. My outcome:
Displayed: $123,456.7890
Detected: $ 23 45 .7830

#6 Xander

Xander
  • Members
  • 140 posts

Posted 06 October 2007 - 12:36 AM

Impressing. :D. My outcome:
Displayed: $123,456.7890
Detected: $ 23 45 .7830

You need to update to the newest version, that was what I got with the example when I first tried, but updated the mapping to support the font used in the example :wink: Though I believe the comma was read for me.

#7 Lissy

Lissy
  • Guests

Posted 10 January 2008 - 08:28 AM

Omg your a genious wow

#8 AHKisNice

AHKisNice
  • Members
  • 35 posts

Posted 25 January 2008 - 02:37 PM

Is it possible to break a youtube captcha?

#9 majkinetor

majkinetor
  • Fellows
  • 4511 posts

Posted 25 January 2008 - 03:17 PM

Interesting, but not very useful the way it is now. Just adding

Gui,  Font, s12

infront of your example, will make results wrong and changing the font size is typical operation.

#10 Guest999x

Guest999x
  • Guests

Posted 26 January 2008 - 07:20 PM

That sucks.

#11 Moki

Moki
  • Members
  • 108 posts

Posted 26 February 2008 - 08:42 PM

This might be a stupid question but how do I use this to read a simple numbered only typed captcha on a website

#12 Moki

Moki
  • Members
  • 108 posts

Posted 27 February 2008 - 01:26 PM

bump ... still interested

#13 NLI-Conquer

NLI-Conquer
  • Guests

Posted 02 March 2008 - 12:46 AM

If you really want help it might be a good idea to show a picture of what you're talking about. And explain a little more..

#14 guest007

guest007
  • Guests

Posted 14 June 2008 - 12:07 AM

Thanks for the script Xander!

I have successfully calibrated this for my project... all except one thing. My zeros and fours give the same signature. I'm trying to decipher the logic for choosing between two characters with the same sig., but am unsuccessful so far. Could you be of any service?

P.S. - It's reading Lucida Console and its not a captcha, just straight up black text on a white bg.

#15 lrh9

lrh9
  • Members
  • 102 posts

Posted 21 June 2009 - 11:27 PM

I was actually working on the same thing.

<!-- m -->http://www.autohotke... ... highlight=<!-- m -->

No dice with the ocr. It was too inaccurate and slow.

I suspect ImageSearch will be too slow as well.

The next thing I would try to do is use the dllcall readprocessmemory to obtain the information, but I don't know where in the pokerstars memory information is at.

Or you could try to reverse engineer the dlls from a preexisting poker utility that features auto reading of cards.