Driver Drowsiness Detection: VARSHA S (URK18CS273)
Driver Drowsiness Detection: VARSHA S (URK18CS273)
VARSHA S (URK18CS273)
BACHELOR OF TECHNOLOGY
In
COMPUTER SCIENCE AND ENGINEERING
MARCH 2021
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
BONAFIDE CERTIFICATE
This is to certify that the project report entitled, “Driver Drowsiness Detection “is a bonafide record of Mini
Project work done during the even semester of the academic year 2020-2021 by
in partial fulfillment of the requirements for the award of the degree of Bachelor of Technology in Computer
Science and Engineering of Karunya Institute of Technology and Sciences.
First and foremost, I praise and thank ALMIGTHY GOD whose blessings have bestowed in me the
I am grateful to our beloved founders Late.Dr. D.G.S. Dhinakaran, C.A.I.I.B, Ph.D and Dr. Paul
Dhinakaran, M.B.A, Ph.D, for their love and always remembering us in their prayers.
I extend my thanks to our Vice Chancellor Dr.P. Mannar Jawahar, Ph.Dand our Registrar Dr.
I would like to thank Dr. Prince Arulraj, M.E., Ph.D.,Dean, School of Engineering and Technology
I would like to place my heart-felt thanks and gratitude toDr. J. Immanuel John Raja, M.E., Ph.D.,
Head of the Department, Computer Science and Engineering for his encouragement and guidance.
I feel it is a pleasure to be indebted to, Mr. J. Andrew, M.E, (Ph.D.), Assistant Professor,
Department of Computer Science and Engineering and Mrs. T. Mathu for their invaluable support, advice and
encouragement.
I also thank all the staff members of the Department for extending their helping hands to make this
I would also like to thank all my friends and my parents who have prayed and helped me during the
project work.
Abstract
Drowsiness and fatigue are one of the main causes leading to road accidents. They can be
prevented by taking effort to get enough sleep before driving, drink coffee or energy drink, or
have a rest when the signs of drowsiness occur. The popular drowsiness detection method uses
complex methods, such as EEG and ECG. This method has high accuracy for its measurement
but it need to use contact measurement and it has many limitations on driver fatigue and
drowsiness monitor [18]. Thus, it is not comfortable to be used in real time driving. This paper
proposes a way to detect the drowsiness signs among drivers by measuring the eye closing rate
and yawning.
This project describes on how to detect the eyes and mouth in a video recorded from the. In the
video, a participant will drive the driving simulation system and a webcam will be place in front
of the driving simulator. The video will be recorded using the webcam to see the transition from
awake to fatigue and finally, drowsy. The designed system deals with detecting the face area of
the image captured from the video. The purpose of using the face area so it can narrow down to
detect eyes and mouth within the face area. Once the face is found, the eyes and mouth are found
by creating the eye for left and right eye detection and also mouth detection.
The parameters of the eyes and mouth detection are created within the face image. The video
were change into images frames per second. From there, locating the eyes and mouth can be
performed. Once the eyes are located, measuring the intensity changes in the eye area determine
the eyes are open or closed.
If the eyes are found closed for 4 consecutive frames, it is confirm that the driver is in
drowsiness condition.
CONTENTS
Acknowledgement i
Abstract ii
1. Introduction 1
1.1 Introduction
1.2 Objectives
1.3 Motivation
1.4 Overview of the Project
1.5 Chapter wise Summary
3. Implementation . 8
3.1. Modules Description
3.2Implementation Details
3.3. Tools used
4. Test results/experiments/verification.
4.1. Testing 17
4.2. Results
4.3. Verification
References 23
1
1. Introduction
1.1 Introduction
Drowsiness is a state of near sleep, where the person has a strong desire for sleep. It has two
distinct meanings, referring both to the usual state preceding falling asleep and the chronic
condition referring to being in that state independent of a daily rhythm [16]. Sleepiness can be
dangerous when performing tasks that require constant concentration, such as driving a vehicle.
When a person is sufficiently fatigue while driving, they will experience drowsiness and this
leads to increase the factor of road accident.
2
Figure 2 shows the difference between fatigue and drowsiness condition.
The development of technologies for detecting or preventing drowsiness while driving is a major
challenge in the field of accident avoidance system. Because of the hazard that drowsiness
presents on the road, methods need to be developed for counteracting its affects.
The aim of this project is to develop a simulation of drowsiness detection system. The focus will
be placed on designing a system that will accurately monitor the open or closed state of the
driver’s eyes and mouth. By monitoring the eyes, it is believed that the symptoms of driver's
drowsiness can be detected in sufficiently early stage, to avoid a car accident. Yawning detection
is a method to assess the driver’s fatigue. When a person is fatigue, they keep yawning to ensure
that there is enough oxygen for the brain consumption before going to drowsiness state .
Detection of fatigue and drowsiness involves a sequence of images of a face, and the observation
of eyes and mouth open or closed duration. Another method to detect eye closure is PERCLOS.
This detection method is based on the time of eyes closed which refers to percentage of a
specific time.
The analysis of face images is a popular research area with applications such as face recognition,
and human identification and tracking for security systems. This project is focused on the
localization of the eyes and mouth, which involves looking at the entire image of the face, and
determining the position of the eyes and mouth, by applying the existing methods in image-
processing algorithm. Once the position of the eyes is located, the system is designed to
determine whether the eyes and mouth are opened or closed, and detect fatigue and drowsiness.
3
1.2 Objectives
1.3 Motivation
Driver drowsiness is a significant factor in the increasing number of accidents on today’s roads and has been
extensively accepted. This proof has been verified by many researchers that have demonstrated ties between
driver drowsiness and road accidents. Although it is hard to decide the exact number of accidents due to
drowsiness, it is much likely to be underestimated. The above statement shows the significance of a research
with the objective of reducing the dangers of accidents anticipated to drowsiness. so far, researchers have tried
to model the behavior by creating links between drowsiness and certain indications related to the vehicle and
to the driver.
Previous approaches to drowsiness detection primarily make pre-assumptions about the relevant behavior,
focusing on blink rate, eye closure, and yawning. The automobile business also has tried to build several
systems to predict driver drowsiness but there are only a few commercial products available today. The
systems do not look at driver performance and overlook driver ability and characteristics. Naturally, most
people would agree that different people drive differently. The system that being develop able to adapt to the
changes of the driver’s behavior.
Drowsiness detection is a safety technology that can prevent accidents that are caused by drivers who fell
asleep while driving.
The objective of this intermediate Python project is to build a drowsiness detection system that will detect that
a person’s eyes are closed for a few seconds. This system will alert the driver when drowsiness is detected.
During long journeys, it’s possible that the driver may lose attention because of drowsiness, which may be a
potential reason for fatal accidents. With technologies like Driver Drowsiness Detection getting it is possible
to detect driver’s driving behavior that may prove fatal to the vehicle as well as the people boarding it.
4
Having such sleep detection system in cars embedded in vehicles could protect precious lives and property
worth billion dollars. The outcome would be positive – it would be suitable for fleet owners as well as
individual vehicle users. In either case, the objective is identical by sleep detection while driving. The driver
drowsiness detection system uses Image Processing to analyze the driver’s eye blink pattern by sitting on the
vehicle’s dashboard
If the eye lid movements are abnormal than usual then the detection system triggers the alarm thus alerting the
driver about the condition.
Anaconda Software:
Anaconda is a free and open-source distribution of the Python and R programming languages for
scientific computing (data science, machine learning applications, large-scale data processing,
predictive analytics, etc.), that aims to simplify package management and deployment.
Python:
We have used pythons 3.6 version which support opencv and dlib packages for face recognition. Python is an
interpreter, general purpose programming language. It is easy to understand.
OpenCV :
It is a library of many programming functions which is mainly used for real time computer vision program.
Dlib:
It is used for creating more complex software and used to solve many real time based problems.
Webcam:
To detect face and eye movements.
Play sound:
If eyes are closed for more interval of time with the help of play sound application it will be able to play
the alarm.
5
2.3 Architecture
Fig 1: architecture
6
2.5. Sequence Diagram
7
3. Implementation
.
A camera is setup that looks for faces in the input video stream and monitors frames of faces. In
the event that a face is identified, facial milestone identification is connected and the eye district is
removed from the earge of video stream
We observe the aspect ratio of the eye remains constant for a period of time indicating that the eye
was open, then it falls rapidly to zero and then increases again which indicates the person blinked
We observe the aspect ratio of the eye remains constant for a period of time indicating that the eye
was open, then it falls rapidly to zero and then increases again which indicates the person blinked
9
We will be observing this eye aspect ratio in our drowsiness detector case to see if the value
remains constant or falls to zero but not increases again implying that the driver has closed his
eyes for extended period
OpenCV was developed keeping image processing in mind. Every function and data struct of
OpenCV concerns itself with an Image Processing library. Comparatively, Matlab is hugely of
generic use & slow.
Any usefulness can be accomplished by methods for tool kits in OpenCV, it might be money
related tool compartments or explicit DNA tool stash
10
Also the dlib library comes with a oriented gradients based face detector histogram a facial
landmark predictor comes bundled in the library.
11
3.2. Implementation Details
12
Algorithmic steps:-
The overall algorithm is pretty straightforward one. First we have used a camera which is
setup at desirable position in a car that looks for faces stream.
If face gets detected, the facial landmark detection task is applied and region of eyes is
extracted.
Once we get the eye region, we calculate the Eye Aspect Ratio to find out if the eye-lids
are down for a substantial amount of time.
On the off chance that the Eye Aspect Ratio demonstrates that the eyes are shut for a
considerably long measure of time, the alert will sound noisy to wake the driver up.For
the functionalities of the system and to make it work efficiently we have used OpenCv,
dlib and Python.
It works efficiently well overall. It can also be used to detect various different types of
objects with the required software.
13
First, we create a new file drowsy_detect.py and write the following script in it : -
Now for calculating the eye-aspect ratio we need to compute the Euclidean distance between the
facial landmarks points which in turn needs SciPy package in python. (It not a strict requirement
but SciPy is needed if work related to computer vision or image processing is intended).
Also the package named imutils is needed for image processing and computer vision functions to
assist the working with OpenCv.
The thread class is imported so that we can beep the alarm in a different thread from main thread
so that it is ensured that our script doesn’t stop/pause executing while the alarm beeps. In order to
play a file of the wav or mp3 format, we need playsound library.
For detecting and localising facial landmarks we will require the dlib library hence we import it.
Eye_aspect_ratio function is defined to calculate the distance between the eye landmarks taken
vertically and distances between the eye landmarks taken horizontally.
14
So, when the eye is open, the value returned for the eye aspect ratio will be a constant
approximately. Then the value will rapidly decrease reaching zero in case of an eye blink.
When the eye is closed, eye aspect ratio again approaches to an approximate constant value which
is very smaller compared to that when the eye is open.
Therefore, the dip in the aspect ratio indicates blink of the eyes.
15
Important variables in the script
EYE_AR_THRESH: it’s a threshold value for the eye aspect ratio. If ratio becomes lower than this
value, counter starts for the number of frames the eyes remain closed.
EYE_AR_CONSEC_FRAMES: If the value for the number of frames for which the eyes remain
closed exceeds this variable’s value , the alarm is activated.
Now from these landmarks, we just churn out the eye regions successfully.
OpenCV
OpenCV is an open source computer vision library accessible in python coding language to code
for visionary capabilities of our smart pc.
16
OpenCV was expected for computational capability and having a high focus on ongoing picture
location and distinguishing proof. OpenCV is coded with streamlined C and can take work with
multicore processors. If we need progressively programmed improvement utilizing Intel models
[Intel], you can purchase Intel's Integrated Performance Primitives (IPP) libraries [IPP]. These
comprise of low-level schedules in different algorithmic regions which are streamlined. OpenCV
consequently utilizes the IPP library, at runtime if that library is introduced.
4. Test results/experiments/verification.
4.1. Testing
Following is the table representing four test cases that are to encountered while doing this project
that concerns with the drowsiness of the driver.
Case1 NO NO No result
Case2 NO NO No result
17
At the point when the eyes are shut for more than certain measure of edges then we find that the
driver is feeling tired. Henceforth these cases are distinguished is and a caution sounded.
4.2. Results
Numerous examples with shifting exactnesses were assembled and consequently a table plotted for
them
Every individual who volunteered for the test will be approached to squint multiple times and act
languid multiple times amid the test procedure. The eye squinting exactness was determined by
beneath referenced recipe
18
Every individual who volunteered for the test will be approached to squint multiple
times and act languid multiple times amid the test procedure. The eye squinting
exactness was determined by beneath referenced recipe
Eye Detection Accuracy = total number of times eyes detected / (total no. of eyes
detected+ total no of times eyes not detected)
Drowsiness Detection Accuracy = total no. of times alarm sounds / (total no.
of times alarm sounds + total no of times alarm didn’t sound)
Face or eyes sometimes might not be detected due to lack of ample ambient light. It will
in general be seen from the above table that in case model 3 isn't mulled over, at that
point the framework has an accuracy of about 100%. That said; the high proportion of
disappointments in test 3 exhibits that the framework is slanted to botch and has certain
obstacles. In test 3 we didn't utilize ample backdrop lights for the webcam. The
subsequent poor lighting conditions gave a very error prone result.
Limitations: -
With poor lighting conditions once in a while the framework is unfit to perceive the eyes. So it gives
a wrong result which must be managed. Continuously
Circumstance infrared setting enlightenments should be used to repel from poor lighting
conditions.
Exactly when the division among face and webcam isn't at perfect range then certain
issues develop. Exactly when face is unreasonably close webcam (less than 25 cm), then
the framework is unfit to perceive the face from the image. Right when face is a long
way from the webcam (more than 80cm) by then the setting light is missing to edify the
face fittingly. So eyes are not related to high precision which results in botch in
recognizable proof of sluggishness. This issue isn't truly considered as progressively
circumstance, the partition between driver's face and webcam is perfect so the issue
never develops.
19
Orientation of face: -
At the point when the face is tilted to a specific degree it will in general be perceived,
anyway past this the framework can't identify the face. So when the face isn't recognized,
eyes are also not distinguished.
In case more than one face is recognized by the webcam, at that point framework
gives an incorrect result. This issue isn't huge as we have to recognize the tiredness
of a solitary driver
4.3. Verification
The peak
value in the
graph show
the driver is v The driver
in drowsiness is drowsy
state. because
the driver
closed his
eyes for
more than
4 frames
per
second.
20
In the image above, the drowsiness state occur from frame number 168 to 179, where
the driver closed it eyes for 11 seconds. The result of the driver yawns just after the
drowsiness state occurs and it is shown in the graph in Figure 31.
Driver yawns
after drowsiness
state occurs.
From the experimentation and modeling, this project successfully detects each eyes and
mouth for drowsiness detection system to meet the objectives of mini Project. This
system is reliable because it detects the transition of the drowsiness state where the
algorithms detects each eyes and mouth changes each frame per second. Therefore, the
Drowsiness Detection System by using Webcam has successfully done. All the data and
result from the simulation algorithm has been shown this chapter.
5. Conclusions
This framework can be stretched out further to have abundant security highlights, for
example, just a certain no of individuals can have specialist get to or work the vehicle.
A picture of the burglar is taken in an attempted theft &sent to the owner of the vehicle who can
register a case against the thief of the vehicle.
References
[4]. Bradski.
22