Skip to content

Repository files navigation

License Plate Recognition (ALPR) Pipeline - Proof of Concept

Python Scikit-Learn Scikit-Image

📌 Project Overview

A complete Automatic License Plate Recognition (ALPR) system built from scratch. This project serves as a Proof of Concept (PoC) to demonstrate the integration of classic computer vision techniques for image segmentation with a custom-trained Support Vector Machine (SVM) model for Optical Character Recognition (OCR).

Unlike out-of-the-box OCR APIs, this project involves manually processing the image, extracting the features, and training a custom Machine Learning classifier.

Note: This PoC is designed and calibrated for controlled environments (ideal lighting, frontal perspective). It showcases fundamental algorithm design and logic before scaling to deep learning architectures.

⚙️ The Pipeline (How it works)

The system operates in three main stages:

  1. Plate Detection (Computer Vision):

    • The raw image is converted to grayscale.
    • Otsu's Thresholding is applied for adaptive binarization based on the image's histogram.
    • Connected Component Analysis (skimage.measure) is used to label regions.
    • Heuristics (height/width ratios and bounding box boundaries) filter out noise to isolate the vehicle's license plate.
  2. Character Segmentation:

    • The cropped license plate undergoes a secondary thresholding process to isolate individual dark characters against the light background.
    • Bounding boxes are drawn around each individual letter and number.
  3. Optical Character Recognition (Machine Learning):

    • A dataset of alphanumeric characters is processed and resized to a strict 20x20 pixel grid.
    • The matrices are flattened into 1D arrays to extract numerical features.
    • A Support Vector Machine (SVM) classifier is trained on these features to predict the characters.

📸 Demo / Results

image image

🛠️ Tech Stack

  • Language: Python
  • Computer Vision: scikit-image
  • Machine Learning: scikit-learn
  • Data Visualization: matplotlib

📁 Repository Structure

├── images/                   # Sample images for testing
├── models/
│   └── svc/                  # Contains the trained SVM model (.pkl)
├── train20X20/               # Dataset used to train the OCR model
├── characterSegmentation.py  # Isolates characters from the cropped plate
├── gray.py                   # Image preprocessing functions
├── main.py                   # Entry point for the ALPR pipeline
├── position.py               # Handles bounding box coordinates
├── recognition.py            # OCR script using the trained SVM
├── requirements.txt          # Project dependencies
└── README.md

Limitations & Future Work

Since this pipeline relies on classic computer vision (global binarization and fixed proportion heuristics), it is highly sensitive to variations in lighting, shadows, and extreme angles.

Future improvements:

-Replace the heuristic-based plate localization with a Deep Learning object detection model (e.g., YOLOv8 or Haar Cascades) for robust detection in uncontrolled environments.

-Implement adaptive local thresholding to better handle shadows and reflections on the bumper.

-Expand the 20x20 dataset with augmented images (rotations, blur) to improve the SVM's OCR accuracy.

About

An Optical Character Recognition (OCR) pipeline built from scratch. The project is a proof of concept developed under controlled lighting and perspective conditions to demonstrate the integration of classical image segmentation (Scikit-Image) with machine learning classification algorithms (Scikit-Learn).

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages