Skip to content

JinTheLin/Magic-Yahoos

Repository files navigation

Magic-Yahoos (Phygital Drawing → G-code)

This project tracks a hand/LED gesture in real time, snaps the path to a grid, and converts it into pen-safe G-code for a Marlin-based printer (Ender 3 Pro).

Requirements

  • Python 3.9+
  • OpenCV + NumPy

Install:

python3 -m pip install opencv-python numpy

Quick Start (Live Tracking → G-code)

python3 -u phase1_led_tracking.py

If the wrong camera opens, pick one:

python3 -u phase1_led_tracking.py --camera-index 0

Controls:

  • r replay + export G-code
  • c clear drawing and keep recording
  • b reset background model
  • q quit

Outputs (saved in project folder):

  • tracking_grid.csv
  • tracking_vectors.csv
  • drawing.gcode
  • drawing.txt

Test Shape (Circle)

Generate a clean circle for testing:

python3 circle_to_gcode.py --center-x 110 --center-y 110 --radius 40 --segments 120

If you want to center the path around (0,0) using G92:

python3 circle_to_gcode.py --center-x 110 --center-y 110 --radius 40 --segments 120 --g92-center

OctoPrint Upload (USB to Ender 3 Pro)

Set your OctoPrint URL and API key (URL should be the base, no /api or /#/):

export OCTO_URL="http://octopi.local"
export OCTO_API_KEY="YOUR_API_KEY"

Upload the live drawing automatically after replay:

python3 -u phase1_led_tracking.py

Upload a test circle to OctoPrint:

python3 scripts/upload_circle_to_octoprint.py --start --open-ui

Mini-Game (Camera 2 Guess After Print)

Use a second camera to capture the finished drawing and ask Gemini to guess it.

Set your Gemini API key:

export GEMINI_API_KEY="YOUR_GEMINI_API_KEY"

Wait for the current print to finish, capture one image from camera 1, and open a result page:

python3 scripts/guess_after_print.py --camera-index 1 --open-ui

If you want to capture immediately (no OctoPrint wait), add --no-wait.

Full Flow (Draw → Print → Guess)

This runs the drawing app and waits for the print to finish before guessing with camera 2:

export OCTO_URL="http://localhost:5001"
export OCTO_API_KEY="YOUR_OCTO_KEY"
export GEMINI_API_KEY="YOUR_GEMINI_KEY"

GAME_CAM_INDEX=1 OPEN_UI=1 ./scripts/draw_then_guess.sh

If you need to force the drawing camera in the full flow:

DRAW_CAM_INDEX=0 GAME_CAM_INDEX=1 OPEN_UI=1 ./scripts/draw_then_guess.sh

If OctoPrint isn't reporting a print state (so the guess never triggers), you can bypass the wait:

REQUIRE_PRINTING=0 DRAW_CAM_INDEX=0 GAME_CAM_INDEX=1 OPEN_UI=1 ./scripts/draw_then_guess.sh

Notes

  • Bed size defaults to 220×220 mm (Ender 3 Pro).
  • The generated path is pen-safe (Z up/down, no extrusion).

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors