Sign in to follow this  

pattern recognition - ocr

This topic is 4382 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I am trying to find an open source ocr library for c#. I am trying to find a way to take a screen shot of whatever is on the monitor and extract numbers, letters and playing card suits. Programming something like this is way over my head so a third party module is needed. Any info on where i can find something like this would be greatly appreciated. Thanks :)

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Hmmm. Are you using this for a card game?

Are the cards always the same?
Are the numbers/letters always in the same font?
Are these pictures of actual cards or graphics?

From,
Nice coder

Share this post


Link to post
Share on other sites
I made a program that extracted the cards from the screen for PartyPoker.
When done I realized that PP saved every event in a log file and parsing the log file was far easier, it was also better since the PP window didn't need to be on top any more.

I wouldn't recommend you to go for the OCR route unless you really have to.
It's going to be almost impossible to get 100% correct results, if you can live with some errors then it might be an option.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Ah you people are trying to scam poker sites? Well I am always amused by a good scam, so I'll just say: OCR is not necessary. The same deck of cards will be used every time, will it not? That means you can simply extract unique patterns from each card, and then do a simple memory search in the screenshot for the patters.

Share this post


Link to post
Share on other sites
yeah OCR is way to much for such a 'simple' task, you should be fine with a 'simple' MSE (mean square error), MAD (mean absolute difference) or NCC(normalized cross correlation), it becomes much easier if you know the location of your cards, then just calulate for examble a MAD and if its smaller some val you specify you found your match...


T2k

Share this post


Link to post
Share on other sites
Thanks all,

Just thought i'd point out that this isn't a scam or cheating, simply calculating statistics automatically which all online players can do in their own ways.

Secondly, not sure what you meant by searching for patterns in memory, is this not what ocr is anyway? Or pretty similar.

As far as i know, calculatem and winholdem programs use ocr. The reason for this is so it can be used for over 100 poker clients. If you just read a log file for each client, you would have to code heaps of stuff and logs change now and again so updating all those would be a pain. Also not sure about that MAD stuff either.

Anyway, just downloaded your software Paul, i'll try it out tonight when i get home. This is similar in what i am trying to do but it is for a comp sci project so my math wont be very useful for players. Am more interested in how you get the software to recognize the poker client and how to read the hole and community cards.

Any help with this would be greatly appreciated.

Thanks :)

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by one mind
Secondly, not sure what you meant by searching for patterns in memory, is this not what ocr is anyway? Or pretty similar.


No, OCR isn't really pattern matching. It's way more advanced than that - it's a branch of pattern recognition, which is a branch of AI.

Share this post


Link to post
Share on other sites
As people have already sudgested :), It comes down to pretty much just taking the images and comparing them to images. Basicaly I have a nice big vector of checksums for each of the image pieces, and locations of where to read them.

BTW, as for why calculatum and such work on so many sites is simply the fact that there arnt as many sites as you would immagine. Many, and i do mean MOST use one of a few different software packages, and are just "SKINS"

Share this post


Link to post
Share on other sites
Cool, thanks Paul.

Just tried out your program, it works great :)

You wouldn't be able to give me a hint at how the program recognizes when the client window is open would you :D

Is it just windows system programming stuff or have you got another trick up your sleeve?

Thanks again :)

Share this post


Link to post
Share on other sites
Quote:
As people have already sudgested :), It comes down to pretty much just taking the images and comparing them to images. Basicaly I have a nice big vector of checksums for each of the image pieces, and locations of where to read them

This is more less what I did, I actually read all cards etc from the installed poker software, thus if the user reskinned the game it would still work.
Getting the names is a bit harder since the font is scaled depending on the string lengths. Initially I read all names and actions from the log window (copied the text to the clipboard and read from there).

A heads up is that you need some logic to filter out events like when a card is animating across the board etc, cards "dissapear" from your app when this happens, I minor issue but something to be aware of.

My main concern about reading the screen is that the application must be fully visible at all times, if not you can't get any valid data from the app.
That's why I switched to using the log files instead. There are some information missing in the logs however (at least what PartyPoker uses), so you need to be pretty smart and "guess" some things.



Share this post


Link to post
Share on other sites
Thanks Eq,

When you say you read the cards directly from the client, do you mean you took a screen shot of the client into memory and extracted info from there? Or some other way?

In the end, is it just about finding a way to take numbers and symbols from a static bitmap or is there another way to get info from apps that are running?

Thanks again

Share this post


Link to post
Share on other sites
If i wanted to read the cards from a poker game, i would probably access directly in the memory... Your hand would probably be at a fixed offset in memory, so you can directly read the process' memory and be done with it..

If it's not, then i would hook the function receiving the cards or the one displaying them.

Those solutions would require far less code, and would give 100% corect results.

just my 2 cents :)

PS : IDA for the win.

Share this post


Link to post
Share on other sites
Quote:
When you say you read the cards directly from the client, do you mean you took a screen shot of the client into memory and extracted info from there

I read the images stored in "C:\Program Files\PartyPoker\Images" :)
Simple as that!
I still think this is the "wrong" was of doing it, it was alot of pain to get it working and the biggest problem with it is that if the window is obscured in ANY way, you will not get any valid data from the app.
If it's indeed for recording poker data, you could use the logs produced (simplest if available) or "hack" the network packets or read from the process memory.

Share this post


Link to post
Share on other sites
I dug up some old .exe of my test-app.
It's "decoding" party-poker plays, currently the partypoker client must be installed at "C:\Program Files\PartyPoker" (default).
It probably need a P4 to run (compiled with IntelCPP with a p4 target).
As I mentioned above I abandonned the idea of using screen shots and now I'm parsing the log files produced instead.

Disclaimer: I've not written any poker bots, cheats, players or such.
My work was for a company that broadcasts (delayed) online poker games on TV and internet.
I've wrote a 3D real time replayer using partypoker for demonstration purposes only.
After some testing we realized that there was no way to get the fast pacing online play to look good in 3d (except having the camera more or less fixed on top of the table).
Still dunno if we're going to give it another shot, are quite busty atm.

Share this post


Link to post
Share on other sites
It's not tested on machines / setups besides my own.
it doesn't do much, grabs the cards that are visible as well as showing a zoomed up portion of the screen around the cursor.
It also grabs the data in the log window and displays that.

Share this post


Link to post
Share on other sites
Turned out that the player name (which was needed) was hardcoded.
Don't ask me why I need the player name, don't remember ;)

If you download the new version (same link), then executes it from the command line (or better create a short cut) using this syntax.
PartyPoker.exe [playerName] <PartyPokerInstallPath>
Ex: PartyPoker.exe BigBadBluff "C:\Program Files\PartyPoker\"
If PartyPokerInstallPath is omitted "C:\Program Files\PartyPoker\" is used.

* Playername is case sensitive, path must end with an trailing back slash.

Share this post


Link to post
Share on other sites

This topic is 4382 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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