Final Report (1) (AutoRecovered)
Final Report (1) (AutoRecovered)
ON
By
Jeevitha N S (R2018242)
Sinchana H R(R2018306)
VI Semester
KLE SOCIETY’s
S. NIJALINGAPPA COLLEGE
RAJAJINAGAR, BANGALORE-560010
(Prof. Bharathi N)
Academic Year
2022-2023
BENGALURU CITY UNIVERSITY
KLE SOCIETY’s S. NIJALINGAPPA
COLLEGE BACHELOR OF COMPUTER
APPLICATION RAJAJINAGAR, BANGALORE-560010
CERTIFICATE
This is to certify that project work entitled “Driver Drowsiness
Detection” has been successfully carried out by Jeevitha N S
(R2018242) , Sinchana H R(R2018306) in partial fulfilment for the
award of VI semester BCA during the academic year 2022-23.
2.
ACKNOWLEDGEMENT
I consider it is my privilege to express my sincere gratitude and respect to all those who
guided us in the completion of this project.
I consider it is a privilege to place my deepest sense of gratitude and sincere thanks to our
beloved Co-Ordinator Prof. Roopa H R, for her sincere co-operation, guidance and
supervision during the course of this project work undertaken by us.
I’m thankful and wish to express my gratitude to my project guide Prof. Bharathi N, for her
kind co-operation and for providing valuable suggestions and constant encouragement for this
project.
I express my sincere thanks and gratitude to the guidance, timely advices, support, sincere co-
operation, suggestions, ideas and also constructive criticisms provided by all the teaching
staff of the Computer Science Department, KLE Society’s Nijalingappa College.
Jeevitha N S (R2018242)
Sinchana H R(R2018306)
ABSTRACT
Data science project as the data is collected in real-time. The data so collected is the eye
motion of the driver, and facial movements. These are then fed as information into the program
that is written using python.
This system already exists in multiple high-end cars and vehicles. Since the statistics majorly
reflect that most of our Indian cars do not feature this particular functionality, it gave me the
motive to develop such a system. We often see newspaper articles where accidents occurred as
drivers felt drowsy and hit the vehicle in front of them. This could have been avoided if their
vehicle were fitted with a technological feature called “The drowsiness Detection System” which
off-late is seen in higher-end vehicles. We have used Open Libraries such as (Open CV, Dlib,
Flask,Pyhton IDLE) is a open-source distribution of the python programming language for data
science that aims to simplify package management and deployment.
Contents
1. Introduction
2. System Analysis
3. Software Requirement Specification
3.1 Existing System
3.2 Proposed System
3.3 Requirement Specification
4. System Definition
a) System Design
b) System Architecture
5. Detailed Design
a. Flowchart
b. Data Flow Diagram
6. Implementation
7. Testing and Results
8. Screenshots
9. Conclusion
10. Future Enhancement
11. Bibliography
Driver Drowsiness Detection
Introduction
INTRODUCTION
Driver drowsiness detection system is a Data Science project that helps in identifying the
drowsiness of drivers at an early stage and avoids accidents and unforeseen circumstances.
We regard this as a data science project as the data is collected in real-time. The data so
collected is the eye motion of the driver, his body posture, and facial movements. These are then
fed as information into the program that is written using python. Open libraries such as Open CV
(Open Computer Vision), Dlib (For facial recognition), matplotlib are used to facilitate the
detection.
It is a car safety technology which helps prevent accidents caused by the driver getting
drowsy. Various studies have suggested that around 20% of all road accidents are fatigue-related,
up to 50% on certain roads.
This system already exists in multiple high-end cars and vehicles. Since the statistics
majorly reflect that most of our Indian cars do not feature this particular functionality, it gave me
the motive to develop such a system.
System Analysis
SYSTEM ANAYLSIS
System analysis is the most essential part of the development of any project. It is the way
of studying a system with an eye on solving its problems using computers. The system analyst has
to understand the functioning and concept of the system in detail before designing the appropriate
computer-based system. He has to carry out a customary approach that includes the following
basic steps:
Requirement specification
Preliminary investigation
Feasibility study
Detailed investigation
Design and coding
Testing
Implementation
Data Science is the new trend and is the new technology which is in word of mouth in
everyday talks. Data Science is the Science of Analysing and getting information about what the
data talks about. To express in simple terms, it is the art of explaining what the data is talking
about. It makes human life easy by making us understand the insights of the data repository or
databases.
We often see newspaper articles where accidents occurred as drivers felt drowsy and hit the
vehicle in front of them. This could have been avoided if their vehicle were fitted with a
technological feature called “The drowsiness Detection System” which off-late is seen in higher-
end vehicles. These articles gave me the motive to develop a solution that could detect facial
movements and alert the driver as and when he felt sleepy.
It is just a small conceptual version that I would be developing and is at its pilot run as a
simulation using my computer. We have used Open Libraries such as (Open CV, Dlib, Python
IDLE. Python IDLE (Integrated Development and Learning Environment) is an interactive
development environment that comes bundled with the standard Python distribution. It serves as a
beginner-friendly and lightweight environment for writing, testing, and executing Python code.
Software
Requirement
Specification
This is an attempt to develop a prototype for such a detection system for cars
that do not feature this technology.
Processor I3[RAM(8gb)]
Monitor[HardDisk-500gb]
Webcam
Software
Python IDLe
3.3.2.1 Python
Python has a simple syntax similar to the English language. Python has syntax
that allows developers to write programs with fewer lines than some other
programming languages. Python runs on an interpreter system, meaning that code
can be executed as soon as it is written. This means that prototyping can be very
quick. A Python module can be run directly — as above "python hello.py Bob" —
or it can be imported and used by some other module. When a Python file is run
directly, the special variable " name " is set to " main ".
Python IDLE, short for Integrated Development and Learning Environment, is a user-
friendly and lightweight interactive development environment included with the
standard Python distribution. It serves as a helpful tool for both beginners and
experienced developers to write, test, and run Python code.
With its simple code editor, Python IDLE provides syntax highlighting, which aids in
writing and modifying Python scripts. The interactive shell is a standout feature,
allowing users to execute Python code line-by-line or in blocks. This feature is
particularly valuable for experimenting with code snippets and learning Python.
Flask, a popular Python web framework, offers a range of libraries and extensions
that enhance its functionality and streamline web application development. These
libraries provide various features, from form handling and database integration to
authentication and real-time communication. Let's explore some of the commonly
used Flask libraries:
One essential extension is Flask-WTF, which seamlessly integrates Flask with
WTForms. This combination simplifies for handling and validation, ensuring secure
and user-friendly data input in web applications.
OpenCV is a Computer Vision library with APIs that let you setup a pipeline
for your Computer Vision project. I/O Loading data from image files, videos,
capturing devices. Performing feature extraction. OpenCV contains a long list of
existing algorithms so you don't have to implement them yourself. Applying
machine learning algorithms for decision making, object recognition and detection.
System Definition
SYSTEM DESIGN
Software design is actually a multistep process that focuses on four distinct attributes of a
program:
Data structure
Software architecture
Interface representations
Procedural (algorithmic) detail
The design process translates requirements into a representation of the software that can
be assessed for quality before coding begins. System study provides an understanding of the
procedural details necessary for implementing the system recommended in the feasibility study.
Basically, it is all about the creation of a new system. This is a critical phase since it decides the
quality of the system and has a major impact on the testing and implementation phases. This
design document is a reference regarding the development of this project. This document gives all
the details of the modules and functions present in this project.
System design consists of three major steps:
Drawings of the expanded system flowcharts to identify all the processing functions
required.
The allocation of the equipment and software to be used.
The identification of test requirements for the system.
While designing the system it passes through two different stages of development namely
Logical design and Physical design. The former reviews the present physical system, proposed
input and output specifications, makes edit security and control specifications and prepares a
logical walk- through. The latter maps out the details of the physical system, plans the system
implementation and specifies new hardware and software.
The fields in the database must be self-explanatory. User friendly and descriptive standard
screens are to be generated. For a particular mask, a generalized standard screen format is to be
made, as it will reduce avoidable errors during data entry. While menu design, it must be self-
explanatory, simple, brief, compact and attractive. Provision for necessary validation messages and
auto validation are to be made. The reports are generated as per need and accurately all the screens
including the menus are self-explanatory, standardized and simple.
The correctness of the design of a system depends upon the level of precision of the
system built which satisfies the requirements of the system. The aim of the design phase is to
produce the best possible design within the limitations imposed by the requirements and the
facilities.
It is the process of defining the components, modules, interfaces, and data for
a system to satisfy specified requirements. System development is the process of
creating or altering systems, along with the processes, practices, models, and
methodologies used to develop them. The purpose of the System Design process is
to provide sufficient detailed data and information about the system and its system
elements to enable the implementation consistent with architectural entities as
defined in models and views of the system architecture.
Elements of a System
Modules - This are components that handle one specific tasks in a system.
A combination of the modules make-up the system.
SYSTEM ARCHITECTURE:
It is a conceptual model that describes the structure and behavior of multiple
components and subsystems like multiple software applications, network devices,
hardware, and even other machinery of a system. It is Architecture Description
Language (ADL) which helps to describe the entire system architecture. So, it is a
much broader topic. System architecture can be broadly categorized into centralized
and decentralized architectural an organization.
A software architecture is a set of principles that define the way software is
designed and developed. An architecture defines the structure of the software system
and how it is organized. It also describes the relationships between components, levels
of abstraction, and other aspects of the software system.
Behavioral Approach
Detailed Design
DATA-FLOW DIAGRAM
Driver Alarm
Subject Drowsiness
Detection
System
Find
Subject Landmark, Alert if drowsy
Calculate
threshold
Implementation
IMPLEMENTATION
app = Flask(__name__)
mixer.init()
no_driver_sound = mixer.Sound('nodriver_audio.wav')
sleep_sound = mixer.Sound('sleep_sound.wav')
tired_sound = mixer.Sound('rest_audio.wav')
# Checking if it is blinked
if (ratio > 0.22):
return 'active'
else:
return 'sleep'
def mouth_aspect_ratio(mouth):
# compute the euclidean distances between the two sets of
# vertical mouth landmarks (x, y)-coordinates
A = compute(mouth[2], mouth[10]) # 51, 59
B = compute(mouth[4], mouth[8]) # 53, 57
if(time.time()-rest_time_start>3):
tired_sound.play()
# cv2.imshow("USER",tired_img)
tired_sound.stop()
return
def detech():
# status marking for current state
sleep_sound_flag = 0
no_driver_sound_flag = 0
yawning = 0
no_yawn = 0
sleep = 0
active = 0
status = ""
color = (0, 0, 0)
no_driver=0
frame_color = (0, 255, 0)
# Initializing the camera and taking the instance
cap = cv2.VideoCapture(0)
while True:
_, frame = cap.read()
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
face_frame = frame.copy()
faces = detector(gray, 0)
KLESNC /BCA/VI Sem/2022-2023 Page 23
Driver Drowsiness Detection
# The numbers are actually the landmarks which will show eye
left_blink = blinked(landmarks[36], landmarks[37],
landmarks[38], landmarks[41], landmarks[40],
landmarks[39])
right_blink = blinked(landmarks[42], landmarks[43],
landmarks[44], landmarks[47], landmarks[46],
landmarks[45])
mouth = landmarks[mStart:mEnd]
mouthMAR = mouth_aspect_ratio(mouth)
mar = mouthMAR
sleep_sound_flag = 0
sleep_sound.stop()
no_driver_sound_flag=1
@app.route("/open_camera")
def open():
detech()
print("open camera")
return redirect("/")
@app.route("/")
def home():
return render_template("index.html")
if __name__ == "__main__":
app.run(debug=True)
INDEX.HTML CODE
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>DDD</title>
<link href="https://fonts.googleapis.com/css2?
family=Source+Sans+Pro:wght@300;400&display=swap" rel="stylesheet">
<link rel="stylesheet" href="/static/css/bootstrap.min.css">
<link rel="stylesheet" href="/static/css/slick.css" type="text/css" />
<link rel="stylesheet" href="/static/css/templatemo-style.css">
<link rel='stylesheet' href='https://use.fontawesome.com/releases/v5.2.0/css/all.css'>
<link rel='stylesheet'
href='https://use.fontawesome.com/releases/v5.2.0/css/fontawesome.css'><link
rel="stylesheet" href="./style.css">
</head>
<body>
<video autoplay muted loop id="bg-video">
<source src="/static/video/gfp-astro-timelapse.mp4" type="video/mp4">
</video>
<div class="page-container">
<div class="container-fluid">
<div class="row">
<div class="col-xs-12">
<div class="cd-slider-nav">
<nav class="navbar navbar-expand-lg" id="tm-nav">
<a class="navbar-brand" href="#">Driver Drowiness Detection</a>
<div class="text-center">
<!-- btn btn-primary tm-intro-btn tm-page-link -->
<a href="/open_camera" class="btn btn-primary tm-intro-btn">
Start Detection
</a>
</div>
</div>
</li>
</p>
</div>
</div>
</li>
<li data-page-no="4">
<div class="mx-auto page-width-2">
<div class="row">
<div class="col-md-6 me-0 ms-auto">
</div>
</div>
<!-- Preloader, https://ihatetomatoes.net/create-custom-preloading-screen/ -->
<div id="loader-wrapper">
<div id="loader"></div>
<div class="loader-section section-left"></div>
<div class="loader-section section-right"></div>
</div>
<script src="/static/js/jquery-3.5.1.min.js"></script>
<script src="/static/js/bootstrap.min.js"></script>
<!-- <script src="/static/js/slick.js"></script> -->
<script src="/static/js/templatemo-script.js"></script>
</body>
</html>
Testing
INTRODUCTION TO TESTING
Software Testing is a critical element of software quality assurance and represents the
ultimate review of specification, design and coding, Testing presents an interesting anomaly for
the software engineer.
TESTING OBJECTIVE
Testing is a process of executing a program with the intent of finding an error.
A good test case is one that has a probability of finding an as yet undiscovered error.
A successful test is one that uncovers an undiscovered error.
TESTING STRATEGIES
A Strategy for software testing integrates software test cases into a series of well planned
steps that result in the successful construction of software. Software testing is a broader topic for
what is referred to as Verification and Validation. Verification refers to the set of activities that
ensure that the software correctly implements a specific function. Validation refers he set of
activities that ensure that the software that has been built is traceable to customer’s requirements.
Unit testing focuses verification effort on the smallest unit of software design that is the
module. Using procedural design description as a guide, important control paths are tested to
uncover errors within the boundaries of the module. The unit test is normally white box testing
oriented and the step can be conducted in parallel for multiple modules.
Integration Testing:
Integration testing is a systematic technique for constructing the program structure, while
conducting test to uncover errors associated with the interface. The objective is to take unit tested
methods and build a program structure that has been dictated by design.
Top-down Integration:
Top down integrations is an incremental approach for construction of program structure.
Modules are integrated by moving downward through the control hierarchy, beginning with the
main control program. Modules subordinate to the main program are incorporated in the structure
either in the breath-first or depth-first manner.
Bottom-up Integration:
This method as the name suggests, begins construction and testing with atomic modules
i.e., modules at the lowest level. Because the modules are integrated in the bottom up manner the
processing required for the modules subordinate to a given level is always available and the need
for stubs is eliminated.
Validation Testing:
At the end of integration testing software is completely assembled as a package. Validation
testing is the next stage, which can be defined as successful when the software functions in the
manner reasonably expected by the customer. Reasonable expectations are those defined in the
software requirements specifications. Information contained in those sections form a basis for
validation testing approach.
System Testing:
System testing is actually a series of different tests whose primary purpose is to fully
exercise the computer-based system. Although each test has a different purpose, all work to verify
that all system elements have been properly integrated to perform allocated functions.
Security Testing:
Attempts to verify the protection mechanisms built into the sytem.
Performance Testing:
This method is designed to test runtime performance of software within the context of an
integrated system.
involves much more than just running the program a few times to see whether it works. Thorough
analysis of the program under test, backed by a broad knowledge of testing techniques and tools
are prerequisites to systematic testing.
Software Testing is the process of executing software in a controlled manner; in order to
answer the question “Does this software behave as specified?” Software testing is used in
association with Verification and Validation. Verification is the checking of or testing of items,
including software, for conformance and consistency with an associated specification. Software
testing is just one kind of verification, which also uses techniques as reviews, inspections, walk-
through. Validation is the process of checking what has been specified is what the user actually
wanted.
Validation: Are we doing the right job?
Methodology
At SDEI, 3 levels of software testing is done at various SDLC phases
Unit Testing: in which each unit (basic component) of the software is tested to verify that the
detailed design for the unit has been correctly implemented
System testing: in which the software is integrated to the overall product and tested to show
that all requirements are met. A further level of testing is also done, in accordance with
requirements:
Acceptance testing: upon which the acceptance of the complete software is based. The clients
often do this.
Regression testing: is used to refer the repetition of the earlier successful tests to ensure that
changes made in the software have not introduced new bugs/side effects.
In recent years the term grey box testing has come into common usage. The typical grey
box tester is permitted to set up or manipulate the testing environment, like seeding a database, and
can view the state of the product after his actions, like performing a SQL query on the database to
be certain of the values of columns. It is used almost exclusively of client-server testers or others
who use a database as a repository of information, but can also apply to a tester who has to
manipulate XML files (DTD or an actual XML file) or configuration files directly.
It can also be used of testers who know the internal workings or algorithm of the software
under test and can write tests specifically for the anticipated results. For example, testing a data
warehouse implementation involves loading the target database with information, and verifying
the correctness of data population and loading of data into the correct tables.
Test levels
o Unit testing tests the minimal software component and sub-component or modules by the
programmers.
o Integration testing exposes defects in the interfaces and interaction between integrated
components (modules).
o Functional testing tests the product according to programmable work.
o System testing tests an integrated system to verify/validate that it meets its requirements.
o Acceptance testing can be conducted by the client. It allows the end-user or customer or client
to decide whether or not to accept the product. Acceptance testing may be performed after the
testing and before the implementation phase. See also Development stage
o Alpha testing is simulated or actual operational testing by potential users/customers or an
independent test team at the developers' site. Alpha testing is often employed for off-the-shelf
software as a form of internal acceptance testing, before the software goes to beta testing.
o Beta testing comes after alpha testing. Versions of the software, known as beta versions, are
released to a limited audience outside of the company. The software is released to groups of
people so that further testing can ensure the product has few faults or bugs. Sometimes, beta
versions are made available to the open public to increase the feedback field to a maximal
number of future users.
It should be noted that although both Alpha and Beta are referred to as testing it is in fact
use emersion. The rigors that are applied are often unsystematic and many of the basic tenets of
testing
process are not used. The Alpha and Beta period provides insight into environmental and
utilization conditions that can impact the software.
After modifying software, either for a change in functionality or to fix defects, a regression
test re-runs previously passing tests on the modified software to ensure that the modifications
haven't unintentionally caused a regression of previous functionality. Regression testing can be
performed at any or all of the above test levels. These regression tests are often automated.
3. Test Development: Test Procedures, Test Scenarios, Test Cases, Test Scripts to use in testing
software.
4. Test Execution: Testers execute the software based on the plans and tests and report any errors
found to the development team.
5. Test Reporting: Once testing is completed, testers generate metrics and make final reports on
their test effort and whether or not the software tested is ready for release.
Test Cases:
Error
Screenshots
SCREENSHOTS
OUTPUT:
Awake
Sleeping
Yawning
No Driver
Conclusion
CONCLUSION
The drowsiness detection and correction system developed is capable of
detecting drowsiness in a rapid manner.
The system which can differentiate normal eye blink and drowsiness which can
prevent the driver from entering the state of sleepiness while driving.
When the eyes have been closed for about two seconds, the alarm beeps to
alert the driver and speed of the vehicle is reduced.
Future Enhancement
FUTURE ENHANCEMENT
The future works may focus on the utilization of outer factors such as vehicle
states, sleeping hours, Weather Conditions, Mechanical data etc. for fatigue
measurement.
Driver Drowsiness pose a major threat to highway safety, and the problem is
particularly severe for commercial motor vehicle operators.
Monitoring the driver’s state of drowsiness and providing feedback on their
conditions.
Twenty-four hours operations, high annual mileage, exposure to challenging
environmental conditions and demanding work schedules all contribute to this
serious safety issue.
Currently, there is no adjustment in zoom or direction of the camera during
operation. Future work may be to automatically zoom is on the eyes once they
are localized.
Bibliography
BIBLIOGRAPY
https://pyimagesearch.com/2017/05/08/drowsiness-detection-opencv/
https://www.pantechsolutions.net/driver-drowsiness-detection-using-opencv-and-python
https://data-flair.training/blogs/python-project-driver-drowsiness-detection-system/
https://en.wikipedia.org/wiki/Driver_drowsiness_detection