RustODotnet 0.4.1
dotnet add package RustODotnet --version 0.4.1
NuGet\Install-Package RustODotnet -Version 0.4.1
<PackageReference Include="RustODotnet" Version="0.4.1" />
<PackageVersion Include="RustODotnet" Version="0.4.1" />
<PackageReference Include="RustODotnet" />
paket add RustODotnet --version 0.4.1
#r "nuget: RustODotnet, 0.4.1"
#:package RustODotnet@0.4.1
#addin nuget:?package=RustODotnet&version=0.4.1
#tool nuget:?package=RustODotnet&version=0.4.1
RustODotnet (.NET SDK)
Official C# / .NET bindings for RustO! — a high-performance, pure-Rust OCR engine powered by Indra OCR, PaddleOCR, and pure-Rust MNN (rusto-nn) inference runtime.
Features
- Zero-Config PP-OCRv6 Tiny:
using var ocr = RustO.Initialize();automatically downloads and caches the defaultppocrv6-tiny(FP32, Apache 2.0) models on first run from Hugging Face Hub — no separate NuGet model packages required. - Standalone Model Support: Load local
.mnnor.rtenmodels directly for offline or air-gapped deployments, or pre-warm caches viaRustO.DownloadModel(...). - Document Intelligence: Built-in UVDoc document unwarping (
WithAutoUnwarp()), 4-way page orientation detection (WithOrientationDetection()), and neural reading-order recovery (WithLayoutReading()). - Fluent Builder API: Chain
.AsLines(),.AsWords(),.AsSpatial(),.AsTsv(), or.WithOutput(...)into a single.Run()terminal method. - Universal Image Inputs: File paths,
byte[]encoded images,ImageSource, or raw 24-bit interleaved RGB buffers via.Rgb(...).
Installation
dotnet add package RustODotnet
Quick Start (Zero-Config)
RustO.Initialize() uses the PP-OCRv6 Tiny (FP32) pipeline by default and automatically downloads assets from Hugging Face Hub into your user cache (~/.cache/rusto/models or RUSTO_CACHE_DIR) on first use:
using System;
using RustODotnet;
using var ocr = RustO.Initialize();
// Structured line-level recognition with unwarping & layout reading order
var result = ocr.DetectText("invoice.png")
.WithAutoUnwarp()
.WithLayoutReading()
.AsLines()
.Run();
if (result is StructuredDetectTextResult structured)
{
foreach (var item in structured.Items)
{
Console.WriteLine(
$"[{item.Score:F2}] ({item.LayoutType ?? "line"} #{item.RegionId?.ToString() ?? "-"}) {item.Text}"
);
}
}
// Reconstructed 2D spatial layout
var spatialResult = ocr.DetectText("invoice.png")
.AsSpatial()
.Run();
if (spatialResult is SpatialDetectTextResult spatial)
{
Console.WriteLine(spatial.Text);
}
Presets & Standalone Models (.mnn / .rten)
Configure model presets (InitializeConfig.Indra(), InitializeConfig.Ppv6(), InitializeConfig.ForModel(...)) or point to local .mnn / .rten model files for offline environments:
using RustODotnet;
// 1. Canonical model & language preset (auto-downloads files if missing)
using var indraOcr = RustO.Initialize(InitializeConfig.Indra());
using var tinyOcr = RustO.Initialize(InitializeConfig.ForModel("ppocrv6-tiny", lang: "latin"));
// 2. Offline standalone models (e.g. placed in ./models/ next to your executable)
var offlineConfig = new InitializeConfig
{
Template = "indra",
EnableReadingOrder = true,
Detection = new DetectionConfig { ModelPath = "models/indra_det.mnn" },
Recognition = new RecognitionConfig
{
ModelPath = "models/indra_rec.mnn",
DictPath = "models/indra_meta.json"
},
Unwarp = new UnwarpConfig { ModelPath = "models/uvdoc.mnn" },
Layout = new LayoutConfig { ModelPath = "models/layout_cdla.mnn" }
};
using var offlineOcr = RustO.Initialize(offlineConfig);
If
det.mnn(ordet.rten),rec.mnn(orrec.rten), anddict.txt(ormeta.json) exist in your application base directory (ormodels/subdirectory),RustO.Initialize()automatically resolves and uses those bundled files offline.
Pre-Downloading Models
For container builds or CI environments, download model assets ahead of time:
string[] cachedFiles = RustO.DownloadModel(model: "ppocrv6-tiny", cacheDir: "./models-cache");
Byte Buffers & Raw RGB Pixels
using System.IO;
using RustODotnet;
using var ocr = RustO.Initialize();
// 1. Encoded PNG/JPEG byte array
byte[] imageBytes = File.ReadAllBytes("receipt.png");
var wordsResult = ocr.DetectText(imageBytes).AsWords().Run();
// 2. Raw interleaved 24-bit RGB pixel buffer
uint width = 1280;
uint height = 720;
ulong stride = width * 3;
byte[] rgbPixels = new byte[stride * height];
var rgbResult = ocr.DetectText()
.Rgb(rgbPixels, width, height, stride)
.AsLines()
.Run();
6-Phase Pipeline Tuning
Customize any stage of the pipeline per call on DetectTextBuilder:
var tuned = ocr.DetectText("scan.jpg")
.WithOrientationDetection()
.WithAutoUnwarp()
.WithLayoutReading()
.WithPreDetection(p => p.TargetMaxSide = 1280)
.WithDetection(d =>
{
d.LimitSideLen = 960;
d.LimitType = "max";
})
.WithPostDetection(pd =>
{
pd.Threshold = 0.3f;
pd.BoxThreshold = 0.6f;
pd.UnclipRatio = 1.6f;
})
.WithRecognition(r => r.BatchSize = 8)
.WithPostRecognition(pr => pr.ScoreThreshold = 0.5f)
.WithOutput(OutputGranularity.Lines)
.Run();
Result Types & Lifecycle
StructuredDetectTextResult: Returned for.AsLines()and.AsWords(). Inspectstructured.Items(IReadOnlyList<TextResult>):Text(string),Score(float),BoxPoints(Point2D[]),Frame(Frame)RegionId(int?) andLayoutType(string:"text","title","table","header","footer","figure", etc.) whenWithLayoutReading()is enabled.
SpatialDetectTextResult: Returned for.AsSpatial(). Inspectspatial.Text(string).- Resource Cleanup:
RustOimplementsIDisposable— preferusing var ocr = RustO.Initialize();or callocr.Close()when finished.
License
Apache-2.0 OR MIT
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. 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. |
| .NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 is compatible. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- System.Text.Json (>= 8.0.5)
-
net6.0
- System.Text.Json (>= 8.0.5)
-
net8.0
- System.Text.Json (>= 8.0.5)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.4.1 | 127 | 11/14/2026 |
| 0.3.2 | 212 | 10/25/2026 |
| 0.3.1 | 132 | 10/10/2026 |
| 0.3.0 | 111 | 10/10/2026 |
| 0.2.5 | 137 | 8/20/2026 |
| 0.2.3 | 134 | 8/19/2026 |
| 0.2.2 | 132 | 8/19/2026 |
| 0.2.1 | 147 | 8/13/2026 |
| 0.2.0 | 130 | 8/13/2026 |
| 0.1.7 | 131 | 8/13/2026 |
| 0.1.6 | 134 | 8/12/2026 |
| 0.1.5 | 129 | 8/12/2026 |
| 0.1.4 | 131 | 8/12/2026 |
| 0.1.3 | 131 | 8/11/2026 |
| 0.1.2 | 263 | 12/24/2025 |
| 0.1.1 | 228 | 12/23/2025 |