EasyOcrSharp 2.0.1
See the version list below for details.
dotnet add package EasyOcrSharp --version 2.0.1
NuGet\Install-Package EasyOcrSharp -Version 2.0.1
<PackageReference Include="EasyOcrSharp" Version="2.0.1" />
<PackageVersion Include="EasyOcrSharp" Version="2.0.1" />
<PackageReference Include="EasyOcrSharp" />
paket add EasyOcrSharp --version 2.0.1
#r "nuget: EasyOcrSharp, 2.0.1"
#:package EasyOcrSharp@2.0.1
#addin nuget:?package=EasyOcrSharp&version=2.0.1
#tool nuget:?package=EasyOcrSharp&version=2.0.1
<div align="center"> <img src="src/EasyOcrSharp/Assets/icon.gif" alt="EasyOcrSharp Logo" width="128" height="128"> <h1>EasyOcrSharp</h1>
Native .NET 10 OCR powered by EasyOCR's neural models on ONNX Runtime. No Python, no PyTorch, no embedded interpreter — just a small managed library that downloads the per-language ONNX models it needs on first use. Recognition accuracy matches upstream EasyOCR, because it runs EasyOCR's exact CRAFT + CRNN networks.
- 🌍 80+ languages across 9 script families (Latin, Cyrillic, Arabic, Devanagari, Bengali, Chinese, Korean, Japanese, Thai)
- 📦 ~3 MB package — models download on demand and are cached locally
- ⚡ AOT / single-file friendly — pure managed code over ONNX Runtime
- 🔒 SHA256-verified model downloads
- 🖥️ CPU by default, optional CUDA GPU via
EasyOcrSharp.Gpu
What changed in v2
EasyOcrSharp 1.x bundled a full Python + PyTorch + EasyOCR runtime inside the NuGet package (~1.5 GB). v2 replaces that with the same neural networks exported to ONNX and run via Microsoft.ML.OnnxRuntime.
| v1 (Python bundled) | v2 (native ONNX) | |
|---|---|---|
| Package size | ~1.5 GB | ~3 MB + on-demand models |
| First-run cost | Minutes (Python boot + model dl) | Seconds (just model dl) |
| AOT / single-file publish | No | Yes |
| Native deps | Python interpreter + torch DLLs | ONNX Runtime only |
| GPU | CUDA via torch | CUDA via EasyOcrSharp.Gpu |
The public API (EasyOcrService.ExtractTextFromImage, OcrResult, OcrLine, OcrBoundingBox) is unchanged — v1 callers upgrade with no code changes beyond the version bump.
Installation
dotnet add package EasyOcrSharp
For NVIDIA GPU acceleration (Windows/Linux x64 with CUDA 12+):
dotnet add package EasyOcrSharp.Gpu
Quick start
using EasyOcrSharp.Services;
using Microsoft.Extensions.Logging;
var loggerFactory = LoggerFactory.Create(b => b.AddSimpleConsole());
await using var ocr = new EasyOcrService(logger: loggerFactory.CreateLogger<EasyOcrService>());
// Extract text — pass one or more language codes.
var result = await ocr.ExtractTextFromImage("sample.png", new[] { "en" });
Console.WriteLine(result.FullText);
foreach (var line in result.Lines)
{
Console.WriteLine($" {line.Text} (confidence {line.Confidence:P0})");
var box = line.BoundingBox;
Console.WriteLine($" at [{box.MinX},{box.MinY} → {box.MaxX},{box.MaxY}]");
}
What you get back
public sealed class OcrResult
{
public string FullText { get; } // all lines joined by newlines
public IReadOnlyList<OcrLine> Lines { get; }
public IReadOnlyList<string> Languages { get; }
public TimeSpan Duration { get; }
public bool UsedGpu { get; }
}
public sealed class OcrLine
{
public string Text { get; }
public double Confidence { get; } // 0..1
public IReadOnlyList<OcrPoint> BoundingPolygon { get; } // 4 corners
public OcrBoundingBox BoundingBox { get; } // axis-aligned bounds (MinX/MinY/MaxX/MaxY + Width/Height/Center)
}
Detected text is grouped into reading-order lines (top-to-bottom), matching EasyOCR's readtext() output.
Multiple languages at once
Pass several language codes to OCR mixed-script images. Each detected region is read by every requested script pack, and the highest-confidence result wins:
// A sign with English, Chinese, and Russian on it:
var result = await ocr.ExtractTextFromImage("street_signs.png",
new[] { "en", "ch_sim", "ru" });
Note that each additional script family loads its own model (see sizes below), so request only the languages you actually expect in the image.
How model downloads work
EasyOcrSharp ships no models in the NuGet package. On the first call for a given language it downloads, into a local cache:
- CRAFT text detector (
craft_mlt_25k.onnx, ~80 MB) — shared across all languages, downloaded once. - CRNN recognizer for the language's script pack (e.g.
latin_g2.onnx) — one per script family. - A tiny vocabulary sidecar (
<pack>.vocab.json) describing the characters that model emits.
Every download is SHA256-verified against a checksum baked into the library, so a corrupted or tampered file is rejected. Models are hosted on Hugging Face.
Files are cached at %LOCALAPPDATA%\EasyOcrSharp\models on Windows (or the platform equivalent on Linux/macOS). Override the cache location or the download source:
// Per-instance cache directory:
await using var ocr = new EasyOcrService(modelCachePath: @"D:\MyApp\Models");
# Environment variable cache override:
EASYOCRSHARP_CACHE=/var/cache/easyocr
# Private model mirror (e.g. for air-gapped environments — pre-seed it with the .onnx + .vocab.json files):
EASYOCRSHARP_MODEL_BASE_URL=https://files.mycorp.example/easyocr
Tip for offline / air-gapped deployment: copy the contents of the model repo into your cache directory ahead of time, and no network access is needed at runtime.
Supported languages
Languages are grouped by script. One CRNN recognizer covers an entire group, so requesting ["en", "es", "fr"] only loads one recognizer file. Model size varies because EasyOCR ships newer, smaller "generation-2" networks for some scripts and only larger "generation-1" networks for others — this affects first-run download size only, not the package.
| Pack | Model size | Languages |
|---|---|---|
latin_g2 |
~15 MB | en, es, fr, de, it, pt, nl, pl, cs, sv, hu, fi, ro, no, da, hr, sk, sl, sq, tr, ca, eu, gl, id, ms, tl, vi, af, et, lv, lt, is, ga, mt, cy, la, oc, ku, mi, sr_latn, rs_latin |
cyrillic_g2 |
~15 MB | ru, sr, kk, az, uz, ky, mn, be, uk, bg, mk, tg, ab |
zh_sim_g2 |
~22 MB | ch_sim, zh_sim |
korean_g2 |
~16 MB | ko |
japanese_g2 |
~17 MB | ja |
arabic_g2 |
~210 MB | ar, fa, ur, ug, ps |
devanagari_g2 |
~210 MB | hi, mr, ne, sa |
bengali_g2 |
~210 MB | bn, as |
thai_g1 |
~210 MB | th |
The ~210 MB packs (Arabic, Devanagari, Bengali, Thai) are EasyOCR's generation-1 networks — EasyOCR never released smaller versions for those scripts. They download once and are cached like any other model.
If you request a language that has no pack, EasyOcrSharp logs a warning and skips it — other requested languages still work.
Not supported: Greek (
el) — upstream EasyOCR has no Greek recognition model, so it can't be exported. Tamil, Telugu, Kannada and Traditional Chinese exist in EasyOCR and can be added on request.
GPU acceleration
await using var ocr = new EasyOcrService(useGpu: true, logger: logger);
Requires the EasyOcrSharp.Gpu package, CUDA 12+ on PATH, and a compatible NVIDIA GPU. Falls back silently to CPU if CUDA isn't available.
Notes on accuracy
EasyOcrSharp reproduces EasyOCR's recognition pipeline faithfully — preprocessing (aspect-preserving resize, normalization, low-confidence contrast retry), CRAFT box dilation, and CTC greedy decoding — so output matches upstream EasyOCR. As with any OCR:
- Visually identical glyphs in some fonts (capital
Ivs lowercasel,$vs8) can be confused. - Handwriting and low-resolution / low-contrast text are harder than clean printed text.
- Right-to-left scripts (Arabic) are returned in the model's character order.
Building from source
git clone https://github.com/easyocrsharp/EasyOcrSharp.git
cd EasyOcrSharp
dotnet build -c Release
The repo is a standard .NET 10 solution: src/EasyOcrSharp (the library), src/EasyOcrSharp.Gpu (the CUDA package), and test/ (a console demo).
License
MIT. See LICENSE. EasyOCR (the upstream model authors) is also MIT-licensed.
Acknowledgments
- EasyOCR — the underlying CRAFT + CRNN models
- ONNX Runtime — neural network execution
- SixLabors.ImageSharp — image I/O and resizing
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. 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. |
-
net10.0
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.8)
- Microsoft.ML.OnnxRuntime (>= 1.26.0)
- SixLabors.ImageSharp (>= 3.1.12)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on EasyOcrSharp:
| Package | Downloads |
|---|---|
|
EasyOcrSharp.Gpu
CUDA GPU execution provider for EasyOcrSharp. Adds Microsoft.ML.OnnxRuntime.Gpu so detection and recognition run on NVIDIA GPUs. |
GitHub repositories
This package is not used by any popular GitHub repositories.