How to Read License Plates using IronOCR

When managing a large volume of vehicle images, manually reading license plates is time-consuming and prone to human error. Automating this process with a tool like IronOCR provides a more efficient, accurate solution. IronOCR's ReadLicensePlate method can programmatically extract license plate numbers from images, saving considerable time while improving data accuracy.

In this guide, we’ll demonstrate how to use IronOCR for license plate recognition, walking through examples and customizable configurations that make the process seamless. By leveraging these methods, developers can automate license plate reading, making tasks like parking management, toll collection, or security surveillance more efficient.

Start using IronOCR in your project today with a free trial.

First Step:
green arrow pointer

To use this function, you must also install the IronOcr.Extension.AdvancedScan package.

Read License Plate Example

To read a license plate in IronOCR, we have to apply the following steps:

  • We utilize the ReadLicensePlate method, which takes an OcrInput as a parameter for the input. This method is more optimized for license plates precisely than the library's standard Read counterpart.
  • Optionally, we can configure IronOCR to whitelist specific characters only that can exist in a license plate, to speed up the license plate number processing.

Please note

  • The method currently only works for English, Chinese, Japanese, Korean, and Latin alphabet scripts.
  • Using advanced scan on .NET Framework requires the project to run on x64 architecture.

License Plate

License plate

Code

:path=/static-assets/ocr/content-code-examples/how-to/read-license-plate-read-license-plate.cs
using IronOcr;
using System;

var ocr = new IronTesseract();
ocr.Configuration.WhiteListCharacters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_";

using var inputLicensePlate = new OcrInput();
inputLicensePlate.LoadImage("plate.jpeg");

// Read license plate
OcrLicensePlateResult result = ocr.ReadLicensePlate(inputLicensePlate);

// Retrieve license plate number and confidence value
string output = $"{result.Text}\nResult Confidence: {result.Confidence}";

Console.WriteLine(output);
Imports Microsoft.VisualBasic
Imports IronOcr
Imports System

Private ocr = New IronTesseract()
ocr.Configuration.WhiteListCharacters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_"

Dim inputLicensePlate = New OcrInput()
inputLicensePlate.LoadImage("plate.jpeg")

' Read license plate
Dim result As OcrLicensePlateResult = ocr.ReadLicensePlate(inputLicensePlate)

' Retrieve license plate number and confidence value
Dim output As String = $"{result.Text}" & vbLf & "Result Confidence: {result.Confidence}"

Console.WriteLine(output)
$vbLabelText   $csharpLabel

Output

License plate result

The code demonstrates how to import an image as an OcrInput and use it with the ReadLicensePlate method to extract the text from the license plate. The output shows the extracted text that matches the license plate shown in the input image, along with a confidence level indicating the accuracy of the OCR.

Text: The extracted text from OCR Input.

Confidence: A "double" property that indicates the statistical accuracy confidence of an average of every character, with one being the highest and 0 being the lowest.


License Plate From a Car Image

The method also works well with images containing a car with a license plate. The code is the exact same as the one above, with the input image changed. You can also extract the pixel coordinates of the area where the license plate is situated in the image.

Example Input

Car license plate

:path=/static-assets/ocr/content-code-examples/how-to/read-license-plate-read-from-car.cs
using IronOcr;
using IronSoftware.Drawing;
using System;

var ocr = new IronTesseract();
using var inputLicensePlate = new OcrInput();
inputLicensePlate.LoadImage("car_license.jpg");

// Read license plate
OcrLicensePlateResult result = ocr.ReadLicensePlate(inputLicensePlate);

// Retrieve license plate coordinates
RectangleF rectangle = result.Licenseplate;

// Write license plate value and coordinates in a string
string output = $"License Plate Number:\n{result.Text}\n\n"
              + $"License Plate Area_\n"
              + $"Starting X: {rectangle.X}\n"
              + $"Starting Y: {rectangle.Y}\n"
              + $"Width: {rectangle.Width}\n"
              + $"Height: {rectangle.Height}";

Console.WriteLine(output);
Imports Microsoft.VisualBasic
Imports IronOcr
Imports IronSoftware.Drawing
Imports System

Private ocr = New IronTesseract()
Private inputLicensePlate = New OcrInput()
inputLicensePlate.LoadImage("car_license.jpg")

' Read license plate
Dim result As OcrLicensePlateResult = ocr.ReadLicensePlate(inputLicensePlate)

' Retrieve license plate coordinates
Dim rectangle As RectangleF = result.Licenseplate

' Write license plate value and coordinates in a string
Dim output As String = $"License Plate Number:" & vbLf & "{result.Text}" & vbLf & vbLf & $"License Plate Area_" & vbLf & $"Starting X: {rectangle.X}" & vbLf & $"Starting Y: {rectangle.Y}" & vbLf & $"Width: {rectangle.Width}" & vbLf & $"Height: {rectangle.Height}"

Console.WriteLine(output)
$vbLabelText   $csharpLabel

Output

Car license plate result

The example shows how the ReadLicensePlate method can be applied to an image of a car. The method will also return the rectangle coordinates of where the license plate is situated in the image.

This method is optimized to find single license plates only and is capable of searching for them in stock images.

Frequently Asked Questions

What is this library used for reading license plates?

IronOCR is a C# library that allows developers to perform optical character recognition, including extracting text from images of license plates.

How does the method for reading license plates work?

The ReadLicensePlate method in IronOCR takes an OcrInput parameter containing the image of the license plate. It extracts the license plate number and provides a confidence level indicating the accuracy of the recognition.

What are the benefits of using this library for reading license plates?

Using IronOCR for license plate reading automates the process, improving efficiency and accuracy compared to manual methods. This is particularly useful in applications like parking management, toll collection, and security surveillance.

Which languages does the method for reading license plates support?

The ReadLicensePlate method currently supports English, Chinese, Japanese, Korean, and Latin alphabet scripts.

What additional package is required to use the method for reading license plates?

To use the ReadLicensePlate method, you must install the IronOcr.Extensions.AdvancedScan package.

Can this library read license plates from images of cars?

Yes, IronOCR can read license plates from images of cars and even extract the coordinates of the license plate area within the image.

How can I enhance the performance of license plate recognition with this library?

You can enhance performance by configuring IronOCR to whitelist specific characters that are commonly found in license plates, which speeds up the processing.

What is the confidence level provided by the method for reading license plates?

The confidence level is a 'double' property indicating the statistical accuracy of the OCR process, with a value from 0 to 1, where 1 is the highest confidence.

Curtis Chau
Technical Writer

Curtis Chau holds a Bachelor’s degree in Computer Science (Carleton University) and specializes in front-end development with expertise in Node.js, TypeScript, JavaScript, and React. Passionate about crafting intuitive and aesthetically pleasing user interfaces, Curtis enjoys working with modern frameworks and creating well-structured, visually appealing manuals.

Beyond development, Curtis has a strong interest in the Internet of Things (IoT), exploring innovative ways to integrate hardware and software. In his free time, he enjoys gaming and building Discord bots, combining his love for technology with creativity.