Hanafuda are traditional japanese playing cards that are used to play a number of games. There are twelve suits, representing months (with four cards of every suit). Each month is designated by a different flower. There are two common and two special cards (with additional design) in every suit. Usually one of the special cards is designed with red or blue ribbon. Every card in pack is unique.
Example of cards representing January:
Program is written in Python 3.5.0.
OpenCV library was used for image processing.
Decision tree from scikit-learn was used as card classifier.
As input program receives photo of single card. First of all, function
(colorful_count, masks) = find_colour_count(image, file_name)
is called. This function retrieves colours (white, red and blue) from card pictures creating three masks. It also returns number of coloured pixels in every mask.
Example of card image and sequentially blue, red and white mask.
Next, function
(hu_moments_for_all_colours) = compute_hu_moments(image, file_name)
is called. This function computes seven Hu moments for every colour mask. As a result it returns array of three arrays with seven image moments.
Farther, all of the computed information and fact of owning ribbon are given to decision tree as training data.
As input program receives photo of cards. Application separates every card from picture using dilation and edge detection.
Then program scales and turns them so they will be ready for image processing.
Than function
( _ , rebbons_colour) = findRibbon(image, file_name)
is called.
This project focused on image processing, not machine learning. For this reason decision tree has't got more training cards than one of every type (in sum, 48 cards) so results was halfway correct.
Example result is presented below. On the left side are card images cut out from original image. On the right side of every founded card are cards assigned by classifier.
INPUT:
OUTPUT: