Forging Player Card Detection and Recognition program with AForge.Net
- Posted: Oct 26, 2011 at 6:00 AM
- 12,080 Views
Today's project struck me as one that's pretty unique. It's doing something that I don't think I seen done before, let alone where its source was released and explained in such detail.
Facial recognition seems to be all the rage. What if you want to recognize something else, say playing cards? For example, you want to an augmented reality game where real world cards are used, where based on the played card something cool happened (like the Jack animated, looked around, etc)? Or maybe you want to add some zest and automation to your weekly poker game? Or you want to create you own Cribbage Reality show (Everyone is doing poker... lol).
How would you build something like that? Taking a color image from a cam and figuring out what card it is?
Here's one way...
Playing card recognition systems can be coupled with a robotic system which acts like a dealer or a human player in a card game, such as blackjack. Implementing this kind of application is also good example for learning computer vision and pattern recognition.
This article involves binarization,edge detection , affine transformation , blob processing, and template matching algorithms which are implemented in AForge .NET Framework.
Note that , this article and this system is based on Anglo-American card decks , it may not work for other card decks. However, this article describes basic methods for detection and recognition of cards. Therefore, recognition algorithm might be changed according to features of the deck that is used.
We need to detect card objects on image so that we can proceed recognition. For detection we apply some image filters on image for helping detection.
First step , we apply grayscaling on image. Grayscaling is a process that converting a colored image to 8 bit image. We need to convert colored image to grayscale image so that we can apply binarization on image.
After we convert colored image to grayscale image, we apply binarization on image. Binarization( thresholding ) is the process that converting a grayscale image to black & white image. In this article, Otsu’s Method is used for global thresholding.
There are several techniques for recognition. Recognition in this system is based on features of deck cards (such as shapes on cards) and also contains template matching. Suit and rank of card are recognized separately. We have enumeration for suits and ranks as following.
Rank recognition is similar to suit recognition. We recognize face cards and non-face cards separately. Because, non-face cards can be recognized by counting suit blobs on card image , no template matching required , simple image filters will do the job. This makes recognition process simple for non-face cards. Unlike , template matching ,it doesn’t take too much processing time.
This implementation , as it is, only recognizes playing cards that are separated each other. Another know issue is that, bad light conditions may lead wrong recognitions.
Most of image routines used in this article, are based on AForge.NET framework. AForge.NET is really cool framework , that provides plenty of features for developers who works in fields of computer vision and machine learning. It is also very easy to use.
This work can be improved such as, recognizing cards even when are not separated. Another improvement could be using this system by an AI BlackJack player.
If you're interested in play card games, augmented reality, detection and recognition then this project is just a download a away