Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 27

Driver Drowsiness

Detection System
KUNAL KUMAR SINGH 2105555
ABHINAV THAKUR-2105513
ABHINASH DAS-2105514
PIYUSH SHAW-21051750
NITISH KUMAR-21051665
Under the Supervision of SUCHISMITA DAS

School of Computer Science Engineering.


Kalinga Institute Of Industrial Technology (KIIT) University.
Bhubaneswar - 751024.
Outline
1. Introduction.

2. Motivation.

3. Existing System.

4. Proposed System.

5. Design and Implementation.

6. Code Executed.

7. Conclusion.

8. Future Enhancement.
01
Introduction
Introduction
● Overview of the problem of Drowsy Driving :
● Driving while drowsy or asleep is a significant public health issue that poses a serious threat to road safety worldwide.

● According to the National Highway Traffic Safety Administration (NHTSA), drowsy driving is responsible for approximately
91,000 car crashes and 800 deaths each year in the India alone.

● As a result, there has been a significant effort to develop sleep detection systems that can help prevent accidents related to
fatigue and sleepiness.

● Importance of Developing Drowsiness Detection System :


● To address this issue, our project focuses on the development of a drowsiness detection system that can detect the onset of
drowsiness in drivers and provide timely alerts to prevent accidents.

● To achieve this goal, we conducted a comprehensive review of the existing literature on drowsiness detection and explored
different methods for detecting drowsiness, including physiological measures such as eye movements, yawning and facial
expressions.
Introduction

● Objectives of the Project :

● In our report, we provide an overview of the existing literature on drowsiness detection and describe the
methodology we used in our study.

● We present the results of our experiments and discuss the implications of our findings for drowsiness detection
and road safety.
02
Motivation
Motivation
● Our project has the potential to contribute significantly to the development of more effective
drowsiness detection systems that can help reduce the number of accidents caused by fatigue and
sleepiness.

● We believe that the development of a reliable and accurate drowsiness detection system can play a
critical role in enhancing road safety and reducing the number of accidents related to driver fatigue.

● Our project's findings have important implications for public health and can help inform the design
of more effective drowsiness detection systems that can be deployed in real-world driving scenarios.

● Overall, our project represents a significant step towards improving road safety and reducing the
incidence of accidents related to drowsy driving.
03
Existing System
Existing System

● By using a non intrusive machine vision based concepts, drowsiness of the driver detected system is
developed. Many existing systems require a camera which is installed in front of driver.

● The openCV detector detects only 40% of face of driver in normal driving position in video recording of
10 minutes.

● Eye Blink detector, which uses a goggle frame to detect the blink time of the eye which is proved not be
comfortable for the driver to wear it all the time.

● Hence existing system is not applicable for large vehicles.


Existing System

Driver drowsiness estimation using EEG


Eye Blink Sensor signals with a dynamical encoder–decoder
modeling framework
04
Proposed System
Proposed System

● Comprises of OpenCV, dlib, and pygame


libraries for image processing, deep
learning based face landmark detection,
and audio alerts, respectively.

● The camera and the face detector.

● Alarm System.

● SMS Alert.
05
Design And
Implementation
Design And Implementation

● Detecting the face in the captured frame and drawing a rectangle around it.

● Detecting the facial landmarks using the Dlib library.

● Checking if the person blinked their eyes or not.

● If the person is not blinking their eyes for a certain period, the code assumes that the person is sleeping and plays the
alert sound file and sends an SMS.
Design And Implementation
● Importing necessary libraries - OpenCV, NumPy, Dlib, imutils, pygame, and twilio.

● Initializing the camera and the face detector.

● Defining a function to compute the distance between two points using the NumPy library.

● Defining a function to detect if the person blinked their eyes or not.

● Defining a function to send an SMS using the Twilio library.

● Initializing the Pygame mixer to load the alert sound file.

● In the main loop, capturing the frames from the camera.


Design And Implementation

● If the person is blinking their eyes at a slow rate, the code assumes that the person is drowsy and plays the alert sound
file.

● If the person is active and not blinking their eyes, the code assumes that the person is alert.

● Displaying the status of the person on the frame using OpenCV.

● Showing the captured frame and the detected face in a separate window.

● Exiting the program when the user presses the "Esc" key.
06
Code Executed
Code Executed

# Importing OpenCV Library for basic image processing functions


import cv2
# Numpy for array related functions
import numpy as np
# Dlib for deep learning based Modules and face landmark detection
import dlib
# face_utils for basic operations of conversion
from imutils import face_utils
# initialize Pygame mixer
import pygame
#initializing twilio
from twilio.rest import Client
Code Executed
import keys def blinked(a, b, c, d, e, f):
up = compute(b, d) + compute(c, e)
down = compute(a, f)
# Initializing the camera and taking the instance ratio = up / (2.0 * down)
cap = cv2.VideoCapture(0)

# Checking if it is blinked
# Initializing the face detector and landmark detector if (ratio > 0.25):
detector = dlib.get_frontal_face_detector() return 2
predictor = dlib.shape_predictor("shape_predictor_68_face_landmarks.dat") elif (ratio > 0.21 and ratio <= 0.25):
return 1
else:
# status marking for current state return 0
sleep = 0
drowsy = 0 def send_sms():
active = 0 client = Client(keys.account_sid,
status = "" keys.auth_token)
color = (0, 0, 0) message = client.messages.create(
def compute(ptA, ptB): body="Drowsiness Detected !!!",
dist = np.linalg.norm(ptA - ptB) from_=key.twilio_number,
return dist to=key.target_number
)
return message
Code Executed
pygame.mixer.init()
# load alert sound file
alert_sound1 = pygame.mixer.Sound('a3.wav')
alert_sound2 = pygame.mixer.Sound('a4.wav') # The numbers are actually the landmarks which will show
eye
while True: left_blink = blinked(landmarks[36], landmarks[37],
_, frame = cap.read() landmarks[38], landmarks[41],
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) landmarks[40], landmarks[39])
right_blink = blinked(landmarks[42], landmarks[43],
faces = detector(gray) landmarks[44], landmarks[47],
# detected face in faces array landmarks[46], landmarks[45])
for face in faces:
x1 = face.left()
y1 = face.top() # Now judge what to do for the eye blinks
x2 = face.right() if (left_blink == 0 or right_blink == 0):
y2 = face.bottom() sleep += 1
drowsy = 0
active = 0
face_frame = frame.copy() if (sleep > 6):
cv2.rectangle(face_frame, (x1, y1), (x2, y2), (0, 255, status = "SLEEPING !!!"
0), 2) color = (255, 0, 0)
alert_sound1.play()
send_sms()
landmarks = predictor(gray, face)
landmarks = face_utils.shape_to_np(landmarks)
Code Executed
elif (left_blink == 1 or right_blink == 1):
sleep = 0
active = 0
drowsy += 1
if (drowsy > 6):
status = "Drowsy !"
color = (0, 0, 255)
alert_sound2.play()

else: cv2.imshow("Frame", frame)


drowsy = 0 cv2.imshow("Result of detector", face_frame)
sleep = 0 key = cv2.waitKey(1)
active += 1 if key == 27:
if (active > 6): break
status = "Active :)"
color = (0, 255, 0)

cv2.putText(frame, status, (100, 100),


cv2.FONT_HERSHEY_SIMPLEX, 1.2, color, 3)

for n in range(0, 68):


(x, y) = landmarks[n]
cv2.circle(face_frame, (x, y), 1, (255, 255, 255), -1)
Code Executed

Key Code To Send SMS Alert !


account_sid = 'AC290bd60b37e0847ea0cb3d33e833d5cc’
auth_token = 'ac00615dd97d92ce6295bbe2d55d031f'
# Enter the twilio no.
twilio_number = '+17695538456'
# Enter you phone no.
target_number = '+919937103783'
07
Conclusion
Conclusion

● In conclusion, the driver drowsiness detection system using Python is an important tool that can
help prevent accidents caused by drowsy driving.

● It is an innovative and effective way to detect early signs of drowsiness and alert drivers to take a
break or pull over to ensure their safety and the safety of others on the road.

● Furthermore, it highlights the importance of getting enough quality sleep to maintain overall
health and well-being and to prevent accidents caused by sleep deprivation and drowsy driving.
08
Future Enhancement
Future Enhancement

● Doziness discovery technology has numerous implicit operations in the future, particularly in
areas related to transportation and safety.

● One of the most important operations is in the field of transportation, where drowsiness
discovery systems can be used to warn motorists, aviators, and other drivers of vehicles when
they're getting too tired to perform their tasks safely.

● This can help prevent accidents caused by motorist fatigue, which is a leading cause of business
accidents.
Thanks!

You might also like