Design of Real-time Drowsiness Detection System using Dlib
Design of Real-time Drowsiness Detection System using Dlib
using Dlib
1
Shruti Mohanty, 1Shruti V Hegde, 1Supriya Prasad, 2J. Manikandan
1
Dept of ECE, PES University, 100-Feet Ring Road, BSK Stage III, Bengaluru - 85, Karnataka, India
2
Dept of ECE, Crucible of Research and Innovation (CORI)
PES University, 100-Feet Ring Road, BSK Stage III, Bengaluru - 85, Karnataka, India
{email : [email protected], [email protected], [email protected],
[email protected]}
Abstract—Drowsiness while driving is a highly prevalent There has been extensive research and a number of papers
problem that leads to thousands of fatal accidents every year. A that have put forth possible methodologies to detect
solution to prevent accidents and fatalities is the need of the hour inattentiveness and drowsiness in a driver in the last two
and while there are complex systems developed that provide decades. In [4], traditional techniques are elaborated which
solutions for detecting drowsiness in drivers, this paper explores are based on physiological measurements including brain
a simpler, yet highly effectual method of doing the same. In this waves, heart rate, pulse rate and respiration. However, these
paper, drowsy driver detection system is designed using Python techniques are intrusive in nature. Reference [5] is based on
and Dlib model. Dlib’s shape detector is used to map the Rowley’s eye detection code from the STASM library.
coordinates of the facial landmarks of the input video and However, the presence of glasses adversely affects the
drowsiness detected by monitoring aspect ratios of eyes and performance of the system. Reference [6] monitors only
mouth. Performance evaluation of the proposed system designed yawning patterns of the driver using two separate cameras to
is carried out by testing videos from a standard public dataset
acquire information of the upper part of the body in order to
track the driver’s mouth. However, the hardware dependency
as well as real-time video captured in our lab. The proposed
is higher.
system gave a maximum recognition accuracy of 96.71% for
dataset video input. Drowsiness in humans is characterized by a few very
specific movements and facial expressions- the eyes begin to
Keywords— Python, face detection, drowsiness detection, close, mouth opens in a yawn, the jaw goes slack and the neck
computer vision, Dlib, OpenCV, HOG, facial landmark estimation tilts. This paper focuses on tracking the eyes and mouth to
detect drowsiness and classify a driver as drowsy. For real-
I. INTRODUCTION time application of the model, the input video can be acquired
Facial expressions have the ability to offer deep insights by mounting a camera on the dashboard of the car and can
into many physiological conditions of the body. The display accommodate the driver’s face, hands, upper body and
of a myriad of emotions and reactions to stimuli have been a occlusions such as non-tinted spectacles.
constant area of study and research, and also used in the The Dlib model is trained to identify 68 facial landmarks.
development of intelligent systems such as facial emotion As shown in Fig 1. the drowsiness features are extracted and
detection in [1], automatic pain detection in [2] and prediction the driver is alerted incase of drowsiness being detected. The
of personality in [3] to name a few. There are numerous model does not require prior information on the individual
algorithms and methodologies available for face detection who is testing it. Main software requirements are Python and
which is the fundamental first step in the process. OpenCV.
Eyes closed, mouth open Eyes closed, mouth closed Fig. 5 shows the facial landmark mapping on particular
frames extracted from the video input for different cases such
as eyes closed mouth open, eyes open mouth closed, eyes
open mouth open and eyes closed mouth closed.
TABLE I: DATASET DESCRIPTION Future work will focus on enhancing the model to work
Feature YawDD Dataset[10] MRL Eye Dataset[11]
under poor to mediocre lighting conditions, and including
Number of 29 84,898
more drowsiness signs such as head nodding for the
videos/images Videos Images drowsiness detection model.
Number of males 16 33
Number of females 13 4
REFERENCES
Actions performed Without talking or Closed or open eyes
talking/singing or [1] M. Matsugu., K. Mori., Y. Mitari, and Y. Kaneda, “Subject
yawning independent facial expression recognition with robust face detection
Resolution 640x480 RGB (24-bit 640x480, 1280x1024, using a convolutional neural network,” Neural networks: the official
true colour) 752x480 journal of the Intern. Neural Network Society, vol. 16, no. 5-6, pp.
555-559, June 2003.
[2] P. Lucey, J. Cohn, S. Lucey, I. Matthews, S. Sridharan and K. M.
B. Results Obtained from Comparison Prkachin, "Automatically detecting pain using facial actions," in 3rd
Intern. Conf. on Affective Computing and Intelligent Interaction and
Table II below describes the recognition accuracy obtained Workshops, Amsterdam, 2009, pp. 1-8.
from two approaches (eye closure and yawn detection), on [3] L. Liu, D. Preotiuc-Pietro., Z.R. Saman, M.E. Moghaddam, and L.H.
using standard datasets and real-time. Ungar, “Analyzing Personality through Social Media Profile Picture
Choice,” Intern. AAAI Conf. on Web and Social Media, Cologne,
Real-time computational results were calculated by taking Germany, May 2016, pp. 214.
the average of 5 trials each of 12 subjects (including 5 males [4] P. K. Stanley, T. Jaya Prakash, S. Sibin Lal and P. V. Daniel,
and 7 females) recorded at different locations. Average result "Embedded based drowsiness detection using EEG signals," IEEE
included cases with and without glasses. Video frames with Intern. Conf. on Power, Control, Signals and Instrumentation
instances of 2 states (sleepy and non-sleepy) for every trial. Engineering, Chennai, India, Sept. 2017, pp. 2596-2600.
[5] T. Danisman, I. M. Bilasco, C. Djeraba and N. Ihaddadene, "Drowsy
Highest percentage accuracy obtained is 96.71 % for yawn
driver detection system using eye blink patterns," Intern. Conf. on
detection followed by 93.25% for drowsy blink detection.
Machine and Web Intelligence, Algiers, Algeria, Oct. 2010, pp. 230-
TABLE II: RESULTS OBTAINED
233.
Recognition Accuracy [6] L. Li, Y. Chen and Z. Li, "Yawning detection for monitoring driver
Features fatigue based on two cameras," 12th Intern. IEEE Conf. on Intelligent
Real Time Dataset
Transportation Systems, St. Louis, USA, Oct. 2009, pp. 1-6.
Eye 82.02 % 93.25 % [7] Davis E. King, Dlib-models [Online].
Available: https://github.com/davisking/dlib-models
Yawn 85.44 % 96.71 %
[8] L. Anzalone, Training Alternative Dlib Shape Predictor models using
Python, Oct. 2018. Accessed on July 16, 2019. [Online]. Available:
https://medium.com/datadriveninvestor/training-alternative-dlib-
shape-predictor-models-using-python-d1d8f8bd9f5c
IV. CONCLUSIONS [9] N. Dalal, B. Triggs “Histogram of oriented gradients for human
In the Dlib approach, the library’s pre-trained 68 facial detection”, IEEE Computer Society Conf. on Computer Vision and
landmark detector is used. The face detector which is based Pattern Recognition, San Diego, USA, June 2005, pp. 63-69.
on Histogram of Oriented Gradients (HOG) was [10] S. Abtahi, M. Omidyeganeh, S. Shirmohammadi, and B. Hariri. 2014.
implemented. The quantitative metric used in the proposed YawDD: a yawning detection dataset, 5th ACM Multimedia Systems
algorithm was the Eye Aspect Ratio (EAR) to monitor the Conf., New York, USA, Mar. 2014, pp. 24-28.
[11] R. Fusek, MRL Eye Dataset, Accessed on May 28th, 2019. [Online].
driver’s blinking pattern and Mouth Aspect Ratio (MAR) to
Available: http://mrl.cs.vsb.cz/eyedataset
determine if the driver yawned in the frames of the
continuous video stream. The average real-time test
accuracies obtained using Dlib for eyes and yawn were
82.02% and 85.44% respectively and 93.25% and 96.71%
respectively for pre-recorded videos.