Black Jack Folks: AI Dealer Robot for Elderly Companionship Howest CTAI

by Hugo Gómez-Cornejo Sorgato in Circuits > Assistive Tech

62 Views, 0 Favorites, 0 Comments

Black Jack Folks: AI Dealer Robot for Elderly Companionship Howest CTAI

BlackJackFolks.jpg

"Loneliness is a silent struggle for many seniors. Sometimes, all they need is a friendly face—or in this case, a friendly robot—to play a simple game of cards with them."

This project is Black Jack Folks, an interactive, AI-powered robot dealer built specifically for elderly users. It uses a Raspberry Pi, a camera, and a custom-trained YOLOv26 Nano model to detect physical playing cards in real-time. A large LCD screen guides the player step-by-step, and 3 buttons control the entire game (Hit / Stand / Help).

I built this robot to combat loneliness through a familiar game, but I learned a lot about product design along the way. The first prototype had issues: the camera was blocked when pressing the button, the 3D-printed shell was too fragile, and I wasted time training 52 separate card classes.

In this updated version, I fixed all of that. The button is moved to the side, the camera is elevated, the enclosure is rock-solid, and the AI logic is simplified to only care about card values (not suits), making it faster and more robust.

Let's build your own Black Jack Folks!

Supplies

Screenshot 2026-08-26 233100.png

Before starting, gather all the hardware. Below is a clear list of what you need. Check the BOM Excel for exact prices and links.

Electronics & Hardware:

Raspberry Pi 5

Webcam

i2c 16x2 LCD

PLA wire

RGB LED

Push Button

Jumper Wires

5V Power Supply

Designing the 3D Enclosure

5784973133130436477_120.jpg
5784973133130436478_120.jpg
5784973133130436479_120.jpg
5784973133130436480_121.jpg
5784973133130436482_121.jpg
5784973133130436486_121.jpg
5784973133130436490_121.jpg
5784973133130436491_120.jpg
5784973133130436492_121.jpg
5784973133130436493_120.jpg
5784973133130436495_121.jpg

The first version of my enclosure was too fragile and the camera was placed behind the button—users accidentally covered the lens while playing.

For this version, I redesigned everything in Siemens NX:

  1. Elevated Camera Mount: The lens is positioned higher and further forward.
  2. Buttons: The buttons are moved to the front side, so you never block the camera while pressing it.
  3. Cable Channels: Built-in grooves keep the internal wiring organized and protected.

Download the STL files here: [BlackJackFolks_STL_Files.zip] (Attach your files).

Hardware Assembly and Wiring

5787521079529116034_121.jpg
5787521079529116035_121.jpg

Now, mount the electronics. Keep the wiring clean to prevent short circuits.

GPIO Pin Mapping (Raspberry Pi 40-pin header):


Component GPIO Pin Notes


Connect ALL grounds together


(Insert Photo 4: Clear photo of the wiring inside the enclosure before closing it, showing cable ties and soldering)

(Insert Photo 5: The fully assembled robot from the front)

Software Setup

I used Python 3.9+. The project runs inside a Docker container for easy deployment, with a PostgreSQL database for storing game history.

1. Clone the Repository:

Open a terminal on your Raspberry Pi and run:

bash

git clone https://github.com/yourusername/black-jack-folks.git
cd black-jack-folks

2. Install Dependencies:

bash

pip install -r requirements.txt

3. Run Docker Compose (for the Database & Gradio App):

bash

docker-compose up -d

This sets up the PostgreSQL database with persistent volumes, meaning your data stays safe even after a reboot.

4. Launch the Game:

bash

python main.py

You should see the LCD light up with "WELCOME FELLA!".

(Insert Photo 6: Screenshot of the terminal running the script)

The AI Model

Screenshot 2026-08-26 232219.png

I initially trained a model with 52 classes (each card and suit). This was a mistake—Blackjack only cares about the value! So, I trained a YOLOv26 Nano model on 5,200 images (100 per class) but wrote a simple Python function to map the 52 detected suits into just 13 values (A, 2-10, J, Q, K).

  1. Framework: PyTorch (.pt file). Note: I used PyTorch, not TensorFlow.
  2. Accuracy: ~80% mAP@0.5. While this is slightly below cutting-edge, it works perfectly for this real-world application because of my next trick: the IoU tracker.

The IoU Tracker (The "Anti-Flicker" System):

When the camera detects a card, the robot saves its exact location (bounding box). If the user's hand passes over the card, the AI might get confused. I calculate the Intersection over Union (IoU) between new detections and confirmed cards. If a new detection overlaps more than 50% with a confirmed card, I ignore it. This stops the system from "flipping out" when cards are partially covered.


The Game Flow

The game runs on a very simple 10-state machine. Because this is for seniors, there are no timers—the player clicks the button to advance when they are ready.

The flow:

  1. Welcome -> Click to play.
  2. Place Cards -> User puts 2 cards down, clicks.
  3. Verify -> Robot shows the total. (Click = OK, Double-Click = Wrong -> sends you back to re-arrange).
  4. Decision -> Click On + symbol is "Hit" (Draw another), Click on = symbol is "Stand" (End turn).
  5. Robot's Turn -> Robot uses its AI to draw cards (with occasional silly mistakes to be friendly).
  6. Result -> Shows who won. Click for Menu, or click for Re-match.

The Gradio App & PostgreSQL Database

The robot is connected to a web interface (Gradio) so family members can check in.

The 4 Gradio Pages:

  1. About: Explains the project's mission.
  2. Operating: Shows the live camera feed and manual override buttons.
  3. Visualization: Charts showing win rates and match history pulled from Postgres.
  4. Debugging: Logs for technical troubleshooting.

Database Structure:

  1. Sessions: Tracks date/time and total rounds.
  2. Hands: Stores player hand, dealer hand, and result (Win/Loss/Push).

Final Results & Lessons Learned

5787437632609521720_121.jpg

The Final Product:

Black Jack Folks is now robust, user-friendly, and genuinely fun. The button doesn't block the camera, the 3D print doesn't break when you pick it up, and the AI smoothly ignores hand obstructions.

What I Learned :

Don't overcomplicate your AI (52 classes is overkill). The physical design (enclosure & camera placement) is just as important as the code. And always test the button placement before printing the final shell!

AI Use Disclosure

I used AI (specifically, a large language model) to assist me in structuring this Instructables guide, optimizing grammar, and brainstorming the step-by-step narrative. The actual hardware assembly, model training, debugging, and final engineering decisions are entirely my own.