Ass Word
Ass Word
DEPARTMENT OF ECE
MINI PROJECT
SUBMITTED BY,
GAYATHRI.VK (963221106011)
RAMYA.V (963221106031)
RAJA SINEKA.P (963221106028)
BRINDHA.R (963221106008)
DEEPA.G (963221106010)
BACHELOR OF ENGINEERING
In
MAY 2024
PET ENGINEERING COLLEGE
An ISO 9001:2008 Certified Institution
Approved by AICTE, Recognized by Government of Tamil Nadu and Affiliated to Anna University
BONAFIDE CERTIFICATE
Mr./Ms……
………………………………………………………………………………….of
ABSTRACT 1
1. INTRODUCTION
Objectives
Motivation 1-3
Overview of the project
Chapter wise summary
3. IMPLEMENTATION
Implementation details
Modules description 9-15
Tools used
4.
RESULTS 15-25
5.
CONCLUSION 26
6.
REFERENCES 26
ABSTRACT
Automatic number plate recognition (ANPR) is an image processing technology which uses number
(license) plate to identify the vehicle. The objective is to design an efficient automatic authorized
vehicle identification system by using the vehicle number plate.
This project aims to recognize license number plates. In order to detect license number plates, we
will use OpenCV to identify number plates and python pytesseract to extract characters and digits
from the number plates.
Automatic Number Plate Recognition (ANPR) is a mass surveillance system that captures the image
of vehicles and recognizes their license number. ANPR can be assisted in the detection of stolen
vehicles. The detection of stolen vehicles can be done in an efficient manner by using the ANPR
systems located in the highways. This paper presents a recognition method in which the vehicle plate
image is obtained by the digital cameras and the image is processed to get the number plate
information. A rear image of a vehicle is captured and processed using various algorithms. In this
context, the number plate area is localized using a novel „feature-based number plate localization???
method which consists of many algorithms. But our study mainly focusing on the two fast algorithms
i.e Edge Finding Method and Window Filtering Method for the better development of the number plate
detection system. it plays(ANPR) plays a significant role throughout this busy world, owing to the rise
in vehicles day by day. Stealing of vehicles, breaking traffic rules, coming into restricted space also are
increasing linearly, thus to dam this act registration code recognition is intended. Among the
fundamental process steps such as detection of number plate, segmentation of characters and
recognition of each characters, segmentation plays an important art, since the accuracy of
recognition is based on how perfect the segmentation is done. To avoid problems like unwanted
illumination, tilt that degrades the segmentation which in turn affects the recognition accuracy
numerous algorithms are developed for this work. This paper presents a strong technique for
localisation, segmentation and recognition of the characters within the located plate. Images from
still cameras or videos are obtained and regenerated in to grayscale images. Hough lines are
determined using Hough transform and therefore the segmentation of grey scale image generated by
finding edges for smoothing image is employed to cut back the quantity of connected part and then
connected part is calculated. Finally, single character within the registration code is detected. The
aim is to indicate that the planned technique achieved high accuracy by optimizing numerous
parameters that has higher recognition rate than the standard ways.
INTRODUCTION
1.Introduction:
Real time segmentation of dynamic regions or objects in video or image are often referred to as
background subtraction or foreground segmentation and is a basic step in several computer vision
applications. With emerge of new developments in communications technologies the requirement
for up Intelligent Surveillance Systems (ISS) technologies is changing into additional important. The
importance often leads to its role in capturing traffic information, accidents and in safety
management in general. It's been demonstrated that vision based information can end in improved
operational efficiency. The terribly beginning in visual process is the segmentation of moving objects
in image sequences, supported the recorded image sequences a background are often estimated.
1
Automatic number plate recognition (ANPR) is a method that uses character recognition on pictures
to obtain vehicle registration plates with the use of existing CCTVs or traffic cameras, or task specific
equipment.
This project aims to recognize license number plates. In order to detect license number plates, we
will use OpenCV to identify number plates any python pytesseract to extract characters and digits
from the number plates.
OBJECTIVE:
In our society, traffic needs to be controlled and the registration of vehicles can suit more then one
purpose. ANPR (Automatic Number Plate Recognition) is developed for these purposes. Depending
on the state/country we see different objectives. The number plate allows categorization of vehicles,
the identification of the driver, or the origin of the driver/car. Therefore, number plate recognition at
a specific location can be useful. It is often used for statistics and data mining.
Some examples:
2
MOTIVATION:
Automatic Number Plate Recognition is a computer vision technology that efficiently identifies
vehicle number plates from images without the need for human intervention. In recent years, it has
become more and more important due to three main factors: the growing number of cars on the
roads, the rapid development of image processing techniques and the great quantity of real-life
applications that this technology offers [1]. Some of the most typical applications of ANPR systems
are traffic law enforcement, automatic toll collection or parking lot access control. But this
technology is also widely used.
Smart Parking uses ANPR/LPR across the india and the rest of the world as part of our solution to
monitor and manage car parks. The technology is simple to install and is proven to be a cost
effective, reliable way to effectively operate control over parking spaces in settings such as
supermarkets, shopping centres, gyms, business estates, hotels, public council-run land, and more.
With any ANPR install, Smart Parking combines our technologies to create a parking management
solution that is tailored to the exigencies of each site. By setting parameters and business rules to the
system we can cater for requirements such as permit only, staff only, free limited time parking, set
time parking, zero tolerance and after business hours.
images to read the on vehicles. ... ANPR is the “heart” of any ITS system. The technology is used by
various police forces and as a method of on pay-peruse roads and , such as red light violence in
intersections.
3
2. ANALYSIS AND DESIGN:
● Functional Requirements:
The menu bar of ANPR contains 6 menus: File, Pre-processing, Localization, Segmentation,
Recognition and Help. All the functions of ANPR are listed in these menus. Below the menu bar is
four panels: Original Image Panel, Localization Panel, Segmentation Panel and Recognition. When
ANPR is running, the result of each step will be displayed in these panels. Two bottoms in the lower
right of the software: Run and Clean, which can run the software to output the registration number
of the vehicle and clean all the changes to let the software return its original state
4
FUNCTION DESCRIPTION:
File Menu:
Open: choose an image file from a file choose dialog, this image will be displayed in the Original
Image Panel.
Pre-processing Menu:
Convert color image to grayscale: change the imported color image into grayscale image and
displays the grayscaled image in the Original Image Panel. This option is only available when an
image is imported.
Gaussian Smoothing: this option is used to smooth the imported image by removes the noises in it.
This can increase the successful rate of character recognition step.
LOCALIZATION MENU:
Edge Detection: perform the edge detection algorithm to the imported image to remove all the
other information except the edges. After perform this algorithm the edge information in the original
image that displayed in the Original Image Panel will be changed into white color and all the other
area will be changed into black.
Number Plate Isolation: separate the number plate area from the image by moving a pre-defined
slid window around in the image to find the area that contains the maximum number of white pixel,
the isolated subimage will be displayed in the Localization Panel. Because the pre-defined slid
window is usually bigger than the number plate, so the isolated area is bigger than the number plate.
This option is only available when the edge detection algorithm is performed to the image.
Number Plate Orientation and Sizing: resize the isolated number plate by remove the border around
the plate. This option is only available when number plate is isolated from the image.
5
SEGMENTATION MENU:
Image Binarization: get the sub-image from the original image as the same size and position of the
resized number plate area, convert the subimage into binary image and display it in the Localization
Panel. This option is only available after the number plate is isolated and resized.
Vertical Projection: apply vertical projection on the binary sub-image to count the number of white
pixels column by column, display the information as a curve in the Segmentation Panel..
Character Segmentation: separate binary sub-image into several parts by using the information from
vertical projection, each separated part is supposed to contains one character and all of these parts
are displayed in the Segmentation Panel.
RECOGNITION MENU:
Character Recognition: perform the character recognition algorithm onto the separated parts of the
sub-image to recognize the character contains in them, change the character into ASCII form and
display them into the Recognition Panel.
ARCHITECTURE:
Current paper presents the new flexible process-oriented architecture of an embedded ANPR
system. The system is built by set of OS processes related to the required ANPR functionalities. The
proposed architecture is developed on the base of theory of the Communicating Sequential
Processes
6
A typical architecture is when lanes are monitored with fixed positioned ANPR cameras. The passing
cars on the industrial PC which sends the recognition result, camera location, image capturing time
and an image to the central server. The central server in the up-to-date National Blacklist Database.
In case of a blacklisted car to the police cars near to the location where the image was captured. At
location 1 the architecture is different. At this point a “smart” camera is used. The number plate
reading (ANPR) function is . The camera send the plate number text, related image and timestamp to
the central server. at this location. license plates are recognized checks the license plate the server
can send an SMS or radio alert performed within the camera CPU No separate controller PC is
needed at this location.
Automatic Number Plate Recognition All-in-one solution for document reading (ANPR/LPR/ALPR):
The latest CARMEN license plate recognition software engine is able to from most countries of the
world. Container code recognition (ACCR), Dangerous Sign reading (ADR) and UIC code recognition
(railway) are additional available CARMEN abilities. ARH offers for vehicle number plate reading and
container code recognition. All camera models are equipped with a built-in infra-red illuminator unit
to in various operating environments night and day. SpeedCAM is an All-in-One solution for The unit
includes a smart camera with speed detector, ANPR processing unit and IR illuminator
7
USE CASE DIAGRAM:
Use Case Diagram for Automatic Number Plate Recognition System. Automatic Number Plate
Recognition (ANPR) is an internationally recognized methodology that is used in vehicle
identification. ANPR systems allow for real time recognition of a vehicle's number plate.
Sequence diagram:
8
sequence diagram on (ANPR) simply depicts interaction between objects in a sequential order i.e.
the order in which these interactions take place. We can also use the terms event diagrams or event
scenarios to refer to a sequence diagram. Sequence diagrams describe how and in what order the
objects in a system function
3. IMPLEMENTATION:
● MODULES DESCRIPTION:
Automatic Number plate Recognition Module – a software tool for other developers who wish
to integrate Number plate recognition to their products This solution enables to transfer by
network recognized vehicle number or directly incorporate it into a MySQL database it is also
possible to save The recognized car to full picture format most of all module features shown as a
designed video clip The license plate recognition application provides accurate license plate
identification even at high vehicle speed. The scene and license plate images from the Vector can be
transferred in real time via a cable or wireless to a local database ensuring fast, constant access to
the data which is encrypted in accordance with the latest DES and AES standards.
IMPLEMENTATION DETAILS:
9
Convert a color image into grey image:
The above algorithm shown is independent of the type of colors(RGB) in image and depends mainly
on the gray scale of an image for processing and extracting theessential data. Color
10
components like Red, Green and Blue value are not used in this algorithm. Thus, if the input image is
a colored i.e. RGB image represented by three-dimensional array in MATLAB, it is converted to a
two-dimensional gray scale image before further processing. The example of original color i.e. RGB
input image and converted gray scale image is shownbelow. So first step is conversion of color to gray
is implemented
Dilation:
image, sharpen the edges of objects and join the broken lines in an image and it also increase the
brightness of an image. Using dilation, the noise from an image can also be removed. By shaping the
edges sharper, the variation of gray value between neighboring pixels at the edge of an object can
also be improved which will help in edges detention. In Automatic Number Plate Recognition
11
Filtering out Unwanted Regions in an Image Once the histograms are passed through a low-pass
digital filter, a filter is applied to remove unwanted areas from an image. In this case, the undesirable
areas are the rows and columns with low histogram values. A low histogram value shows that the
part of image have very small amount of variations among neighboring pixels. As the probable region
with a license plate have a plain background with alphanumeric characters in the region, the
difference in the adjacent pixels, especially at the edges of characters and number plate, will be very
high. This results in a high histogram value for such part of an image. Accordingly, a region with
probable license plate has a high horizontal and vertical histogram values. We do not require the
area having less value anymore. The unwanted areas are removed from an image by applying a
dynamic threshold. In this algorithm, value for the dynamic threshold the average value of a
histogram. Now both horizontal and vertical histograms which we have calculates are passed through
a low pass filter with this dynamic threshold. The output of this process is histogram showing regions
having high possible of containing a number plate.
Segmentation:
The output of this segmentation step is all the probable regions that having maximum probability
of containing a license plate. Out of these probable regions, we want the one with the maximum
histogram value. Which will be considered as the most probable candidate for number plate. All
these regions are processed row-wise and column-wise to find a common region which is having
maximum horizontal and vertical histogram value. This is the region having highest possibility of
having a license plate.
12
Character Recognization:
Optical character recognition (OCR) is used to compare the each individual character against the
complete alphanumeric database. The OCR actually uses correlation method to match individual
character and finally the number is identified and stored in string format in a variable. The character
is then compared with the database for the vehicle authorization. The resultant signals are given
according to the result of comparison.
Black and white images are stored in MATLAB as a two dimensional array containing 1s and 0s where
0 represents black and 1 represents white. The values in a single row are all added together. If the
sum is not equal to zero, then it means that there is at least one non-zero value in the row. However,
if the sum is equal to zero, then it indicates that the row contains only zero elements. A row with all
zeroes is a row with only blank space and without any text and a row with some non-zero elements is
a row with some portion of the text. So, a row with all zeroes is removed. The group of rows between
2 eliminated rows represents a row of text. This group is extracted and passed to the next block for
extracting individual characters.
13
TEXT OUTPUT:
The character from the templates file that gives the highest correlation is the extracted character and
it is written into a text file. Table no shows the output value and their respective characters Figure
shows the text output of segmented characters
Tools used:
For reliable number plate detection and recognition, ensure that your system meets the following:
Camera:
Micro Focus recommends a separate camera for each lane of traffic. If you use a single camera for
several lanes of traffic, high-definition recording is required (1080p or better).
Image contrast:
The contrast must be sufficient for the number plates to be human-readable. If you are reading
retroreflective number plates, the best results are obtained with infra-red (IR) illumination.
The number plates must be human-readable and characters in the video must not be less than 10
pixels high.
14
Position the camera above the traffic, so that number plates appear to be horizontal. The closer the
plates are to horizontal, the better the performance.
Media Server improves accuracy by reading number plates across multiple frames. For moving traffic
Media Server requires 25 or 30 frames per second. Do not reduce the frame rate of the captured
video.
4. TEST RESULTS/EXPERIMENTS/VERIFICATION:
● Testing :
● Imports:
For this project we need numpy and pillow python libraries with openCV and pytesseract
Now we will define three functions, to find the unnecessary contours that openCV may identify
but it does not have probability of being a number plate.
● The first function to check the area range and width-height ratio:
15
● The second function to check average of image matrix:
16
Now we will write a function to clean the identified number plate for preprocessing before feeding
to pytesseract:
17
In this step, we will take an image input. We will perform Gaussian Blur, Sobel and morphological
operations. After we find contours in the image and loop through each contour to identify the
number plate. We will then clean the image contour and feed it to pytesseract to recognize the
number and characters.
img = cv2.imread("testData/sample15.jpg")
cv2.imshow("input",img)
pass
img2 = cv2.Sobel(img2,cv2.CV_8U,1,0,ksize=3)
_,img2 = cv2.threshold(img2,0,255,cv2.THRESH_BINARY+cv2.THRESH_OTSU)
morph_img_threshold = img2.copy()
dst=morph_img_threshold)
num_contours, hierarchy=
cv2.findContours(morph_img_threshold,mode=cv2.RETR_EXTERNAL,method=cv2.CHAIN_
APPROX_NONE)
min_rect = cv2.minAreaRect(cnt)
if ratio_and_rotation(min_rect):
x,y,w,h = cv2.boundingRect(cnt)
plate_img = img[y:y+h,x:x+w]
18
pass
if(isMaxWhite(plate_img)):
if rect:
fg=0
x1,y1,w1,h1 = rect
x,y,w,h = x+x1,y+y1,w1,h1
# cv2.imwrite("clena.png",clean_plate)
plate_im = Image.fromarray(clean_plate)
19
Make a new file gui.py and paste the below code:
import tkinter as tk
import numpy as np
import cv2
def clean2_plate(plate):
num_contours,hierarchy = cv2.findContours(thresh.copy(),cv2.RETR_EXTERNAL,
cv2.CHAIN_APPROX_NONE)
if num_contours:
20
contour_area = [cv2.contourArea(c) for c in num_contours]
max_cntr_index = np.argmax(contour_area)
max_cnt = num_contours[max_cntr_index]
max_cntArea = contour_area[max_cntr_index]
x,y,w,h = cv2.boundingRect(max_cnt)
if not ratioCheck(max_cntArea,w,h):
return plate,None
return final_img,[x,y,w,h]
else:
return plate,None
if ratio < 1:
ratio = 1 / ratio
if (area < 1063.62 or area > 73862.5) or (ratio < 3 or ratio > 6):
return False
return True
def isMaxWhite(plate):
avg = np.mean(plate)
if(avg>=115):
return True
else:
return False
def ratio_and_rotation(rect):
if(width>height):
21
angle = -rect_angle
else:
angle = 90 + rect_angle
if angle>15:
return False
if height == 0 or width == 0:
return False
area = height*width
if not ratioCheck(area,width,height):
return False
else:
return True
top=tk.Tk()
top.geometry('900x700')
top.iconphoto(True, PhotoImage(file="/home/shivam/Dataflair/Keras
Projects_CIFAR/GUI/logo.png"))
Page 38 of 42
img = ImageTk.PhotoImage(Image.open("logo.png"))
top.configure(background='#CDCDCD')
label=Label(top,background='#CDCDCD', font=('arial',35,'bold'))
# label.grid(row=0,column=1)
sign_image = Label(top,bd=10)
plate_image=Label(top,bd=10)
def classify(file_path):
res_text=[0]
res_img=[0]
22
img = cv2.imread(file_path)
img2 = cv2.Sobel(img2,cv2.CV_8U,1,0,ksize=3)
_,img2 = cv2.threshold(img2,0,255,cv2.THRESH_BINARY+cv2.THRESH_OTSU)
morph_img_threshold = img2.copy()
dst=morph_img_threshold)
num_contours, hierarchy=
cv2.findContours(morph_img_threshold,mode=cv2.RETR_EXTERNAL,method=cv2.CHAIN_APP
ROX_NONE)
min_rect = cv2.minAreaRect(cnt)
if ratio_and_rotation(min_rect):
x,y,w,h = cv2.boundingRect(cnt)
plate_img = img[y:y+h,x:x+w]
res_img[0]=plate_img
cv2.imwrite("result.png",plate_img)
if(isMaxWhite(plate_img)):
if rect:
fg=0
x1,y1,w1,h1 = rect
x,y,w,h = x+x1,y+y1,w1,h1
23
plate_im = Image.fromarray(clean_plate)
res_text[0]=text
if text:
break
label.configure(foreground='#011638', text=res_text[0])
uploaded=Image.open("result.png")
im=ImageTk.PhotoImage(uploaded)
plate_image.configure(image=im)
plate_image.image=im
plate_image.pack()
plate_image.place(x=560,y=320)
def show_classify_button(file_path):
classify_b=Button(top,text="Classify Image",command=lambda:
classify(file_path),padx=10,pady=5)
classify_b.configure(background='#364156', foreground='white',font=('arial',15,'bold'))
classify_b.place(x=490,y=550)
def upload_image():
try:
file_path=filedialog.askopenfilename()
uploaded=Image.open(file_path)
uploaded.thumbnail(((top.winfo_width()/2.25),(top.winfo_height()/2.25)))
im=ImageTk.PhotoImage(uploaded)
sign_image.configure(image=im)
sign_image.image=im
label.configure(text='')
show_classify_button(file_path)
24
except:
pass
upload=Button(top,text="Upload an image",command=upload_image,padx=10,pady=5)
upload.configure(background='#364156', foreground='white',font=('arial',15,'bold'))
upload.pack()
upload.place(x=210,y=550)
sign_image.pack()
sign_image.place(x=70,y=200)
label.pack()
label.place(x=500,y=220)
heading = Label(top,image=img)
heading.configure(background='#CDCDCD',foreground='#364156')
heading.pack()
top.mainloop()
RESULT:
The resulting image is shown below. Normally added to cropping the image, we can also gray it
and edge it if required. This is done to improve the character recognition in next step. However I
VERIFICATION:
25
As you can see, our program was able to detect the license plate correctly and crop it. But the
teserract library has failed to recognize the characters properly. Instead of the actual “MH 20 EE
7598” the OCR has recognized it to be “MH20 EE 7598”. Problems like this can be corrected by either
using better orientation images or by configuring the Tesseract engine.
5.Conclusion:
In this paper the development of an automatic parking system with license plate recognition, parking
lots status and guidance parking system and electronic billing system is successfully implemented.
The performance of the developed of algorithms for License Plate Localization and License Plate.
Recognition is acceptable range. The developed algorithms accurately localize and recognize in
different location of the license plate. Electronic billing system performance is also acceptable and
recommended for commercial use .
References:
[1] Feng Yang, Zheng Ma “Vehicle License Plate location Based on Histogramming and Mathematical
Morphology “, 2005.
[2] Tran Duc Duan, Duong Anh Duc, Tran Le Hong Du “Combining Hough Transform and Contour
Algorithm for detecting Vehicles. License-Plates”, October 2004
[3] Tran Duc Duan, Tran Le Hong Du, Tran Vinh Phuoc, Nguyen Viet Hoang Building an Automatic
Vehicle License-Plate Recognition System “, Febraury 2005
[4] CheokMan, Kengchung “A High Accurate Macau License Plate Recognition System”, 2008
[5] R Thuy Tuong Nguyen, Xuan Dai Pham and Jae Wook Jeon”Rectangular Object Tracking Based on
Standard Hough Transform “, February, 2009
[6] Yungang Zhang Changshui Zhang “A New Algorithm for Character Segmentation of License Plate”,
June 2003
26