Sign in to follow this  
yelmu

Card recognition in Poker Clients like Party Poker?

Recommended Posts

So what could be easy method to automatically identify what cards are dealt in poker client? That information would then be used with Poker odds calculator. Maybe some kind of screen capture and then analyzing what cards were dealt? Or some API calls? Using VS 6.0 c++.

Share this post


Link to post
Share on other sites
Not that I ever did anything like this *cough*, but doing a screen capture/pixel compare works pretty well (so long as you make sure that the window doesn't have anything over it when you take the shot - which is trickier than it sounds). Given that the cards are dealt in the same screen coordinates with the same images (ignoring, if you will, any window-resizing/scaling features), you should be able to get away with looking at about 8-16 pixels per card to determine uniqueness. I highly suggest making a four-color deck a requirement - it makes it that much easier.

But if they happen to do any text-based realtime logging (to disk or to a window), you can nab it from that as well, and it'd be easier than screenscraping. Most clients don't do that, though. Also, if you're really hardcore, most programs build up their logs that they write to disk in memory. I don't remember the APIs off-hand, but you could get the text right out of their heap. That's a pain, though - screen scraping is easier :)

Share this post


Link to post
Share on other sites
Use templating.

Basically take a screenshot of every card in the deck and store these in memory.

Then check each card in your database against each card shown on screen (doing pixel compares). This is more difficult if the cards are not always in the same place - but I assume this is not the case.

I would try this first. If it doesn't work for you (this is a fragile method that will break if the card's appearences change) - you are going to have to write a classifier (the 2nd easiest approach to this problem). A machine vision text will help, or I would recommend Russel and Norvig's AI book. By "2nd easiest" I did not mean "easy". But if you wrote a killer poker bot, this will be cake for you :-)

Share this post


Link to post
Share on other sites
Note that most of these clients have on-disk bitmaps of each of the cards (often a set for 2 color and a set for 4 color)

Some of these clients actualy make runtime changes to the brightness of the bitmaps in order to highlight card(s) so you may want to detect cards when they are heighlighted as well (for instance, to 'see' the winning hand) .. which is why I went with my final solution:

1) Define a boolean pixel test, whiteish(pixel), which returns if the pixel is or is not approximately gray/white.

2) Choose 32 random locations from the upper left corner of the cards

3) For each card, produce a 32-bit identifier using those 32 randomized locations passing the pixels through the boolean whiteish()

4) If the identifiers are not all unqiue, go back to step 2 and try again

From there its just a matter of hard-coding the client locations of each card location as they would be rendered. Hold'em would have 25 card locations for 10 handed tables (50 locations if you want to identify cards that have been 'pushed up')


I do it this way because I like the fact that the card ID's are 32-bit, so they can be passed around and compared efficiently. The problem can be reduced to 6-bit identifiers in the ideal case, but the removal of redundancy is a drawback causing false positives when the client isnt topmost. Redundancy is a good thing in pattern matching.

In my experience, it only takes a few passes through 2-4 before finding a good set of locations (infact, I believe in the case of partypoker it only takes a single pass with my default random seed)

Also, the algorithm doesnt care if the user is using 2 color or 4 color decks.

- Rockoon (Joseph Koss)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this