Major Project
Major Project
A Project Report on
Submitted to partial fulfillment of the requirements for the award of the degree
of
BACHELOR OF TECHNOLOGY
in
COMPUTER SCIENCE & ENGINEERING
By
A NAVEEN KRISHNA-------- (16911A05C4)
M SUSHANTH REDDY------- (16911A05F2)
SHAIK SHAHID---------------- (16911A05H3)
YASHWANTH HOLLA------- (16911A05J0)
CERTIFICATE
This is to certify that the project report titled “Drowsiness Detection And Alert
System” is being submitted by A. NAVEEN KRISHNA(16911A05C4), M
SUSHANTH REDDY(16911A05F2), SHAIK SHAHID(16911A05H3),
YASHWANTH HOLLA(16911A05J0). In partial fulfilment for the award of the
Degree of Bachelor of Technology in Computer Science & Engineering, is a record
of bonafide work carried out by him/her under my guidance and supervision. These
results embodied in this project report have not been submitted to any other University
or Institute for the award of any degree of diploma.
External Examiner
~3~
DECLARATION
(16911A05C4)
M SUSHANTH REDDY
SHAIK SHAHID
(16911A05H3)
YASHWANTH HOLLA
(16911A05J0)
~4~
ACKNOWLEDGEMENT
I would like to take this opportunity to express my gratitude to our Director Dr.
P. VENUGOPAL REDDY for providing necessary infrastructure to complete this
project.
I would thank my parents and all the faculty members who have contributed to
my progress through the course to come to this stage.
A NAVEEN KRISHNA
(16911A05C4)
M SUSHANTH REDDY
(16911A05F2)
SHAIK SHAHID
(16911A05H3)
YASHWANTH HOLLA
(16911A05J0)
~5~
ABSTRACT
INDEX
Abstract
1. Introduction 1
7. System Design 31
7.1 Functional Specifications 31
7.2 Non-Functional Specifications 31
7.3 UseCase Diagram 32
7.4 Class Diagram 34
7.5 Sequence Diagram 35
7.6 Activity Diagram 36
7.7 State Chart Diagram 37
7.8 Component Diagram 38
~7~
9. Conclusion 51
~1~
CHAPTER-1
INTRODUCTION
over the time, the movement of the frames is constant. This method is
intended for the methodological purposes, that is, the section of
traffic in the area devoted to the area (not exceeding the registration
process). Its performance can be improved by solving this algorithm
into the form of a pyramid (image analysis of a small improvement
and then its gradual change). The Horn-Schunk algorithm is based on
the use of the optical flow equation, taking into account two
conditions: the brightness of the dots (the pixel brightness of the
moving object in the image is constant) and the speed of the dots (the
speed of the pixels belonging to the moving object are close to each
other, the motion field changes smoothly). This method belongs to
the global methods. Thanks to this, we get a high density of the flow
vector, which results in a more accurate information about the
movement of the object, including information about the area under
investigation in which the object is moving. The disadvantage of this
algorithm is that it is more susceptible to interference compared to
the local methods (e.g. Lucas-Kaneda). The example of the application
of an optical flow is shown below.
BLOCK DIAGRAM
In order to reduce the number of road accidents resulting from
a driver fatigue, it is of great importance to introduce to the
automotive industry a system that would effectively detect the first
signs of a fatigue and notify the driver. A system based on real-time
face analysis can be one of the most effective approaches for
detecting fatigue symptoms. There are many problems associated
with its design such as uneven illumination of a driver’s face or the
selection of effective real-time data processing algorithms to name a
few. Current technological advances in video recording and
processing help reduce and even eliminate such problems. It is
envisaged that by integrating such a system with other on-board car
driving system would increase road safety definitely. The block
diagram of the hypothetical system, and principle of its operation is
presented in Figure 4. The investigations of the proposed drowsiness
detection vision system will be continued and the results of the
research will be delivered.
CHAPTER-2
During long journeys, it’s possible that the driver may lose
attention because of drowsiness, which may be a potential reason for
fatal accidents. With technologies like Driver Drowsiness
Detection getting it is possible to detect driver’s driving behaviour
that may prove fatal to the vehicle as well as the people boarding it.
While driving, you may feel drowsy when you’re under driving
fatigue because of continuous driving for several hours. It’s here that
the driver drowsiness detection plays a significant role in preventing
accidents that could otherwise cause massive loss of life and
property.
If the eye lid movements are abnormal than usual then the detection
system triggers the alarm thus alerting the driver about the
condition.
Further, your vehicles comprise heavy capital assets, which you need
to protect from potential losses because of fatal accidents.
There are diverse products that protect and ensure the safety of
vehicles but most of them don’t come with a built-in drowsiness
detection sensor.
Practically this is not an ideal option for both fleet owners and even
for individual car owners to deal with multiple devices.
CHAPTER-3
Apply facial landmark localization to extract the eye regions from the
face.
Now that we have the eye regions, we can compute the eye aspect
ratio to determine if the eyes are closed:
~ 15 ~
Figure 5: Step #3 — Compute the eye aspect ratio to determine if the eyes are
closed.
If the eye aspect ratio indicates that the eyes have been closed for a
sufficiently long enough amount of time, we’ll sound an alarm to
wake up the driver:
Figure 6: Step #4 — Sound an alarm if the eyes have been closed for a
sufficiently long enough time.
~ 16 ~
The Thread class so we can play our alarm in a separate thread from
the main thread to ensure our script doesn’t pause execution while
the alarm sounds.
In order to actually play our WAV/MP3 alarm, we need
the playsound library, a pure Python, cross-platform implementation
for playing simple sounds.
The playsound library is conveniently installable via pip :
def eye_aspect_ratio(eye):
18 # compute the euclidean distances between the two
19 sets of
20 # vertical eye landmarks (x, y)-coordinates
21 A = dist.euclidean(eye[1], eye[5])
22 B = dist.euclidean(eye[2], eye[4])
23
24 # compute the euclidean distance between the
25 horizontal
26 # eye landmark (x, y)-coordinates
27 C = dist.euclidean(eye[0], eye[3])
28
29 # compute the eye aspect ratio
30 ear = (A + B) / (2.0 * C)
31
32 # return the eye aspect ratio
return ear
~ 18 ~
If the eye is closed, the eye aspect ratio will again remain
approximately constant, but will be much smaller than the ratio
when the eye is open.
On the top-left we have an eye that is fully open with the eye facial
landmarks plotted. Then on the top-right we have an eye that is
closed. The bottom then plots the eye aspect ratio over time.
As we can see, the eye aspect ratio is constant (indicating the eye
is open), then rapidly drops to zero, then increases again,
indicating a blink has taken place.
Visualizing the 68 facial landmark coordinates from the iBUG 300-W dataset
(larger resolution).
# grab the indexes of the facial landmarks for the left and
62 # right eye, respectively
63 (lStart, lEnd) =
64 face_utils.FACIAL_LANDMARKS_IDXS["left_eye"]
65 (rStart, rEnd) =
face_utils.FACIAL_LANDMARKS_IDXS["right_eye"]
Using these indexes, we’ll easily be able to extract the eye regions via
an array slice.
~ 22 ~
102 # compute the convex hull for the left and right eye, then
103 # visualize each of the eyes
104 leftEyeHull = cv2.convexHull(leftEye)
105 rightEyeHull = cv2.convexHull(rightEye)
106 cv2.drawContours(frame, [leftEyeHull], -1, (0, 255, 0), 1)
~ 24 ~
we are now ready to check to see if the person in our video stream
is starting to show symptoms of drowsiness:
# check to see if the eye aspect ratio is below the blink
# threshold, and if so, increment the blink frame counter
if ear < EYE_AR_THRESH:
109 COUNTER += 1
110
111 # if the eyes were closed for a sufficient number of
112 # then sound the alarm
113 if COUNTER >= EYE_AR_CONSEC_FRAMES:
114 # if the alarm is not on, turn it on
115 if not ALARM_ON:
116 ALARM_ON = True
117
118 # check to see if an alarm file was
119 supplied,
120 # and if so, start a thread to have the
121 alarm
122 # sound played in the background
123 if args["alarm"] != "":
124 t=
125 Thread(target=sound_alarm,
126 args=(args["alarm"],))
127 t.deamon = True
128 t.start()
129
130 # draw an alarm on the frame
131 cv2.putText(frame, "DROWSINESS ALERT!",
132 (10, 30),
133 cv2.FONT_HERSHEY_SIMPLEX, 0.7, (0,
134 0, 255), 2)
135
136 # otherwise, the eye aspect ratio is not below the blink
137 # threshold, so reset the counter and alarm
138 else:
COUNTER = 0
ALARM_ON = False
CHAPTER-4
MACHINE LEARNING: --
With ML, you don’t need to babysit your project every step
of the way. Since it means giving machines the ability to learn, it lets
them make predictions and also improve the algorithms on their own. A
common example of this is anti-virus software; 9 they learn to filter new
threats as they are recognized. ML is also good at recognizing spam.
Continuous Improvement: --
Wide Applications: --
SUPERVISED LEARNING: --
UNSUPERVISED LEARNING: --
• k-means clustering
• self-organizing maps
• value decomposition
SEMI-SUPERVISED LEARNING: --
REINFORCEMENT LEARNING: --
SYSTEM REQUIREMENTS
HARDWARE REQUIREMENTS: --
Mouse: Logitech.
Ram: 1 GB
Camera : WebCam
~ 30 ~
SOFTWARE REQUIREMENT: --
CHAPTER-5
SYSTEM DESIGN
PROPOSED SYSTEM: --
In the existing system we are just generating the alarm based on the
speed of the driver. But where as in the proposed system whenever the
drowsiness of the driver is detected we genearate an alarm.
Advantages: --
• Increase in safety
• Avoid accidents
FUNCTIONAL SPECIFICATIONS: --
NON-FUNCTIONAL SPECIFICATIONS: --
GOALS: --
A use case diagram is usually simple. It does not show the detail of the
use cases:
• It does not show the order in which steps are performed to achieve
the goals of each use case
UseCase Diagram
~ 34 ~
CLASS DIAGRAM: --
Class Diagram
SEQUENCE DIAGRAM: --
Sequence Diagram
ACTIVITY DIAGRAM: --
Activity Diagram
STATECHART DIAGRAM: --
Statechart Diagram
COMPONENT DIAGRAM: --
Component Diagram
OBJECT DIAGRAM: --
Object Diagram
COLLABORATION DIAGRAM: --
Collaboration Diagram
DEPLOYMENT DIAGRAM: --
DFD shows how the information moves through the system and
how it is modified by a series of transformations. It is a graphical
~ 41 ~
technique that depicts information flow and the transformations that are
applied as data moves from input to output.
CHAPTER-6
$ python detect_drowsiness.py \
--shape-predictor
shape_predictor_68_face_landmarks.dat
--alarm alarm.wav
In the first part- the eye aspect ratio and how it can be used to
determine if a person is blinking or not in a given video frame.
Then write Python, OpenCV, and dlib code to
(1) perform facial landmark detection
(2) detect blinks in video streams.
Based on this implementation we’ll apply our method to detecting
blinks in example webcam streams along with video files.
Applying facial landmarks to localize various regions of the face, including eyes,
eyebrows, nose, mouth, and jawline.
CHAPTER-7
Test-Cases
Result: --
As shown in Fig, when there is ambient amount of light, the automobile
driver's face and eyes are successfully detected.
Test case 2: -- Position
Position of the automobile drivers face.
When the automobile driver’s head is tilted.
~ 49 ~
Result: --
As shown in the figure, when the automobile driver’s face is tilted for
more than 30 degrees from vertical plane, it was observed that the
detection of face and eyes failed.
The system was extensively tested even in real world scenarios, this was
achieved by placing the camera on the visor of the car, focusing on the
automobile driver. It was found that the system gave positive output
unless there was any direct light falling on the camera.
Test Case3: -- Using spectacles
Result: --
As shown in screen snapshot below, When the automobile driver is
wearing spectacles, the face, eyes, eye blinks, and drowsiness was
successfully detected.
~ 50 ~
Limitations: --
The following are some of the limitations of proposed system.
1. The system fails, if the automobile driver is wearing any kind of
sunglasses.
2. The system does not function if there is light falling directly on
the camera.
3. The system fails when the person is not blinking his eyes.
4. The system fails when the driver sleeps by opening his eyes.
CONCLUSION:
Four features that make our system different from existing ones are:
(a) Focus on the driver, which is a direct way of detecting the
drowsiness.
(b) A real-time system that detects face,iris, blink, and driver
drowsiness.
(c) A completely non-intrusive system, and
(d) Cost effective.