The ultimate guide: Automatic Number Plate Recognition using computer vision.

ANPR systems are highly reliable and built with cutting-edge technologies like artificial intelligence (AR), enabling them to be precise and functional.

The ANPR system uses image processing and optical character recognition to identify and verify vehicle license plates. Today, ANPR has become integral to intelligent transportation systems affecting smart parking, law enforcement, tolling and traffic monitoring applications.

The extraordinary technological advances have enabled the development of numerous helpful tools and techniques to alleviate human effort. Automatic Number Plate Recognition (ANPR), one such technology, is quickly gaining global prevalence and offers an abundance of advantages.

Undoubtedly, ANPR doesn’t directly allow to control the speeding behavior of drivers. However, it helps in efficiently identifying the vehicle that is speeding. This, in turn, enables the authorities to act quickly and avoid such circumstances in the future.

The ANPR system uses image processing and optical character recognition to identify and verify vehicle license plates. Today, ANPR has become integral to intelligent transportation systems affecting smart parking, law enforcement, tolling and traffic monitoring applications. Our computer vision AI services’ capabilities will help you build an ANPR system.

How does the ANPR system work?

Broadly, the system uses the following three steps:

Image extraction: Takes an image of a vehicle as input
Image processing: The process from a whole image to the plate region extraction
Image recognition: Character segmentation and character recognition of the number plate

This how-to guide describes these steps in detail. We will show code snippets with each section to demonstrate the functioning of ANPR technology for this how-to guide.

Red, Green, Blue to grayscale conversion

Grayscaling converts an image from other color spaces – such as RGB, CMYK, or HSV – to grayscale. We used the OpenCV module’s functions like “cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)” in Python to convert RGB to Grayscale.

Median filtering

High-speed, or even fixed image capturing comes with a great deal of noise. Gray processing has significant limitations in removing noise. Median filters are used to remove noise from an image. This is a crucial step because it directly affects the system’s recognition rate in license plate recognition.

Edge detection and dilation of BGM (binary gradient masking)

Edge detection reduces the amount of data in an image while preserving the structural properties for further image analysis. Edge detection finds sharp discontinuities in images. This is the most widely used method for detecting meaningful discontinuities in intensity values.

Plate region extraction

We first determined an image’s row and column values to extract regions of interest. Following it, we modified the image using r/3:r and saved the objects. The saved objects are then used in a dilation, the morphological closing operation, followed by erosion. That’s how we identified the coordinates of the license plate.

Morphological operations

Morphology is a large range of image processing operations focused on shapes. Morphological tasks apply an organizing component to an input picture. Here, the most fundamental tasks are dilation and erosion.

Morphology is a broad category of image processing operations centered on shapes and structures inside images. These operations transform images in two ways:

  • Increase or decrease the objects’ size

  • Open or close the gaps between objects

Amongst different morphological tasks – dilation, erosion, opening, closing, morphological gradient, white hat and black hat – dilation and erosion are fundamental.

“erosion = cv2.erode(img,kernel,iterations = 1)” is the erosion command, while “dilation = cv2.dilate(img,kernel,iterations = 1)” is the dilation command. The open morphological operation is an erosion followed by a dilation operation for the same structuring element. While the close morphological operation is a dilation followed by an erosion operation for the same structuring element.

Character segmentation

Character segmentation means decomposing an image into sub-images of individual characters. Segmentation processes divide an image into distinct parts, each containing one character and capable of being extracted for further processing.

There are two approaches to image segmentation: contour-based and region-based. We used contour-based segmentation in this simulation, which is based on the gradient-based segmentation method. It looks for edges and boundaries based on high gradient magnitudes. Character segmentation employs the bounding box technique.

The bounding box technique measures the properties of an image region. A bounding box is drawn around each character and number on a number plate. The ANPR system then extracts each character and number.

Character recognition

Character recognition is the mechanical or electronic conversion of images of typed, handwritten, or printed text into text that a machine can understand. Character recognition software scans character segmented images. Thus, it separates images in the light and dark zone text and determines the letters to represent. That’s how the character recognition technique identifies each character on the license plate.

Python-tesseract is a wrapper for Google’s Tesseract OCR engine. It can read any image types supported by the Pillow and Leptonica imaging libraries. It includes JPEG, PNG, GIF, BMP, TIFF and others, making it usable as a standalone tesseract invocation script. Python-tesseract will print the recognized text rather writing it to a file if used as a script.

Conclusion

ANPR is a crucial AI vision technology. The ANPR systems are widely in use across the world. The use cases of ANPR are wide-ranging. It covers smart parking management, journey time analysis, toll booth records, retail park security and most importantly law enforcement.

It’s no surprise that ANPR has grown in popularity in recent years. The global automatic number plate recognition market is rapidly expanding. Disruptive ANPR projects in logistics, transportation, security and the public sector are common.

If your company wants to take advantage of this powerful technology, get in touch with us.