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

How can I automate license plate recognition in C#?

You can automate license plate recognition in C# using IronOCR's ReadLicensePlate method. This method allows you to extract license plate numbers from images, improving efficiency and accuracy compared to manual methods.

What steps are involved in reading a license plate using IronOCR?

To read a license plate using IronOCR, download the C# library, import the license plate image as an OcrInput, and use the ReadLicensePlate method to extract data. You can then access the OcrLicensePlateResult property for further manipulation.

Can IronOCR handle images of cars with visible license plates?

Yes, IronOCR can read license plates from images of cars. It can also provide the pixel coordinates of the license plate's location within the image.

What languages are supported by IronOCR for license plate reading?

IronOCR's ReadLicensePlate method supports English, Chinese, Japanese, Korean, and Latin alphabet scripts for license plate reading.

How can configuring character whitelists enhance license plate recognition?

By configuring IronOCR to whitelist specific characters commonly found in license plates, you can enhance recognition performance and speed up the processing of license plate numbers.

What additional package is necessary for advanced license plate scanning?

For advanced scanning capabilities, you need to install the IronOcr.Extensions.AdvancedScan package.

What is the significance of the confidence level in license plate recognition?

The confidence level in license plate recognition indicates the statistical accuracy of the OCR process, ranging from 0 to 1, where 1 represents the highest confidence.

How is IronOCR optimized for reading license plates on .NET Framework?

IronOCR is optimized for reading license plates on the .NET Framework when running on x64 architecture, ensuring efficient processing and recognition performance.

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.

...Read More