A comprehensive monitoring and safety system for archaeologists working in challenging environments like caves. ArchGuard provides real-time telemetry monitoring, hazard detection, live video streaming, and AI-powered object detection from a centralized command center dashboard.
ArchGuard is a full-stack application designed to monitor teams of archaeologists equipped with smart helmets featuring IMU sensors. The system provides:
- Real-time Telemetry Monitoring: Track accelerometer and gyroscope data from field workers
- Hazard Detection: Automatic alerts for falls, abnormal vibration, poor posture, and inactivity
- Live Video Streaming: Receive video feeds from Raspberry Pi-based helmet cameras
- Local AI Detection: Run YOLO26X object detection on the command center for real-time scene analysis
- Multi-language Support: English and Russian interfaces included
- User Management: Manage and bind archaeologist devices to the system
- Framework: React with Three.js for 3D visualization
- UI Library: Lucide React for icons
- Features:
- Real-time telemetry display (orientation, acceleration, rotation)
- Live camera stream viewer
- Hazard alert feed
- User management panel
- YOLO detector toggle and status
- Time tracking for in-cave operations
- Multilingual interface (EN, RU)
- Framework: Flask with CORS support
- I2C Integration: Reads telemetry from MPU6050/6500 IMU sensors on Raspberry Pi
- Features:
- Sensor data acquisition at 160 Hz
- Advanced sensor fusion (complementary filtering)
- Hazard detection algorithms (impact, inactivity, posture)
- Low-latency MJPEG/WebRTC camera streaming
- USB camera device probing and auto-detection
- Zeroconf mDNS service registration
- Framework: Flask with YOLOv8/YOLOv26X support
- GPU Support: Apple Silicon (MPS), CUDA, and CPU modes
- Features:
- Low-latency object detection pipeline
- Configurable inference interval and confidence threshold
- JPEG stream output from annotated frames
- Multi-source URL support (falls back gracefully)
- Warm-up frame validation
- Continuous frame capture from camera source
- Python 3.8+ (for backend services)
- Node.js/npm (for frontend development, if needed)
- Hardware:
- Raspberry Pi (for sensor acquisition and camera streaming)
- IMU sensor (MPU6050 or MPU6500)
- USB camera or CSI camera module
- Command center computer with GPU (optional but recommended)
-
Install Python dependencies:
pip install flask flask-cors smbus2 zeroconf opencv-python ultralytics torch
-
Mac-specific setup (for YOLO local service):
# PyTorch with MPS support for Apple Silicon pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu -
Verify YOLO model: Ensure
yolo26x.ptoryolo26x.mlpackageis in the project directory
Currently, the frontend runs via inline Babel in index.html. For development:
- Ensure a modern web browser supporting ES6 modules
- Serve the project on a local web server:
python -m http.server 8000
Run this on the Raspberry Pi or your sensor-connected device:
python archguard.py
# Listens on http://localhost:5000
# Exposes /video (MJPEG stream), /status (telemetry JSON), and other endpointsRun this on your command center computer:
python yolo.py
# Listens on http://localhost:8001
# Endpoints: /yolo/toggle, /yolo/video, /yolo/status- Open
index.htmlin a web browser or serve it via HTTP - Connect to the Raspberry Pi IP address or use
arch-helmet.localif Zeroconf is configured - Monitor real-time telemetry, video streams, and hazard alerts
PORT: Flask server port (default: 5000)I2C_SENSOR_ADDRESSES: I2C addresses for IMU sensors (default: [0x68, 0x69])USB_CAMERA_INDEXES: USB camera device indexes to probe (default: [0, 1, 2, 3])IMPACT_G_THRESHOLD: G-force threshold for fall detection (default: 2.5)STATIONARY_TIME: Time in seconds for inactivity detection (default: 5.0)SENSOR_LOOP_HZ: Sensor acquisition frequency (default: 160 Hz)
YOLO_LOCAL_PORT: Service port (default: 8001)YOLO_CONFIDENCE: Detection confidence threshold (default: 0.35)YOLO_INFERENCE_INTERVAL_S: Inference frequency in seconds (default: 0.0 = continuous)YOLO_DEVICE: Device for inference - "mps" (Apple Silicon), "cuda" (NVIDIA), or "" (CPU)YOLO_MODEL_PATH: Custom path to YOLO model fileYOLO_STREAM_JPEG_QUALITY: JPEG compression quality (default: 75)ARCHGUARD_STREAM_URL: Custom telemetry service URL (falls back to defaults)
- GET /status: Current telemetry state (orientation, acceleration, gyro, hazards)
- GET /video: MJPEG video stream from helmet camera
- POST /users: Add or manage users
- GET /health: Service health check
- POST /yolo/toggle: Enable/disable local AI detection
- GET /yolo/video: JPEG stream with annotated detections
- GET /yolo/status: Service status and detection statistics
- GET /yolo/detections: Latest detection results (JSON)
The system monitors for the following hazards:
- Impact/Fall Detection: Triggered when acceleration exceeds
IMPACT_G_THRESHOLD(2.5G default) - Inactivity Detection: Triggered after
STATIONARY_TIMEseconds of minimal motion - Abnormal Vibration: Detected via high-frequency gyroscope variance
- Poor Posture: Detected through accelerometer pitch/roll deviations
- System Hazards: Custom AI-detected hazards from YOLO
- Sensor Acquisition: Multi-threaded capture at 160 Hz with complementary filtering
- YOLO Inference: Continuous frame capture with inference on the latest frame only
- Video Streaming: Separate threads for capture, annotation, and MJPEG encoding
- Sensor Fusion: Complementary filter merges accelerometer and gyroscope for stable orientation
- Graceful Fallbacks: Multiple camera device candidates and streaming URL options
- Sanitization: Telemetry payloads are validated before state updates to prevent crashes
- Multi-device Support: User management system supports binding multiple helmet devices
- Modular Architecture: Services communicate via HTTP, allowing distributed deployment
- Configurable Inference: YOLO inference interval and confidence can be tuned for performance
- Probe connected USB cameras:
ls -la /dev/video* - Check device permissions (may need
sudoorusermod) - Verify camera is not in use by another process
- List I2C devices:
i2cdetect -y 1 # Use 0 for older Pi models - Verify sensor connections and address (SDA/SCL pins)
- Check I2C is enabled in Raspberry Pi settings
- Verify
yolo26x.ptexists in the project directory - Check PyTorch installation for your device type (MPS, CUDA, or CPU)
- Review environment variable overrides
- Verify
archguard.pyis running and accessible at the configured URL - Check browser console for CORS errors
- Ensure firewall allows connections on ports 5000 and 8001
- Telemetry Payloads: Always sanitize
orientation,accel,gyro, andhazardsfields to handle partial updates - App.jsx not Currently Used: The runtime source is the inline Babel-compiled JSX in
index.html - Camera Auto-Recovery: Camera initialization includes warm-up frame validation and automatic reinit on read failure
- Model Format Support: YOLO supports both
.pt(PyTorch) and.mlpackage(CoreML) formats
[Add license information here]
[Add contributors here]