Skip to content

PlateDetect-PK : A YOLOv4 and OCR-Based ANPR Solution for Punjab Number Plates

shamsher haider anpr ai ml punjab excise number plate psca

Introduction

In 2019-2020, the Punjab Safe Cities Authority (PSCA) undertook a series of in-house research initiatives under directives of COO IGP Dr Akbar Nasir Khan QPM and later COO DIG Kamran Khan to address critical challenges in urban safety and traffic management. One of the most pressing issues was the inefficiency of the Automatic Number Plate Recognition (ANPR) systems in accurately identifying vehicle number plates issued by the Punjab Excise Department. These plates, characterized by intricate designs, non-standardized fonts, and varying formats, posed significant hurdles for conventional ANPR systems, particularly for motorcycles. This inefficiency often required manual verification by Punjab Traffic Police wardens, undermining the effectiveness of the e-challan system deployed at the time.

To address this issue, a dedicated research team at PSCA, led by the Chief Software Development Officer of PSCA Shamsher Haider and supported by Umair Ayub, Syed Konain Abbas Kirmani, Syed Safeer Abbas, Muhammad Asad Ali, and Ahsan Bilal, developed a novel ANPR framework tailored to the unique challenges of Punjab’s vehicle number plates. This project was part of a broader effort to explore multiple technical approaches to improve the reliability and efficiency of ANPR systems. While this work was conducted in 2020, it laid the foundation for future advancements in traffic management and surveillance systems.


The Challenge of Non-Standardized Number Plates

Unlike standardized number plates in many countries, Pakistani plates, particularly those issued by the Punjab Excise Department, lack uniformity. They feature diverse fonts, colors, and designs, with some plates having single rows and others double rows. Motorcycle plates, in particular, are smaller and more challenging to detect. Environmental factors such as poor lighting, dust, and motion blur further complicated the recognition process. These challenges rendered existing ANPR systems ineffective, necessitating a customized solution.


The Proposed Solution: YOLOv4-Based ANPR Framework

The research team developed a robust ANPR framework leveraging the YOLOv4 (You Only Look Once) object detection model and OCR (Optical Character Recognition) Tesseract. The framework was designed to address the unique challenges of Punjab’s number plates and consisted of five key stages:

  1. Image Acquisition: A dataset of 2000 images of Pakistani vehicle number plates was created, capturing various formats, fonts, and environmental conditions. Low-resolution images (416×416) were used to simulate real-world CCTV conditions.

  2. Number Plate Localization: YOLOv4 was employed to detect and extract the number plate region from images. This model achieved a mean average precision (mAP) score of 99.5%, significantly outperforming its predecessor, YOLOv3, which achieved 94.3%.

  3. Image Preprocessing: Techniques such as grayscale conversion, noise removal, binarization, and contrast enhancement were applied to improve the quality of the extracted plate images.

  4. Character Recognition: OCR Tesseract was used to recognize the characters on the number plates. This open-source tool was optimized to handle the diverse fonts and styles of Punjab plates.

  5. Number Plate Label Management: The recognized characters were reconstructed into a string format and stored for further processing, such as issuing e-challans.


Technical Implementation and Tools

The project utilized a range of Python libraries and frameworks to implement the ANPR system:

  • Deep Learning Frameworks: TensorFlow, Keras, PyTorch, and Darknet (for YOLO).
  • Image Processing Libraries: OpenCV, PIL, scikit-image, and numpy.
  • OCR and Text Processing: Tesseract OCR via pytesseract, fuzzywuzzy for string matching, and regex for pattern matching.
  • Development Tools: Jupyter Notebooks, Docker for containerization, and Git for version control.
  • Visualization and Monitoring: Matplotlib, TensorBoard, and Weights & Biases for experiment tracking.

The modular architecture allowed for easy experimentation with different components and approaches, enabling the team to refine the system iteratively.


Results and Performance

The proposed framework demonstrated significant improvements over existing solutions:

  • Processing Speed: 0.8 seconds per image, making it suitable for real-time applications.
  • Recognition Accuracy: 73% average accuracy for complete plate recognition.
  • Localization Precision: 99.5% mAP score with YOLOv4.
  • Versatility: Effective for both single and double-row plates, as well as motorcycle plates.

Comparative analysis with previous methods revealed the superiority of the YOLOv4-based framework. For instance, a KNN-based approach achieved only 9% accuracy and required 44 seconds per image, while the proposed system was faster, more accurate, and capable of handling diverse plate formats.


Broader Research Context

This project was one of several exploratory initiatives undertaken by PSCA in 2020 to address the challenges of ANPR in Punjab. Each iteration explored different technical approaches, contributing to a deeper understanding of the problem and potential solutions. While the team members involved in this project have since moved on to other roles, their work remains a cornerstone of PSCA’s efforts to modernize traffic management systems.


Future Directions

The research team envisioned several enhancements for the framework, including:

  • Testing it in live CCTV environments.
  • Improving recognition for moving vehicles and at greater distances.
  • Expanding its application to other provinces with similar challenges.

These advancements would help PSCA achieve its goal of creating a reliable, real-time ANPR system that could be integrated into its broader traffic management and surveillance infrastructure.


Conclusion

The YOLOv4-based ANPR framework developed by PSCA in 2020 represents a significant step forward in addressing the unique challenges of Pakistani number plates. By leveraging advanced object detection and OCR technologies, the system offers a fast, accurate, and versatile solution for real-time traffic management. Although the team members who contributed to this project have since moved on, their work continues to influence the development of ANPR systems in Pakistan and beyond, setting a benchmark for future innovations in the field.