Iskocopykalle
Iskocopykalle
INTRODUCTION
1.1 Overview
1.2. Scope
1
1.3. Definitions and Acronyms
DISADVANTAGE
.
2
DISADVANTAGES
.
DISADVANTAGES
.
3
ADVANTAGES
No Database:
4
CHAPTER 2
LITERATURE
SURVEY
2.1 INTRODUCTION
5
2.2 JOURNAL 1
ABSTRACT:
DRAWBACKS:
6
2.3 JOURNAL 2
TITLE: Driver Fatigue Detection based on Eye Tracking and Dynamic Template
Matching
ABSTRACT:
DRAWBACKS:
7
2.4 JOURNAL 3
ABSTRACT:
DRAWBACKS:
D
8
CHAPTER 3
SYSTEM ANALYSIS
3.1 INTRODUCTION
9
3.2 SOFTWARE REQUIREMENTS
10
CHAPTER 4
SOFTWARE DESIGN
Software design is a mechanism to transform user requirements into some
suitable form, which helps the programmer in software coding and implementation.
The software design phase is the first step in SDLC (Software Design Life Cycle),
which moves the concentration from the problem domain to the solution domain.
11
Figure 4.1 Architectural design
12
4.2 UML DIAGRAMS
The Unified Modelling Language (UML) is one of the most exciting tools in the
world of system development today. The UML enables system builders to create blue
prints that capture their vision in a standard ease-to-understand way and communicate
them to others.
Things
Relationships
Diagrams
Class diagram
Use case diagram
Sequence diagram
Collaboration diagram
State chart diagram
Activity diagram
Component diagram
Deployment diagram
13
4.2.1 CLASS DIAGRAM
Class diagrams are the main building blocks of every object-oriented methods.
It is a static diagram. It represents the static view of an application. Class diagram is
not only used for visualizing, describing, and documenting different aspects of a
system but also for constructing executable code of the software application.
Class diagram describes the attributes and operations of a class and also the
constraints imposed on the system. The class diagrams are widely used in the
modeling of object-oriented systems because they are the only UML diagrams, which
can be mapped directly with object-oriented languages.
Class diagram is a static diagram and it is used to model the static view of a
system. The static view describes the vocabulary of the system. Generally, UML
diagrams are not directly mapped with any object-oriented programming languages
but the class diagram is an exception. Class diagram clearly shows the mapping with
object- oriented languages such as Java, C++, etc. From practical experience, class
diagram is generally used for construction purpose.
The purpose of the class diagram is to model the static view of an application.
Class diagrams are the only diagrams which can be directly mapped with object-
oriented languages and thus widely used at the time of construction.
This is the only UML which can appropriately depict various aspects of OOPs
concept.
Analysis and design of the static view of an application.
Describe responsibilities of a system.
Base for component and deployment diagrams.
14
Figure 4.2 Class Diagram
15
4.2.2 USE CASE DIAGRAM
Use case diagrams are typically developed in the early stage of development
and are used to gather the requirements of a system including internal and external
influences. These requirements are mostly design requirements. Hence, when a
system is analyzed to gather its functionalities, use cases are prepared and actors are
identified. When the initial task is complete, use case diagrams are modelled to
present the outside view.
The main purpose of a use case diagram is to portray the dynamic aspect of a
system. It accumulates the system's requirement, which includes both internal as well
as external influences. It invokes persons, use cases, and several things that invoke the
actors and elements accountable for the implementation of use case diagrams. It
represents how an entity from the external environment can interact with a part of the
system.
16
Figure 4.3 Use Case Diagram
17
4.2.3 ACTIVITY DIAGRAM
The activity diagram is used to demonstrate the flow of control within the
system rather than the implementation. It models the concurrent and sequential
activities.
The activity diagram helps in envisioning the workflow from one activity to
another. It put emphasis on the condition of flow and the order in which it occurs. The
flow can be sequential, branched, or concurrent, and to deal with such kinds of flows,
the activity diagram has come up with a fork, join, etc.
Activity is a particular operation of the system. Activity diagrams are not only
used for visualizing the dynamic nature of a system, but they are also used to
construct the executable system by using forward and reverse engineering techniques.
The only missing thing in the activity diagram is the message part. It does not
show any message flow from one activity to another. Activity diagram is sometimes
considered as the flowchart. Although the diagrams look like a flowchart, they are
not. It shows different flows such as parallel, branched, concurrent, and single.
18
Figure 4.4 Activity Diagram
19
4.3 MODULES
Data Acquisition
Frame Extraction
Face Detection & Facial Landmark Detection
Calculate
Using this module we will connect application to webcam using OPENCV built-in
function called VideoCapture. Video is recorded using webcam and processed in a
laptop.
Using this module we will grab frames from webcam and then extract each picture
frame by frame and convert image into 2 dimensional array.
We will detect faces from images and then extract facial features from the frames.
4.3.4 CALCULATE
Using this module we will calculate distance with Euclidean Distance formula to
check whether given face distance closer to eye blinks or yawning, if eyes blink for 20
frames continuously and mouth open as yawn then it will alert driver.
20
CHAPTER 5
IMPLEMENTATION
5.1 INTRODUCTION
5.2.1 DOMAIN
MACHINE LEARNING
Recommendation engines are a common use case for machine learning. Other
popular uses include fraud detection, spam filtering, malware threat detection,
business process automation (BPA) and Predictive maintenance.
Supervised Learning
Unsupervised Learning
Reinforcement Learning
21
Here in our system we use supervised learning approach.
Supervised machine learning requires the data scientist to train the algorithm with
both labeled inputs and desired outputs. Supervised learning algorithms are good for
the following tasks:
PYTHON
It is used for
LIBRARIES
A python library is a collection of utility methods, classes, and modules that your
application code can use to perform specific tasks without writing the functionalities
from scratch. It contains bundles of code that can be used repeatedly in different
programs. It makes python programming simpler and convenient for the programmer,
as we don’t need to write the same code again and again for different programs.
Python
22
libraries play a very vital role in fields of Machine Learning, Data Science, Data
Visualization, etc.
TKinter
Python offers multiple options for developing GUI (Graphical User Interface).
Out of all the GUI methods, TKinter is the most commonly used method. It is a
standard python interface to the Tk GUI toolkit shipped with Python. Python with
TKinter is the fastest and easiest way to create the GUI applications. Creating a GUI
using TKinter is an easy task.
NumPy
NumPy is a python library used for working with arrays. It also has functions
working for in domain of linear algebra, fourier transform, and matrices.
In Python we have lists that serve the purpose of arrays, but they are slow to
process. NumPy arrays are stored at one continuous place in memory unlike lists, so
process can access and manipulate them very efficiently.
OpenCV
Dlib
Dlib is one of the most powerful and easy-to-go open-source library consisting
of machine learning library/algorithms and various tools for creating software. Dlib is
mostly used for face recognition purposes. They analyzed the object/face using the
functions called HOG (Histogram of oriented gradients) and CNN (Convolutional
Neural Networks).
23
Scikit-learn (SKlearn)
Scikit-learn is the most useful and robust library for machine learning in
python. It features various algorithms like support vector machine, random forests,
and k- neighbours, and it also supports python numerical and scientific libraries like
NumPy and SciPY.
Imutils
5.2.3. ALGORITHM
Intuitively, the further from the hyperplane our data points lie, the more
confident we are that they have been correctly classified. We therefore want our data
points to be as far away from the hyperplane as possible, while still being on the
correct side of it. So when new testing data is added, whatever side of the hyperplane
it lands will decide the class that we assign to it.
The distance between the hyperplane and the nearest data point from either set
is known as the margin. The goal is to choose a hyperplane with the greatest possible
margin between the hyperplane and any point within the training set, giving a greater
chance of new data being classified correctly.
24
CHAPTER 6
SOURCE
CODE
main = tkinter.Tk()
main.title("Driver Drowsiness Monitoring")
main.geometry("500x400")
def EAR(drivereye):
point1 = dist.euclidean(drivereye[1], drivereye[5])
point2 = dist.euclidean(drivereye[2], drivereye[4])
# compute the euclidean distance between the horizontal
distance = dist.euclidean(drivereye[0], drivereye[3])
# compute the eye aspect ratio
ear_aspect_ratio = (point1 + point2) / (2.0 * distance)
return ear_aspect_ratio
def MOR(drivermouth):
# compute the euclidean distances between the horizontal
point = dist.euclidean(drivermouth[0], drivermouth[6])
# compute the euclidean distances between the vertical
point1 = dist.euclidean(drivermouth[2], drivermouth[10])
point2 = dist.euclidean(drivermouth[4], drivermouth[8])
25
# taking average
26
Ypoint = (point1+point2)/2.0
# compute mouth aspect ratio
mouth_aspect_ratio = Ypoint/point
return mouth_aspect_ratio
def startMonitoring():
pathlabel.config(text="Webcam Connected Successfully")
webcamera = cv2.VideoCapture(0)
svm_predictor_path = 'SVMclassifier.dat'
EYE_AR_THRESH = 0.25
EYE_AR_CONSEC_FRAMES = 10
MOU_AR_THRESH = 0.75
COUNTER = 0
yawnStatus = False
yawns = 0
svm_detector = dlib.get_frontal_face_detector()
svm_predictor = dlib.shape_predictor(svm_predictor_path)
(lStart, lEnd) = face_utils.FACIAL_LANDMARKS_IDXS["left_eye"]
(rStart, rEnd) = face_utils.FACIAL_LANDMARKS_IDXS["right_eye"]
(mStart, mEnd) = face_utils.FACIAL_LANDMARKS_IDXS["mouth"]
while True:
ret, frame = webcamera.read()
frame = imutils.resize(frame, width=640)
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
prev_yawn_status = yawnStatus
rects = svm_detector(gray, 0)
27
leftEAR = EAR(leftEye)
rightEAR = EAR(rightEye)
mouEAR = MOR(mouth)
ear = (leftEAR + rightEAR) / 2.0
leftEyeHull = cv2.convexHull(leftEye)
rightEyeHull = cv2.convexHull(rightEye)
mouthHull = cv2.convexHull(mouth)
cv2.drawContours(frame, [leftEyeHull], -1, (0, 255, 255), 1)
cv2.drawContours(frame, [rightEyeHull], -1, (0, 255, 255), 1)
cv2.drawContours(frame, [mouthHull], -1, (0, 255, 0), 1)
28
yawns+=1
cv2.putText(frame, "MAR: {:.2f}".format(mouEAR), (480, 60),
cv2.FONT_HERSHEY_SIMPLEX, 0.7, (0,0,255), 2)
cv2.putText(frame,"Visual Behaviour & Machine Learning Drowsiness
@ DROWSINESS”, (370,470), cv2. FONT_HERSHEY_COMPLEX,
0.6,(153,51,102),1)
cv2.imshow("Frame", frame)
key = cv2.waitKey(1) & 0xFF
if key == ord("q"):
break
cv2.destroyAllWindows()
webcamera.release()
pathlabel = Label(main)
pathlabel.config(bg='DarkOrange1', fg='white')
pathlabel.config(font=font1)
pathlabel.place(x=50,y=250)
main.config(bg='chocolate1')
main.mainloop()
29
CHAPTER 7
TESTING
7.1 INTRODUCTION
Software Testing is defined as an activity to check whether the actual results
match the expected results and to ensure that the software system is Defect free. It
involves execution of a software component or system component to evaluate one or
more properties of interest. Software testing also helps to identify errors, gaps or
missing requirements in contrary to the actual requirements. It can be either done
manually or using automated tools. Some prefer saying Software testing as a White
Box and Black Box Testing.
The process of software testing aims not only at finding faults in the existing
software but also at finding measures to improve the software in terms of efficiency,
accuracy and usability. It mainly aims at measuring specification, functionality and
performance of a software program or application.
30
IMPORTANCE OF SOFTWARE TESTING:
The importance of software testing is imperative. Software Testing is important
because of the following reasons:
Software Testing points out the defects and errors that were made during the
development phases. It looks for any mistake made by the programmer during
the implementation phase of the software.
It ensures that the customer finds the organization reliable and their
satisfaction in the application is maintained. Sometimes contracts include
monetary penalties with respect to the timeline and quality of the product and
software testing prevent monetary losses.
It also ensures the Quality of the product. Quality product delivered to the
customers helps in gaining their confidence. It makes sure that the software
application requires lower maintenance cost and results in more accurate,
consistent and reliable results.
Users are not inclined to use software that has bugs. They may not adopt
software if they are not happy with the stability of the application. Testing is
important for the product to stay in business.
It’s important to ensure that the application should not result in any failures
because it can be very expensive in the future or in the later stages of the
development.
31
Quality Check: Software testing helps in determining following set of
properties of any software such as
Functionality
Reliability
Usability
Efficiency
Maintainability
Portability
32
ADVANTAGES OF MANUAL TESTING:
It does not require programming knowledge while using the Black box method.
It is used to test dynamically changing GUI design.
Tester interacts with software as a real user so that they are able to discover
usability and user interface issues.
It ensures that the software is a hundred percent bug-free.
It is cost-effective.
Easy to learn for new testers.
DISADVANTAGES OF MANUAL TESTING:
It requires a large number of human resources.
It is very time-consuming.
Tester develops test cases based on their skills and experience. There is no
evidence that they have covered all functions or not.
Test cases cannot be used again. Need to develop separate test cases for each
new software.
It does not provide testing on all aspects of testing.
Since two teams work together, sometimes it is difficult to understand each
other's motives, it can mislead the process.
2. AUTOMATION TESTING:
Automation testing, which is also known as Test Automation, is when the
tester writes scripts and uses another software to test the product. This process
involves automation of a manual process. Automation Testing is used to re-run the
test scenarios that were performed manually, quickly, and repeatedly.
Apart from regression testing, automation testing is also used to test the
application from load, performance, and stress point of view. It increases the test
coverage, improves accuracy, and saves time and money in comparison to manual
testing.
33
Automation Testing provides re-usability of test cases on testing of different
versions of the same software.
Automation testing is reliable as it eliminates hidden errors by executing test
cases again in the same way.
Automation Testing is comprehensive as test cases cover each and every
feature of the application.
It does not require many human resources, instead of writing test cases and
testing them manually, they need an automation testing engineer to run them.
The cost of automation testing is less than manual testing because it requires a
few human resources.
34
Figure 7.1 Levels of Testing
1. UNIT TESTING:
Unit Testing is a software testing technique by means of which individual
units of software i.e., group of computer program modules, usage procedures and
operating procedures are tested to determine whether they are suitable for use or not.
It is a testing method using which every independent module is tested to determine if
there are any issue by the developer himself. It is correlated with functional
correctness of the independent modules.
Unit Testing is defined as a type of software testing where individual
components of a software are tested. Unit Testing of software product is carried out
during the development of an application. An individual component may be either an
individual function or a procedure. Unit Testing is typically performed by the
developer.
Unit testing focuses on the building blocks of the software system, that is,
objects and subsystems. They are three motivations behind focusing on components.
First, unit testing reduces the complexity of the overall test activities, allowing us to
focus on smaller units of the system. Unit testing makes it easier to pinpoint and
correct faults given that few computers are involved in this test. Unit testing allows
parallelism in the testing activities; that is each component can be tested
independently of one another.
The specific candidates for unit testing are chosen from the object model and
the system decomposition of the system. In principle, all the objects developed during
the development process should be tested.
35
OBJECTIVE OF UNIT TESTING:
The objective of Unit Testing is:
To isolate a section of code.
To verify the correctness of code.
To test every function and procedure.
To fix bug early in development cycle and to save costs.
To help the developers to understand the code base and enable them to make
changes quickly.
To help for code reuse.
ADVANTAGES:
Reduces Cost of Testing as defects are captured in very early phase.
Unit Tests, when integrated with build gives the quality of the build as well.
Unit Testing allows developers to learn what functionality is provided by a
unit and how to use it to gain a basic understanding of the unit API.
Unit testing allows the programmer to refine code and make sure the module
works properly.
Unit testing enables to test parts of the project without waiting for others to be
completed.
2. INTEGRATION TESTING:
Integration testing is the second level of the software testing process comes
after unit testing. In this testing, units or individual components of the software are
tested in a group. The focus of the integration testing level is to expose defects at the
time of interaction between integrated components or units.
Unit testing uses modules for testing purpose, and these modules are combined
and tested in integration testing. The Software is developed with a number of software
modules that are coded by different coders or programmers. The goal of integration
testing is to check the correctness of communication among all the modules.
In integration testing, testers test the interfaces between the different modules.
These modules combine together to form a bigger component or the system. Hence, it
becomes very crucial to validate their behavior when they work together. Apart from
the interfaces, they also test the integrated components. Integration testing is the next
36
level of testing after unit testing. Testers do it after completion of the unit testing
phase. Integration testing techniques can be a white box or black box depending on
the project requirements.
37
It results in higher code coverage.
It starts in the early stages when the entire module may not be ready. Hence, it
avoids the bugs getting into the system.
3. SYSTEM TESTING:
System Testing is a type of software testing that is performed on a complete
integrated system to evaluate the compliance of the system with the corresponding
requirements.
In other words, System Testing means testing the system as a whole. All the
modules/components are integrated in order to verify if the system works as expected
or not. System Testing is done after Integration Testing. This plays an important role
in delivering a high-quality product.
The purpose of a system test is to evaluate the end-to-end system
specifications. Usually, the software is only one element of a larger computer-based
system. Ultimately, the software is interfaced with other software/hardware systems.
System Testing is actually a series of different tests whose sole purpose is to exercise
the full computer-based system.
In system testing, integration testing passed components are taken as input.
The goal of integration testing is to detect any irregularity between the units that are
integrated together. System testing detects within both the integrated units and the
whole system. The result of system testing is the observed behavior of a component or
a system when it is tested.
System Testing is carried out on the whole system in the context of either
system requirement specifications or functional requirement specifications or in the
context of both. System testing tests the design and behavior of the system and also
the expectations of the customer.
38
System testing must verify whether the design of the functional and non-
functional behaviours of the system is as per the customer’s specifications.
Validate that the system is complete and will work as expected.
System testing aims to build confidence in the quality of the system as a whole.
System testing also aims to find defects and to prevent defects from escaping
to higher test levels or production. Additionally, it is the only phase that
occurs on the full System just before the User Acceptance testing. So it’s
critical to find all the possible defects at this stage, and they don’t leak to
production.
System Testing results are used by stakeholders to make release decisions. The
Entry criteria for User Acceptance testing is the basis completion of System
Testing. System testing may also adhere to legal or regulatory requirements or
standards.
4. ACCEPTANCE TESTING:
Acceptance Testing is a method of software testing where a system is tested
for acceptability. The major aim of this test is to evaluate the compliance of the
system with the business requirements and assess whether it is acceptable for delivery
or not.
The standard definition of Acceptance testing is given as, “It is a formal
testing according to user needs, requirements and business processes conducted to
determine whether a system satisfies the acceptance criteria or not and to enable the
users, customers or other authorized entities to determine whether to accept the
system or not.”
Acceptance Testing is the last phase of software testing performed after
System Testing and before making the system available for actual use.
The main goal behind acceptance testing is to check whether the developed
software product passes the acceptance norms defined on the basis of user and
business requirements, so as to declare it acceptable or non-acceptable for its use by
the users. Acceptance testing is one of the last types of software testing performed
over a software or application. It is conducted by a pool of targeted users to ensure the
readiness and quality of the system from user's perspective, which allows the team to
meet their needs and expectations.
40
ADVANTAGES OF ACCEPTANCE TESTING:
Acceptance testing has the following benefits, complementing those which can be
obtained from unit tests:
Encouraging closer collaboration between developers on the one hand and
customers, users or domain experts on the other, as they entail that business
requirements should be expressed
Providing a clear and unambiguous “contract” between customers and
developers; a product which passes acceptance tests will be considered
adequate (though customers and developers might refine existing tests or
suggest new ones as necessary).
Decreasing the chance and severity both of new defects and regressions
(defects impairing functionality previously reviewed and declared acceptable).
41
1. WHITE-BOX TESTING
White –box testing, sometimes called glass-box testing is a test, case designed
method that uses the control structure of the procedural design to derive test cases.
Using white-box testing methods, the s/w engineer can derive test cases that guarantee
that all independent paths within a module have been exercised at least once. Exercise
all logical decisions on their true and false sides. Execute all loops at their boundaries
and within their operational bounds. Exercise internal data structures to ensure their
validity.
Basis path testing is a white-box testing technique. The basis path
method enables the test case designer to derive a logical complexity
measure of a procedural design and use this measure as a guide for
defining a basis set are guaranteed to exercise every statement in the
program at least one-time during testing.
ADVANTAGES:
As the tester has knowledge of the source code, it becomes very easy to find
out which type of data can help in testing the application effectively.
It helps in optimizing the code.
Extra lines of code can be removed which can bring in hidden defects.
Due to the tester's knowledge about the code, maximum coverage is attained
during test scenario writing.
DISADVANTAGES:
Due to the fact that a skilled tester is needed to perform white-box testing, the
costs are increased.
Sometimes it is impossible to look into every nook and corner to find out
hidden errors that may create problems, as many paths will go untested.
It is difficult to maintain white-box testing, as it requires specialized tools like
code analyzers and debugging tools.
42
2. BLACK BOX TESTING
ADVANTAGES
DISADVANTAGES
43
Blind coverage, since the tester cannot target specific code segments or error-
prone areas.
7.2.2 SCENARIOS
44
CHAPTER 8
RESULTS
8.1 Run the
application
45
Figure 8.2 Command Prompt Screen
46
8.2 OUTPUT SCREENS
The main window of the application gets opened.
Then click on start Start Behaviour Monitoring Using Webcam button.
47
We place a synthetic driver infront of the webcam.
The webcam starts recording the video.
It calculates the Eye Aspect Ratio and Mouth Opening Ratio and compares
with threshold values.
As a result, it displays the message as “Eyes Open” as shown in Figure 8.4.
48
Now the synthetic driver closes his eyes.
It calculates the Eye Aspect Ratio and Mouth Opening Ratio and
compares with threshold values continuously.
As a result, it displays the message as “Eyes Closed DROWSINESS ALERT”
as shown in Figure 8.5.
49
Now the synthetic driver starts yawning.
It calculates the Eye Aspect Ratio and Mouth Opening Ratio and
compares with threshold values continuously.
As a result, it displays the message as “Eyes Open Yawning, DROWSINESS
ALERT! Yawn Count: 4” as shown in Figure 8.6.
50
CHAPTER 9
CONCLUSIO
N
51
CHAPTER 10
BIBLIOGRAPGHY
10.2 WEBSITES
https://www.researchgate.net/publication/353922961_DRIVER_DROWSINE
SS_MONITORING_SYSTEM_USING_VISUAL_BEHAVIOUR_AND_MA
CHINE_LEARNING
https://www.springerprofessional.de/en/svm-based-drivers-drowsiness-
detection-using-machine-learning-an/18570020
https://www.semanticscholar.org/paper/Driver-drowsiness-monitoring-system-
using-visual-Kumar-Patra/1a179a87878e6168001f7333ae4135b6331c2133
https://www.slideshare.net/venkatjavaprojects/driver-drowsiness-monitoring-
system-using-visual-behaviour-and-machine-learning
52