Online poker, meet optical character recognition. Optical character recognition, meet online poker. I'm sure the two of you will get along just fine.

Optical character recognition or OCR is one of those cool technologies which occupies a boring space. Document scanning is nifty and all, very useful from an office productivity standpoint, but it's not sexy. But take that same OCR component and embed it as a cog in the gearworks of an intricate real-time online poker botting rig...
That's positively porn star.
Well, whatever. The point is, repurposing a plain vanilla office productivity app for the purposes of online poker degeneracy makes us happy. So let's see what happens when we feed a piece of online poker text...

...to a typical OCR engine such as the one included with recent versions of Microsoft Word: MODI, short for Microsoft Office Document Imaging.

Only let's do it in code, because that's the way we do things 'round here! MODI can be automated over COM and of all the bajillion ways of invoking a COM object from a given language, .NET's COM Interop is one of the cleanest from a usage standpoint. So we'll add a reference (speaking in Visual Studio terms here) to the MODI type library:

And we'll hack out a few lines of C# code to a) create a new MODI document from an image and b) perform the OCR.
For this barebones proof of concept, you'll have to take a screenshot of the poker window, crop it down to the piece of text you want to OCR, store the result as a TIFF, and pass the name of that file into the Create method. I used this image:

Later, assuming you choose to use OCR in your poker bot or other real-time strategy assist, you'd want to automate this process:
A little messy, but these steps can be performed across multiple tables on commodity hardware without taxing the machine as only a small amount of text is being OCRed. If you currently do any sort of interval-based screen scraping or pixel testing, these steps can likely be factored into your existing input loop. And no, this method does not require that the poker table be visible at all times: it's possible to take a full-sized snapshot of a window which is currently minimized.
But I digress.
After running the above code, MODI will return the following text.
Dealer: downgoesdown Folds
Dealer: xactr21 bids
Dealer: Warstar raises $8 to $12
Dealer: iceoholic bIds
Dealer: rdegs2l boids
Dealer: TheYeti calls $10
Comparing that to the original text, we can see that three errors have been introduced.
Dealer: downgoesdown Folds
Dealer: xactr21 folds
Dealer: Warstar raises $8 to $12
Dealer: iceoholic folds
Dealer: rdegs2l folds
Dealer: TheYeti calls $10
MODI has mistaken the word "folds" on line 2, 4, and 5 for "bids," "bIds," and "boids," respectively. But before you start complaining about how "Microsoft software is crap" consider that you've written a whopping total of six lines of code.
Imagine what you could do with:
Ultimately, if you're serious about incorporating OCR into your poker bot or other automata, you won't use MODI at all. It's a nifty application, but for error-free OCR you'll want to take advantage of training, customization, and your complete knowledge of how text is displayed in whatever online poker application you're targeting.

In order to do that, leverage one of the many available open-source and/or commercial OCR packages. I've used tesseract-ocr, tessnet2, OCRopus, and GOCR at different times (not necessarily in an online poker botting capacity) and we haven't even touched the commercial OCR solutions, some of which are rock-solid.
I'm not recommending that you actually use OCR. That depends on your specific situation:
But I am saying that OCR is feasible and it does offer certain advantages over mechanical techniques:
The online poker user interface is really a sort of implicit CAPTCHA unto itself: easy for humans to solve, not so easy for computers. Over time this CAPTCHA has gotten progressively more sophisticated as poker sites have started employing passive countermeasures aimed at making it more difficult for external tools to interrogate the poker client application for game-related text data.
There are ways around these countermeasures, but maybe you don't want to get involved in a war of escalation. Maybe you shun that sort of bickering. Maybe you grok that one thing you can always count on is the visual interface. Or maybe, like me, you enjoy corrupting innocent office productivity applications just to be perverse.
If that's the case, give OCR a chance. You might not regret it.
UPDATE:
Those interested in the OCR approach should take a look at this fascinating 9-page discussion of real-world OCR in a poker botting context, including the pros/cons of OCR training vs. pixel testing vs. NN-based recognition at PokerAI.org. (You DO read PokerAI.org, don't you?)
60 comment(s)
I've used tesseract before although not for anything poker related-- but I have wondered whether typical OCR would be up to the online poker challenge. The small x-size of on-screen fonts taxes a lot of OCR apps which expect to be going off a fairly high DPI image, at least, that's what I've gleaned from the theory I've read.
Still interesting to see it actually done, even just in proof-of-proof-of-concept form. Thanks for the food for thought.
Anonymous on Friday, May 29, 2009There appear to be 4 errors. It has incorretly read rdegs21 as rdegs2l (replacing the 1 with an a lowercase L). But then that was not your point...
Anonymous on Friday, May 29, 2009"Marblecake also the game."
Lol. Awesome.
notmoot on Friday, May 29, 2009@Anonymous 1: That's an excellent point. In fact I tested the above sample image with tesseract and got back either gibberish or empty text. There's a note on this somewhere in the tesseract docs. However, tesseract can be trained and, if push comes to shove, you can tweak the code directly.
@Anonymous 2: Nice catch. I missed that.
James Devlin on Friday, May 29, 2009One advantage of OCR is that you can run poker in a virtual machine, with literally zero detectability (other than it may know it's in a VM)
Kevin H on Friday, May 29, 2009And even if the poker client knows it's running in a VM, it probably won't matter. VMs will become (probably already are) too widespread for the sites to declare that Thou Shalt Not Run Our Software in a VM. Windows 7 will let you peel off XP instances out of the box. A lot of people on the Mac/Linux side wouldn't be able to play at all were it not for VMs. But who knows...
James Devlin on Friday, May 29, 2009http://www.codinghorror.com/blog/archives/001258.html
James Devlin on Friday, May 29, 2009One wonders whether the online poker sites should just offer a formal API with per-developer license keys. Legit tools could go directly through the API. Poker bots would be left out in the cold but at least there'd be a formal mechanism for the 'real-time strategy assists' as you call them, that are not blocked by EULA.
Just an idea...
Ed K. on Saturday, May 30, 2009I have Microsoft 2003 and 2007 but for some reason, Microsoft Document Imaging isn't installed. Any ideas? I'd rather not go through getting tessnet up and running. Looks pretty hairy.
bot4life on Saturday, May 30, 2009Some discussion on the OCR topic: http://www.pokerai.org/pf3/viewtopic.php?f=79&t=1682
Indiana on Saturday, May 30, 2009another, bad, mistake is the name of xfactr 21, which is read to be xactr21, without the f.
Anonymous on Saturday, May 30, 2009I used to use a diy OCR via pixel reading but reading fonts is a major pain in the ass for a lot of sites due to fuzzy fonts. Someone once suggested that DirectX could be manipulated to disable all the fancy stuff but i never did find out how. Perhaps someone out there knows...
And i'm glad that Linux (and Mac) was mentioned because not everyone uses Windows. Downside is that the list of poker clients is very limited, although web browser clients are becoming more common now. I have managed to get the Entraction (Java Applet) clients to run as a native app on my Ubuntu Linux box with a simple launch script. Main reason for doing that is to enable the saving of Hand History files (which an Applet can't due to security restrictions). The script and source code can be downloaded from my website: http://bespokebots.com/linux.php.
birchy on Saturday, May 30, 2009@Indiana: Thanks for the link to that excellent discussion. I've updated the post to include it.
@birchy: So true. DirectX can be manipulated via hooking if nothing else, but most of the sites are using plain vanilla GDI. On the Windows side of things anyhow. Either that or they're using pixel/bitmap fonts and they have some custom logic to blit those to the screen (still, via the GDI). Both ways present problems. If they use formal text-output APIs, the font's appearance can and will vary slightly. But those APIs can be hooked. On the other hand if they draw text by blitting an [i]image[/i] of text, then you can't necessarily hook a public API and extract the text. But in that case the fonts are static/unchanging, making a pixel-test DIY OCR more feasible.
James Devlin on Sunday, May 31, 2009But James I think your point was correct, and it seems indicated in the pokerai discussion as well, that if you train a robust OCR to a specific font, you can get a 100% success rate. The question is whether that's less work than doing a pixel-test method.
Anonymous on Sunday, May 31, 2009I'm going to have to call bullshit on this one. Nobody is actually going to use some godforsaken "pixel-test" method to read text. If they can't get the text directly from whatever window displays it, then it's easy: they can't run a bot.
Period.
Remember, the people who build poker bots aren't qualified software developers. They're Internet script-kiddies trying to get rich quick.
Guido on Monday, June 01, 2009???
Anonymous on Monday, June 01, 2009I only see one pile of bullshit here: [quote="Guido on 6/1/2009 4:16:12 AM"]I'm going to have to call bullshit on this one. Nobody is actually going to use some godforsaken "pixel-test" method to read text. If they can't get the text directly from whatever window displays it, then it's easy: they can't run a bot.
Period.
Remember, the people who build poker bots aren't qualified software developers. They're Internet script-kiddies trying to get rich quick.[/quote]
Although screen scraping is a last resort tactic, it DOES work. Most of the commercial odds calculators and live advisors use screen scraping methods. Even well known names like Winholdem, OpenHoldem and Calculatem use screen scraping. Most so-called "script kiddies" are able to create working bots. If they are as unprofessional as you claim, then a flood of highly predictable bots can only be good for the rest of us...
birchy on Monday, June 01, 2009@Guido: Have to agree with @birchy here.
Online poker botters, far from being "script kiddies", are some of the most tenacious and creative developers you'll ever meet. If corporate code was developed with the same level of just sheer outright...[i]obsession[/i]...I think a lot more companies would achieve profitability.
And OCR (including DIY pixel-testing) is more common than you think among the poker botting crowd. The "script kiddy" metaphor breaks down when it comes to online poker, because of the rewards involved.
James Devlin on Monday, June 01, 2009Has anybody published source code for a simple pixel-testing method? I don't want to OCR, I just want to look at the individual pixels. I've seen this mentioned various places but there's usually not source code to go with it.
Any ideas?
Anonymous on Monday, June 01, 2009You mentioned getting a snapshot of a minimised window. Got a link on how that's done? Currently I'm using SwitchToThisWindow and waiting for it to come to the front, which takes an unacceptable amount of time. Thanks.
stalewee on Tuesday, June 02, 2009Theres an article on capturing a minimized window here: http://www.codeproject.com/KB/cs/CapturingMinimizedWindow.aspx?display=Print I dont know how good/fast it is though, havent needed to try it.
JB on Tuesday, June 02, 2009Anonymous: If you just want a simple pixel-testing method, you could just use a 32-bit CRC checksum of the pixel, window square, et.c, that you wish to test for. You would have to map each card to its own CRC checksum (precomputed) value. This is not the most robust way of doing it because a CRC will not tolerate a single bit change in the pixels that you check, i.e. it is an exact testing method. If only one color is changed (compared to the image you computed the checksum from in the first place) in the pixel window you are testing for, you will most likely end up with a completely different checksum value.
Check google for the CRC checksum algorithm, there should be source samples out there...
Frode Nesbakken on Tuesday, June 02, 2009stalewee, there are many other ways which you can do that.
Have a look at experts-exchange.com
Poker Bot on Tuesday, June 02, 2009Frode - errr. or you could just get a DC, and use GetPixel.
I test a single pixel to get card rank (2 color tests, one each for black and red), and one for card suite (again one color test for black and red), on AP - But that's probably just the way the anti-aliasing worked out in my favor.
Slightly off topic, since this is an 0ptical chanacter recogrition post. Fortunately for me AP does run drawtext to put text to screen, and the chatbox is pretty much a standard RTF text box. AP isn't gungho-psycho about demolishing third party software development - which is why I won't touch PS. If they change to something more complicated/tricky, me and my little poker calculator are probably shit-outta-luck T_T
aw on Tuesday, June 02, 2009@stalewee:
There are various ways to do this (snapshot a minimized window). You can Google for most of these. The most interesting is probably [url=http://www.fengyuan.com/article/wmprint.html]Feng Yuan's method of BeginPaint hooking[/url] but it's a little out of date. Stay tuned for some code/examples re: how to do this cleanly.
@aw:
I agree and I think Poker Stars has actually gone a little overboard. They've made various updates which have alienated builders of "legitimate" tools even while failing to prohibit poker botters.
Of course, [url=http://www.guardian.co.uk/technology/2009/feb/26/robots-poker]poker botting is neither illegal nor unethical nor cheating[/url], and even if it were, prohibition still wouldn't really work.
James Devlin on Wednesday, June 03, 2009Fascinating stuff James.
@ Guido. I think your response is a fairly poorly developed one. Creating bots for anything is highly technical and that goes for poker bots too. It doesn't just involve a few spotty kids trying to earn some money, there's some really great computer science involved here.
Poker Forum on Wednesday, June 03, 2009Ultimately you could stick a camera in front of the screen and interpret the video image, generate mouse movements and key presses electronically. I remember seeing a project where a guy had a tetris playing bot using these techniques. Let them try and detect that..........
FT_Anon_But_Not_For_Long on Wednesday, June 03, 2009You really don't think it's unethical to use bots or artificial intelligence to make calculated decisions against other poker and casino depositors?
When the local casinos in Vegas allow me to sit my robot down against the humans at live games then I will agree with you.
Ukash Casino Deposit on Friday, June 05, 2009@Ukash: No more unethical than, say, trying to harvest affiliate revenue by commenting on a poker-botting blog with a link to your affiliate site. Poker bots don't have any information beyond what a normal player would have. If poker bots were hacking the servers or colluding, that would be one thing, but a bot that has to go off the same information given to the human player? That's not cheating. It might be against Terms of Service, but it's far from cheating.
James Devlin on Friday, June 05, 2009Great articles, James! I have question for you. Did you make onboard cards recognition on Poker Stars? I made simple recognition by capturing and recognizing card images from window, and it works like shit.
w_fg on Sunday, June 07, 2009aw - I meant calculating the CRC of all the pixels in a fixed size window area the cards are displayed (only the upper left corner that displays As, 2h and so on.) I don't think I was making my self very clear on that point. I do agree however, that this is a very naive approach, but if the client doesnt change the card bitmaps, it should work.
Frode Nesbakken on Friday, June 19, 2009Hey, what is the name of OCR program used on a first picture? And is it detectable?
tom on Wednesday, July 01, 2009Nice article. I'll have to look into it. I currently capture the whole screen and hash screen regions against stored images to get the current table state.
Anonymous on Sunday, October 04, 2009in my opinion there is a problem using OCRs: how to know, the new OCR scan, if the chat lines was pre-existent or not?
True line: Dealer: Johnny34 folds
First OCR: Dealer: Jobnny34 folds Second OCR: Dealer: Johnni34 folds
If I compare the two rows for my code them are different... I register a fold that in real play there is not....
ezio on Tuesday, November 10, 2009I have developed the same thing but not using windows ocr but faster way by just comparing letters to its match (all fields are same font). If anyone is interested mail me semmimuzespsat(at)email.cz - I have c# code and it could work in real time with added evaluations and statistics.
something similar on Tuesday, March 23, 2010I have developed the same thing but not using windows ocr but faster way by just comparing letters to its match (all fields are same font). If anyone is interested mail me semmimuzespsat(at)email.cz - I have c# code and it could work in real time with added evaluations and statistics.
something similar on Tuesday, March 23, 2010nice article. keep post like this...
Fendi replica watches on Tuesday, July 20, 2010Your post is really informative for me. I liked it very much. Keep sharing such important posts..
U-Boat replica watches on Saturday, July 24, 2010PerformingGraham for sale that will create a one-wayswiss watches backlink to your website whichMaurice Lacroix watches is a good point to have. It is Patek Philippe watchesa time-consuming Tag Heuer for saleprocess even though it produces good outcomes U-boat for saleand works. You can also swiss watchespost comments on blogs alongMaurice Lacroix watches together with your link, but make sureGraham watches these blogs are do-follow, which dolce & gabbana handbagsindicates the link that youreplica coach handbags simply post will probably be replica handbagscounted by the search engines jimmy choo replicaas a backlink.There are many thingsversace replica handbags that contribute to online businessjuicy couture replica failure, and the lack of good action thomas wyldeis surely one of the deadliest business-killersdolce gabbana handbags on the net. Take action like by no means chloe handbags replicaprior to, and don’t get struck by analysis paralysisburberry replica. Your achievement lies in your rapid actionchanel replica and how well you apply numerous strategies.
replica watches on Saturday, July 24, 2010nike air jordan 2010 nike air jordan 5 nike air jordan 3 nike air jordan 11 cheap nike air jordan 2 nike air jordan 1 nike air jordan shoes discount nike air jordan shoes nike air jordan 6 wholesale nike air jordan 1 discount nike air jordan 6 nike air jordan 7 nike air jordan 8 top quality nike air jordan shoes 23 nike air jordan 21 nike air jordan 22 nike air jordan 6 rings cheap nike air jordan 22 nike air lebron james shoes nike air lebron james shoes nike air jordan 2010 nike air joredan lebron james nike air jordan 2009 discount nike air jordan 2009 nike lebron james wholesale nike air jordan 2010 cheap nike air jordan 2009 discount nike air jordan 19 cheap nike air jordan 3 discount nike air jordan 18 brand nike air jordan 12 wholesale nike air jordan 2 nike air jordan 13 nike air jordan 14 nike air jordan 6 rings discount jordan shoes7 discount jordan shoes1 jordan shoes2010 jordan shoes 6 rings cheap jordan shoes2 discountjordan shoes3 discount jordan shoes4 jordan shoes uk23 jordan shoes classic bw22 cheap jordan shoes 21 ltd discount jordan shoes20 discountjordan shoes19 jordan shoes 18 uk nike air jordan shoes 17 cheap nike air jordan shoes 16 discount air jordan shoes 15 discount air jordan shoes 14 nike air jordan shoes 3 uk nike air jordan shoes 13 cheap nike air jordan shoes 11 discount air jordan shoes 6 discount jordan shoes 10 nike air jordan shoes 8 nike air jordan shoes 7 cheap louis vuitton bags cheap kobe bryant shoes cheap lebron james shoes .
cheapjordan on Saturday, July 24, 2010I will keep visiting this blog very often. Blu ray ripper /
ipad converter on Sunday, July 25, 2010coach outlet coach outlet online coach outlet store coach bags on sale coach factory outlet coach handbags This article is written by zocy002 on 2010-7-26 on New Coach Handbags
coach outlet on Monday, July 26, 2010The variety links of london items bearing depends on the occasion. You are plain, but you are elegant. links of London sweetie braceletIf presence a groove, especially nightfall outfit, you are allowed to be very gentle in truth. What you should do is to links of london charms choose some delicate sweetie bracelets with your subtle sensation of fashion on Christmas Day, Easter, Halloween and Valentines Day. Discovering links of London friendship bracelet on the net is an excellent choice for your needs and can also assure you may benefit from the best insurance coverage at the best price tag. The links of London braceletis one kind of those brands that basically level the start a time honored design and style and design untreated. links of london necklace and links of london earringswill be the consultant of level and higher personal taste; so many people contain the hopes for donning links of London sweetie bracelets. Nevertheless, in the large price, so most of us cannot pay the big money. links of London friendship bracelets charm bracelets links of london sale charm bracelet silver friendship bracelets links of london charm bracelet
links of london on Monday, July 26, 2010ed hardy, cheap ed hardy, ed hardy clothing, ed hardy outlet, ed hardy jeans, ed hardy bags, ed hardy swimwear, ed hardy shirts, ed hardy tee, ed hardy caps, ed hardy purse, ed hardy board shorts, ed hardy shoes, ed hardy for men, ed hardy for women, ed hardy jeans for women.
cheap ed hardy on Tuesday, July 27, 2010ed hardy, cheap ed hardy, ed hardy clothing, ed hardy outlet, ed hardy jeans, ed hardy bags, ed hardy swimwear, ed hardy shirts, ed hardy tee, ed hardy caps, ed hardy purse, ed hardy board shorts, ed hardy shoes, ed hardy for men, ed hardy for women, ed hardy jeans for women.
cheap ed hardy on Tuesday, July 27, 2010The Best Louis vuitton Millionaire Replica Sunglasses The best inspired version of the Louis vuitton store to date! The 'Millionaire Luxe' features
High Quality Louis vuitton wallets, Louis vuitton Replica wallets lowest price. Wholesale price 35% - 75% off.3-7 Day Louis vuitton damier shipping, Free shipping now.
Just how do you tell a best Louis vuitton online store from the real thing? ... getting the perfect back-to-school outfit, we've got you covered with the best tips.
louisvuitton4 on Thursday, July 29, 2010Best Deals From Louis Vuitton Purses Collection Guranteed !! Louis Vuitton - I would have to admit that at first I wasn't
really sure how to pronounce ...
Topreplicashop retail and wholesale Louis Vuitton outlet, Key Chains, Cufflinks,
Accessories, ...
Louis Vuitton is no more a luxury if you find www.sale4louisvuitton.com, the best online source of top quality mirror image
wallets.html" tItlE="Louis Vuitton wallets">Louis Vuitton wallets, ...
louis vuitton on Thursday, July 29, 2010Share your knowledge to continue a timeless tradition;
DVD Ripper on Friday, July 30, 2010Life will change what you are but not who you are;
Blu-ray Ripper on Friday, July 30, 2010Marry a person who likes talking; because when you get old, you’ll find that chatting to be a great advantage
blu-ray ripper on Friday, July 30, 2010Live a noble and honest life. Reviving past times in your old age will help you to enjoy your life again;
DVD Ripper on Friday, July 30, 2010I like your article. Will always support you!He is quite a good reading. i'd appreciate it. time to realize his.
DVD Ripper on Friday, July 30, 2010In your article I found very different things. Very characteristic. I've never seen before.Thank you very much the share. you are very creative.
DVD to iPod on Friday, July 30, 2010Your article is very appealing to me.I like this article, this article that i learned a lot of knowledge.
Video Converter on Friday, July 30, 2010You have a unique perspective.Thank you for sharing. it is wonderful super classic. I admire you.
DVD Cloner on Friday, July 30, 2010Pool Temperature Madera Jobs Madera Pest Control Madera Dentist Merced Dentist Visalia Dentist Modesto Dentist Fresno Limousine Fresno Granite briefcases leather leather briefcases prospect solution | prospect solutions | prospectsolution | prospectsolutions | prospectsolution.com prospect solution | prospect solutions | prospectsolution | prospectsolutions | prospectsolution.com prospect solution | prospect solutions | prospectsolution | prospectsolutions | prospectsolution.com
carmi on Friday, July 30, 2010Choosing the right tiffany jewelry accessory will turn an ordinary outfit into a fashion statement before you buy it from one mall or others, you can budget from our mall; christian louboutin as being beautiful and making us feel sexy Italian research has shown that a good pair of heels can help tone the body, condition muscles and improve the wearer's sex life, buy it please click the link; Look for ed hardy clothing, just click the link and you will have a great surprise; Finding beautiful cartier jewelry as gifts, we provide different styles for your reference; Choose the different links of london jewellery from our site, enjoy free and fast shopping worldwide; If you plan on shopping for NFL jerseys, you can purchase nfl jerseys online at our mall. We will do our best to serve for you. Welcome you!
tiffany jewelry on Friday, July 30, 2010essay essay writing essay writing service essay writing service uk
jane on Friday, July 30, 2010Replica miu miu handbags are not just beautiful and elegant, but it is also at excellent quality and similar design as the real. You will like it once you see it. Now attention please, at our shop, we are holding a promotion. You can buy replica miu miu bags of high quality with the lowest price. Meanwhile, miu miu handbags buying from here you can enjoy free and fast delivery shipping. Welcome to our shop!
miu miu bags on Friday, July 30, 2010Want to get Ed hardy at home? No hesitation, get them at with big discount. We are promise you that all the ed hardy clothing are good in qualities. Meanwhile, buying ed hardy clothing online, that’s never a bad idea. By the way, whenever and wherever you need us, we will be there for you. Ed Hardy T-Shirts are waiting for you now, welcome you!
ed hardy on Friday, July 30, 2010