View all Blog | Developers | News

Python Tutorial: Detect Suits in Playing Cards

Landing AI
June 06, 2023

Landing AI offers code samples in our software development kit (SDK) to help you learn how to effectively deploy computer vision Models you’ve built in LandingLens.

This tutorial explains how to use the Python Detect Suits in Poker Cards sample in the SDK to run an application that detects suits in playing cards. In this tutorial, you will use a web camera to take images of playing cards for suit recognition. An Object Detection Model developed in LandingLens (and hosted by Landing AI) will then run inference on your images.

This example is run in a Jupyter Notebook, but you can use any application that is compatible with Jupyter Notebooks.


  • Python (install for free here)
  • Jupyter Notebook (install for free here)
  • Playing cards
  • Webcam

Step 1: Clone the Repository

Clone the Landing AI Python repository from GitHub to your computer. This will allow you to later open the webcam-collab-notebook Jupyter Notebook, which is in the repository.

To clone the repository, run the following command:


    git clone


You can use other methods to clone repositories. For more information, check out the GitHub documentation.

Step 2: Open the Jupyter Notebook

Open Jupyter Notebook by running this command in your terminal:


    Jupiter notebook


In Jupyter Notebook, open the landingai-python repository you cloned.Navigate to and open this file:

Jupyter Notebook File for the Example

The notebook opens in a new tab or window.

Opened Example File

Step 3: Start Running the Application

The notebook consists of a series of code cells. Run each code cell, one at a time.
An asterisk (*) displays in the pair of brackets next to a code cell while that code executes. When the code has run, the asterisk disappears.
Not too familiar with Jupyter Notebook? To run a code cell, click the Run button in the toolbar, or press Shift+Enter. You need to do this for each cell!

Step 4: Take a Photo with Your Webcam

When you run the Acquire Image from Camera code cell, the application turns on your webcam. Hold a playing card up to the webcam and press Spacebar to take a photo.
Your webcam turns off, and the image displays below the code cell.

Your Photo Displays Below the Code Cell

Don’t like the photo? You can replace it by running the Acquire Image from Camera code cell again.


Step 5: Run the Model and See the Predictions

Continue running the code cells.

Running the Run the Object Detection Model on LandingLens Cloud code cell initiates the Model in LandingLens to run inference on your image.

Then, when you run the Visualize Results code cell, an image displays below the cell. This is your original image, with the predictions from the LandingLens Model overlaid on top. The prediction includes the bounding box, the name (Class) of the object detected, and the Confidence Score of the prediction.

For example, in the screenshot below, the Model identified that the card has several Diamonds.

The Model Detected the Suits in the Image

Step 6: Count How Many Objects Were Detected

Run the next code cell, which is Process Results to Count the Number of Suits. When you run this code, the application counts how many objects were detected that had a confidence score higher than 50%. The count displays below the code cell.

For example, in the screenshot below, the application counted four Diamonds that met the threshold criteria.

The App Detected Four Objects (Suits)

Step 7: Make Your Own Application

Congrats! You have now successfully run a LandingLens Model and made predictions! You can now customize the code cells to create your own application!

Landing AI Monthly Newsletter

Stay updated with AI news and resources delivered to your box

Related Resources