A computer vision system that can automatically detect driver drowsiness in a real-time video stream and then play an alarm if the driver appears to be drowsy.
We already did an eye-blink detector python project earlier, using Facial landmarks. Now we will extend this feature to determine for how long does the eye of a person is closed. If the eyes are closed for a certain time, and the pattern is recurring, we'll assume the driver is dozing off and the alarm will be played.
We'll use librarries like openCV, dlib
We are using the SciPy package, so we can compute the Euclidean distance between the facial landmark points in the EAR The imutils package make working with OpenCV much better
You can install the packages by
pip install <package-name>
pip install --upgrade <package-name>
If you want to install imutils, type this in the terminal
pip install --upgrade imutils
We are also using the "Thread" class, so we can play our alarm in separate thread In order to play the MP3/WAV music file as an alarm, we need the "playsound" library
pip install playsound
(Mac users also need to import pyobj)
The return value of the eye aspect ratio will be approximately constant when the eye is open. The value will then rapid decrease towards zero during a blink.
If the eye is closed, the eye aspect ratio will again remain approximately constant, but will be much smaller than the ratio when the eye is open.