Skip to content

Blackjack Card Counting with YOLOv8. A computer vision system that uses a custom trained YOLOv8 model to detect playing cards in real time and track their count for blackjack strategy

Notifications You must be signed in to change notification settings

tomalmog/CV-CardCounting

Repository files navigation

Real-Time Blackjack Card Counter

A computer vision system that detects and classifies playing cards in real time to count cards in blackjack using the Hi-Lo counting system. This project combines deep learning object detection with sophisticated tracking algorithms to replicate what professional card counters do mentally.

Demo

Watch the System in Action

Watch the system in action here Youtube Video Demo

Training Results

The model was trained using Google Colab's GPU resources with multiple iterations across different datasets and augmentations to achieve robust performance in various conditions.

Validation Performance Metrics Validation Metrics Graph

Training Loss Progress Training Loss Graph

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. The system requires a webcam for real time card detection and classification.

Prerequisites

What things you need to install the software and how to install them

Python 3.8 or higher
Webcam or video capture device
CUDA-capable GPU (recommended for optimal performance)

The core dependencies include:

ultralytics>=8.0.0
opencv-python>=4.5.0
numpy>=1.21.0

Installing

A step by step series of examples that tell you how to get a development environment running

Clone the repository to your local machine

git clone https://github.com/tomalmog/CV-CardCounting.git
cd CV-CardCounting

Install the required Python packages

pip install ultralytics opencv-python numpy

The trained model (model.pt) is included in the repository and located in the main directory alongside the Python files - no additional setup required.

Test the installation by running the main script

python main.py

You should see a window open showing your camera feed with card detection capabilities. Press ESC to exit.

Built With

  • Ultralytics YOLOv8 - Object detection framework
  • OpenCV - Computer vision and image processing
  • NumPy - Mathematical operations and array processing
  • PyTorch - Deep learning framework (via Ultralytics)
  • Google Colab - GPU training environment

Author

Disclaimer: This project is for educational and research purposes only. It demonstrates computer vision and machine learning techniques applied to object detection and tracking. The system is not intended for actual casino use.

About

Blackjack Card Counting with YOLOv8. A computer vision system that uses a custom trained YOLOv8 model to detect playing cards in real time and track their count for blackjack strategy

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages