0% found this document useful (0 votes)
8 views41 pages

Community c Report File (1)[1]

The report on 'Automatic Number Plate Detection' by Faraz Imtiyaz Mir and Nibbritta Niloy Sarker outlines a system for recognizing vehicle license plates using image processing techniques. It details the methodology involving image pre-processing, character segmentation, and Optical Character Recognition (OCR) to efficiently identify and track vehicles, particularly for security purposes. The project is supervised by Dr. Yojna Arora and aims to address challenges in recognizing non-standard Indian license plates.

Uploaded by

Mir Faraz.M
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views41 pages

Community c Report File (1)[1]

The report on 'Automatic Number Plate Detection' by Faraz Imtiyaz Mir and Nibbritta Niloy Sarker outlines a system for recognizing vehicle license plates using image processing techniques. It details the methodology involving image pre-processing, character segmentation, and Optical Character Recognition (OCR) to efficiently identify and track vehicles, particularly for security purposes. The project is supervised by Dr. Yojna Arora and aims to address challenges in recognizing non-standard Indian license plates.

Uploaded by

Mir Faraz.M
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 41

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING,

SCHOOL OF ENGINEERING & TECHNOLOGY,

SHARDA UNIVERSITY, GREATER NOIDA

COMMUNITY CONNECT REPORT

On

AUTOMATIC NUMBER PLATE


DETECTION

By

Faraz Imtiyaz Mir (2023471971)

Nibbritta Niloy Sarker (2021489693)

Supervised by:

Dr. YOJNA ARORA, Assoc. Prof (CSE)


April, 2024
CERTIFICATE

This is to certify that the report entitled “Automatic Number Plate Detection” submitted
by “Ms. Faraz Imtiyaz Mir (2023471971), Mr. Nibbritta Niloy Sarker (2023847142)” to
Sharda University, towards the fulfillment of requirements of the degree of “Masters of Technology” is
record of bonafide community connect work carried out by him in the “Department of Computer Science
and Engineering, School of Engineering and Technology, Sharda University”.

The results/findings contained in this Project have not been submitted in part or full to
any other University/Institute for award of any other Degree/Diploma.

Signature of Supervisor Signature of Co-supervisor

Name: Dr. Yojna Arora Name: Mr.

Designation: Assoc. Prof (CSE) Designation: Asst. Professor


(CSE)

Signature of External Examiner

DATE
ACKNOWLEDGEMENT

A major project is a golden opportunity for learning and self- development. We


consider our self very lucky and honored to have so many wonderful people lead us
through in completion of this project.

First and foremost, we would like to thank PROF. (DR.) SANJEEV KUMAR
PIPPAL, HOD, CSE who gave us an opportunity to undertake this project.

My grateful thanks to DR. YOJNA ARORA for their guidance in our project
work.

DR. YOJNA ARORA, who in spite of being extraordinarily busy with academics,
took time out to hear, guide and keep us on the correct path. We do not know where
we would have been without her help.

CSE department monitored our progress and arranged all facilities to make life
easier. We choose this moment to acknowledge their contribution gratefully.

Name and signature of Students:

Faraz Imtiyaz Mir (2023471971)

Nibbritta Niloy Sarker (2021489693)


ABSTRACT

Automatic Number Plate Recognition (ANPR) is a mass surveillance system that


captures the image of vehicles and recognizes their license numbers. ANPR can be used
in the detection of stolen vehicles. The detection of stolen vehicles can be done in an
efficient manner by using the ANPD systems located in the highways. This method
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. An image of a
vehicle is captured and processed using image pre-processing algorithm. In this context,
the number plate area is localized using edge detection method and the characters
acquired are segmented using segmentation method. The segmented characters are passed
to Optical character reader (OCR) which gives exact characters of the number plate and
are stored in database. The image pre-processing is done using Gaussian Blur method,
conversion of RGB (Red, Green, Blue) to grayscale, Edge detection using sobel followed
by contour detection and license plate is extracted. OCR is run on the Region of Interest
(ROI) given by the contour analysis. The OCR provides the vehicle’s number obtained
from the number plate and is stored in the database which is used for surveillance and
tracking vehicle’s location. The software used in the process is Python version 3 and
different python libraries like Tesseract OCR, OpenCV
TABLE OF CONTENTS
CHAPTER TITLE OF THE CHAPTER PAGE
NO. NO.
ABSTRACT iv
LIST OF FIGURES vii
LIST OF ABBREVIATIONS viii

1 INTRODUCTION 1
1.1 OVERVIEW 1
1.2 NEED FOR THE PROJECT 2
1.3 OBJECTIVE 2
1.4 CHALLENGES 2
1.5 ORGANISATION OF THE REPORT 3
2 LITERATURE SURVEY 4
2.1 ANPR 4
2.2 OCR 4
2.3 FUSION TECHINQUE 5
2.4 ALPR 6
2.5 REGION BASED CNN 6
2.6 INFERENCE FROM LITERATURE SURVEY 7
3 SYSTEM DESIGN 8

3.1 PROPOSED SYSTEM MODEL 8


3.2 IMAGE PRE-PROCESSING 9

3.3 NUMBER PLATE EXTRACTION 12

3.4 NUMBER PLATE RECOGNITION 14

3.5 CHARACTER SEGMENTATION 14

3.6 NUMBER PLATE TEXT RECOGNITION 15


3.7 SUMMARY 15
4 DATABASE AND USER INTERFACE 16

4.1 DATABASE AND DESIGN 16


4.2 USER INTERFACE 16
4.3 SUMMARY 18
5 CONCLUSION AND FUTURE SCOPE 19
5.1 CONCLUSIONS 19
5.2 FUTURE SCOPE 19
REFERENCES 20
APPENDIX 21
A1 SOURCE CODE 21
A2 PLAGIARISM REPORT 35
CHAPTER 1

INTRODUCTION

This chapter discusses the overview of the Automatic number plate recognition system. The
need and objectives with the overview of techniques used are mentioned.
1.1 OVERVIEW
License Plate Recognition is an image processing system that recognizes the car using the number
plate. With the use of the vehicle number plate, the aim is to design, an effective automatic approved
vehicle identification system. The system is introduced for surveillance and safety monitoring at
various regions, such as colleges, housing areas and public places.
Organization or even individual may use this system for security purposes. Real time image of the
vehicle's number plate is captured and is stored in data base. If there is a need to know the details of
any car, it can be traced through processing license plate image.
The developed device senses the vehicle and captures the picture of the vehicle. By segmenting the
picture into an image, the region of the vehicle number plate is extracted. The Optical Character
Recognition Technique (OCR) is used for character recognition. The resulting data can be used to
compare the records on a database to provide unique information such as the location of the car.
In several nations, such as Australia, Canada and South Korea, license plate recognition programs
have been introduced. The early development of license plate recognition systems has been assisted
by the stringent enforcement of license plate requirements in these countries. These systems use
traditional license plate features such as plate height, plate boundary, character color, and font, etc.
These systems help to accurately find the number plate and recognize the vehicle's license number.
In terms of font styles, script, scale, location, and color of the number of plates, large variations are
found. In a few instances, the number plate includes other unwelcome decorations amidst vehicle
number plates in India.

1
The overall goal of this research is to establish an Indian License Plate Identification deployable
working method, which is a difficult challenge since there is no uniformity of the Indian License
Plates since each state has followed its own design and structure. In addition to the challenges found
by the General License Plate Recognition Algorithms, the Indian Algorithms for License Plate
Recognition need to fix some complex problems.

1.2 NEEDFORTHEPROJECT
 ANPR (Automatic number plate recognition system) has a wide range of
applications since the license number is the primary and most widely accepted
identifier of motor vehicles.Access Control License plate recognition brings
automation of vehicle access control management providing increased security.
 Monitoring and Surveillancecan be used to monitor vehicles near important
areas for better security. To provide to the conventional system to monitor
stolen vehicles.

1.3 OBJECTIVES

 To design an efficient automatic authorized vehicle identification system by using the


vehicle number plate for surveillance in different scenarios.
 To provide efficient system to locate stolen vehicles using public surveillance cameras.

1.4 CHALLENGES
 Dealing with bright and dark objects: Many details present in an RGB image become less
salient when we convert it into grayscale. To visualize the change in intensity and thus to
deal with bright and dark objects in the image, converting it to grayscale works best.
 Dealing with noisy images: The image is convolved with a Gaussian filter in the pre-
processing stage to reduce the noise present in the image.

2
 Dealing with cross-angled or skewed number plates :De-skewing, i.e. rotating the image to
the required position can be done to detect the text present on the number plate.
 Dealing with non-standard number plates: The code we implemented won’t give any results
in case of non-standard/partially torn number plates. Hence, they won’t be stored in the
database and searching is not possible on it

1.5 ORGANIZATION OF THE REPORT

The rest of the report is organized as follows. Chapter 2 discusses the related worksand
presents their Pros and Cons. Chapter 3 discusses the system model and working of the system.
Chapter 4 discusses the database design and user interface. Chapter 5 discusses about the conclusion
and future scope of the system.

3
CHAPTER 2

LITERATURE SURVEY

This chapter gives an overview of research carried out related to theprojectwork on


“Automatic Number plate Recognition”. It provides the idea to use different algorithms in an
efficient manner and helps to improve the accuracy of the system.

2.1 ANPR
Monica Khinchi and Chanchal Aggarwal,2016,discussedAutomatic Number plate
Recognition and stated its importance in today’s world. Automatic Number Plate Recognition
(ANPR) was first discovered by UK police in 1976. This technology is gaining popularity in
the last decade. ANPR system identifies vehicle number plate. It has a camera that takes a
picture, searches the position of the number plate and then identifies the features of characters
using character detection methods. Another name forthe ANPR system is vehicle number plate
detection, license plate tracking, etc.

An automatic number plate detection system is used in parking management and use for
security purposes. The ANPR system has the following steps: Vehicle image capture, Pre-
processing, Extraction of the number plate, Character segmentationand character recognition.

2.2 OCR
Rishabh Mittal and AnchalGarg, presenteda survey on Optical Character Recognition
systems.Optical Character Recognition (OCR) is the computerized conversion of text or making
a digital copy of the text through sources like handwritten documents, printed text, or natural
images.DIP is the process in which digital images are processed through a computer algorithm
DIP is a field that has applications in pretty much every other field like in the Healthcare

4
division for PET sweeps, Banking segment, Robotics, and so forth and is yet developing with
time. One of its major applications is pattern recognition which includes computer-aided
diagnoses, handwriting recognition, and image recognition.
The need for text recognition software came because the amount of data in the world is
growing at an exponential rate. All this data cannot be stored physically and hence need to
preserve digitally. Thus, it is done using Automatic Character Recognition, which utilizes
OCR. OCR frameworks are these days normally used to extract text content from any
computerized picture or natural image.

2.3 FUSION TECHNIQUE


Farheen Ali, et al., 2013 have presented to improve the quality of the vehicles, the
image fusion technique is used for the extraction of the license plate and isolating the characters
which are present on the number plate and identifying the characters on the license plate using
artificial neural network. License Plate Recognition is an image processing system that
recognizes the car using the number plate. With the use of the vehicle number plate, the aim is
to design, and effective automatic approved vehicle identification system. The system is
introduced for safety monitoring at the entry to a highly confined region, such as combat zones
and public areas.

By segmenting the picture into an image, the region of the vehicle number plate is
extracted. The Optical Character Recognition Technique (OCR) is used for character
recognition. The resulting data is then used to compare the records on a database to provide
unique information such as the identity of the owner, registration location, address, etc. The
framework is implemented and simulated in Java, and it is tested on actual picture results.

5
2.4 ALPR

AnumolSasi and Swapnil Sharma presented a review by categorizing different


techniques used in Automatic License Plate Recognition (ALPR) according to the features these
techniques used in each stage. The author suggests recognition of plates with different styles,
multiple plates and recognizing characters with ambiguity as to the future area of research in
ALPR. The paper implements AS (Autonomous System) to solve various problems like
Travelling Salesman Problem, Quadratic Assignment and Job Shop Scheduling. It proposes an
ACO-based edge detection approach by exploiting Ant Colony System.

The performance of this approach is proved to be better than that discussed earlier
which is obtained by exploiting Ant System. The system proposes a weighted heuristic ACO
algorithm. The proposed approach provides better accuracy by setting weights to the intensities
of neighboring pixels. This is very well exploited by the ants. which move continuously over
the image.

2.5 REGION BASED CNN

N Palanivel , T Vigneshwaran, R Madhanraj and N Srivarappradhan presented work on


Vehicle license plate detection using region-based convolutional neural networks.Automatic
number plate detection is a well hot topic in the machine learning and image processing
domains. This number plate detection is applied on the surveillance camera in the traffic areas.
This system is used to increase the accuracy of the detection of the number plate over manual
conditions. The core area of this system is frame separation from the input video to convert to
an image and then techniques like image segmentation, image interpolation and OCR are
applied to the image to get the information about the number plate in that image. Some of the
important factors in number plate detection are frame separation and feature extraction.

It is very difficult in handling in varying lighting conditions. So non-parametric models


based on the kernel density estimation is used. Hoffmann-based model is used which is by
assigning adaptive randomness of parameters.
6
The principal component analysis is a powerful method in background separation.

2.6 INFERENCE FROM LITERATURE SURVEY

The process of ANPR is primarily divided into Image Acquisition, imagepre-processing,


segmentation, feature extraction, and classification. Steps performed in image pre-processing are
Gaussian blur, thresholding, grey scaling, Sobel edge and morphology. Feature extraction primarily
depends on proper contour analysis which is then followed by classification of the characters
extracted from ROI (Region Of Interest). OCR capabilities have improved over the years but
however,but there are still limitations on the accuracy and performance of images with a higher
percentage of noise.

7
CHAPTER 3

SYSTEM DESIGN

This chapter discusses the proposed system model and working principle of the system. The
methodologies include Gaussian blur, grey-scaling, Sobel edge, morphological transformation, and
counter detection.

3.1 PROPOSED SYSTEM MODEL

Fig 3.1 depicts a block diagram of the system. It provides an overview of image pre-
processing techniques and the storage of data in the database after successful character recognition
using OCR. The data can be fetched by a user through a Graphics User Interface provided in order
to view the data.

Fig 3.1– Proposed system model

8
3.2 IMAGE PRE-PROCESSING
Fig 3.1 depicts a custom RGB image taken to explain different phases of image Pre-
Processing.

Fig 3.2- RGB image

 Noise reduction: The objective of Gaussian filtering/ Gaussian smoothing is to reduce noise
and detail. This will serve well for further image processing steps. Fig 3.2 depicts the image
after applying Gaussian filtering. The input image is made to convolve with this 2-D ‘G’
matrix to obtain a smoothened image in OpenCV.

9
Fig 3.3 – Image after Gaussian filtering

 RGB to Grayscale conversion: Converting RGB image to grayscale saves a lot of time since
convolution is performed with the image with Sobel filter over only one 2D matrix rather than
RGB image having 3 dimensions and making it complicated. Another reason is, that in the case
of image edge detection the focus is on the intensity change and it is easier to analyze it in a
gray-scaled image.
Fig 3.3 depicts the conversion of RGB to grayscale in order to make the image into a 2D Matrix
which is convenient to use for further processing.

 Edge detection using the Sobel method: Sobel edge detection works by calculating the gradient
of image intensity at each pixel within the image. It finds the direction of the largest increase
from light to dark and the rate of change in that direction. :Fig 3.4 depicts the Sobel Edge result
after being converted to grayscale.

10
Fig 3.4 – Grayscale image

Fig 3.5 – Sobel Edge detection


11
 Morphological transformation:Top-hat and Black-hat filters are part of Morphological
transformations. The Top-hat operation is used to enhance bright objects of interest in a
relatively dark background, while the black-hat operation (also known as bottom-hat) is used
to enhance dark objects of interest in a relatively bright background. In this work, top-hat
results are added to the original image and black-hat results are subtracted from it.Fig 3.5
depicts the morphological Transformation of the image after Sobel edge detection.

Fig 3.6 – Morphological transformation

3.3 NUMBER PLATE EXTRACTON


Apply Counters: Contour Tracing, also called Border following is the algorithm used for generating
Contours. A contour is a link of equal intensity points along the boundary. In OpenCV, finding
contours is like finding a white object from a black background, therefore during the Adaptive
Gaussian Thresholding stage, the inversion operation has to be applied. Fig 3.6 depicts the counters
drawn around the number

12
plate of the car for further processing and extraction of number plate.

Fig 3.7 - Apply Counters

Filter Contours and extract region of interest: For small regions, especially sharp edges and noise
outliers, contours are applied. A human eye can easily figure out that such contours are unnecessary,
but this must be incorporated into a program. Initially, Bounding boxes were applied to each
contour. Then, for each contour, the factors such as minimum contour area, minimum contour width
and height, minimum and maximum possible aspect ratios are considered. This resulted in the
filtering of most of the unnecessary contours, propelling us near to the objective, ie, detect number
plate. Fig 3.7 depicts the extracted region of interest which was successfully extracted after image
Pre-Processing and counter detection.

13
Fig 3.8 – Region of interest

3.4 NUMBER PLATE RECOGNITION

 Number plate de-skewing: Skew is the amount of rotation necessary to return an image to
horizontal and vertical alignment. Skew is measured in degrees. Deskewing is a process
whereby skew is removed by rotating an image by the same amount as its skew but in the
opposite direction. This results in a horizontally and vertically aligned image where the text
runs across the page rather than at an angle. In our project, this step is done using
ratio_and_rotation().

 Pre-process region of interest: It is possible that two or more contours may completely
overlap with each other, as in the case with the number ‘zero’. The inner contour, if detected
in the contour process, may lie completely inside its outer contour. Due to this phenomenon,
both contours may get recognized as separate characters during the recognition process. If
needed, imageis resized before doing the recognition step.

3.5 CHARACTER SEGMENTATION


The objective of character segmentation method is to separate each letter and extract the
character and left the other unwanted components. The use of this method is to decide the outline of
character in image.

14
3.6 NUMBER PLATE TEXT RECOGNITION
Python-tesseract is an optical character recognition (OCR) tool for python. That is, it will
recognize and “read” the text embedded in images. Hence this tool is used to obtain the text present
in the filtered, de-skewed contour.

3.7 SUMMARY
A step by step methodology is given to Pre-process the image and extract the number plate
from the rest of the image and successful application of OCR on the extracted area to recognize
characters is done.

15
CHAPTER 4

DATABASE AND USER INTERFACE

This chapter discusses the database used to store the extracted information and the different
database fields that are used in the server.

4.1 DATABASE AND DESIGN:

The table designed for storing the number plates is of the following schema:

Fig 4.1- Database overview

Fig 4.1 depicts the database is connected to python using mysql.connector module, the
connection is established between the server and the database. The fields created in the database are
car number, location and timestamp.

4.2 USER INTERFACE

The Frontend is designed using HTML/CSS with bootstrap used as a framework for the
design,

16
Fig 4.2 and Fig 4.3 shows the web pages for the web portal. It consists of three fields for
searching the details of vehicles that are given to fetch the following details of the desired vehicle.
 number plate
 timestamp
 location

Fig 4.2- Frontend index page

17
Fig 4.3 – Searching by location

4.3 SUMMARY

A custom dataset of random images is used to check the efficiency and accuracy of the
system. The user will be able to search according to any of the three fields which are Number plate,
location and timestamp. The details of number plates are continuously appended in the database
when OCR is run on the dataset according to the time of the entry. The location details are also
attached to along with the timestamp.

18
CHAPTER 5

CONCLUSION AND FUTURESCOPE

5.1 CONCLUSION

A method to recognize the number plates of Indian vehicle number plates is proposed which
is less time consuming and applied to various types of pictures. Edges could be recognized through
the use of the SOBEL edge detection method. To retrieve the vehicle's number plate,ROI and OCR
is applied. The proposed system is mainly based on the Indian car number plate scheme, the
accuracy of extracting the number plate for low light images can be increased, as well as the number
plate that has different font size and also different font type can be recognized.

5.2 FUTURESCOPE

The future scope is that the automatic vehicle recognition system plays a major role in
detecting threats to defense also it can improve the security related to women as they can easily
detect the number plate before using a cab or other services. The system robustness can be
increased if a brighter and sharper camera is used withproper installation.

19
REFRENCES

1. M. Khinchi and C. Agarwal, "A Review on Automatic Number Plate Recognition Technology
and Methods",in the proc. of International Conference on Intelligent Sustainable Systems
(ICISS), 2019, pp. 363-366, doi: 10.1109/ISS1.2019.8908014.

2. Sasi, S. Sharma and A. N. Cheeran, "Automatic car number plate recognition",in the proc. of
International Conference on Innovations in Information, Embedded and Communication
Systems (ICIIECS), 2017, pp. 1-6, doi: 10.1109/ICIIECS.2017.8275893.

3. R. Mittal and A. Garg, "Text extraction using OCR: A Systematic Review",in the proc. of
Second International Conference on Inventive Research in Computing Applications
(ICIRCA), 2020, pp. 357-362, doi: 10.1109/ICIRCA48905.2020.9183326.

4. F. Ali, H. Rathor and W. Akram, "License Plate Recognition System",in the proc. of
International Conference on Advance Computing and Innovative Technologies in Engineering
(ICACITE), 2021, pp.1053-1055, doi: 10.1109/ICACITE51222.2021.9404706.

5. N. P. Ap, T. Vigneshwaran, M. S. Arappradhan and R. Madhanraj, "Automatic Number Plate


Detection in Vehicles using Faster R-CNN",in the proc. of International Conference on
System, Computation, Automation and Networking (ICSCAN), 2020, pp. 1-6, doi:
10.1109/ICSCAN49426.2020.9262400.

6. Ap, N. P. et al. (2020) “Automatic number plate detection in vehicles using faster R-CNN,”
in 2020 International Conference on System, Computation, Automation and Networking
(ICSCAN). IEEE.

7. Lubna, Naveed Mufti, and Syed Afaq Ali Shah. "Automatic number plate Recognition: A
detailed survey of relevant algorithms." Sensors 21.9 (2021): 3028.

8. Gnanaprakash, V., N. Kanthimathi, and N. Saranya. "Automatic number plate recognition


using deep learning." IOP Conference series: materials science and engineering. Vol. 1084.
No. 1. IOP Publishing, 2021.

9. Tang, Junqing, et al. "Automatic number plate recognition (ANPR) in smart cities: A
systematic review on technological advancements and application cases." Cities 129 (2022):
103833.

10. Kumar, JMSV Ravi, B. Sujatha, and N. Leelavathi. "Automatic vehicle number plate
recognition system using machine learning." IOP Conference Series: Materials Science and
Engineering. Vol. 1074. No. 1. IOP Publishing, 2021.

11. Shashirangana, Jithmi, et al. "Automated license plate recognition: a survey on methods and
techniques." IEEE Access 9 (2020): 11203-11225.

12. Ap, N. Palanivel, et al. "Automatic number plate detection in vehicles using faster R-CNN."
2020 International conference on system, computation, automation and networking
(ICSCAN). IEEE, 2020.

13. Chandra, B. Mouli, et al. "Recognition of vehicle number plate using Matlab." J. Univ.
Shanghai Sci. Technol 23.2 (2021): 363-370.
14. Kaur, Parneet, et al. "Automatic License Plate Recognition System for Vehicles Using a
CNN." Computers, Materials & Continua 71.1 (2022).

15. Alam, Nur-A., et al. "Intelligent system for vehicles number plate detection and recognition
using convolutional neural networks." Technologies 9.1 (2021): 9.

16. Hadavi, Sheida, et al. "Analyzing passenger and freight vehicle movements from automatic-
Number plate recognition camera data." European Transport Research Review 12 (2020): 1-
17.

17. Wang, Yi, et al. "Rethinking and designing a high-performing automatic license plate
recognition approach." IEEE transactions on intelligent transportation systems 23.7 (2021):
8868-8880.

18. Silva, Sergio M., and Cláudio Rosito Jung. "A flexible approach for automatic license plate
recognition in unconstrained scenarios." IEEE Transactions on Intelligent Transportation
Systems 23.6 (2021): 5693-5703.

19. Henry, Chris, Sung Yoon Ahn, and Sang-Woong Lee. "Multinational license plate recognition
using generalized character sequence detection." IEEE Access 8 (2020): 35185-35199.

20. Izidio, Diogo MF, et al. "An embedded automatic license plate recognition system using deep
learning." Design Automation for Embedded Systems 24.1 (2020): 23-43.

21. Kukreja, Vinay, Deepak Kumar, and Amandeep Kaur. "GAN-based synthetic data
augmentation for increased CNN performance in Vehicle Number Plate Recognition." 2020
4th international conference on electronics, communication and aerospace technology
(ICECA). IEEE, 2020.

22. Hamdi, Abdelsalam, Yee Kit Chan, and Voon Chet Koo. "A New Image Enhancement and
Super Resolution technique for license plate recognition." Heliyon 7.11 (2021).

23. Castro‐Zunti, Riel D., Juan Yépez, and Seok‐Bum Ko. "License plate segmentation and
recognition system using deep learning and OpenVINO." IET Intelligent Transport Systems
14.2 (2020): 119-126.

24. Tu, Chunling, and Shengzhi Du. "A hierarchical RCNN for vehicle and vehicle license plate
detection and recognition." International Journal of Electrical and Computer Engineering 12.1
(2022): 731.

25. Salau, Ayodeji Olalekan, Thomas Kokumo Yesufu, and Babatunde Sunday Ogundare.
"Vehicle plate number localization using a modified GrabCut algorithm." Journal of King
Saud University-Computer and Information Sciences 33.4 (2021): 399-407.

26. Laroca, Rayson, et al. "On the cross-dataset generalization in license plate recognition." arXiv
preprint arXiv:2201.00267 (2022).

20
APPENDIX A1

SOURCE CODE
SOURCE CODE FOR READING NUMBER PLATE
from flask import Flask, render_template, jsonify import
mysql.connector
from datetime import datetime
from time import gmtime, strftime
import random
from image_config import IMAGE_CONFIGS import
cv2
import numpy as np
from PIL import Image
import pytesseract
import re
from pytz import timezone

LOCATIONS = ['CIT','Airport','Hopes','Gandhipuram','KTC','PSG',"IIM",'Aqfer']

app = Flask(__name__)

def number_plate_detection(image):
img=cv2.imread('static/images'+image) img
= cv2.resize(img, (600, 600))
def clean2_plate(plate):
gray_img = cv2.cvtColor(plate, cv2.COLOR_BGR2GRAY)

_, thresh = cv2.threshold(gray_img, 110, 255, cv2.THRESH_BINARY)


if cv2.waitKey(0) & 0xff == ord('q'):
pass
num_contours,hierarchy =
cv2.findContours(thresh.copy(),cv2.RETR_EXTERNAL,
cv2.CHAIN_APPROX_NONE)

if num_contours:
contour_area = [cv2.contourArea(c) for c in num_contours]
max_cntr_index = np.argmax(contour_area)

max_cnt = num_contours[max_cntr_index]

21
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

final_img = thresh[y:y+h, x:x+w]


return final_img,[x,y,w,h]

else:
return plate,None

def ratioCheck(area, width, height):

ratio = float(width) / float(height)


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):
(x, y), (width, height), rect_angle = rect

if(width>height):
angle = -rect_angle
else:
angle = 90 + rect_angle

if angle>15:
return False

if height == 0 or width == 0:
return False

area = height*width
22
if not ratioCheck(area,width,height):
return False
else:
return True

img2 = cv2.GaussianBlur(img, (5,5), 0)


img2 = cv2.cvtColor(img2, cv2.COLOR_BGR2GRAY)

img2 = cv2.Sobel(img2,cv2.CV_8U,1,0,ksize=3)
_,img2 =
cv2.threshold(img2,0,255,cv2.THRESH_BINARY+cv2.THRESH_OTSU)

element = cv2.getStructuringElement(shape=cv2.MORPH_RECT, ksize=(17, 3))


morph_img_threshold = img2.copy()
cv2.morphologyEx(src=img2, op=cv2.MORPH_CLOSE, kernel=element,
dst=morph_img_threshold)
num_contours, hierarchy=
cv2.findContours(morph_img_threshold,mode=cv2.RETR_EXTERNAL,method=cv2
.CHAIN_APPROX_NONE)
cv2.drawContours(img2, num_contours, -1, (0,255,0), 1)
#cv2.imshow("Contours",img2)
#cv2.waitKey(0)
gray = cv2.GaussianBlur(img, (5,5), 0)

# gray = cv2.cvtColor(gray, cv2.COLOR_BGR2GRAY)


bw_img = cv2.threshold(gray, 127, 255, cv2.THRESH_BINARY)
edged = cv2.Canny(gray, 30, 200)
num_contours, hierarchy=
cv2.findContours(edged,mode=cv2.RETR_EXTERNAL,method=cv2.CHAIN_APPR
OX_NONE)
cv2.drawContours(img, num_contours, -1, (0,255,0), 1)
#cv2.imshow('image',edged)
#cv2.waitKey(0)
cnts,new = cv2.findContours(edged.copy(), cv2.RETR_LIST,
cv2.CHAIN_APPROX_SIMPLE)
image1=img.copy()
cv2.drawContours(image1,cnts,-1,(0,255,0),3)
# cv2.imshow("contours",bw_img)
# cv2.waitKey(0)

for i,cnt in enumerate(num_contours):


min_rect = cv2.minAreaRect(cnt)
if ratio_and_rotation(min_rect):
23
x,y,w,h = cv2.boundingRect(cnt)
# print(x,y,w,h)
plate_img = img[y:y+h,x:x+w]
if(isMaxWhite(plate_img)):
clean_plate, rect = clean2_plate(plate_img)
if rect:
fg=0
x1,y1,w1,h1 = rect
x,y,w,h = x+x1,y+y1,w1,h1
plate_im = Image.fromarray(clean_plate)
# cv2.imshow('image',plate_img)
# cv2.waitKey(0)

text = pytesseract.image_to_string(plate_im, lang='eng')


mydb_add = mysql.connector.connect(
host="localhost",
user="root",
password="Sherjeel@123",
db = "mini_project_database",
autocommit=True
)

mycursor = mydb_add.cursor()
mycursor.execute('insert into captured_data (car_number, time, location)
values("{}", "{}","{}");'.format(text,strftime("%Y-%m-%d %H:%M:%S",
gmtime()),random.choice(LOCATIONS)))
mycursor.close()

@app.route("/")
def index():
return render_template('index.html')

@app.route("/live_tracking")
def live_trackering():
return render_template('live.html')

@app.route('/add/<img>')
def add(img):
mydb_add = mysql.connector.connect(
host="localhost",
user="root",

24
password="Sherjeel@123",
db = "mini_project_database",
autocommit=True
)
now_utc = datetime.now(timezone('UTC'))
format = '%Y-%m-%d %H:%M:%S'
now_utc = datetime.now(timezone('UTC'))
now_asia = now_utc.astimezone(timezone('Asia/Kolkata'))
mycursor = mydb_add.cursor()
mycursor.execute('insert into captured_data (car_number, time, location)
values("{}",
"{}","{}");'.format(IMAGE_CONFIGS[img],now_asia.strftime(format),random.choic
e(LOCATIONS)))
print(img,IMAGE_CONFIGS[img])
mycursor.close()
return IMAGE_CONFIGS[img]

@app.route("/live")
def live():
mydb = mysql.connector.connect(
host="localhost",
user="root",
password="Sherjeel@123",
db = "mini_project_database",
autocommit=True
)
mycursor = mydb.cursor()
mycursor.execute("select * from captured_data order by time desc")
data = mycursor.fetchall()
print(data)
mydb.close()
return jsonify(data)

@app.route("/search/<field>/<field_type>")
def search(field, field_type):
mydb = mysql.connector.connect(
host="localhost",
user="root",
password="Sherjeel@123",
db = "mini_project_database",
autocommit=True
)

25
#print (field, field_type)
mycursor = mydb.cursor()
#print('select * from captured_data where {} = "{}"'.format(field_type,field))
mycursor.execute("select * from captured_data where {} =
'{}'".format(field_type,field))
data = mycursor.fetchall()
mydb.close()
return jsonify(data)

if __name__ == '__main__':
app.run(debug=True)

26
SOURCE CODE
Front End- Index.html
<!doctype html>
<html lang="en">

<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Surveillance Portal</title>
<link
href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0-beta1/dist/css/
bootstrap.min.css" rel="stylesheet"
integrity="sha384-
0evHe/X+R7YkIZDRvuzKMRqM+OrBnVFBL6DOitfPri4tjfHxaWutUpFmBp4vmV
or" crossorigin="anonymous">
</head>

<body>

<div style="text-align:center; margin:50px;"> <h1>


Surveillance Portal
</h1>
</div>
<script
src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0-beta1/dist/js/bootstr
ap.bundle.min.js"
integrity="sha384-
pprn3073KE6tl6bjs2QrFaJGz5/SUsLqktiwsUTF55Jfv3qYSDhgCecCxMW52nD2"
crossorigin="anonymous"></script>

<div class="div" style="margin-left:200px; margin-right:200px; margin-top:


100px;">
<div style="display: flex;">
<input class="form-control form-control-lg" type="text" id="car_details"
name="car_details"
placeholder="Please Enter Car Details" aria-label=".form-control-lg
example"
style="margin-right: 10px;">
<button type="button" class="btnbtn-dark" onclick="test()">Search</button> </div>

<div style=" display: flex; justify-content: center;margin-top:20px;"> <div


class="form-check form-check-inline" >

27
<input class="form-check-input" type="radio" id="number_plate"
name="search_field" value="car_number" onclick="hide_table()" checked="checked">
<label class="form-check-label" for="number_plate">Number
Plate</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" id="timestamp"
name="search_field" value="timestamp" onclick="hide_table()">
<label class="form-check-label" for="timestamp">Timestamp</label> </div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" id="location"
name="search_field" value="location" onclick="hide_table()">
<label class="form-check-label" for="location">location</label> </div>
</div>

<div style="text-align: center; margin-top: 25px;">


<a href="/live_tracking"><button type="button" class="btnbtn-danger btn-lg">RUN
OCR</button></a>

</div>

<div style="margin-top: 50px;" id="table_data" hidden> <table


class="table table-secondary">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Number Plate</th>
<th scope="col">Time</th>
<th scope="col">Location</th>
</tr>
</thead>
<tbody id="table_rows">
</tbody>
</table>
</div>

</div>

<ul class="text-bg-dark nav justify-content-center fixed-bottom">


28
<li class="nav-item">
<p class="active" aria-current="page" style="padding-top:10px;">Made By Batch 8 as
Part Of The Mini Project
</p>
</li>
</ul>

</body>

</html>

<script>
function test() {
document.getElementById('table_data').hidden = false;
console.log(document.getElementById('car_details').value)

console.log(document.querySelector('input[name="search_field"]:checked').value)

// Url for the request


var url = 'http://127.0.0.1:5000/search/' +
document.getElementById('car_details').value + '/' +
document.querySelector('input[name="search_field"]:checked').value;

/ Making our request fetch(url,


{ method: 'GET' })
.then(Result =>Result.json())
.then(result => {
/ Printing our response //console.log(result);
//console.log(document.getElementById('table_rows').innerHTML )
document.getElementById('table_rows').innerHTML = ""
let a = ""
for(let i=0; i<result.length;i++)
{
a+=
`<tr>
<th scope="row">`+ parseInt(parseInt(i)+1) +`</th> <td>$
{result[i][1]}</td> <td>${result[i][2].slice(0,-3)}</td>
<td>${result[i][3]}</td>
</tr>`;
//console.log(x) //a
= a.concat(x)
29
}
console.log(a)
document.getElementById('table_rows').innerHTML = a;
})
.catch(errorMsg => { console.log(errorMsg); });
}

function hide_table()
{
document.getElementById('table_data').hidden = true;
}
</script>

30
SOURCE CODE

Live.html

<!doctype html>
<html lang="en">

<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>LIVE TRACKER</title>
<link
href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0-beta1/dist/css/
bootstrap.min.css" rel="stylesheet"
integrity="sha384-
0evHe/X+R7YkIZDRvuzKMRqM+OrBnVFBL6DOitfPri4tjfHxaWutUpFmBp4vmV
or" crossorigin="anonymous">
</head>

<body>
<div>
<img id="image" src="static/images/1.jpeg" width="200" height="200"> </div>

</div>
<div style="text-align:center; margin-top:50px;"> <h1>
LIVE TRACKING
</h1>
</div>
<script
src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0-beta1/dist/js/bootstr
ap.bundle.min.js"
integrity="sha384-
pprn3073KE6tl6bjs2QrFaJGz5/SUsLqktiwsUTF55Jfv3qYSDhgCecCxMW52nD2"
crossorigin="anonymous"></script>

<div class="div" style="margin-left:200px; margin-right:200px; margin-top:


100px;">
<div style="margin-top: 50px;" id="table_data"> <table
class="table table-secondary">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Number Plate</th>
<th scope="col">Time</th>
31
<th scope="col">Location</th>
</tr>
</thead>
<tbody id="table_rows">
</tbody>
</table>
</div>

</div>
<ul class="text-bg-dark nav justify-content-center fixed-bottom"> <li
class="nav-item">
<p class="active" aria-current="page" style="padding-top:10px;">Made By Batch 8 as
Part Of The Mini Project
</p>
</li>
</ul>

</body>

</html>

<script>
let data = [
{ "image": "1.jpeg" },
{ "image": "2.jpeg" },
{ "image": "3.jpeg" },
{ "image": "4.jpeg" },
{ "image": "5.jpeg" },
{ "image": "6.jpeg" },
{ "image": "7.jpeg" },
{ "image": "8.jpeg" },
{ "image": "9.jpeg" },
{ "image": "10.jpeg" },
{ "image": "11.jpeg" },
{ "image": "12.jpeg" },
{ "image": "13.jpeg" },
{ "image": "14.jpeg" }
]
console.log(data)

function test() {
// Url for the request
var url = 'http://127.0.0.1:5000/live';
32
/ Making our request fetch(url,
{ method: 'GET' })
.then(Result =>Result.json())
.then(result => {
/ Printing our response //console.log(result);
//console.log(document.getElementById('table_rows').innerHTML )
document.getElementById('table_rows').innerHTML = ""
let a = ""
for (let i = 0; i <result.length; i++) { a +=
`<tr>
<th scope="row">`+ parseInt(parseInt(i) + 1) + `</th> <td>$
{result[i][1]}</td> <td>${result[i][2].slice(0,-3)}</td> <td>$
{result[i][3]}</td>

</tr>`;
//console.log(x) //a
= a.concat(x)
}
console.log(a)
document.getElementById('table_rows').innerHTML = a;
})
.catch(errorMsg => { console.log(errorMsg); });
}

//setInterval(test, 2000)

const sleepNow = (delay) => new Promise((resolve) =>setTimeout(resolve, delay)) async


function add() {
for(let a=0; a<data.length;a++) {
document.getElementById('image').src = "static/images/" + data[a].image;
await new Promise(done =>setTimeout(() => done(), 1000));
console.log("static/images/" + data[a].image)
var url = 'http://127.0.0.1:5000/add/' + data[a].image;
/ Making our request fetch(url, {
method: 'GET' })
.catch(errorMsg => { console.log(errorMsg); });
await new Promise(done =>setTimeout(() => done(), 1000)); test();
await new Promise(done =>setTimeout(() => done(), 1000));
}
}

33
add();

</script>

34

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy