0% found this document useful (0 votes)
177 views63 pages

Driver Drowsiness Detection System Final Draft

This document describes a driver drowsiness detection system using image processing with OpenCV. The system aims to reduce road accidents caused by drowsiness by detecting when a driver's eyes are closed or open in real-time using a machine learning model. It uses the Haar Cascade algorithm and OpenCV library to monitor a video feed of the driver and detect the eyes. Eye aspect ratio is calculated to determine if the eyes are open or closed. A Raspberry Pi with camera module simulates the system in a vehicle to alert the driver when drowsiness is detected.

Uploaded by

Tanatswanashe
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
177 views63 pages

Driver Drowsiness Detection System Final Draft

This document describes a driver drowsiness detection system using image processing with OpenCV. The system aims to reduce road accidents caused by drowsiness by detecting when a driver's eyes are closed or open in real-time using a machine learning model. It uses the Haar Cascade algorithm and OpenCV library to monitor a video feed of the driver and detect the eyes. Eye aspect ratio is calculated to determine if the eyes are open or closed. A Raspberry Pi with camera module simulates the system in a vehicle to alert the driver when drowsiness is detected.

Uploaded by

Tanatswanashe
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 63

DRIVER DROWSINESS DETECTION SYSTEM BY IMAGE

PROCESSING USING OPEN CV

By

TANATSWANASHE KADZVITI (R184576Y)

Submitted in partial fulfilment for the degree of

BSc (Hons) Telecommunications Engineering


Department of Applied Physics & Telecommunication in the Faculty of
Science and Technology
Midlands State University
Gweru, Zimbabwe
April 2021
HTENG 438 Dissertation
Mr Mafukidze
Abstract

Road crashes are the most common cause of accidents and deaths worldwide, and the
major causes of these accidents are usually intoxication, drowsiness, and reckless
driving. According to the World Health Organization, the number of road traffic
injuries has risen to 1.25 billion worldwide, making driver drowsiness detection a
critical issue.

Potential area for reducing the number of sleep-related road accidents. This project
proposes a method for detecting drowsiness using machine learning. As a result of the
learning algorithms, the driver is alerted in real-time to avoid a collision The Haar
Cascade algorithm is used in the model. in conjunction with the OpenCV library to
monitor real-time video of the driver, as well as to detect the driver's eyes The system
makes use of The concept of Eye Aspect Ratio (EAR) is used to determine whether or
not the eyes are open or it is closed. We also feed a data-set file containing the facial
images. To train the machine learning algorithm, features data-points are used. The
model inspects each frame of the video, which aids in determining the driver's state.
In addition, a Raspberry Pi single-board computer a computer with a camera module
and an alarm system assists the project in simulating a compact drowsiness detection
system adaptable to a variety of automobiles.

Keywords: Raspberry pi, Eye tracking, Driver, camera, buzzer, drowsiness

DRIVER DROWSINESS DETECTION SYTEM I


Declaration
I, Tanatswanashe Kadzviti hereby declare that I am the sole author of this thesis. I
authorise the Midlands State University to lend this to other individuals and
institutions for the purpose of scholarly research.

Signature………………………………… Date……3 May 2022…………………….

DRIVER DROWSINESS DETECTION SYTEM II


Approval

This dissertation /thesis titled “Driver Drowsiness Detection System by Image


Processing and Open CV” by Tanatswanashe Kadzviti meets the regulations
governing the award of the degree of BSc (Hons) Telecommunications Engineering of
the Midlands State University, and is approved for its contribution to knowledge and
literal presentation.

Supervisor ……………………………………………………

Date …… 3 MAY 2022……………………………………………………..

DRIVER DROWSINESS DETECTION SYTEM III


Dedication

This work is a fruit of countless and arduous sacrifices. Through the researchers effort
this work is heartily and proudly dedicated to the people who save as an inspiration
from my parents brother and the circle of colleagues who extended their help in the
midst of problems while doing this work. .May the dear Lord bless you abundantly.
“ If you keep doing what you are doing, you keep getting what you are getting”

DRIVER DROWSINESS DETECTION SYTEM IV


Acknowledgements
The project of this amplitude could not have progressed without intense dedication,
love, sacrifice and grace. My undying gratitude is credited to the Almighty God who
gave me the opportunity to carry out this research of vibrant magnitude.
 Supervisor Mr Mafukidze and The Chairperson of the Department of Applied
Physics & Telecommunications for his assistive effort and supervision
throughout this research.
 My Dad, Mom and Brother
 My siblings and fellow colleagues for the love, support and motivation

DRIVER DROWSINESS DETECTION SYTEM V


Table of Contents
CHAPTER 1 .............................................................................................................................................. 1
INTRODUCTION .....................................................................................................................................1
1.1. Background .................................................................................................................................1
1.2. Research scope and Aim ............................................................................................................ 2
1.2.1. Research aims and objectives ..................................................................................................3
1.2.2. Dissertation Structure .............................................................................................................. 3
REFERENCES .......................................................................................................................................... 5
CHAPTER 2 .............................................................................................................................................. 6
LITERATURE REVIEW ..........................................................................................................................6
2.1. Introduction ................................................................................................................................ 6
2.2. BACKGROUND ........................................................................................................................6
2.2.1. Fatigue ..................................................................................................................................... 6
2.3. PERCLOS (Percentage of Eye Closure) .................................................................................... 7
2.4. PERCLOS (Percentage of Eye Closure) .................................................................................... 7
2.4.1. Electroencephalography (EEG) for Drowsiness Detection ..................................................... 8
2.4.2. Local Binary Patterns ............................................................................................................... 9
2.4.3. Steering Wheel Movement ................................................................................................... 10
2.4.4. Yawning Detection Method .................................................................................................. 10
2.5. Drowsiness detection by Face Recognition( Image Processing) ..............................................11
2.6. Facial Recognition ....................................................................................................................12
2.7. Raspberry Pi ............................................................................................................................. 16
2.8. Pi Camera Module ....................................................................................................................17
Pin Description ........................................................................................................................................ 18
2.9. Active Passive Buzzer .............................................................................................................. 19
2.10. Viola Jones Face Detection Algorithm ...................................................................................20
REFERENCES ........................................................................................................................................ 22
CHAPTER 3 ............................................................................................................................................24
METHODOLOGY .................................................................................................................................. 24
3. Introduction ................................................................................................................................. 24
3.1.1. Research Methodology ..........................................................................................................24
3.1.2. Physiological Level Approach .............................................................................................. 24
3.1.3. Behavioral Based Approach .................................................................................................. 25
3.1.4. Vehicle Based Approach ....................................................................................................... 25
3.1.5. Background of Study .............................................................................................................25
3.1.6. Literature Review .................................................................................................................. 26
3.1.7. Previous data Gathering Analysis ......................................................................................... 26
3.1.8. Algorithm Design and Development .....................................................................................26
3.1.8.1. Viola Jones Face Detection Algorithm ...............................................................................26
3.1.8.2. Cascade of Classifiers .........................................................................................................28
3.1.9. Analysis and Testing ............................................................................................................. 29
3.2. Structure of the Overall System ............................................................................................... 29
3.2.1. Technologies of Use .............................................................................................................. 30
3.2.2. Tensor Flow ...........................................................................................................................30
3.2.3. Machine learning ................................................................................................................... 30
3.2.4. Open CV ................................................................................................................................30
3.3. System Description ...................................................................................................................31
3.3.1. Recognition of Eyes state ...................................................................................................... 33
3.3.2. Eye Aspected Ratio Calculation ............................................................................................33
3.3.3. Eye State Determination ........................................................................................................34
3.3.4. Drowsiness Detection ............................................................................................................34
3.4. Conclusion ................................................................................................................................ 35
REFERENCE SYSTEM ......................................................................................................................... 36
CHAPTER 4 ............................................................................................................................................38
RESULTS AND ANALYSIS ................................................................................................................. 38

DRIVER DROWSINESS DETECTION SYTEM VI


4. Introduction .................................................................................................................................38
4.1. Project Progress ........................................................................................................................38
4.2. Results Presentation .................................................................................................................39
4.3. System Overview ...................................................................................................................... 42
4.4. LIMITATIONS .............................................................................................................................44
4.5. Conclusion ................................................................................................................................ 45
CHAPTER 5 ............................................................................................................................................47
CONCLUSIONS AND DISCUSSIONS .................................................................................................47
5. Introduction .................................................................................................................................47
5.1. Summary Of Driver Drowsiness Detection System. ................................................................. 47
5.2. Project Achievements. ..............................................................................................................47
5.3. Challenges Faced ...................................................................................................................... 48
5.4. Recommendations ....................................................................................................................48
APPENDIX A ......................................................................................................................................... 49
MICROCONTROLLER CODE ..............................................................................................................49
ALGORITHM ......................................................................................................................................... 49
break .................................................................................................................................... 51

DRIVER DROWSINESS DETECTION SYTEM VII


CHAPTER 1
INTRODUCTION

1.1.Background

Drowsy driving is amongst the leading causes of fatal car accidents. According to a
recent study, one out of every five road accidents is caused by drowsy driving,
accounting for roughly 21 percent of all road accidents, and this percentage is
increasing year after year, according to the global status report on road safety 2015,
which is based on data from over 160 different countries. It is undeniably true,
highlighting the fact that the total number of road traffic deaths worldwide is very
high due to driver drowsiness. Driver fatigue, drunk driving, and carelessness are
cited as major causes of such road accidents. Many lives and families were lost.

Various countries are being impacted as a result of this. One of the most effective
majors that can be used is real-time drowsy driving detection can be used to help
drivers become aware of drowsy driving conditions. [10]This type of driver
behavioral state detection system can assist in catching. However, ocular
measurement can be performed without a physical connection. Since it can detect the
eye's open/closed state non intrusively by the use of a camera, an ocular measure for
detection of the drivers eye condition and possible vision based on eye closure are
well suited for real-world driving conditions. [8]In a real-time driver drowsiness
system based on image processing, the eye state of the driver is captured using
computer vision.

[10]Drowsiness detection systems have been developed by analyzing the interval


between eye closures and development of an algorithm to detect the occurrence of
drowsiness. driver's drowsiness in advance and warn the driver through the vehicle's
alarm. This section explains how faces are detected and how. [10]Eye detection is
used in automotive applications and is required for determining driver drowsiness.

[9]Drowsy or fatigued driving is a condition in which drivers are tired and exhausted
but continue to drive their vehicle. Driving in a fatigued state can impair the driver's
attention span. and also the vehicles around. For those with less build-up sleep debt,
or not enough sleep, fatigue can impair reaction time and decision making when one

DRIVER DROWSINESS DETECTION SYSTEM USING OPEN CV 1


is behind the wheel which will increase the risk of being involved in an accident.
When a driver falls asleep or looks down not keeping the head straight for just four
seconds while traveling at a speed of 100km/h the vehicle would have traveled 111
meters without control of the driver. People at risk are Heavy vehicle drivers, drivers
with sleep disorders, young drivers who operate phones, radios during driving.

[5]The Computer Vision method is the most feasible method for a Driver's
Drowsiness Detection System. It is because it does not rely on any outside factor that
might cause a false positive. Neither does it necessitate any physical connections with
the driver and could divert the driver's attention. The computer vision domain makes
use of a number of machine learning algorithms to ascertain drowsiness, for example,
the Support Vector Machine (SVM)[3]. An algorithm for classifying objects by
separating data items.[6][8][9] Using a dataset, it detects the eyes and other facial
features. However, it produces less accurate results and has a higher error rate.
particularly in large or noisy datasets. Another algorithm of this type is the model of
Convolutional Neural Networks (CNN), which utilizes neural networks to detect
drowsiness mimic the operation of the human brain on a computer [4, 5].

[5] It proves to be extremely accurate, but it also necessitates a device is needed for
detection of a significant feature of the driver’s face to indicate the fatigue level and
wake the driver. The device should be able to detect the eyes of the driver if is seeing
the road as well as if the driver is awake. In case the driver is drowsy or has lost focus
operating the radio that the driver can not see where he/she is driving to, the system
should be able to alert the driver.

1.2. Research scope and Aim

This chapter holds the vital content of this research subject by giving exact and
satisfactory advancement, points, and purpose of this research. It likewise extends a
sound result of this examination through objectives and aims.

DRIVER DROWSINESS DETECTION SYSTEM USING OPEN CV 2


1.2.1. Research aims and objectives

The design aims to ensure that drivers are assisted during driving and accidents by
lack of concentration are reduced. the driver is alerted when they start to doze off or
close their eyes. There will be a reduction in accidents and deaths caused by driver
error. To design a cost-effective and compatible system that benefits drivers during
driving. To build a system that alerts the driver when they are losing focus by not
looking on the road and alerts the driver when they are sleeping whilst driving. To
build a system that is reliable and convenient to the user. The goals of the project are
as shown below

 To take an image from the camera as input

 To detect a face from the image and creation of a region of interest

 To detect eyes from the Region of Interest (ROI).

 To detect fatigue by an eye blink.

 To alert the driver when he/she loses focus either by sleeping.

 To regain consciousness and full attention of drivers.

 To reduce road accidents caused by fatigue.

 Improve the safety of driving on roads

1.2.2. Dissertation Structure

The dissertation is sorted as follows-:

Chapter 1-This part gives a completely clear picture and outline of the project. It
gives the issue explanation, point and goals, project scope, and the forecast to offer a
more clear course of the project.

Chapter 2- The Chapter provides detailed analysis, literature review, and theoretical
analysis of the instruments used in this research. The instruments include Pi Camera,

DRIVER DROWSINESS DETECTION SYSTEM USING OPEN CV 3


Raspberry module, open cv, a buzzer, and any other sources of information referenced
to support this project.

Chapter 3: The chapter states the methodology used, systems design, the interfacing
of components, the data collection methods, and procedures

Chapter 4- The chapter presents the gathered outcomes, the tuning strategies utilized,
and an investigation of the outcomes, difficulties, choices, and solutions used are
unmistakably stated.

Chapter 5- The chapter concludes and gives a recommendation as clearly described in


this chapter. Suggestions for additional review are given in this part.

DRIVER DROWSINESS DETECTION SYSTEM USING OPEN CV 4


REFERENCES
[1] Krajewski J, Sommer D, Trutschel U, Edwards D, Golz M. Steering wheel
behavior based estimation of fatigue. The fifth international driving symposium on
human factors in driver assessment, training and vehicle design 2009;118-124.
[2] K. Fagerberg. Vehicle-based detection of inattentive driving for integration in an
adaptive lane departure warning system Drowsiness detection, M.S. thesis, KTH
Signals Sensors and Systems, Stockholm, Sweden, 2004
[3] Savas, B. K., & Becerikli, Y. (2018). Real Time Driver Fatigue Detection Based
on SVM Algorithm. 2018 6th International Conference on Control Engineering &
Information Technology (CEIT). doi:10.1109/ceit.2018.8751886.
[4] Danisman T, Bilasco IM, Djeraba C, Ihaddadene N. Drowsy driver detection
system using eye blink patterns. Machine and Web Intelligence (ICMWI) IEEE
2010;230-233.
[5] Donahue J, Anne Hendricks L, Guadarrama S, Rohrbach M, Venugopalan S,
Saenko K, Darrell T. Long-term recurrent convolutional networks for visual
recognition and description. IEEE conference on computer vision and pattern
2015;2625-2634.
[6] I. Garcia, S. Bronte, L. M. Bergasa, J. Almazan, J. Yebes, “Vision-based
Drowsiness Detector for Real Driving Conditions”. In Intelligent Vehicles
Symposium, pp. 618-623, June 2012.
[7] Driver State Sensor developed by seeingmachines Inc. Available from:
http://www.seeingmachines.com/product/DSS. [ 20 November 2013].
[8] Yu-Shan Wu, Quen-Zong Wu, Ting-Wei Lee, Heng-Sung Liu, “An Eye State
Recognition Method for Drowsiness Detection”. In Vehicular Technology Conference,
pp. 1-5, 2010.
[9] Marco Javier Flores, Jose Maria Armingol, Arturo de la Escalera, “RealTime
Warning System for Driver Drowsiness Detection Using Visual Information”, Dec.
2009.
[10] Tapan Pradhan, Ashutosh Nandan Bagaria, Aurobinda Routray, “Measurement
of PERCLOS using Eigen-Eyes”, 4th International Conference on Intelligent Human
Computer Interaction, pp. 1-4, Dec. 2012.

DRIVER DROWSINESS DETECTION SYSTEM USING OPEN CV 5


CHAPTER 2

LITERATURE REVIEW

2.1. Introduction

The automobile industry is currently on the rise all over the world. As a result, the
number of vehicles on the road is increasing at an exponential rate, which has
exacerbated the problem of increased road accidents. In each country, there has been
an increase in the number of road accidents. Road Accidents have proven to be a
significant threat and reduced the general public's safety, let alone the driver's.

The World Health Organization stated in their Global Status Report on Road Safety,
distinguished sleepiness, liquor addiction, and inconsiderateness as critical reasons for
street mishaps. Subsequently, the fatalities and related costs represent a genuine
danger to families from one side of the planet to the other. The ongoing drowsiness
identification strategies are not generally utilized because of their significant expense
and restricted accessibility, making them unsatisfactory for use in the norm or non-
extravagance vehicles.

Along these lines, there is a developing requirement for a brilliant and reasonable
drowsiness identification framework that the various vehicles in the business can
rapidly adjust. The fields of AI and computerized reasoning have made various earth-
shattering advances, which utilize various algorithms to train the framework to be
brilliant and independent.

2.2. BACKGROUND

2.2.1. Fatigue

"Fatigue" in step with the Merriam-Webster Dictionary. is described as "exhaustion or


weariness from exertion, stress or labor" or "the brief lack of electricity to reply this is
caused in a sensory receptor or motor cease organ through continued stimulation".
This feeling of tiredness and sleepiness may be triggered by many factors along with

DRIVER DROWSINESS DETECTION SYSTEM USING OPEN CV 6


stress, napping disorders, more working hours, own circle of relatives duties, and
more. Sleeping is a crucial part of all human beings, the urge to fall asleep will
become greater while a person is compelled to restrain the sensation of sleepiness, 10
NCSDR/NHTSAA study on eye blinks in every day and fatigue state. P. Caffier et al
[17] it is proven that the eye-blink parameters are divided into blink period which
incorporates a final time of eyelids and the reopening time. On average, the blink
period of a normal person is 202.25ms whilst the blink period of a fatigued person
will increase by approximately 50ms. The final time and the reopening time of a
fatigued person also take longer in comparison to an everyday alert man or woman.
Such parameters are used for observation of the fatigue stage amongst drivers.

2.3. PERCLOS (Percentage of Eye Closure)

According to the National Sleep Foundation's Sleep in America poll on 2005 [11]
National Sleep Foundation. approximately 60% of Americans have experienced
driving whilst feeling sleepy, whilst the other 36% have admitted to have fallen asleep
whilst driving. This disturbing figure is obvious proof that drowsiness and fatigue are
affecting drivers nowadays. Society is being fed with precautions not to operate
machinery or drive under when intoxicated. However, people do not put into
consideration [5] that fatigue also can contribute to road carnage. This is due to the
fact that tiredness or fatigue will lessen the response time, attention, and attentiveness
of a person who is undertaking activities that are need full attention, in this case, using
motor vehicles. This will similarly result in slower, poor judgment and decision-
making, [12]The Royal Society For The Prevention of Accidents.

2.4. PERCLOS (Percentage of Eye Closure)

Drowsiness is caught by identification of the eye flickers [5] D. Liu et al and


(PERCLOS) the level of eye conclusion. For identification of eye blinks, propose a
technique that learns the example of the length of the eyelid shut. As indicated by T.
Danisma et al, the proposed technique estimates the ideal opportunity for an
individual shut their eyes and on the off chance that they are shut longer than the

DRIVER DROWSINESS DETECTION SYSTEM USING OPEN CV 7


ordinary eyeblink time, the individual might nod off. In [3], the author referenced that
almost 310.3ms is the typical season of ordinary individual eye blink.

PERCLOS technique recommends that drowsiness is estimated by rate computation


of the eyelid hangs F. Dinges and R. Effortlessness,". Sets of eyes open and eyes shut
are put away in the product libraries to be used as a component to recognize whether
the eyes are completely shut or completely open. For the eyelid to droop, it occurs in a
lot more slow time as the individual is gradually nodding off. Consequently, the
change over of the driver's drowse can be recorded. Along these lines, PERCLOS
technique puts a corresponding worth where when the eyes are 80% shut, which is
almost completely shut, it expects that the driver is sluggish [2] and [12]S. T. Lin, The
technique is positive to use progressively driving as the need might arise to fix the
limit worth of enlightening for the PERCLOS strategy to precisely work. The two
techniques to distinguish drowsiness utilizing an eye flicker design and PERCLOS
have a comparative issue where the camera should be situated at a specific point to
get a decent image of the video without really any interruption of the eyebrow and the
shadows that cover the eyes.

2.4.1. Electroencephalography (EEG) for Drowsiness Detection

Fig 2.1 Examples of EEG Data Collecting

DRIVER DROWSINESS DETECTION SYSTEM USING OPEN CV 8


(EEG)Electroencephalography is a technique to quantify the cerebrum's electrical
movement. As displayed in Figure 2.1 , it very well might be utilized to quantify the
eye-flicker, heartbeat and, surprisingly, major actual body developments like head
development. It very well may be utilized on people or creatures as subjects to get
cerebrum movement. There is the utilization of particular equipment that places
sensors around the head to detect any electrical cerebrum movement.

The figure shows Examples of EEG Data Collecting A. Picot, 7 Authors in B. T. Jap
et al, referenced that the carried out technique by the previous specialist to notice
indications of sluggishness, the EEG strategy is appropriate for use for exhaustion and
sleepiness identification. In the technique, EEG has 4 sorts of recurrence parts that
might be investigated, theta (θ), beta (β), alpha (α) and delta (δ). At the point when
there are an expansion in power in alpha (α) and delta (δ) recurrence groups, it shows
that the driver is encountering exhaustion and drowsiness[4]B. T. Jap, The
disadvantage of the technique is that it is very commotion delicate to regions around
the sensors. For example, when one is attempted an EEG explore, the encompassing
regions should be absolutely quiet. The commotion slows down the sensors that are
for cerebrum movement identification. The other inconvenience of this technique is
that, regardless of whether the outcome might be precise, it is can not be qualified for
use in genuine driving applications [10]. Think about it when somebody is driving and
is wearing something on the head brimming with wires and when the driver moves
their head, the wire could take off from its place. However it isn't advantageous to be
utilized for continuous driving it is probably the best technique such a long ways for
analyze purposes and information assortment [2].

2.4.2. Local Binary Patterns

Local Binary Patterns(LBPs) have stimulated expanding interest in picture handling


and PC vision. As a nonparametric technique, LBP sums up neighborhood designs of
pictures proficiently by contrasting every pixel and its adjoining pixels. The main
properties of LBP are its resistance with respect to monotonic enlightenment changes
furthermore, its computational straightforwardness. [11]This procedure is for the most
part utilized for distinguishing feelings on the face like satisfaction, bitterness, fervor,
and so forth. LBP (Local Binary Pattern) is utilized in sluggishness identification for

DRIVER DROWSINESS DETECTION SYSTEM USING OPEN CV 9


distinguishing the face of the driver, it partitions the picture into four quadrants then
the top and base part are detected. The figure below shows LBP extricate the picture
from the video then the picture is partitioned into blocks after that LBP histograms are
produced from each square, and highlight histograms are formed[14] Figure Shows
the LBP procedure.

2.4.3. Steering Wheel Movement

Measured utilizing a controlling point sensor and it is a generally utilized vehicle-


based measure for distinguishing the degree of driver drowsiness[9]. Utilizing a point
sensor mounted on the controlling segment, the driver is estimated to control conduct.
When drowsy, the number of miniature rectifications on the controllings wheel
diminishes contrasted with ordinary driving. Leave of absence and Graham observed
that sleepless drivers made less controlling wheel inversions than ordinary drivers. To
dispense with the impact of path changes, the specialists thought about as it were
little controlling wheel developments (somewhere in the range of 0.5° and 5°), which
are expected to change the horizontal situation inside the path. This shows the SWM-
based identification. [8]As a general rule, controlling way of behaving is impacted by
attributes of the driving undertaking (for example speed, ebb and flow, and pathwidth),
driver characteristics (for example driving experience), and driver states (for example
carelessness, interruption, or exhaustion). Drivers are continually making a decision
about the circumstance ahead and applying little, smooth, controlling changes in
accordance with the right for little street knocks and crosswinds by turning the
controlling wheel in little increases[13].

2.4.4. Yawning Detection Method

As indicated by [12] M. Saradadevi and P. Bajaj, states that the drowsiness of an


individual might be viewed by looking at their direct and confront. The author
proposes a procedure wherein sleepiness might be distinguished through mouth
situating and the photos handled using the cascade of the classifier proposed by Viola-
Jones for faces. The photos are correlated with the arrangement of pictures data for
the mouth and yawning [10]. Certain individuals close their mouths through their
palms while yawning. It is an impediment to get exact pictures on the off chance that
somebody shuts their mouth while yawning, but yawning means that somebody has

DRIVER DROWSINESS DETECTION SYSTEM USING OPEN CV 10


drowsiness and exhaustion. The figure is the case of the yawning identification
procedure used in the investigations. In certain investigations and the predominant
strategies, this adventure recommends that the eyes and yawning identification
procedure might be utilized. Length of the eye flicker offers the data that after an
individual shuts their eyes for a really long time, they'll be thought-about to be
sluggish. At the point when one is in a drowsy state, eyes might be shut longer than
the customary eye flicker. Other than that, yawning is one of the signs and side effects
of drowsiness that is an ordinary response for a languid or exhausted. person.

2.5. Drowsiness detection by Face Recognition( Image Processing)

The most reasonable technique for a Driver Drowsiness Detection System amongst
the three, as mentioned above, is the Computer Vision strategy. This technique neither
depends on any outside factors that could prompt an inaccurate positive nor does it
need any actual associations with the driver and could distract the driver.
The Computer vision space utilizes an assortment of AI calculations to decide
sluggishness, similar to the Support Vector Machine (SVM) calculation, it
characterizes objects by isolating information things Savas, B. K., and Becerikli, Y.
The framework distinguishes the eyes and other facial highlights by the utilization of
a dataset however it gives less precise outcomes and has a higher mistake rate,
particularly in uproarious or enormous datasets. Another comparative calculation is
the Convolutional Neural Networks (CNN) model, which completes drowsiness
identification by utilizing brain networks that reproduce the working of the human
cerebrum on a PC, Donahue J et al. [7]. It ends up being more precise however it
additionally requires a very high computational expense and an enormous dataset to
prepare the model because of which it isn't the best appropriate for the drowsiness
identification framework.
Another critical model that we consider for the undertaking utilizes the Haar Cascades
calculation, which utilizes the facial highlights of the driver to distinguish
sluggishness [6]Viola, P.and Jones M. It is the second most precise and quickest
calculation after the CNNs, and it chips away at the low computational expense and a
more modest training set, which then, at that point, makes the framework conservative
and the best model for our pupose.

DRIVER DROWSINESS DETECTION SYSTEM USING OPEN CV 11


2.6. Facial Recognition

Facial recognitiont utilized in the undertaking was made utilizing ubuntu and
customized in Python (programming language). In the framework, pip was introduced,
a package of the executive's framework that is for simplifying the establishment and
the board of programming bundles written in Python. Pip is utilized to introduce
NumPy, Dlib scikit-picture, OpenCV3, and OpenCV 4. NumPy is a bundle that
contains N-layered exhibit object, instruments for reconciliation C/C++ and Fortran
code, refined (telecom) work, Fourier change, straight variable-based math, and
irregular number capacities. The is an open-source picture handling library for the
Python programming language. Scikit-picture incorporates calculations for
mathematical changes, division, variety space control, investigation, morphology,
highlight identification, separating, and that's only the tip of the iceberg.

It is intended to work close by with the Python mathematical and logical libraries
NumPy [16] Wikipedia, OpenCV is a Python library that is intended to take care of
PC vision issues, OpenCV is a wrapped class for the first C++ library to be utilized in
Python. All OpenCV cluster structures are switched over completely to or from
NumPy array.[17] The Dlib is a cutting edge C++ tool compartment containing AI
calculations and instruments for making complex programming in C++ to address
certifiable issues. It is utilized in scholarly community and industry in a wide scope of
spaces including installed gadgets, mechanical technology, cell phones, and greater
superior execution registering conditions. Dlib's open source authorizing permits it to
be utilized for nothing and in any application.

[17] Sparkfun Start Something, Using OpenCV and the Dlib facial landmark is
distinguished in a picture. The landmarks (central issues) that are of significance for
the gadget are the ones that portray the state of the face ascribes like eyes, nose,
mouth, jawline, eyes, and eyebrows. [19]These focuses give extraordinary
understanding into the investigated face structure, it tends to be exceptionally valuable
for a wide scope of utilization, including face liveliness, face acknowledgment, flicker
identification, feeling acknowledgment, and photography. The Dlib offers The Face
Landmark Detection calculation which is an execution of the Ensemble of Regression
Trees (ERT) introduced in 2014 by Kazemi and Sullivan.

DRIVER DROWSINESS DETECTION SYSTEM USING OPEN CV 12


c
Fig2.5 Facial Diagram Built with Dlib(Landmarks)
The procedure uses straightforward and quick highlights (pixel powers contrasts) to
straightforwardly appraise the landmark positions. The assessed positions are later on
refined with an iterative interaction done by a cascade of regressors. [21]The
regressors produce another gauge from the past one, attempting to decrease the
arrangement blunder of the assessed focuses at every iteration. The algorithm is
exceptionally quick, to call attention to it takes around 1-3ms (on the work area stage)
to distinguish (adjust) a bunch of 68 tourist spots on a given face [12]Dlib C++

c
Fig2.5 Facial Diagram Built with Dlib(Landmarks)
By the utilization of a coding program running in python, a component inside Dlib
called preparing choice utilizes a few boundaries, for example,
• "Tree Depth — It determines the profundity of the trees utilized in each outpouring.
The "limit" of the model is addressed by the boundary. As far as the place of precision,
an ideal worth is 4, all things being equal, a worth of 3 is a decent trade among
exactness and model size.

• Nu — is the regularization boundary. It decides the capacity of the model to learn


and sum up designs rather than fixed information. A value near 1 will underscore the

DRIVER DROWSINESS DETECTION SYSTEM USING OPEN CV 13


learning of fixed information rather than designs, consequently raising the
opportunities for over-fitting to occur. All things being equal, an ideal nu value of 0.1
will cause the model to perceive designs as opposed to fixed circumstances,
dispensing with the issue of over-fitting. How much preparation tests can be an issue,
with lower nu esteems the model requires a great deal (a large number of) training
tests for it to perform well.

• Cascade Depth — it is the quantity of cascades used to prepare the model. This
boundary influences either the precision or size of a model. 10 - 12 is viewed as a
decent value, all things being equal, a value of 15 is the right equilibrium between
sensible model size and most extreme exactness.

• Feature Pool Size — indicates the number of pixels used to produce the elements for
the arbitrary trees at each cascade. A bigger number of pixels will lead the calculation
to become precise and vigorous however to execute more slowly. A value of 400
accomplishes extraordinary precision with an incredible runtime speed. On the off
chance that speed isn't an issue, setting the parameter value to 800 (or even 1000) 16
will prompt predominant accuracy. With a value somewhere in the range of 100 and
150, it is as yet conceivable to procure a decent precision with an extraordinary
runtime speed. The last value is appropriate for installed and cell phone applications.

• Num Test Splits — is the number of divided highlights inspected at every node. It is
a boundary answerable for choosing the best highlights at each cascade during the
training interaction. The parameter influences the training speed and the model
exactness. The default value of the boundary is 20. This parameter is exceptionally
valuable, for instance, when we need to train a model with great exactness despite
everything keeping it of little size. This is finished by expanding how much num split
test to 100 or 300, to build the model exactness and not the model's size.

• Oversampling Amount — determines the quantity of arbitrarily chosen


disfigurements applied to the available preparation samples. The utilization of
irregular disfigurements in the preparation pictures is a straightforward procedure that
successfully expands the size of the training dataset. Expanding the value of the
boundary to 20 or even 40 is just expected on account of little datasets, additionally, it

DRIVER DROWSINESS DETECTION SYSTEM USING OPEN CV 14


will build the training time significantly (so be cautious). The most recent release of
the Dlib library has another training boundary: the oversampling jittering sum that
applies an interpretation disfigurement to the given bounding boxes to make the
model more vigorous against in the long run lost face regions.
By accurately calibrating the preparation choices it is feasible to modify the training
interaction such that it fulfills the requirements of the framework under development.
The requirements can be about storage utilization and memory, leader speed,
robustness, and general accuracy. What describes the stage which is being developed
with ( cell phones, work areas, and installed frameworks) (Generally, various
platforms have different arrangements of value prerequisites). Moreover, by the
determination of just the significant landmarks, specific models that restrict a specific
subset of landforms can be made, subsequently, there is the disposal of superfluous
points ."

Fig 2.5 Divisions of Facial Implementation

DRIVER DROWSINESS DETECTION SYSTEM USING OPEN CV 15


2.7. Raspberry Pi

The Raspberry Pi is a cheaper, credit-card-sized computer that connects to a TV or


Computer Monitor and it uses a standard mouse and Keyboard. [13]The Raspberry Pi
little device size of a credit card that allows people to explore computing and to
acquire knowledge on how to program in different languages like Python and
Skratch.[18] It is capable of performing the tasks one would expect a regular desktop
computer to perform, from internet browsing and playing videos in high definition, to
spreadsheet making , playing games and word-processing . The Raspberry Pi is one of
the affordable microcomputers available on the market. [5]Moreover, with its large
community and usability, open-source based, it is the best microcomputer for
prototype development that could suppress the Arduino in some features for not being
just a microprocessor but also a microcomputer.

The Raspberry Pi components includes :

(1) 700 MHz processor.

(2) HDMI port.

(3) USB ports for external devices.

(4) 512 MB RAM.

(5) Ethernet port.

(6) Camera interface.

(7) 40 GPIO pins.

(8) Display interface.

(9) Micro SD card slots.

(10) Power supply port.

DRIVER DROWSINESS DETECTION SYSTEM USING OPEN CV 16


Fig 2.6 Raspberry Pi
We have implemented Face detection with the help of
 Raspberry pi.
 Raspbian operating system.
 Web Cam.
 Python IDE.
 OpenCv (Open source Computer Vision) for python (with Haar object detection).
 Code for face detection in (Python Programming language).

2.8. Pi Camera Module

The Pi camera module is a small, lightweight camera module that supports Raspberry
Pi. The pi camera communicates with Pi by the use of the MIPI camera serial
interface protocol.Ordinarily it is utilized in AI, picture handling, or reconnaissance
projects. It is generally utilized in reconnaissance drones since the camera's payload is
exceptionally less. Aside from these modules, Pi can utilize ordinary USB webcams
that are utilized alongside the PC.

DRIVER DROWSINESS DETECTION SYSTEM USING OPEN CV 17


Fig 2.5 Pi Camera Module
Features of the Pi Camera include

 5MP color camera module.

 It supports both Raspberry Pi Models.

 Has MIPI Camera serial interface.

 Omnivision 5647 Camera Module.

 Its Resolution: 2592 * 1944.

 It Supports: 480p 720p and 1080p.

 Portable and Lightweight (3g only)

Pin Description

DRIVER DROWSINESS DETECTION SYSTEM USING OPEN CV 18


Fig 2.7 Raspberry Pi Pins

2.9. Active Passive Buzzer

A buzzer is a little, productive part that adds sound highlights to a project or


framework. It is a small and conservative 2-pin structure along these lines that can be
effortlessly utilized on the breadboard, PCBs, and, surprisingly, on PERF Boards
which makes it a generally involved part in a number of electronic applications.
Two kinds of buzzers are generally accessible. [8]This one is a straightforward buzzer
that when controlled will make a consistent signal sound, the other sort is known as a
readymade buzzer which looks bulkier than this and produces a beep signal sound
because of the interior wavering circuit present inside it. [20]The one displayed here
is for the most part utilized in light of the fact that it may very well be modified with
the assistance of contrasting circuits to fit effectively in any application.
The signal can be utilized by controlling it making use of a DC power supply going to
9v from 4v.[18] A battery of 9V can be utilized, however, it is fitting to utilize a

DRIVER DROWSINESS DETECTION SYSTEM USING OPEN CV 19


directed +6V or +5V DC supply. The signal is ordinarily connected with a changing
circuit to turn ON or OFF the ringer at the necessary time and required stretch.

Fig 2.8 Active Passive Buzzer

2.10. Viola Jones Face Detection Algorithm

Viola-Jones object detection framework may be used for detection of several some of
object classes, however, it is more centered on detecting the face and its capabilities.
The algorithm makes use of the idea of rectangle functions which contain the sums of
pixels in the square areas [15]. The total of the pixels that are inside white rectangles
are removed from the total of the pixels which are in grey rectangles. The value of the
rectangular feature, represented with the aid of using A and B is the distinction among
the sum of pixels in square areas. [22]The areas have form and size. They also are
vertically or Horizontally-orientated and are adjoining to every other. A three-
rectangle feature, being represented as C, generates the sum inside out of doors
rectangles being subtracted from the sum in a middle rectangle. Lastly, a four-
rectangular feature, being presented as D generates the distinction among the diagonal
pairs of the rectangles.

DRIVER DROWSINESS DETECTION SYSTEM USING OPEN CV 20


Fig 2.9 Feature used in Viola Jones

The rectangle features are generated rapidly by the use of a representation for the
picture known as the integral image.

Fig 2.9.2 Feature for face Detection

DRIVER DROWSINESS DETECTION SYSTEM USING OPEN CV 21


REFERENCES
[1] Fatigue – Definition and More from the Free Merriam-Webster Dictionary”.
Internet: http://www.merriam-webster.com/dictionary/fatigue [Feb. 16, 2013]
[2] NCSDR/NHTSA Expert Panel on Driver Fatigue & Sleepiness; Drowsy Driving
and Automobile Crashes, Report HS 808 707, 1998.
[3] P. Caffier, U. Erdmann, P. Ullsperger, “Experimental evaluation of eyeblink
parameters as a drowsiness measure”, Federal Institute for Occupational Safety and
Health, pp.319-325, March 2003.
[4] National Sleep Foundation. “Facts and Stats: Drowsy Driving – Stay Alert, Arrive
Alive”. Internet: http://drowsydriving.org/about/facts-and-stats/ [Feb 16, 2013].
[5] The Royal Society For The Prevention of Accidents; Driver Fatigue and Road
Accidents, A literature Review and Position Paper, 2001.
[6] D. Liu, P. Sun, Y. Xiao, and Y. Yin, "Drowsiness Detection Based on Eyelid
Movement," in Education [1]Technology and Computer Science (ETCS), 2010
Second International Workshop on, 2010, pp. 49-52
[7] T. Danisman, I. M. Bilasco, C. Djeraba, and N. Ihaddadene, "Drowsy driver
detection system using eye blink patterns," in Machine and Web Intelligence
(ICMWI), 2010 International Conference on, 2010, pp. 230-233.
[8] D. F. Dinges and R. Grace, "PERCLOS: A valid psychophysiological measure of
alertness as assessed by psychomotor vigilance," Federal Highway Administration.
Office of motor carriers, Tech. Rep. MCRT-98-006, 1998.
[9] S. T. Lin, Y. Y. Tan, P. Y. Chua, L. K. Tey, and C. H. Ang, "PERCLOS
Threshold for Drowsiness Detection during Real Driving," Journal of Vision, vol. 12,
pp. 546-546, 2012.
[10] A. Picot, S. Charbonnier, and A. Caplier, "On-line automatic detection of driver
drowsiness using a single electroencephalographic channel," in Engineering in
Medicine and Biology Society, 2008. EMBS 2008. 30th Annual International
Conference of the IEEE, 2008, pp. 3864-3867.
[11] B. T. Jap, S. Lal, P. Fischer, and E. Bekiaris, "Using EEG spectral components to
assess algorithms for detecting fatigue," Expert Systems with Applications, vol. 36,
pp. 2352- 2359, 2009.
[12] M. Saradadevi and P. Bajaj, "Driver fatigue detection using mouth and yawning
analysis," IJCSNS International Journal of Computer Science and Network Security,
vol. 8, pp. 183-188, 2008.

DRIVER DROWSINESS DETECTION SYSTEM USING OPEN CV 22


[13] Savas, B. K., & Becerikli, Y. (2018). Real Time Driver Fatigue Detection Based
on SVM Algorithm. 2018 6th International Conference on Control Engineering &
Information Technology (CEIT). doi:10.1109/ceit.2018.8751886.
[14] Donahue J, Anne Hendricks L, Guadarrama S, Rohrbach M, Venugopalan S,
Saenko K, Darrell T. Long-term recurrent convolutional networks for visual
recognition and description. IEEE conference on computer vision and pattern
2015;2625-2634.
[15] Viola, P., Jones, M. Rapid object detection using a boosted cascade of simple
features.Computer Vision and Pattern Recognition, IEEE Computer Society
Conference.2001;I:I.
[16] Wikipedia, January 2020, https://en.wikipedia.org/wiki/Scikit-image
[17] Sparkfun Start Something, January 2020,
https://learn.sparkfun.com/tutorials/what-is-an-arduino/all.
[18]T. Pilutti, and A.G. Ulsoy, “On-line Identification of Driver State for
Lanekeeping Tasks,” in Proc. American Control Conference, Seattle,Washington, vol.
1, pp. 678-681, 1995.
[19] T. Pilutti, and A.G. Ulsoy, “Identification of Driver State for Lane-keeping
Tasks”, in IEEE Trans. Systems, Man, and Cybernetics, Part A, vol. 29, pp. 486-502,
1999.
[20] Iizuka H. Yanagishima-T. Kataoka Y. Seno T. Yabuta, K., “The Development of
Drowsiness Warning Devices”. In Proceedings 10th International Technical
Conference on Experimental Safety Vehicles, Washington, USA., 1985.
[21] Planque S. Lavergne, C. Cara H. de Lepine, P. Tarriere, C. Artaud P., “An On-
board System for Detecting Lapses of Alertness in Car Driving”. In 14th E.S.V.
conference, session 2 - intelligent vehicle highway system and human factors Vol 1,
Munich, Germany, 1994.
[22] C. Lavergne, P. De Lepine, P. Artaud, S. Planque, A. Domont, C. Tarriere, C.
Arsonneau, X. Yu, A. Nauwink, C. Laurgeau, J.M. Alloua, R.Y. Bourdet, J.M. Noyer,
S. Ribouchon, and C. Confer. “Results of the Feasibility Study of a System for
Warning of Drowsiness at the Steering Wheel Based on Analysis of Driver Eyelid
Movements.” In Proceedings of the Fifteenth International Technical Conference on
the Enhanced Safety of Vehicles, Melbourne, Australia, 1996.

DRIVER DROWSINESS DETECTION SYSTEM USING OPEN CV 23


CHAPTER 3

METHODOLOGY

3. Introduction

This chapter covers the processes, tools and tasks accompanying this projects’
completion. It involves analysis of every stage that will be featured to carry out the
project.

This chapter explains the methods that have been put to practice to reach the set
objectives and aims of the project and a closer look at project implementation. Each
selection and accomplishment of the method implemented in this project will be
explained for each stage till the completion of the project. The project makes use of is
Computer Vision Software . These methods used are methods in command for
detection of mouth area, face, and nose.

3.1.1. Research Methodology

Research methodology is referred to as a set of operations for use to carry out on a


certain research project. To complete the project systematically in the range of the
specified period, there are a number of activities and methodologies that need to be
prearranged and followed correctly.

3.1.2. Physiological Level Approach

This technique is an intrusive method where we make use of electrodes to obtain brain
activity, pulse rate, and heart rate. ECG is used to calculate heart rate variations and to
detect various conditions for drowsiness [12]. The correlation between different
signals such as EEG (electroencephalogram), ECG (electrocardiogram), and EMG
(electromyogram) are made and the output is generated whether the driver is drowsy
or not.

DRIVER DROWSINESS DETECTION SYSTEM USING OPEN CV 24


3.1.3. Behavioral Based Approach

In this technique, the eye-head pose, blinking frequency, etc. of a person is monitored
by a camera, and the driver is alerted if any of the drowsiness signs are sensed.

3.1.4. Vehicle Based Approach

This technique continuously monitors the position of the car in the lane, steering
wheel position, and pressure on the acceleration pedal. by measuring all these
parameters system indicates whether the driver Is drowsy or not.

Fig 3.1 Flow Chart of Project Progress

3.1.5. Background of Study

Before beginning any studies or assignment, fundamental statistics of the associated


subject matter are needed to make certain that the writer knows what the assignment
is all about[13]. In this stage, the heritage of having a look at enables the writer knows
the relations between drowsiness and fatigue. It additionally enables the writer to
information the seriousness of riding a motored automobile in drowsiness

DRIVER DROWSINESS DETECTION SYSTEM USING OPEN CV 25


circumstances [8]. It is tested that riding the automobile in drowsiness and fatigue
circumstance is a leadership aspect to road accidents

3.1.6. Literature Review

At this stage, it concerned having a look at the preceding studies carried out
associated with the creator project. This subject matter observes the connection
between drowsiness situations and coping with a motored vehicle. A thorough
commentary became carried out on the present technique to hit upon the drowsiness.
Different parameters had been utilized by preceding research. By putting focus at the
parameters which are detecting the mouth and eyes, enables to slender down the angle
of the project.

3.1.7. Previous data Gathering Analysis

At this stage, it becomes located that one of the satisfactory manners to hit upon eyes
and yawning is through an algorithm. Some of the present-day algorithms which
might be associated with this assignment are reviewed to assist in growing the
assignment. In [10], the advocate technique measures the time for someone to close
their eyes and if their eyes are have been closed longer than the regular eye-blink time,
it is far feasible that the man or woman is getting asleep. Based upon research of
human eye blinks, it has been recognized that the common human blink length takes
approximately 202.25ms even as the blink length of a drowsy character takes
approximately 258.58ms.

3.1.8. Algorithm Design and Development

Garcia et al, explains that a few algorithms and approach has been used withinside the
method of detecting eyes, face, and mouth. The Cascade Object Detector is the set of
rules and approaches used. The Cascade Object Detector utilizes the Viola-Jones set
of rules to discover people's faces, noses, eyes, mouths, or top bodies.

3.1.8.1.Viola Jones Face Detection Algorithm

Viola-Jones object identification framework may be used to stumble on lots of item


classes, however, it is greater targeted at the identification of the face and its facial

DRIVER DROWSINESS DETECTION SYSTEM USING OPEN CV 26


functions. The set of rules makes use of the idea of rectangle functions which includes
the sums of pixels in the square areas. [15] the total of the pixels that are in the white
rectangles are taken off he sum of pixels in the gray rectangles.

The value of a 2 Rectangle Feature, addressed by B and A, is the distinction between


the number of pixels inside two rectangular regions. The regions are of similar size
and shape. They are additionally adjusted horizontally or in the vertical direction and
are neighboring one another[10]. A unit of three rectangles, represented as C,
calculates the sum inside two outer rectangles subtracted from the sum in a middle
rectangle. Finally, a feature of four rectangles, represented as D, calculates the
difference between diagonal pairs of rectangles[14].

Fig 3.1.1 Feature used in Viola Jones

The value of the integral picture at the point (x,y) is the total of all the pixels to the
left above and of it. Supported on the integral picture, the total of the pixels within the
rectangle D can be calculated using four matrix references. The integer image value at
position 1 is the total of the pixels in rectangle A. B + A is the value at position 2,
A + C is the value at position 3 , and at position 4 is C + D + B + A

DRIVER DROWSINESS DETECTION SYSTEM USING OPEN CV 27


Fig 3.1.2 Feature for Face Detection

3.1.8.2.Cascade of Classifiers

In a regular 24x24 pixel pane, there are around a total of 45,397 possible features to
be recognized. This is too large and prohibitively expensive a number to judge. To
improve the recognition performance, there is need for functions to be included to the
classifiers. This step, computation time directly increases and the detection process is
made slower[16]. Consequently, the cascade of classifiers is built to increase the
recognition performance while drastically reducing the computation time.

Fig 3.1.3 Cascade of Classifiers


The assessment of the strong classifiers that are generated through the studying
method may be finished quick however isn't speedy sufficient to run in real-time.
Thus, the robust classifiers are cascaded so as of complexity. Each next classifier is

DRIVER DROWSINESS DETECTION SYSTEM USING OPEN CV 28


handiest educated on decided on samples that byskip the preceding classifiers. [10] If
at any degree of the cascade a classifier rejects the tested sub-window, no similarly
processing is finished and it keeps attempting to find the subsequent sub-window.

3.1.9. Analysis and Testing

To be able to detect the mouth and eye area, there must face be detection of the face
area. Nevertheless, this measure reduces system performance and speed due to a large
detection area. The project aims to identify signs of sleepiness in the eyes and mouth.
Hence , this project put the limit to the detection area to the eyes and mouth. This will
improve system performance. Tests are required to ensure it meets the required
parameters.

3.2. Structure of the Overall System

The system contains the following Components

I) Raspberry Pi Module
II) Buzzer
III) Pi Camera Module
IV) Connecting Wires

.
Fig 3.2 Block diagram of Driver Drowsiness Detection System

DRIVER DROWSINESS DETECTION SYSTEM USING OPEN CV 29


The embedded system consists of PI Camera Module which is a digital camera, a
raspberry module, and a buzzer that is interfaced with the microcontroller. The system
is controlled by the Raspbian operating system. The system detects real-time
situations of the driver's vigilance and control over the vehicle. If alcoholic and/or
drowsiness tests are positive, it alerts the driver through the buzzer.

3.2.1. Technologies of Use

3.2.2. Tensor Flow

It is an open-source software library that is for data flow programming across a


variety of tasks. T. Welsh et al say that it is a symbolic mathematics library, and is
used for machine learning applications such as neural networks. It is used for both
production and research. The TensorFlow calculations are shown as stateful dataflow
diagrams. The name TensorFlow gets from the activities that such brain networks
perform on multi-faceted information clusters. These clusters are alluded to as
"tensors"[18].

3.2.3. Machine learning

B. T. Jap et al states that Artificial Intelligence is a type of programming that grants


computers the ability to consequently gain from information without being
unequivocally customized. At the end of the day, these programs change their way of
behaving by gaining from the information. Python is one of the best machine learning
languages. Python includes special machine learning libraries namely pandas, numpy,
and scipy which are great for doing linear algebra and learning the core methods of
machine learning. The language is excellent for working with Artificial Intelligence
algorithms and has a relatively simple syntax.

3.2.4. Open CV

OpenCV represents Open Source Computer Vision. It is an open-source BSD


authorized library containing many progressed computer vision calculations
streamlined to utilize equipment speed increase. OpenCV is ordinarily utilized for AI,
picture handling, picture control, and significantly more. OpenCV has a particular

DRIVER DROWSINESS DETECTION SYSTEM USING OPEN CV 30


construction. G. Borghini et al said that there are static and shared libraries and a CV
namespace. In short, OpenCV is used in our application to easily load bitmap files
with landscape images and undertake a merging operation between two images so that
one image can be displayed in the background of another image. This image editing is
easy to do with OpenCV compared to other methods in a few lines of code[13].
OpenCV.org is a must-read if you want to explore and deepen image processing and
machine learning in general.

3.3. System Description

Fig 3.3 System Flow Chart


In the framework we have involved facial milestone expectation for eye identification
Facial landmarks are utilized to restrict and address remarkable districts of the face,
for example,

 Eyes

DRIVER DROWSINESS DETECTION SYSTEM USING OPEN CV 31


 Nose

 Eyebrows

 Jawline

 Mouth

Facial landmarks had been efficiently carried out to stand alignment, head pose
estimation, face swapping, blink detection, and plenty more[13]. In the context of
facial landmarks, we intend to detect critical facial systems at the face through the
usage of form prediction methods. The detection of facial landmarks is consequently
a two-step process:

• Localizing the face in the image.

• Detecting the main facial structures on the face Region Of Interest.

Localize the face with inside the photo: The face photo is localized via way of means
of Haar feature-primarily based cascade classifiers which turned into mentioned
withinside the first step of our set of rules i.e. face detection[12]. Detecting the
important thing facial systems at the face ROI. There are a whole lot of facial
landmark detectors, however, all strategies attempt to localize and label the
subsequent facial regions: mouth, right eye, left eye, left brow, right brow, and nose.

The facial features detector protected withinside the dlib library it is an


implementation of the One Millisecond Face Alignment with an Ensemble of
Regression Trees paper with the aid of using Kazemi and Sullivan (2014).

1. A training set of categorized facial landmarks on a picture. These photographs are


manually categorized, specifying defined (x, y)-coordinates of areas surrounding
every facial structure.

2. Priors, of greater specifically, the possibility of distance among pairs of enter pixels.
The pre-skilled facial landmark detector in the dlib library is used for estimation of
the location of the 68 (x, y)-coordinates that map to the facial systems at the face.

DRIVER DROWSINESS DETECTION SYSTEM USING OPEN CV 32


3.3.1. Recognition of Eyes state

The eye place may be expected from optical flow, with the aid of using sparse
monitoring or with the aid of using frame-to-frame depth differencing and adaptive
thresholding by H. Seifoory et al. Finally, a selection is made whether or not the eyes
are or aren't included with the aid of using eyelids. An extraordinary technique is to
deduce the kingdom of the attention commencing from an unmarried picture, as e.g.
with the aid of using correlation coordination with open and closed eye templates, a
heuristic horizontal or vertical picture depth projection over the attention region, a
parametric version becoming to discover the eyelids, or lively form models[15].

Therefore, we suggest an easy however green set of rules to locate eye blinks with the
aid of using the use of a recent facial landmark detector. A singular scalar amount that
displays a degree of the attention establishing is derived from the landmarks.
Eventually, having a per-body collection of the attention-establishing estimates, the
attention blinks are located with the aid of using an SVM classifier this is educated on
examples of blinking and non-blinking patterns[18].

3.3.2. Eye Aspected Ratio Calculation

The eye landmarks are detected for every video frame, The (EAR) Eye aspect ratio is
between the width and height of the eye is computed.

in which p1,. ., p6 are the 2D landmark locations, shown in the diagram. The EAR is
ordinarily constant while a watch is open and is getting near 0 at the same time as
ultimate a watch. It is in part individual and head pose insensitive. The aspect ratio of
the open eye has a smaller variance amongst individuals, and its miles are completely
invariant to a uniform scaling of the picture and in-aircraft rotation of the face.
[16]Since eye blinking is carried out with the aid of using each eye synchronously, the
EAR of each eye is averaged.

DRIVER DROWSINESS DETECTION SYSTEM USING OPEN CV 33


Fig 3.3.2

3.3.3. Eye State Determination

Finally, the selection for the attention nation is made primarily based totally on EAR
calculated withinside the preceding step. If the space is 0 or is near 0, the attention
nation is classed as "closed" in any other case the attention nation is diagnosed as
“open”.

3.3.4. Drowsiness Detection

The ultimate step of the set of rules is to decide the person's circumstance primarily
based totally on pre-set circumstances for drowsiness. The common blink length of
someone is 100-four hundred milliseconds (i.e. 0.1-0.four of a second)[13]. Hence, if
someone is drowsy, his or her eye closure ought to be passed this interval. We set a
time body of five seconds. If the eyes continue to be closed for 3 or greater seconds,
drowsiness is then detected and an alert pop concerning the drowsiness is triggered.

Fig 4 Gantt Chat for Project

DRIVER DROWSINESS DETECTION SYSTEM USING OPEN CV 34


3.4. Conclusion

The Viola Jones algorithm is best for image detection since it is a frame work that
deals with Object detection. Open CV is used for image manipulation and image
processing and machine learning. The eye state detection will be measured by the
Eye Aspect Ratio(EAR) to determine the percentage of eye closure before the
buzzer is triggered.

DRIVER DROWSINESS DETECTION SYSTEM USING OPEN CV 35


REFERENCE SYSTEM
[1] Facial Features Monitoring for Real Time Drowsiness Detection by Manu B.N,
2016 12th International Conference on Innovations in Information Technology (IIT)
[Pg. 78-81] https://ieeexplore.ieee.org/document/7880030
[2] Real Time Drowsiness Detection using Eye Blink Monitoring by Amna Rahman
Department of Software Engineering Fatima Jinnah Women University 2015 National
Software Engineering Conference (NSEC 2015)
https://ieeexplore.ieee.org/document/7396336
[3] Implementation of the Driver Drowsiness Detection System by K. Srijayathi
International Journal of Science, Engineering and Technology Research (IJSETR)
Volume 2, Issue 9, September 2013
[4] Stan, Ovidiu, Liviu Miclea, and Ana Centea. "EyeGaze Tracking Method Driven
by Raspberry PI Applicable in Automotive Traffic Safety." Artificial Intelligence,
Modelling and Simulation (AIMS), 2014 2nd International Conference on. IEEE,
2014.
[5] SS, Kulkarni, and A. D. Harale. " application of raspberry pi based embedded
system for real time protection against road accidents due to driver’s drowsiness
and/or drunk and drive cases." international journal of engineering sciences &
research technology, 5(9): September, 2016.
[6] Anjali, K. U., et al. "Real-time nonintrusive monitoring and detection of eye
blinking in view of accident prevention due to drowsiness." Circuit, Power and
Computing Technologies (ICCPCT), 2016 International Conference on. IEEE, 2016.
[7] Stan, Ovidiu, Liviu Miclea, and Ana Centea. "EyeGaze Tracking Method Driven
by Raspberry PI Applicable in Automotive Traffic Safety." Artificial Intelligence,
Modelling and Simulation (AIMS), 2014 2nd International Conference on. IEEE,
2014.
[8] Turan, Garima, and Sheifali Gupta. "Road Accidents Prevention system using
Driver’s Drowsiness Detection." International Journal of Advanced Research in
Computer Engineering & Technology (IJARCET) Volume 2 (2013).
[9] Ruian Liu,et.a;, "Design of face detection and tracking system," Image and Signal
Processing (CISP), 2010 3rd International Congress on , vol.4, no., pp.1840,1844, 16-
18 Oct. 2010
[10] Ahmad Noor Syukri, M. Siti Atiqah, L. Fauziana, and A. Abdul Rahmat,
"MIROS crash investigation and reconstruction: annual statistical 2007-2010," 2012.

DRIVER DROWSINESS DETECTION SYSTEM USING OPEN CV 36


[11] A. Picot, S. Charbonnier, and A. Caplier, "On-line automatic detection of driver
drowsiness using a single electroencephalographic channel," in Engineering in
Medicine and Biology Society, 2008. EMBS 2008. 30th Annual International
Conference of the IEEE, 2008, pp. 3864-3867.
[12] G. Borghini, L. Astolfi, G. Vecchiato, D. Mattia, and F. Babiloni, "Measuring
neurophysiological signals in aircraft pilots and car drivers for the assessment of
mental workload, fatigue and drowsiness," Neuroscience & Biobehavioral Reviews,
2012.
[13] B. T. Jap, S. Lal, P. Fischer, and E. Bekiaris, "Using EEG spectral components to
assess algorithms for detecting fatigue," Expert Systems with Applications, vol. 36,
pp. 2352- 2359, 2009.
[14] D. Liu, P. Sun, Y. Xiao, and Y. Yin, "Drowsiness Detection Based on Eyelid
Movement," in Education [1]Technology and Computer Science (ETCS), 2010
Second International Workshop on, 2010, pp. 49-52.
[15] H. Seifoory, D. Taherkhani, B. Arzhang, Z. Eftekhari, and H. Memari, "An
Accurate Morphological Drowsy Detection," ed: IEEE, 2011.
[16] D. J. McKnight, "Method and apparatus for displaying grey-scale or color images
from binary images," ed: Google Patents, 1998.
[17] T. Welsh, M. Ashikhmin, and K. Mueller, "Transferring color to greyscale
images," ACM Transactions on Graphics, vol. 21, pp. 277-280, 2002.
[18] I. Garcia, S. Bronte, L. Bergasa, N. Hernandez, B. Delgado, and M. Sevillano,
"Visionbased drowsiness detector for a realistic driving simulator," in Intelligent
Transportation Systems (ITSC), 2010 13th International IEEE Conference on, 2010,
pp. 887-894.
[19] T. Danisman, I. M. Bilasco, C. Djeraba, and N. Ihaddadene, "Drowsy driver
detection system using eye blink patterns," in Machine and Web Intelligence
(ICMWI), 2010 International Conference on, 2010, pp. 230-233.

DRIVER DROWSINESS DETECTION SYSTEM USING OPEN CV 37


CHAPTER 4

RESULTS AND ANALYSIS

4. Introduction

This chapter discusses the results achieved in the context of the final year project.
Apart from that, this chapter covers the information for simulating the algorithm. The
steps to detect eyes are also explained in this chapter.

4.1. Project Progress

Implemented drowsiness detection using Python and OpenCV, including the


following steps-:

Successful runtime video capture with a camera. The captured video was separated
into frames and each individual frame was analyzed. Successful face recognition
followed by eye recognition. detected, it is classified as a sleepy state, otherwise, it is
considered a normal blink, and the loop of image capture and controller status
analysis is performed over and over . In this implementation, during the sleep state,
the eye is not circled or detected, and the appropriate message is displayed.

DRIVER DROWSINESS DETECTION SYSTEM USING OPEN CV 38


4.2. Results Presentation

Video Stream Starting

Yawn Detected

DRIVER DROWSINESS DETECTION SYSTEM USING OPEN CV 39


POOR LIGHTING WARNING

DRIVER DROWSINESS DETECTION SYSTEM USING OPEN CV 40


Frame of Drowsiness Detected

Driver is Awake

TEST ID TEST CONDITION SYSTEM BEHAVIOR EXPECTED

DRIVER DROWSINESS DETECTION SYSTEM USING OPEN CV 41


RESULT
T01 STRAIGHT FACE, NON DROWSY NON DROWSY
GOOD LIGHT WITH
GLASSES
T02 TILTED FACE, GOOD DROWSY DROWSY
LIGHT, NO GLASSES
T03 TILTED FACE, GOOD DROWSY DROWSY
LIGHT, WITH
GLASSES
T04 STRAIGHT FACE, NON DROWSY NON DROWSY
GOOD LIGHTING NO
GLASSES

4.3. System Overview

While executing the program, the dataset trains the model utilizing facial highlights of
a human face and perceives the driver's eyes progressively. The upper right corner of
the screen screens the EAR or perspective proportion of the eye. This proportion
decides the "receptiveness" of the eyes and falls underneath 0.17 (the limit used to
decide framework exhaustion) when the framework distinguishes shut eyes. Each
casing ascertains its EAR, and a counter factor tracks the quantity of consistent edges
that the driver's eyes are shut. When the counter arrives at the model's limit, for this
situation, five back to back outlines, the driver is viewed as lethargic and the
Raspberry Pi conveys a result message to the caution framework by means of the
GPIO library.

DRIVER DROWSINESS DETECTION SYSTEM USING OPEN CV 42


Fig 4.1 image of the working Prototype

The transition of the designed system can be tracked as it is regarded as an improved


system from some of the commonly used drowsiness detection systems.

Parameters Proposed System Existing System

Video Acquisition Available Not Available

Sound Alert System Used Not used

Image Processing Available Not Available

To achieve the end result a massive wide variety of images and videos had been taken
and their accuracy in figuring out eye blinks and drowsiness become examined. An
outside buzzer is used to supply alert sound output to be able to awaken the driving
force when drowsiness exceeds a sure threshold. The device becomes examined for
extraordinary humans in extraordinary ambient lights situations( daylight and
nighttime). When the webcam backlight become grew to become ON and the face is

DRIVER DROWSINESS DETECTION SYSTEM USING OPEN CV 43


stored at an optimum distance, then the device is capable of stumble on blinks in
addition to drowsiness with extra than 95% To achieve the result a massive wide
variety of movies had been taken and their accuracy in figuring out eye blinks and
drowsiness become examined. For this venture, we used a five megapixel USB
webcam linked to the computer. An outside buzzer is used to supply alert sound
output to be able to awaken the driving force when drowsiness exceeds a sure
threshold. The device becomes examined for extraordinary humans in extraordinary
ambient lights situations( daylight and nighttime). This is a superb result and may be
carried out in actual-time structures as well. Sample outputs for numerous situations
in numerous pix are given. Two movies had been taken; one wherein best the eyes
had been detected and the alternative wherein each face and eyes had been detected.
Though the 2 strategies have the distinctly same accuracy, the computational
necessities of the previous and lesser than that of the latter. accuracy. This is a superb
result and may be carried out in actual-time structures as well. Sample outputs for
numerous situations in numerous pix are given below. Two movies had been taken;
one wherein best the eyes had been detected and the alternative wherein each face and
eyes had been detected. Though the 2 strategies have the distinctly same accuracy, the
computational necessities of the previous and lesser than that of the latter

4.4. LIMITATIONS

Limitations of the system are below-;

1. The dependence on ambient lighting- With bad lights situations even though
the face is easily detected, once in a while the machine is not able to come across
the eyes. So it offers an erroneous result that needs to be taken care of. In actual
time situations, infrared backlights have to be used to keep away from bad lights
situations.

2. Orientation of the Face- while the face is tilted to a positive volume it could be
detected, but past this our device fails to stumble on the face. So while the face
isn't always detected, eyes are additionally now no longer detected. This hassle is
resolved through the use of monitoring capabilities which music any motion and
rotation of the items in an image. An educated classifier for tilted face and tilted
eyes can additionally be used to keep away from this form of hassle.

DRIVER DROWSINESS DETECTION SYSTEM USING OPEN CV 44


3. Poor detection when wearing Spectacles- When the driving force wears glasses
the device fails to stumble on eyes that are the maximum full-size disadvantage
of our device. This difficulty has now no longer yet been resolved and it is a
mission for nearly all eye detection structures designed as of now.

4. Problem with multiple faces detected- If multiple faces are detected through the
webcam, then our device offers an inaccurate result. This trouble isn't critical as
we need to detect the drowsiness of a single driver.

5. Optimum Range Required for Detection- whilst the distance between the face
and webcam isn't always at most fulfilling variety then certain issues arise. When
the face is so closer to the the webcam ( less than 30 cm), the system finds it
difficult to detect the face from the picture. So it best indicates the video as output
as a set of rules is designed to locate eyes from the face region. This may be
resolved through detecting eyes at once by the use of haar detect objects
capabilities from the whole picture rather than the face area. So eyes may be
monitored even supposing faces aren't detected. When a face is far from the
webcam (greater than 70cm) then the backlight is not enough to light up the face
properly. Therefore, eyes aren't detected with excessive accuracy which indicates
blunders in the drowsiness detection. This trouble isn't always significantly taken
under consideration as in actual time state of affairs the gap among drivers face
and the webcam does not exceed 50cm. So the trouble in no way arises.
Considering the mentioned difficulties, the most fulfilling distance variety for
detection of drowsiness is about 40-70 cm.

4.5. Conclusion

The results came out as expected and as required. Under certain conditions, the
system works very well, when there isn't enough ambient lighting and people driving
with spectacles the system will have difficulties in detecting the eyes of the driver.
Also when there are so many faces within the camera's detection space, the system
will have difficulties in eye detection.

DRIVER DROWSINESS DETECTION SYSTEM USING OPEN CV 45


However, the system works very well by alerting the driver when they are feeling
dizzy through the Buzzer. It also shows the Eye Aspect Ratio (EAR) of the person
under the camera detection.

DRIVER DROWSINESS DETECTION SYSTEM USING OPEN CV 46


CHAPTER 5

CONCLUSIONS AND DISCUSSIONS

5. Introduction

This chapter presents an evaluation of the outcome /findings of the research. It


additionally discusses the tips and regions which require development or similar
research.

5.1. Summary Of Driver Drowsiness Detection System.

The project undertaking intends to plan and foster a minimal expense Driver
Drowsiness Detection System utilizing Open CV. The ringer is for cautioning the
driver by delivering sound signs, which stirs the driver progressively to keep away
from road carnage. Eye identification is finished utilizing the Haar cascade classifier
by the computation of the Eye perspective proportion additionally diminishes the
misleading eye recognition, an issue that is looked at by the other drowsiness
discovery frameworks that utilize just the OpenCV library. Be that as it may, the
misleading problems are insignificant, which gives an expansion in the capacity of the
system. The Eye Aspect Ratio( EAR) of various back-to-back casings will help us to
eliminate those insignificant mistakes and successfully ascertain Drowsiness.

5.2. Project Achievements.

A non-invasive system was developed to locate the eyes and for the monitoring of
fatigue. Information about the positioning of the head and eyes is acquired through
various image processing algorithms that are developed. During monitoring, the
system can decide whether the eyes are open or closed. closed for too long, a warning
signal sounds. In addition, the system can automatically detect eye position errors that
occur during monitoring.

The overall objectives of the research were met. A working prototype was designed,
built, and tested, showing that the theory is workable, flexible, and can be further

DRIVER DROWSINESS DETECTION SYSTEM USING OPEN CV 47


improved to address other issues faced by drivers when they experience fatigue during
driving.

5.3. Challenges Faced

Several challenges were met during the design and production of the low-cost Driver
drowsiness detection system. Failed to gather all the best-suited components for the
project and ended up using alternatives that work similarly. The Pi Camera was
expensive and made use of a WebCam. Also to be able to install the Operation code,
we had to use Anaconda Spider( programming Platform) which requires a high-
performance computer with a big size RAM. To curb the challenge, the RAM was
changed to an 8Gb RAM. Installation of Raspbian OS on the Raspberry Pi 3 was a
challenge. There was a need for a monitor to use as a screen for the Raspberry and it
was not at easy disposal as they are hard to get. This challenge was solved by using a
Projector connected to the Raspberry Pi.

5.4. Recommendations

Improvements to the system can be made by adding a web base to it so that


supervisors ( in the case of Companies) can view the current state of each driver on
duty.

At the moment there is no adjustment in zooming or direction of the camera during


operation. Future work on the system would be to automatically zoom in on the eyes
when they are detected. By this, it would avert from the trade-off between having a
wide field of view for the eyes to be located, and a narrow view for fatigue detection.

Adaptive binarization can be added to assist in making the system more robust. This
eliminates the requirement for the noise removal function, reducing the number of the
computations needed to locate the eyes. By this, adaptability to changes in ambient
lighting is allowed.

DRIVER DROWSINESS DETECTION SYSTEM USING OPEN CV 48


APPENDIX A

MICROCONTROLLER CODE

ALGORITHM
1. Capture the picture of the driver from the camera.
1. Send the captured picture to Haar Cascade report for face detection.
2. If the face is detected then crop the picture together with the face most effective.
If the driver is distracted then a face won't be detected, so play the buzzer.
3. Send the face picture to Haar Cascade report for eye detection.
4. If the eyes are detected then crop most effective the eyes and extract the left and
proper eye from that picture. If each eyes aren't located, then the driving force is
asking sideways, so sound the buzzer.
5. The cropped eye pics are despatched to the hough changes for detecting pupils,
with a view to decide whether or not they're open or closed.
6. If they're located to be closed for 5 non-stop frames, the driver should be alerted
via way of means of sound from the buzzer.

import face_recognition
import cv2
import numpy as np
import time
import cv2
import eye_game
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
BUZZER= 23
GPIO.setup(BUZZER, GPIO.OUT)
previous ="Unknown"
count=0
video_capture = cv2.VideoCapture(0)
#frame = (video_capture, file)
file = 'image_data/image.jpg'
# Load a sample picture and learn how to recognize it.
img_image = face_recognition.load_image_file("img.jpg")
img_face_encoding = face_recognition.face_encodings(img_image)[0]
# Create arrays of known face encodings and their names
known_face_encodings = [
img_face_encoding
]

DRIVER DROWSINESS DETECTION SYSTEM USING OPEN CV 49


known_face_names = [
"Ashish"
]

# Initialize some variables


face_locations = []
face_encodings = []
face_names = []
process_this_frame = True
while True:
# Grab a single frame of video
ret, frame = video_capture.read()
# Resize frame of video to 1/4 size for faster face recognition
processing
small_frame = cv2.resize(frame, (0, 0), fx=0.25, fy=0.25)
# Convert the image from BGR color (which OpenCV uses) to RGB color
(which face_recognition uses)
rgb_small_frame = small_frame[:, :, ::-1]
# Only process every other frame of video to save time
if process_this_frame:
# Find all the faces and face encodings in the current frame of
video
face_locations = face_recognition.face_locations(rgb_small_frame)
face_encodings = face_recognition.face_encodings(rgb_small_frame,
face_locations)
cv2.imwrite(file, small_frame)
face_names = []
for face_encoding in face_encodings:
# See if the face is a match for the known face(s)
matches =
face_recognition.compare_faces(known_face_encodings, face_encoding)
name = "Unknown"
face_distances =
face_recognition.face_distance(known_face_encodings, face_encoding)
best_match_index = np.argmin(face_distances)
if matches[best_match_index]:
name = known_face_names[best_match_index]
direction= eye_game.get_eyeball_direction(file)
print(direction)
#eye_game.api.get_eyeball_direction(cv_image_array)
if previous != direction:
previous=direction
else:
print("old same")
count=1+count
print(count)
if (count>=10):
GPIO.output(BUZZER, GPIO.HIGH)
time.sleep(2)
GPIO.output(BUZZER, GPIO.LOW)
print("Alert!! Alert!! Driver Drowsiness
Detected")
cv2.putText(frame, "DROWSINESS ALERT!", (10, 30),

cv2.FONT_HERSHEY_SIMPLEX, 0.7, (0, 0, 255), 2)


face_names.append(name)

DRIVER DROWSINESS DETECTION SYSTEM USING OPEN CV 50


process_this_frame = not process_this_frame
# Display the results
for (top, right, bottom, left), name in zip(face_locations,
face_names):
# Scale back up face locations since the frame we detected in
was scaled to 1/4 size
top *= 4
right *= 4
bottom *= 4
left *= 4
# Draw a box around the face
cv2.rectangle(frame, (left, top), (right, bottom), (0, 255, 0),
2)
# Draw a label with a name below the face
cv2.rectangle(frame, (left, bottom - 35), (right, bottom), (0, 0,
255), cv2.FILLED)
font = cv2.FONT_HERSHEY_DUPLEX
cv2.putText(frame, name, (left + 6, bottom - 6), font, 1.0, (0,
0, 255), 1)
#cv2.putText(frame, frame_string, (left + 10, top - 10), font,
1.0, (255, 255, 255), 1)
# Display the resulting image
cv2.imshow('Video', frame)
# Hit 'q' on the keyboard to quit!
if cv2.waitKey(1) & 0xFF == ord('q'):
break
# Release handle to the webcam
video_capture.release()
cv2.destroyAllWindows()

DRIVER DROWSINESS DETECTION SYSTEM USING OPEN CV 51


DRIVER DROWSINESS DETECTION SYSTEM USING OPEN CV 52
DRIVER DROWSINESS DETECTION SYSTEM USING OPEN CV 53
DRIVER DROWSINESS DETECTION SYSTEM USING OPEN CV 54

You might also like