Various studies show that around 20% of all road accidents are fatigue-related, up to 50% on certain conditions. One of the ways to reduce this percentage is to use Driver drowsiness detection technology. In this code I introduce an implementation of Driver drowsiness detection via eye monitoring being it closed or opened.
Install Xquartz for Mac os and install libx11-dev if you use Ubuntu to be able run the realtime code.
Dlib is a C++ toolkit for machine learning, it also provides a python API to use it in your python apps. One of its best features is a great documentation for C++ and Python API. It is used in the code to detect faces and get facial landmarks coordinates especially the 12 points which define the two eyes left and right (Fig 1). After getting the 12 points of left and right eye, we compute Eye aspect ratio (Fig 2) to estimate the level of the eye opening. Open eyes have high values (>0.2) of EAR while the closed eye it is getting close to zero.