Skip to content

{Python}: Detect and extract the license plate of vehicles using Machine Learning and Image Processing Techniques

Notifications You must be signed in to change notification settings

Sardhendu/License-Plate-Detection

Repository files navigation

Licence-Plate-Detection

This project aims to utilize Machine Learning and Image Processing techniques to detect/extract license plates of vehicle given an image.

Modules:

  • You would want to start with the module LP_Detect_main.py. Lets go one by one

    • This module is aimed to extract features from a license plate/non license plate and store them in the disk (Training Features).

    • Here, we manually create a small dataset by cropping out License plates from vehicle images and small set of random images (non-license plates).

    • Usual image processing techniques such as thresholding, standarization, erosion etc. are applied to the images.

    • We employ Histogram of Oriented Gradients (HOG) as a features extraction technique. In a nutshell, given an image (say 32x32x3) HOG would create a feature vector which can be consumed by a Machine Learning model. You could even experiment with simple features extraction technique such as Edges 32x32 = 1024x1, Flattening the image (32x32x3) into 3072x1 and use these vectors as an input to Machine learning Models.

      Module

    • From step 1 we already have our features, now all we have to do is send these features to a machine learning model to learn a reasonable boundary to separate License plates and Non-License plates.

    • In our case, the data is not very big, so we use Support Vector Machines as our machine learning model. SVM's with RBF kernel performs excellent with small data size and are robust to overfitting.

      Module:
      • Fetches the saved features and the corresponding label (license_plate or non-license plate) and sends it to the SVM model.
      • Stores the learned model into the disk to be used while cross validation and testing.
    • Now that we have a model in place we would want to validate the model to predict if a rectangular region is license plate or non-license plate
    • Note here we do not provide the whole image, but use manually extract license plates and random images to get a sense of the model performance
    • We have every thing set up. We have a good model too and have validated it against cross validation dataset. Now the aim is to extract all the license plate given a image containing vehicles.
    • We know that a license plate has visible edges. So, we extract all contours or region of interests (ROI) from a image, i.e (rectangles, circles polygon defined with intense edges).
    • We know that license plate are rectangular in shape, so we reshape/extend the ROI as rectangles. Note, for a given image we can have 100's or ROI of which only 2-3 would be license plate. So we have to classify all the ROI using our SVM model.
    • All the ROI's are send to the feature extractor module.
    • The generated features for each ROI are then send to the SVM classifier for classification.
    • A high probability (say >90%) indicates a ROI to be the license plate.
    • Finally we stash the ROI that have high probability of being a license plate into the disk for manual examination.

    Look HERE to get a sense of the directory name, so that you can run the model for yourself.

Snapshot of the process

Train:

Training data is manually created by taking a vehicle's image and cropping out the license plate image. Another simple way would be to extract all possible contours form the image (look at /Code/Classify.py) and save them in a directory. Then manually go an select the license plates. Below are some images of License plates used for Training.

License Plates:

Non License Plates

Test:

For testing, an image containing a vehicle image with its license plate was provided. Given the image we first extracted all the ROI's and then classify each ROI's as a license plate or not a license plate.

Test Images:

Contours Extracted (Region of Interest)

Region of interest classified as License Plate

A sample of Dataset is provided: Look under the directory folder "/DataSet" to get a sense of the dataset.

About

{Python}: Detect and extract the license plate of vehicles using Machine Learning and Image Processing Techniques

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages