-
-
what basically happens when drowsiness is detected. EAR< 0.2 and the model detects drowsiness, so an alarm will sound in this case.
-
Example of what happens underground when drowsiness is not detected. EAR > 0.2
-
Hardware of the system
-
System after completion
-
Flow chart of the system
-
Block diagram of the system
-
Confusion matrix showing the performance of the model on more than 3000 dataset
-
ROC curve showing the performance of the model
Inspiration
The inspiration for this project came from the rising number of road accidents in Nigeria and across Africa that are caused by driver fatigue and drowsiness. I came from a locality that many accidents do occur which is linked to drivers falling asleep while driving. Also while researching the causes of road accidents across Africa, I reviewed reports from the FRSC (Nigeria), academic studies from South Africa, and publications by road safety researchers across the continent. These studies shows that drowsiness while driving is the major culprit and a major cause of this accidents. I realized that many of these accidents could have been prevented if there was a reliable system to detect when a driver is becoming drowsy and alert them in time.
My background in AI and embedded systems allowed me to picture a solution that would be not only be affordable and efficient but also work in real-time. Seeing news reports of tragic accidents, especially involving commercial drivers is my major inspiration.
What it does
This system monitors a driver’s eye in real time using a camera for continuous live capture and detection of signs of drowsiness which is eye closure. It uses a lightweight CNN model deployed on a Raspberry Pi to check for drowsiness. When drowsiness is detected, the system instantly triggers an audible alarm to alert the driver, preventing accidents that might have occurred.
How we built it
The system was built using a Raspberry Pi 5 and a USB camera to capture real-time video of the driver’s face. MediaPipe’s FaceMesh was used to detect and track facial landmarks, particularly around the eyes. Each eye region was cropped and fed into a lightweight Convolutional Neural Network (CNN) model, optimized with TensorFlow Lite for edge deployment.
The model classifies the eye state (open or closed), and an Eye Aspect Ratio (EAR) method was also integrated for enhanced accuracy. Once drowsiness is detected based on prolonged eye closure or low EAR, the system activates an audible sound alarm to alert the driver.
The entire solution runs locally on the Raspberry Pi without requiring internet access or electricity because is uses batteries as source of power, making it efficient, fast, and suitable for embedded real-time applications.
Challenges we ran into
Well, one of the major challenge ran into in the project is the fact that the camera that was used is it infrared enabled and so face detection in a poorly lighted environment or in the dark is near impossible meaning the system is not adapted to work at night.
Accomplishments that we're proud of
The major accomplishment is that in a good lightening condition, the detection is close to 100% accuracy. Also, false positive and false negative is very very minimal. The system also works on battery which is a major accomplishment and I can say the major accomplishment is the fact that the detection is actually real time. The duration of time the system captures drowsiness to the duration of time the system give out the alert warning is estimated to be 0.024 seconds which is really remarkable.
What we learned
I learnt how to design, train, and optimize lightweight machine learning models using TensorFlow and deploy them efficiently on edge devices like the Raspberry Pi. I also gained hands-on experience with TensorFlow Lite, model quantization, and inference speed optimization under hardware constraints. I developed a deeper understanding of facial landmark detection using MediaPipe FaceMesh, and how to combine data-driven AI (CNN) with rule-based techniques (EAR) for robust real-time performance.I actuallu do not know some of this amazing frameworks exist until I have to use them. I improved my skills in Python scripting, GPIO interfacing, OpenCV image processing, and managing Linux services (systemd) to create a production-ready embedded AI system.
What's next for Real-time drowsiness detection system for drivers
- We are going to make the system much more adaptable to different lighting condition especially in the dark so that the system will be useful at night as well.
- We need to get dataset from real world deployment so that the model can be fined-tuned so as to support personalized threshold and blink rate which might sometimes be assumed and detected to be drowsiness.
- We aim to integrate it to the vehicle systems so that alarm can be sounded by the vehicles sound system and also the system using the the vehicles power as a power source instead of batteries.
- We also aim to provide mobile app for fleet managers and logistic companies so that they will be able to monitor drivers drowsiness report, get alerts for repeated drowsiness detection and schedule for drivers on long journey on when they are supposed to take little nap. This can also be used in accessing the professionalism of their drivers and maybe get rid of those that are of safety concern.
- If possible, we also aim to partner with regulators like the FRSC so that citizens can drive more safely and also they will have a centralized system where repeated drivers drowsiness violation can be monitored and fines are meted on drivers with repeated violation. This is relatively easy since they already have the registration of vehicles. Just that we need to figure out a way such that each system will have its own id and each id will be registered to a particular driver.
Built With
- machine-learning
- mediapipe
- numpy
- opencv
- python
- tensorflow