ITBees.PlateRecognition
8.0.6
See the version list below for details.
dotnet add package ITBees.PlateRecognition --version 8.0.6
NuGet\Install-Package ITBees.PlateRecognition -Version 8.0.6
<PackageReference Include="ITBees.PlateRecognition" Version="8.0.6" />
<PackageVersion Include="ITBees.PlateRecognition" Version="8.0.6" />
<PackageReference Include="ITBees.PlateRecognition" />
paket add ITBees.PlateRecognition --version 8.0.6
#r "nuget: ITBees.PlateRecognition, 8.0.6"
#:package ITBees.PlateRecognition@8.0.6
#addin nuget:?package=ITBees.PlateRecognition&version=8.0.6
#tool nuget:?package=ITBees.PlateRecognition&version=8.0.6
ITBees.PlateRecognition
Licence plate recognition from a still image (a camera snapshot), locally, in process, on the CPU - no Python, no separate service, no cloud. Runs wherever .NET 8 and ONNX Runtime run: Windows and Linux, x64 and arm64 (Chipsee columns, local servers, AdminApi).
- detector: YOLOv9-t 640 trained on plates (open-image-models, end-to-end NMS),
- OCR: CCT-S v2 global (fast-plate-ocr, 10 character slots, also guesses the country),
- both are the ONNX models of the Python
fast-alprpackage; this library reproduces its pre- and post-processing (OpenCV bilinear resize, YOLO letterbox, slot decoding) so the results match it.
Quick start
services.AddPlateRecognition(); // or AddPlateRecognition(configuration.GetSection("PlateRecognition"))
var result = await plateRecognizer.RecognizeAsync(jpegBytes);
if (result.Best is { Confidence: >= 0.9 } plate)
{
// plate.Text = "WW763YF", plate.Box = position in the image, plate.Region = "Poland"
}
RecognizeAsync takes JPEG/PNG/BMP/WebP bytes and an optional region of interest (e.g. without the text strip
some cameras burn under the picture; returned boxes stay in whole-image coordinates). The first call loads the
models (about 2 s, ~100 MB of memory), WarmUpAsync() does it earlier. Register the recognizer as a singleton
(AddPlateRecognition does).
How a frame is read
- The detector looks at the whole frame and at 6 overlapping tiles (2 rows x 3 columns, half the width, two thirds of the height). Plates far from the camera or on a fisheye frame are found only in the tiles.
- Every plate box is cut out of the original image and read by the OCR. Confidence = the lowest probability over all 10 character slots, so one unsure character or an unsure length lowers it.
PlateTextRules(Polish plates,PolishPlateRules, on by default): anIfrom the fourth character on is read as1; only 4-8 letters and digits with at least one of each count as a plate (drops road signs such as "ZAKAZ PALENIA" and logos); the same text from several searches is kept once; a text that is a part of a longer one (a plate cut by a tile edge) is dropped.Platesis ordered by confidence (to 0.01), then by box size - of two equally certain plates the bigger one belongs to the car closer to the camera, i.e. the one at the barrier.
RawReads keeps every OCR read before the rules, for logs.
Accuracy and speed
Measured on 196 frames of 8 parking cameras (Cibet, Toruń, Sandomierz, Zielona Góra; day and night, stopped and moving cars), truth = camera reads with disagreements checked by hand:
| correct | |
|---|---|
| this library (whole frame + tiles) | 93.4 % (night 92 %) - the same pick as Python fast-alpr in 190 of 196 frames |
| Python fast-alpr, same rules | 95 % |
whole frame only (UseTiles = false) |
~63 % |
The 6 frames that differ from Python all show 2-3 cars read at confidence 1.00 each; this library takes the closer one. Every frame of a car standing at the barrier was read correctly. Errors: another car in the frame, far cars with headlights at night, very dark frames.
Time per 2688x1520 frame on a desktop x64 CPU (4 threads): median ~1 s with tiles, ~0.2 s without.
SkipTilesAboveConfidence skips the tiles when the whole frame is already certain - faster, but 4 frames of
the benchmark lost their last character, so it is off by default.
The benchmark is BenchmarkTests (it runs when PLATE_BENCHMARK_TSV points to the frames list of the Python
reference run; the frames are not in the repository, they show real cars).
Models
Downloaded on the first use from the authors' GitHub releases (~13 MB), checked against pinned SHA-256 and kept
in ModelDirectory (default ~/.local/share/itbees-plate-recognition/models, on Windows
%LOCALAPPDATA%\itbees-plate-recognition\models). A device without internet: copy the three files there and set
DownloadModels = false.
| File | SHA-256 |
|---|---|
yolo-v9-t-640-license-plates-end2end.onnx |
c3c1026c...0c076 |
cct_s_v2_global.onnx |
384bbbd2...6e47b |
cct_s_v2_global_plate_config.yaml |
0335c74a...0a6 |
A fine-tuned model (trained with fast-plate-ocr in Python and exported to ONNX) is loaded with
OcrModelPath + OcrConfigPath (its plate config YAML), a custom detector with DetectorModelPath.
Options
| Option | Default | |
|---|---|---|
ModelDirectory |
see above | where the models are |
DownloadModels |
true | download missing models |
DetectorConfidence |
0.25 | minimum detector score |
UseTiles |
true | search the 6 tiles too |
SkipTilesAboveConfidence |
null | skip the tiles when the whole frame is this certain |
PolishPlateRules |
true | Polish plate rules (above) |
IntraOpThreads |
half of the cores | CPU threads per model run |
MaxConcurrentRecognitions |
1 | more calls wait |
Native libraries and app size
ONNX Runtime and SkiaSharp ship native libraries for about 20 platforms (over 600 MB with symbols). The package
adds a build step (buildTransitive/ITBees.PlateRecognition.targets) that keeps only linux-arm64, linux-x64
and win-x64 in a portable build or publish, without symbol files: about 75 MB, ~26 MB per platform. Another
platform is added in the app's project:
<PlateRecognitionRuntimeIdentifiers>linux-arm64;linux-x64;win-x64;osx-arm64</PlateRecognitionRuntimeIdentifiers>
An app published for one RuntimeIdentifier gets only that platform anyway.
Licences
The library is MIT. ONNX Runtime and SkiaSharp are MIT. The models are published by their author under MIT (fast-plate-ocr, open-image-models); the detector is a YOLOv9 architecture, whose reference implementation is GPL-3.0 - the library downloads the weights from the author instead of shipping them.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.2)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.2)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 8.0.0)
- Microsoft.ML.OnnxRuntime (>= 1.20.1)
- SkiaSharp (>= 4.154.0)
- SkiaSharp.NativeAssets.Linux.NoDependencies (>= 4.154.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.