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 may be used in a variety of public settings to serve a variety of functions, including automatic toll tax collection, car park systems, and automatic vehicle parking systems.
This project uses YOLOv5 for number plate detection and paddleocr for recognizing characters of the detected number plate. It also uses object tracking to track number plates and get the best OCR result for each plate, which is then saved into a CSV file.
To solve this problem, I've taken a two-step approach. In the first step is number plate detection model is trained using YOLOv5 model.
The second step is to run the number plate detection model to locate all of the number plate present in an image and extract plate region from that image. Once a number plate is located, preprocessing is performed on ROI image and PaddleOCR is used to recognise characters in the number plate.
When running above proposed ANPR on a video, it causes some issues which makes the ANPR less accurate, such as Jittering, Fluctuation of OCR output. But if the tracker is used, these issues can be rectified. The NorFai Tracker will be used to track the number plate and ensure the best OCR results are obtained. The recognized number plates will be saved to a CSV file.
The dataset consists of 928 images different types of vehicles. These images are collected from:
- Car License Plate Detection Dataset
- Automatic Number Plate Recognition Dataset
- Web Scraping Images from Google
All the dependencies and required libraries are included in the file requirements.txt
See here
Make sure to install correct gpu versions of PaddlePaddle and torch.
- Clone the repo
$ git clone https://github.com/Tkvmaster/ANPR-System.git
- Change your directory to the cloned repo
$ cd ANPR-System
- clone the YOLOv5 directory from GitHub
$ git clone https://github.com/rkuo2000/yolov5/
- Now, run the following command in your Terminal/Command Prompt to install the libraries required
$ pip3 install -r requirements.txt
To detect number plates in video feed:
$ python3 anpr-system.py \
--weights yolo_weights.pt \
--input input_video.mp4 \
--output output_video.mp4 \
--csv all_number_plates.csv
Video Source : https://www.videvo.net/video/cars-driving-along-an-indian-freeway/6374/
This ANPR system is designed for real-time license plate detection and recognition, but it may not work well in all situations. The accuracy of the system may be affected by factors such as lighting, camera quality, and the angle and position of the license plate in the video.
The code in this project is licensed under MIT License.