Back to Projects



PythonML
Drowsiness Detection System
March 21, 2026
Overview
A real-time drowsiness detection system built using MediaPipe Face Mesh and Eye Aspect Ratio (EAR). The application streams webcam frames from a Next.js frontend to a FastAPI backend via WebSockets, where facial landmarks are analyzed to detect eye closure patterns. If prolonged eye closure is detected, the system triggers an instant audio-visual alert to prevent accidents. Designed for low-latency performance and real-time feedback.
Key Features
- •Real-time webcam streaming using WebSockets for low-latency communication
- •MediaPipe Face Mesh detecting 478 facial landmarks per frame
- •Eye Aspect Ratio (EAR) algorithm for accurate eye state detection
- •Drowsiness alert triggered after sustained eye closure (~2 seconds)
- •Audio (Web Audio API) and visual alert system for instant feedback
- •Customizable thresholds (EAR, FPS, frame count) for tuning accuracy
- •Clean modular architecture separating frontend UI and backend ML logic
Highlights
- •Real-time detection (~10 FPS)
- •Low-latency WebSocket pipeline
- •EAR-based eye tracking algorithm