DROWSINESS DETECTION USING OPEN
CV&arduino
Project guide : Team mates:
Dr.Shafiulla basha sir (HOD)
1011904013 – S. KARISHMA
1011904001- K .AKHIL
1011904020-K.PAVAN KUMAR
1012004905- B.DHANUSH
Contents
Introduction
Related work
Proposed system
HOG algorithm
Open cv
About arduino
Arduino pin daigram
Interfacing arduino with hardware components
introduction
Drowsiness refers to feeling more sleepy than normal during the day. People who are drowsy
may fall asleep in when they do not want to or at times which can lead to safety concerns.
Due to the lack of drowsiness detection systems in Advanced Driver Assistance Systems
(ADAS), numerous drivers and pedestrians are seriously injured as result of drowsy driving.
According to the Central Road Research Institute (CRRI), fatigued drivers who fall asleep
while driving are responsible for around 40 percent of all traffic fatalities and injuries.
Therefore, drowsy driving is a significant and latent risk factor for road accidents. Hence, it is
necessary to develop a systematic drowsiness detection algorithm in order to reduce road
accidents.
Related work
drowsiness detection techniques are classified into three categories:
physiological measures,
vehicle-based measures
face analysis
comparison
Physiological Vehicle based behavioural
dependent on body elements such vehicle-based measures detect behavioural measures or face
as heart rate, body temperature, drowsiness by observing vehicle analysis detect drowsiness by
pulse rate, and so on, as physical behaviour such as steering wheel observing facial expressions and
conditions alter whenIn general, movement, random braking, movements using machine
ECG , EEG EMG, and EOG are speed variations, and so on. learning and computer vision(CV)
the commonly used physiological Sensors are installed in the
signals for assessing the physical vehicle components to monitor
conditions of human(driver). a driving performance and identify
driver becomes tired driving trends in order to detect
drowsiness.
Drawbacks in physiological
vehicle based measures:
The main disadvantage of adopting physiological methods is that it is
crucial to assure driver convenience while wearing sensors
The main drawback of adopting vehicle-based methods is that the
vehicle’s behaviour can be altered owing to bad weather and road
conditions, heavy medication, and so on
Proposed system:
Overview design:
the overall design idea of drowsiness detection is to capture image from the
camera and approximately estimate the state of drivers with data processing to
realise these requirements ; required hardware and software materials have to be
collected. For this project python machine learning and arduino are used along with
camera .for facial and eye detection openCV and HOG algorithms are used and
OPENCV libraries are used.
Histogram of gradient (HOG)
HOG algorithm is used to pre-process the image
which includes image resize and colour
normalization
In this project HOG is used to detect effecient
features from eye detection and extract HOG
features from image patterns and gives the exact
regions of eyes from the captured image of
driver.
How HOG works?
Histogram of oriented is a feature
descriptor used to detect objects in
computer vision and image
processing
The hog descriptor technique counts
occurences of gradient orientations
in localised portions of an image-
detection window or Region of
interest
Steps to calculate HOG features
Take the input image you want to calculate HOG features of. Resize the image into an image
of 128x64 pixels (128 pixels height and 64 width)
Figure 1 : The image imported to get HOG features of. Figure 2 : The imported image grayscale for the process. Figure 3 :
Resized and grayscale image of the imported image.
2. The gradient of the image is calculated. The gradient is obtained by combining
magnitude and angle from the image. Considering a block of 3x3 pixels, first Gx and
Gy is calculated for each pixel. First Gx and Gy is calculated using the formulae
below for each pixel value .
Where r,c are rows and columns respectively
After calculating Gx and , magnitude and angle of each pixel is calculated using the formulae
mentioned below.
Figure 4 : Visualization of magnitude of the image. Figure 5 :
Visualization of angle of the image.
3. After obtaining the gradient of each pixel, the gradient matrices (magnitude and angle matrix)
are divided into 8x8 cells to form a block. For each block, a 9-point histogram is calculated. A 9-
point histogram develops a histogram with 9 bins and each bin has an angle range of 20 degrees
Each of these 9-point histograms can be plotted as histograms with bins outputting the intensity
of the gradient in that bin. As a block contains 64 different values, for all 64 values of magnitude
and gradient the following calculation is performed. As we are using 9 point histograms, hence :
Each j th boundary will form :
Value of the centre of each bin will be :
Figure 6 : 8x8 blocks on the magnitude image. Figure 7 : 8x8 blocks on an angle image
Once histogram computation is over for all blocks, 4 blocks from the 9 point histogram matrix are
clubbed together to form a new block (2x2). This clubbing is done in an overlapping manner with
a stride of 8 pixels. For all 4 cells in a block, we concatenate all the 9 point histograms for each
constituent cell to form a 36 feature vector.
Extraction of HOG features for given image
Open cv method:
OpenCV is a cross-platform library using which we can develop real-time computer vision
applications. It mainly focuses on image processing, video capture and analysis including features like
face detection and object detection.
Computer Vision can be defined as a discipline that explains how to reconstruct, interrupt, and
understand a 3D scene from its 2D images, in terms of the properties of the structure present in the
scene. It deals with modelling and replicating human vision using computer software and hardware.
Computer Vision overlaps significantly with the following fields −
Image Processing − It focuses on image manipulation.
Pattern Recognition − It explains various techniques to classify patterns.
Photogrammetry − It is concerned with obtaining accurate measurements from images.
Flow chart :
What is arduino?
Arduino is a open source platform used for building electronics projects.
Arduino consists of both a physical programmable circuit board (often referred to as a
microcontroller and a piece of software or IDE (Integrated Development
Environment) that runs on your computer, used to write and upload computer code to
the physical board
the Arduino does not need a separate piece of hardware (called a programmer) in order
to load new code onto the board -- you can simply use a USB cable.
The arduino can be used as the brains behind almost any electronic projects
What does it do?
Arduino can interact with buttons, LEDs, motors, speakers, GPS units, cameras,
the internet, and even your smart-phone or your TV!
This flexibility combined with the fact that the Arduino software is free, the
hardware boards are pretty cheap, and both the software and hardware are easy to
learn
For everything from robots and a heating pad hand warming blanket to honest
fortune-telling machines, and even a Dungeons and Dragons dice-throwing
gauntlet.
How to make power supply to
arduino
Arduino boards can be powered in several ways
Arduino boards have five options in which they can be powered:
Powering via USB connector
Powering via the onboard barrel jack connector (if available on the board)
Powering via the onboard battery connector (if available on the board)
Powering via the VIN (Voltage In) pin
Powering via the 3V3/5V pin*
1.Usb connector
.
The most common and easiest way we can
power an Arduino board is by using
its onboard USB connector. The USB
connector provides a regulated 5V line to
power the board's electronics. However, 5V
from the USB connector can also power
external components through the 5V
pin that can be found in Arduino boards
2.Barrel jack connector
The voltage line from the barrel jack connector
is regulated in Arduino boards using their
onboard voltage regulator; usually, it is first
regulated to 5V and then regulated again to 3V3
in most Arduino boards. The recommended
voltage and current ratings for external
regulated DC power supplies connected to the
barrel jack
3.Battery connector
The boards mentioned before have
an onboard integrated battery charge
management circuit. This circuit integrates
the most common battery and power
management functions, like a battery
charger, a voltage regulator, and a load
switch, all in one.
4.Vin pin
The VIN pin in Arduino boards is a power pin with a dual function.
This pin can work as a voltage input for regulated external
power supplies that do not use a barrel jack connector. This pin
can also work as a voltage output when an external power
supply is connected to the barrel jack connector present in some
Arduino boards. An important consideration is that the VIN pin is
connected directly to the input pin of the onboard voltage regulator
on Arduino boards. Since the VIN pin is directly connected to the
voltage regulator, the VIN pin does not have reverse polarity
protection.
3V3/5V Pin
Interfacing arduino with buzzer
For this simple interfacing you will need:
A Piezo Buzzer.
Arduino Uno.
Resistor 100ohm.
Jumper Wires.
BreadBoard.
Connect the Supply wire (RED) of the buzzer to the Digital Pin 9 of
the Arduino through a 100 ohm resistor.
Connect the Ground wire (BLACK) of the buzzer to any Ground
Pin on the Arduino.
The resistor is used in order to protect the board/micro-controller from
any damage due to the audio output device.
THANK
YOU