A high-performance, real-time safety system that monitors driver alertness using computer vision and provides instant feedback through a modern web dashboard and Telegram notifications.
- Real-time Eye Tracking: Uses MediaPipe and EAR (Eye Aspect Ratio) calculation for high-precision drowsiness detection.
- Stable Live Feed: Optimized React-based vision system with manual Start/Stop controls.
- Intelligent Alerting:
- Warning State: Triggered after ~2 seconds of sustained drowsiness (Visual amber glow).
- Critical Alert: Triggered after ~6 seconds of sustained drowsiness (Visual red pulse + alarming).
- Telegram Integration: Automated alerts sent to
@EARdrowsines_alertincluding JPEG snapshots of the driver and precise timestamps. - Modern Analytics Dashboard: Real-time graphs for EAR value, system health status, and a detailed event log.
- Customizable Thresholds: Adjustable EAR sensitivity and notification cooldowns via the settings panel.
- Frontend: React 18, TypeScript, Tailwind CSS, Lucide React.
- Backend: Flask (Python), MediaPipe, OpenCV, Asyncio.
- Communication: REST API, Telegram Bot API.
- Deployment: Vercel ready (Backend & Frontend).
- Python 3.10+
- Node.js 18+
- A webcam
cd MainLogic
pip install -r requirements.txt --break-system-packages
# Ensure face_landmarker.task is in the MainLogic folder
python Drowniness_detect.pycd Client
npm install
npm run devThe system is pre-configured to send alerts to the @EARdrowsines_alert channel. To use your own bot:
- Update
BOT_TOKENandCHAT_IDinMainLogic/Drowniness_detect.py. - Ensure your bot has permission to post to the specified channel.
- EAR Threshold: Default is set to
0.20. Lower values make the system less sensitive (requiring more eye closure). - Notification Cooldown: Default is
60sto prevent alert spamming.
├── Client/ # React Frontend (Vite + TypeScript)
│ ├── src/
│ │ ├── components/ # UI Components (CameraFeed, EventLog, etc.)
│ │ ├── services/ # API Integration
│ │ └── types/ # TypeScript Definitions
├── MainLogic/ # Python Backend (Flask)
│ ├── Drowniness_detect.py # Core logic and API
│ ├── face_landmarker.task # MediaPipe model file
│ └── requirements.txt # Backend dependencies
└── vercel.json # Deployment configuration
This project is optimized for deployment on Vercel:
- Connect your repository to Vercel.
- The
vercel.jsonfile in the root will automatically configure the Python serverless functions. - Ensure serverless functions environment allows for enough memory for MediaPipe (at least 512MB recommended).
MIT License - See LICENSE for details............
