B.tech It Batchno 44
B.tech It Batchno 44
Information Technology
By
SATHYABAMA
INSTITUTE OF SCIENCE AND TECHNOLOGY
(DEEMED TO BE UNIVERSITY)
Accredited with Grade “A” by NAAC
MARCH 2021
i
SATHYABAMA
INSTITUTE OF SCIENCE AND TECHNOLOGY
(DEEMED TO BE UNIVERSITY)
Accredited with “A” grade by NAAC
Jeppiaar Nagar, Rajiv Gandhi Salai,
Chennai – 600 119
www.sathyabama.ac.in
BONAFIDE CERTIFICATE
This is to certify that this Project Report is the bonafide work of Dinesh Kumar A
(Reg.No 37120087) and Logeswaran R (37120042) who carried out the project
entitled “Vehicle Number Plate Detection System For Indian Vehicles using
OCR” under my supervision from November 2020 to March 2021.
Internal Guide
Dr.P.SARAVANAN M.E.,Ph.D.,
ii
DECLARATION
hereby declare that the Project Report entitled “Vehicle Number Plate
Detection System For Indian Vehicles using OCR” done by us under the
Technology.
DATE:
PLACE: CHENNAI SIGNATURE OF THE CANDIDATE
iii
ACKNOWLEDGEMENT
iv
ABSTRACT
v
TABLE OF CONTENTS
ABSTRACT
LIST OF FIGURES
LIST OF ABBREVIATIONS
1 INTRODUCTION 1
1.1 OVERVIEW 1
2 AIM AND SCOPE 2
2.1 AIM 2
2.2 SCOPE 2
2.2.1 FUNDAMENTAL STEPS IN OCR 3
3 LITERATURE REVIEW 3
3.1 REVIEW OF LITERATURE 3
4 METHODOLOGY 10
4.1 SYSTEM ANALYSIS 10
4.1.1 EXISTING SYSTEM 11
4.1.2 PROPOSED SYSTEM 12
4.1.3 LANGUAGES USED IN THE SYSTEM 12
4.1.3.1 ABOUT PYTHON LANGUAGE 13
4.2 SYSTEM REQUIRMENTS 14
4.2.1 HARDWARE REQUIREMENTS 15
4.2.2 SOFTWARE REQUIREMENTS 16
4.2.2.1 CODING LANGUAGES 16
4.3 METHODOLOGY 17
4.3.1 SYSTEM ARCHITECTURE 17
4.3.2 MODULES 18
4.3.2.1 DATA PRE-PROCESSING 18
4.3.2.2 FEATURE SELECTION 19
4.3.2.3 BUILDING AND TRAINING MODEL 20
4.3.2.4 NUMBER PLATE EXTRACTION 21
4.3.2.5 CHARACTER SEGMENTATION 23
vi
4.3.2.6 OPTICAL CHARACTER 24
RECOGNITION
4.3.2.7 TEMPLATE MATCHING 25
4.3.3 UML DIAGRAMS 25
4.3.3.1 USECASE DIAGRAM 26
4.3.3.2 SEQUENCE DIAGRAM 26
4.3.3.3 ACTIVITY DIAGRAM 27
4.4 TESTING 27
4.4.1 SOFTWARE TESTING 28
4.4.2 TEST CASE 28
4.4.3 TESTING TECHNIQUES 28
5 CONCLUSION 29
5.1 CONCLUSION 29
5.2 FUTURE WORK 30
REFERENCES 30
APPENDICES 31
SAMPLE CODE 32
vii
LIST OF FIGURES
viii
LIST OF ABBREVIATIONS
ix
CHAPTER 1
I
x
INTODUCTION
1.1 OVERVIEW
Number Plate recognition plays an important role in various applications such as
traffic monitoring on road, automatic toll payment, parking lots access control,
detection of stolen vehicles. To identify a car number plate is effective because of its
uniqueness of the car. Real time number plate recognition plays an important role in
automatic monitoring of traffic rules. The recognition of car number plate can be
used for automatic car parking because each car has its own identification number.
The camera is used to capture the image automatically and can be used for many
application such as automatic toll plaza and car parking.
1
CHAPTER 2
AIM AND SCOPE
2.1 AIM
For the standard number plates the automatic number plate recognition becomes
very easy to read and recognizes the character. In India the vehicle number plates
has no standard size and font so it become very difficult to read and recognize the
characters of the number plate. So we are using machine learning algorithm to solve
this problem.
2.2 SCOPE
This is based on various operation such as image enhancement,
morphological transformation, edge detection and extraction of number plate from
vehicle image. After this segmentation is applied to recognize the characters
present on number plate using template matching. This algorithm can recognize
number plate quickly and accurately from the vehicles image.
2
CHAPTER 3
LITERATURE REVIEW
3
recognition technology using SVM alone, we get a 3.6% improvement in
recognition rate.
4
5.Automatic car number plate recognition
Authors: Anumol Sasi ; Swapnil Sharma ; Alice N. Cheeran, 2017
A traffic surveillance system includes detection of vehicles which involves the
detection and identification of license plate numbers. This paper proposes an
intelligent approach of detecting vehicular number plates automatically using three
efficient algorithms namely Ant colony optimization (ACO) used in plate localization
for identifying the edges, a character segmentation and extraction algorithm and a
hierarchical combined classification method based on inductive learning and SVM
for individual character recognition. Initially the performance of the Ant Colony
Optimization algorithm is compared with the existing algorithms for edge detection
namely Canny, Prewitt, Roberts, Mexican Hat and Sobel operators. The Ant Colony
Optimization used in communication systems has certain limitations when used in
edge detection like random initial ant position in the image and the heuristic
information being highly dictated by transition probabilities. In this paper,
modifications like assigning a well-defined initial ant position and making use of
weights to calculate heuristic value which will provide additional information about
transition probabilities are used to overcome the limitations.
5
proposed, and good results are obtained. The detection rate is improved by about
20 points in percent as compared to the fixed case. It achieves the best
performance among the conventional fixed threshold method, Otsu's method, and
the conventional method of JavaANPR.
6
recognition of license plate of Bangladesh by using image processing's and
machine learning model. This algorithm executes in three steps: detection of the
plate with shape verification, tilt correction and recognition of the number. For
detection, RGB color space, median filtering, binarization, morphological analysis,
region properties for filtering are applied. To discard noisy object, shape verification
is done through robust distances to borders vectors. Before character
segmentation, horizontal tilt correction is applied.
7
dilation morphology and scoring based on the height-width ratio and the number of
connected components in the region. The candidate region images are classified in
two classes, namely number plate and outlier images. As image feature extractor,
pre-trained CNN (convolutional neural network) is used and as classifier, SVM
(support vector machine) is used. The algorithm was implemented by programming
language C++ in morphological image processing and MATLAB in pre-trained CNN
and SVM parts. The paper shows experimental verification of the algorithm and test
results for 126 car images.
8
CHAPTER 4
METHODOLOGY
4.1 SYSTEM ANALYSIS
4.1.1 Existing System
In previous we used that project in matlab with hardware connection.but now we
use no hardware only software.we use only python code & some libraries. The
drowsiness detection system is built using MATLAB and Viola Jones Algorithm.
Limitations
1. It is cost of License. Its very costly user has to buy each and every module and
pay for it.
3. Its very difficult or requires deep devel Matlab knowledge to deal with all errors.
Advantages of OCR
1. Higher Productivity
OCR software helps businesses to achieve higher productivity by facilitating
quicker data retrieval when required.
2. Cost Reduction
Opting for OCR will help businesses on cutting down on hiring professionals to
9
carry out data extraction, which is one of the most important benefits of OCR data
entry methods.
3. High Accuracy
One of the major challenges of data entry is inaccuracy. Automated data entry tools
such as OCR data entry result in reduced errors and inaccuracies, resulting in
efficient data entry.
FEASIBILITY STUDY
The feasibility of the project is analyzed in this phase and business proposal is
put forth with a very general plan for the project and some cost estimates. During
system analysis the feasibility study of the proposed system is to be carried out.
This is to ensure that the proposed system is not a burden to the company. For
feasibility analysis, some understanding of the major requirements for the system is
essential.Three key considerations involved in the feasibility analysis are
1. Economic feasibility
2. Technical feasibility
3. Social feasibility
ECONOMICAL FEASIBILITY
This study is carried out to check the economic impact that the system will have
on the organization. The amount of fund that the company can pour into the
research and development of the system is limited. The expenditures must be
justified. Thus the developed system as well within the budget and this was
achieved because most of the technologies used are freely available. Only the
customized products had to be purchased.
TECHNICAL FEASIBILITY
This study is carried out to check the technical feasibility, that is, the technical
requirements of the system. Any system developed must not have a high demand
10
on the available technical resources. This will lead to high demands being placed
on the client. A feasibility study evaluates the project’s potential for success.
SOCIAL FEASIBILITY
The aspect of study is to check the level of acceptance of the system by the
user. This includes the process of training the user to use the system efficiently.
The user must not feel threatened by the system, instead must accept it as a
necessity. The level of acceptance by the users solely depends on the methods
that are employed to educate the user about the system and to make him familiar
with it. His level of confidence must be raised so that he is also able to make some
constructive criticism, which is welcomed, as he is the final user of the system.
11
➢ It includes the basic text manipulation facilities of Perl and Awk
➢ A module in Python may have one or more classes and free functions
12
Good Language to Teach Programming
Python is used by many companies to teach programming to kids and newbies.
It is a good language with a lot of features and capabilities. Yet, it's one of the
easiest language to learn because of its simple easy-to-use syntax.
Importing tkinter is same as importing any other module in the Python code. Note
that the name of the module in Python 2.x is ‘Tkinter’ and in Python 3.x it is ‘tkinter’.
tkinter also offers access to the geometric configuration of the widgets which can
organize the widgets in the parent windows. There are mainly three geometry
manager classes class.
✓ pack() method:It organizes the widgets in blocks before placing in the parent
widget.
13
About Opencv Package
And the support of Numpy makes the task more easier. Numpy is a highly
optimized library for numerical operations. It gives a MATLAB-style syntax. All the
OpenCV array structures are converted to-and-from Numpy arrays. So whatever
operations you can do in Numpy, you can combine it with OpenCV, which
increases number of weapons in your arsenal. Besides that, several other libraries
like SciPy, Matplotlib which supports Numpy can be used with this.
So OpenCV-Python is an appropriate tool for fast prototyping of computer vision
problems.
14
System : Pentium IV 2.4 GHz
Hard Disk : 1TB
Floppy Drive : 1.44 Mb
Monitor : 15 VGA Colour
Mouse : Logitech
Ram : 8Gb
Do not need to compile program before executing it. This is similar to PERL
and PHP.
15
Features
➢ Easy-to-learn − Python has few keywords, simple structure, and a clearly
defined syntax. This allows the student to pick up the language quickly.
➢ Easy-to-read − Python code is more clearly defined and visible to the eyes.
➢ A broad standard library − Python's bulk of the library is very portable and
cross-platform compatible on UNIX, Windows, and Macintosh.
➢ Portable − Python can run on a wide variety of hardware platforms and has
the same interface on all platforms.
16
4.3 METHODOLOGY
4.3.1 SYSTEM ARCHITECTURE
The projected system is to observe every character from range plate one by one.
This could be done by morphological operation. It includes a way to section all the
characters employed in the quantity plate. Range plate extraction is that stage
wherever vehicle range plate is detected. The detected range plate is
pre-processed to get rid of the noise then the results passed to the section half to
17
segment the one by one character from the extracted range plate. The divided
characters normalized associate degreed passed to an OCR formula. Ultimately
the optical character info is going to be regenerate into encoded text. The
characters recognized exploitation template matching. The ultimate output should
be within the type of string of characters.
4.3.2 MODULES
4.3.2.1 Data Pre-Processing
The entries are present in the dataset. The null values are removed using df =
df.dropna() where df is the data frame. The categorical attributes
(Date,High,Low,Close,Adj value) are converted into numeric using Label Encoder.
The date attribute is splitted into new attributes like total which can be used as
feature for the model.
1.DataCleaning:
The data can have many irrelevant and missing parts. To handle this part, data
cleaning is done. It involves handling of missing data, noisy data etc.
2.DataTransformation:
This step is taken in order to transform the data in appropriate forms suitable for
mining process.
3.DataReduction:
Since data mining is a technique that is used to handle huge amount of
data.While working with huge volume of data, analysis became harder in such
cases.In order to get rid of this, we uses data reduction technique. It aims to
increase the storage efficiency and reduce data storage and analysis costs.
Gaussian filter
A Gaussian filter is a linear filter. It's usually used to blur the image or to reduce
18
noise.The Gaussian filter alone will blur edges and reduce contrast. The
Median filter is a non-linear filter that is most commonly used as a simple way to
reduce noise in an image.
Edge Detection
Each image (video frame) has three significant features to achieve detection
goals. These features include: edges, contours and points. Among mentioned
features, an appropriate option is to use edge pixels. Processing of image pixels
enables us to find edge pixels, which are the main features of passing vehicles in a
roadway video frame.
Edge detection process is demonstrated in a binary image (threshold) with the
detected edge pixels.
The next step is to extract moving edges from sequential video frames and process
the resulting edge information to obtain quantitative geometric measurements of
passing vehicles.
Contour
Contour map uses contours or color-coded regions helps us to visualize 3D
data in two dimensions. Contour maps are also used to visualize the error surfaces
in deep learning/machine learning optimization techniques
Masking
The idea behind masking is to have two additional arrays that record whether
an input or output is actually present for a given time step and example, or whether
the input/output is just padding.
Model Creation ;
CNN Algorithm
A convolutional neural network (CNN) is a specific type of artificial neural
network that uses perceptrons, a machine learning unit algorithm, for supervised
learning, to analyze data. CNNs apply to image processing, natural language
processing and other kinds of cognitive tasks.
CNN image classifications takes an input image, process it and classify it under
certain categories.
19
➢ Line up the feature and the image
Training
The training data set in Machine Learning is the actual dataset used to train the
model for performing various actions. This is the actual data the ongoing
development process models learn with various API and algorithm to train the
machine to work automatically.
Testing
It uses patterns identified by your machine learning algorithms to predict. the
machine recognizes patterns in the data, the cross-validation data is used to
ensure better accuracy and efficiency of the algorithm used to train the machine,
and the test data is used to see how well the machine can predict based on its
training.
20
image and into binary image.
21
and Architecture model. To model a system the most important aspect is to capture
the dynamic behavior which has some internal or external factors for making the
interaction. These internal or external agents are known as actors. It consists of
actors, use cases and their relationships. In this fig we represent the Use Case
diagram for our project.
The UML is a very important part of developing objects oriented software and
the software development process. The UML uses mostly graphical notations to
express the design of software projects.
GOALS:
The Primary goals in the design of the UML are as follows:
1. Provide users a ready-to-use, expressive visual modeling Language so that
they can develop and exchange meaningful models.
2. Provide extendibility and specialization mechanisms to extend the core
concepts.
3. Be independent of particular programming languages and development
process.
4. Provide a formal basis for understanding the modeling language.
5. Encourage the growth of OO tools market.
6. Support higher level development concepts such as collaborations,
frameworks, patterns and components.
22
cases. The two main components a user or another system that will interact with
the system modeled. A use case is an external view of the system that represents
some action the user might perform in order to complete a task.
23
Fig 4.3 Sequence diagram
4.3.3.3 Activity Diagram
Activity diagrams are graphical representations of workflows of stepwise
activities and actions with support for choice, iteration and concurrency. In the
Unified Modeling Language, activity diagrams can be used to describe the
business and operational step-by-step workflows of components in a system. An
activity diagram shows the overall flow of control.
24
4.4 TESTING
General
In a generalized way, we can say that the system testing is a type of testing in
which the main aim is to make sure that system performs efficiently and
seamlessly. The process of testing is applied to a program with the main aim to
discover an unprecedented error, an error which otherwise could have damaged
the future of the software. Test cases which brings up a high possibility of
discovering and error is considered successful. This successful test helps to
answer the still unknown errors.
25
the internal program logic. The validation of all the decision branches and internal
code takes place. After the individual unit is completed it takes place. Plus it is
taken into account after the individual united is completed before integration. The
unit test thus performs the basic level test at its component stage and test the
particular business process, system configurations etc. The unit test ensures that
the particular unique path of the process gets performed precisely to the
documented specifications and contains clearly defined inputs with the results
which are expected.
26
by the tester himself to find out a possible bug or error. It is used in situation in
which the black box is incapable of finding out a bug. It is a complex type of testing
which takes more time to get applied.
27
CHAPTER 5
CONCLUSION
5.1 CONCLUSION
28
REFERENCES
1.A New Approach for Vehicle Number Plate Detection, Sarthak Babbar
; Saommya Kesarwani ; Navroz Dewan ; Kartik Shangle ; Sanjeev Patel, 2018
Eleventh International Conference on Contemporary Computing (IC3)
2.A hierarchical license plate recognition system using supervised K-means and
Support Vector Machine, Wei-Chen Liu ; Cheng-Hung Lin, 2017 International
Conference on Applied System Innovation (ICASI)
3.Deep Learning System for Automatic License Plate Detection and Recognition,
Zied Selmi ; Mohamed Ben Halima ; Adel M. Alimi, 2017 14th IAPR International
Conference on Document Analysis and Recognition (ICDAR)
4.Automatic number plate recognition for motorcyclists riding without helmet,
Yogiraj Kulkarni ; Amit Kamthe ; Shubhangi Bodkhe ; Archana Patil, 2018
International Conference on Current Trends towards Converging Technologies.
5.Automatic car number plate recognition, Anumol Sasi ; Swapnil Sharma
; Alice N. Cheeran, 2017 International Conference on Innovations in Information,
Embedded and Communication Systems (ICIIECS)
6.License Plate Detection with Machine Learning Without Using Number
Recognition, Kazuo Ohzeki ; Max Geigis ; Stefan Alexander Schneider, 2019
Federated Conference on Computer Science and Information Systems (FedCSIS)
7.A New Convolutional Architecture for Vietnamese Car Plate Recognition,
Thanh-Nga Nguyen ; Duc-Dung Nguyen, 2018 10th International Conference on
Knowledge and Systems Engineering (KSE)
8.Bangladeshi License Plate Recognition Using Adaboost Classifier, Prashengit
Dhar ; Md. Zainal Abedin ; Razuan Karim ; Fatema-Tuj-Johora ; Mohammad
Shahadat Hossain, 2019 Joint 8th International Conference on Informatics,
Electronics & Vision (ICIEV) and 2019 3rd International Conference on Imaging,
Vision & Pattern Recognition (icIVPR)
9.Long distance Automatic Number Plate Recognition under perspective
distortion using zonal density and Support Vector Machine, Noprianto ; Sunu
Wibirama ; Hanung Adi Nugroho, 2017 3rd International Conference on Science
and Technology - Computer (ICST)
10.Extraction of number plate images based on image category classification
using deep learning, Yoshihiro Shima, 2016 IEEE International Symposium on
Robotics and Intelligent Sensors (IRIS)
29
APPENDICES
A) SAMPLE CODE
from flask import Flask,url_for,request,render_template,redirect,session
import sqlite3
from werkzeug.utils import secure_filename
import os
import pytesseract
from PIL import ImageFilter
from PIL import Image
import datetime
app=Flask(__name__)
app.config['UPLOAD_FOLDER'] = './media'
app.secret_key="Rudy"
vnumlist=[]
parkingslot=[]
slotname=None
slotnamelist=[]
pytesseract.pytesseract.tesseract_cmd=r"C:\Program
Files\Tesseract-OCR\tesseract.exe"
@app.route('/',methods=["GET","POST"])
def login():
username=None
password=None
err="Invalid username and password"
if request.method=='POST':
session['username']=request.form['uname']
session['vid']=request.form['pwd']
username=request.form['uname']
password=request.form['pwd']
conn = sqlite3.connect("carparking.db")
r=conn.cursor()
r.execute("select name,pwd from userregister where name=? and
pwd=?",(username,password))
rows=r.fetchall()
if username=='Admin' and password=='Admin':
return redirect(url_for('Admin'))
else:
if len(rows)!=0:
for i in rows:
if i[0]==username and i[1]==password:
return redirect(url_for('userpage'))
#return render_template('user.html',username=username)
else:
return render_template('login.html',err=err)
30
else:
return render_template('login.html',err=err)
return render_template('login.html')
@app.route('/reg',methods=["GET","POST"])
def reg():
uname=None
pwd=None
phn=None
ema=None
vtype=None
vnum=None
msg="Register successfully"
if request.method=='POST':
uname=request.form['txt']
pwd=request.form['passw']
phn=request.form['phn']
ema=request.form['ema']
vtype=request.form['vtype']
vnum=request.form['vnum']
try:
import sqlite3
table_name = 'userregister'
conn = sqlite3.connect("carparking.db")
c = conn.cursor()
c.execute('create table if not exists ' + table_name + ' (name
varchar(50),pwd varchar(50) primary key,phn varchar(50),ema varchar(50),vtype
varchar(50),vnum varchar(50))')
c.execute('insert into '+table_name+' values
(?,?,?,?,?,?)',(uname,pwd,phn,ema,vtype,vnum))
conn.commit()
conn.close()
flash("Register successfully")
except:
return render_template('registration.html',msg=msg)
# return render_template('registration.html')
else:
return render_template('registration.html')
return render_template("registration.html")
@app.route('/userpage',methods=["POST","GET"])
def userpage():
err="Your not authorized to park here."
sloterr="Parking slot was full"
if request.method=='POST':
image = request.files['ocrImage']
text = ''
filename = secure_filename(image.filename)
image.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
31
img = Image.open(os.path.join(app.config['UPLOAD_FOLDER'],
filename))
text = pytesseract.image_to_string(img)
print(text)
session["vnumm"]=text.strip()
conn=sqlite3.connect("carparking.db")
r=conn.cursor()
r.execute("select name,phn,vtype,vnum from userregister where
vnum=?",(session["vnumm"],))
rows=r.fetchall()
li=[]
if len(rows)!=0:
if rows[0][3]==session["vnumm"]:
ss=conn.cursor()
ss.execute("select slot from parkingslot where
status=?",("available",))
slotrow=ss.fetchall()
if len(slotrow)!=0:
for i in slotrow:
li.append(i)
session["slot"]=li[0]
return
render_template("user.html",rows=rows,slotrow=session["slot"])
else:
return render_template("user.html",rows=rows,err=sloterr)
else:
print("noo")
else:
return render_template("user.html",err=err)
return render_template('user.html',text=session["vnumm"])
else:
return render_template("user.html")
return render_template('user.html')
if __name__=='__main__':
app.run(debug=True)
32