Detecting playing cards by separating each card in the image

7 visualizzazioni (ultimi 30 giorni)

I am working on a project that detects playing cards in a poker game. I will have three cards on the table and i have to separate each card and save them as a separate image so that i can do template matching or SIFT on them. Can anyone tell me how to do this? All i have done till now is threshold the image, use sobel edge detector on the thresholded image, dilate the image and apply hough transform to the image.

Risposta accettata

Image Analyst
Image Analyst il 24 Set 2016
Modificato: Image Analyst il 24 Set 2016
Please show the original image.
If the background behind the cards is a different color than the cards, like black background and white cards, then you can simply threshold, call imfill, and label then use ismember to create a mask for each card.
backgroundMask = ....... % Do color segmentation.
allCardsMask = imfill(~backgroundMask, 'holes');
% Extract only the 3 largest blobs
allCardsMask = bwareafilt(allCardsMask, 3);
labeledImage = bwlabel(allCardsMask);
cardMask1 = ismember(allCardsMask, 1);
cardMask2 = ismember(allCardsMask, 2);
cardMask3 = ismember(allCardsMask, 3);
Your edge detection method could have a lot of problems if your edges are not completely connected, like in the upper right corner of your card on the right.
To identify the cards, you might use SIFT but a simpler way might be to simply count the number of colored pixels on each card in each color channel. It could be that every card has a unique count for R, G, and B. Then you could simply look up that number in a lookup table that you've filled up in advance with the "official" counts for each card. This would probably be far simpler than SIFT or SURF.

Più risposte (0)

Categorie

Scopri di più su Card games in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by