A gesture-controlled maze game using Google's Teachable Machine for pose detection. Navigate through a maze by pointing your hand in different directions!
.
├── index.html # Main HTML file
├── maze.js # Game logic and Teachable Machine integration
├── style.css # Styling
├── tmModel/ # Teachable Machine model files
│ ├── model.json
│ ├── metadata.json
│ └── weights.bin
├── server.py # Local web server (Python)
└── README.md # This file
You MUST run a local web server to use this project. Opening index.html directly in a browser will fail due to CORS (Cross-Origin Resource Sharing) security restrictions that prevent loading local model files.
- Open Terminal/Command Prompt
- Navigate to the project folder:
cd pose-based-maze-navigation - Run the Python server:
Or if you have Python 2:
python3 server.py
python server.py
- Open your browser and go to:
http://localhost:8000/index.html
If server.py doesn't work, use Python's built-in server:
# Python 3
python3 -m http.server 8000
# Python 2
python -m SimpleHTTPServer 8000Then open: http://localhost:8000/index.html
If you have Node.js installed:
npx http-server -p 8000Then open: http://localhost:8000/index.html
If you use VS Code:
- Install the "Live Server" extension
- Right-click on
index.html - Select "Open with Live Server"
- Start the Game: Click the "Start Game" button
- Allow Webcam Access: Grant permission when your browser asks
- Make Gestures:
- Point Left to move left
- Point Right to move right
- Point Up to move up
- Point Down to move down
- Stay Neutral to stop
- Goal: Navigate the blue circle (player) to the red goal!
- Smoothing & Thresholds: Only moves when confidence ≥ 70% and prediction is stable for 3 frames
- Controlled Movement: Player moves every 400ms to prevent jittery movement
- Real-time Feedback: Continuously displays detected direction and confidence level
- Visual Feedback: Shows prediction stability status
The model was trained with 5 classes:
Neutral- No pointing gesturePointLeft- Pointing leftPointRight- Pointing rightPointUp- Pointing upPointDown- Pointing down
- Went to Teachable Machine
- Created a new Pose Project
- Trained 5 classes with multiple samples each:
- Captured various angles and lighting conditions
- Aimed for at least 100-200 samples per class
- Neutral class was trained for 145 pose samples
- PointLeft class was trained for 209 pose samples
- PointRight class was trained for 178 pose samples
- PointUp class was trained for 128 pose samples
- PointDown class was trained for 113 pose samples
- Exported the model:
- Chose "TensorFlow.js" format
- Downloaded and extracted to
tmModel/folder - Ensured files are named:
model.json,metadata.json,weights.bin
Scripts are loaded in this specific order (required):
- TensorFlow.js (CDN)
- Teachable Machine Pose library (CDN)
- maze.js (local)
- 0 = Empty space (walkable)
- 1 = Wall (blocked)
- 2 = Player start position
- 3 = Goal position
- Threshold: 0.7 (70% confidence required)
- Stability Frames: 3 consecutive frames needed
- Movement Interval: 400ms between moves
- Problem: "Access to fetch... blocked by CORS policy"
- Solution: Use a local web server (see Setup Instructions above)
- Problem: "Failed to fetch" or "Model not found"
- Solution:
- Ensure
tmModel/folder contains all three files - Check that you're using a web server (not opening file directly)
- Verify file paths in browser console
- Ensure
- Problem: Webcam doesn't start
- Solution:
- Check browser permissions for camera access
- Ensure no other application is using the webcam
- Try a different browser (Chrome recommended)
- Problem: Game doesn't respond to gestures
- Solution:
- Ensure good lighting
- Make clear, distinct pointing gestures
- Check that confidence levels are above 70%
- Verify pose is fully visible in webcam frame
- Requires Webcam: Game only works with a webcam
- Lighting Dependent: Performance varies with lighting conditions
- Gesture Recognition: May not work well with complex backgrounds
- Browser Compatibility: Best tested in Chrome/Edge (Chromium-based browsers)
- Local Server Required: Cannot run directly from file system
- Visual polish: Better maze graphics, animations, HUD
- Additional gestures: "Reset" gesture, "Pause" gesture
- Keyboard fallback: Allow arrow keys when webcam unavailable
- Multiple maze levels
- Score tracking and timer
- Sound effects
- Built with Teachable Machine
- Uses TensorFlow.js
- Pose detection powered by PoseNet