Skip to content Skip to sidebar Skip to footer

Ocr Playing Cards

I decided to do a project for fun where I want to take as input the image of a playing card and return its rank and suit. I figure that I only need look at the upper-left corner, s

Solution 1:

I don't think there's something already written for what you are trying to accomplish (at least open source and in Python).

As for your second question, it depends on what you are trying to recognize. If the inputs can come from different sources -- e.g., different brands of playing cards with distinctive styles --, then you should probably use a machine learning-based algorithm (such as neural network or support vector machine [SVM]), in order to let it learn how to recognize unknown inputs. However, if the input is always the same in shape or style, then a simple image comparison algorithm will suffice (e.g., compare the pixels of the sliced upper-left corner with the pixels of each rank).

If you do decide to use a machine learning-based algorithm, I also think you don't need very complex features, as the suits and ranks don't really vary that much in shape or style, and you should be fine with using just the pixels of the upper left corner as features.

There's a toy OCR example here that you may find interesting. The lib that is used (LibSVM) also has a Python version, which I have used, and found very simple to work with.

Hope it helps.

Solution 2:

Personally I would go the machine learning route with this one.

Solution 3:

Given the limited sample size (4 suits, 13 different values) I'd just try to match a reference image of the suit and value with a new input image. First find the bounding box of the incoming suit / value (the smallest box enclosing all non-white pixels), scale your reference pictures to match the size of that bounding box, and find the best "match" through pixel-wise absolute difference. The colour of the picture (i.e. red or black) will make this even easier.

Solution 4:

It's not as robust, but you can look at the colours of 3 or 4 locations on the card so that if they are white or if they are a color, you can determine which card and suit it is. Obviously this won't work if you don't always have the same cards.

Post a Comment for "Ocr Playing Cards"