Sample Report - Speed Estimation of Vehicles with Plate Detection (1)

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 44

Speed Estimation of Vehicles with Plate Detection

By
Aashish B.K. (20836/075)
Avni Ghimire (20847/075)
Kriteeka Adhikari (20851/075)

A project report submitted in partial fulfillment of the requirement for the degree
of Bachelor of Science (B.Sc.) Computer Science and Information Technology
Awarded by IOST, Tribhuvan University

Sagarmatha College of Science and Technology


(Under the affiliation of Tribhuvan University)
Sanepa, Lalitpur

May, 2023
Sagarmatha College of Science and Technology
Sanepa, Lalitpur
(T.U. Affiliate)

DISCLAIMER

We hereby declare that this project entitled “Speed Estimation of Vehicles with Plate Detection”
is based on our original research work. Related works on the topic, by other researchers, have been
duly acknowledged. We owe all the liabilities relating to the accuracy and authenticity of the data
or any other information included hereunder.

Aashish B.K. (20836/075)

Avni Ghimire (20847/075)

Kriteeka Adhikari (20851/075)

i
Sagarmatha College of Science and Technology
Sanepa, Lalitpur
(T.U. Affiliate)

Supervisor’s Recommendation

I hereby recommend that this project, prepared under my supervision by Aashish B.K., Avni
Ghimire, Kriteeka Adhikari entitled “Speed Estimation of Vehicles with Plate Detection” in
partial fulfillment of the requirements for the degree of B.Sc. in Computer Science and Information
Technology be processed for the evaluation.

..............................................

Manish Aryal
Associate Professor
Department CSIT

ii
Sagarmatha College of Science and Technology
Sanepa, Lalitpur
(T.U. Affiliate)

Certificate of Approval

This is to certify that this project prepared by Aashish B.K., Avni Ghimire, Kriteeka
Adhikari entitled “Speed Estimation of Vehicles with Plate Detection” in partial
fulfillment of the requirements for the degree of B.Sc. in Computer Science and
Information Technology has been well studied. In our opinion, it is satisfactory in the
scope and quality as a project for the required degree.

……………………………. …………………………….
Pratique Timalsena Manish Aryal
Program Coordinator Project Supervisor
Sagarmatha College of Science and Sagarmatha College of Science and
Technology Technology

…………………………….
Jagdish Bhatta
External Examiner
Central Department of Computer Science and Information Technology
Tribhuvan University

iii
Acknowledgement

We would like to express our gratitude and appreciation to all those who immensely provided us
with the guidance and assistance to complete our project. We would like to extend special gratitude
to our program coordinator Pratique Timalsena, for his guidance and patience during this project
and also for mentoring throughout all the brief encounters with the research and development
aspects of this project.

Furthermore, we would like to thank our project supervisor Er. Manish Aryal, Lecturer,
Department of Computer Science, Sagarmatha College of Science and Technology for providing
us valuable guidelines, supervision, and suggestions to successfully complete this project. The
success and final outcome of this project required a lot of guidance and assistance from many
people. We are fortunate to have got this all along with the completion of this project.

In the end, we would like to express our sincere thanks to all our friends and especially Mr. Arjun
Saud, Asst. Prof. CDCSIT who helped us directly or indirectly during this project.

iv
Abstract

Any kind of roadways, including off-roads, freeways, etc., require an efficient traffic management
system. Speed limit may vary from road to road, although several laws and speed controller has
been attached to the vehicles. The traffic management system still faces numerous obstacles on a
daily basis, even though a number of proposals have been identified. It remains an active area of
research. Different methods using computer vision and machine learning have been proposed for
object tracking. In this study, videos from security cameras are taken to identify and locate
automobiles and then retrieve the number plate of over speeding vehicles. The objective of the
current research is to identify the vehicles using computer vision techniques and detect them using
the Haar Cascade Classifier. Using machine learning to identify the cars and estimate their speeds
is a challenging but beneficial task. Convolutional Neural Networks (CNN) have been widely
employed in computer vision for the past several years for vehicle detection and identification.
Using dlib, this technique is able to track many objects simultaneously.

Keywords: Computer Vision, Haar Cascade Classifier, Vehicle Detection, dlib

v
Table of Contents

DISCLAIMER ............................................................................................................................ i
Supervisor’s Recommendation ................................................................................................... ii
Certificate of Approval.............................................................................................................. iii
Acknowledgement .................................................................................................................... iv
Abstract ......................................................................................................................................v
List of Figures ......................................................................................................................... viii
List of Tables ............................................................................................................................ ix
Abbreviations ..............................................................................................................................x
Chapter 1: Introduction ...............................................................................................................1
1.1 Introduction ..................................................................................................................1
1.2 Problem Statement ........................................................................................................1
1.3 Objectives .....................................................................................................................2
1.4 Scope and Limitation ....................................................................................................2
1.4.1 Scope ..........................................................................................................................2
1.4.2 Limitations ..................................................................................................................2
1.5 Development Methodology ...........................................................................................3
1.6 Report Organization ......................................................................................................5
Chapter 2: Background Study and Literature Review ..................................................................6
2.1 Background Study .............................................................................................................6
2.2 Literature Review ..............................................................................................................7
2.2.1 Vehicle speed classified by Haar cascade classifier ......................................................7
2.2.2 A HOG feature and SVM based method for forward vehicle detection ........................8
2.2.3 Vehicle detection using SVM and YOLO ....................................................................8
2.2.4 CNN-Based Method for Multi-Directional Car License Plate Detection ......................8
Chapter 3: System Analysis .........................................................................................................9
3.1 Requirement Analysis ........................................................................................................9
3.1.1 Functional Requirements .............................................................................................9
3.1.2 Non-Functional Requirements ................................................................................... 10
3.2 Feasibility Analysis ......................................................................................................... 11
3.2.1 Technical Feasibility ................................................................................................. 11

vi
3.2.2 Operational Feasibility .............................................................................................. 11
3.2.3 Economic Feasibility ................................................................................................. 11
3.2.4 Schedule Feasibility .................................................................................................. 11
3.3 Analysis ........................................................................................................................... 13
3.3.1 Data Flow Diagram ................................................................................................... 13
3.3.1.1 DFD Level 0 ....................................................................................................... 13
3.3.1.2 DFD Level 1 ....................................................................................................... 13
3.3.2 Sequence Diagram..................................................................................................... 14
3.3.3 Activity Diagram ....................................................................................................... 15
Chapter 4: System Design ......................................................................................................... 16
4.1 System Architecture ......................................................................................................... 16
4.2 Design ............................................................................................................................. 17
4.2.1 Component Diagram ................................................................................................. 17
4.3 Algorithm Details ............................................................................................................ 18
4.3.1 Haar Cascade Classifier ............................................................................................. 18
4.3.2 CCA algorithm .......................................................................................................... 20
Chapter 5: Implementation and Testing ..................................................................................... 21
5.1 Implementation ................................................................................................................ 21
5.1.1 Tools Used ................................................................................................................ 22
5.1.2 Implementation Details of Modules ........................................................................... 24
5.2 Testing ............................................................................................................................. 25
5.3 Result Analysis ................................................................................................................ 27
Chapter 6: Conclusion and Future Recommendations ................................................................ 28
6.1 Conclusion....................................................................................................................... 28
6.2 Future Recommendations................................................................................................. 28
References ................................................................................................................................ 29
APPENDIX .............................................................................................................................. 31

vii
List of Figures

Figure 1: Agile Model ................................................................................................................. 3


Figure 2: Use-case Diagram ...................................................................................................... 10
Figure 3: Gantt Chart ................................................................................................................ 12
Figure 4: DFD Level 0 .............................................................................................................. 13
Figure 5: DFD Level 1 .............................................................................................................. 13
Figure 6: Sequence Diagram ..................................................................................................... 14
Figure 7: Activity Diagram ....................................................................................................... 15
Figure 8: System Architecture ................................................................................................... 16
Figure 9: Component Diagram .................................................................................................. 17
Figure 10: Block Diagram of Haar Cascade Classifier ............................................................... 18
Figure 11: Flowchart of Haar cascade algorithm........................................................................ 24

viii
List of Tables

Table1: Task Schedule ................................................................................................................ 12


Table 2: Software used for System Implementation .................................................................... 21
Table 3: Hardware used for System Implementation ................................................................... 21
Table 4: Test Description ............................................................................................................ 26

ix
Abbreviations

SDLC Software Development Life Cycle


LPR License Plate Recognition
AI Artificial Intelligence
CNN Convolutional Neural Network
R-CNN Region-based Convolutional Neural Network
YOLO You Only Look Once
XML Extensible Markup Language
HTML Hypertext Markup Language
HOG Histogram of Oriented Gradients
SVM Support Vector Machine
DFD Data Flow Diagram
CCA Connected Component Analysis
OpenCV Open Source Computer Vision Library
VS Code Visual Studio Code
UML Unified Modeling Language
SysML Systems Modeling Language
BPMN Business Process Modeling Notation
ER Entity Relationship
ioS iPhone Operating System

x
Chapter 1: Introduction

1.1 Introduction
The number of automobiles worldwide has significantly increased in the recent years. With
the increase in the number of vehicles the number of accidents has been seen to have risen
significantly. One of the main causes of road accidents has been determined to be directly
related with over speeding among vehicles.[1] Road traffic accidents claim the lives of almost
1.3 million people every year throughout the world.[2]
Thus, being able to restrict vehicles from over speeding has been proven to reduce the overall
rate of road traffic accidents. For this purpose, there are numerous types of speed control
systems used in different parts of the world in order to estimate the vehicle speed as well as
detect the concerned license plate among public individuals through deployment of numerous
study-based vehicle speed estimation and license plate detection systems. However, there are
numerous limitations associated with these systems of approach specially in relation with their
level of accuracy. Using computer vision techniques and machine learning methods,
automobiles are detected, and then the object is tracked using dlib’s functions in this study.

1.2 Problem Statement


Number of ways are being implemented to check and identify the over speeding vehicle. But
no automatic system has been developed so far that can perform the task of speed detection
and vehicle identification without human assistance. The major issues seen at the present
context are:
• Road accidents are increasing day by day with prime cause being the over speeding of
the vehicles.
• The use of human resources to check this issue can be very tedious and time consuming
and sometimes become irrelevant.
• Near the commonly speeding areas, it’s harder to check if a vehicle is speeding and
difficult to read license plate number.

1
1.3 Objectives
The objective of this project is to develop a system that can identify vehicles traveling at
speeds beyond the designated limit and alert the appropriate authorities right away.
The main objectives are presented below:
• To develop a real system that detects over speed cars
• To recognize the number plate of over speed cars

1.4 Scope and Limitation


1.4.1 Scope
1. Traffic monitoring
2. Security purpose
3. Accident prevention
4. Vehicle tracking

1.4.2 Limitations
1. The dlib correlation tracker occasionally fails when the object's scale is constantly
changing.
2. The lengthy scanning and processing time make the estimated speed less reliable.
3. The license plate may occasionally be covered by dust, a front rod, or simply not
be present, making it impossible to read.
4. A high-resolution camera should be utilized to effectively detect license plates.
5. The accuracy of the system may be impacted by poor or inconsistent lighting since
vehicle plate detection is highly reliant on lighting conditions.

2
1.5 Development Methodology
The Agile approach is the most appropriate development methodology for our project. Agile
SDLC model is a combination of iterative and incremental process models with focus on
process adaptability and customer satisfaction by rapid delivery of working software product.
The product is divided into smaller incremental builds using agile methods. Iterations of these
builds are supplied. Usually, an iteration lasts between one to three weeks. Cross-functional
teams work simultaneously on several areas during each iteration, including-
• Planning
• Requirement Analysis
• Design
• Building
• Testing

Figure 1: Agile Model

3
Planning and Requirement Analysis
This stage involves analyzing and documenting the software development requirements. In
our case, the system should detect vehicle, predict speed and identify plate numbers.

Designing
Here, the system architecture is designed so that it resembles how the system appears to the
user.

Building
The development process begins after gathering all the requirements and designing the model.
In every development phase small prototype of the system is developed and analyzed by the
user. In our system, small prototype is made that simply detects the vehicle. Moreover, the
system will be developed to estimate speed of vehicles and identify number plates.

Testing
In this phase, the developed prototype is examined to see if it satisfies with the requirements
as identified in the requirement analysis. Here, the system is repeatedly examined to see if it
accurately identifies the vehicles or not. Additionally, the system is checked to see if it extracts
the correct features from the number plate and if there are any problems with processing.
Finally, at the end of iteration, a working and usable product is presented to the client and
other key shareholders. The system is then used to determine the vehicle's speed, locate the
number plate on the moving vehicle, and extract numbers of over speeding vehicles.

4
1.6 Report Organization

Altogether this project is organized into six different chapters, each representing different
development phases of the project. The chapters can be discussed briefly as follows:

Chapter 1: It deals with the introductory part of the project and explains what the project is about,
how it came into being, the main objectives of the project that is planned to be achieved after the
completion, its scope, and limitations.

Chapter 2: This chapter is all about the research process carried out to do the project. It consists of
the background idea for the project and a literature review of the project.

Chapter 3: It includes functional, non-functional requirements, different types of feasibility


analysis (technical, operational, economical, schedule), and a structured approach to the project.

Chapter 4: It deals with the designing phase and which algorithms are used to develop the system.

Chapter 5: It is all about the implementation and testing of this system. Various tools are used for
implementation and testing is carried out using various test cases.

Chapter 6: Finally, this chapter is about the conclusion and future enhancement which contains an
idea about what was achieved at the end of the project.

5
Chapter 2: Background Study and Literature Review

2.1 Background Study

In the 1960s, researchers started creating computer vision algorithms to identify and categorize
items in images. The ability to detect and track objects more quickly and accurately than ever
before is made possible by ongoing technological advancements like multi-sensor fusion and real-
time processing. In 1976, License Plate Recognition (LPR) technology was invented at the Police
Scientific Development Branch in the United Kingdom. It now plays a crucial role in intelligent
transportation systems and has several applications in traffic control, smart parking, and law
enforcement.[3]

2.1.1 Machine Learning

Machine learning is an area of artificial intelligence (AI) that focuses on creating statistical models
and algorithms that enable computer systems to learn from data without being explicitly
programmed. It enables computers to improve their performance on a task by learning from
examples, patterns, and experience, rather than by following a fixed set of rules. Machine learning
algorithms are created to learn from a set of labeled data (training set) and then apply that learning
to new, unlabeled data (test set).

2.1.2 Object Detection

Object detection is a computer vision technique that enables us to detect and locate objects within
an image or a video stream. With this kind of localization and identification, object detection can
be used to count the objects in a scene, as well as to locate and track them in real time while
accurately labeling them. Popular algorithms used to perform object detection include
convolutional neural networks (R-CNN, Region-Based Convolutional Neural Networks), Fast R-
CNN, Haar Cascade and YOLO (You Only Look Once).[4]

6
2.1.3 Batch File

On Microsoft Windows operating systems, tasks can be automated using script files called batch
files. It contains a series of commands that are executed sequentially when the batch file is run.
".bat" or ".cmd" are the file extensions for batch files. Any text editor, such Visual Studio Code or
Notepad, can be used to create batch files. They are used for the automation of repetitive processes,
including file backups, software installations, and maintenance of the system. Batch files can also
be used to automate complex command chains and to simplify administrative tasks.[5]

2.1.4 XML File

An XML (Extensible Markup Language) file is a text-based file format that is used for storing and
transmitting structured data. There are series of elements in XML files, each of which has a name
and a value. While XML and HTML share a similar syntax, XML is not predefined and allows for
customization to meet particular requirements.[6] The trained Haar cascade classifiers are stored
in XML files. In Haar cascade classifier, once the algorithm has been trained, it generates a set of
rules for detecting the object of interest in new images. These rules are stored in an XML file and
can be loaded and used to detect the object in new images.

2.2 Literature Review


This section provides a summary of the research done on identification of license plates and vehicle
speed estimation. Few of many research papers based on speed estimation and license plate
detection are mentioned below.

2.2.1 Vehicle speed classified by Haar cascade classifier


In [7], Haar cascade classifier was investigated by authors like d. bhargava, kritika; goyal et al for
the detection system which incorporates Haar features, integral image, AdaBoost learning and
cascade classifier. Python OpenCV library was used to implement the system and evaluated on
road traffic video collected in one-way traffic. The proposed method yields 97.92% of accuracy in
vehicle detection done in daylight.

7
2.2.2 A HOG feature and SVM based method for forward vehicle detection
In [8], HOG feature and SVM Based method was proposed for forward vehicle detection by Li,
X., & Guo et al, 2013 focusing on improving the performance of vehicle detection system with
single camera. Shadow underneath a vehicle is the most significant feature that can be used to
detect vehicle at daytime. Histogram analysis method was used to segment the shadow accurately.
A vehicle classifier based on the histogram of gradient and support vector machine was used to
further verify the initial candidates, which were created by merging the horizontal and vertical
edge features of the shadow.

The experimental results demonstrate the suggested method's strong ability to adapt to various
lighting conditions, with a detection rate of 96.87 percent and a false rate of 2.77 percent in
conditions of normal light.

2.2.3 Vehicle detection using SVM and YOLO


In [9], it is stated that YOLO is significantly more desirable due to its strength vs SVM's
weaknesses: better detection, more consistent bounding box location, and real-time processing
speed, close to 40 fps, according to Kaspar Sakmann et al's 2017 study.

2.2.4 CNN-Based Method for Multi-Directional Car License Plate Detection


In [10], Xie et al 2018 developed a novel convolutional neural network (CNN)-based technique
for high-accuracy real-time license plate detection in this research. Many contemporary methods
for detecting license plates on moving vehicles only work well under certain circumstances or
under very strong assumptions. However, when the assessed car license plate images have some
rotation due to manual capture by traffic police or camera deviation, they perform poorly.
Therefore, the CNN-based MD-YOLO framework is proposed for multi-directional car license
plate detection. The proposed solution may elegantly handle rotational issues in real-time
applications by accurately predicting the rotation angle and using a quick intersection-over-union
evaluation strategy. The proposed method surpasses other current state-of-the-art methods in terms
of greater accuracy and cheaper computational cost, according to a number of trials conducted to
support this claim.

8
Chapter 3: System Analysis

3.1 Requirement Analysis


Requirement analysis involves determining the technology's goal, compiling user needs,
specifying system capabilities, prioritizing requirements, and identifying potential difficulties.
This makes it easier to make sure the technology is customized to meet the goals and requirements
that have been set and is reliable, effective, and efficient in a variety of applications.

3.1.1 Functional Requirements


Functional requirements refer to the specific functionalities or tasks that a system or technology
must perform in order to satisfy the needs and requirements of its users. Functional requirements
of this system are:

1. It should have the ability to recognize and read license plate numbers clearly in different
lighting and weather conditions.
2. It should be able to evaluate images quickly and produce results in just a few seconds.
3. It should be able to accurately detect multiple vehicles.
4. The system must be capable of recognizing and processing multiple license plates
simultaneously.
5. The system must be able to safely and efficiently store the collected license plate data for
later use.

9
Figure 2: Use-case Diagram

3.1.2 Non-Functional Requirements


The features or attributes of the system that can determine its performance are known as non-
functional requirements. Non-functional requirements of this system are:

1. Accuracy and Precision:


The system should perform its process accurately and precisely to avoid issues
2. Security:
The system should be secure and maintain the privacy of the faulty drivers.
3. Usability:
The system should be simple to understand and easy to deal with.
4. Scalability:
Large data volumes should not be a problem for the system, and it should be simple to scale
up or down to meet demand variations.
5. Maintainability:
6. Clear documentation and user support should be provided, and the system should be simple
to upgrade.

10
3.2 Feasibility Analysis
Feasibility analysis is an assessment of practicality and suitability of a purposed project or a
system. The main goal of the feasibility study is not only to solve the problems but to achieve the
scope of our project. It aims to uncover the strengths and weaknesses to determine whether the
project is viable, feasible and worth pursuing. Thus, a feasibility analysis evaluates the potential
for success of the project.

3.2.1 Technical Feasibility


The technical feasibility of a project refers to whether or not it can be implemented successfully
using the available technology and resources. The project uses widely used and proven algorithms
for vehicle detection and number plate identification therefore, this project is technically feasible.

3.2.2 Operational Feasibility


The system can be easily operated on various systems. Proper documentation will be included
alongside the system therefore, the project becomes operationally feasible.

3.2.3 Economic Feasibility


The project is economically feasible as it does not require too many resources for development
and testing.

3.2.4 Schedule Feasibility


We have a proper schedule and enough time to complete this project in time. So, this project is
schedule feasible.

11
Table1: Task Schedule

SN Task Name Start Date End Date


1 Planning 12/15/2022 1/15/2023
2 Study and Analysis 1/1/2023 2/15/2023
3 Coding and Implementation 2/15/2023 5/10/2023
4 Testing 3/15/2023 5/12/2023
5 Documentation 4/15/2023 5/15/2023

The above table displays the project's timetable, demonstrating that our project is also time-
feasible.

The Gantt Chart of this duration is mentioned below:

Figure 3: Gantt Chart

12
3.3 Analysis
3.3.1 Data Flow Diagram
3.3.1.1 DFD Level 0

Figure 4: DFD Level 0


In the zero level DFD of this project, admin can provide a video to the system and finally, the
system displays speed and number plate of vehicles as an output.

3.3.1.2 DFD Level 1

Figure 5: DFD Level 1


The above figure i.e. first level DFD of this project illustrates that the admin can provide video to
the Vehicle Detection System. The Speed Estimation System takes input in the form of coordinates
of the tracked vehicles and produces speed of each detected vehicles in the video as output. After
13
that the Number Plate Recognition System takes input in the form of cropped image of over
speeding vehicles and gives the number plate of such vehicles as output.

3.3.2 Sequence Diagram

Figure 6: Sequence Diagram

14
3.3.3 Activity Diagram

Figure 3- SEQ Figure_3- \* ARABIC 6:


Activity Diagram

Figure 7: Activity Diagram

15
Chapter 4: System Design

4.1 System Architecture

Figure 8: System Architecture

16
Speed Estimation with plate detection system is developed with the objective to identify overspeed
vehicles, using Deep Learning and Machine Learning Algorithms. After acquisition of series of
images from the video, vehicles are detected using Haar Cascade Classifier. This is followed by
tracking down the vehicles and estimating their speeds with the help of their respective locations,
ppm (pixels per meter) and fps (frames per second). Now, the cropped images of the identified
trucks are sent for License Plate detection. The CCA algorithm assists in Number Plate detection.
After recognition, the license plate of overspeed vehicles are displayed.

4.2 Design
4.2.1 Component Diagram

Figure 9: Component Diagram

Figure 4- SEQ Figure_4- \* ARABIC 2:


Component Diagram 17
4.3 Algorithm Details
4.3.1 Haar Cascade Classifier

Figure 10: Block Diagram of Haar Cascade Classifier

Steps:

1. Positive image and negative image:


Images containing car are positive images whereas other images are negative images.
2. Train Cascade Classifier:
There are total 6 training steps to create a Haar-like Classifier. They are:
i. Collecting image dataset:
We have used several positive and negative image samples for training. A classifier
will be more accurate if there are more positive and negative (background) images.
ii. Arranging negative images
From the negative file folder, the batch file is executed to get a text file in.jpg
format. This negative data file is necessary for the classifier's training.
iii. Crop and mark positive images
We create a data file (vector file) in this phase that includes the names of the
positive images as well as the locations of the objects in each image. We can create
this file via two utilities: Objectmarker or Image Clipper.
iv. Creating a vector of positive images
There is a batch file which loads info.txt and packs the car images into a vector file
and after running the batch file, we get the file carvector.vec.

18
v. Haar-Training
For each stage, Harrtraining.exe collects a new set of negative samples.
Additionally, non-neg sets a limit on the set's size. Which of the "candidate
samples" are incorrectly classified is determined using the data from the earlier
stages. When the ratio of incorrectly identified samples to candidate samples falls
below 500, training is complete.
vi. Creating the XML file:
We have to create our own XML file where we need to train Cascade Classifier
only once. Once the XML file is created, we need to compare it with real image for
vehicle detection.[11]

3. Pre-Processing:
For accuracy, the XML file should be in grayscale when compared to the real image in
order to obtain the desired results. Therefore, the pre-processing operation covers the XML
file in grey scale.

Speed Estimation:

We calculate the average vehicle speed on road by analyzing video. First, a video frame was taken,
and then the digital width of the road in pixels was determined. Secondly, we have taken the actual
road width in meters from the real world. To map the distances between these two worlds, we have
calculated pixels per meter by dividing distance of road in pixels to meters. The vehicle's pixel
distance in one frame of our video processing is indicated by the value of d_pixels. We need to
convert d_pixels to d_meters first in order to estimate speed in any standard unit. d_meters is the
distance travelled in one frame. We have already calculated the average fps during video
processing, where frame per seconds (fps) is the number of rendered frames it takes for the vehicles
to move from the start location to the end location.

To get the speed in m/s, just (d_metres * fps) was done. The estimated speed was multiplied by
3.6 to convert it into km/hr. Therefore, the speed calculation formula is mentioned below:

Speed (in km/hr) = Distance Travelled by the detected cars (in meters) * fps * 3.6 [12]

19
4.3.2 CCA algorithm
As an algorithmic application of graph theory, CCA for detecting License Plate and segmenting
connected component labeling assigns unique labels to subsets of connected components. In
computer vision, connected component labeling is used to detect connected areas in binary digital
images.

Relevant input data is used to create a graph with vertices and connecting edges. The edges indicate
related "neighbors," whereas the vertices carry information needed by the comparison heuristic.
Based on the connectivity and relative values of their neighbors, an algorithm traverses over the
graph, labeling the vertices as it goes. Connectivity is determined by the medium; image graphs,
for example, can be 4-connected or 8-connected.

Assumptions made: Width of the license plate region to the full image ranges between 15% and
40% and height of the license plate region to the full image is between 8% & 20%.

20
Chapter 5: Implementation and Testing

5.1 Implementation
We require different resources to implement the speed estimation and plate detection system
effectively. Various hardware and software have been used in this project. All the resources used
for implementation are included in the table below:

Software used for system implementation:

Table 2: Software used for System Implementation

Software Description

VS code Used as lightweight source code editor for


Python during development and testing
Windows 10 and 11 To operate the system

Hardware used for the system implementation:

Table 3: Hardware used for System Implementation

Hardware Description

Personal computer with 8 GB RAM and 1 TB For development and testing


hard disk space

iPhone 12 pro with 12-megapixel triple lens For recording video of moving vehicles
camera

21
5.1.1 Tools Used
a) Python
Python is a high-level, interpreted programming language that is employed for a variety of
tasks, including data analysis, scientific computing, web development, and artificial
intelligence. Python is known for its simplicity, readability, and ease of use. It is an object-
oriented language that is known for having an extensive library of modules that offer a
variety of functionality, from processing data to producing graphical user interfaces.
NumPy, pandas, matplotlib, TensorFlow are some of the libraries written in python
language.
b) OpenCV
OpenCV is a well-known open source computer vision and machine learning library
written in C++ and python. For processing images and videos, OpenCV offers a wide range
of algorithms and functions, including feature extraction, object detection, face
recognition, motion detection, and many others. Additionally, it includes tools for stereo
vision, 3D reconstruction, and camera calibration. OpenCV supports multiple
programming languages, including C++, Python, and Java, and it is available on multiple
platforms, including Windows, Linux, and macOS.

c) Visual Studio Code


Visual Studio Code (VS Code) is a source code editor developed by Microsoft for
Windows, Linux, and macOS. It includes support for debugging, embedded Git control
and GitHub, syntax highlighting, intelligent code completion, snippets, and code
refactoring. One of VS Code's key benefits is its extensive library of extensions, which let
users adapt the editor to their particular requirements. There are several extensions
available for various programming languages and frameworks, ranging from simple
utilities to more sophisticated tools.

22
d) Kaggle

Kaggle, a subsidiary of Google LLC, is an online community of data scientists and machine
learning practitioners. Users can discover and share data sets on Kaggle, study and develop
models in a web-based data science environment, collaborate with other data scientists and
machine learning experts, and participate in competitions to address data science
challenges.

We have used vehicle detection image set from Kaggle to train our Cascade Classifier to
detect vehicles. Two labels of the image set are Non-vehicles and Vehicles.

e) Draw.io
Draw.io is a UML CASE Tool supporting UML 2, SysML, and Business Process Modeling
Notation (BPMN) from the Object Management Group. It is free, open-source online
diagramming and flowchart tool. Flowcharts, block diagrams, ER diagrams, DFD can be
made using this tool.

f) Microsoft Office
Microsoft Office is a collection of productivity programs developed by Microsoft
for Windows, macOS, iOS, and Android operating systems. A variety of word processing,
spreadsheet management, presentation building, email and calendaring, note-taking, and
other tools are included in the suite. The most popular applications in Microsoft Office
include Microsoft Word, Microsoft Excel, Microsoft PowerPoint etc.

23
5.1.2 Implementation Details of Modules

5.1.2.1 Haar Cascade Classifier


Haar Cascade is an algorithm used in machine learning to detect particular items in pictures or
movies, such as faces or vehicles. It is trained on positive and negative images to identify the
visual characteristics of the object.

Working mechanism:

Figure 11: Flowchart of Haar cascade algorithm

The Haar cascade algorithm is a useful method for finding moving objects in video. To begin, it
chooses Haar-like features, that capture patterns of intensity change in the image. The
computation of an integral image using these characteristics enables effective feature
computation. The system chooses the most useful features for vehicle detection by using the
machine learning technique Adaboost. These characteristics are arranged into a series of
classifiers that can differentiate between positive and negative samples. The method uses a
sliding window technique to detect automobiles, moving a window with a certain size across the
image at various scales and positions.

24
5.1.2.2 CCA Algorithm
Using connected component analysis, we can detect license plates of moving objects.

Working Mechanism:

The working mechanism of connected component analysis for number plate detection involves the
following steps:

1. Image Preprocessing: To highlight the regions of interest, the input image is preprocessed.
2. Binarization: After preprocessing, the image is transformed into a binary image. By doing
so, the foreground is separated from the background.
3. Connected Component Labeling: In this stage, connected areas or parts of the binary image
are identified. To distinguish it from other components, each pixel in a connected
component is given a label.
4. Filtering and Analysis: To find suitable number plate locations, the labeled components
can be filtered depending on a number of factors. We have used size filtering (removing
components that are too small or too large) in this system.

5.2 Testing
In order to detect errors in our program, testing was done. This method helps to improve the
application's quality while minimizing maintenance expenses, maximizing output, and cutting
down on development and maintenance time. Application testing guarantees the correct
operation of a specific program or application.

In this iterative process, we assessed the performance of the product by evaluating our
application to find discrepancies between actual output and predicted output with specific inputs.
To make it best comply to the criteria and be bug-free, it was done in both the development
process and the actual operational environment. The table below lists the numerous test scenarios
and their details:

25
Table 4: Test Description

Test ID Actual Speed Predicted Speed Difference


(km/hr) (km/hr)
T1 7 7 0

T2 5 5 0

T3 4 4 0

T4 10 10 0

T5 15 15 0

T6 20 20 0

T7 68 63 5

T8 20 12 8

T9 4 4 0

T10 15 15 0

T11 35 30 5

T12 10 10 0

T13 60 60 0

26
T14 53 72 19

T15 62 62 0

To calculate the accuracy of predicted speeds compared to actual speeds, we use the following
formula:

Accuracy = (Number of correctly predicted speeds) / (Total number of samples) * 100

Therefore, the accuracy of the system is found to be 73.33%.

5.3 Result Analysis


We have conducted several manual tests and system tests on our system, which yielded an
accuracy of 73.33%. However, our system is producing mixed results due to various factors such
as video resolution, lighting conditions, and processing capability. To improve this, we can
utilize a high-resolution camera and a hardware system with enhanced processing capability.

27
Chapter 6: Conclusion and Future Recommendations

6.1 Conclusion
The project “Speed estimation of vehicles with plate detection system” combines the abilities of
speed estimation and number plate recognition to improve road safety and enforce traffic laws.
This technology offers useful data for monitoring and regulating traffic flow, enforcing speed
restrictions, and identifying vehicles involved in potential violations by precisely determining the
speed of vehicles and detecting their number plates. The project involves processing video data
and extracting appropriate information from images of vehicles using computer vision techniques
and machine learning algorithms. Vehicle identification and tracking are made possible by the
number plate detection system, which concurrently reads and recognizes license plates.

6.2 Future Recommendations


The speed estimation of vehicles with a plate detection system is based on various machine
learning models. ML models provide accurate results when trained with more data. They can be
retrained with additional data in the future to improve accuracy further. Future efforts should focus
on enhancing the precision and real-time processing capabilities of the speed estimation and plate
detection system. Exploring more advanced techniques and algorithms can increase precision and
reliability.

In the near future, this system can be implemented using mobile applications. Privacy and data
security should be given priority to ensure the system's effectiveness. User feedback can be
actively encouraged to facilitate continuous improvement. By implementing these
recommendations, the project can evolve into a more accurate, efficient, and seamlessly integrated
system, contributing to safer roads and effective traffic management.

28
References

[1] A. Gaur, A. Vats, A. Raturi, “Automatic Vehicle Plate Recognition And Over Speed Detection
Using Machine Learning,” Journal of Emerging Technologies and Innovative Research, vol. 9,
issue 5, pp. 290-301, May 2022.

[2] WHO. (2022, June. 20). Road traffic injuries [Online]. Available: https://www.who.int/news-
room/fact-sheets/detail/road-traffic-injuries

[3] S. Gautam. (2019, Feb. 5). The Evolution License Plate Recognition Technology [Online].
Available: https://blog.getmyparking.com/2019/02/05/the-evolution-of-license-plate-recognition-
technology/

[4] FRITZ AI. (2021). OBJECT DETECTION GUIDE [Online]. Available:


https://www.fritz.ai/object-
detection/#:~:text=Object%20detection%20is%20a%20computer,all%20while%20accurately%2
0labeling%20them.

[5] GeeksforGeeks. (2022, Sep. 29). Writing a Windows batch script [Online]. Available:
https://www.geeksforgeeks.org/writing-windows-batch-script/

[6] Indeed Editorial Team. (2023, March. 16). What is an XML File? (Definition, Benefits and
How To Open) [Online]. Available: https://www.indeed.com/career-advice/career-
development/xml-file

[7] d. bhargava, kritika; goyal, “a video surveillance system for speed detection of vehicles and
law enforcement using automatic number plate recognition,” international journal of research in
computer engineering and electronics, vol. 3, no. 3, 2014.

[8] Li, X., & Guo, X. (2013). A HOG Feature and SVM Based Method for Forward Vehicle
Detection with Single Camera. 2013 5th International Conference on Intelligent Human-Machine
Systems and Cybernetics. doi:10.1109/ihmsc.2013.69

[9] Kaspar Sakmann. (2017). Vehicle-detection-and-tracking-using-hog-features-svm-vs-yolo


73e1ccb35866

29
[10] Xie, L., Ahmad, T., Jin, L., Liu, Y., & Zhang, S. (2018). A New CNN-Based Method for
Multi-Directional Car License Plate Detection. IEEE Transactions on Intelligent Transportation
Systems, 19(2), 507–517.

[11] M. Rezaei. (n.d.). “Creating a Cascade of Haar-Like Classifiers: Step by Step”. Available:
https://www.cs.auckland.ac.nz/~m.rezaei/Tutorials/Creating_a_Cascade_of_Haar-
Like_Classifiers_Step_by_Step.pdf

[12] P. D. Mahalakshmi, D. M. Babu, “Vehicle Speed Estimation using Haar Classifier


Algorithm,” International Journal of Trend in Scientific Research and Development, vol. 4, no. 1,
pp. 243-246, Dec 2019.

30
APPENDIX

1. Car Detection

2. Estimation of speed

31
3. Cropped image of overspeed car

4. Grey image and binary image of the car

32
5. Number plate detection

33

You might also like