/Playing-Card-Detector

Card Detector : Implemented by image processing, and it can be quickly implemented on other card types by taking a group of photos and marking the label.

Primary LanguagePython

Card Detector

Card Detector: Implemented by image processing

  • It can still be used even in low-light or highly reflective environments.
  • Can be quickly implemented on other card types by taking a group of photos and marking the label.

Usage

  • Take a photo of a group of cards and record the labels in the text file in sequence, from left to right in the photos.
  • You can take more than one photo and more than one text file, just put them into training_image_filename_list and training_labels_filename_list in the file card_detection.py in order.
  • The default is to take the corners of the picture to identify playing cards. If you want to identify other types of cards, you need to compare the entire card. It can be done by modifying the function preprocess in card_detection.py.
  • Execute card_detection.py, the parameter is the photo to be identified.
    python ./card_detection.py {photo path}

Method

Card Extraction

  • Use the threshold value obtained by the Otsu algorithm to do binarization to avoid adverse light effects.

Correct the card

  • Transform the slanted cards in the original image to rectangles by perspective transformation.

Take out the corner part and compare it with the labeled card

  • Using a specially designed adaptive threshold, you can see that most of the information can be retained even if the reflection is severe.
    Take out the corner part by specially designed adaptive threshold
  • Calculate the sum of the difference between the intensity value of each pixel of the labeled card and the query card. The label of the card with the smallest value difference is the recognition result.