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

ABSTRACT

The Driver Drowsiness Detection System Using Image Processing aims to


address the critical issue of driver fatigue, which poses a significant risk to road safety.
Inspired by advanced vehicle safety features like Attention Assist, this project employs
image processing techniques to monitor driver behavior and detect signs of drowsiness
in real-time. By analyzing facial expressions, eye movements, and other visual cues, the
system can accurately identify deviations from normal driving behavior associated with
fatigue. Through the integration of sophisticated algorithms and machine learning
models, the system provides timely warnings to alert drivers of their drowsy state and
recommends appropriate measures, such as taking breaks at nearby service areas. This
project represents a proactive approach to enhancing road safety by leveraging
technology to mitigate the dangers posed by driver fatigue during long-distance
journeys.

TABLE OF CONTENT
S
ABSTRACT.....................................................................................................................i
TABLE OF CONTENTS..................................................................................................ii
LIST OF FIGURES.......................................................................................................iv
CHAPTER 1....................................................................................................................1
INTRODUCTION..........................................................................................................1
1.1 What is Python........................................................................................................2
1.2 Advantages of Python.............................................................................................2
1.3 Disadvantages of Python.........................................................................................3
1.4 Install Python on Windows Step by Step................................................................4
1.5 Installation of Python..............................................................................................6
1.6 Verify the Python Installation..................................................................................7
1.7 Check how the Python IDLE works........................................................................8
1.8 What is VS Code:....................................................................................................8
1.9 Steps to Install Visual Studio Code on Windows....................................................9
CHAPTER 2..................................................................................................................13
SYSTEM ANALYSIS...................................................................................................13
2.1 Existing System.....................................................................................................13
2.1.1 Drawbacks......................................................................................................13
2.2 Proposed System...................................................................................................14
2.2.1 Advantages.....................................................................................................15
2.3 Modules.................................................................................................................16
2.4 Feasibility Study....................................................................................................18
2.4.1 Technical Feasibility.......................................................................................18
2.4.2 Financial Feasibility.......................................................................................18
2.4.3 Market Feasibility...........................................................................................18
2.4.4 Operational Feasibility...................................................................................19
2.4.5 Legal and Ethical Feasibility..........................................................................19
CHAPTER 3..................................................................................................................20
REQUIREMENT ANALYSIS.....................................................................................20
3.1 Software Requirements.........................................................................................20
3.2 Functional Requirements.......................................................................................20
3.3 Hardware Requirements........................................................................................20
CHAPTER 4..................................................................................................................21
SOFTWARE DESIGN..................................................................................................21
4.1 Data Flow Diagram...............................................................................................21
4.2 Use Case diagram..................................................................................................23
4.3 Class Diagram.......................................................................................................24
4.4 Sequence Diagram.................................................................................................25
4.5 Activity Diagram...................................................................................................26
4.6 State Machine Diagram.........................................................................................27
CHAPTER 5..................................................................................................................28
IMPLEMENTATION...................................................................................................28
5.1 Image processing...................................................................................................28
5.2 Source Code..........................................................................................................34
5.3.1 drowsiness-detection.ipynb............................................................................34
5.3.2 main.py...........................................................................................................35
5.3.3 activate.bat......................................................................................................37
5.3.4 deactivate.bat..................................................................................................38
CHAPTER 6..................................................................................................................39
TESTING.......................................................................................................................39
6.1 System Test............................................................................................................39
6.2 Types of Tests........................................................................................................39
6.2.1 Unit testing.....................................................................................................39
6.2.2 Integrated Testing...........................................................................................39
6.2.3 Functional Testing..........................................................................................40
6.2.4 White Box Testing..........................................................................................40
6.2.5 Black Box Testing...........................................................................................41
6.3 Test strategy and approach....................................................................................41
6.3.1 Test objectives................................................................................................41
6.3.2 Features to be tested.......................................................................................41
6.4 Acceptance Testing................................................................................................41
CHAPTER 7..................................................................................................................42
OUTPUT........................................................................................................................42
CHAPTER 8..................................................................................................................46
CONCLUSION & FUTURE ENHANCEMENT......................................................46
BIBLIOGRAPHY.........................................................................................................48
LIST OF FIGURES

Fig 1.1 Python Official Website........................................................................................4


Fig 1.2 Python Download Page........................................................................................4
Fig 1.3 Python Versions Available to Download..............................................................5
Fig 1.4 Select the OS to download...................................................................................5
Fig 1.5 Python application Setup......................................................................................6
Fig 1.6 Setup Successful Message....................................................................................6
Fig 1.7 Open Command Prompt.......................................................................................7
Fig 1.8 Check Whether Python is Installed......................................................................7
Fig 1.9 Python IDLE Interface.........................................................................................8
Fig 1.10 Visual Studio Code Official Download Site.......................................................9
Fig 1.11 VS Code Licence agreement............................................................................10
Fig 1.12 Add the VS Code to PATH...............................................................................10
Fig 1.13 VS Code Installation Screen.............................................................................11
Fig 1.14 VS Code Installation Complete........................................................................11
Fig 1.15 VS Code Interface............................................................................................12
Fig 4.1 Data Flow Diagram............................................................................................22
Fig 4.2 Use Case Diagram..............................................................................................23
Fig 4.3 Class Diagram....................................................................................................24
Fig 4.4 Sequence Diagram..............................................................................................25
Fig 4.5 Activity Diagram................................................................................................26
Fig 4.6 State Machine Diagram......................................................................................27
Fig 5.1 The Symmetry Histogram...................................................................................28
Fig 5.2 The original image, the edges and the histogram of projected edges.................28
Fig 5.3 Detection of eye..................................................................................................29
Fig 5.4 Block Diagram...................................................................................................30
Fig 5.5 System configuration..........................................................................................30
Fig 5.6 Flowchart of the given system............................................................................30
Fig 5.7 Histogram corresponding to eye opened/closed..................................................33
Fig 7.1 create vent-cmd..................................................................................................42
Fig 7.2 Change terminal.................................................................................................42
Fig 7.3 Activate-bat........................................................................................................43
Fig 7.4 Package installing-cmd.......................................................................................43
Fig 7.5 Code run main.py-cmd.......................................................................................44
Fig 7.6 i:p & o:p(Awake)................................................................................................44
Fig 7.7 i_p & o_p(Drowsy)............................................................................................45
Driver Drowsiness Detection System Using Image Processing

CHAPTER 1

INTRODUCTION
In today's fast-paced world, long-distance driving has become a routine aspect
of modern life, whether for business or leisure. However, with the convenience of travel
comes the inherent risk of driver fatigue, a leading cause of road accidents worldwide.
According to experts, drowsy driving contributes to a significant portion of serious
motorway accidents, surpassing even the dangers posed by drink-driving. Recognizing
the urgency of addressing this issue, automotive manufacturers and researchers have
been exploring innovative solutions to detect and mitigate driver drowsiness in real-
time.

The Driver Drowsiness Detection System Using Image Processing project aims
to contribute to this vital area of road safety by harnessing the power of image
processing techniques to monitor driver behavior and identify signs of fatigue. Inspired
by existing technologies like Attention Assist found in modern vehicles, this project
seeks to develop a robust and efficient system capable of accurately detecting
drowsiness and alerting drivers before potential accidents occur.

The rationale behind this project is rooted in the understanding that human
factors play a crucial role in road safety. While technological advancements have led to
significant improvements in vehicle safety features, such as airbags and anti-lock
braking systems, the human element remains a critical factor in preventing accidents.
Recognizing the limitations of solely relying on drivers to recognize their own fatigue,
the Driver Drowsiness Detection System aims to provide an additional layer of
protection by actively monitoring driver behavior and providing timely warnings when
signs of drowsiness are detected.

The primary objective of this project is to develop a comprehensive system


capable of accurately detecting drowsiness using image processing techniques. By
analyzing facial expressions, eye movements, and other visual cues, the system can
identify deviations from normal driving behavior associated with fatigue. Through the
integration of sophisticated algorithms and machine learning models, the system can
adapt to individual driving styles and environmental conditions, ensuring robust
performance across a wide range of scenarios.

Dept of CSE, BVCEC, Odalarevu 1


Driver Drowsiness Detection System Using Image Processing

In addition to detecting drowsiness, the system will also provide real-time


feedback to drivers about their current state of fatigue and recommend appropriate
measures to mitigate the risk, such as taking breaks at nearby service areas. This
proactive approach not only enhances road safety but also promotes responsible driving
habits by encouraging drivers to prioritize their well-being during long journeys.

The significance of this project lies in its potential to save lives and reduce the
number of accidents caused by driver fatigue. By leveraging image processing
techniques and advanced algorithms, the Driver Drowsiness Detection System
represents a proactive step towards enhancing road safety and protecting drivers and
passengers from the dangers of drowsy driving. Through continuous research and
development, this project aims to contribute to the ongoing efforts to create safer and
more sustainable transportation systems for the future.

1.1 What is Python

These are some facts about Python. Python is present most widely used multi-
purpose and high-level programming language.it allows programming in Object-
Oriented and Procedural paradigms. Python programs commonly are smaller than other
programming languages like Java. Programmers have to write relatively less and
indentation requirement of the language, makes them readable all the time. Python
language is being used by the almost all tech-giant companies like – Google, Amazon,
Facebook, Instagram, Dropbox, Uber… etc. The biggest strength of Python language is
huge collection of standard libraries it can be used for the following

 Machine Learning.

 GUI Applications (such as Kivy, Tkinter, PyQt, etc.)

 Web frame works such as Django (used by YouTube, Instagram, Dropbox)

 Image processing (such as Open cv and Pillow)

 Web scraping (such as Scrapy, Beautiful So up and Selenium)

1.2 Advantages of Python

1) Less Coding

When performing the same task in other languages, all tasks performed in
Python require less coding. Python is also excellent standard library support, so there is

Dept of CSE, BVCEC, Odalarevu 2


Driver Drowsiness Detection System Using Image Processing

no need to search for third-party libraries to get the job done. This is the main reason
why many people recommend that beginners learn Python.

2) Affordable

Python is a free resource, so individuals, small businesses, or large


organizations can use available free resources to build applications, and Python is a
popular and widely used community supply.

3) Python is for Everyone

Python can run in any environment, be it Linux, Mac or Windows. Programmers


need to learn different languages for different jobs, but with Python, you can
professionally use Python to create web applications, perform data analysis and
machine learning, automate things, perform web scraping, and create powerful games
and visualization initial later rain programming language.

1.3 Disadvantages of Python

1. Speed Limitations

We have seen that Python code executes line by line. But because Python is
interpreted, its execution speed is very slow. This is not a problem, unless speed is the
focus of the project work. In other words, the speed is necessary, and the benefits
Python provides are enough to distract us from its speed limitations.

2. Weak in Mobile Computing and Browsers

Although Python is a good server-side language, Python is rarely seen on the


client side. Most importantly, is rarely used to implement smartphone- based
applications. One of these applications is called Carbon nelle. Although Bright on
exists, it is not so famous because it is not so safe.

3. Design Restrictions

Python is a dynamically typed language. This means that you do not need to
declare variable types when writing code content. It uses to duck typing. what is that?
Well, it just means that if it looks like a duck, then it must be a duck. This is easy for
programmers in the coding process, and it will generate runtime errors.

4. Under developed data base access layer

Dept of CSE, BVCEC, Odalarevu 3


Driver Drowsiness Detection System Using Image Processing

Compared to the most widely used technologies such as JDBC (Java DataBase
Connectivity) and ODBC (Open DataBase Connectivity), Python's database access
layer is a bit underdeveloped and it is used less in large companies.

5. Simple

We are not kidding. Python's simplicity is indeed a problem. I don't do Java, I'm
more of a Python person. To me, its syntax is so simple that Java code seems
unnecessary.

1.4 Install Python on Windows Step by Step

Step-1: Go to the official site and use Google Chrome or any other web browser to
download and install Python. Or click on the following link:

https://www.python.org/

Fig 0.1 Python Official Website

Now check the latest and correct version of your operating system.

Step-2: Click on the Download Tab.

Dept of CSE, BVCEC, Odalarevu 4


Driver Drowsiness Detection System Using Image Processing

Fig 0.2 Python Download Page

Step-3: You can select the yellow Download Python for Windows3.7.4 button, or you
can scroll download click the download of the corresponding version. Here, we are
downloading the latest version of Python for Window 3.7.4.

Fig 0.3 Python Versions Available to Download

Step-4: Scroll down the page until you find the "File" option.

Step5: Here you will see different versions of Python and operating systems.

Fig 0.4 Select the OS to download

 To download Windows 32bit Python, you can select the built-in Windows X86 Zip
file, WindowsX86 executable installer or WindowsX86 installer on the Web.

 To download Windows 64-bit Python, you can select any option of the three

Dept of CSE, BVCEC, Odalarevu 5


Driver Drowsiness Detection System Using Image Processing

options. Zip File Embeddable Windows X866, Windows X8664 executable installer
or Windows X8664 installer based on the web.

1.5 Installation of Python

Step-1: Goto Download and Open the downloaded python version to carry out the
installation process.

Step-2: Before you click on Install Now, make sure to put a tick on Add Python 3.7 to
Path

Fig 0.5 Python application Setup

Step-3: Click on Install Now After the installation is successful. Click on Close.

Dept of CSE, BVCEC, Odalarevu 6


Driver Drowsiness Detection System Using Image Processing

Fig 0.6 Setup Successful Message

With these above three steps on python installation, you have successfully and
correctly installed Python. Now is the time to verify the installation.

Note: The installation process might take a couple of minutes.

1.6 Verify the Python Installation

Step-1: Click on Start

Step-2: In the Windows Run Command, type “cmd”.

Dept of CSE, BVCEC, Odalarevu 7


Driver Drowsiness Detection System Using Image Processing

Fig 0.7 Open Command Prompt

Step-3: Open the Command prompt option.

Fig 0.8 Check Whether Python is Installed

Step-4: Let us test whether the python is correctly installed. Type python– V and press
Enter.

Step-5: You will get the answer as 3.7.4

Note: If you have any of the earlier versions of Python already installed. You must first
uninstall the earlier version and then install the new one.

Dept of CSE, BVCEC, Odalarevu 8


Driver Drowsiness Detection System Using Image Processing

1.7 Check how the Python IDLE works

Step-1: Click on Start

Step-2: In the Windows Run command, type “python idle”.

Step-3: Click on IDLE (Python3.7 64-bit) and launch the program

Step-4: To go ahead with working in IDLE

Fig 0.9 Python IDLE Interface

Step-5: Name the file and save as type should be Python files. Click on SAVE.

1.8 What is VS Code:

Visual Studio Code is the most popular code editor and the IDEs provided by
Microsoft for writing different programs and languages. It allows the users to develop
new code bases for their applications and allow them to successfully optimize them.

For its high popularity, individuals opt to Install Visual Studio Code on Windows over
any other IDE. Installation of Windows Visual Studio Code is not a difficult matter. The
Installation process starts with Downloading the Visual Studio Code EXE file to some
on-screen instructions.

We are going to list all the steps required to Install VS Code on Windows in a detailed
format.

 Quick Preview to Install Visual Studio Code on Windows

 Download the VS Code file from the Official Website.

 Execute the download file.

 Accept the Terms & Conditions.

Dept of CSE, BVCEC, Odalarevu 9


Driver Drowsiness Detection System Using Image Processing

 Click on the Install button.

 Wait for the installation to complete.

 Click on the Launch button to start it.

1.9 Steps to Install Visual Studio Code on Windows

Step 1: Visit the Official Website of the Visual Studio Code using any web browser like
Google Chrome, Microsoft Edge, etc.

Fig 0.10 Visual Studio Code Official Download Site

Step 2: Press the “Download for Windows” button on the website to start the download
of the Visual Studio Code Application.

Step 3: When the download finishes, then the Visual Studio Code Icon appears in the
downloads folder.

Step 4: Click on the Installer icon to start the installation process of the Visual Studio
Code.

Step 5: After the Installer opens, it will ask you to accept the terms and conditions of
the Visual Studio Code. Click on I accept the agreement and then click the Next button.

Dept of CSE, BVCEC, Odalarevu 10


Driver Drowsiness Detection System Using Image Processing

Fig 0.11 VS Code Licence agreement

Step 6: Choose the location data for running the Visual Studio Code. It will then ask
you to browse the location. Then click on the Next button.

Fig 0.12 Add the VS Code to PATH

Step 7: Then it will ask to begin the installation setup. Click on the Install button.

Step 8: After clicking on Install, it will take about 1 minute to install the Visual Studio
Code on your device.

Dept of CSE, BVCEC, Odalarevu 11


Driver Drowsiness Detection System Using Image Processing

Fig 0.13 VS Code Installation Screen

Step 9: After the Installation setup for Visual Studio Code is finished, it will show a
window like this below. Tick the “Launch Visual Studio Code” checkbox and then click
Next.

Fig 0.14 VS Code Installation Complete

Dept of CSE, BVCEC, Odalarevu 12


Driver Drowsiness Detection System Using Image Processing

Step 10: After the previous step, the Visual Studio Code window opens successfully.
Now you can create a new file in the Visual Studio Code window and choose a
language of yours to begin your programming journey!

Fig 0.15 VS Code Interface

Dept of CSE, BVCEC, Odalarevu 13


Driver Drowsiness Detection System Using Image Processing

CHAPTER 2

SYSTEM ANALYSIS
2.1 Existing System

The existing systems for detecting driver drowsiness primarily rely on


physiological signals such as eye movements, steering patterns, and vehicle dynamics.
These systems often utilize sensors embedded within the vehicle to monitor these
signals and detect deviations associated with drowsiness. For example, some systems
track the frequency of eye blinks and the duration of eyelid closures to assess driver
alertness. Others analyze steering wheel movements and lane deviations to infer driver
fatigue. While these systems have shown some effectiveness in detecting drowsiness,
they often have limitations such as sensitivity to environmental factors, false alarms,
and lack of adaptability to individual differences in behavior. Additionally, the reliance
on physiological signals alone may not capture the full spectrum of drowsiness-related
behaviors, leading to incomplete or inaccurate detection. Therefore, there is a need for
more comprehensive and robust solutions that incorporate multiple modalities, such as
image processing, to improve the accuracy and reliability of drowsiness detection
systems.

2.1.1 Drawbacks

1. Limited Sensitivity: Existing systems primarily rely on physiological signals such


as eye movements and steering patterns, which may not always accurately reflect
the driver's level of fatigue. For example, some drivers may exhibit subtle signs of
drowsiness that are not captured effectively by these sensors, leading to false
negatives and potentially missed warnings.

2. Environmental Sensitivity: Many current systems are sensitive to environmental


factors such as lighting conditions and road surface quality. Changes in these
factors can impact the reliability of drowsiness detection, leading to inconsistent
performance and false alarms.

3. False Alarms: Due to the reliance on physiological signals, existing systems may
produce false alarms when drivers engage in non-fatigue-related behaviors that
mimic drowsiness. For instance, a driver may exhibit erratic steering behavior due
to road conditions or distractions, leading to a false drowsiness alert.

Dept of CSE, BVCEC, Odalarevu 14


Driver Drowsiness Detection System Using Image Processing

4. Lack of Individualization: Current systems often lack the ability to adapt to


individual differences in driver behavior and preferences. This one-size-fits-all
approach may result in suboptimal performance for some drivers, as the system fails
to account for their unique driving styles and habits.

5. Limited Scope: Many existing systems focus solely on detecting drowsiness based
on physiological signals and may overlook other important indicators such as facial
expressions and body posture. This narrow focus may limit the system's
effectiveness in accurately identifying drowsiness in all drivers and situations.

6. Dependency on Hardware: Some drowsiness detection systems require


specialized hardware installations within the vehicle, making them costly to
implement and maintain. This dependency on hardware may also limit the
scalability and accessibility of these systems for widespread adoption.

2.2 Proposed System

The proposed system for the Driver Drowsiness Detection project aims to
overcome the limitations of existing systems by incorporating image processing
techniques to enhance the accuracy and reliability of drowsiness detection. The system
will utilize a combination of facial recognition, eye tracking, and other visual cues to
monitor driver behavior and identify signs of fatigue in real-time.

1. Facial Recognition: The system will analyze facial expressions, including changes
in facial muscle movements and eye closure patterns, to detect signs of drowsiness.
By leveraging facial recognition algorithms, the system can accurately identify
subtle changes indicative of fatigue, such as drooping eyelids and yawning.

2. Eye Tracking: Eye tracking technology will be employed to monitor the driver's
gaze patterns and detect instances of prolonged eye closure or erratic eye
movements, which are common indicators of drowsiness. By continuously tracking
the driver's eye movements, the system can detect deviations from normal behavior
and issue timely warnings when signs of fatigue are detected.

3. Other Visual Cues: In addition to facial recognition and eye tracking, the system
will also analyze other visual cues such as head position, body posture, and hand
movements to further enhance drowsiness detection accuracy. By integrating
multiple visual cues, the system can provide a more comprehensive assessment of

Dept of CSE, BVCEC, Odalarevu 15


Driver Drowsiness Detection System Using Image Processing

the driver's alertness level and improve overall detection performance.

4. Adaptive Algorithms: The proposed system will incorporate adaptive algorithms


that can dynamically adjust detection thresholds and parameters based on individual
driver behavior and environmental conditions. By continuously learning and
adapting to changing circumstances, the system can optimize performance and
reduce false alarms, ensuring robust and reliable drowsiness detection in diverse
driving scenarios.

5. Real-time Feedback: Upon detecting signs of drowsiness, the system will provide
real-time feedback to the driver through visual and auditory alerts, prompting them
to take corrective action such as taking a break or switching drivers. Additionally,
the system may integrate with the vehicle's navigation system to suggest nearby
service areas where the driver can safely stop and rest.

Overall, the proposed system represents a comprehensive and adaptive approach to


drowsiness detection, leveraging image processing techniques to enhance accuracy and
reliability. By integrating multiple modalities and incorporating adaptive algorithms,
the system aims to provide proactive assistance to drivers and mitigate the risks
associated with drowsy driving, ultimately enhancing road safety for all.

2.2.1 Advantages

1. Improved Accuracy: By incorporating facial recognition and eye tracking


technologies, the proposed system can detect subtle signs of drowsiness with higher
accuracy compared to systems that rely solely on physiological signals. This
enhanced accuracy reduces the likelihood of false alarms and ensures that drivers
receive timely warnings when they are genuinely fatigued.

2. Comprehensive Monitoring: The use of multiple visual cues, including facial


expressions, eye movements, head position, and body posture, allows the system to
provide a more comprehensive assessment of driver alertness. This comprehensive
monitoring capability enhances the system's ability to detect drowsiness across a
wide range of driving conditions and driver behaviors.

3. Adaptive Algorithms: The incorporation of adaptive algorithms enables the system


to dynamically adjust detection thresholds and parameters based on individual
driver behavior and environmental factors. This adaptability ensures that the system
can effectively accommodate variations in driving styles and conditions, optimizing

Dept of CSE, BVCEC, Odalarevu 16


Driver Drowsiness Detection System Using Image Processing

performance and minimizing false alarms.

4. Real-time Feedback: Upon detecting signs of drowsiness, the system provides


real-time feedback to the driver through visual and auditory alerts. This immediate
feedback prompts drivers to take corrective action, such as taking a break or
switching drivers, thereby reducing the risk of accidents due to drowsy driving.

5. Integration with Navigation Systems: The proposed system may integrate with
the vehicle's navigation system to suggest nearby service areas where drivers can
safely stop and rest. This integration enhances the system's usability and encourages
drivers to prioritize their well-being during long journeys.

6. Cost-effective Implementation: Unlike some existing systems that require


specialized hardware installations, the proposed system primarily relies on
software-based image processing techniques, making it more cost-effective to
implement and maintain.

2.3 Modules

 Image Acquisition and Preprocessing

 Feature Extraction and Selection

 Drowsiness Detection Module

 User Interface and Alert System Integration

1. Image Acquisition and Preprocessing Module:

This module focuses on obtaining images or video feed from the onboard camera
or any other input source within the vehicle. The acquired images may contain various
environmental factors such as varying lighting conditions, occlusions, and noise.
Preprocessing techniques are employed to enhance the quality and clarity of the images,
which is crucial for accurate drowsiness detection. Common preprocessing steps
include noise reduction, contrast enhancement, and normalization. Additionally, image
registration techniques may be applied to compensate for any movement or vibration of
the camera. This module ensures that the input images are optimized for subsequent
processing stages.

Dept of CSE, BVCEC, Odalarevu 17


Driver Drowsiness Detection System Using Image Processing

2. Feature Extraction and Selection Module:

In this module, relevant features are extracted from the preprocessed images to
characterize facial expressions and movements indicative of drowsiness. These features
may include eye closure duration, head pose, blink rate, and facial landmarks such as
mouth curvature. Feature extraction techniques like Haar cascades, HOG (Histogram of
Oriented Gradients), and deep learning-based methods such as Convolutional Neural
Networks (CNNs) are employed to capture discriminative information from the images.
Furthermore, feature selection algorithms are utilized to reduce dimensionality and
remove redundant or irrelevant features, improving computational efficiency and model
performance.

3. Drowsiness Detection Module:

This module implements the core algorithm responsible for detecting driver drowsiness
based on the extracted features. Various machine learning and deep learning techniques
such as Support Vector Machines (SVM), Random Forests, Recurrent Neural Networks
(RNNs), or Long Short-Term Memory (LSTM) networks can be employed for
classification. The algorithm analyzes the feature vectors derived from the input images
in real-time and determines the driver's drowsiness state. Thresholding techniques or
probabilistic models may be utilized to establish criteria for identifying drowsiness,
triggering appropriate alerts or interventions when necessary.

4. User Interface and Alert System Integration Module:

The final module involves the development of a user-friendly interface to interact with
the drowsiness detection system and integration with the vehicle's alert system. The
user interface provides real-time feedback to the driver, displaying the current
drowsiness level and relevant alerts. Alerts may include auditory, visual, or haptic cues
to grab the driver's attention and prompt them to take corrective actions, such as taking
a break or pulling over safely. Integration with the vehicle's alert system ensures
seamless communication and coordination with existing safety mechanisms, enhancing
overall driver safety and reducing the risk of accidents due to drowsy driving.

Dept of CSE, BVCEC, Odalarevu 18


Driver Drowsiness Detection System Using Image Processing

2.4 Feasibility Study

A feasibility study for a driver drowsiness detection system project involves


assessing various aspects to determine the viability and practicality of implementing the
system. Here's a breakdown of key considerations:

2.4.1 Technical Feasibility

1. Availability of Necessary Technology: Evaluate the availability and suitability


of hardware components such as cameras, processors, and memory for real-time
image processing.

2. Software Requirements: Assess the feasibility of implementing the required


algorithms and image processing techniques within the constraints of the chosen
platform (e.g., embedded system, mobile device).

3. Performance Requirements: Determine whether the system can meet


performance metrics such as processing speed, accuracy of drowsiness detection,
and reliability under different environmental conditions.

2.4.2 Financial Feasibility

1. Cost of Development: Estimate the costs associated with acquiring hardware,


software licenses, development tools, and hiring personnel with the necessary
expertise.

2. Return on Investment (ROI): Assess the potential benefits of the system, such
as reduced accidents and associated costs (e.g., medical expenses, property
damage), improved driver safety, and potential revenue streams (e.g., licensing
the technology to automotive manufacturers).

2.4.3 Market Feasibility

1. Market Demand: Research the prevalence of drowsy driving incidents and


existing solutions in the automotive safety market. Identify potential customers,
including individual consumers, fleet operators, and automotive manufacturers.

2. Competitive Landscape: Analyze competitors offering similar drowsiness


detection systems and evaluate their strengths, weaknesses, and market
positioning.

3. Regulatory Compliance: Ensure that the proposed system complies with

Dept of CSE, BVCEC, Odalarevu 19


Driver Drowsiness Detection System Using Image Processing

relevant regulations and standards in the automotive industry regarding safety


and privacy.

2.4.4 Operational Feasibility

1. Integration with Existing Systems: Assess the compatibility and ease of


integration with existing vehicle systems, including onboard computers, alert
systems, and driver monitoring systems.

2. User Acceptance: Conduct surveys or usability studies to gauge the acceptance


and usability of the system among target users, such as drivers and fleet
operators.

3. Maintenance and Support: Evaluate the requirements for ongoing


maintenance, updates, and technical support to ensure the long-term viability and
reliability of the system.

2.4.5 Legal and Ethical Feasibility

1. Privacy Considerations: Address privacy concerns related to the collection and


processing of driver data, ensuring compliance with data protection regulations
(e.g., GDPR, CCPA).

2. Liability Issues: Consider legal implications in the event of system failure or


incorrect detection of drowsiness, including potential liability for accidents or
injuries.

Dept of CSE, BVCEC, Odalarevu 20


Driver Drowsiness Detection System Using Image Processing

CHAPTER 3

REQUIREMENT ANALYSIS
3.1 Software Requirements
 For developing the application, the following are the
1. Software Requirements: Python, Visual Studio Code
2. Operating Systems supported: Windows 10 and above

3.2 Functional Requirements


1. Encoding and Decoding Algorithms
2. User Interface Design

3.3 Hardware Requirements


1. Processor: Intel i5 or Above
2. Ram: Minimum 4GB
3. Secondary storage: Minimum 40 GB

Dept of CSE, BVCEC, Odalarevu 21


Driver Drowsiness Detection System Using Image Processing

CHAPTER 4

SOFTWARE DESIGN
4.1 Data Flow Diagram
A data flow diagram (DFD) is a visual representation of how data moves through a
system, using standardized symbols and notation. DFDs can be simple overviews or
complex representations with multiple levels. The most common and intuitive DFDs
are level 0 DFDs, also called context diagrams.
A DFD can include:
Level 0 DFD
Also called a context diagram, this is a basic overview of the system or process being
modeled. It shows the system as a single high-level process, with its relationship to
external entities.
Level 1 DFD
This represents the main functions of the system and how they interact with each other.
Level 2 DFD
This represents the processes within each function of the system and how they interact
with each other.
Level 3 DFD
This represents the data flow within each process and how the data is
transformed and stored
DFDs are commonly used in software engineering to model the structure and behavior
of systems, aiding in the understanding, analysis, and communication of
complex processes.
1. External Entities:
Driver: Represents the user of the system who interacts with the drowsiness detection
system.

Camera/Input Sensor: Represents the hardware component that captures images or


sensor data of the driver's face and surrounding environment.

2. Processes:

Dept of CSE, BVCEC, Odalarevu 22


Driver Drowsiness Detection System Using Image Processing

Image Processing: This process involves preprocessing the captured images or sensor
data to enhance quality and extract relevant features related to drowsiness detection.

Drowsiness Detection Algorithm: This process analyzes the preprocessed data to


detect signs of drowsiness based on predefined criteria or algorithms.

Alert Generation: Upon detecting drowsiness, this process generates alerts to notify
the driver, typically through visual, auditory, or haptic feedback.

3. Data Stores:
Drowsiness Data: Represents the data related to drowsiness detection, including
preprocessed image data, extracted features, and detection results.

Alert Log: Stores records of alerts generated by the system, including timestamps and
details of the detected drowsiness events.

4. Data Flows:
Image/Sensor Data: Represents the flow of raw image data or sensor readings from
the camera/input sensor to the Image Processing process.

Preprocessed Data: Represents the processed image data or extracted features


transmitted from the Image Processing process to the Drowsiness Detection Algorithm.

Detection Result: Represents the output of the Drowsiness Detection Algorithm,


indicating the presence or absence of drowsiness.

Alert Signal: Represents the signal generated by the Alert Generation process to notify
the driver of detected drowsiness.

A data flow diagram (DFD) is a graphical representation of the flow of data within a
system. It typically consists of processes, data stores, data flows, and external entities.
The processes represent the transformations or operations performed on the data, data
stores are repositories where data is stored, data flows depict the movement of data
between processes and data stores, and external entities are sources or destinations of
data that interact with the system.

Dept of CSE, BVCEC, Odalarevu 23


Driver Drowsiness Detection System Using Image Processing

Fig 0.16 Data Flow Diagram

UML Diagrams:

A Unified Modeling Language (UML) diagram is a visual representation of a software


system's design, architecture, and implementation. UML diagrams are standardized and
can be used across different development processes and programming languages.
Software engineers use UML diagrams to understand the code architecture, designs,
and proposed implementation of complex software systems. UML diagrams can also be
used to model business processes and workflows.

A Unified Modeling Language (UML) diagram for the driver drowsiness detection
system project can provide a visual representation of the system's structure and
behavior. Here's an explanation of the key components of a UML diagram for this
project:

Dept of CSE, BVCEC, Odalarevu 24


Driver Drowsiness Detection System Using Image Processing

4.2 Use Case diagram


A use case diagram is a visual representation of how users interact with a system. It
summarizes the system's details and users, and the events that occur within the system
and how they flow. Use case diagrams do not describe how events are implemented.
The four main components of a use case diagram are actors, the system itself,
relationships, and use cases. Actors: Actors are the users of a system. They can be
people, organizations, or other systems. An actor can be a primary user or a secondary
user of a system.
Use cases represent the system's functionalities from the perspective of its users. In this
diagram, the primary actor would be the "Driver," and the use cases could include
actions such as "Start Drowsiness Detection," "Receive Alert," and "Acknowledge
Alert." Each use case represents a specific interaction between the user and the system.

Dept of CSE, BVCEC, Odalarevu 25


Driver Drowsiness Detection System Using Image Processing

Fig 0.17 Use Case Diagram

4.2 Class Diagram

Class diagrams are the blueprints of your system or subsystem. You can use class
diagrams to model the objects that make up the system, to display the relationships
between the objects, and to describe what those objects do and the services that they
provide. Class diagrams are useful in many stages of system design.class diagram is an
illustration of the relationships and source code dependencies among classes in the
Unified Modeling Language (UML). In this context, a class defines the methods and

Dept of CSE, BVCEC, Odalarevu 26


Driver Drowsiness Detection System Using Image Processing

variables in an object, which is a specific entity in a program or the unit of code


representing that entity
The class diagram illustrates the system's static structure by showing the classes, their
attributes, methods, and relationships. For this project, classes could include
"Drowsiness Detection System," "Camera," "Image Processor," "Drowsiness Detector,"
and "Alert System." Relationships between these classes depict how they interact and
collaborate within the system.

class diagram is a type of diagram in the Unified Modeling Language (UML) that
represents the structure of a system by showing the classes of the system, their
attributes, methods, and the relationships among them.

In a class diagram:

Classes are depicted as rectangles with three compartments: the top compartment
contains the class name, the middle compartment contains the attributes (data members)
of the class, and the bottom compartment contains the methods (member functions) of
the class.

Relationships between classes are shown as lines connecting them, indicating


associations, dependencies, inheritances, or realizations.

Associations represent relationships between classes and can be one-to-one, one-to-


many, or many-to-many. They are typically represented by lines connecting the classes,
often with arrows indicating the direction of the relationship.

Dependencies represent a relationship where a change in one class may affect another
class. They are typically represented by a dashed line with an arrow indicating the
direction of the dependency.

Inheritance represents an "is-a" relationship, where one class (subclass) inherits


attributes and methods from another class (superclass). It is represented by a solid line
with a hollow triangle pointing to the superclass.

Class diagrams are widely used in software development for designing object-oriented
systems, providing a visual representation of the system's structure and helping to
communicate design decisions among stakeholders.

Dept of CSE, BVCEC, Odalarevu 27


Driver Drowsiness Detection System Using Image Processing

Fig 0.18 Class Diagram

4.4 Sequence Diagram


A sequence diagram depicts the interactions between objects in a particular scenario or
sequence of events. In this context, a sequence diagram could show the flow of
interactions between the components of the system during the drowsiness detection
process. It would illustrate the steps involved, such as capturing an image from the

Dept of CSE, BVCEC, Odalarevu 28


Driver Drowsiness Detection System Using Image Processing

camera, processing the image, analyzing for signs of drowsiness, and triggering an alert
if necessary.
A sequence diagram is a Unified Modeling Language (UML) diagram that illustrates
the order of messages sent between objects in an interaction. It uses parallel vertical
lines (lifelines) to represent objects or processes, and horizontal arrows to represent
messages exchanged between them. Sequence diagrams are used by software
developers and business professionals to: Understand requirements for a new system,
Document an existing process, Design new systems, Document how objects in an
existing system work, and Communicate how a business works.

Fig 0.19 Sequence Diagram

4.5 Activity Diagram


An activity diagram visualizes the flow of activities or processes within the system. For
this project, an activity diagram could represent the overall process of drowsiness
detection, including steps such as "Capture Image," "Preprocess Image," "Detect
Drowsiness," and "Generate Alert." Each activity would be connected by arrows
indicating the flow of control.

Dept of CSE, BVCEC, Odalarevu 29


Driver Drowsiness Detection System Using Image Processing

An activity diagram is a type of Unified Modeling Language (UML) flowchart that


shows the flow of activities in a system or process. It's also known as a "behavior
diagram" because it describes what should happen in the modeled system. Activity
diagrams are used to model both computational and organizational processes, as well as
the data flows intersecting with the related activities.

Activity diagrams show the control flow from step to step, i.e., from activity to activity.
An activity shows a set of actions, the sequential or branching control flow, and values
that are produced or consumed by actions. Activity diagrams can also include elements
showing the flow of data between activities through one or more data stores.

Activity diagrams are often used in business process modeling. They can also describe
the steps in a use case diagram. An activity diagram is a type of behavioral diagram in
the Unified Modeling Language (UML) that represents the flow of control or the
sequence of activities in a system or process. It visually depicts the steps and actions
involved in completing a specific task or achieving a particular goal within a system.

In an activity diagram:

Activities are represented as rounded rectangles and are connected by arrows to show
the flow of control from one activity to another. Decision points, represented by
diamonds, indicate branching in the flow of control based on conditions or decisions.
Control flow arrows indicate the sequence in which activities are performed, including
loops, concurrent activities, and parallel flows. Swimlanes can be used to represent
different actors, roles, or system components involved in the activities. Activity
diagrams are used to model business processes, software workflows, and system
behaviors, helping to visualize and understand the dynamic aspects of a system or
process. They are particularly useful for capturing complex logic and interactions
between different components or actors within a system.

Dept of CSE, BVCEC, Odalarevu 30


Driver Drowsiness Detection System Using Image Processing

Fig 0.20 Activity Diagram

4.6 State Machine Diagram


A state machine diagram models the behavior of an object or system over time,
depicting its states and transitions between them. In the context of the drowsiness
detection system, a state machine diagram could represent the various states that the
system can be in, such as "Idle," "Processing," and "Alert Triggered," along with the
conditions or events that trigger transitions between these states.
A state machine diagram models the behaviour of a single object, specifying the
sequence of events that an object goes through during its lifetime in response to events.
As an example, the following state machine diagram shows the states that a door goes
through during its lifetime.

Dept of CSE, BVCEC, Odalarevu 31


Driver Drowsiness Detection System Using Image Processing

Fig 0.21 State Machine Diagram

Dept of CSE, BVCEC, Odalarevu 32


Driver Drowsiness Detection System Using Image Processing

CHAPTER 5

IMPLEMENTATION
5.1 Image processing
Localization of Face: Since the Face is symmetric, we use a symmetry-based
approach. We found that it is enough to use a sub sampled, gray-scale version of the
image. A symmetry-value is then computed for every pixel-column in the reduced
image. If the image is represented as I(x, y) then the symmetry value for a pixel-column
is given by S(x) = ∑∑ [abs I ((x,y-w)-(x,y+w))]. S(x) is computed for X € [k,size-k]
where k is the maximum distance from the pixel-column that symmetry is measured,
and x size is the width of the image. The x corresponding to the lowest value of S(x) is
the center of the face.

Fig 0.22 The Symmetry Histogram

EXPERIMENTAL SET-UP

Dept of CSE, BVCEC, Odalarevu 33


Driver Drowsiness Detection System Using Image Processing

Fig 0.23 The original image, the edges and the histogram of projected edges.

Location of Eyes: A raster scan algorithm is used for the exact location of the eyes
and extracts that vertical location of eyes.

Tracking of the eyes: We track the eye by looking for the darkest pixel in the
predicted region. In order to recover from tracking errors, we make sure that none
of the geometrical constraints are violated. If they are, we delocalize the eyes in
the next frame. To find the best match for the eye template, we initially center it at
the darkest pixel, and then perform a gradient descent in order to find a local
minimum.

Fig 0.24 Detection of eye

Detection of Drowsiness: As the driver becomes more fatigued, we expect the eye-
blinks to last longer. We count the number of consecutive frames that the eyes are
closed in order to decide the condition of the driver. For this, we need a robust way to
determine if the eyes are open or closed; so we used a method that looks at the
horizontal histogram across the pupil.

EXPERIMENTAL SET-UP

The final system consists of a camera pointing at the driver. The camera is to be
mounted on the dashboard inside the vehicle. For the system we are developing, the
camera is stationary and will not adjust its position or zoom during operation. For
experimentation, we are using a webcam. The grabbed frames are represented in RGB-
space with 8-bit pixels (256 colors). We will not be using any specialized hardware for
image processing. Given below is the block diagram

Dept of CSE, BVCEC, Odalarevu 34


Driver Drowsiness Detection System Using Image Processing

Fig 0.25 Block Diagram

Fig 0.26 System configuration

Fig 0.27 Flowchart of the given system

Dept of CSE, BVCEC, Odalarevu 35


Driver Drowsiness Detection System Using Image Processing

The function of the system can be broadly divided into eye detection function,
comprising the first half of the preprocessing routine, and a drowsiness detection
function, comprising the second half.
After inputting a facial image, preprocessing is p e r f o r m e d to binaries the image
and remove noise, which makes it possible for the image to be accepted by the image
processor. The maximum width of the face is then detected so that the right and left
edges of the face can be identified. After that the vertical position of each eye is
detected independently within an area defined by the center line of the face width and
lines running through the outermost points of the face. On that basis, the area in which
each eye is present is determined. Once the areas of eye presence have been defined,
they can be updated by tracking the movement of the eyes. The degree of eye openness
is output simultaneously with the establishment or updating of the areas of eye
presence. That value is used in judging whether the eyes are open or closed and also in
judging whether the eyes have been detected correctly or not. If the system judges that
the eyes have not been detected correctly, the routine returns to the detection of the
entire face.

The following explains the eye detection procedure in the order of the processing
operations.
a) Preprocessing
The preprocessing operations include the binarization of a facial image to increase
the processing speed and conserve memory capacity and noise removal. The image
processor developed for this drowsiness warning system performs the expansion and
contraction operation on the white pixels and processing for noise removal is
performed on the small black pixels of the facial images.

After the binarization, the noise removal procedure involves an expansion processing
method combined with the use of a median filter. These preprocessing operations are
sufficient to support detection of the vertical positions of the eyes.

However, following identification of the eye positions, the size of the eyes must be
converted back to the original image format at the time the degree of eye openness is
output. To facilitate that, data contraction is performed in the latter stage of
preprocessing.

Dept of CSE, BVCEC, Odalarevu 36


Driver Drowsiness Detection System Using Image Processing

b) ce width detection
The maximum width of the driver’s face must be detected in order to determine the
lateral positions of the areas in which the eyes are present. Face width is detected by
judging the continuity of white pixels and the pattern of change in pixel number. On
that basis, the outer edges of the face are recognized and determined.

c) Detection of vertical eye positions


Each vertical eye position is detected independently within an area demarcated by the
center line of the face, which is found from the face width, and straight lines running
through the right and left outer edges of the face. In a binary image, the eye becomes
collection of black pixels, along with the eyebrows, nostrils, mouth and other facial
features. These collections of black pixels are recognized on the basis of a labeling
operation, and the position of each eye is extracted by judging the area of each label
along with its aspect ratio and relative coordinate positions in the facial image.
Through this process of detecting each vertical eye position, the central coordinates
of each eye are recognized. The coordinates serve as references for defining the areas
of eye presence.

d) Eye tracking
A function for tracking the positions of the eye is an important capability for
achieving high-speed processing because it eliminates the need to process every
frame in order to detect each eye position from the entire facial image.

This function consists of a subordinate for updating the areas of eye presence and
recognizing when tracking becomes impossible. The basic concept of eye tracking is
to update the area of eye presence, in which an eye search is made in the following
frame, according to the central coordinates of the eye in the previous frame. The
updating process involves defining an arc of eye presence on the basis of the
coordinates (xk, yk) at the point of intersection of center lines running through the
Ferret’s diameter of the detected eye. The area thus becomes the area of eye presence
in which the system searches for the eye in the image data of the next frame.

This process of using information on eye position to define the eye position for
obtaining the next facial image data makes it possible to track the position of the eye.
As it is clear from this description, the size of the area of eye position changes. If the

Dept of CSE, BVCEC, Odalarevu 37


Driver Drowsiness Detection System Using Image Processing

eyes are tracked correctly, their degree of openness will always vary within certain
specified range for each individual driver. Consequently, if the value found by the
system falls outside the range, it judges that the eyes are not being tracked correctly.
The process of detecting the position of each eye from the entire facial image is then
executed once more.

e) Judgment whether the eye is open/closed:


We constructed a template consisting of two circles, one inside the other. A good
match would result in many dark pixels in the area inside the inner circle, and many
bright pixels in the area between the two circles. This match occurs when the inner
circle is centered on the iris and the outside circle covers the sclera. The match M
(a1, a2) is computed as

M (a1, a2) = ∑ I (p, q)-∑ I (p, q)

(p, q)€a1 (p, q) €a2

A low value for M (a1, a2) corresponds to a good match. The template is matched
across the predicted eye-region, and the best match is reported. We track the eye by
looking for the darkest pixel in the predicted region

Fig 0.28 Histogram corresponding to eye opened/closed.

Dept of CSE, BVCEC, Odalarevu 38


Driver Drowsiness Detection System Using Image Processing

5.2 Source Code


5.3.1 drowsiness-detection.ipynb

from roboflow import Roboflow


import supervision as sv
import cv2
import pygame

rf = Roboflow(api_key="fwNieMnrMWlCxLCHOKFU") #Enter your Roboflow API


Key
project = rf.workspace().project("drowsiness-detection-systemv1.1")
model = project.version(2).model

labels = model.classes

label_annotator = sv.LabelAnnotator()
bounding_box_annotator = sv.BoxAnnotator()

cap = cv2.VideoCapture(0)

pygame.mixer.init()
alert_sound = pygame.mixer.Sound("warning.mp3")

while True:
ret, frame = cap.read()
if not ret:
break

result = model.predict(frame, confidence=40, overlap=30).json()

Dept of CSE, BVCEC, Odalarevu 39


Driver Drowsiness Detection System Using Image Processing

detections = sv.Detections.from_roboflow(result)
annotated_frame = bounding_box_annotator.annotate(scene=frame,
detections=detections)
annotated_frame = label_annotator.annotate(scene=annotated_frame,
detections=detections, labels=labels)

for prediction in result['predictions']:


if prediction['class'] == 'Drowsy':
alert_sound.play()
break

cv2.imshow('Drowsiness Detection', annotated_frame)

if cv2.waitKey(1) & 0xFF == ord('q'):


break

cap.release()
cv2.destroyAllWindows()

5.3.2 main.py
from roboflow import Roboflow
import supervision as sv
import cv2
import pygame

rf = Roboflow(api_key="fwNieMnrMWlCxLCHOKFU") #Enter your Roboflow API


Key
project = rf.workspace().project("drowsiness-detection-systemv1.1")
model = project.version(2).model

labels = model.classes

Dept of CSE, BVCEC, Odalarevu 40


Driver Drowsiness Detection System Using Image Processing

label_annotator = sv.LabelAnnotator()
bounding_box_annotator = sv.BoxAnnotator()

cap = cv2.VideoCapture(0)

pygame.mixer.init()
alert_sound = pygame.mixer.Sound("warning.mp3")

while True:
ret, frame = cap.read()
if not ret:
break

result = model.predict(frame, confidence=40, overlap=30).json()

detections = sv.Detections.from_roboflow(result)

annotated_frame = bounding_box_annotator.annotate(scene=frame,
detections=detections)
annotated_frame = label_annotator.annotate(scene=annotated_frame,
detections=detections, labels=labels)

for prediction in result['predictions']:


if prediction['class'] == 'Drowsy':
alert_sound.play()
break

cv2.imshow('Drowsiness Detection', annotated_frame)

if cv2.waitKey(1) & 0xFF == ord('q'):


break

Dept of CSE, BVCEC, Odalarevu 41


Driver Drowsiness Detection System Using Image Processing

cap.release()
cv2.destroyAllWindows()
5.3.3 activate.bat

@echo off

rem This file is UTF-8 encoded, so we need to update the current code page while
executing it
for /f "tokens=2 delims=:." %%a in ('"%SystemRoot%\System32\chcp.com"') do (
set _OLD_CODEPAGE=%%a
)
if defined _OLD_CODEPAGE (
"%SystemRoot%\System32\chcp.com" 65001 > nul
)

set VIRTUAL_ENV=C:\Users\anush\Dropbox\PC\Downloads\Drowsiness-Detection-
main(1)\.venv

if not defined PROMPT set PROMPT=$P$G

if defined _OLD_VIRTUAL_PROMPT set PROMPT=%_OLD_VIRTUAL_PROMPT


%
if defined _OLD_VIRTUAL_PYTHONHOME set PYTHONHOME=
%_OLD_VIRTUAL_PYTHONHOME%

set _OLD_VIRTUAL_PROMPT=%PROMPT%
set PROMPT=(.venv) %PROMPT%

if defined PYTHONHOME set _OLD_VIRTUAL_PYTHONHOME=


%PYTHONHOME%
set PYTHONHOME=

if defined _OLD_VIRTUAL_PATH set PATH=%_OLD_VIRTUAL_PATH%

Dept of CSE, BVCEC, Odalarevu 42


Driver Drowsiness Detection System Using Image Processing

if not defined _OLD_VIRTUAL_PATH set _OLD_VIRTUAL_PATH=%PATH%

set PATH=%VIRTUAL_ENV%\Scripts;%PATH%
set VIRTUAL_ENV_PROMPT=(.venv)

:END
if defined _OLD_CODEPAGE (
"%SystemRoot%\System32\chcp.com" %_OLD_CODEPAGE% > nul
set _OLD_CODEPAGE=
)

5.3.4 deactivate.bat

@echo off

if defined _OLD_VIRTUAL_PROMPT (
set "PROMPT=%_OLD_VIRTUAL_PROMPT%"
)
set _OLD_VIRTUAL_PROMPT=

if defined _OLD_VIRTUAL_PYTHONHOME (
set "PYTHONHOME=%_OLD_VIRTUAL_PYTHONHOME%"
set _OLD_VIRTUAL_PYTHONHOME=
)

if defined _OLD_VIRTUAL_PATH (
set "PATH=%_OLD_VIRTUAL_PATH%"
)

set _OLD_VIRTUAL_PATH=

set VIRTUAL_ENV=
set VIRTUAL_ENV_PROMPT=

Dept of CSE, BVCEC, Odalarevu 43


Driver Drowsiness Detection System Using Image Processing

:END

CHAPTER 6

TESTING
6.1 System Test
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.

6.2Types of Tests
6.2.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.
6.2.2 Integrated Testing
Integration tests are designed to test integrated software components to
determine if they 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.

Dept of CSE, BVCEC, Odalarevu 44


Driver Drowsiness Detection System Using Image Processing

6.2.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:
1. Valid Input: Identified classes of valid input must be accepted.
2. Invalid Input: Identified classes of invalid input must be rejected
3. Functions: Identified functions must be exercised.
4. Output: Identified classes of application outputs must be exercised.
5. Systems/Procedures: Interfacing systems or procedures must be invoked.
Organization and preparation of functional tests is focused on requirements, key
functions, or special test cases. In addition, systematic coverage pertaining to identify
Business process flows; data fields, predefined processes, and successive processes
must be considered for testing. Before functional testing is complete, additional tests
are identified and the effective value of current tests is determined.
6.2.4 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.

Dept of CSE, BVCEC, Odalarevu 45


Driver Drowsiness Detection System Using Image Processing

6.2.5 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. It is a testing
in which the software under test is treated, as a black box. you cannot “see” into it. The
test provides inputs and responds to outputs without considering how the software
works.
6.3 Test strategy and approach
Field testing will be performed manually and functional tests will be written in detail.
6.3.1 Test objectives
1. All field entries must work properly.
2. Pages must be activated from the identified link.
3. The entry screen, messages and responses must not be delayed.
6.3.2 Features to be tested
1. Verify that the entries are of the correct format
2. No duplicate entries should be allowed
3. All links should take the user to the correct page.

6.4 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.
Test Results:
All the test cases mentioned above passed successfully. No defects encountered

Dept of CSE, BVCEC, Odalarevu 46


Driver Drowsiness Detection System Using Image Processing

CHAPTER 7

OUTPUT

Fig 0.29 create vent-cmd

Dept of CSE, BVCEC, Odalarevu 47


Driver Drowsiness Detection System Using Image Processing

Fig 0.30 Change terminal

Fig 0.31 Activate-bat

Dept of CSE, BVCEC, Odalarevu 48


Driver Drowsiness Detection System Using Image Processing

Fig 0.32 Package installing-cmd

Fig 0.33 Code run main.py-cmd

Dept of CSE, BVCEC, Odalarevu 49


Driver Drowsiness Detection System Using Image Processing

Fig 0.34 i:p & o:p(Awake)

Fig 0.35 i_p & o_p(Drowsy)

Dept of CSE, BVCEC, Odalarevu 50


Driver Drowsiness Detection System Using Image Processing

CHAPTER 8

CONCLUSION AND FUTURE ENHANCEMENT


The driver drowsiness detection system project represents a critical endeavor aimed at enhancing
road safety by mitigating the risks associated with drowsy driving. Through the integration of
advanced image processing techniques, machine learning algorithms, and real-time alert systems,
the project seeks to detect early signs of driver fatigue and prompt timely interventions to prevent
potential accidents.

Conclusion and future enhancement states that

The driver drowsiness detection system project represents a critical endeavor aimed at enhancing
road safety by mitigating the risks associated with drowsy driving. Through the integration of
advanced image processing techniques, machine learning algorithms, and real-time alert systems,
the project seeks to detect early signs of driver fatigue and prompt timely interventions to prevent
potential accidents.

Throughout the project, we have delved into various aspects, including technical
feasibility, financial considerations, market analysis, operational aspects, and legal and
ethical implications. The feasibility study confirmed the viability of the project,
highlighting the availability of necessary technology, market demand, and potential
return on investment. Additionally, operational aspects such as integration with existing
systems and user acceptance were addressed to ensure the system's effectiveness and
practicality.
The development process involved the implementation of key modules,
including image acquisition and preprocessing, feature extraction and selection,
drowsiness detection algorithms, and integration with user interfaces and alert systems.
These modules were meticulously designed and implemented to ensure robustness,
accuracy, and real-time performance, essential for effective drowsiness detection in
dynamic driving scenarios.
Furthermore, the project emphasized the importance of adhering to legal and
ethical standards, particularly regarding privacy, data protection, and liability
considerations. By addressing these concerns, the system aims to uphold the highest
standards of safety, reliability, and ethical conduct.

Dept of CSE, BVCEC, Odalarevu 51


Driver Drowsiness Detection System Using Image Processing

In conclusion, the driver drowsiness detection system project represents a


significant step towards improving road safety and saving lives. By leveraging cutting-
edge technology and interdisciplinary approaches, the system strives to empower
drivers with the tools and support needed to stay vigilant and alert behind the wheel,
ultimately contributing to safer roads and communities. As we move forward,
continuous refinement, testing, and collaboration with stakeholders will be essential to
realize the full potential of this life-saving technology.
In considering future enhancements for the driver drowsiness detection system,
several avenues present themselves to further improve its efficacy and user experience.
Firstly, integrating multi-modal sensing capabilities, such as infrared sensors or steering
wheel sensors, could provide a more comprehensive view of the driver's state by
capturing physiological signals like heart rate and skin conductivity. Secondly,
advanced machine learning techniques, including deep learning architectures like
convolutional neural networks (CNNs) or recurrent neural networks (RNNs), could be
explored to enhance the accuracy and robustness of drowsiness detection algorithms.
Additionally, implementing dynamic alert mechanisms that adapt to driving conditions
and individual driver characteristics could make alerts more effective and less intrusive.
Personalization features, such as driver profiling based on behavior and physiological
responses, could further refine alert strategies. Integrating the system with existing
advanced driver assistance systems (ADAS) would provide comprehensive driver
assistance and safety features. Real-time monitoring and feedback mechanisms for fleet
managers could enhance fleet safety and management. Data-driven insights and
reporting capabilities could enable proactive interventions and policy decisions based
on historical drowsiness data analysis. Integration with autonomous vehicle
technologies and enhanced user interfaces would further elevate the system's
capabilities and user engagement. Lastly, continuous validation and improvement
through real-world testing and collaboration with stakeholders would ensure the system
remains at the forefront of drowsiness detection technology, promoting safer roads for
all.

Dept of CSE, BVCEC, Odalarevu 52


Driver Drowsiness Detection System Using Image Processing

CHAPTER 9
BIBLIOGRAPHY
[1] Qiang Ji, Zhiwei Zhu and Peilin Lan ―IEEE transactions on Vehicular
Technology Real Time Non-intrusive Monitoring and Prediction of Driver
Fatigue, vol. 53, no. 4, July 2004.
[2] N.G. Narole, and G.H. Raisoni., ―IJCSNS A Neuro-genetic System Design for
Monitoring Driver’s Fatigue. vol. 9. No. 3, March 2009.
[3] Wei-niin Huang & Robert Mariani, ―Face Detecion and precise Eyes Location
―, Proceeding of the International Conference on Patteni
Recognization(ICPP‖OO),Vol.4,2000
[4] Gonzalez, Rafel C. and Woods, Richard E. ―Digital Image Processing‖,
Prentice Hall: Upper Saddle River, N.J., 2002.
[5] Perez, Claudio A. et al. ―Face and Eye Tracking Algorithm Based on Digital
Image Processing‖,IEEE System, Man and Cybernetics 2001 Conference, vol. 2
(2001), pp 1178-1188.
[6] Singh, Sarbjit and Papanikolopoulos, N.P. ―Monitoring Driver Fatigue Using
Facial Analysis Techniques‖, IEEE Intelligent Transport System Proceedings
(1999), pp 314-318.
[7] Ueno H., Kanda, M. and Tsukino, M. ―Development of Drowsiness
DetectionSystem‖,IEEE Vehicle Navigation and Infor mation Systems
Conference Proceedings,(1994), ppA1-3,15-20.
[8] Weirwille, W.W. (1994). ―Overview of Research on Driver Drowsiness
Definition and Driver Drowsiness Detection,‖ 14th International Technical
Conference on Enhanced Safety of Vehicles, pp 23-26.
[9] R. Brunelli, Template Matching Techniques in Computer Vision: Theory and
Practice, Wiley, ISBN 978-0-470-51706-2, 2009
[10] J. Cox, J. Ghosn, P.N. Yianilos, ―Feature-Based Recognition Using
Mixture-Distance, ―NEC Research Institute,Technical Report 95 - 09, 1995.
[11] I. Craw, H. Ellis and J.R. Lishman, ―Automatic Extraction of Face-

Dept of CSE, BVCEC, Odalarevu 53


Driver Drowsiness Detection System Using Image Processing

Features,‖Pattern Recognition Letters, 5, pp. 183-187, 1987.


[12] L.C. De Silva, K. Aizawa and M. Hatori,―Detection and Tracking of Facial
Features by Using Edge Pixel Counting and Deformable Circular Template
Matching,‖IEICE Transaction on Information and Systems, Vol. E78-D No. 9,
pp. 1195- 1207, September 1995.
[13] C. Huang and C. Chen, ―Human Facial Feature Extraction for Face
Interpretation and Recognition,‖ Pattern Recognition, Vol. 25, NO. 12 pp.1435-
1444, 1992.
[14] M. Kass, A.Witkin and D.Terzopoulos, ―Snakes: Active Contour
Models,‖1042-1052, 1993, International Journal of Computer Vision,
[15] X.Li and N.Roeder,―Face Contour Extraction from Front View
Images,‖Pattern Recognition, Vol. 28, No. 8, pp.
[16] K.P.White,T.E. Hutchinson and J.M.Carley,―Spatially Dynamic
Calibration of an Eye-Tracking System,‖IEEE Transactions on Systems, Man,
and Cybernetics, Vol. 23, No. 4, pp. 1 162-1 168, 1993.
[17] N. Roeder and Xiabo Li, ―Accuracy Analysis for Facial Feature
Detection,‖Pattern Recognition, Vol. 29, No. 1, pp.
[18] Y. Segawa, H. Sakai, T. Endoh, K. Murakami, T. Toriu and H.Koshimizu,
―Face RecognitionThrough HoughTransform for Irises Extraction and
Projection Procedures for Parts Localization,‖ Pacific Rim International
Conference on Artificial Intelligence, pp.
[19] L. Stringa, ―Eyes Detection for Face Recognition,‖ Applied Art$cial
Intelligence, No. 7, pp. 365-382, 1993.
[20] R. Stiefelhagen, J. Yang and A. Waibel, ―A Model-Based Gaze Tracking
System,‖International IEEE Joint Symposia on Intelligence and Systems, pp.
304-3 IO, 1996.
[21] E.R.Tello,―Between Man and Machine,‖BYTE September,pp.288-293, 1983.
[22] D.Tock and I.Craw,―Tracking and Measuring Drivers Eyes,‖Real- Time
Computer Vision, pp. 71-89, 1995.
[23] X. Xie, R. Sudhakar and H. Zhuang, ―On Improving EyeFeatures Extraction
Using Deformable Templates,‖Pattern Recognition, Vol. 27, No. 6, pp. 791-799,
1994.
[24] X. Xie, R. Sudhakar and H. Zhuang, ―Real-Time Eye Feature Tracking from a
Video Image Sequence Using Kalman Filter,‖IEEE Transactions on Systems,

Dept of CSE, BVCEC, Odalarevu 54


Driver Drowsiness Detection System Using Image Processing

Man, and Cybernetics, Vol. 25,No.12, pp. 1568-1577, 1995.


[25] T.Yoo and I. Oh, ―Extraction of Face Region and Features Based on
Chromatic Properties of Human Faces, ―Pacific Rim International Conference
on Artificial Intelligence, pp. 637-645, 1996.
[26] H. Wu, Q. Chen, and M. Yachida, ―Facial Feature Extraction and Face
Verification, ―International Conference on Pattern Recognition, pp. 484-488,
1996.

Dept of CSE, BVCEC, Odalarevu 55

You might also like