FocusGuard is a real-time computer vision application designed to prevent driver fatigue accidents. It uses MediaPipe's Face Mesh technology to track 468 facial landmarks and mathematically calculates the Eye Aspect Ratio (EAR) to detect drowsiness with high precision.
- Real-Time Tracking: Monitors eye blinks and closure duration in milliseconds.
- Intelligent Logic: Distinguishes between natural blinks and "micro-sleeps" using a calibrated EAR threshold (0.15).
- Dual Alarm System: Triggers a Red Visual Border and an Audio Alert when fatigue is detected.
- Privacy First: All processing happens locally on the device (Edge AI); no video is sent to the cloud.
- Language: Python
- Computer Vision: OpenCV (
cv2) - AI Model: Google MediaPipe (Face Landmarker Task)
- Math: NumPy / Python Math (Euclidean Geometry)
The system uses the Eye Aspect Ratio (EAR) formula to quantify eye openness:
- EAR > 0.20: Eyes are Open (Safe)
- EAR < 0.15: Eyes are Closed (Drowsy)
- If the EAR remains low for 1.5 seconds, the Alarm triggers.
-
Clone the Repository
git clone https://github.com/upamada-ekanayake/-FocusGuard-AI-Drowsiness-Detector-.git cd -FocusGuard-AI-Drowsiness-Detector- -
Install Dependencies
pip install opencv-python mediapipe
-
Run the App
python main.py
main.py: The core application logic.face_landmarker.task: The pre-trained AI model file.diagnostic.py: Diagnostic script for audio drivers.
Created by Upamada Ekanayake