A
Training Report of
Industrial Training Project at
On
License Plate Recognition Using Python and OpenCV
Submitted
In the Partial Fulfilment of
Bachelors of Technology
In
Information Technology
Department of Computer Science
Institute of Engineering and Technology, Lucknow
2018 - 19
Submitted to: Submitted By:
Ms. Shipra Gautam Name : Vishal Polley
B. Tech (I.T.): 4th
Year
Semester : 7
Roll No. : 1505213053
2
ACKNOWLEDGEMENT
There is always a sense of gratitude which one express towards others for their help and
supervision in achieving the goals. This formal piece of acknowledgement is an attempt to
express the feeling of gratitude towards people who helpful me in successfully completing of
my training.
I would like to express my deep gratitude to Mr. Deepanshu Kukreja, my project mentor for
their constant co-operation. He was always there with his competent guidance and valuable
suggestion throughout the pursuance of this research project.
I would also like to place of appreciation to all the respondents and group members whose
responses and coordination were of utmost importance for the project. Above all no words
can express my feelings to my parents, friends all those persons who supported me during
my project. I am also thankful to all the respondents whose co-operation & support has
helped me a lot in collecting necessary information.
Vishal Polley
3
TABLE OF CONTENTS
1. About the Company 4
2. Introduction 6
3. Technologies Used 7
4. Module’s Information 8
5. Data Flow Diagram 10
6. Test Cases 11
7. Demonstration and Screenshots 12
8. Source Codes 16
9. Future Enhancements 21
10. References 22
11. Certificate 23
4
ABOUT COMPANY
Tata Consultancy Services Limited (TCS) is an Indian multinational information technology
(IT) service, consulting company headquartered in Mumbai, Maharashtra. It is part of the
Tata Group and operates in 46 countries.
TCS is one of the largest Indian companies by market capitalization. TCS is now placed
among the most valuable IT services brands worldwide. In 2015, TCS is ranked 64th overall
in the Forbes World's Most Innovative Companies ranking, making it both the highest-
ranked IT services company and the top Indian company. It is the world's 2nd largest IT
services provider. As of 2017, it is ranked 10th on the Fortune India 500 list. In April 2018,
TCS became the first Indian IT company to breach $100 billion market capitalization, and
second Indian company ever (after Reliance Industries achieved it in 2007) after its m-cap
stood at Rs. 6,79,332.81 crore ($102.6 billion) in Bombay Stock Exchange.
In 2016-2017, Parent company Tata Sons owned 70% of TCS; and more than 70% of Tata
Sons' dividends were generated by TCS. In March 2018, Tata Sons decided to sell stocks of
TCS worth $1.25 billion in a bulk deal.
Products and services
TCS and its 67 subsidiaries provide a wide range of information technology-related products
and services including application development, business process outsourcing, capacity
planning, consulting, enterprise software, hardware sizing, payment processing, software
management and technology education services. The firm's established software products are
TCS BaNCS and TCS MasterCraft.
5
Service lines
TCS' services are currently organised into the following service lines (percentage of total
TCS revenues in the 2012-13 fiscal year generated by each respective service line is shown
in parentheses):
 Application development and maintenance (43.80%) value;
 Asset leverage solutions (2.70%);
 Assurance services (7.70%);
 Business process outsourcing (12.50%);
 Consulting (2.00%);
 Engineering and Industrial services (4.60%);
 Enterprise solution (15.21%); and
 IT infrastructure services (11.50%).
6
INTRODUCTION
Automatic number-plate recognition (ANPR) is a technology that uses optical character
recognition on images to read vehicle registration plates to create vehicle location data. It can
use existing closed-circuit television, road-rule enforcement cameras, or cameras specifically
designed for the task. ANPR is used by police forces around the world for law enforcement
purposes, including to check if a vehicle is registered or licensed. It is also used for
electronic toll collection on pay-per-use roads and as a method of cataloguing the
movements of traffic, for example by highways agencies.
Automatic number plate recognition can be used to store the images captured by the cameras
as well as the text from the license plate, with some configurable to store a photograph of the
driver. Systems commonly use infrared lighting to allow the camera to take the picture at any
time of day or night. ANPR technology must take into account plate variations from place to
place.
Concerns about these systems have centred on privacy fears of government tracking citizens'
movements, misidentification, high error rates, and increased government spending. Critics
have described it as a form of mass surveillance.
License plate recognition (LPR) is a type of technology, mainly software that enables
computer systems to read automatically the registration number (license number) of vehicles
from digital pictures.
License Plate Recognition Systems use the concept of optical character recognition to read
the characters on a vehicle license plate. In other words, LPR takes the image of a vehicle as
the input and outputs the characters written on its license plate.
LPR also called ALPR (Automatic License Plate Recognition) has 3 major stages.
1. License Plate Detection: This is the first and probably the most important stage of the
system. It is at this stage that the position of the license plate is determined. The input at this
stage is an image of the vehicle and the output is the license plate.
2. Character Segmentation: It’s at this stage the characters on the license plate are mapped
out and segmented into individual images.
3. Character Recognition: This is where we wrap things up. The characters earlier
segmented are identified here. We have used machine learning for this.
7
TECHNOLOGIES USED
1. OS - Ubuntu 16.04:
Ubuntu is a free and open source operating system and Linux distribution based on Debian.
It is the most popular operating system for the cloud. There is python installed in it which
makes our work easier.
2. IDE - Atom:
Atom is a desktop application built using web technologies. It is free and open source text
and source code editor for Linux. It is based on Electron, a framework that enables cross-
platform desktop applications using Chromium and Node.js. It is written in Coffee Script and
Less. It can also be used as an Integrated Development Environment (IDE).
3. Database - SQLite3:
SQLite is a relational database management system contained in a C programming library. In
contrast to many other database management systems, SQLite is not a client-server database
engine. It is embedded into the end program. SQLite is ACID-compliant and implements
most of the SQL standard, using a dynamically and weakly typed SQL syntax that does not
guarantee the domain integrity.
4. Front End - Tkinter:
Python offers multiple options for developing GUI (Graphical User Interface). Out of all the
GUI methods, tkinter is most commonly used method. It is a standard Python interface to the
Tk GUI toolkit shipped with Python. Python with tkinter outputs the fastest and easiest way
to create the GUI applications.
5. Back End - Python:
Python is an interpreted high-level programming language. It provides constructs that enable
clear programming on both small and large scales. It is meant to be an easily readable
language. Writing programs in Python takes less time than in some other languages.
8
MODULE’S INFORMATION
Python Modules - scikit-learn, scikit-image, OpenCV, SciPy, Pillow, NumPy, matplotlib.
We have built our project over isolated python virtual environment. This makes it easy to
manage our project’s dependencies and packages. We have used virtualenv package to create
a virtual environment, which can be installed and activated by running these commands -
cd lpr/
virtualenv -p python3 env
source env/bin/activate
We have included a requirements file named as requirements.txt inside our project folder. To
install all the modules and dependencies required for the project run the following command
in terminal as -
pip install -r requirements.txt
1. scikit-learn:
scikit-learn is a Python module for machine learning built on top of SciPy. It provides a
range of supervised and unsupervised learning algorithms via a consistent interface in
Python.
2. scikit-image:
For performing Image Processing, we have used scikit-image. It’s a Python package for
image processing.
3. SciPy:
SciPy is a free and open-source Python library used for scientific computing and technical
computing. It contains modules for optimization, linear algebra, integration, interpolation,
special functions, FFT, signal and image processing, ODE solvers and other tasks common
in science and engineering.
9
4. OpenCV:
OpenCV (Open Source Computer Vision Library) is an open source computer vision and
machine learning software library. OpenCV was built to provide a common infrastructure for
computer vision applications and to accelerate the use of machine perception in the
commercial products.
5. Pillow:
Python Imaging Library (abbreviated as PIL) is a free library for the Python programming
language that adds support for opening, manipulating, and saving many different image file
formats.
6. NumPy:
NumPy is a library for the Python programming language, adding support for large, multi-
dimensional arrays and matrices, along with a large collection of high-level mathematical
functions to operate on these arrays.
7. matplotlib:
Matplotlib is a plotting library for the Python programming language and its numerical
mathematics extension NumPy. It provides an object-oriented API for embedding plots into
applications using general-purpose GUI toolkits like Tkinter, wxPython, Qt, or GTK+.
10
DATA FLOW DIAGRAM
11
TEST CASES
INPUT -
OUTPUT -
12
DEMONSTRATION AND SCREENSHORTS
1. In the first step, open terminal (Python Bash) and activate the virtualenv (Python virtual
environment) by running the following command inside the project folder -
source env/bin/activate
2. Now run the python project by executing python script named prediction.py in the
terminal (Python Bash)
13
3. The tkinter image file input dialog box will now open.
4. Now open any car image placed inside images folder in the project folder.
5. The next step displays the license plate detection process (plate localization). In this
process the original image is converted to its grayscale version. Now to localize license plate
14
from the image a specific threshold is applied to the grayscale image. The following image
shows a comparison between the grayscale image and the threshold image in the matplotlib
pyplot.
5. Now after localizing license plate from the original image, the next image shows the
process of identifying all the connected regions in the image using the concept of
connected component analysis (CCA). It basically, helps us group and label connected
regions on the foreground. A pixel is deemed to be connected to another if they both have
the same value and are adjacent to each other.
15
6. In the next step we have mapped out all the characters from the image using character
segmentation process and CCA.
7. In the final step we have used supervised machine learning to detect the possible
character present on the license plate. It makes use of a known dataset (called the training
dataset) to make predictions and thus, the license plate number is detected and displayed
inside a new dialog box as output.
16
SOURCE CODES
1. License Plate Detection
localization.py
cca.py
17
cca2.py
18
2. Character Segmentation
segmentation.py
19
3. Character Recognition
machine_train.py
20
prediction.py
21
FUTURE ENHANCEMENTS
1. The project currently works over still captured images only, and can be modified in future
to be implemented to extract license plate information over live video feeds.
2. Efficiency of the project can be increased by improving the character segmentation
algorithm so it can be applicable to various types of car’s images.
3. Image Processing speed can be increased by installing faster processors.
4. The project can be implemented with Raspberry-Pie so as to use it for real life conditions.
5. Project currently have a simple GUI based on tkinter but it can be made much more user
friendly and easily navigable by using many other modules.
6. We are currently using pre-build Machine Learning libraries for recognizing and
detecting license plate numbers. Self-written machine learning codes can further enhance
the speed and process for images of all conditions.
7. More number of character datasets can be trained with the project, so to detect and
recognize characters of regional languages and hand-written license plates.
22
REFERENCES
 Developing a License Plate Recognition System with Machine Learning in Python by
Femi Oladeji
https://blog.devcenter.co/developing-a-license-plate-recognition-system-with-machine-
learning-in-python-787833569ccd
 License Plate Recognition Nigerian Vehicles Dataset
https://github.com/andela-foladeji/License-Plate-Recognition-Nigerian-
vehicles/tree/master/training_data

License Plate Recognition Using Python and OpenCV

  • 1.
    A Training Report of IndustrialTraining Project at On License Plate Recognition Using Python and OpenCV Submitted In the Partial Fulfilment of Bachelors of Technology In Information Technology Department of Computer Science Institute of Engineering and Technology, Lucknow 2018 - 19 Submitted to: Submitted By: Ms. Shipra Gautam Name : Vishal Polley B. Tech (I.T.): 4th Year Semester : 7 Roll No. : 1505213053
  • 2.
    2 ACKNOWLEDGEMENT There is alwaysa sense of gratitude which one express towards others for their help and supervision in achieving the goals. This formal piece of acknowledgement is an attempt to express the feeling of gratitude towards people who helpful me in successfully completing of my training. I would like to express my deep gratitude to Mr. Deepanshu Kukreja, my project mentor for their constant co-operation. He was always there with his competent guidance and valuable suggestion throughout the pursuance of this research project. I would also like to place of appreciation to all the respondents and group members whose responses and coordination were of utmost importance for the project. Above all no words can express my feelings to my parents, friends all those persons who supported me during my project. I am also thankful to all the respondents whose co-operation & support has helped me a lot in collecting necessary information. Vishal Polley
  • 3.
    3 TABLE OF CONTENTS 1.About the Company 4 2. Introduction 6 3. Technologies Used 7 4. Module’s Information 8 5. Data Flow Diagram 10 6. Test Cases 11 7. Demonstration and Screenshots 12 8. Source Codes 16 9. Future Enhancements 21 10. References 22 11. Certificate 23
  • 4.
    4 ABOUT COMPANY Tata ConsultancyServices Limited (TCS) is an Indian multinational information technology (IT) service, consulting company headquartered in Mumbai, Maharashtra. It is part of the Tata Group and operates in 46 countries. TCS is one of the largest Indian companies by market capitalization. TCS is now placed among the most valuable IT services brands worldwide. In 2015, TCS is ranked 64th overall in the Forbes World's Most Innovative Companies ranking, making it both the highest- ranked IT services company and the top Indian company. It is the world's 2nd largest IT services provider. As of 2017, it is ranked 10th on the Fortune India 500 list. In April 2018, TCS became the first Indian IT company to breach $100 billion market capitalization, and second Indian company ever (after Reliance Industries achieved it in 2007) after its m-cap stood at Rs. 6,79,332.81 crore ($102.6 billion) in Bombay Stock Exchange. In 2016-2017, Parent company Tata Sons owned 70% of TCS; and more than 70% of Tata Sons' dividends were generated by TCS. In March 2018, Tata Sons decided to sell stocks of TCS worth $1.25 billion in a bulk deal. Products and services TCS and its 67 subsidiaries provide a wide range of information technology-related products and services including application development, business process outsourcing, capacity planning, consulting, enterprise software, hardware sizing, payment processing, software management and technology education services. The firm's established software products are TCS BaNCS and TCS MasterCraft.
  • 5.
    5 Service lines TCS' servicesare currently organised into the following service lines (percentage of total TCS revenues in the 2012-13 fiscal year generated by each respective service line is shown in parentheses):  Application development and maintenance (43.80%) value;  Asset leverage solutions (2.70%);  Assurance services (7.70%);  Business process outsourcing (12.50%);  Consulting (2.00%);  Engineering and Industrial services (4.60%);  Enterprise solution (15.21%); and  IT infrastructure services (11.50%).
  • 6.
    6 INTRODUCTION Automatic number-plate recognition(ANPR) is a technology that uses optical character recognition on images to read vehicle registration plates to create vehicle location data. It can use existing closed-circuit television, road-rule enforcement cameras, or cameras specifically designed for the task. ANPR is used by police forces around the world for law enforcement purposes, including to check if a vehicle is registered or licensed. It is also used for electronic toll collection on pay-per-use roads and as a method of cataloguing the movements of traffic, for example by highways agencies. Automatic number plate recognition can be used to store the images captured by the cameras as well as the text from the license plate, with some configurable to store a photograph of the driver. Systems commonly use infrared lighting to allow the camera to take the picture at any time of day or night. ANPR technology must take into account plate variations from place to place. Concerns about these systems have centred on privacy fears of government tracking citizens' movements, misidentification, high error rates, and increased government spending. Critics have described it as a form of mass surveillance. License plate recognition (LPR) is a type of technology, mainly software that enables computer systems to read automatically the registration number (license number) of vehicles from digital pictures. License Plate Recognition Systems use the concept of optical character recognition to read the characters on a vehicle license plate. In other words, LPR takes the image of a vehicle as the input and outputs the characters written on its license plate. LPR also called ALPR (Automatic License Plate Recognition) has 3 major stages. 1. License Plate Detection: This is the first and probably the most important stage of the system. It is at this stage that the position of the license plate is determined. The input at this stage is an image of the vehicle and the output is the license plate. 2. Character Segmentation: It’s at this stage the characters on the license plate are mapped out and segmented into individual images. 3. Character Recognition: This is where we wrap things up. The characters earlier segmented are identified here. We have used machine learning for this.
  • 7.
    7 TECHNOLOGIES USED 1. OS- Ubuntu 16.04: Ubuntu is a free and open source operating system and Linux distribution based on Debian. It is the most popular operating system for the cloud. There is python installed in it which makes our work easier. 2. IDE - Atom: Atom is a desktop application built using web technologies. It is free and open source text and source code editor for Linux. It is based on Electron, a framework that enables cross- platform desktop applications using Chromium and Node.js. It is written in Coffee Script and Less. It can also be used as an Integrated Development Environment (IDE). 3. Database - SQLite3: SQLite is a relational database management system contained in a C programming library. In contrast to many other database management systems, SQLite is not a client-server database engine. It is embedded into the end program. SQLite is ACID-compliant and implements most of the SQL standard, using a dynamically and weakly typed SQL syntax that does not guarantee the domain integrity. 4. Front End - Tkinter: Python offers multiple options for developing GUI (Graphical User Interface). Out of all the GUI methods, tkinter is most commonly used method. It is a standard Python interface to the Tk GUI toolkit shipped with Python. Python with tkinter outputs the fastest and easiest way to create the GUI applications. 5. Back End - Python: Python is an interpreted high-level programming language. It provides constructs that enable clear programming on both small and large scales. It is meant to be an easily readable language. Writing programs in Python takes less time than in some other languages.
  • 8.
    8 MODULE’S INFORMATION Python Modules- scikit-learn, scikit-image, OpenCV, SciPy, Pillow, NumPy, matplotlib. We have built our project over isolated python virtual environment. This makes it easy to manage our project’s dependencies and packages. We have used virtualenv package to create a virtual environment, which can be installed and activated by running these commands - cd lpr/ virtualenv -p python3 env source env/bin/activate We have included a requirements file named as requirements.txt inside our project folder. To install all the modules and dependencies required for the project run the following command in terminal as - pip install -r requirements.txt 1. scikit-learn: scikit-learn is a Python module for machine learning built on top of SciPy. It provides a range of supervised and unsupervised learning algorithms via a consistent interface in Python. 2. scikit-image: For performing Image Processing, we have used scikit-image. It’s a Python package for image processing. 3. SciPy: SciPy is a free and open-source Python library used for scientific computing and technical computing. It contains modules for optimization, linear algebra, integration, interpolation, special functions, FFT, signal and image processing, ODE solvers and other tasks common in science and engineering.
  • 9.
    9 4. OpenCV: OpenCV (OpenSource Computer Vision Library) is an open source computer vision and machine learning software library. OpenCV was built to provide a common infrastructure for computer vision applications and to accelerate the use of machine perception in the commercial products. 5. Pillow: Python Imaging Library (abbreviated as PIL) is a free library for the Python programming language that adds support for opening, manipulating, and saving many different image file formats. 6. NumPy: NumPy is a library for the Python programming language, adding support for large, multi- dimensional arrays and matrices, along with a large collection of high-level mathematical functions to operate on these arrays. 7. matplotlib: Matplotlib is a plotting library for the Python programming language and its numerical mathematics extension NumPy. It provides an object-oriented API for embedding plots into applications using general-purpose GUI toolkits like Tkinter, wxPython, Qt, or GTK+.
  • 10.
  • 11.
  • 12.
    12 DEMONSTRATION AND SCREENSHORTS 1.In the first step, open terminal (Python Bash) and activate the virtualenv (Python virtual environment) by running the following command inside the project folder - source env/bin/activate 2. Now run the python project by executing python script named prediction.py in the terminal (Python Bash)
  • 13.
    13 3. The tkinterimage file input dialog box will now open. 4. Now open any car image placed inside images folder in the project folder. 5. The next step displays the license plate detection process (plate localization). In this process the original image is converted to its grayscale version. Now to localize license plate
  • 14.
    14 from the imagea specific threshold is applied to the grayscale image. The following image shows a comparison between the grayscale image and the threshold image in the matplotlib pyplot. 5. Now after localizing license plate from the original image, the next image shows the process of identifying all the connected regions in the image using the concept of connected component analysis (CCA). It basically, helps us group and label connected regions on the foreground. A pixel is deemed to be connected to another if they both have the same value and are adjacent to each other.
  • 15.
    15 6. In thenext step we have mapped out all the characters from the image using character segmentation process and CCA. 7. In the final step we have used supervised machine learning to detect the possible character present on the license plate. It makes use of a known dataset (called the training dataset) to make predictions and thus, the license plate number is detected and displayed inside a new dialog box as output.
  • 16.
    16 SOURCE CODES 1. LicensePlate Detection localization.py cca.py
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
    21 FUTURE ENHANCEMENTS 1. Theproject currently works over still captured images only, and can be modified in future to be implemented to extract license plate information over live video feeds. 2. Efficiency of the project can be increased by improving the character segmentation algorithm so it can be applicable to various types of car’s images. 3. Image Processing speed can be increased by installing faster processors. 4. The project can be implemented with Raspberry-Pie so as to use it for real life conditions. 5. Project currently have a simple GUI based on tkinter but it can be made much more user friendly and easily navigable by using many other modules. 6. We are currently using pre-build Machine Learning libraries for recognizing and detecting license plate numbers. Self-written machine learning codes can further enhance the speed and process for images of all conditions. 7. More number of character datasets can be trained with the project, so to detect and recognize characters of regional languages and hand-written license plates.
  • 22.
    22 REFERENCES  Developing aLicense Plate Recognition System with Machine Learning in Python by Femi Oladeji https://blog.devcenter.co/developing-a-license-plate-recognition-system-with-machine- learning-in-python-787833569ccd  License Plate Recognition Nigerian Vehicles Dataset https://github.com/andela-foladeji/License-Plate-Recognition-Nigerian- vehicles/tree/master/training_data