The Casino Cam (CTAI Howest)

by roelremmerie in Circuits > Raspberry Pi

16 Views, 0 Favorites, 0 Comments

The Casino Cam (CTAI Howest)

IMG_20250620_021917.jpg

Do you like card games? Does AI or Internet Of Things peak your interests? If you answered yes to any of these questions you came to the right place.

The Casino Cam is a table where you and your friends can play the famous Catalan - French card game of Manilla. A phone camera records your game and at the end of each round you don't have to count your points, the table does it for you! In this Instructable I will explain how you can make the table and run the game.

If you are not familiar with the game of Manilla, you can learn more here.

Supplies

IMG_20250619_192701.jpg
IMG_20250619_192830.jpg
IMG_20250618_095531.jpg

Tools you need for building the table

  1. Roll of duct tape
  2. Large ruler (100 cm)
  3. Box cutter
  4. As much cardboard as one can find. (Check with stores if they have some cardboard to spare)

Electroncis

  1. smartphone (android operating system)
  2. pc or laptop
  3. raspberry pi
  4. USB-c power
  5. ethernet cable
  6. lcd display
  7. 4 small cables to connect the lcd display to the raspberry pi

Create the Table

IMG_20250619_231133.jpg
IMG_20250619_231240.jpg
IMG_20250619_231411.jpg
IMG_20250619_231156.jpg
IMG_20250619_231118.jpg
IMG_20250619_231311.jpg
IMG_20250619_231458.jpg
IMG_20250619_231534.jpg
IMG_20250619_231603.jpg
IMG_20250619_231631.jpg
Raspberry-Pi-5-Pinout--1210x642.jpg
IMG_20250619_231810.jpg
IMG_20250619_231850.jpg
IMG_20250619_231915.jpg
IMG_20250619_231711.jpg

Before we get started:

  1. cm stands for centimeters.
  2. Use a ruler to cut straight with your box cutter.
  3. Images are placed in chronological order. Use them to follow allong with the steps.


  1. Pillars
  2. Take two longer pieces of cardboard hat have an edge that can fold in the middle.
  3. Cut out two longer pieces of equal height (+-80cm) and 15 cm width.
  4. Cut out 5cm by 3cm holes at 70cm height on each pillar.
  5. Table base
  6. Stack multiple layers of cardboard carefully together at 4cm of height.
  7. Cut out an 80cm by 80cm square (like a cake).
  8. Use tape to your hearts content to hold it all together.
  9. Cut out 2 holes at opposite corners (2cm deep) that can hold the pillars upright. These holes should be 2cm away from the edge and the same thickness as the pillars
  10. Table edge
  11. Stack three layers of carboard edges (8cm width) resembling the outline of a square (80cm by 80cm outside / 64cm by 64cm inside)
  12. Use tape to hold it together.
  13. Cut out identical holes for the pillars as on the table base. Make sure they line up.
  14. Phone camera housing
  15. Fold a piece of cardboard 4 times.
  16. Cut out a hole for the camera.
  17. Use a simple line of tape to secure the housing.
  18. Beam
  19. Use cardboard residue edges (5cm width) and stack them together to form a 120cm by 5cm by 3cm beam.
  20. Wrap tape around to hold it together.
  21. Make sure it's strudy enough.
  22. Felt
  23. Cut out a 75cm by 75cm square from your green felt.
  24. Cardboard assembly
  25. Place the felt in the center of the table base.
  26. Place the table edge on top of the table base and felt.
  27. Slide the pillars into the holes of the table edge and table base.
  28. Slide the beam through the phone camera housing.
  29. Slide the beam with phone camera housing through the holes made in the pillars.
  30. raspberry pi assembly
  31. carefully inspect your raspberry pi and lcd display pins.
  32. We will be using pin numbers 3, 4, 5, 6 on the raspberry pi.
  33. We will be using pin numbers 3, 2, 4, 1 on the lcd display. (yes that is strange number order well noticed by you.)
  34. Use the 4 small wires to connect the pins from the raspberry pi to the lcd display. Use the strange lcd pin order (8c.) to properly connect the wires to the corresponding pi pins (8b.). Make sure you get this right to not fry your pi or lcd.
  35. Full assembly: slip the lcd under the table edge.
  36. (BONUS) Disassembly: slide all the loose parts out of eachother. Easy peasy.

Raspberry Pi Code

Follow each step carefully on your raspberry pi.


Install python 3.11 on your raspberry pi

Create a directory named casino-cam in your home directory on the raspberry pi with the following structure

casino-cam/
app.py
requirements.txt
services.py

Make sure your working directory is the casino-cam directory. Use vscode ctrl+shift+P to activate the command pallette. Search for "Python: Create Environment" then follow the steps to create .venv virtual environment based on the requirements.txt file. Check out this link for more information.

Your directory now looks like this

casino-cam/
.venv/
app.py
requirements.txt
services.py


go to your home directory and create the following file: casinocam.service


[Unit]
Description=The Casino Cam
After=network.target

[Service]
WorkingDirectory=/<home-directory>/casino-cam
ExecStart=/<home-directory>/casino-cam/.venv/bin/fastapi run app.py
StandardOutput=inherit
StandardError=inherit
Restart=always
User=student
CPUSchedulingPolicy=rr
CPUSchedulingPriority=99
Environment="PATH=/<home-directory>/casino-cam/.venv/bin:/usr/bin:/bin"

[Install]
WantedBy=multi-user.target


Now execute the following commands

Copy This File to /etc/systemd/system as Root User

sudo cp casinocam.service /etc/systemd/system/casinocam.service


Test the File by Starting It

sudo systemctl start casinocam.service


Stop the Service

sudo systemctl stop casinocam.service


Enable the Script to Start Automatically After Booting

sudo systemctl enable casinocam.service


Now reboot your Pi

sudo reboot now

Set Up Droidcam

droidcam.jpg
250620_02h57m25s_screenshot.png
  1. Download droidcam client from dev47apps on your pc or laptop.
  2. Download droidcam from the google play store on your smartphone.
  3. Open droidcam on your smartphone and droidcam client on your pc.
  4. Find the browser ip cam access port on your phone and fill in the phone ip and port in on the droidcam client.
  5. Press connect (your phone is now registered as a webcam)

PC Code

Follow each step carefully on your pc or laptop.

Due to Instructables' constraints I cannot upload my trained model weights. Please contact me if you wish to use them.


Create the following folder structure

casino-cam-game/
ai_models/
symbol_weights.pt
value_weights.pt
data/
symbol.json
value.json
game_logic/
game_states.py
manager.py
models/
cards.py
predictions.py
services/
predict.py
rpi.py

app.py
requirements.txt


Change line 16 to match the ip address your lcd is now displaying.

rpi_service = RPIService("172.0.0.1") #change to the displayed ip


Make sure your working directory is the casino-cam-game directory. Use vscode ctrl+shift+P to activate the command pallette. Search for "Python: Create Environment" then follow the steps to create .venv virtual environment based on the requirements.txt file. Check out this link for more information.


Open your terminal in the casino-cam-game directory and execute the following commands.

Activate the virtual environment

source .venv/bin/activate


Run the app using gradio

gradio app.py


now navigate to http://localhost:7860 and enjoy the game!