Skip to content

This project is used to detect the license plate of the vehicle in real time, trained using Car Detection Licence Plate dataset available on Kaggle. Used yolov4 because it performs much better than traditional cv techniques and then used EasyOCR to extract text from the number plate. Please see readme for details.

License

Notifications You must be signed in to change notification settings

harshitkd/Real-Time-Number-Plate-Recognition

Repository files navigation

Real-Time-Number-Plate-Recognition

1_-1D-CabftTbQpm01cp3Dpg

Tech Stack

  • yolov4 : I used this OD model because it performs much better than traditional computer vision methods.
  • Easy OCR : In this project I used EasyOCR to extract text and leverage a size filtering algorithm to grab the largest detection region. EasyOCR is build on PyTorch.
  • openCV: It is a library mainly used at real-time computer vision.
  • Tensorflow : Here I used Tensorflow object detection Model (SSD MobileNet V2 FPNLite 320x320) to detect the plate trained on a Kaggle Dataset.
  • Python Libraries: Most of the libraries are mentioned in requirements.txt but some of the libraries and requirements depends on the user's machines, whether its installed or not and also the libraries for Tensorflow Object Detection (TFOD) consistently change. Eg: pycocotools, pytorch with CUDA acceleration (with or without GPU), microsoft visual c++ 19.0 etc.

Steps

These outline the steps I used to go through in order to get up and running with ANPR.

Install and Setup :

Step 1. Clone this repository: https://github.com/harshitkd/Real-Time-Number-Plate-Recognition

Step 2. Create a new virtual environment

python -m venv arpysns

Step 3. Activate your virtual environment
source tfod/bin/activate # Linux
.\arpysns\Scripts\activate # Windows 

Step 4. Install dependencies and add virtual environment to the Python Kernel
python -m pip install --upgrade pip
pip install ipykernel
python -m ipykernel install --user --name=anprsys

Dataset:

Used the Car License Plate Detection kaggel dataset and manually divided the collected images into two folders train and test so that all the images and annotations will be split among these two folders.

Training Object Detection Model

I used pre-trained state-of-the-art model and just fine tuned it on our particular specific use case.Begin the training process by opening Real Time Number Plate Detection and installed the Tensoflow Object Detection (TFOD)

68747470733a2f2f692e696d6775722e636f6d2f465351466f31362e706e67

In the below image you will see the object detection model which is now trained. I have decided to train it on the terminal because the training inside a separate terminal on a windows machine displays live loss metrics.

Screenshot (72)

  • Visualization of Loss Metric, learning rate and number of steps:
tensorboard --logdir=.

tensorboard loss

tensorboard learning and steps

Detecting License Plates

Screenshot 2021-12-10 130124

Apply OCR to text

import easyocr
detection_threshold=0.7
image = image_np_with_detections
scores = list(filter(lambda x: x> detection_threshold, detections['detection_scores']))
boxes = detections['detection_boxes'][:len(scores)]
classes = detections['detection_classes'][:len(scores)]

Screenshot 2021-12-10 125508

Results

Used this in real time to detect the license plate and stored the text in .csv file and images in the Detection_Images folder.

Object Detection Metric:

evaluation metric

evaluation metric detail

tensorboard --logdir=.

mAP

AR

For all other details and errors I faced, you can see here

About

This project is used to detect the license plate of the vehicle in real time, trained using Car Detection Licence Plate dataset available on Kaggle. Used yolov4 because it performs much better than traditional cv techniques and then used EasyOCR to extract text from the number plate. Please see readme for details.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published