A dual-camera system for detecting and tracking unidentified flying objects (UFOs) using Raspberry Pi, with infrared detection and high-quality camera capabilities.
- Dual Camera System:
- Infrared-sensitive camera for motion detection
- High-quality camera for detailed captures
- Web Interface: Unified dashboard with multiple viewing modes
- Live camera streams (MJPEG)
- Image stacking for long exposure effects
- Auto-tracking mode with client-side motion detection
- Image gallery and browser
- Camera Controls: Manual camera settings adjustment (exposure, gain, brightness, contrast)
- Pan-Tilt Mechanism: Complete Waveshare HRB8825 stepper controller integration with WASD keyboard control
- Multi-viewer Support: Concurrent camera access without conflicts
- System Monitoring: Real-time status monitoring and system information
- Raspberry Pi 5 (Required - this system is optimized for Pi 5 hardware)
- 2x Camera modules:
- 1x Infrared-sensitive camera (e.g., Pi NoIR Camera)
- 1x High-quality camera module
- Waveshare stepper motor controller (for pan-tilt mechanism)
- MicroSD card (32GB+ recommended)
- Power supplies:
- 5V 5A for Raspberry Pi 5
- 12V power supply for stepper motors (separate from Pi power)
- Raspberry Pi OS (64-bit recommended for Pi 5)
- Python 3.9+ (comes with Pi OS on Pi 5)
- See
requirements.txtfor Python dependencies
-
Clone this repository:
git clone <repository-url> cd ufo-tracker
-
Run the automated setup script:
chmod +x setup.sh ./setup.sh
The setup script will:
- Install system dependencies and OpenCV requirements
- Create a Python virtual environment
- Install Python packages from requirements.txt
- Enable camera interface (on Raspberry Pi)
- Set up camera permissions
- Optionally create a systemd service
-
Install system dependencies:
sudo apt update sudo apt install python3-pip python3-venv python3-dev build-essential sudo apt install python3-picamera2 libcamera-apps libcamera-dev # Raspberry Pi only -
Create virtual environment and install dependencies:
python3 -m venv venv source venv/bin/activate pip install -r requirements.txt -
Enable camera interface (Raspberry Pi only):
sudo raspi-config # Navigate to Interface Options > Camera > Enable
-
Copy the example configuration:
cp config/config.example.py config/config.py
-
Edit
config/config.pyto match your camera setup and preferences.
-
Activate the virtual environment:
source venv/bin/activate -
Start the UFO tracker application:
./run.sh
Or manually:
python app.py
-
Open a web browser and navigate to:
http://your-raspberry-pi-ip:5000
The unified dashboard provides several viewing modes:
- Live Cameras: Real-time MJPEG streams from both cameras
- Camera Controls: Manual adjustment of camera settings (exposure, gain, brightness, contrast)
- Auto Tracking: Client-side motion detection and tracking with integrated WASD pan/tilt control
- Image Stacking: Advanced image stacking with multiple blend modes for astrophotography and motion capture
- Image Browser: Browse captured images with filtering and management
- Pan-Tilt Controls: Live keyboard control using WASD keys with fine movement support
- System Settings: Configuration and system monitoring
The UFO Tracker includes sophisticated client-side image stacking capabilities with four distinct blending modes:
๐ข Default (Average Stacking)
- Blends all frames equally using weighted averaging
- Each frame contributes
1/Nopacity where N is the number of frames - Best for: General noise reduction, creating stable composite images
- Result: Smooth, averaged image with reduced noise and background movement
๐ Long Exposure Mode
- Uses "lighten" blend mode - keeps the brightest pixel from each frame
- Simulates traditional long-exposure photography techniques
- Best for: Capturing motion trails, star trails, light streaks
- Result: Preserves bright moving objects while maintaining dark background
๐ฅ Juiced Exposure Mode
- Uses "lighter" blend mode - adds brightness from each frame (30% per frame)
- Creates artistic light painting and accumulation effects
- Recommended: Use with fewer frames (3-5) to prevent overexposure
- Best for: Light painting effects, emphasizing bright moving objects
- Result: Bright, accumulated light effects with enhanced luminosity
โพ๏ธ Infinite Exposure Mode
- True infinite stacking - locks the frame counter and continuously accumulates frames
- Uses Long Exposure technique but never stops adding new frames
- Automatic: Disables other modes and locks the stack count slider when enabled
- Best for: Extended observation sessions, capturing rare events over time
- Result: Continuously building composite with unlimited frame accumulation
Usage Tips:
- Start with Default mode for general use
- Switch between modes in real-time to see different effects
- Long Exposure works well with 10-20 frames
- Juiced Exposure is most effective with 3-8 frames
- Infinite Exposure runs continuously until manually stopped
- All modes (except Infinite) support 2-100 frame stacking ranges
The UFO Tracker features intuitive keyboard control for the pan-tilt mechanism:
๐ฎ WASD Controls
- W: Tilt camera up
- S: Tilt camera down
- A: Pan camera left
- D: Pan camera right
๐ง Control Features
- Fine Movement: Hold
Shiftwhile pressing WASD for precise control (10% of normal step size) - Auto Motor Enable: Motors automatically enable when WASD control is activated
- Multi-View Access: WASD controls available in both Live Cameras and Auto Tracking modes
- Visual Feedback: Button shows ON/OFF status with color indication
โ๏ธ Advanced Features
- Keepalive Mode: Keep motors powered during long exposures to prevent position drift
- Home Position: Return to center position with one click
- Step Size Control: Adjustable step size for different movement ranges
- Safety Limits: Hardware-enforced movement limits prevent damage
Usage:
- Navigate to Live Cameras or Auto Tracking view
- Click "โจ๏ธ WASD: OFF" button to enable keyboard control
- Use W/A/S/D keys to move the camera
- Hold Shift for fine adjustments
- Click button again to disable WASD control
If you installed the systemd service:
# Start service
sudo systemctl start ufo-tracker
# Stop service
sudo systemctl stop ufo-tracker
# Check status
sudo systemctl status ufo-tracker
# View logs
sudo journalctl -u ufo-tracker -fufo-tracker/
โโโ app.py # Main Flask application
โโโ api_service.py # API service with pan-tilt endpoints
โโโ camera_service.py # Camera streaming service
โโโ frame_service.py # Frame capture service
โโโ satellite_service.py # Satellite tracking service
โโโ timelapse_service.py # Timelapse functionality
โโโ setup.sh # Automated setup script
โโโ run.sh # Application startup script
โโโ restart-ufo-services.sh # Service restart script
โโโ requirements.txt # Python dependencies
โโโ README.md # This file
โโโ CLAUDE.md # Development guidance for Claude Code
โโโ MPU9250_SETUP.md # Motion sensor setup guide
โโโ CAMERA_FLIP_CHANGES.md # Camera orientation changes
โโโ config/
โ โโโ __init__.py
โ โโโ config.py # Configuration settings (created from example)
โ โโโ config.example.py # Example configuration template
โ โโโ compass_calibration.json # Compass calibration data
โ โโโ mpu9250_calibration.json # Motion sensor calibration
โโโ camera/
โ โโโ __init__.py
โ โโโ camera_manager.py # Camera initialization and management
โ โโโ ir_camera.py # Infrared camera handler
โ โโโ hq_camera.py # High-quality camera handler
โ โโโ streaming.py # Video streaming objects for multi-viewer support
โ โโโ auto_tuner.py # Auto-tuning for camera settings
โโโ detection/
โ โโโ __init__.py
โ โโโ motion_detector.py # Motion detection algorithms
โ โโโ object_tracker.py # Object tracking logic
โ โโโ auto_tracker.py # Auto-tracking functionality
โ โโโ image_processor.py # Image processing and stacking
โโโ hardware/
โ โโโ __init__.py
โ โโโ pan_tilt.py # Complete pan-tilt mechanism implementation
โโโ services/
โ โโโ __init__.py
โ โโโ adsb_service.py # ADSB flight tracking
โ โโโ adsb_tracker.py # ADSB data processing
โ โโโ compass_service.py # Compass functionality
โ โโโ color_generator.py # Color utilities
โ โโโ mpu9250_sensor.py # Motion sensor interface
โ โโโ trajectory_projector.py # Trajectory calculations
โโโ templates/
โ โโโ unified_dashboard.html # Main web interface
โ โโโ index.html # Alternative interface
โ โโโ viewer.html # Camera viewer page
โ โโโ frame_viewer.html # Frame viewer
โ โโโ error.html # Error page template
โโโ static/
โ โโโ css/
โ โ โโโ style.css # Web interface styling
โ โโโ js/ # Modular JavaScript files
โ โโโ core.js # Core functionality
โ โโโ navigation.js # Navigation controls
โ โโโ camera-feeds.js # Camera feed handling
โ โโโ camera-controls.js# Camera settings controls
โ โโโ pantilt-controls.js# Pan-tilt WASD controls
โ โโโ tracking.js # Motion tracking
โ โโโ feature-tracking.js# Feature-based tracking
โ โโโ trajectory-overlay.js# Trajectory visualization
โ โโโ compass-trajectory.js# Compass trajectory
โ โโโ motion-detection.js# Motion detection
โ โโโ gallery.js # Image gallery
โ โโโ stacking-optimized.js# Optimized image stacking
โ โโโ stacking.js # Image stacking
โ โโโ unified-music-engine.js# Audio system
โ โโโ mood-music.js # Background music
โ โโโ adsb-tracker.js # ADSB flight tracking
โ โโโ mpu9250-sensor.js # Motion sensor interface
โ โโโ viewer.js # Viewer functionality
โ โโโ utils.js # Utility functions
โโโ cache/ # Cache directory
โโโ detections/ # Detection images storage
โโโ logs/ # Application logs
โโโ .gitkeep
/- Main unified dashboard/viewer- Camera viewer interface/ir_feed- Infrared camera MJPEG stream/hq_feed- High-quality camera MJPEG stream/ir_frame- Single IR camera frame/hq_frame- Single HQ camera frame
/api/camera_settings/<camera_type>- Get/set camera settings/api/camera_auto_tune/<camera_type>- Auto-tune camera settings/api/capture/<camera_type>- Capture single image
/api/pantilt/status- Get pan-tilt controller status and position/api/pantilt/move_relative- Move relative to current position (WASD control)/api/pantilt/enable_motors- Enable stepper motors (turn on holding torque)/api/pantilt/disable_motors- Disable stepper motors (save power)/api/pantilt/start_keepalive- Start keepalive pulses for long exposures/api/pantilt/stop_keepalive- Stop keepalive pulses/api/pantilt/home- Home mechanism to center position/api/pan_tilt- Legacy pan-tilt status and movement commands/api/pan_tilt/motors- Legacy motor enable/disable/api/pan_tilt/keepalive- Legacy keepalive enable/disable
/api/system_status- Overall system and component status/api/test- Simple API test endpoint
The UFO Tracker system requires:
- Raspberry Pi 5's improved CPU performance for real-time motion detection
- Enhanced camera interfaces available on Pi 5
- Optimized for Pi 5's memory and processing capabilities
- Separate 12V power supply for stepper motors (do not power motors from Pi)
While some components may work on Pi 4, full functionality and performance are only guaranteed on Raspberry Pi 5.
Power Supply Warning: Never connect the 12V stepper motor power directly to the Raspberry Pi. The stepper motors require their own 12V power supply connected to the motor controller board.
- Fork the repository
- Create a feature branch
- Make your changes
- Test on Raspberry Pi 5 hardware
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
Camera Not Working
- Ensure cameras are properly connected to CSI ports
- Enable camera interface:
sudo raspi-configโ Interface Options โ Camera โ Enable - Check user is in video group:
groups $USER(should include "video") - Test camera access:
libcamera-hello(if available)
Application Won't Start
- Activate virtual environment:
source venv/bin/activate - Check Python version:
python3 --version(requires 3.9+) - Install missing dependencies:
pip install -r requirements.txt - Check logs in
logs/directory
Performance Issues
- Reduce camera resolution in
config/config.py - Close browser tabs/viewers when not needed
Stepper Motors Not Working
- Verify 12V power supply is connected to motor controller (not Pi)
- Check motor controller is properly connected to Pi GPIO pins
- Ensure motors are enabled in the web interface
- Verify wiring connections between motors and controller
- Check 12V power supply is providing adequate current
- Monitor system resources:
htopor/api/system_status - Consider using the headless OpenCV version
Network Access Issues
- Check firewall:
sudo ufw status - Verify Pi network connection:
hostname -I - Try accessing locally:
curl http://localhost:5000/api/test
For development with Claude Code, see CLAUDE.md for detailed setup instructions and architectural notes.
- Complete Waveshare HRB8825 stepper controller integration
- WASD keyboard control with fine movement support
- New API endpoints for comprehensive motor control
- Auto motor enable/disable and keepalive functionality
- Multi-view integration (Live Cameras and Auto Tracking modes)
- Removed orphaned test templates (stacked_test.html, test_stream.html)
- Streamlined template structure for better maintainability
- Motion detection: Currently disabled for performance (auto-tracking uses client-side detection)
- Timelapse features: Disabled for performance optimization
- Image stacking: Basic implementation - may need performance tuning for large images