This is a real-time drowsiness and impact detection system designed for drivers using a Raspberry Pi 4. It leverages computer vision, accelerometer data, and GPS location tracking to prevent accidents by alerting drivers and notifying emergency contacts through SMS.
- 👁️ Drowsiness Detection using eye blink ratio and head pose estimation via MediaPipe + OpenCV
- 🌍 Real-time GPS tracking with BN-220 module
- 📲 Emergency SMS Alerts using Twilio API
- 📟 Live Status Display via 16x2 LCD
- 💥 Impact Detection using MPU6050 accelerometer
- 🧲 Button-triggered Execution from LCD display
Component | Description |
---|---|
Raspberry Pi 4 Model B | Core processing unit for the system |
Raspberry Pi Night Cam | Night-vision camera for facial detection |
BN-220 GPS Module | Tracks live location |
MPU6050 Accelerometer | Detects sudden impacts |
I2C LCD 16x2 Display | Displays system status and thresholds |
Active Buzzer & Button | Audible alerts and physical interaction |
This schematic shows the full wiring setup for the system using Raspberry Pi, including:
- Sensors (MPU6050, GPS)
- Output devices (LCD, buzzer)
- Input (button) It visually represents how components connect to the Pi’s GPIO.
A photo of the actual built prototype, showcasing the wired connections between the Raspberry Pi, night vision camera, GPS module, LCD, and other peripherals. It brings the Fritzing diagram to life in a practical setup.
- Executes the main script when a physical button is pressed.
- Real-time face mesh and eye detection using
MediaPipe
- Head pose estimation using OpenCV's
solvePnP
- GPS tracking via
gpsd
- Impact detection using
mpu6050
- SMS alerting via
Twilio
- LCD status update using
rpi_lcd
- Blink Detection: Calculates eye aspect ratio. If the value exceeds
eye_thresh
, it's flagged. - Head Pose Estimation: Calculates the angle of head tilt. If
x ≤ head_thresh
, drowsiness is suspected. - Crash Detection: Detects high g-force values to identify collisions and immediately sends GPS + SMS.
- Emergency Alerts: Sends alert via Twilio API to a preset emergency contact.
Hello Mr. Abdullah
Car Impact Alert From: Ahmed
Location: https://maps.google.com/?q=24.7136,46.6753
-
Install required libraries:
pip install opencv-python mediapipe twilio gps3 gpiozero rpi_lcd mpu6050-raspberrypi
-
Enable Camera & I2C on Raspberry Pi:
sudo raspi-config
-
Set up
gpsd
:sudo gpsd /dev/serial0 -F /var/run/gpsd.sock
-
Run the system:
python3 run.py
Replace your account_sid
, auth_token
, and messaging_service_sid
in main0.1.py
.
- Detect phone usage with YOLO or MobileNet
- Enhance facial gesture recognition (yawning, nodding)
- Mobile App Integration via Bluetooth
- Cloud-based real-time monitoring dashboard
This project is licensed under the MIT License.