13 Batch Mini Project[1]]

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 54

DRIVER DROWSINESS DETECTION

A Mini Project Report submitted to


JNTU Hyderabad in partial fulfillment
of the requirements for the award of the degree

BACHELOR OF TECHNOLOGY
In
COMPUTER SCIENCE AND ENGINEERING

Submitted by
P. NEHA 21S11A0533
K. HARIKA 21S11A0515
CH. MEGHANA 21S11A0525
P. TEJARAKSHITH 21S11A0556

Under the guidance of


Mr. A. Anand
B. Tech, M. Tech
Assistant Professor

DEPARTMENT OF COMPUTER SCIENCE &


ENGINEERING
MALLA REDDY INSTITUTE OF TECHNOLOGY &
SCIENCE
(Approved by AICTE New Delhi and Affiliated to JNTUH)
(Accredited by NBA & NAAC with “A” Grade)
An ISO 9001: 2015 Certified Institution
Maisammaguda, Medchal, Hyderabad-500100, T. S
JULY 2024
i
DEPARTMENT OF COMPUTER SCIENCE &
ENGINEERING
MALLA REDDY INSTITUTE OF TECHNOLOGY &
SCIENCE
(Approved by AICTE New Delhi and Affiliated to JNTUH)
(Accredited by NBA & NAAC with “A” Grade)
An ISO 9001: 2015 Certified Institution
Maisammaguda, Medchal (M), Hyderabad-500100, T. S.
JULY 2024

CERTIFICATE
This is to certify that the mini project entitled “DRIVER DROWSINESS
DETECTION” has been submitted by P. NEHA (21S11A0533), K.
HARIKA (21S11A0515), CH. MEGHANA (21S11A0525) and P.
TEJARAKSHITH (21S11A0556) in partial fulfillment of the requirements
for the award of BACHELOR OF TECHNOLOGY in COMPUTER SCIENCE
& ENGINEERING. This record of bonafide work carried out by them under
my guidance and supervision. The result embodied in this mini
project report has not been submitted to any other University or
Institute for the award of any degree.

Mrs. K. HARIKA Mrs. K. MAMATHA


Assistant Professor Head of the
Department
Project Guide

ii
External Examiner
ACKNOWLEDGEMENT
The Mini Project work carried out by our team in the
Department of Computer Science and Engineering, Malla
Reddy Instituter of Technology and Science, Hyderabad.
This work is original and has not been submitted in
part or full for any degree or diploma of any other
university.

We wish to acknowledge our sincere thanks to our project


guide Mr. A. Anand, Assistant Professor of Computer
Science & Engineering for formulation of the problem,
analysis, guidance and her continuous supervision during
the course of work.

We acknowledge our sincere thanks to Dr. Vaka Murali


Mohan, Principal and Mrs. K. Mamatha, Head of the
Department and Coordinator, faculty members of CSE
Department for their kind cooperation in making this Mini
Project work a success.

We extend our gratitude to Sri. Ch. Malla Reddy,


Founder Chairman MRGI and Sri. Ch. Mahender Reddy,
Secretary MRGI, Dr.Ch. Bhadra Reddy, President MRGI, Sri.
Ch. Shalini Reddy, Director MRGI, Sri. P. Praveen Reddy,
Director MRGI, for their kind cooperation in providing the
infrastructure for completion of our Mini Project.

We acknowledge our special thanks to the entire


teaching faculty and non-teaching staff members of the
Computer Science & Engineering Department for their support
in making this project work a success.
[

P. NEHA 21S11A0533__________________

iii
K. HARIKA 21S11A0515__________________

CH. MEGHANA 21S11A0525__________________

P. TEJARAKSHITH 21S11A0556__________________

INDEX
CHAPTER Page
no.

ABSTRACT VI
LIST OF FIGURES VII
LIST OF TABLES VIII

1. SYSTEM ANALYSIS 1

1.1 Existing System 1


1.1.1 Disadvantages 1
1.2 Proposed System 1
1.1.2 Advantages 1
1.3 Introduction 1
1.4 Algorithms 4
1.4.1 CNN working procedure 4
2. LITERATURE SURVEY 5

3. SYSTEM DESIGN 7

3.1 System Architecture 7

3.2 Modules 8
3.2.1 Data Acquisition 8
3.2.2 Face Detection 8
3.2.3 Facial Landmark marking 8
3.2.4 Feature Extraction 8
3.2.5 Classification 8
3.3 UML Diagrams 9
3.3.1 Class Diagram 9
3.3.2 Usecase Diagram 10
3.3.3 Sequence Diagram 11

iv
3.4 System Requirements 12
3.4.1 Hardware Requirements 12
3.4.2 Software Requirements 12
4. INPUT&OUTPUT DESIGN
12

4.1 Input Design 13


4.2 Output Design 13
5. SYSTEM ENVIRONMENT 13

5.1 What is Python 14


5.2 What can Python do 14
5.3 Python Install 15
5.4 Virtual Environments and Packages 17
5.5 Using the Python Interpreter 28
5.5.1. Invoking the Interpreter 28
5.5.2 The Interpreter and Its Environment 29
5.6 Introduction to Artificial Intelligence 30
5.6.1 Trending AI Article 31
5.7 Machine Learning 32
5.7.1 Introduction 32
5.8 Approaches 33
5.8.1 k-nearest neighbor 33
5.8.2 Decision Tree Learning 35
5.9 Introduction to Deep Learning 35
6. SYSTEM STUDY 36
6.1 Economic Feasibility 36
6.2 Technical Feasibility 36
6.3 Social Feasibility 36
7. SYSTEM TESTING
36

7.1 TYPES OF TESTS 37


7.1.1 Unit testing 37
7.1.2 Integration testing 37
7.1.3 Functional Testing 37

v
7.1.4 System Testing 38
7.1.5 Acceptance Testing 39
7.2 Test cases 39
8. RESULTS
40

9. CONCLUSION & FUTURE ENHANCEMENT 42


9.1 Conclusion 43
9.2 Future Enhancement 43
10. BIBLIOGRAPHY 43

vi
ABSTRACT

Nowadays, accidents occur during drowsy road trips and increase day by day;
It is a known fact that many accidents occur due to driver fatigue and
sometimes inattention, this research is primarily devoted to maximizing efforts
to identify drowsiness. State of the driver under real driving conditions. The
aim of driver drowsiness detection systems is to try to reduce these traffic
accidents. The secondary data collected focuses on previous research on
systems for detecting drowsiness and several methods have been used to detect
drowsiness or inattentive driving. The goal is to provide an interface where the
program can automatically detect the driver's drowsiness and detect it in the
event of an accident by using the image of a person captured by the webcam
and examining how this information can be used to improve driving safety can
be used. A vehicle safety project that helps prevent accidents caused by the
driver's sleep. Basically, you're collecting a human image from the webcam
and exploring how that information could be used to improve driving safety.
Collect images from the live webcam stream and apply machine learning
algorithm to the image and recognize the drowsy driver or not. When the
driver is sleepy, it plays the buzzer alarm and increases the buzzer sound. If
the driver doesn't wake up, they'll send a text message and email to their
family members about their situation. Hence, this utility goes beyond the
problem of detecting drowsiness while driving. Eye extraction, face extraction
with dlib.
LIST OF FIGURES
Figure No. Figure-name Page No.

Figure 1.1 Django Framework 3

Figure 1.2 Django Model 3

Figure 3.1 System Architecture 7

Figure 3.2 Class Diagram 10

Figure 3.3 Use Case Diagram 11

Figure 3.4 Sequence Diagram 11

Figure 5.1 IBM Watson Diagram 31

Figure 5.2 KNN Example 1 33

Figure 5.3 KNN Example 2 34

Figure 5.4 KNN Example 3 34

Figure 5.5 Decision Tree 35

Figure 5.6 Deep learning 35


LIST OF TABLES
Table No. Table Name Page No.
Table 7.1 Test case for empty login 39
fields

Table 7.2 Test case for wrong login 39


fields

Table 7.3 Test Case for Sign up fail 40


Driver Drowsiness Detection System

CHAPTER – 1: SYSTEM ANALYSIS

1.1 Existing System


Now a days maximum members are using vehicle (car, lorry, bus). According to survey 10 to
15% are accidents accruing because of the driver was in sleepy mode.no software is having
to give alert to the driver

1.1.1 Disadvantages:-

 More accidents are accruing.


 Unable to give alert while driver was sleepy.

1.2 Proposed System


A block diagram of the proposed driver drowsiness monitoring system has been depicted in
Fig 1. At first, the video is recorded using a webcam. The camera will be positioned in front
of the driver to capture the front face image. From the video, the frames are extracted to
obtain 2-D images. Face is detected in the frames using histogram of oriented gradients
(HOG) and linear support vector machine (SVM) for object detection [10]. After detecting
the face, facial landmarks [11] like positions of eye, nose, and mouth are marked on the
images. From the facial landmarks, eye aspect ratio, mouth opening ratio and position of the
head are quantified and using these features and machine learning approach, a decision is
obtained about the drowsiness of the driver. If drowsiness is detected, an alarm will be sent to
the driver to alert him/her. The details of each block are discussed below

1.1.2 Advantages:-

 Provide alert to the driver.


 Decrease the accidents.

1.3 Introduction
Drowsy driving is one of the major causes of deaths occurring in road accidents. The truck
drivers who drive for continuous long hours (especially at night), bus drivers of long-distance
route or overnight buses are more susceptible to this problem. Driver drowsiness is an
overcast nightmare to passengers in every country. Every year, a large number of injuries and
deaths occur due to fatigue related road accidents. Hence, detection of driver’s fatigue and its
indication is an active area of research due to its immense practical applicability. The basic
drowsiness detection system has three blocks/modules; acquisition system, processing system
and warning system. Here, the video of the driver’s frontal face is captured in acquisition
Driver Drowsiness Detection System

system and transferred to the processing block where it is processed online to detect
drowsiness. If drowsiness is detected, a warning or alarm is sent to the driver from the
warning system.

Generally, the methods to detect drowsy drivers are classified in three types; vehicle based,
behavioral based and physiological based. In vehicle-based method, a number of metrics like
steering wheel movement, accelerator or brake pattern, vehicle speed, lateral acceleration,
deviations from lane position etc. are monitored continuously. Detection of any abnormal change
in these values is considered as driver drowsiness. This is a nonintrusive measurement as the
sensors are not attached on the driver. In behavioral based method [1- 7], the visual behavior of
the driver i.e., eye blinking, eye closing, yawn, head bending etc. are analyzed to detect
drowsiness. This is also nonintrusive measurement as simple camera is used to detect these
features. In physiological based method [8,9], the physiological signals like Electrocardiogram
(ECG), Electrooculogram (EOG), Electroencephalogram (EEG), heartbeat, pulse rate etc. are
monitored and from these metrics, drowsiness or fatigue level is detected. This is intrusive
measurement as the sensors are attached on the driver which will distract the driver. Depending
on the sensors used in the system, system cost as well as size will increase. However, inclusion
of more parameters/features will increase the accuracy of the system to a certain extent. These
factors motivate us to develop a low-cost, real time driver’s drowsiness detection system with
acceptable accuracy. Hence, proposed a webcam-based system to detect driver’s fatigue from the
face image only using image processing and machine learning techniques to make the system
low-cost as well as portable.

PYTHON

Python is a general-purpose interpreted, interactive, object-oriented, and high-level


programming language. An interpreted language, Python has a design philosophy that
emphasizes code readability (notably using whitespace indentation to delimit code blocks
rather than curly brackets or keywords), and a syntax that allows programmers to express
concepts in fewer lines of code than might be used in languages such as C++or Java. It
provides constructs that enable clear programming on both small and large scales. Python
interpreters are available for many operating systems. C Python, the reference implementation
of P Python features a dynamic type system and automatic memory management. It supports
multiple programming paradigms, including object-oriented, imperative, functional and
procedural, and has a large and comprehensive standard library
Driver Drowsiness Detection System

DJANGO

Django is a high-level Python Web framework that encourages rapid development and clean,
pragmatic design. Built by experienced developers, it takes care of much of the hassle of Web
development, so you can focus on writing your app without needing to reinvent the wheel.
It’s free and open source.

Django's primary goal is to ease the creation of complex, database-driven websites. Django
emphasizes reusability and "pluggability" of components, rapid development, and the
principle of don't repeat yourself. Python is used throughout, even for settings files and data
models.

Figure No. 1.1 Django Framework

Django also provides an optional administrative create, read, update and delete interface that
is generated dynamically through introspection and configured via admin models
Driver Drowsiness Detection System

Figure No. 1.2 Django Model

1.4 Algorithms
1.4.1 CNN working procedure
To demonstrate how to build a convolutional neural network-based image classifier, we shall
build a 6-layer neural network that will identify and separate one image from other. This
network that we shall build is a very small network that we can run on a CPU as well.
Traditional neural networks that are very good at doing image classification have many more
parameters and take a lot of time if trained on normal CPU. However, our objective is to
show how to build a real-world convolutional neural network using TENSORFLOW
Neural Networks are essentially mathematical models to solve an optimization problem. They
are made of neurons, the basic computation unit of neural networks. A neuron takes an input
(say x), do some computation on it (say: multiply it with a variable w and adds another
variable b) to produce a value (say; z= w x + b). This value is passed to a non-linear function
called activation function (f) to produce the final output (activation) of a neuron. There are
many kinds of activation functions. One of the popular activation functions is Sigmoid. The
neuron which uses sigmoid function as an activation function will be called sigmoid neuron.
Depending on the activation functions, neurons are named and there are many kinds of them
like RELU, TanH.
Driver Drowsiness Detection System

CHAPTER – 2: LITERATURE SURVEY

1.“Intelligent Video-Based Drowsy Driver Detection System under Various Illuminations

and Embedded Software Implementation”

Author: W. L. Ou, M. H. Shih, C. W. Chang, X. H. Yu, C. P. Fan [3]

Abstract: An intelligent video-based drowsy driver detection system, which is unaffected by


various illuminations is developed in this study. Even if a driver wears glasses, the proposed
system detects the drowsy conditions effectively. By a near-infrared-ray (NIR) camera, the
proposed system is divided into two cascaded computational procedures: the driver eyes
detection and the drowsy driver detection. The average open/closed eyes detection rates
without/with glasses are 94% and 78%, respectively, and the accuracy of the drowsy status
detection is up to 91%. By implementing on the FPGA-based embedded platform, the
processing speed with the 640×480 format video is up to 16 frames per second (fps) after
software optimizations

2.“Driver Fatigue Detection based on Eye Tracking and Dynamic Template Matching”

Author: W. B. Horng, C. Y. Chen, Y. Chang, C. H. Fan [10]

Abstract: A vision-based real-time driver fatigue detection system is proposed for driving
safely. The driver's face is located, from color images captured in a car, by using the
characteristic of skin colors. Then, edge detection is used to locate the regions of eyes. In
addition to being used as the dynamic templates for eye tracking in the next frame, the
obtained eyes' images are also used for fatigue detection in order to generate some warning
alarms for driving safety. The system is tested on a Pentium III 550 CPU with 128 MB RAM.
The experiment results seem quite encouraging and promising. The system can reach 20
frames per second for eye tracking, and the average correct rate for eye location and tracking
can achieve 99.1% on four test videos. The correct rate for fatigue detection is l00%, but the
average precision rate is 88.9% on the test videos.

3.“Monitoring Driver Fatigue using Facial Analysis Techniques”

Author: S. Singh, N.P. Papanikolopoulos [11]


Driver Drowsiness Detection System

Abstract: It describes a non-intrusive vision-based system for the detection of driver fatigue.
The system uses a color video camera that points directly rewards the driver's face and
monitors the driver's eyes in order to detect micro-sleeps (short periods of sleep). The system
deals with skin-color information in order to search for the face in the input space. After
segmenting the pixels with skin like color, perform blob processing in order to determine the
exact position of the face

4.“The Steps of Proposed Drowsiness Detection System Design based on Image


Processing in Simulator Driving”

Author: M. Karchani, A. Mazloumi, G. N. Saraji, A. Nahvi, K. S. Haghighi, B. M.


Abadi, A. R. Foroshani, A. Niknezhad [4]

Abstract: Drowsiness detection has many implications including reducing roads traffic
accidents importance. Using image processing techniques is amongst the new and reliable
methods in sleepy face. The present pilot study was done to investigate sleepiness and
providing images of drivers' face, employing virtual-reality driving simulator. In order to
detecting level of sleepiness according to the signal, information related to 25 drivers was
recorded with imaging rate of 10 fps. Moreover, on average 3000 frames was analyzed for
each driver. The frames were investigated by transforming in grey scale space and based on
the Cascade and Viola & Jones techniques and the images characteristics were extracted
using Binary and Histogram methods. The MPL neural network was applied for analyzing
data.70% of information related to each driver were inserted to the network of which 15% for
test and 15% for validation. In the last stage the accuracy of 93% of the outputs were
evaluated. The intelligent detection and usage of various criteria in long-term time frame are
of the advantages of the present study, comparing to other researches. This is helpful in early
detection of sleepiness and prevents the irrecoverable losses by alarming

5. "A Multimodal System for Assessing Alertness Levels Due to Cognitive Loading"

Author: A. Sengupta, A. Dasgupta, A. Chaudhuri, A. George, A. Routray, R. Guha [1]

Abstract: The study presents a multimodal system for assessing alertness levels in response
to cognitive loading. By integrating physiological metrics, such as heart rate variability and
EEG, with behavioral performance data, we evaluated how cognitive demands affect

alertness. Our findings indicate a significant correlation between increased cognitive load and
decreased alertness, highlighting the system's potential applications in various fields.
Driver Drowsiness Detection System

CHAPTER – 3: SYSTEM DESIGN

3.1 System Architecture


A block diagram of the proposed driver drowsiness monitoring system has been depicted in
Fig 1. At first, the video is recorded using a webcam. The camera will be positioned in front
of the driver to capture the front face image. From the video, the frames are extracted to
obtain 2-D images. Face is detected in the frames using histogram of oriented gradients
(HOG) and linear support vector machine (SVM) for object detection [10]. After detecting
the face, facial landmarks [11] like positions of eye, nose, and mouth are marked on the
images. From the facial landmarks, eye aspect ratio, mouth opening ratio and position of the
head are quantified and using these features and machine learning approach, a decision is
obtained drowsiness of the driver. If drowsiness is detected, an alarm will be sent to the driver
to alert him/her. The details of each block are discussed below.
Driver Drowsiness Detection System

Figure No. 3.1 System Architecture

3.2 Modules
3.2.1 Data Acquisition
The video is recorded using webcam (Sony CMU-BR300) and the frames are extracted and
processed in a laptop. After extracting the frames, image processing techniques are applied on
these 2D images. Presently, synthetic driver data has been generated. The volunteers are
asked to look at the webcam with intermittent eye blinking, eye closing, yawning and head
bending. The video is captured for 30 minutes duration.
3.2.2 Face Detection
After extracting the frames, first the human faces are detected. Numerous online face
detection algorithms are there. In this study, histogram of oriented gradients (HOG) and linear
SVM method [10] is used. In this method, positive samples of descriptors are computed on
them. Subsequently, negative samples (samples that do not contain the required object to be
detected i.e., human face here) of same size are taken and HOG descriptors are calculated.
Usually the number of negative samples is very greater than number of positive samples.
After obtaining the features for both the classes, a linear SVM is trained for the classification
task. To improve the accuracy of VM, hard negative mining is used.
3.2.3 Facial Landmark marking
After detecting the face, the next task is to find the locations of different facial features like
the corners of the eyes and mouth, the tip of the nose and so on. Prior to that, the face images
should be normalized in order to reduce the effect of distance from the camera, non-uniform
illumination and varying image resolution. Therefore, the face image is resized to a width of
500 pixels and converted to grayscale image. After image normalization, ensemble of
regression trees [11] is used to estimate the landmark positions on face from a sparse subset
of pixel intensities. In this method, the sum of square error loss is optimized using gradient
boosting learning. Using this method, the boundary points of eyes, mouth and the central line
of the nose are marked and the number of points for eye, mouth and nose are given in Table I.
3.2.4 Feature Extraction
After detecting the facial landmarks, the features are computed as described below. Eye
aspect ratio (EAR): From the eye corner points, the eye aspect ratio is calculated as the ratio
of height and width of the eye as given by.
3.2.5 Classification
After computing all the three features, the next task is to detect drowsiness in the extracted
frames. In the beginning, adaptive thresholding is considered for classification. Later,
Driver Drowsiness Detection System

machine learning algorithms are used to classify the data. For computing the threshold values
for each feature, it is assumed that initially the driver is in complete awake state. This is
called setup phase. In the setup phase, the EAR values for first three hundred (for 10s at 30
fps) frames are recorded. Out 4of these three hundred initial frames containing face, average
of 150 maximum values is considered as the hard threshold for EAR. The higher values are
considered so that no eye closing instances will be present. If the test value is less than this
threshold, then eye closing (i.e., drowsiness) is detected. As the size of eye can vary from
person to person, this initial setup for each person will reduce this effect. Similarly, for
calculating threshold of MOR, since the mouth may not be open to its maximum in initial
frames (setup phase) so the threshold is taken experimentally from the observations. If the test
value is greater than this threshold then yawn (i.e., drowsiness) is detected. Head bending
feature is used to find the angle made by head with respect to vertical axis in terms of ratio of
projected nose lengths. Normally, NLR has values room 0.9 to 1.1 for normal upright position
of head and it increases or decreases when head bends down or up in the state of drowsiness.
The average nose length is computed as the average of the nose lengths in the setup phase
assuming that no head bending is there.

3.3 UML Diagrams

UML stands for Unified Modeling Language. UML is a standardized general-purpose


modeling language in the field of object-oriented software engineering. The standard is
managed, and was created by, the Object Management Group.

The goal is for UML to become a common language for creating models of object-oriented
computer software. In its current form UML is comprised of two major components: a Meta-
model and a notation

The Unified Modeling Language is a standard language for specifying, Visualization,


Constructing and documenting the artifacts of software system, as well as for business
modeling and other non-software systems. The UML is a very important part of developing
object-oriented software and the software development process. The UML uses mostly
graphical notations to express the design of software projects.
3.3.1 CLASS DIAGRAM

In software engineering, a class diagram in the Unified Modeling Language (UML) is a type
of static structure diagram that describes the structure of a system by showing the system's
Driver Drowsiness Detection System

classes, their attributes, operations (or methods), and the relationships among the classes. It
explains which class contains information.

Figure No 3.2 Class Diagram

3.3.2 USE CASE DIAGRAM

A use case diagram in the Unified Modeling Language (UML) is a type of behavioral diagram
defined by and created from a Use-case analysis. The purpose is to present a graphical
overview of the functionality provided by a system in terms of actors, their goals (represented
as use cases), and any dependencies between those use cases. The main purpose of a use case
diagram is to show what system functions are performed for which actor. Roles of the actors
in the system can be depicted.
Driver Drowsiness Detection System

Figure No 3.3 Use Case Diagram


3.3.3 SEQUENCE DIAGRAM
A sequence diagram in Unified Modeling Language (UML) is a kind of interaction diagram
that shows how processes operate with one another and in what order. It is a construct of a
Message Sequence Chart. Sequence diagrams are sometimes called event diagrams, event
scenarios, and timing diagrams.

Figure No 3.4 Sequence Diagram


Driver Drowsiness Detection System

3.4 System Requirements


3.4.1 Hardware Requirements

 Processor : Pentium IV 2.4 GHz


 Ram : 512 Mb
 Hard Disk : 40 GB
 Floppy Drive : 1.44 Mb

3.4.2 Software Requirements

 Operating system : Windows


 Coding Language : Python
 Designing : HTML ,CSS , Java script, AJA
 Algorithm : Deep Neural Network
 Python Web Server : Django
 Data Base : MySQL
 Front-End : Python
Driver Drowsiness Detection System

CHAPTER – 4: INPUT DESIGN AND OUTPUT DESIGN


4.1 INPUT DESIGN
The input design is the link between the information system and the user. It comprises the
developing specification and procedures for data preparation and those steps are necessary to
put transaction data in to a usable form for processing can be achieved by inspecting the
computer to read data from a written or printed document or it can occur by having people
keying the data directly into the system. The design of input focuses on controlling the
amount of input required, controlling the errors, avoiding delay, avoiding extra steps and
keeping process simple. The input is designed in such a way so that it provides security and
ease of use with retaining the privacy:

4.2 OUTPUT DESIGN


A quality output is one, which meets the requirements of the end user and presents the
information clearly. In any system results of processing are communicated to the users and to
other system through outputs. In output design it is determined how the information is to be
displaced for immediate need and also the hard copy output

1. Designing computer output should proceed in an organized, well thought out manner; the
right output must be developed while ensuring that each output element is designed so that
people will find the system can use easily and effectively.

2.Select methods for presenting information.

3.Create document, report, or other formats that contain information produced by the system.

The output form of an information system should accomplish one or more of the following
objectives.

 Convey information about past activities, current status or projections of the Future.
 Signal important events, opportunities, problems, or warnings.
 Trigger an action.
 Confirm an action.
Driver Drowsiness Detection System

CHAPTER – 5: SYSTEM ENVIRONMENT

Python is a general-purpose interpreted, interactive, object-oriented, and high-level


programming language. An interpreted language, Python has a design philosophy that
emphasizes code readability (notably using whitespace indentation to delimit code
blocks rather than curly brackets or keywords), and a syntax that allows programmers to
express concepts in fewer lines of code than might be used in languages such as C+
+or Java. It provides constructs that enable clear programming on both small and large scales.
Python interpreters are available for many operating systems.

5.1 What is Python


Python is a popular programming language. It was created by Guido van Rossum, and
released in 1991.

It is used for:

 web development (server-side),


 software development
 mathematics
 system scripting.

5.2 What can Python do

 Python can be used on a server to create web applications.


 Python can be used alongside software to create workflows.
 Python can connect to database systems. It can also read and modify files.
 Python can be used to handle big data and perform complex mathematics.
 Python can be used for rapid prototyping, or for production-ready software

Why Python

 Python works on different platforms (Windows, Mac, Linux, Raspberry Pi, etc.).
 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.
Driver Drowsiness Detection System

Good to know

 The most recent major version of Python is Python 3, which we shall be using in this
tutorial. However, Python 2, although not being updated with anything other than
security updates, is still quite popular.
 In tutorial Python will be written in a text editor. It is possible to write Python in an
Integrated Development Environment, such as Thonny, PyCharm, Net beans or
Eclipse which are particularly useful when managing larger collections of Python
files.

Python Syntax compared to other programming languages

 Python was designed for readability, and has some similarities to the English
language with influence from mathematics.
 Python uses new lines to complete a command, as opposed to other programming
languages which often use semicolons or parentheses.
 Python relies on indentation, using whitespace, to define scope; such as the scope
of loops, functions and classes. Other programming languages often use curly-
brackets for this purpose.

5.3 Python Install

Many PCs and Macs will have python already installed.

To check if you have python installed on a Windows PC, search in the start bar for Python or
run the following on the Command Line (cmd.exe):

C:\Users\Your Name>python --version

To check if you have python installed on a Linux or Mac, then on Linux open the command
line or on Mac open the Terminal and type:

python --version

If you find that you do not have python installed on your computer, then you can download it
for free from the following website: https://www.python.org/

Python Quick start


Driver Drowsiness Detection System

Python is an interpreted programming language; this means that as a developer you write
Python (.py) files in a text editor and then put those files into the python interpreter to be
executed.

The way to run a python file is like this on the command line:

C:\Users\Your Name>python helloworld.py

Where "helloworld.py" is the name of your python file.

Let's write our first Python file, called helloworld.py, which can be done in any text editor.

helloworld.py

print("Hello, World!")

Simple as that. Save your file. Open your command line, navigate to the directory where you
saved your file, and run:

C:\Users\Your Name>python helloworld.py

The output should read:

Hello, World!

Congratulations, you have written and executed your first Python program.

The Python Command Line

To test a short amount of code in python sometimes it is quickest and easiest not to write the
code in a file. This is made possible because Python can be run as a command line itself.

Type the following on the Windows, Mac or Linux command line:

C:\Users\Your Name>python

Or, if the "python" command did not work, you can try "py":

C:\Users\Your Name>py
Driver Drowsiness Detection System

From there you can write any python, including our hello world example from earlier in the
tutorial:

C:\Users\Your Name>python

Python 3.6.4 (v3.6.4: d48eceb, Dec 19 2017, 06:04:45) [MSC v.1900 32 bit (Intel)] on win32

Type "help", "copyright", "credits" or "license" for more information.

>>>print("Hello, World!")

Which will write "Hello, World!" in the command line:

C:\Users\Your Name>python

Python 3.6.4 (v3.6.4: d48eceb, Dec 19 2017, 06:04:45) [MSC v.1900 32 bit (Intel)] on win32

Type "help", "copyright", "credits" or "license" for more information.

>>>print("Hello, World!")

Hello, World!

Whenever you are done in the python command line, you can simply type the following to
quit the python command line interface:

exit()

5.4 Virtual Environments and Packages

Introduction

Python applications will often use packages and modules that don’t come as part of the
standard library. Applications will sometimes need a specific version of a library, because the
application may require that a particular bug has been fixed or the application may be written
using an obsolete version of the library’s interface.

This means it may not be possible for one Python installation to meet the requirements of
every application. If application A needs version 1.0 of a particular module but application B
Driver Drowsiness Detection System

needs version 2.0, then the requirements are in conflict and installing either version 1.0 or 2.0
will leave one application unable to run.

Different applications can then use different virtual environments. To resolve the earlier
example of conflicting requirements, application A can have its own virtual environment with
version 1.0 installed while application B has another virtual environment with version 2.0. If
application B requires a library be upgraded to version 3.0, this will not affect application A’s
environment.

Creating Virtual Environments

The module used to create and manage virtual environments is called venv. venv will usually
install the most recent version of Python that you have available. If you have multiple
versions of Python on your system, you can select a specific Python version by running
python3 or whichever version you want.

To create a virtual environment, decide upon a directory where you want to place it, and run
the venv module as a script with the directory path:

python3 -m venv tutorial-env

A common directory location for a virtual environment is. venv. This name keeps the
directory typically hidden in your shell and thus out of the way while giving it a name that
explains why the directory exists. It also prevents clashing with.env environment variable
definition files that some tooling supports.

Once you’ve created a virtual environment, you may activate it.

On Windows, run:

tutorial-env\Scripts\activate.bat

On Unix or MacOS, run:

source tutorial-env/bin/activate

(This script is written for the bash shell. If you use the csh or fish shells, there are alternate
activate.csh and activate. Fish scripts you should use instead.)
Driver Drowsiness Detection System

Activating the virtual environment will change your shell’s prompt to show what virtual
environment you’re using, and modify the environment so that running python will get you
that particular version and installation of Python. For example:

$ source ~/env/tutorial-env/bin/activate

(tutorial-env) $ python

Python 3.5.1 (default, May 6 2016, 10:59:36)

>>> import sys

>>>sys.path

['', '/user/local/lib/python35.zip', ...,

'~/env/tutorial-env/lib/python3.5/site-packages']

>>>12.3. Managing Packages with pip

You can install, upgrade, and remove packages using a program called pip. By default pip
will install packages from the Python Package Index, <https://pypi.org>. You can browse the
Python Package Index by going to it in your web browser, or you can use pip’s limited search
feature:

(tutorial-env) $ pip search astronomy

skyfield - Elegant astronomy for Python

gary - Galactic astronomy and gravitational dynamics.

novas - The United States Naval Observatory NOVAS astronomy library

astroobs - Provides astronomy ephemeris to plan telescope observations

PyAstronomy - A collection of astronomy related tools for Python.

pip has a number of subcommands: “search”, “install”, “uninstall”, “freeze”, etc. (Consult the
Installing Python Modules guide for complete documentation for pip.)
Driver Drowsiness Detection System

You can install the latest version of a package by specifying a package’s name:

(tutorial-env) $ pip install novas

Collecting novas

Downloading novas-3.1.1.3.tar.gz (136kB)

Installing collected packages: novas

Running setup.py install for novas

Successfully installed novas-3.1.1.3

You can also install a specific version of a package by giving the package name followed by
== and the version number:

(tutorial-env) $ pip install requests==2.6.0

Collecting requests==2.6.0

Using cached requests-2.6.0-py2.py3-none-any.whl

Installing collected packages: requests

Successfully installed requests-2.6.0

If you re-run this command, pip will notice that the requested version is already installed and
do nothing. You can supply a different version number to get that version, or you can run pip
install --upgrade to upgrade the package to the latest version:

(tutorial-env) $ pip install --upgrade requests

Collecting requests

Installing collected packages: requests

Found existing installation: requests 2.6.0

Uninstalling requests-2.6.0:
Driver Drowsiness Detection System

Successfully uninstalled requests-2.6.0

Successfully installed requests-2.7.0

pip uninstall followed by one or more package names will remove the packages from the
virtual environment.

pip show will display information about a particular package:

(tutorial-env) $ pip show requests

---Metadata-Version: 2.0

Name: requests

Version: 2.7.0

Summary: Python HTTP for Humans.

Home-page: http://python-requests.org

Author: Kenneth Reitz

Author-email: [email protected]

License: Apache 2.0

Location: /Users/akuchling/envs/tutorial-env/lib/python3.4/site-packages

Requires:

pip list will display all of the packages installed in the virtual environment:

(tutorial-env) $ pip list

novas (3.1.1.3)

numpy (1.9.2)

pip (7.0.3)
Driver Drowsiness Detection System

requests (2.7.0)

setup tools (16.0)

pip freeze will produce a similar list of the installed packages, but the output uses the format
that pip install expects. A common convention is to put this list in a requirements.txt file:

(tutorial-env) $ pip freeze > requirements.txt

(tutorial-env) $ cat requirements.txt

novas==3.1.1.3

numpy==1.9.2

requests==2.7.0

The requirements.txt can then be committed to version control and shipped as part of an
application. Users can then install all the necessary packages with install -r:

(tutorial-env) $ pip install -r requirements.txt

Collecting novas==3.1.1.3 (from -r requirements.txt (line 1))

...Collecting numpy==1.9.2 (from -r requirements.txt (line 2))

...Collecting requests==2.7.0 (from -r requirements.txt (line 3))

...Installing collected packages: novas, numpy, requests

Running setup.py install for novas

Successfully installed novas-3.1.1.3 numpy-1.9.2 requests-2.7.0pip has many more options.


Consult the Installing Python Modules guide for complete documentation for pip. When you’ve
written a package and want to make it available on the Python Package Index, consult the
Distributing Python Modules guide.

Cross Platform

Platform. Architecture (executable=sys.executable, bits='', linkage='')


Driver Drowsiness Detection System

Queries the given executable for various architecture information.

Values that cannot be determined are returned as given by the parameter presets. If bits is
given as '', the sizeof(pointer) (or sizeof(long) on Python version < 1.5.2) is used as indicator
for the supported pointer size.

Note On Mac OS X (and perhaps other platforms), executable files may be universal files
containing multiple architectures.

To get at the “64-bitness” of the current interpreter, it is more reliable to query the
sys.maxsize attribute:

is_64bits = sys.maxsize> 2**32

platform.machine ()

Returns the machine type, e.g. 'i386'. An empty string is returned if the value cannot be
determined.

platform.node ()

Returns the computer’s network name. An empty string is returned if the value cannot be
determined.

platform. Platform(aliased=0, terse=0)

Returns a single string identifying the underlying platform with as much useful information as
possible.

The output is intended to be human readable rather than machine parseable. It may look
different on different platforms and this is intended.If aliased is true, the function will use
aliases for various platforms that report system names which differ from their common
names, for example SunOS will be reported as Solaris. The system_alias() function is used to
implement this.

Setting terse to true causes the function to return only the absolute minimum information
needed to identify the platform.

platform.processor()
Driver Drowsiness Detection System

Returns the (real) processor name, e.g. 'amdk6'.

An empty string is returned if the value cannot be determined. Note that many platforms do
not provide this information or simply return the same value as for machine(). NetBSD does
this.

platform.python_build()

Returns a tuple (build no, build date) stating the Python build number and date as strings.

platform.python_compiler()

Returns a string identifying the compiler used for compiling Python.

platform.python_branch()

Returns a string identifying the Python implementation SCM branch.

New in version 2.6.

platform.python_implementation()

Returns a string identifying the Python implementation. Possible return values are: ‘C
Python’, ‘Iron Python’, ‘Jython’, ‘PyPy’.

New in version 2.6.

platform.python_revision()

Returns a string identifying the Python implementation SCM revision. New in version 2.6.

platform.python_version()

Returns the Python version as string 'major.minor.patch level'.

Note that unlike the Python sys.version, the returned value will always include the patch level
(it defaults to 0).

platform.python_version_tuple()
Driver Drowsiness Detection System

Returns the Python version as tuple (major, minor, patch level) of strings.

Note that unlike the Python sys.version, the returned value will always include the patch level
(it defaults to '0').

platform.release()

Returns the system’s release, e.g. '2.2.0' or 'NT' An empty string is returned if the value
cannot be determined.

platform.system()

Returns the system/OS name, e.g. 'Linux', 'Windows', or 'Java'. An empty string is returned if
the value cannot be determined.

platform.system_alias(system, release, version)

Returns (system, release, version) aliased to common marketing names used for some
systems. It also does some reordering of the information in some cases where it would
otherwise cause confusion.

platform.version()

Returns the system’s release version, e.g. '#3 on degas'. An empty string is returned if the
value cannot be determined.

platform.uname()

Fairly portable uname interface. Returns a tuple of strings (system, node, release, version,
machine, processor) identifying the underlying platform.

Note that unlike the os.uname() function this also returns possible processor information as
additional tuple entry.Entries which cannot be determined are set to ''.

Java Platform

platform.java_ver(release='', vendor='', vminfo=('', '', ''), osinfo=('', '', ''))

Version interface for Jython.


Driver Drowsiness Detection System

Returns a tuple (release, vendor, vminfo, osinfo) with vminfo being a tuple (vm_name,
vm_release, vm_vendor) and osinfo being a tuple (os_name, os_version, os_arch). Values
which cannot be determined are set to the defaults given as parameters (which all default to
'').

Windows Platform

platform.win32_ver(release='', version='', csd='', ptype='')

Get additional version information from the Windows Registry and return a tuple (release,
version, csd, ptype) referring to OS release, version number, CSD level (service pack) and OS
type (multi/single processor).

As a hint: ptype is 'Uniprocessor Free' on single processor NT machines and 'Multiprocessor


Free' on multi processor machines. The ‘Free’ refers to the OS version being free of
debugging code. It could also state ‘Checked’ which means the OS version uses debugging
code, i.e. code that checks arguments, ranges, etc.

Win95/98 specific

platform.popen(cmd, mode='r', bufsize=None)

Portable popen() interface. Find a working popen implementation preferring


win32pipe.popen(). On Windows NT, win32pipe.popen() should work; on Windows 9x it
hangs due to bugs in the MS C library.

Mac OS Platform

platform.mac_ver(release='', version info=('', '', ''),machine='').Get Mac OS version


information and return it as tuple (release, version info, machine) with version info being a
tuple (version, dev_stage, non_release_version).Entries which cannot be determined are set to
''. All tuple entries are strings.

Unix Platforms

platform.dist(distname='', version='', id='', supported_dists=('SuSE', 'debian', 'redhat',


'mandrake', ...))
Driver Drowsiness Detection System

This is an old version of the functionality now provided by linux_distribution(). For new
code, please use the linux_distribution().

The only difference between the two is that dist() always returns the short name of the
distribution taken from the supported_dists parameter.

Deprecated since version 2.6.

platform.linux_distribution(distname='', version='', id='', supported_dists=('SuSE', 'debian',


'redhat', 'mandrake', ...), full_distribution_name=1)

Tries to determine the name of the Linux OS distribution name.

supported_dists may be given to define the set of Linux distributions to look for. It defaults to
a list of currently supported Linux distributions identified by their release file name.

If full_distribution_name is true (default), the full distribution read from the OS is returned.
Otherwise the short name taken from supported_dists is used.

Returns a tuple (distname,version,id) which defaults to the args given as parameters. id is the
item in parentheses after the version number. It is usually the version codename.

Note This function is deprecated since Python 3.5 and removed in Python 3.8. See alternative
like the distro package.

New in version 2.6.

platform.libc_ver(executable=sys.executable, lib='', version='', chunk size=2048)

Tries to determine the lib c version against which the file executable (defaults to the Python
interpreter) is linked. Returns a tuple of strings (lib, version) which default to the given
parameters in case the lookup fails.
Driver Drowsiness Detection System

5.5 Using the Python Interpreter


5.5.1. Invoking the Interpreter

The Python interpreter is usually installed as /user/local/bin/python3.8 on those machines


where it is available; putting /usr/local/bin in your Unix shell’s search path makes it possible
to start it by typing the command:

python3.8

On Windows machines where you have installed Python from the Microsoft Store, the
python3.8 command will be available. If you have the py.exe launcher installed, you can use
the py command. See Excursus: Setting environment variables for other ways to launch
Python.

Typing an end-of-file character (Control-D on Unix, Control-Z on Windows) at the primary


prompt causes the interpreter to exit with a zero exit status. If that doesn’t work, you can exit
the interpreter by typing the following command: quit().

The interpreter’s line-editing features include interactive editing, history substitution and code
completion on systems that support the GNU Readline library. Perhaps the quickest check to
see whether command line editing is supported is typing Control-P to the first Python prompt
you get. If it beeps, you have command line editing; see Appendix Interactive Input Editing
and History Substitution for an introduction to the keys. If nothing appears to happen, or if ^P
is echoed, command line editing isn’t available; you’ll only be able to use backspace to
remove characters from the current line.

When known to the interpreter, the script name and additional arguments thereafter are turned
into a list of strings and assigned to the argv variable in the sys module. The length of the list
is at least one; when no script and no arguments are given, sys.argv[0] is an empty string.
When the script name is given as '-' (meaning standard input), sys.argv[0] is set to '-'. When -c
command is used, sys.argv[0] is set to '-c'. When -m module is used, sys.argv[0] is set to the
full name of the located module. Options found after -c command or -m module are not
consumed by the Python interpreter’s option processing but left in sys.argv for the command
or module to handle.

Interactive Mode
Driver Drowsiness Detection System

When commands are read from a tty, the interpreter is said to be in interactive mode. In this
mode it prompts for the next command with the primary prompt, usually three greater-than
signs (>>>); for continuation lines it prompts with the secondary prompt, by default three
dots (...). The interpreter prints a welcome message stating its version number and a copyright
notice before printing the first prompt:

$ python3.8

Python 3.8 (default, Sep 16 2015, 09:25:04)

[GCC 4.8.2] on Linux

Type "help", "copyright", "credits" or "license" for more information.

>>>

Continuation lines are needed when entering a multi-line construct. As an example, take a
look at this if statement:

>>>

>>>the world is flat = True

>>>if the world is flat:

... print("Be careful not to fall off!")

...Be careful not to fall off! For more on interactive mode, see Interactive Mode.

5.5.2 The Interpreter and Its Environment

Source Code Encoding

By default, Python source files are treated as encoded in UTF-8. In that encoding, characters
of most languages in the world can be used simultaneously in string literals, identifiers and
comments — although the standard library only uses ASCII characters for identifiers, a
convention that any portable code should follow.
Driver Drowsiness Detection System

The syntax is as follows:

# -*- coding: encoding -*-

where encoding is one of the valid codecs supported by Python.

For example, to declare that Windows-1252 encoding is to be used, the first line of your
source code file should be:

# -*- coding: cp1252 -*-

One exception to the first line rule is when the source code starts with a UNIX “shebang”
line. In this case, the encoding declaration should be added as the second line of the file. For
example:

#!/usr/bin/env python3

# -*- coding: cp1252 -*-

5.6 Introduction to Artificial Intelligence

“The science and engineering of making intelligent machines, especially intelligent


computer programs”. -John McCarthy-

Artificial Intelligence is an approach to make a computer, a robot, or a product to think how


smart human think. AI is a study of how human brain think, learn, decide and work, when it
tries to solve problems.. The aim of AI is to improve computer functions which are related to
human knowledge, for example, reasoning, learning, and problem-solving.

The intelligence is intangible. It is composed of

 Reasoning

 Learning

 Problem Solving

 Perception
Driver Drowsiness Detection System

5.6.1 Trending AI Articles


1. Cheat Sheets for AI, Neural Networks, Machine Learning, Deep Learning & Big Data
2. Data Science Simplified Part 1: Principles and Process
3. Getting Started with Building Realtime API Infrastructure
4. AI & NLP Workshop

Major Goals

 Knowledge reasoning

 Planning

 Machine Learning

 Natural Language Processing

 Computer Vision

 Robotics
IBM Watson

“Watson” is an IBM supercomputer that combines Artificial Intelligence (AI) and complex
inquisitive programming for ideal execution as a “question answering” machine. The
supercomputer is named for IBM’s founder, Thomas J. Watson.

Figure No. 5.1 IBM Watson Diagram

IBM Watson is at the forefront of the new era of computing. At the point when IBM Watson
made, IBM communicated that “more than 100 particular techniques are used to inspect
Driver Drowsiness Detection System

perceive sources, find and make theories, find and score affirm, and combination and rank
speculations.”

5.7 Machine Learning


5.7.1 Introduction
Machine learning is a subfield of artificial intelligence (AI). The goal of machine learning
generally is to understand the structure of data and fit that data into models that can be
understood and utilized by people.

Although machine learning is a field within computer science, it differs from traditional
computational approaches. In traditional computing, algorithms are sets of explicitly
programmed instructions used by computers to calculate or problem solve. Machine learning
algorithms instead allow for computers to train on data inputs and use statistical analysis in
order to output values that fall within a specific range. Because of this, machine learning
facilitates computers in building models from sample data in order to automate decision-
making processes based on data inputs.

5.7.2 Machine Learning Methods

In machine learning, tasks are generally classified into broad categories. These categories are
based on how learning is received or how feedback on the learning is given to the system
developed.

Two of the most widely adopted machine learning methods are supervised learning which
trains algorithms based on example input and output data that is labeled by humans,
and unsupervised learning which provides the algorithm with no labeled data in order to
allow it to find structure within its input data. Let’s explore these methods in more detail.

Supervised Learning

In supervised learning, the computer is provided with example inputs that are labeled with
their desired outputs. The purpose of this method is for the algorithm to be able to “learn” by
comparing its actual output with the “taught” outputs to find errors, and modify the model
accordingly. Supervised learning therefore uses patterns to predict label values on additional
unlabeled data. For example, with supervised learning, an algorithm may be fed data with
images of sharks labeled as fish and images of oceans labeled as water.
Driver Drowsiness Detection System

Unsupervised Learning

In unsupervised learning, data is unlabeled, so the learning algorithm is left to find


commonalities among its input data. As unlabeled data are more abundant than labeled data,
machine learning methods that facilitate unsupervised learning are particularly valuable.

The goal of unsupervised learning may be as straightforward as discovering hidden patterns


within a dataset, but it may also have a goal of feature learning, which allows the
computational machine to automatically discover the representations that are needed to
classify raw data.

5.8 Approaches
For those who may not have studied statistics, it can be helpful to first define correlation and
regression, as they are commonly used techniques for investigating the relationship among
quantitative variables. Correlation is a measure of association between two variables that are
not designated as either dependent or independent. Regression at a basic level is used to
examine the relationship between one dependent and one independent variable. Because
regression statistics can be used to anticipate the dependent variable when the independent
variable is known, regression enables prediction capabilities.

5.8.1 k-nearest neighbor

The k-nearest neighbor algorithm is a pattern recognition model that can be used for
classification as well as regression. Often abbreviated as k-NN, the k in k-nearest neighbor is
a positive integer, which is typically small. In either classification or regression, the input will
consist of the k closest training examples within a space.
Driver Drowsiness Detection System

Figure No. 5.2 KNN Example 1

We will focus on k-NN classification. In this method, the output is class membership. This
will assign a new object to the class most common among its k nearest neighbors. In the case
of k = 1, the object is assigned to the class of the single nearest neighbor.

Figure No. 5.3 KNN Example 2

When we choose k = 3, the algorithm will find the three nearest neighbors of the green heart in
order to classify it to either the diamond class or the star class.

In our diagram, the three nearest neighbors of the green heart are one diamond and two stars.
Therefore, the algorithm will classify the heart with the star class.

Figure No. 5.4 KNN Example 3


Driver Drowsiness Detection System

APPLICATIONS OF AI

 Natural Language Interact with the computer that understands natural language
processing spoken by humans.
 Expert Systems Machine or software provide explanation and advice to
others.
 Vision Systems Systems understand, describe visual input on the computer.
5.8.2 Decision Tree Learning
For general use, decision trees are employed to visually represent decisions and show or
inform decision making. When working with machine learning and data mining, decision
trees are used as a predictive model. These models map observations about data to
conclusions about the data’s target value.

Figure No. 5.5 Decision Tree

5.9 Introduction to Deep Learning


What is deep learning Deep learning is a branch of machine learning which is completely
based on artificial neural networks, as neural network is going to mimic the human brain so
deep learning is also a kind of mimic of human brain. In deep learning, we don’t need to
explicitly program everything.
Driver Drowsiness Detection System

Figure No. 5.6 Deep Learning

CHAPTER-6: SYSTEM STUDY


Feasibility study
The feasibility of the project is analyzed in this phase and business proposal is put forth with
a very general plan for the project and some cost estimates. During system analysis the
feasibility study of the proposed system is to be carried out. This is to ensure that the
proposed system is not a burden to the company. For feasibility analysis, some understanding
of the major requirements for the system is essential.

Three key considerations involved in the feasibility analysis are,

 ECONOMICAL FEASIBILITY

 TECHNICAL FEASIBILITY
 SOCIAL FEASIBILITY

6.1 Economic Feasibility


This study is carried out to check the economic impact that the system will have on the
organization. The amount of fund that the company can pour into the research and
development of the system is limited. The expenditures must be justified. Thus, the developed
system as well within the budget and this was achieved because most of the technologies used
are freely available. Only the customized products had to be purchased.

6.2 Technical Feasibility


This study is carried out to check the technical feasibility, that is, the technical requirements
of the system. Any system developed must not have a high demand on the available technical
resources. This will lead to high demands on the available technical resources. This will lead
to high demands being placed on the client. The developed system must have a modest
requirement, as only minimal or null changes are required for implementing this system.

6.3 Social Feasibility


The aspect of study is to check the level of acceptance of the system by the user. This
includes the process of training the user to use the system efficiently. The user must not feel
threatened by the system, instead must accept it as a necessity. The level of acceptance by the
Driver Drowsiness Detection System

users solely depends on the methods that are employed to educate the user about the system
and to make him familiar with it. His level of confidence must be raised so that he is also able
to make some constructive criticism, which is welcomed, as he is the final user of the system.

CHAPTER – 7: SYSTEM TESTING

The purpose of testing is to discover errors. Testing is the process of trying to discover every
conceivable fault or weakness in a work product. It provides a way to check the functionality
of components, sub-assemblies, assemblies and/or a finished product It is the process of
exercising software with the intent of ensuring that the Software system meets its
requirements and user expectations and does not fail in an unacceptable manner. There are
various types of tests. Each test type addresses a specific testing requirement.

7.1 TYPES OF TESTS


7.1.1 Unit testing
Unit testing involves the design of test cases that validate that the internal program logic is
functioning properly, and that program inputs produce valid outputs. All decision branches
and internal code flow should be validated. It is the testing of individual software units of the
application .it is done after the completion of an individual unit before integration. This is a
structural testing, that relies on knowledge of its construction and is invasive. Unit tests
perform basic tests at component level and test a specific business process, application, and/or
system configuration. Unit tests ensure that each unique path of a business process performs
accurately to the documented specifications and contains clearly defined inputs and expected
results.

7.1.2 Integration testing


Integration tests are designed to test integrated software components to determine if they
actually run as one program. Testing is event driven and is more concerned with the basic
outcome of screens or fields. Integration tests demonstrate that although the components were
individually satisfaction, as shown by successfully unit testing, the combination of
components is correct and consistent. Integration testing is specifically aimed at exposing
the problems that arise from the combination of components.
Driver Drowsiness Detection System

7.1.3 Functional Testing


Functional tests provide systematic demonstrations that functions tested are available as
specified by the business and technical requirements, system documentation, and user
manuals.
Functional testing is centered on the following items

Valid Input : identified classes of valid input must be accepted.

Invalid Input : identified classes of invalid input must be rejected.

Functions : identified functions must be exercised.

Output : identified classes of application outputs must be exercised.

Systems/Procedures : interfacing systems or procedures must be invoked

7.1.4 System Testing

System testing ensures that the entire integrated software system meets requirements. It tests
a configuration to ensure known and predictable results. An example of system testing is the
configuration-oriented system integration test. System testing is based on process descriptions
and flows, emphasizing pre-driven process links and integration points.

White Box Testing


White Box Testing is a testing in which in which the software tester has knowledge of the
inner workings, structure and language of the software, or at least its purpose. It is purpose. It
is used to test areas that cannot be reached from a black box level.

Black Box Testing

Black Box Testing is testing the software without any knowledge of the inner workings,
structure or language of the module being tested. Black box tests, as most other kinds of tests,
must be written from a definitive source document, such as specification or requirements
document, such as specification or requirements document.

Unit Testing
Driver Drowsiness Detection System

Unit testing is usually conducted as part of a combined code and unit test phase of the
software lifecycle, although it is not uncommon for coding and unit testing to be conducted as
two distinct phases.

Test objectives
 All field entries must work properly.
 Pages must be activated from the identified link.
 The entry screen, messages and responses must not be delayed.

Features to be tested
 Verify that the entries are of the correct format
 No duplicate entries should be allowed
 All links should take the user to the correct page
Integration Testing
Software integration testing is the incremental integration testing of two or more integrated
software components on a single platform to produce failures caused by interface defects.

7.1.5 Acceptance Testing


User Acceptance Testing is a critical phase of any project and requires significant
participation by the end user. It also ensures that the system meets the functional
requirements.

7.2 Test cases

Test Case 1

Test Case Name Empty login fields testing

In the login screen if the username and password fields are


Description
empty

Login fails showing an alert box asking to enter username and


Output password.

Table 7.1: Test case for Empty Login Field


Driver Drowsiness Detection System

Test Case 2

Test Case Wrong login fields testing


Name
A unique username and password are set by administrator. On
Description
entering wrong username or password gives.
Login fails showing an alert box username or password incorrect.
Output

Table 7.2: Test case for wrong login field

Test Case 3

Test Case Name User Signup Fails.

Description User signup need to provide all data.


Signup Fails and an alert message appears asking to enter valid
Output
email and name.

Table 7.3: Test Case for Signup fail


Driver Drowsiness Detection System

CHAPTER – 8: RESULTS

User Screen:
To run this project double click on ‘run.bat’ file to get below screen

Drowsiness Detection System

In above screen click on ‘Start Behavior Monitoring Using Webcam’ connect application
with webcam, will get below screen with webcam streaming

Drowsiness Detection System


Driver Drowsiness Detection System

In above screen we can see web cam stream then application monitor all frames to see person
eyes are open or not, if closed then will get alarm sound was going to start

Continuous eyes closing starts alarm sounds continuously

Driver
Drowsiness
Driver Drowsiness Detection System

CHAPTER – 9: CONCLUSION & FUTURE ENHANCEMENT

A system in which density of traffic is measured by comparing captured image with real time
traffic information against the image of the empty road as reference image is proposed. Each
lane will have a minimum amount of green signal duration allocated. According to the
percentage of matching allocated traffic light duration can be controlled

9.1 Conclusion
A low-cost, real-time driver drowsiness monitoring system has been proposed based on
visual behavior and machine learning. Here, visual behavior features like eye aspect ratio,
mouth opening ratio and nose length ratio are computed from the streaming video, captured
by a webcam. An adaptive thresholding technique has been developed to detect driver
drowsiness in real time. The developed system works accurately with the generated synthetic
data. Subsequently, the feature values are stored and machine learning algorithms have been
used for classification. Bayesian classifier, FLDA and SVM have been explored here. It has
been observed that FLDA and SVM outperform Bayesian classifier. The sensitivity of FLDA
and SVM is 0.896 and 0.956 respectively whereas the specificity is 1 for both. As FLDA and
SVM give better accuracy, work will be carried out to implement them in the developed
system to do the classification (i.e., drowsiness detection) online.

9.2 Future Enhancement


The future scope for driver drowsiness detection systems is promising, driven by
advancements in technology and a growing emphasis on road safety. As artificial intelligence
and machine learning improve, these systems will become more accurate in analyzing driver
behavior and physiological signals. Integration with wearable devices could facilitate
continuous monitoring of vital signs, while smart vehicle systems can offer real-time alerts
and interventions, such as suggesting breaks or adjusting environmental conditions.
Additionally, leveraging big data analytics will help identify drowsiness patterns across
various demographics and driving conditions, enabling tailored solutions. Enhanced user
interfaces will improve communication of alerts, making them more intuitive. As regulatory
standards evolve, there will be an increasing demand for reliable detection systems in
commercial vehicles and public transport. Furthermore, as the automotive industry shifts
toward autonomous vehicles, understanding driver alertness will be critical for safe
transitions between manual and automated driving.
Driver Drowsiness Detection System

CHAPTER – 10: BIBLIOGRAPHY

[1] A. Sengupta, A. Dasgupta, A. Chaudhuri, A. George, A. Routray, R. Guha; "A


Multimodal System for Assessing Alertness Levels Due to Cognitive Loading", IEEE Trans.
on Neural Systems and Rehabilitation Eng., vol. 25 (7), pp 1037-1046, 2017.

[2] K. T. Chui, K. F. Tsang, H. R. Chi, B. W. K. Ling, and C. K. Wu, “An accurate ECG
based transportation safety drowsiness detection scheme,” 118732 IEEE Transactions on
Industrial Informatics, vol. 12, no. 4, pp. 14381452, Aug. 2016.

[3] W. L. Ou, M. H. Shih, C. W. Chang, X. H. Yu, C. P. Fan, "Intelligent Video-Based


Drowsy Driver Detection System under Various Illuminations and Embedded Software
Implementation", 2015 international Conf. on Consumer Electronics - Taiwan, 2015.

[4] M. Karchani, A. Mazloumi, G. N. Saraji, A. Nahvi, K. S. Haghighi, B. M. Abadi, A. R.


Foroshani, A. Niknezhad, “The Steps of Proposed Drowsiness Detection System Design
based on Image Processing in Simulator Driving”, International Research Journal of Applied
and Basic Sciences, vol. 9(6), pp 878-887, 2015.

[5] R. Ahmad, and J. N. Borole, “Drowsy Driver Identification Using Eye Blink Detection,”
IJISET - International Journal of Computer Science and Information Technologies, vol. 6, no.
1, pp. 270-274, Jan. 2015.

[6] A. Abas, J. Mellor, and X. Chen, “Non-intrusive drowsiness detection by employing


Support Vector Machine,” 2014 20th International Conference on Automation and
Computing (ICAC), Bedfordshire, UK, 2014, pp. 188193.

[7] V. Kazemi and J. Sullivan; "One millisecond face alignment with an ensemble of
regression trees", IEEE Conf. on Computer Vision and Pattern Recognition, 23-28 June,
2014, Columbus, OH, USA.

[8] B. Alshaqaqi, A. S. Baquhaizel, M. E. A. Ouis, M. Bouumehed, A. Ouamri, M. Keche,


“Driver Drowsiness Detection System”, IEEE International Workshop on Systems, Signal
Processing and their Applications, 2013.

[9] N. Dalal and B. Triggs, “Histograms of Oriented Gradients for Human Detection”, IEEE
conf. on CVPR, 2005.
Driver Drowsiness Detection System

[10] W. B. Horng, C. Y. Chen, Y. Chang, C. H. Fan, “Driver Fatigue Detection based on Eye
Tracking and Dynamic Template Matching”, IEEE International Conference on Networking,
Sensing and Control, Taipei, Taiwan, March 21-23, 2004.

[11] S. Singh, N.P. Papanikolopoulos, “Monitoring Driver Fatigue using Facial Analysis
Techniques”, IEEE Conference on Intelligent Transportation System, pp 314-318.

[12] Richard O. Duda, Peter E. Hart, David G. Stork, “Pattern Classification”, Wiley student
edition.

[13] Dataset: https://sites.google.com/site/invedrifac/

You might also like