You are on page 1of 5

IOT BASED DRIVER DROWSINESS DETECTION AND ALERT

SYSTEM
Y. Surya Kumar, V. Shiva Narasimha, V. Nalini, T. Mounika, Dr. P. A. Nageswara Rao

Department of Electronics and Communication Engineering,


Gayatri Vidya Parishad College for Degree and P.G. Courses (A)

Abstract

In recent years’ driver fatigue is one of the major causes of vehicle accidents in the world. Due to these accidents, many people
lose their lives or get severely injured. A direct way of measuring driver fatigue is measuring the state of the driver i.e. drowsiness. So,
it is very important to detect the drowsiness of the driver to save life and property.
This project is aimed towards developing a prototype for drowsiness detection and accident prevention using Raspberry Pi. This
system is a real-time system which captures image continuously and measures the state of the eye according to the specified algorithm
and gives a warning if required. So, when the closure of the eye exceeds a certain amount which is observed by the camera module
connected to the Raspberry Pi, the driver is identified to be sleepy and an alert is given in the form of a buzzer or any other sound from
the Pygame module present in the Raspbian OS. If the alerts are found to be more than a particular count, the processor gradually
reduces the speed of the vehicle and the system ignition is set to off state by stopping the motor. A GPS module is used to locate the
coordinates of the vehicle and a notification is sent to the registered family or friends’ numbers. If there aren’t any alerts i.e. the eye
closure range is within a certain threshold, then the system lets the engine run without any interruption.
This system continuously monitors the drowsiness of the driver and thus helps in reducing the possibility of occurring accidents.

Keywords: Drowsiness Detection, Raspberry Pi , USB camera, Eye Aspect Ratio , Buzzer, GPS Module.

1.Introduction compared to the rested one. Nowadays, more and more


professions require long-term concentration. People who
Each year, around 1.5 lakh people die in road mishaps in work for transportation business must keep a close eye on
India. Some of them due to drowsy or sleep driving. the road, so they can react to sudden events immediately.
Around 400 people on an average are losing their lives Long hours of driving cause the driver fatigue and,
every day on Indian roads. That means 16 precious lives consequently, reduces her/his response time. Some of
being sucked out every minute. We often hear of drunken them conducted experiments with the driving simulator
driving, no seat belt, speeding, road condition, bad and they concluded that a tired driver is much worse
weather and mechanical failures. But one of the biggest dangerous than a person whose alcohol level in blood is
and yet often unrecognized human errors is drowsy 25% above the allowed limit. Driver fatigue can cause the
driving. A major problem not only in India but across the driver falling asleep behind the wheel. Therefore, there is
globe. The risk, danger, and often tragic results of drowsy a need to develop a system that will detect and notify a
driving are alarming indeed. Obviously lack of sleep is the driver which could significantly reduce the number of
main culprit. And add to it the promoters like medications, fatigue-related car accidents. Due to the increasing
alcohol and sleep disorders, sleepiness gets in serious number of vehicles on the road, which translates into the
condition. road accidents directly, equipping a car with the fatigue
detection system is a must. One of the technical
possibilities to implement such a system is to use vision-
Many drivers sacrifice sleep, an often overlooked and
based approach. There are some techniques can be carried
dangerous behaviour that results in majority of them being
out using mind wave monitoring, heart-beat rate. Also, to
sleep-divested while behind the wheel every day. There is
find vision based or facial appearances. Mouth gaping and
no official count of lives lost in drowsy driving-related
eye closure are the best symptoms to detect drowsiness in
crashes in our country. Falling asleep at the wheel is
a driver. The driver fatigue is detected using computer
suicidal. It is not only dangerous to the driver but to all
vision. The face is detected using haar cascade and face
other road users. It certainly risks our lives.
detection using dlib, open cv.
Exhausted drivers who doze off at the wheel are
responsible for about 40% of road accidents, says a study
by the Central Road Research Institute (CRRI) on the 300- Open cv is nothing but a computer vision. The driver
km Agra-Lucknow Expressway. Indian highway drowsiness level is determined by the frequency of eye
motorists ignore the importance of taking adequate rest blinking and the drowsiness level is calculated by
and end up endangering lives. Raspberry Pi3 along with a Pi camera. The experiment is
carried out under altered conditions and also with and
without eye wear they obtain face and eye detection rate
Vision-based systems are becoming more popular and are up to 98%. A buzzer is introduced for every counter and
more widely used in different applications. Such complex then the buzzer count exceeds the threshold level, the
systems could also be used to detect vehicle operator motor speed reduces. The speed of motor can be
fatigue using vision-based solutions. Drowsiness is such a controlled by PWM. This system is interfaced with
condition of a man, which does not allow for a full Raspberry PI 3 with Raspbian OS, USB camera, Motor.
concentration. It influences the human response time to
decrease, because the tired person reacts much slower,
Car drivers, truck drivers, taxi drivers, etc. should be approach where a cascade function is trained from a lot of
allowed to use this solution to increase the safety of the positive and negative images First step is to collect the
passengers, other road users and the goods they carry. Haar Features. A Haar feature considers adjacent
rectangular regions at a specific location in a detection
2. Methodology
The principal goal is to detect drowsiness of driver, the
drowsiness of the driver is captured by a camera module.
Open cv is a library of programming functions aimed at
real time computer vision and it consists large number of
libraries for detecting object faces. The detection is done
using object and face detection algorithms like Haar
Cascades and Shape predictor libraries. The Eye Aspect
Ratio which indicates the drowsiness of the driver is
calculated at every instant of time and is compared with

Fig 2.1 c) Features implemented on Human face

window, sums up the pixel intensities in each region. At


first, we apply each and every feature on all training
images. There are about 6000 features. A window is
created instead of applying 6000 features they are
grouped into stages and applied one by one. Open cv
provides a training method or pre trained models upon
installation.

For example, consider the image below. The first feature


selected seems to focus on the property that the region of
the eyes is often darker than the region of the nose and
cheeks. The second feature selected relies on the property
that the eyes are darker than the bridge of the nose. But
Fig 2. 1 a) Methodology flowchart the same windows applying on cheeks or any other place
is irrelevant. During the detection phase, a window of the
target size is moved over the input image, and for each
the threshold values. The proposed method involved with
subsection of the image and Haar features are calculated
the following methodologies such as Haar Cascade
.This difference is then compared to a learned threshold
Classifiers, Shape Predictor_68_facial landmark
that separates non-objects from objects. A large number
detection, Eye Aspect Ratio (EAR), Buzzer alert system,
of Haar features are necessary to describe an object with
Motor speed control using PWM , GPS module and
sufficient accuracy , therefore all of them are organized
Twilio.
into number of classifiers to form a strong cascade
classifier
2.1 Haar Cascade Classifiers
Haar Cascade is a machine learning object detection 2.2 Shape predictor_68_Facial Landmark
algorithm used to identify objects in an image or video detection using DLIB
and based on the concept of features proposed by Paul
Viola and Michael Jones in their paper "Rapid Object DLIB is a machined learning pre trained library which has
Detection using a Boosted Cascade of Simple Features" facial landmarks (points). The are used to localize region
in 2001. It is a machine learning based of face such as eyes, mouth, nose etc... It localizes the face
in the image and detect key facial features using open cv
haar cascade and facial landmarks in dlib library.
Detecting landmarks is a subset of shape prediction
problem. Given an input image, a shape prediction
algorithmattempts to localize key points of interest along
the shape A training set of labelled facial landmarks on an
image are applied. Specific (x, y) –coordinates of regions
surrounding each facial feature are identified. Given the
training data an estimate is obtained to find landmark
positions. The end result is a facial landmark detector that
can be used to detect facial landmarks in real-time with
high quality predictions.

Fig 2.1 b) Types of features


time the buzzer gets ‘on’ the buzzer counter is
incremented by one. A certain threshold for the buzzer
counter is taken above which the motor starts to slow
down. The speed of the motor gradually decreases and
finally comes to rest.
Raspberry pi can be interfaced using two methods using a
motor driver or transistor as a switch for the 5v to flow
through the motor. We prefer second method. Equipment
required are Transistor, Resistor, Diode, Motor.

The motor is switched on and off using the n-p-n transistor


(MPS2222A). The base and collector of transistor are
connected to the GPIO output and the 5v respectively. The
emitter is connected to ground. The motor is connected to
the 5v supply of the raspberry per 1 kilo ohm resistor is
connected to the transistor to limit current passing into the
base.

Fig 2.2 a) 68 Facial Landmarks on Human Face The inclusion of the diode is to prevent voltage spikes
which can occur when the motor stops and the magnetic
field collapses.
2.3 Buzzer alert system using Py Game
The eye_aspect_ratio is calculated at every instant from
the coordinates as shown in the figure. The distance
between the coordinates (p1, p2, p3, p4, p5, p6) in fig(b)

are extracted and E.A.R is calculated using formulae in fig


(a)

Fig 2.3 a) The EAR is calculated for every instant


Fig 2.4 Motor speed control circuit diagram

Bread board Connections :

1. Pin ‘2’ (5 volt) of the raspberry pi is connected


to the +ve terminal of motor.
2. Pin ‘7’ (GPIO) is connected to the resistor
which is in series to the base of transistor.
3. Pin ‘6’ (Gnd) is connected to the –ve terminal
Fig 2.3 b) Close and open eyes with landmark the of the motor.
coordinates are detected automatically. 4. Setting the pin ‘7’ as ‘1 ’switches ON the
motor and ‘0’ to stop the motor.
Therefore, whenever the eye_aspect_ratio is less than the
given threshold or the eyes are closed as shown in fig(c)
the buzzer immediately switches on and continues till the
driver opens his eyes. The buzzer is switched on using
the keyword

“pygame. mixer. music. Load('buzzer.wav')’’

Where buzzer.wav is the audio file used

2.4 Motor speed control using PWM Fig 2.4 .a) Interfacing motor with raspberry Pi.
Here, “Vehicle is represented as a Motor”.
Now to turn the motor on the GPIO pin is set HIGH and
LOW to switch of the motor.
After detecting the drowsiness of the driver, a variable
‘buzzer counter’ is added to count the no of buzzers. Each
Reducing the speed of motor by setting the pins ‘1’ (high) Identifying coordinates of the vehicle using the GPS
or ‘0’ (low) the motor either runs at max speed or module and creating a link which is to be forwarded.
completely stops rotating. Now to operate the motor at an
in between speed the GPIO pin should be switched on and The link created using GPS or any other required
off very fast. notification is sent to the registered mobile number using
We can accomplish this by setting the pin as a GPIO pulse Twilio.
width modulated pin .Now the speed of the motor can be
changed by changing the Duty cycle of the pin.
3. Hardware and Software
The Human Drowsiness detection system provides a
solution to the accidents occurring due to the drivers being
in the state of drowsiness. To achieve this the proposed
system includes a collection of hardware components as
well as Software program to provide optimum
solution/results.

The components used in the system are explained in brief


as follows:

Fig 2.4 b) Speed variation using PWM


3.1 Hardware
1. Raspberry Pi 3 Model B
The speeds of the motor can be changed as shown in the 2. Webcam
figure by varying the Duty cycle. The Duty cycle can be 3. DC motor
changed using the keyword 4. GPS module
“ChangeDutyCycle(value)” 3.2 Software
where the value should range in (1-100). 1 Python software(python> =3.5)

2.5 Locating coordinates using GPS module Installed Raspbian os and libraries in raspberry pi. The
libraries which are installed in raspberry pi are
Global Positioning System (GPS) makes use of signals
sent by satellites in space and ground stations on Earth to 1. NumPy
accurately determine their position on Earth. 2. Py Game
3. SciPy
Radio Frequency signals sent from satellites and ground 4. C Make
stations are received by the GPS. GPS makes use of these 5. Dlib
signals to determine its exact position. 6. Open Cv and other similar libraries like setup tool etc.
are installed in it.

4. Output and Results

Fig 2.5 a) GPS module (NEO-6M)

The GPS itself does not need to transmit any information.


The signals received from the satellites and ground
stations contain time stamps of the time when the signals
were transmitted. By calculating the difference between Fig 4 a) The EAR is calculated for each and every frame through
the time when the signal was transmitted and the time the webcam module.
when the signal was received. Using the speed of the
signal, the distance between the satellites and the GPS
receiver can be determined using a simple formula for
distance using speed and time. Using information from 3
or more satellites, the exact position of the GPS can be
triangulated.

The GPS receiver module uses UART communication to


communicate with controller or PC terminal.
Fig 4 b) An alert in the form of buzzer is given whenever the EAR This will help to calculate drowsiness level. Frequent
is less than a certain threshold as shown in the figure above detection of eye blinking. When he/she reaches maximum
threshold, the driver will be alarmed by a Buzzer that will
wake up the driver from the sleep state. When the buzzer
alert also reaches threshold point the speed of the motor
reduces gradually and comes to rest position

Then the co-ordinates are located by GPS and sent to the


registered number.

6.References
[1] Musale, T., & Pansambal, B. H. DRIVER
DROWSINESS DETECTION TECHNIQUE USING
RASPBERRY PI.
Fig 4 c) The speed of the vehicle gradually decreases when the [2 Soukupova, T., & Cech, J. (2016, May). Eyeblink
number of buzzers are greater than the threshold amount. detection using facial landmarks. In 21st Computer Vision
Winter Workshop, Rimske Toplice, Slovenia .
[3] Šustek, M., Marcaník, M., Tomášek, P., & Úředníček,
Z. (2017). DC motors and servo-motors controlled by
Raspberry Pi 2 B. In MATEC Web of Conferences (Vol.
125, p. 02025). EDP Sciences.
[4] S. Ren, X. Cao, Y. Wei, and J. Sun. Face alignment
at 3000 fps via regressing local binary features. In
Proc. CVPR, 2014.
[5]Mario I Chacon-MurguiaClaudia Prieto-
Resendiz,”Detecting Driver Drowsiness-A survey of
system designs and technology,” IEEE Consumer
Electronics Magazine,
pp.107-108,October 2015.
[6]Mayank Chauhan, Mukesh Sakle”Study & Analysis of
Different Face Detection Techniqes ” International
Fig 4 d) Coordinates of the location are extracted. Journal of Computer Science and Information
Technologies, Vol. 5 (2) , pp 1615-1618,2014.
[7]1. A. A. Asadi, S. Bagheri, A. Imam, E. Jalayeri, W.
Kinsner, and N. Sepehri. Institute of Electrical and
Electronics Engineers Inc. (2016)
[8]W. H. Lee, E. C. Lee, and K. E. Park. Blink detec-
tion robust to various facial poses. Journal of Neu-
roscience Methods, Nov. 2010. 1, 3, 6, 7
[9]F. Yang, X. Yu, J. Huang, P. Yang, and D. Metaxas.
Robust eyelid tracking for fatigue detection. In ICIP,
2012. 1
[10]M. Vanitha., M. Selvalakshmi, R. Selvarasu. Institute
of Electrical and Electronics Engineers Inc. (2016)

Fig 4 e) The coordinates are sent to the registered mobile number


using Twilio along with the required message.

5.Conclusion
Driver drowsiness detection and Buzzer alert system is
designed mainly to keep the driver awake while driving to
avoid the accident due to sleepiness the raspberry pi and
camera used to capture eyes or face. Fatigue is measured
by detecting Eye and face using Haar Cascade Classifier,
especially facial landmarks is detected using shape-
predictor and Eye Aspect Ratio (EAR) by calculating the
Euclidean distance between the eyes. Accurate eye
detection and faces in every frame

You might also like