RustODotnet 0.4.1

dotnet add package RustODotnet --version 0.4.1
                    
NuGet\Install-Package RustODotnet -Version 0.4.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="RustODotnet" Version="0.4.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="RustODotnet" Version="0.4.1" />
                    
Directory.Packages.props
<PackageReference Include="RustODotnet" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add RustODotnet --version 0.4.1
                    
#r "nuget: RustODotnet, 0.4.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package RustODotnet@0.4.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=RustODotnet&version=0.4.1
                    
Install as a Cake Addin
#tool nuget:?package=RustODotnet&version=0.4.1
                    
Install as a Cake Tool

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 default ppocrv6-tiny (FP32, Apache 2.0) models on first run from Hugging Face Hub — no separate NuGet model packages required.
  • Standalone Model Support: Load local .mnn or .rten models directly for offline or air-gapped deployments, or pre-warm caches via RustO.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 (or det.rten), rec.mnn (or rec.rten), and dict.txt (or meta.json) exist in your application base directory (or models/ 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(). Inspect structured.Items (IReadOnlyList<TextResult>):
    • Text (string), Score (float), BoxPoints (Point2D[]), Frame (Frame)
    • RegionId (int?) and LayoutType (string: "text", "title", "table", "header", "footer", "figure", etc.) when WithLayoutReading() is enabled.
  • SpatialDetectTextResult: Returned for .AsSpatial(). Inspect spatial.Text (string).
  • Resource Cleanup: RustO implements IDisposable — prefer using var ocr = RustO.Initialize(); or call ocr.Close() when finished.

License

Apache-2.0 OR MIT

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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