Loading repository data…
Loading repository data…
mjrecosana06 / repository
AI-powered drowsy driver detection with real-time computer vision alerts, hardware integration, and cloud-ready deployment tools.
A transparent discovery signal based on current public GitHub metadata.
This score does not audit code, security, maintainers, documentation quality, or suitability. Verify the repository and its current documentation before adoption.
🎬 Watch the full system demo: AI Drowsy Driver Detection Demo
Mark Joseph Recosana & Fernando Jose Reeves | BSIT
An intelligent real-time drowsiness detection system designed to prevent road accidents by monitoring driver alertness using computer vision and facial landmark analysis. The system detects early signs of drowsiness through multiple metrics and provides immediate alerts through visual, audio, and IoT-based notifications.
Admin dashboard with system overview and driver monitoring
Admin settings and configuration panel
Real-time driver monitoring with live video feed
Centralized settings management for all drivers
Driver monitoring interface with live metrics
Driver-specific settings and preferences
Live camera feed viewable from admin panel
Arduino Uno R3 connection setup
Alternative Arduino connection configuration
Complete breadboard setup with buzzer, LEDs, and resistors
I2C LCD connection for status display
LiquidCrystal library installation
LCD-I2C library for display support
Before installing, ensure you have:
git clone https://github.com/mjrecosana06/AI-Drowsy-Driver-Detection.git
cd AI-Drowsy-Driver-Detection
Windows:
python -m venv venv
venv\Scripts\activate
macOS/Linux:
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
Note for Apple Silicon (M1/M2 Macs):
The requirements.txt automatically handles MediaPipe installation for Apple Silicon. If you encounter issues, you may need to install mediapipe-silicon separately:
pip install mediapipe-silicon
Create a .env file in the project root for custom configuration:
# Camera Settings
CAMERA_INDEX=0
CAM_WIDTH=640
CAM_HEIGHT=480
CAM_FPS=12
CAM_MIRROR=0
JPEG_QUALITY=60
# Detection Thresholds
EAR_THRESHOLD=0.23
MAR_THRESHOLD=0.65
TILT_THRESHOLD_DEG=18
FRAMES_BELOW_THRESH=12
PERCLOS_THRESHOLD=0.2
# Arduino Settings (Optional)
ARDUINO_PORT=/dev/cu.usbserial-10
ARDUINO_BAUD=9600
# Notification Settings (Optional)
TWILIO_ACCOUNT_SID=your_twilio_sid
TWILIO_AUTH_TOKEN=your_twilio_token
TWILIO_PHONE_NUMBER=your_twilio_number
If you want to use Arduino for physical alerts:
Install Required Libraries:
Upload Arduino Code:
arduino_uno_drowsy_alert.ino in Arduino IDEConnect Components:
Images/Arduino Uno R3 Economy Circuits/Test Connection:
python test_arduino_connection.py
Windows:
cd "C:\path\to\AI-Drowsy-Driver-Detection"
start_flask.bat
macOS/Linux:
cd "/path/to/AI-Drowsy-Driver-Detection"
chmod +x start_flask.sh
./start_flask.sh
Windows (Command Prompt):
set FLASK_HOST=0.0.0.0
set FLASK_PORT=5000
python app.py
Windows (PowerShell):
$env:FLASK_HOST="0.0.0.0"
$env:FLASK_PORT="5000"
python app.py
macOS/Linux:
export FLASK_HOST=0.0.0.0
export FLASK_PORT=5000
python3 app.py
http://localhost:5000http://[YOUR_IP]:5000
ipconfig in Command Prompt, look for IPv4 Addressifconfig or ip addr, look for inet addresshttp://localhost:5000/register.htmlhttp://localhost:5000/login.htmlCloudflare Tunnel provides free, secure public access to your local Flask server without exposing your IP address.
Step 1: Install Cloudflare Tunnel
Windows:
cloudflared.exe from Cloudflare Releasescloudflared.exe in your project folder (already included)start_cloudflare.bat scriptmacOS:
# Install via Homebrew (Recommended)
brew install cloudflared
# Or download manually from GitHub releases
# Place cloudflared in your project folder
Step 2: Start Flask Server
Windows:
# Open Command Prompt or PowerShell
cd "C:\path\to\AI-Drowsy-Driver-Detection"
start_flask.bat
macOS/Linux:
# Open Terminal
cd "/path/to/AI-Drowsy-Driver-Detection"
chmod +x start_flask.sh
./start_flask.sh
Step 3: Start Cloudflare Tunnel (In a NEW Terminal/Command Prompt)
Windows:
# Open a NEW Command Prompt window
cd "C:\path\to\AI-Drowsy-Driver-Detection"
start_cloudflare.bat
# Or manually:
cloudflared tunnel --url http://127.0.0.1:5000
macOS/Linux:
# Open a NEW Terminal window
cd "/path/to/AI-Drowsy-Driver-Detection"
chmod +x start_cloudflare.sh
./start_cloudflare.sh
# Or manually:
cloudflared tunnel --url http://127.0.0.1:5000
Step 4: Get Your Public URL
After starting Cloudflare Tunnel, you'll see output like:
+--------------------------------------------------------------------------------------------+
| Your quick Tunnel has been created! Visit it at (it may take some time to be reachable): |
| https://random-words-1234.trycloudflare.com |
+--------------------------------------------------------------------------------------------+
Copy this URL and share it to access your system from anywhere!
Important Notes:
Step 1: Install ngrok
Windows:
ngrok.exe from ngrok.comngrok.exe in your project folder (already included)ngrok config add-authtoken YOUR_AUTH_TOKENmacOS:
# Install via Homebrew
brew install ngrok/ngrok