Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Temppus/AlprNet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 

Repository files navigation

AlprNet

A .NET Standard library for license plate detection and recognition. It uses public and open source ONNX models for inference.

Note: The library works, but it is a work in progress (WIP). Once further polished, a NuGet package will be published.

Demo

Input Image

Car Image

Detected License Plate

Detected License Plate

License plate string: UD 1234

Usage

Example usage is shown below. See Program.cs for the full inference code.

Mat plateCropImg;

// Plate detection
{
    var modelDirPath = Path.Combine(Directory.GetCurrentDirectory(), "PlateDetection\\Models");
    var modelPath = Path.Combine(modelDirPath, "yolo-v9-t-512-license-plates-end2end.onnx");
    using var licensePlateDetector = new LicensePlateDetector(modelPath);
    var image = Mat.FromImageData(await File.ReadAllBytesAsync("car.jpg"));

    Console.WriteLine("Running license plate detection");
    var detections = licensePlateDetector.Run(image);
    var detectedPlate = detections.Single();

    plateCropImg = detectedPlate.ToPlateCropImage(image);
    Console.WriteLine("License plate detected and cropped");
    plateCropImg.SaveImage("car_plate.jpg");
}

// Plate recognition
{
    var modelDirPath = Path.Combine(Directory.GetCurrentDirectory(), "PlateRecognition\\Models");
    var modelPath = Path.Combine(modelDirPath, "cct_s_v1_global.onnx");
    var modelConfigPath = Path.Combine(modelDirPath, "cct_s_v1_global_plate_config.yaml");
    using var recognizer = new LicensePlateRecognizer(modelPath, modelConfigPath);

    Console.WriteLine("Running license plate recognition");
    var result = recognizer.Run([plateCropImg], returnConfidence: true);

    var plate = result.plates.Single();
    Console.WriteLine($"License plate is: {plate}");
}

Models

Models are included in the repository but can also be downloaded via utility classes:

  • PlateDetectionModelsRepository
  • PlateOcrModelsRepository

Acknowledgments

About

License plate detection and recognition library for .NET via ONNX inference.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages