Number Plate Detection using ML

We need to build a system that is capable of-

  • Looking for a license plate in the image:
    To detect an object(license plate) from an image we need another tool that can recognize an Indian license plate so for that I’ve used Haar cascade, pre-trained on Indian license plates (will be updating soon to YOLO v3).


  • OpenCV: OpenCV is a library of programming functions mainly aimed at real-time computer vision plus its open-source, fun to work with and my personal favorite. I have used version 4.1.0 for this project.
  • Python: aka swiss army knife of coding. I have used version 3.6.7 here.
  • IDE: I’ll be using Jupyter here.
  • Haar cascade: It is a machine learning object detection algorithm used to identify objects in an image or video and based on the concept of ​​ features proposed by Paul Viola and Michael Jones in their paper “Rapid Object Detection using a Boosted Cascade of Simple Features” in 2001. More info
  • Keras: Easy to use and widely supported, Keras makes deep learning about as simple as deep learning can be.
  • Scikit-Learn: It is a free software machine learning library for the Python programming language.

STEP 1 : Environment

Setup the Environment

  1. Install the dependencies
  2. import the necessary modules

STEP 2 : Plate Detection

  1. Preprocess the image
  2. Extract the plate ( using indian_plate.xml haarcascade)
  3. Save it in an image

STEP 3 : Data Preprocessing/Cleaning

  1. Collect the images of characters from (0–9, A-Z), dimensions: 28x28
  2. Save each character images in their own folders
  3. Create Train and Eval Sets using ImageDataGenerator

STEP 4 : Build and Train the Machine Learning Model

  1. Using Convolution technique
  2. Create layers as mentioned in the program(github link:
  3. Finally, Compile the model using Adam as Optimizer and Categorical Cross Entropy as Loss function
  4. Train the model by feeding the Image Data that we Generated in STEP 3

STEP 5 : Now Predict the Things

  1. Take an Image and Go through the step 2, and get the number plate
  2. Call API of RTO to get the details of the Vehicle Registration



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store