A real-time Gollum detection system with both image upload and live webcam detection modes.
- Image Upload Mode: Upload images to detect if Gollum is present
- Live Detection Mode: Real-time webcam detection with live video streaming
- LED Integration: Controls Raspberry Pi LEDs based on detection results
- Red LED: Gollum detected
- Green LED: No Gollum detected
- WebSocket Updates: Real-time detection notifications
- Frontend: React + Vite (port 5174)
- Backend: Flask + Roboflow InferencePipeline (port 5001)
- LED Server: Raspberry Pi Flask server (port 5000)
GollumApp/
├── backend/ # Python Flask backend
│ ├── server.py # Main server with detection pipeline
│ ├── train_yolo.py # Local YOLOv8/v11 training script
│ └── requirements.txt # Python dependencies
├── gollum-detector/ # React frontend
│ ├── src/
│ │ ├── App.jsx # Main application component
│ │ └── App.css # Styles
│ └── package.json # Node dependencies
├── raspberry-pi/ # Raspberry Pi LED control
│ ├── api.py # Flask API for LED control
│ ├── program.py # Button-controlled LED demo
│ ├── requirements.txt # Pi Python dependencies
│ ├── led-api.service # Systemd service file
│ └── README.md # Pi setup instructions
└── README.md # This file
cd backend
# Create virtual environment
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
cd gollum-detector
# Install dependencies
npm install
The Raspberry Pi controls the physical LEDs that indicate detection status. See the raspberry-pi/ directory for:
- Complete setup instructions
- Hardware wiring diagram
- Code to run on the Pi
- Systemd service for auto-start
Quick Setup:
Make sure your Raspberry Pi LED server is running on 10.0.0.106:5000 with these endpoints:
POST /led/red/onPOST /led/red/offPOST /led/green/onPOST /led/green/off
See raspberry-pi/README.md for detailed setup instructions.
You need to run both the backend and frontend servers:
cd backend
source venv/bin/activate
python server.py
Backend will start on http://localhost:5001
cd gollum-detector
npm run dev
Frontend will start on http://localhost:5174
Navigate to http://localhost:5174
- Click "Image Upload" button (default mode)
- Drag & drop an image or click "Choose File"
- Click "Detect Gollum"
- View results and LED indicators
- Click "Live Detection" button
- Click "Start Camera" to activate your webcam
- Watch live video feed with real-time Gollum detection
- LEDs update automatically based on detections
- Click "Stop Camera" when done
- Image uploaded → Both LEDs turn OFF
- Detection starts → Both LEDs turn OFF
- Detection complete:
- Gollum found → Red LED ON, "GOLLUM FOUND" displayed
- No Gollum → Green LED ON, "gollum not found" displayed
- Camera starts → Both LEDs turn OFF
- Continuous detection:
- Gollum appears → Red LED ON, "GOLLUM FOUND" displayed
- Gollum leaves → Green LED ON, "gollum not found" displayed
- Camera stops → Both LEDs turn OFF
POST /start_camera- Start webcam and detection pipelinePOST /stop_camera- Stop webcam and detectionGET /status- Get current camera statusGET /video_feed- MJPEG video stream- WebSocket
/socket.io- Real-time detection events
Client receives:
connected- Connection establisheddetection- Detection result{gollum_found: boolean, timestamp: number}
Backend (server.py):
- Roboflow API Key:
g3kyzU8K82YQwalVS2Ks - Workspace:
die-counter - Workflow:
gollum-finder-2 - Camera: Device 0 (built-in webcam)
- Max FPS: 30
- Confidence: 0.95
LED Server:
- Address:
10.0.0.106:5000
- Make sure no other application is using your webcam
- Check that the backend server is running
- Verify Python dependencies are installed
- Ensure Raspberry Pi is accessible at
10.0.0.106:5000 - Check that the LED server is running on the Pi
- Verify network connectivity
- Make sure backend is running on port 5001
- Check browser console for errors
- Try refreshing the page
- Verify both frontend and backend are running
- Check that ports 5001 and 5174 are not blocked by firewall
Python (Backend):
- Python 3.8+
- Flask
- Roboflow Inference SDK
- OpenCV
- Socket.IO
Node.js (Frontend):
- Node.js 16+
- React 18
- Vite
- Socket.IO Client
Hardware:
- Webcam (built-in or USB)
- Raspberry Pi with LED setup (optional)
This project uses Roboflow's inference API for object detection.