Final Project Report SV
Final Project Report SV
A
Project Report
BACHELOR OF TECHNOLOGY
JUNE,2023
Driver Drowsiness Detection System
DECLARATION
I, declare that the work embodied in this Project report is my own original work carried out by
me under the supervision of Dr. Deepak Arya Sir for the session 2022 - 2023 at Roorkee Institute
of Technology, Roorkee. The matter embodied in this Project report has not been submitted
elsewhere for the award of any other degree. I declare that I have faithfully acknowledged, given
credit to and referred to the researchers wherever the work has been cited in the text and the
body of the thesis. I further certify that I have not willfully lifted up some other’s work, Para,
text, data, results, etc. reported in the journals, books, magazines, reports, dissertations, thesis,
etc., or available at websites and have included them in this Project report and cited as my own
work.
Place:
Supervisor Signature :
Supervisor Name :
Supervisor Designation :
Name of Department :
Date :
ACKNOWLEDGEMENT
I am very happy to gently acknowledge the numerous personalities involved in lending their
help to make our project “DRIVER DROWSINESS DETECTION SYSTEM” a successful
one.
We take this opportunity to express our deep sense of gratitude to our honorable Director “DR.
PARAG JAIN” for providing an excellent academic climate in the college that made this
endeavour possible.
We give our wholehearted admiration and a deep sense sense of gratitude to “DR. DEEPAK
ARYA”, HOD, “COMPUTER SCIENCE & ENGINEERING”, Roorkee Institute of
Technology, Roorkee for his inspiration, valuable guidance, encouragement, suggestion, and
overall help throughout.
We express our sincere thanks to our guide “DR. DEEPAK ARYA”, HOD,
“COMPUTER SCIENCE & ENGINEERING”, Roorkee Institute of Technology, Roorkee, for
his keen interest and invaluable help throughout the project.
We would like to express our sincere thanks to our project coordinator “DR.DEEPAK ARYA”,
“HOD”, “COMPUTER SCIENCE & ENGINEERING”, Roorkee Institute of Technology,
Roorkee, for his kind support and encouragement throughout this course of work.
Finally, we express our gratitude to all the Teaching and Non-Teaching staff of “COMPUTER
SCIENCE & ENGINEERING”, Roorkee Institute of Technology, Roorkee for their timely
support and suggestions.
ABSTRACT
• This document is a review report on the research conducted and the project made in the
field of computer engineering to develop a system for driver drowsiness detection to
prevent accidents from happening because of driver fatigue and sleepiness. The report
proposed the results and solutions on the limited implementation of the various
techniques that are introduced in the project. Whereas the implementation of the
project gives the real-world idea of how the system works and what changes can be done
to improve the utility of the overall system.
• Furthermore, the paper states the overview of the observations made by the authors to
help further optimization in the mentioned field to achieve the utility at a better
efficiency for a safer road.
• This project describes on how to detect the eyes and mouth in a video recorded from
the experiment conducted by MIROS (Malaysian Institute of Road Safety). 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 mouth detection. The parameters of the eyes and mouth detection
are created within the face image. The video was 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 confirmed that the driver is in
drowsiness condition.
Abbreviation Description
FASTER RCNN
Table of Contents
1. PROJECT INTRODUCTION ....................................................................................................................................... 7
1.2 PROBLEM STATEMENT ................................................................................................................................................ 8
1.3 THE INTENDED AUDIENCE .................................................................................................................................................9
1.4 ADVANTAGE OF PROJECT ..................................................................................................................................................9
1.5 SCOPE OF PROJECT ......................................................................................................................................................... 9
1.6 TOOLS & TECHNOLOGY USED .......................................................................................................................................... 10
6 CONCLUSION ......................................................................................................................................................... 58
7 REFERENCES ........................................................................................................................................................... 59
CHAPTER-1
PROJECT INFORMATION
1.1 Purpose
• Humans have always invented machines and devised techniques to ease and protect their
lives, for mundane activities like traveling to work, or for more interesting purposes like
aircraft travel. With the advancement in technology, modes of transportation kept on
advancing and our dependency on it started increasing exponentially. It has greatly affected
our lives as we know it. Now, we can travel to places at a pace that even our grandparents
wouldn’t have thought possible. In modern times, almost everyone in this world uses some
sort of transportation every day. Some people are rich enough to have their own vehicles
while others use public transportation. However, there are some rules and codes of
conduct for those who drive irrespective of their social status. One of them is staying alert
and active while driving. Neglecting our duties towards safer travel has enabled hundreds
of thousands of tragedies to get associated with this wonderful invention every year. It may
seem like a trivial thing to most folks but following rules and regulations on the road is of
utmost importance. While on road, an automobile wields the most power and in
irresponsible hands, it can be destructive and sometimes, that carelessness can harm lives
even of the people on the road. One kind of carelessness is not admitting when we are too
tired to drive. In order to monitor and prevent a destructive outcome from such
negligence, many researchers have written research papers on driver drowsiness detection
systems. But at times, some of the points and observations made by the system are not
accurate enough. Hence, to provide data and another perspective on the problem at hand,
in order to improve their implementations and to further optimize the solution, this project
has been done.
• Our current statistics reveal that just in 2015 in India alone, 148,707 people died due to car
related accidents. Of these, at least 21 percent were caused due to fatigue causing drivers
to make mistakes. This can be a relatively smaller number still, as among the multiple
causes that can lead to an accident, the involvement of fatigue as a cause is generally
grossly underestimated. Fatigue combined with bad infrastructure in developing countries
like India is a recipe for disaster. Fatigue, in general, is very difficult to measure or observe
unlike alcohol and drugs, which have clear key indicators and tests that are available easily.
Probably, the best solutions to this problem are awareness about fatigue-related accidents
and promoting drivers to admit fatigue when needed. The former is hard and much more
expensive to achieve, and the latter is not possible without the former as driving for long
hours is very lucrative. When there is an increased need for a job, the wages associated
with it increases leading to more and more people adopting it. Such is the case for driving
transport vehicles at night. Money motivates drivers to make unwise decisions like driving
all night even with fatigue. This is mainly because the drivers are not themselves aware of
the huge risk associated with driving when fatigued. Some countries have imposed
restrictions on the number of hours a driver can drive at a stretch, but it is still not
enough to solve this problem as its implementation is very difficult and costly.
Driver drowsiness detection is a car safety technology which helps prevent accidents
caused by the driver getting drowsy. Various studies have suggested that around 20% of all
road accidents are fatigue-related, up to 50% on certain roads. Some of the current systems
learn driver patterns and can detect when a driver is becoming drowsy.
• Fatigue is a safety problem that has not yet been deeply tackled by any country in the world
mainly because of its nature. Fatigue, in general, is very difficult to measure or observe
unlike alcohol and drugs, which have clear key indicators and tests that are available easily.
Probably, the best solutions to this problem are awareness about fatigue-related accidents
and promoting drivers to admit fatigue when needed. The former is hard and much more
expensive to achieve, and the latter is not possible without the former as driving for long
hours is very lucrative
• Current drowsiness detection systems monitoring the driver’s condition requires complex
computation and expensive equipment, not comfortable to wear during driving and is not
suitable for driving conditions; for example, Electroencephalography (EEG) and
Electrocardiography (ECG), I. e. detecting the brain frequency and measuring the rhythm
of heart, respectively.
• A drowsiness detection system which uses a camera placed in front of the driver is more
suitable to be use but the physical signs that will indicate drowsiness need to be located
first in order to come up with a drowsiness detection algorithm that is reliable and accurate.
Lighting intensity and while the driver tilts their face left or right are the problems occur
during detection of eyes and mouth region.
• Therefore, this project aims to analyse all the previous research and method, hence
propose a method to detect drowsiness by using video or webcam. It analyses the video
images that have been recorded and come up with a system that can analyse each frame
of the video Project Objective
The intended audience for this document is the development team, the project evaluation jury,
and other tech-savvy enthusiast who Wish to further work on the project.
• The Drowsiness Detection System developed based on eye closure of the driver can
differentiate normal eye blink and drowsiness and detect the drowsiness while driving. The
proposed system can prevent the accidents due to the sleepiness while driving. The system
works well even in case of drivers wearing spectacles and even under low light conditions
if the camera delivers better output
• During the monitoring, the system is able to decide if the eyes are opened or closed. When
the eyes have been closed for too long, a warning signal is issued. processing judges the
driver’s alertness level on the basis of continuous eye closures
• In this project, the author will focus on these following procedures: Basic concept of
drowsiness detection system Familiarize with the signs of drowsiness Determine the
drowsiness from these parameters - Eye blink - Area of the pupils detected at eyes -
Yawning Data collection and measurement. Integration of the methods chosen. Coding
development and testing. Complete testing and improvement
• There are many products out there that provide the measure of fatigue level in the drivers
which are implemented in many vehicles. The driver drowsiness detection system provides
the similar functionality but with better results and additional benefits. Also, it alerts the
user on reaching a certain saturation point of the drowsiness measure
Python: -
Python is a high-level, interpreted, general-purpose programming language. Its design philosophy
emphasizes code readability with the use of significant indentation.
Python is dynamically typed, and garbage collected. It supports multiple programming paradigms,
including structured (particularly procedural), object-oriented and functional programming. It is
often described as a "batteries included" language due to its comprehensive standard library.
Guido van Rossum began working on Python in the late 1980s as a successor to the ABC
programming language and first released it in 1991 as Python 0.9.0. Python 2.0 was released in
2000 and introduced new features such as list comprehensions, cycle-detecting garbage collection,
reference counting, and Unicode support. Python 3.0, released in 2008, was a major revision that
is not completely backward compatible with earlier versions. Python 2 was discontinued with
version 2.7.18 in 2020.
PyCharm: -
PyCharm is an integrated development environment (IDE) used in computer programming,
specifically for the Python programming language. The Czech company JetBrains (formerly known
as IntelliJ) develops it. It provides code analysis, a graphical debugger, an integrated unit tester,
integration with version control systems (VCSeZ), and supports web development with Django as
well as data science with Anaconda.
PyCharm is cross-platform, with Windows, macOS and Linux versions. The Community Edition is
released under the Apache License, and there is also an educational version, as well as a
Professional Edition with extra features (released under a subscription-funded proprietary license)
OpenCV: -
OpenCV is the huge open-source library for the computer vision, machine learning, and image
processing and now it plays a major role in real-time operation which is very important in today’s
systems. By using it, one can process images and videos to identify objects, faces, or even
handwriting of a human. When it integrated with various libraries, such as NumPy, python can
process the OpenCV array structure for analysis. To Identify image pattern and its various features
we use vector space and perform mathematical operations on these features.
The first OpenCV version was 1.0. OpenCV is released under a BSD license and hence it’s free for
both academic and commercial use. It has C++, C, Python and Java interfaces and supports
Windows, Linux, Mac OS, iOS and Android. When OpenCV was designed the main focus was real
time applications for computational efficiency. All things are written in optimized C/C++ to take
advantage of multi-core processing.
Machine Learning: -
Machine Learning is the field of study that gives computers the capability to learn without being
explicitly programmed. ML is one of the most exciting technologies that one would have ever come
across. As it is evident from the name, it gives the computer that makes it more like humans: The
ability to learn. Machine learning is actively being used today, perhaps in many more places than
one would expect.
Image Processing: -
Image processing is the process of transforming an image into a digital form and performing certain
operations to get some useful information from it. The image processing system usually treats all
images as 2D signals when applying certain predetermined signal processing methods.
CHAPTER-2
2. Literature Review
This survey is done to comprehend the need and prerequisite of the general population, and to
do as such, we went through different sites and applications and looked for the fundamental data.
Based on these data, we made an audit that helped us get new thoughts and make different
arrangements for our task. We reached the decision that there is a need of such application and
felt that there is a decent extent of progress in this field too
The developed system is a real time system. It uses image processing for eye and face detection.
HAAR based cascade classifier is used for face detection. An algorithm to track objects is used to
track the eyes continuously. In order to identify the drowsy state of the driver, the PERCLOS
algorithm issued [2]. The paper focuses on developing a non- intrusive system which can detect
fatigue and issue a warning on time. The system will monitor the drivers eyes using a camera. By
developing an algorithm, the symptoms of driver fatigue can be detected early enough to avoid
accident. When the signs of fatigue have been identified output in the form of sound and seat belt
vibration is provided to alert the driver. Warning will be deactivated manually rather than
automatically. This paper uses a faster algorithm than PERCLOS. This system will detect drivers
fatigue by the processing of the eye region. After image acquisition, the first stage of processing is
face detection. If eyes are blinking
visual, non-visual, and vehicular features into one. The last idea is to develop wearable hardware
such as smart watches in order to detect drowsiness
CHAPTER-3
Researchers have used various methods to measure driver drowsiness. This section provides a
review of the four most widely used methods, among which the first method is measured either
verbally or through questionnaire and the remaining three by means of various sensors.
Subjective measures that evaluate the level of drowsiness are based on the driver’s personal
estimation and many tools have been used to translate this rating to a measure of driver
drowsiness. The most commonly used drowsiness scale is the Karolinska Sleepiness Scale (KSS), a
nine-point scale that has verbal anchors for each step, as shown in Table 1. Hu et al. measured the
KSS ratings of drivers every 5 min and used it as a reference to the EoG signal collected. Portouli et
al. evaluated EEG data by confirming driver drowsiness through both a questionnaire and a
licensed medical practitioner. Some researchers compared the self-determined KSS, which was
recorded every 2 min during the driving task, with the variation of lane position (VLP) and found
that these measures were not in agreement. Ingre et al. determined a relationship between the
eye blink duration and the KSS collected every 5 min during the driving task.
Researchers have determined that major lane departures, high eye blink duration and drowsiness
related physiological signals are prevalent for KSS ratings between 5 and 9. However, the subjective
rating does not fully coincide with vehicle-based, physiological and behavioural measures.
Because the level of drowsiness is measured approximately every 5 min, sudden variations cannot
be detected using subjective measures. Another limitation to using subjective ratings is that the
self-introspection alerts the driver, thereby reducing their drowsiness level. In addition, it is
difficult to obtain drowsiness feedback from a driver in a real driving situation. Therefore, while
subjective ratings are useful in determining drowsiness in a simulated environment, the remaining
measures may be better suited for the detection of drowsiness in a real environment.
Steering Wheel Movement (SWM) is measured using steering angle sensor and it is a widely used
vehicle-based measure for detecting the level of driver drowsiness [32,33,36]. Using an angle
sensor mounted on the steering column, the driver’s steering behaviour is measured. When
drowsy, the number of micro-corrections on the steering wheel reduces compared to normal
driving. Fairclough and Graham found that sleep deprived drivers made fewer steering wheel
reversals than normal drivers. To eliminate the effect of lane changes, the researchers considered
only small steering wheel movements (between 0.5° and 5°), which are needed to adjust the lateral
position within the lane. Hence, based on small SWMs, it is possible to determine the drowsiness
state of the driver and thus provide an alert if needed. In a simulated environment, light side winds
that pushed the car to the right side of the road were added along a curved road in order to create
variations in the lateral position and force the drivers to make corrective SWMs. Car companies,
such as Nissan and Renault, have adopted SWMs but it works in very limited situations. This is
because they can function reliably only at particular environments and are too dependent on the
geometric characteristics of the road and to a lesser extent on the kinetic characteristics of the
vehicle.
Standard Deviation of Lane Position (SDLP) is another measure through which the level of driver
drowsiness can be evaluated. In a simulated environment, the software itself gives the SDLP and
in case of field experiments the position of lane is tracked using an external camera. Ingra et al.
conducted an experiment to derive numerical statistics based on SDLP and found that, as KSS
ratings increased, SDLP (meters) also increased. For example, KSS ratings of 1, 5, 8, and 9
corresponded to SDLP measurements of 0.19, 0.26, 0.36 and 0.47, respectively. The SDLP was
calculated based on the average of 20 participants; however, with some drivers, the SDLP did not
exceeded 0.25 m even for a KSS rating of 9. In the above experiment by performing correlation
analysis on a subject-to-subject basis significant difference is noted. Another limitation of SDLP is
that it is purely dependent on external factors like road marking, climatic and lighting conditions.
In summary, many studies have determined that vehicle-based measures are a poor predictor of
performance error risk due to drowsiness. Moreover, vehicular-based metrics are not specific to
drowsiness. SDLP can also be caused by any type of impaired driving, including driving under the
influence of alcohol or other drugs, especially depressants
A drowsy person displays several characteristic facial movements, including rapid and constant
blinking, nodding or swinging their head, and frequent yawning. Computerized, non-intrusive,
behavioral approaches are widely used for determining the drowsiness level of drivers by
measuring their abnormal behaviors. Most of the published studies on using behavioral
approaches to determine drowsiness, focus on blinking. PERCLOS (which is the percentage of
eyelid closure over the pupil over time, reflecting slow eyelid closures, or “droops”, rather than
blinks) has been analysed in many studies. This measurement has been found to be a reliable
measure to predict drowsiness and has been used in commercial products such as Seeing Machines
and Lexus. Some researchers used multiple facial actions, including inner brow rise, outer brow
rise, lip stretch, jaw drop and eye blink, to detect drowsiness. However, research on using other
behavioral measures, such as yawning and head or eye position orientation, to determine the level
of drowsiness is ongoing.
3. Project Description
3.1 Introduction & Working Principle
Driver drowsiness detection is a car safety technology which prevents accidents when the driver is
getting drowsy. Numerous studies have suggested that around 20% of all road accidents are
fatigue-related, up to 50% on certain roads. Driver fatigue is a significant factor in a large number
of vehicle accidents. Recent statistics estimate that annually 1,200 deaths and 76,000 injuries can
be attributed to fatigue related crashes. The development of technologies for detecting or
preventing drowsiness at the wheel is a major challenge in the field of accident-avoidance systems.
Because of the hazard that drowsiness presents on the road, methods need to be developed for
counteracting its affects. Driver inattention might be the result of a lack of alertness when driving
due to driver drowsiness and distraction. Driver distraction occurs when an object or event draws
a person’s attention away from the driving task. Unlike driver distraction, driver drowsiness
involves no triggering event but, instead, is characterized by a progressive withdrawal of attention
from the road and traffic demands. Both driver drowsiness and distraction, however, might have
the same effects, i.e., decreased driving performance, longer reaction time, and an increased risk
of crash involvement. shows the block diagram of overall system. Based on Acquisition of video
from the camera that is in front of driver perform real-time processing of an incoming video stream
to infer the driver’s level of fatigue if the drowsiness is Estimated then it will give the alert by
sensing the eyes.
Here we are used SVM (support vector machine) to classify the components in the input video.
While cropping the region of interest components in the video is not accurate. Sometimes it will
show regions wrong. To sense the eyes first we have to create boundary boxes for that and a
classification algorithm. The algorithm of SVM will not support.
There are several different algorithms and methods for eye tracking, and monitoring. Most of them
in some way relate to features of the eye (typically reflections from the eye) within a video image
of the driver. The original aim of this project was to use the retinal reflection as a means to find
the eyes on the face, and then using the absence of this reflection as a way of detecting when the
eyes are closed. Applying this algorithm on consecutive video frames may aid in the calculation of
eye closure period. Eye closure period for drowsy drivers is longer than normal blinking. It is also
extraordinarily little, longer time could result in severe crash. So, we will warn the driver as soon
as closed eye is detected.
The framework is created utilizing the incremental model. The center model of the framework is
first created and afterwards augmented in this way in the wake of testing at each turn. The
underlying undertaking skeleton was refined into expanding levels of ability.
At the following incremental level, it might incorporate new execution backing and improvement
In this Python project, we will be using OpenCV for gathering the images from webcam and feed
them into a Deep Learning model which will classify whether the person’s eyes are ‘Open’ or
‘Closed.’ The approach we will be using for this Python project is as follows:
With a webcam, we will take images as input. So to access the webcam, we made an infinite loop
that will capture each frame. We use the method provided by OpenCV, cv2.VideoCapture(0) to
access the camera and set the capture object (cap). cap.read() will read each frame and we store
the image in a frame variable.
Step 2 – Detect the face in the image and create a Region of Interest (ROI).
To detect the face in the image, we need to first convert the image into grayscale as the OpenCV
algorithm for object detection takes gray images in the input. We don’t need color information to
detect the objects. We will be using haar cascade classifier to detect faces. This line is used to set
our classifier face = cv2.CascadeClassifier(‘ path to our haar cascade xml file’). Then we perform
the detection using faces = face.detectMultiScale(gray). It returns an array of detections with x,y
coordinates, and height, the width of the boundary box of the object. Now we can iterate over the
faces and draw boundary boxes for each face.
Step 3 – Detect the eyes from ROI and feed it to the classifier.
The same procedure to detect faces is used to detect eyes. First, we set the cascade classifier for
eyes in leye and reye respectively then detect the eyes using left eye = leye.detectMultiScale(gray).
Now we need to extract only the eyes data from the full image. This can be achieved by extracting
the boundary box of the eye and then we can pull out the eye image from the frame with this code
We are using CNN classifier for predicting the eye status. To feed our image into the model, we
need to perform certain operations because the model needs the correct dimensions to start with.
First, we convert the color image into grayscale using r_eye = cv2.cvtColor(r_eye,
cv2.COLOR_BGR2GRAY). Then, we resize the image to 24*24 pixels as our model was trained on
24*24 pixel images cv2.resize(r_eye, (24,24)). We normalize our data for better convergence r_eye
= r_eye/255 (All values will be between 0-1). Expand the dimensions to feed into our classifier. We
loaded our model using model = load_model(‘models/cnnCat2.h5’) . Now we predict each eye with
our model lpred = model.predict_classes(l_eye). If the value of lpred[0] = 1, it states that eyes are
open, if value of lpred[0] = 0 then, it states that eyes are closed.
The score is basically a value we will use to determine how long the person has closed his eyes. So
if both eyes are closed, we will keep on increasing score and when eyes are open, we decrease the
score. We are drawing the result on the screen using cv2.putText() function which will display real
time status of the person.
The dataset used for this model is created by us. To create the dataset, we wrote a script that
captures eyes from a camera and stores in our local disk. We separated them into their respective
labels ‘Open’ or ‘Closed’. The data was manually cleaned by removing the unwanted images which
were not necessary for building the model. The data comprises around 7000 images of people’s
eyes under different lighting conditions. After training the model on our dataset, we have attached
the final weights and model architecture file “models/cnnCat2.h5
The model we used is built with Keras using Convolutional Neural Networks (CNN). A convolutional
neural network is a special type of deep neural network which performs extremely well for image
classification purposes. A CNN basically consists of an input layer, an output layer and a hidden
layer which can have multiple layers. A convolution operation is performed on these layers using
a filter that performs 2D matrix multiplication on the layer and filter.
The final layer is also a fully connected layer with 2 nodes. A Relu activation function is used in all
the layers except the output layer in which we used Softmax.
Webcam: -
A webcam is a video camera that feeds or streams an image or video in real time to or through a
computer network, such as the Internet. Webcams are typically small cameras that sit on a desk,
attach to a user's monitor, or are built into the hardware. Webcams can be used during a video
chat session involving two or more people, with conversations that include live audio and video.
Webcam software enables users to record a video or stream the video on the Internet. As video
streaming over the Internet requires much bandwidth, such streams usually use compressed
formats. The maximum resolution of a webcam is also lower than most handheld video cameras,
as higher resolutions would be reduced during transmission. The lower resolution enables
webcams to be relatively inexpensive compared to most video cameras, but the effect is adequate
for video chat sessions.[1]
The term "webcam" (a clipped compound) may also be used in its original sense of a video camera
connected to the Web continuously for an indefinite time, rather than for a particular session,
generally supplying a view for anyone who visits its web page over the Internet. Some of them, for
example, those used as online traffic cameras, are expensive, rugged professional video cameras.
Laptop: -
Memory: 16 GB RAM is the minimum, I repeat, the minimum. 32 GB or 64 GB is obviously better,
but most laptops don’t come with that as a standard. Check if it supports adding extra RAM. It’s
the single most important piece of hardware for data science, both for holding large datasets in
memory and running VMs. CPU: Core i7 or equivalent.
Python: -
Python is an interpreted, object-oriented, high-level programming language with dynamic
semantics. Its high-level built in data structures, combined with dynamic typing and dynamic
binding, make it very attractive for Rapid Application Development, as well as for use as a scripting
or glue language to connect existing components together. Python's simple, easy to learn syntax
emphasizes readability and therefore reduces the cost of program maintenance. Python supports
modules and packages, which encourages program modularity and code reuse. The Python
interpreter and the extensive standard library are available in source or binary form without charge
for all major platforms, and can be freely distributed.
Often, programmers fall in love with Python because of the increased productivity it provides. Since
there is no compilation step, the edit-test-debug cycle is incredibly fast. Debugging Python
programs is easy: a bug or bad input will never cause a segmentation fault. Instead, when the
interpreter discovers an error, it raises an exception. When the program doesn't catch the
exception, the interpreter prints a stack trace. A source level debugger allows inspection of local
and global variables, evaluation of arbitrary expressions, setting breakpoints, stepping through the
code a line at a time, and so on. The debugger is written in Python itself, testifying to Python's
introspective power. On the other hand, often the quickest way to debug a program is to add a
few print statements to the source: the fast edit-test-debug cycle makes this simple approach very
effective.
PlaySound: -
The playsound module contains only one thing - the function (also named) playsound.
It requires one argument - the path to the file with the sound you’d like to play. This may be a local
file, or a URL.
There’s an optional second argument, block, which is set to True by default. Setting it to False
makes the function run asynchronously.
On Windows, uses windll.winmm. WAVE and MP3 have been tested and are known to work. Other
file formats may work as well.
On OS X, uses AppKit.NSSound. WAVE and MP3 have been tested and are known to work. In
general, anything QuickTime can play, playsound should be able to play, for OS X.
On Linux, uses GStreamer. Known to work on Ubuntu 14.04 and ElementaryOS Loki. I expect any
Linux distro with a standard gnome desktop experience should work.
If you’d like other Linux distros (or any other OS) to work, submit a PR adding in support for it, but
please make sure it passes the tests
Numpy: -
NumPy, which stands for Numerical Python, is a library consisting of multidimensional array objects
and a collection of routines for processing those arrays. Using NumPy, mathematical and logical
operations on arrays can be performed. This tutorial explains the basics of NumPy such as its
architecture and environment. It also discusses the various array functions, types of indexing, etc.
An introduction to Matplotlib is also provided. All this is explained with the help of examples for
better understanding.
Dlib: -
Dlib is principally a C++ library, however, you can use a number of its tools from python
applications. This page documents the python API for working with these dlib tools. If you haven’t
done so already, you should probably look at the python example programs first before consulting
this reference. These example programs are little mini-tutorials for using dlib from python. They
are listed on the left of the main dlib web page.
Scipy: -
SciPy (pronounced /ˈsaɪpaɪ/ "sigh pie"[3]) is a free and open-source Python library used for
scientific computing and technical computing.
SciPy contains modules for optimization, linear algebra, integration, interpolation, special
functions, FFT, signal and image processing, ODE solvers and other tasks common in science and
engineering.
SciPy is also a family of conferences for users and developers of these tools: SciPy (in the United
States), EuroSciPy (in Europe) and SciPy.in (in India).[5] Enthought originated the SciPy conference
in the United States and continues to sponsor many of the international conferences as well as
host the SciPy website.
The SciPy library is currently distributed under the BSD license, and its development is sponsored
and supported by an open community of developers. It is also supported by NumFOCUS, a
community foundation for supporting reproducible and accessible science.
The SciPy package is at the core of Python's scientific computing capabilities. Available subpackages
include:
OpenCV: -
OpenCV (Open Source Computer Vision Library) is a library of programming functions mainly aimed
at real-time computer vision.[1] Originally developed by Intel, it was later supported by Willow
Garage then Itseez (which was later acquired by Intel[2]). The library is cross-platform and free for
use under the open-source Apache 2 License. Starting with 2011, OpenCV features GPU
acceleration for real-time operations.
OpenCV is written in C++ and its primary interface is in C++, but it still retains a less comprehensive
though extensive older C interface. All of the new developments and algorithms appear in the C++
interface. There are bindings in Python, Java and MATLAB/OCTAVE. The API for these interfaces
can be found in the online documentation.[12] Wrappers in several programming languages have
been developed to encourage adoption by a wider audience. In version 3.4, JavaScript bindings for
a selected subset of OpenCV functions was released as OpenCV.js, to be used for web platforms
Pygame: -
Pygame is a cross-platform set of Python modules designed for writing video games. It includes
computer graphics and sound libraries designed to be used with the Python programming language
Pygame was originally written by Pete Shinners to replace PySDL after its development stalled. It
has been a community project since 2000 and is released under the free software GNU Lesser
General Public License (which "provides for Pygame to be distributed with open source and
commercial software
Pygame uses the Simple Direct Media Layer (SDL) library,[a] with the intention of allowing realtime
computer game development without the low-level mechanics of the C programming language
and its derivatives. This is based on the assumption that the most expensive functions inside games
can be abstracted from the game logic, making it possible to use a high-level programming
language, such as Python, to structure the game.
Other features that SDL does have include vector math, collision detection, 2D sprite scene graph
management, MIDI support, camera, pixel-array manipulation, transformations, filtering,
advanced free type font support, and drawing.
Applications using Pygame can run on Android phones and tablets with the use of Pygame Subset
for Android (pgs4a). Sound, vibration, keyboard, and accelerometer are supported on Android.
Imutils: -
Imutils is a series of functions to implement basic image processing functions such as translation,
rotation, resizing, displaying Matplotlib images, detecting edges, and much more easier with
OpenCV.
To install imutils, you should already have NumPy, SciPy, Matplotlib, and OpenCV installed. To
install these modules into your python environment, run the following commands in the terminal.
The implementation uses a custom-designed Convolutional Neural Network that has the following
characteristics —
Model training runs for a total of 200 epochs with a batch size of 128. ImageDataGenerator is used
for randomizing the training images for better performance of the model.
Classification Report —
Confusion Matrix —
The implementation uses the ‘dlib’ library for face detection in the image. Face Alignment is done
using FaceAlignment class of imutils.face_utils library for better eye detection. Eye detection is
performed using Haar Cascade Classifiers.
Finally, the results can be viewed as follows —
3.4 Snapshots
Code Snippets: -
–––
Researchers have used various methods to measure driver drowsiness. This section provides a
review of the four most widely used methods, among which the first method is measured either
verbally or through questionnaire and the remaining three by means of various sensors.
Subjective measures that evaluate the level of drowsiness are based on the driver’s personal
estimation and many tools have been used to translate this rating to a measure of driver
drowsiness. The most commonly used drowsiness scale is the Karolinska Sleepiness Scale (KSS), a
nine-point scale that has verbal anchors for each step, as shown in Table 1. Hu et al. measured the
KSS ratings of drivers every 5 min and used it as a reference to the EoG signal collected. Portouli et
al. evaluated EEG data by confirming driver drowsiness through both a questionnaire and a
licensed medical practitioner. Some researchers compared the self-determined KSS, which was
recorded every 2 min during the driving task, with the variation of lane position (VLP) and found
that these measures were not in agreement. Ingre et al. determined a relationship between the
eye blink duration and the KSS collected every 5 min during the driving task.
Researchers have determined that major lane departures, high eye blink duration and
drowsinessrelated physiological signals are prevalent for KSS ratings between 5 and 9. However,
the subjective rating does not fully coincide with vehicle-based, physiological and behavioural
measures.
Because the level of drowsiness is measured approximately every 5 min, sudden variations cannot
be detected using subjective measures. Another limitation to using subjective ratings is that the
self-introspection alerts the driver, thereby reducing their drowsiness level. In addition, it is
difficult to obtain drowsiness feedback from a driver in a real driving situation. Therefore, while
subjective ratings are useful in determining drowsiness in a simulated environment, the remaining
measures may be better suited for the detection of drowsiness in a real environment.
measures. Some researchers found that sleep deprivation can result in a larger variability in the driving
speed. However, the two most used vehicle-based measures are the steering wheel movement and the
standard deviation of lane position.
Steering Wheel Movement (SWM) is measured using steering angle sensor and it is a widely used
vehiclebased measure for detecting the level of driver drowsiness [32,33,36]. Using an angle sensor
mounted on the steering column, the driver’s steering behavior is measured. When drowsy, the number of
microcorrections on the steering wheel reduces compared to normal driving. Fairclough and Graham found
that sleep deprived drivers made fewer steering wheel reversals than normal drivers. To eliminate the effect
of lane changes, the researchers considered only small steering wheel movements (between 0.5° and 5°),
which are needed to adjust the lateral position within the lane. Hence, based on small SWMs, it is possible
to determine the drowsiness state of the driver and thus provide an alert if needed. In a simulated
environment, light side winds that pushed the car to the right side of the road were added along a curved
road in order to create variations in the lateral position and force the drivers to make corrective SWMs. Car
companies, such as Nissan and Renault, have adopted SWMs but it works in very limited situations. This is
because they can function reliably only at particular environments and are too dependent on the geometric
characteristics of the road and to a lesser extent on the kinetic characteristics of the vehicle.
Standard Deviation of Lane Position (SDLP) is another measure through which the level of driver drowsiness
can be evaluated. In a simulated environment, the software itself gives the SDLP and in case of field
experiments the position of lane is tracked using an external camera. Ingre et al. conducted an experiment
to derive numerical statistics based on SDLP and found that, as KSS ratings increased, SDLP (meters) also
increased. For example, KSS ratings of 1, 5, 8, and 9 corresponded to SDLP measurements of 0.19, 0.26, 0.36
and 0.47, respectively. The SDLP was calculated based on the average of 20 participants; however, with
some drivers, the SDLP did not exceeded 0.25 m even for a KSS rating of 9. In the above experiment by
performing correlation analysis on a subject-to-subject basis significant difference is noted. Another
limitation of SDLP is that it is purely dependent on external factors like road marking, climatic and lighting
conditions. In summary, many studies have determined that vehicle-based measures are a poor predictor
of performance error risk due to drowsiness. Moreover, vehicular-based metrics are not specific to
drowsiness. SDLP can also be caused by any type of impaired driving, including driving under the influence
of alcohol or other drugs, especially depressants
rise, lip stretch, jaw drop and eye blink, to detect drowsiness. However, research on using other behavioral
measures, such as yawning and head or eye position orientation, to determine the level of drowsiness is
ongoing.
CHAPTER-4
Many Deep Learning projects get delayed because due attention is not paid to managing the
dependencies across the various teams. The project plan must take into consideration the
crossteam dependencies when setting start and end dates for each deliverable. It is also crucial to
break a ‘user story” into as many meaningfully small pieces as possible. This will ensure that
progress can be shown on a weekly basis rather than having to wait for a full month (or more)
before showing any progress.
4.2 Observation
One of the challenges in developing an efficient drowsiness detection system is how to obtain
proper drowsiness data. Due to safety reasons, drowsiness cannot be manipulated in a real
environment; thus, the drowsiness detection system must be developed and tested in a laboratory
setting. However, in a laboratory setting, the most reliable and informative data that pertains to
driver drowsiness relies only on the way in which the driver falls into the drowsy state.
Driver drowsiness mainly depends on: (i) the quality of the last sleep; (ii) the circadian rhythm (time
of day) and (iii) the increase in the duration of the driving task [11,26,27]. In some research
experiments, the subjects were fully deprived of sleep, whereas they were only partially deprived
of sleep-in others . In addition, some researchers recruited night shift workers as their subjects; in
these cases, the subjects were totally deprived of sleep because the experiments were conducted
in the morning . Kokonozi et al. conducted an experiment in which they monitored the participants
for 24 h before the experiment began to ensure that they were completely sleep-deprived. In
certain experiments, researchers partially deprived the subjects of sleep by allowing them to sleep
for less than 6 h. Peters et al. studied the same subjects during four consecutive days and
considered the effects of no sleep deprivation, partial sleep deprivation and total sleep deprivation
on their drowsiness level. They observed that, even in the case of partial sleep deprivation, the
subjects tend to get drowsy after some time. Hence, the quality of the last sleep is an important
criterion that influences drowsiness.
The performance of the driver deteriorates when physiological activity diminishes. A circadian
rhythm is used to refer to any biological variations or rhythms that occur in a cycle of approximately
24 h. These rhythms are self-sustaining (i.e., free running) and will persist even when the organism
is placed in an environment devoid of time cues, such as constant light or constant darkness.
Recent statistics from countries such as the United Kingdom, the United States, Israel, Finland, and
France indicate that an increased number of vehicle accidents caused by driver drowsiness
occurred during the peak drowsiness periods of 2:00 am to 6:00 am and 2:00 pm to
4:00 pm. During these time frames, the circadian rhythm shows higher chance of getting drowsy
and drivers are three times more likely to fall asleep at these times than at 10:00 am or at 7:00 pm.
Liu et al. pointed out that the circadian rhythm produces small, but significant, changes in vehicle-
based measures. Researchers have asked subjects to drive between 2:30 pm and 5:30 pm in order
to monitor drowsiness by measuring eyelid movement, ECG and EEG.
The duration of the driving task also plays a major role in influencing drowsiness. Otamani et al.
found that sleep deprivation alone does not directly influence the brain signals that control
drowsiness, whereas the duration of task has a strong influence. Researchers have also inferred
that prolonged driving on a monotonous environment stimulates drowsiness. In fact, it has been
observed that the subjects can become drowsy within 20 to 25 min of driving. This last finding,
reported by Philip et al., contradicts the observation made by Thiffault et al. that, in a real
environment, the duration of the drive does not impact the performance during the first two hours.
In addition, researchers have found that drowsiness-related crashes are more probable in a
monotonous environment than in a stimulating environment.
Therefore, there is a very high probability that a partially sleep-deprived driver will become drowsy
when driving in a monotonous environment at a constant speed for three hours during a time
when their circadian rhythm is low. This should be taken into consideration when designing an
experiment relating to recording driver drowsiness.
• safety system. To develop such a system, we need to estimate the condition of the driver
at wheel. The following is a concise description of the papers surveyed.
• The following is a concise description of the papers surveyed. The paper presents an
arithmetic-based method to solve the problem related to the detection of drowsiness.
Three stages were involved. They are Face detection, Eye position detection and Eye
tracking. This paper provides an efficient method for the detection of the state of the driver.
This framework uses the motion of the eyes to detect the state of the driver and gives an
alert within 0.5 seconds. The performance of the driver is transcribed in the form of a graph.
A new method for fatigue detection is presented. YCbCr colour space and canny edge
detection methods are used. These methods are used to determine if the driver is under
fatigue. When the driver is drowsy, an alarm system is turned on. A distinct system which
focuses on the concept of computer vision is designed. A software algorithm is developed.
This algorithm is partially tested and is found to be working effectively. Research is in
progress in order to develop a full-blown system. The developed system is capable in
identifying the state of drowsiness quickly. The system can differentiate between normal
eye blink and the eye blink associated with drowsiness. It can perform under low light
conditions and when the driver is wearing spectacles. This can further be developed by
adding different sensors. The developed system is based on computer vision. The system
utilizes Viola Jones algorithm as well as the CAMSHIFT algorithm. This paper is concerned
with the development of a software framework for the timely and precise detection of
drowsiness. Multiple facial features were considered as inputs. The paper proposes a
method for detecting the drowsy state based on the time-series analysis of the angular
velocity of the steering wheel. When compared with the traditional method, this method
provides a series of advantages. It groups drowsiness detection techniques into two kinds.
They are
• driver based and vehicle based. It also provides a survey of numerous driver and
vehiclebased techniques. A drowsiness detection system which is dependent upon an
algorithm known as shape predictor algorithm and eye blink rate is developed. It is based
on the concept of image processing. The system provides a non-invasive approach. This
system also proposes the incorporation of yawning as a parameter to detect drowsiness.
In order to estimate a driver’s condition, certain facial features were identified. Using
python libraries, they were examined. These features were rate of eye closure, ECD, per
closure, head positions and rate of yawning. Certain limitations were also highlighted
• A safe work method statement (SWMS) must be prepared for all high-risk construction
projects, before work commences. The SWMS should outline the scope of work involved,
any potential safety issues, and how risks will be prevented and managed. By law,
construction work must not commence until SWMS standards are met.
• Restricted site access should not only be put in place to simply protect equipment from
damage or theft. Security in and outside of work hours is integral to protect pedestrians
from potential construction hazards. This includes supervision or authorised site visitors.
Strict security and safety protocols will also protect contractors from liability and
negligence in the case of a safety incident or security breach
• A safe work method statement (SWMS) must be prepared for all high-risk construction
projects before work commences. The SWMS should outline the scope of work involved,
any potential safety issues, and how risks will be prevented and managed. By law,
construction work must not commence until SWMS standards are met
• The site SWMS should be clearly displayed at the construction site, so that all safety
protocols are readily available - including a 24-hour emergency contact number and a map
or directions to the site office. Visible signage should also indicate site amenities (such as
toilets), entry and exit points, and first aid or emergency fire equipment
• Separate entry and exit points should be established for heavy machinery/vehicle access,
to strengthen pedestrian safety at high traffic points
4.4 Maintenance
The execution and control phase of a project encompasses kicking off the project, monitoring and
control, quality and deliverable acceptance, issues and change management, and finally meetings,
reviews and reporting. Although all aspects of the execution and control phase are equally
important, the main focus often falls on the deliverable. For a client to accept the deliverable, it
must meet his expectations for both quality and scope. Therefore, precise monitoring and control
are required.
Depending on the nature of the project, the project manager will be responsible for monitoring
and controlling the project. Some of the factors they may be responsible for could include schedule
actuals (start, finish and milestone dates), cost actuals versus budget constraints, and effort and
resource actuals. The detail and frequency of monitoring updates should be determined up front
with the frequency likely to vary during the project.
Several tools are available that can help the project manager communicate what is being
monitored to the client. Performance curves, Gantt charts and any other visual methods are useful
to avoid misinterpretation of the data.
5 Future Scope
• The model can be improved incrementally by using other parameters like blink rate,
yawning, state of the car, etc. If all these parameters are used it can improve the accuracy
by a lot.
• We plan to further work on the project by adding a sensor to track the heart rate to prevent
accidents caused due to sudden heart attacks to drivers.
• Same model and techniques can be used for various other uses like Netflix and other
streaming services can detect when the user is asleep and stop the video accordingly. It can
also be used in application that prevents user from sleeping
6 Conclusion
In this paper, we have reviewed the various methods available to determine the drowsiness state
of a driver. Although there is no universally accepted definition for drowsiness, the various
definitions and the reasons behind them were discussed. This paper also discusses the various
ways in which drowsiness can be manipulated in a simulated environment. The various measures
used to detect drowsiness include subjective, vehicle-based, physiological and behavioral
measures; these were also discussed in detail and the advantages and disadvantages of each
measure were described. Although the accuracy rate of using physiological measures to detect
drowsiness is high, these are highly intrusive. However, this intrusive nature can be resolved by
using contactless electrode placement. Hence, it would be worth fusing physiological measures,
such as ECG, with behavioral and vehicle-based measures in the development of an efficient
drowsiness detection system. In addition, it is important to consider the driving environment to
obtain optimal results.
7 References
• For Python installation
https://www.python.org/downloads/
• Reference websites
http://ncrb.gov.in/StatPublications/ADSI/ADSI2015/chapter1A%20traffic%20
accidents.pdf
http://www.jotr.in/text.asp?2013/6/1/1/118718
http://dlib.net/face_landmark_detection_ex.cpp.html
https://data-flair.training/blogs/python-project-driver-
drowsinessdetectionsystem/
• Reference Books