This is a template project for building Discord bots that communicate with Luxonis OAK-D cameras. Use this as a starting point to create your own smart object systems with computer vision and interactive communication.
What's Included:
- ποΈ Real-time person detection using YOLO
- π΄ Fatigue detection (eye tracking + head pose)
- π Gaze estimation (where someone is looking)
- π Whiteboard OCR reader
- π€ Discord bot with commands (!status, !detect, !screenshot)
- π’ Automatic webhook notifications
- π― Temporal smoothing for stable detection
- πΌοΈ Live camera screenshots on demand
Your instructor has pre-configured the Raspberry Pis β you can connect and start experimenting immediately! This guide shows you how to use the template, then extend it for your own creative projects.
| Camera | RAM | Configuration | Hostname | Access Method |
|---|---|---|---|---|
| Orbit | 16GB | Desktop + VNC | orbit | SSH (key-based) + VNC Viewer |
| Gravity | 16GB | Desktop + VNC | gravity | SSH (key-based) + VNC Viewer |
| Horizon | 16GB | Desktop + VNC | horizon | SSH (key-based) + VNC Viewer |
Note: All three Raspberry Pis have VNC enabled, but only one user can hold the VNC desktop seat at a time. Multiple users can SSH in simultaneously.
The GitHub repository stays on YOUR LOCAL COMPUTER. You do NOT clone it onto the Raspberry Pi.
Instead, you:
- π Clone and work with the repo on your laptop
- π€ Copy only the Python files you need to the Pi using
scp - π Create your
.envfile with Discord tokens on the Pi βΆοΈ Run the scripts on the Pi
See WORKFLOW.md for complete instructions and examples.
Note for instructors:
- If you need to set up new Pis from scratch, see INITIAL_SETUP.md
- For camera bot token reference, see CAMERA_BOT_TOKENS.md (instructor use only)
- STUDENT_QUICKSTART.md - Start here! Quick setup and common commands
- WORKFLOW.md - How to copy files from your laptop to the Pi
- CHEATSHEET.md - Quick command reference (print this!)
- Claude Code - AI coding assistant (see installation in STUDENT_QUICKSTART.md)
Prefer slides? View all documentation as slides
- Part 1: Connecting to the Pis
- Part 2: Person Detection Script
- Part 3: Auto-Start on Boot (Future)
- Part 4: Quick Reference
- WiFi Network Management - Switching between home and classroom networks
- Multi-User Access - Collaborative work on shared Pis
- Discord Integration - Webhook setup (simple, one-way)
- Discord Bot Setup - Full bot with commands (advanced, two-way)
- VS Code Remote Development - Professional development environment
- Next Steps
- INITIAL_SETUP.md - For instructors: setting up new Pis from scratch
- CHEATSHEET.md - Quick command reference (print this!)
- WORKING_VERSIONS.md - Package version compatibility
- NEXT_IDEAS.md - Project extension ideas
- EQUIPMENT_LIST.md - Hardware reference
- CLAUDE.md - For AI assistant context only
The Pis are already configured and ready to use! Here's how to connect.
On your computer:
- SSH client (built into Mac/Linux, use PowerShell on Windows)
- RealVNC Viewer (optional, for desktop Pi GUI access)
- VS Code with Remote-SSH extension (recommended - see VS Code Remote Development)
Network:
- Your computer and the Pis must be on the same network
- The Pis should power on and connect to WiFi automatically
# Connect to any of the three cameras
ssh orbit
ssh gravity
ssh horizonYour instructor has configured SSH key-based authentication with SSH config files, so you should connect automatically without entering a password!
First time connecting? You'll see a fingerprint verification prompt:
The authenticity of host 'orbit' can't be established.
ED25519 key fingerprint is SHA256:...
Are you sure you want to continue connecting (yes/no)?
Type yes and press Enter.
Troubleshooting: If you get "Host not found" or connection fails:
- Make sure the Pi is powered on and connected to the network
- Check your SSH config file (
~/.ssh/config) has the correct IP addresses - Ask your instructor for the Pi's IP address if needed
Example SSH config file (~/.ssh/config):
# Orbit - 16GB Pi
Host orbit
HostName 10.1.x.x
User your_username
IdentityFile ~/.ssh/id_ed25519_smartobjects
# Gravity - 16GB Pi
Host gravity
HostName 10.1.x.x
User your_username
IdentityFile ~/.ssh/id_ed25519_smartobjects
# Horizon - 16GB Pi
Host horizon
HostName 10.1.x.x
User your_username
IdentityFile ~/.ssh/id_ed25519_smartobjects
Note: Replace 10.1.x.x with the actual IP addresses provided by your instructor. The .local hostnames don't work reliably on this network, so use IP addresses instead.
For graphical desktop access to any of the Pis:
- Open RealVNC Viewer on your computer
- Enter the hostname:
orbit,gravity, orhorizon - Enter the username and password (ask your instructor)
- You should see the Pi desktop
Note: All three Raspberry Pis have VNC enabled, but only one user can hold the VNC desktop seat at a time. Multiple users can SSH in simultaneously.
The best way to code on the Pi is using VS Code Remote-SSH extension. See VS Code Remote Development for complete setup instructions.
Quick start:
- Install VS Code and the "Remote - SSH" extension
- macOS users: Grant VS Code "Local Network" permission (System Settings β Privacy & Security β Local Network)
- Connect:
Ctrl+Shift+Pβ "Remote-SSH: Connect to Host" βorbit(orgravity,horizon)
The person detector script is already installed on the Pis. Here's how to use it.
Once you're connected via SSH (or VS Code), navigate to the project directory:
cd ~/oak-projects
ls -laYou should see:
/opt/oak-shared/
βββ venv/ # Shared Python virtual environment (all users)
~/oak-projects/ # Your personal project directory
βββ person_detector.py # Person detection (YOLO)
βββ fatigue_detector.py # Fatigue detection (EAR + head pose)
βββ gaze_detector.py # Gaze direction estimation
βββ whiteboard_reader.py # OCR text detection
βββ discord_notifier.py # Discord webhook module
βββ discord_bot.py # Discord bot for commands
βββ discord_dm_notifier.py # Personal DM notifications
βββ utils/ # Helper modules
βββ depthai_models/ # Model YAML configurations
βββ camera_status.json # Status for bot (auto-generated)
βββ .env # Environment variables
βββ *.log # Detection logs (if --log used)
Before running any Python scripts, activate the shared virtual environment:
activate-oakYour prompt should change to show (venv):
(venv) username@orbit:~/oak-projects $
# Basic detection (console output only)
python3 person_detector.py
# With video display (requires VNC or X11)
python3 person_detector.py --display
# With file logging
python3 person_detector.py --log
# Adjust sensitivity (0.0 - 1.0, default 0.5)
python3 person_detector.py --threshold 0.7
# Combine options
python3 person_detector.py --log --threshold 0.6Stop the script with: Ctrl+C
The script uses the OAK-D camera to detect people in real-time using a neural network that runs directly on the camera's processor.
Key features:
- Detects people using YOLO v6 (from Luxonis Hub)
- Runs at ~15 FPS on the OAK-D's onboard processor
- Temporal smoothing (1.5s debounce) to prevent detection flickering
- Only logs when detection status changes (person detected β no person)
- Optional video display with bounding boxes
- Optional logging to timestamped files
- Adjustable confidence threshold
- Discord notifications (webhooks and bot support)
Package versions: See WORKING_VERSIONS.md for tested compatible versions.
To view the full script:
cat ~/oak-projects/person_detector.py
# Or open in VS Code for syntax highlightingTo modify the script:
- Make your own copy first:
cp person_detector.py person_detector_yourname.py - Edit with VS Code (recommended) or nano:
nano person_detector_yourname.py - Run your version:
python3 person_detector_yourname.py
If you ran with --log, check the logs:
# List all log files
ls -lh ~/oak-projects/*.log
# View the most recent log
tail -f ~/oak-projects/person_detection_*.log
# View specific log with line numbers
cat -n ~/oak-projects/person_detection_20260201_143052.logCurrently NOT implemented - We're still in the exploratory phase!
Right now, you need to manually run person_detector.py each time you want to use the camera. This is intentional because we're still experimenting with different features and configurations.
Once you're confident about what a camera should do permanently (for example, "Camera 1 should always detect people in the classroom entrance"), you could set it up to auto-start on boot using systemd services.
Benefits of auto-start:
- Camera begins detecting as soon as Pi powers on
- Automatically restarts if the script crashes
- Runs in background without keeping terminal open
- Useful for long-term deployments
Why we're NOT using it now:
- Still testing different detection settings
- Trying different models and thresholds
- Want flexibility to run different scripts
- Need to experiment without conflicting processes
If you eventually want a camera to auto-start, see INITIAL_SETUP.md for systemd service configuration instructions.
Basic concept:
- Create a systemd service file at
/etc/systemd/system/person-detector.service - Configure it to run your script with specific flags
- Enable it with
sudo systemctl enable person-detector - Camera will auto-start on every boot
For now, just run scripts manually when you need them!
If you need to move your Pi between different WiFi networks (home β classroom), see the complete guide:
Quick command to add a new network:
ssh orbit
sudo nmtui # Text menu to add WiFi networksMultiple students can access the same Pi simultaneously! The camera automatically announces who's using it via Discord.
Key points:
- Only one person runs
person_detector.pyat a time - Everyone can SSH in and edit code simultaneously via VS Code
- Camera auto-announces via Discord when someone starts/stops
Set up webhooks or an interactive bot to get camera alerts and control detection remotely.
π€ Discord Integration Guide
Features:
- Real-time detection alerts
- Interactive commands (!status, !screenshot, !detect)
- Multi-camera coordination
# Activate shared virtual environment
activate-oak
# Check camera connection (depthai 3.x)
python3 -c "import depthai as dai; devices = dai.Device.getAllAvailableDevices(); print(f'Found {len(devices)} camera(s)')"
# Quick camera test with device info
python3 -c "import depthai as dai; device = dai.Device(); print(f'Device: {device.getDeviceId()}')"
# Monitor system resources
htop
# View detection logs (if using --log flag)
ls -la ~/oak-projects/*.log
tail -f ~/oak-projects/person_detection_*.log| Camera | Hostname | SSH Command | VNC |
|---|---|---|---|
| Orbit | orbit | ssh orbit |
orbit |
| Gravity | gravity | ssh gravity |
gravity |
| Horizon | horizon | ssh horizon |
horizon |
Note: SSH uses key-based authentication via SSH config (no password needed if configured). All three Pis have VNC, but only one user can hold the desktop seat at a time.
/opt/oak-shared/
βββ venv/ # Shared Python virtual environment (all users)
~/oak-projects/ # Your personal project directory
βββ person_detector.py # Person detection (YOLO)
βββ fatigue_detector.py # Fatigue detection (EAR + head pose)
βββ gaze_detector.py # Gaze direction estimation
βββ whiteboard_reader.py # OCR text detection
βββ discord_notifier.py # Discord webhook module
βββ discord_bot.py # Discord bot for commands
βββ discord_dm_notifier.py # Personal DM notifications
βββ utils/ # Helper modules
βββ depthai_models/ # Model YAML configurations
βββ camera_status.json # Status for bot (auto-generated)
βββ .env # Environment variables
βββ *.log # Detection logs (if --log used)
# Check USB connection
lsusb | grep Myriad
# Should show something like:
# Bus 001 Device 002: ID 03e7:2485 Intel Movidius MyriadX
# If not found, try:
# 1. Unplug and replug the camera
# 2. Try a different USB port (use USB 3.0 blue ports)
# 3. Use a powered USB hub
# 4. Check udev rules are set up correctlyIf you're experiencing camera issues or want the latest features, update the firmware:
# Activate venv
activate-oak
# Check current version
python3 -c "import depthai as dai; device = dai.Device(); print(f'Bootloader: {device.getBootloaderVersion()}')"Note for USB OAK-D cameras: USB cameras boot from the host and typically show None for bootloader version - this is normal and expected. The depthai library manages bootloader compatibility automatically. Firmware updates are typically only needed for PoE cameras. See INITIAL_SETUP.md for detailed firmware information.
# Reapply udev rules
sudo udevadm control --reload-rules && sudo udevadm trigger
# Or add user to video group
sudo usermod -aG video $USER
# Then logout and back in# Set a resolution in config
sudo raspi-config
# Display Options β VNC Resolution β 1920x1080
# Or edit config.txt directly
sudo nano /boot/firmware/config.txt
# Add:
# hdmi_force_hotplug=1
# hdmi_group=2
# hdmi_mode=82
sudo reboot# Check memory usage
free -h
# If needed, increase swap (not usually necessary with 8-16GB)
sudo dphys-swapfile swapoff
sudo nano /etc/dphys-swapfile
# Set CONF_SWAPSIZE=2048
sudo dphys-swapfile setup
sudo dphys-swapfile swapon# Run manually to see error messages
activate-oak
python3 ~/oak-projects/person_detector.py
# If it crashes, check:
# 1. Is the camera connected? (lsusb | grep Myriad)
# 2. Is the virtual environment activated? (should see (venv) in prompt)
# 3. Are all dependencies installed?VS Code Remote SSH is the recommended way to develop on the Raspberry Pi. This gives you a professional development environment on your laptop while the code executes on the Pi.
- Full VS Code editor running on your laptop
- Files stored and code executed on the Pi
- Integrated terminal (no separate SSH window needed)
- IntelliSense, syntax highlighting, debugging
- Works great over slow WiFi
Download and install VS Code on your computer:
π https://code.visualstudio.com/download
Available for Windows, macOS, and Linux.
- Open VS Code
- Click the Extensions icon in the left sidebar (or press
Ctrl+Shift+X/Cmd+Shift+X) - Search for:
Remote - SSH - Click Install on "Remote - SSH" by Microsoft
IMPORTANT for Mac users: VS Code needs permission to access your local network.
- Open System Settings (Apple menu β System Settings)
- Go to Privacy & Security
- Scroll down and click Local Network
- Find Visual Studio Code in the list
- Toggle it ON β
If you don't see Visual Studio Code:
- Try connecting once (it will fail)
- The app will appear in the list
- Enable it and try again
This is required! Without this permission, you'll get "No route to host" errors even though terminal SSH works fine.
- Press
Ctrl+Shift+P(Windows/Linux) orCmd+Shift+P(Mac) - Type:
Remote-SSH: Connect to Host - If your SSH config is already set up, you should see
orbit,gravity, andhorizonin the list - just select one - Otherwise, click + Add New SSH Host and enter:
(or
ssh orbitgravityorhorizon) - Select your SSH config file (usually the first option)
- Click Connect in the popup
On first connect:
- Select Linux when asked about the platform
- Enter your password when prompted (if not using SSH keys)
- Wait while VS Code installs its server component on the Pi (1-2 minutes)
You'll know you're connected when the bottom-left corner shows:
>< SSH: orbit
(or gravity or horizon, depending on which you connected to)
- Click File β Open Folder (or
Ctrl+K Ctrl+O) - Navigate to
/home/[username]/oak-projects - Click OK
- Trust the folder when prompted
You should now see the project files in the Explorer sidebar.
- Go to Extensions (
Ctrl+Shift+X) - Search for:
Python - Install "Python" by Microsoft
- Open any
.pyfile - Look at the bottom status bar β click where it shows the Python version
- Select:
/opt/oak-shared/venv/bin/python
Or use Command Palette:
Ctrl+Shift+PβPython: Select Interpreter- Choose:
/opt/oak-shared/venv/bin/python
Open a terminal inside VS Code:
- Press
Ctrl+`(backtick), or - Terminal β New Terminal
The terminal is already connected to the Pi! Activate the virtual environment:
activate-oakNow you can run scripts:
python3 person_detector.py- Open a Python file
- Click the βΆ Play button in the top-right corner
- Or press
F5to run with debugging
- Right-click in the editor
- Select Run Python File in Terminal
- Click the Run and Debug icon in the sidebar (or
Ctrl+Shift+D) - Click create a launch.json file
- Select Python File
- Set breakpoints by clicking left of line numbers
- Press
F5to start debugging
| Action | Windows/Linux | Mac |
|---|---|---|
| Command Palette | Ctrl+Shift+P |
Cmd+Shift+P |
| Open Terminal | Ctrl+` |
Cmd+` |
| Open File | Ctrl+P |
Cmd+P |
| Find in Files | Ctrl+Shift+F |
Cmd+Shift+F |
| Toggle Sidebar | Ctrl+B |
Cmd+B |
| Run Code | F5 |
F5 |
| Save | Ctrl+S |
Cmd+S |
Install these on the remote (they'll install on the Pi):
| Extension | Purpose |
|---|---|
| Python | Python language support |
| Pylance | Better Python IntelliSense |
| GitLens | Git integration |
| Error Lens | Inline error highlighting |
| indent-rainbow | Visualize indentation |
If multiple people connect to the same Pi:
- Don't edit the same file simultaneously β VS Code doesn't merge changes
- Create your own branch or subfolder for experiments
- Communicate with your team!
# Create your own working copy
cd ~/oak-projects
cp person_detector.py person_detector_yourname.py
# Edit your copy
code person_detector_yourname.pyProblem: VS Code can't access local network even though terminal SSH works.
Solution: Grant VS Code Local Network permission:
- Open System Settings β Privacy & Security β Local Network
- Find Visual Studio Code and toggle it ON β
- Restart VS Code completely
- Try connecting again
This is required on macOS - VS Code needs explicit permission to access local IP addresses (192.168.x.x).
- Make sure the Pi is powered on and booted
- Check you're on the same network
- Verify your SSH config has the correct IP address for the host
- Ask your instructor if the IP address has changed
- Double-check your password
- Make sure SSH is enabled on the Pi:
sudo raspi-config # Interface Options β SSH β Enable
Remote extensions install on the Pi, not your laptop. If an extension isn't working:
- Open Extensions sidebar
- Look for the extension
- Check if it says "Install in SSH: orbit" (or gravity/horizon)
- Click to install it on the remote
Make sure you:
- Activated the venv:
activate-oak - Selected the correct interpreter in VS Code (bottom status bar)
- Use wired Ethernet if possible
- Close unnecessary VS Code extensions
- Reduce the number of open files/tabs
Once basic detection is working, you might want to explore:
-
Discord Integration β Set up webhooks or interactive bot
- See Discord Integration Guide for complete setup
- Get real-time detection alerts and control cameras with commands
-
Different models β Try other YOLO models from Luxonis Hub
- Browse models at https://models.luxonis.com
- Change model with
--modelargument - Example:
python3 person_detector.py --model luxonis/yolov8-nano:r2-coco-640x640
-
Depth integration β Get distance to detected persons
- Use
depthai-nodesspatial detection features - See DepthAI 3.x Documentation
- Use
-
Recording β Save video clips when people are detected
- Use DepthAI 3.x VideoEncoder node
- See examples in depthai-python repository
-
Web dashboard β Flask/FastAPI server to view status remotely
-
Multiple cameras β Run detection on multiple OAK-D cameras
- Coordinate them via Discord commands
- See Discord Integration Guide for multi-camera ideas
Resources for learning more:
- DepthAI 3.x Documentation: https://docs.luxonis.com/software-v3/depthai/
- depthai-nodes GitHub: https://github.com/luxonis/depthai-nodes
- Luxonis Hub Models: https://models.luxonis.com
- OAK Examples & Experiments: https://github.com/luxonis/depthai-experiments
- Tutorials: https://docs.luxonis.com/software-v3/tutorials/
- [Your name here]
- [Student names]
MIT License - Feel free to use and modify for educational purposes.