Вы находитесь на странице: 1из 25

1.

INTRODUCTION

Massive integration of information technologies into all aspects of modern life caused need
for processing vehicles as conceptual resources in information systems. Because a standalone
information system without any data has no sense, there was also a need to transform information
about vehicles between the reality and information systems. This can be achieved by a human
agent, or by special intelligent equipment which is be able to recognize vehicles by their number
plates in a real environment and reflect it into conceptual resources. Because of this, various
recognition techniques have been developed and number plate recognition systems are today used
in various traffic and security applications, such as parking, toll plazas, access and border control,
or tracking of stolen cars.
In parking, number plates are used to calculate duration of the parking. When a vehicle
enters an input gate, number plate is automatically recognized and stored in database. When a
vehicle later exits the parking area through an output gate, number plate is recognized again and
paired with the first-one stored in the database. The difference in time is used to calculate the
parking fee. Automatic number plate recognition systems can be used in access control. For
example, this technology is used in many companies to grant access only to vehicles of authorized
personnel. In some countries, ANPR systems installed on country borders automatically detect and
monitor border crossings. Each vehicle can be registered in a central database and compared to a
black list of stolen vehicles. In traffic control, vehicles can be directed to different lanes for a better
congestion control in busy urban communications during the rush hours.

• Mathematical aspects of number plate recognition systems

In most cases, vehicles are identified by their number plates, which are easily readable for
humans, but not for machines. For machine, a number plate is only a grey picture defined as a two-
dimensional function , f(x,y) , where x and y are spatial coordinates, and f is a light intensity at that
point. Because of this, it is necessary to design mathematical model, which will be able to extract
features from the captured image. These functions are implemented in so-called ANPR systems,
where the acronym ANPR stands for an Automatic Number Plate Recognition. ANPR system means
transformation of data between the real environment and information systems.
The first phase of algorithm is to detect the number plate area. This phase will be able to
detect a rectangular area of the number plate in original image. Humans define the number plate in a

1
natural language as a small plastic or metal plate attached to a vehicle for official identification
purposes, but machines do not understand this definition. Because of this, there is a need to find an
alternative definition of the number plate based on descriptors, which will be comprehensible for
machines. This is implemented by computer vision methodologies.
The second phase would be character segmentation. In most cases, characters are segmented
using the horizontal projection of a pre-processed number plate, but sometimes these principles can
fail, especially if detected number plates are too warped or skewed. Then, more sophisticated
segmentation algorithms must be used. This is followed by the recognition of characters. At first,
character dimensions and brightness must be normalized to ensure invariance towards a size and
light conditions. Then, a feature extraction algorithm must be applied on a character to filter
irrelevant data. It is necessary to extract features, which will be invariant towards character
deformations, used font style etc. Characters can be classified and recognized by the K Nearest
Neighbor algorithm (KNN) applied to a list of extracted features. Sometimes, the recognition
process may fail and the detected plate can contain errors. Some of these errors can be detected by a
syntactical analysis of the recognized plate. If we have a regular expression, or a rule how to
evaluate a country-specific license plate, we can reconstruct defective plates using this rule. For
example, a number zero “0” can be automatically repaired to a character “O” on positions, where
numbers are not allowed.

• Physical aspects of ANPR system

Automatic number plate recognition system is a special set of hardware and software components
that proceeds an input graphical signal like static pictures or video sequences, and recognizes
license plate characters from it. A hardware part of the ANPR system typically consists of a camera,
image processor, camera trigger, communication and storage unit.
The hardware trigger physically controls a sensor directly installed in a lane. Whenever the
sensor detects a vehicle in a proper distance of camera, it activates a recognition mechanism.
Alternative to this solution is a software detection of an incoming vehicle, or continual processing
of the sampled video signal. Software detection, or continual video processing may consume more
system resources, but it does not need additional hardware equipment, like the hardware trigger.
Image processor recognizes static snapshots captured by the camera, and returns a text
representation of the detected license plate. ANPR units can have own dedicated image processors
(all-in-one solution), or they can send captured data to a central processing unit for further
processing (generic ANPR). The image processor is running on special recognition software, which

2
is a key part of whole ANPR system.Because one of the fields of application is a usage on road
lanes, it is necessary to use a special camera with the extremely short shutter. Otherwise, quality of
captured snapshots will be degraded by an undesired motion blur effect caused by a movement of
the vehicle. For example, usage of the standard camera with shutter of 1/100 sec to capture a
vehicle with speed of 80 km/h will cause a motion skew in amount of 0.22 m. This skew means the
significant degradation of recognition abilities. There is also a need to ensure system invariance
towards the light conditions. Normal camera should not be used for capturing snapshots in darkness
or night, because it operates in a visible light spectrum. Automatic number plate recognition
systems are often based on cameras operating in an infrared band of the light spectrum. Usage of
the infrared camera in combination with an infrared illumination is better to achieve this goal.
Under the illumination, plates that are made from reflexive material are much more highlighted than
rest of the image. This fact makes detection of license plates much easier.

3
2. SYSTEM ANALYSIS

Here, the difference between the existing system and the proposed system is taken into
consideration. The existing system is the one which is being used for years and proposed system is the
one which is going to be build.

2.1 EXISTING SYSTEM

In the case of toll plaza, customers have to wait at the toll booth for long time to pay the
collector. This makes a little traffic delay. When it comes to the violation of traffic rules, the existing
system needs manual interference for the understanding of the visuals gained by the traffic cameras.
Processing of images for the identification of stolen vehicle also needs the human resources.

2.2 PROPOSED SYSTEM

The ANPR system can be integrated with software which automates the toll plaza payments.
This would remove unneccessary traffic delays; keeps an eye on any car that might not be correctly
registered or number plates exchanged for theft purpose. Automated toll collection is fast becoming a
globally accepted for toll collection. This can also be inegrated with traffic cameras.

2.3. FEASIBILITY STUDY

2.3.1. Technical feasibility

The programming language used in this project is python since it provides libraries and
frameworks that are apt for computer vision and machine learning. It also provides libraries to support
the diffterent operations in these domains.

2.3.2. Economic feasibility

This system is economically feasible as the cost of the system zero, and can be integrated with
existing softwares. Every softwares used in the develpment of this project are open source software.

4
For the better perfomance of the system, it has to be trained with vast amount of data. This will
demand much processing power, memory and storage.

2.3.3. Operational feasibility

The system is very easy to work with. IDEs like jupyter, PyCharm can be used which can help coding
to be faster. They integrate with the python kernel and work fast and efficiently. Google Colab is a
handy cloud platform to work with if your system does not qualify for the project system requirements.
It can work well with heavy weight codes fast.

2.4. SYSTEM SPECIFICATION

A system specification is a document that captures complete description about how the system is
expected to perform. It is usually signed off at the end of requirements engineering phase. A system
specification minimizes the time and effort required by developers to achieve desired goals and also
minimizes the development cost. A good document defines how an application will interact with system
hardware, other programs and human users in a wide variety of real-world situations

2.4.1. Hardware Specifications

 PROCESSOR: intel core i3 2.0Ghz


 RAM: 4GB
 STORAGE: 500MB
 GPU: 2GB or Above

2.4.2. Software Specifications

2.4.2.1. Technologies used in the project


1. Language: - Python.

2. IDE: - PyCharm

3. Packages: - OpenCV

2.4.2.2. Software and languages required:

• Softwares:

5
PyCharm : PyCharm is an integrated development enviromnent (IDE) used in computer
programming, specifically for the Python language. It is cross platform, with windows, macOS and
linux versions. It provides API so that developers can write their own plugins to extend PyCharm
features.

 Languages:

 PYTHON: Python is a general-purpose programming language. Hence, it can be


choosen as the programming language for developing both desktop and web
applications. Also, Python can be used for developing complex scientific and
numeric applications. Python is designed with features to facilitate data analysis and
visualization. Additionally, Python supports the use of modules and packages, which
means that programs can be designed in a modular style and code can be reused
across a variety of projects. Once a module or packege is developed, it can be scaled
for use in other projects, and it's easy to import or export these modules.

6
3. SYSTEM DESIGN

3.1 MODULE DESIGN

The whole process can be divided into two as Number Plate Detection and Number Plate Recognition.
The first phase is responsible for detecting the number plate and the second one is responsible for
recognising the characters from the number plate.

3.1.1 NUMBER PLATE AREA DETECTION

The first step in a process of automatic number plate recognition is a detection of a number plate area.
This problematic includes algorithms that are able to detect a rectangular area of the number plate in an
original image. Humans define a number plate in a natural language as a small plastic or metal plate
attached to a vehicle for official identification purposes, but machines do not understand this definition
as well as they do not understand what vehicle, road, or whatever else is. Because of this, there is a
need to find an alternative definition of a number plate based on descriptors that will be
comprehensible for machines. The number plate can be defined as rectangular area with increased
occurrence of horizontal and vertical edges; with maximum number of characters. The high density of
horizontal and vertical edges on a small area is in many cases caused by contrast characters of a
number plate.

7
Figure 1: Original Image
3.1.1.1 Image Thresholding
i. The original image is converted into gray scale image.
ii. Increase the constrast with morphological transformations(TopHat , BlackHat)
iii. Apply Gaussian Blur to the resulting image.
iv. Use Adaptive Threshold over the image.

Figure 2: Grayscale Image

8
Figure 3: Threshold Image
3.1.1.2 List of Possible Characters in the Image
i. Find all the contours in the image.
ii. Check if it’s a possible character using the predefined pixel criteria.

Figure 4:All contours

9
Figure 5: Possible Characters
3.1.1.3 List of Matching characters
i. Find the distance, angle, change in area, change in width and change in height between
characters.
ii. Check the pixel criteria for the matching characters.

Figure 6: Matching Characters

10
3.1.1.4 Plate Extraction
i. Calculate the center point of the plate.
ii. Calculate plate width and height.
iii. Crop the image with the above values.

Figure 7: Detected Plates

Figure 8: Cropped Possible Plates

3.1.2 NUMBER PLATE RECOGNITION


The second step in a process of automatic number plate recognition is a recognition of the
number plate. This problematic includes algorithms that are able to deetect each character on the
plate and recognise it. KNN model is used for the recognition of the character. The model is trained
with some previously generated data.
3.1.2.1 Possible Plate Thresholding
i. The original image is converted into gray scale image.
ii. Increase the constrast with morphological transformations(TopHat , BlackHat)
iii. Apply Gaussian Blur to the resulting image.
iv. Use Adaptive Threshold over the image.
v. Threshold again to eliminate any gray areas.

11
Figure 9: Gray Scale Image

Figure 10: Threshold Image


3.1.2.2 List of Possible Characters in Plate
iii. Find all the contours in the image.
iv. Check if it’s a possible character using the predefined plate criteria.

Figure 11: Possible Characters


3.1.2.3 List of Matching Characters
i. Find the distance, angle, change in area, change in width and change in height between
characters.
ii. Check the plate criteria for the matching characters.

Figure 12: Matching Characters


3.1.2.4 Removing Inner Overlapping
i. Check for overlapping characters.
ii. Remove them and update the list .

Figure 13: Overlapping Removed


3.1.2.5 Recognition Using KNN
i. Crop character out of threshold image.
ii. Resize the image to 20x30 pixels
iii. Predict the character with KNN model.
iv. Append the predicted character to the result.

Figure 14: Charactes Recognised


3.2 DATA FLOW DIAGRAM

12
Figure 15: Data Flow Diagram

13
Figure 15: Data Flow Diagram (Detailed)

4. IMPLEMENTATION AND TESTING

4.1. IMPLEMENTATION

14
To implement the above-mentioned system, it’s important to have a clear knowledge on the
subject. It has to go through the algorithms and methods over and over again to get things clear
before implementing it properly. The system needs to be trained with maximum number of data that
is images in order to get maximum accuracy. The dataset is passed through the model many number
of times to achieve minimal accuracy.

Implementation in Python programming language is easy but it should be minutely done. Every
command is based on a package so package installation is an important task. Even in PyCharm, step
wise implementation and analysis is a tenuous work. But overall, the work is exciting.
As proposed in the requirements, the system used to run the code is Intel Core i3 processor in a
Linux operating system with a RAM of 8 GB and GPU of 2 GB.

4.2. TESTING

The process of testing of an integrated hardware and software system to verify that the system
meets its specified requirements. In order to make a good system it must be tested thoroughly.
Testing includes Unit testing, Validation testing and Functional testing.

4.2.1. UNIT TESTING

Entire code is being tested bit by bit. All the lines are particularly checked and satisfied with the
desired output. PyCharm is used for coding and in this IDE we can run every set of code separately,
so it is easy to do unit testing. So here every code modules like character detection, plate detection,
preprocessing of image, training and predicting data will be tested seperately.

4.2.2. VALIDATION TESTING

15
The code is being checked different error and results are being noted. There were many errors like
dependency errors, import errors because some packages are system dependent to run the code.
Experimental coding is also been done in order to see that it is being perfectly compiled or not.

4.2.3. FUNCTIONAL TESTING


All the functionality of this app has tested successfully. All the coding parts that has connection
with dataset and model is tested and those are working successfully without any errors. The main
functionality like plate recognition and making prediction also tested and working successfully.

4.2.4. TESTING THE MODEL

The trained model will be tested with test data and the accuracy will be noted. Here using KNN
model is used for the training. The higher the accuracy the system will make perfect predictions. So
the model needs to be trained well.

5. CONCLUSION

16
The primary objective of this project was to a develop new automated systems for number
plate recognition. So, images of vehicles with number plate has taken for the processing.
Traditionally, human interference is need to process an image and gain the information from it. It is
a time-consuming process and requires a lot of time compared to machines. So, the process need to
have better methods to make it faster and efficient.

The system reads number plate image as input and based on that it will make predictions.
This system will be a useful in many real life applications for toll plaza, parking area and traffic
systems.

KNN algorithm is used for training the model. Machine learning techniques in recognising
the character is so useful and innovative.With the help of a powerful working machine the training
and testing can be made faster. Large number images needs to be used to train the model in order to
get maximum accuracy.

In the future versions, the system will be using other algorithms for training developing a more
appropriate system.

17
6. REFERENCES

 https://docs.opencv.org/master/d6/d00/tutorial_py_root.html

 http://javaanpr.sourceforge.net

 https://www.pyimagesearch.com

 www.stackoverflow.com

 https://dl.acm.org/citation.cfm

18
ANNEXURE I

CODE

# Main.py

import cv2

import numpy as np

import os

import DetectChars

import DetectPlates

import PossiblePlate

SCALAR_BLACK = (0.0, 0.0, 0.0)

SCALAR_WHITE = (255.0, 255.0, 255.0)

SCALAR_YELLOW = (0.0, 255.0, 255.0)

SCALAR_GREEN = (0.0, 255.0, 0.0)

SCALAR_RED = (0.0, 0.0, 255.0)

showSteps = False

licenseNo = None

def main(imgName):

global licenseNo

blnKNNTrainingSuccessful = DetectChars.loadKNNDataAndTrainKNN()

if blnKNNTrainingSuccessful == False:

print("\nerror: KNN traning was not successful\n")

19
return

imgOriginalScene = cv2.imread(imgName)

if imgOriginalScene is None:

print("\nerror: image not read from file \n\n")

os.system("pause")

return

listOfPossiblePlates = DetectPlates.detectPlatesInScene(imgOriginalScene)

listOfPossiblePlates = DetectChars.detectCharsInPlates(listOfPossiblePlates)

if len(listOfPossiblePlates) == 0:

print("\nno license plates were detected\n")

licenseNo = "No licence Plates Found"

else:

listOfPossiblePlates.sort(key = lambda possiblePlate: len(possiblePlate.strChars), reverse =

True)

licPlate = listOfPossiblePlates[0]

if len(licPlate.strChars) == 0:

print("\nno characters were detected\n\n")

return

20
drawRedRectangleAroundPlate(imgOriginalScene, licPlate)

print("\nlicense plate read from image = " + licPlate.strChars + "\n")

licenseNo = licPlate.strChars

print("----------------------------------------")

writeLicensePlateCharsOnImage(imgOriginalScene, licPlate)

cv2.imwrite("imgOriginalScene.png", imgOriginalScene)

print(licenseNo+"from main")

return

def drawRedRectangleAroundPlate(imgOriginalScene, licPlate):

p2fRectPoints = cv2.boxPoints(licPlate.rrLocationOfPlateInScene)

cv2.line(imgOriginalScene, tuple(p2fRectPoints[0]), tuple(p2fRectPoints[1]), SCALAR_RED, 2)

cv2.line(imgOriginalScene, tuple(p2fRectPoints[1]), tuple(p2fRectPoints[2]), SCALAR_RED, 2)

cv2.line(imgOriginalScene, tuple(p2fRectPoints[2]), tuple(p2fRectPoints[3]), SCALAR_RED, 2)

cv2.line(imgOriginalScene, tuple(p2fRectPoints[3]), tuple(p2fRectPoints[0]), SCALAR_RED, 2)

def writeLicensePlateCharsOnImage(imgOriginalScene, licPlate):

ptCenterOfTextAreaX = 0

ptCenterOfTextAreaY = 0

21
ptLowerLeftTextOriginX = 0

ptLowerLeftTextOriginY = 0

sceneHeight, sceneWidth, sceneNumChannels = imgOriginalScene.shape

plateHeight, plateWidth, plateNumChannels = licPlate.imgPlate.shape

intFontFace = cv2.FONT_HERSHEY_SIMPLEX

fltFontScale = float(plateHeight) / 30.0

intFontThickness = int(round(fltFontScale * 1.5))

textSize, baseline = cv2.getTextSize(licPlate.strChars, intFontFace, fltFontScale,

intFontThickness)

( (intPlateCenterX, intPlateCenterY), (intPlateWidth, intPlateHeight), fltCorrectionAngleInDeg )

= licPlate.rrLocationOfPlateInScene

intPlateCenterX = int(intPlateCenterX)

intPlateCenterY = int(intPlateCenterY)

ptCenterOfTextAreaX = int(intPlateCenterX)

if intPlateCenterY < (sceneHeight * 0.75):

ptCenterOfTextAreaY = int(round(intPlateCenterY)) + int(round(plateHeight * 1.6))

else:

22
ptCenterOfTextAreaY = int(round(intPlateCenterY)) - int(round(plateHeight * 1.6))

# end if

textSizeWidth, textSizeHeight = textSize

ptLowerLeftTextOriginX = int(ptCenterOfTextAreaX - (textSizeWidth / 2))

ptLowerLeftTextOriginY = int(ptCenterOfTextAreaY + (textSizeHeight / 2))

cv2.putText(imgOriginalScene, licPlate.strChars, (ptLowerLeftTextOriginX,

ptLowerLeftTextOriginY), intFontFace, fltFontScale, SCALAR_YELLOW, intFontThickness)

if __name__ == "__main__":

main("/home/ubais/PycharmProjects/miniprog/carImages/IMG_20191111_224838.jpg")

23
ANNEXURE II

SCREENSHOTS (INTERFACE)

Choosing image:

Result:

24
Choosing another image:

Result:

25

Вам также может понравиться