RapidOCRLib 0.9.5

dotnet add package RapidOCRLib --version 0.9.5
                    
NuGet\Install-Package RapidOCRLib -Version 0.9.5
                    
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="RapidOCRLib" Version="0.9.5" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="RapidOCRLib" Version="0.9.5" />
                    
Directory.Packages.props
<PackageReference Include="RapidOCRLib" />
                    
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 RapidOCRLib --version 0.9.5
                    
#r "nuget: RapidOCRLib, 0.9.5"
                    
#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 RapidOCRLib@0.9.5
                    
#: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=RapidOCRLib&version=0.9.5
                    
Install as a Cake Addin
#tool nuget:?package=RapidOCRLib&version=0.9.5
                    
Install as a Cake Tool

RapidOCRSharp

Open source OCR for the security of the digital world

Join our Discord

简体中文 | English


📝 Introduction

RapidOCR is a fully open-source, free, offline-deployable OCR tool that supports multiple platforms and languages. It is designed with a strong focus on extreme speed and broad compatibility.

Supported Languages:
By default, it supports Chinese and English. For additional supported languages, please refer to the documentation:
👉 Model List

Project Background:
Given that PaddleOCR still has room for improvement in engineering and deployment, we aim to simplify and accelerate OCR model inference across various platforms.

We convert PaddleOCR models into highly compatible ONNX format, and provide implementations in multiple programming languages such as Python, C++, Java, and C#, enabling seamless cross-platform deployment and easy integration.

Name Meaning:
"RapidOCR" reflects our vision:

  • ⚡ Fast (quick response, easy to use)
  • 💡 Efficient (low resource usage, cost-effective)
  • 🤖 Intelligent (powered by deep learning for accurate recognition)

We focus on building lightweight yet powerful models, always pursuing speed while ensuring excellent recognition performance.


👉👉 This repository is the C# implementation of the main RapidOCR project:
👉 https://github.com/RapidAI/RapidOCR


If you find this project helpful, please consider giving us a ⭐ Star. Your support means a lot!


👉 Quick Start

The following example demonstrates how to get started using a .NET Console Application.

1. Create a console project

dotnet new console -n ocrdemo
cd ocrdemo

2. Add package reference

dotnet add package RapidOCRLib

3. Add the following code to Program.cs

using Emgu.CV;
using RapidOCRLib;
using System.Diagnostics;

var path = Path.Combine(AppContext.BaseDirectory, "models");

// Initialize model
OcrLite ocrEngin = new OcrLite()
{
    DetPath = Path.Combine(path, "ch_PP-OCRv5_mobile_det.onnx"),
    ClsPath = Path.Combine(path, "ch_ppocr_mobile_v2.0_cls_infer.onnx"),
    RecPath = Path.Combine(path, "ch_PP-OCRv5_rec_mobile_infer.onnx"),
    KeyDicPath = Path.Combine(path, "ppocrv5_dict.txt"),
};

await ocrEngin.InitModels();

// Image to OCR
var demoWillOCRFile = Path.Combine(AppContext.BaseDirectory, "Assets", "demo.png");

// OCR detect
var result = ocrEngin.Detect(demoWillOCRFile, 50);

if (result != null)
{
    Console.WriteLine(result.ToString());

    var img = result.BoxImg.ToBitmap();
    var desFile = Path.Combine(
        AppContext.BaseDirectory!,
        "Assets",
        Path.GetFileNameWithoutExtension(Path.GetRandomFileName()) + ".png"
    )!;

#pragma warning disable CA1416
    img?.Save(desFile!);
#pragma warning restore CA1416

    if (File.Exists(desFile))
    {
        ProcessStartInfo psi = new ProcessStartInfo
        {
            FileName = desFile,
            UseShellExecute = true
        };

        Process.Start(psi);
    }

    Console.WriteLine("Display OCR result:");
    Console.WriteLine(result.StrRes);
}

Console.ReadKey();

⚠️ Note:

  • Ensure that model files and images are placed in the correct directories.
  • You can also run the RapidOCRConsole project directly, which includes a lightweight PP-OCRv5 model.

⚒️ Project Structure

Project Directory Description
Core Library RapidOCRLib Core C# OCR wrapper library with sync/async APIs
Console App RapidOCRConsole .NET console demo with built-in PP-OCRv5 model
WinForms App RapidOCRWinform WinForms demo (model not included; copy from console project)

❓ Parameters & Tuning

OcrLite provides both synchronous and asynchronous methods:

// Sync
public OcrResult Detect(string imgFile, int padding = 50, int maxSideLen = 1024, float boxScoreThresh = 0.5f, float boxThresh = 0.3f,
                     float unClipRatio = 1.6f, bool doAngle = true, bool mostAngle = false);

// Async
public async Task<OcrResult> DetectAsync(string imgFile, int padding = 50, int maxSideLen = 1024, float boxScoreThresh = 0.5f, float boxThresh = 0.3f,
               float unClipRatio = 1.6f, bool doAngle = true, bool mostAngle = false);

Parameter Explanation

Parameter Description Impact Tuning Tips
padding Adds padding around the image Improves edge text detection Increase if text is near edges
maxSideLen Max image side length Controls image clarity Increase for large images with small text
boxThresh Pixel-level threshold Affects detection sensitivity Lower = more results, higher = fewer false positives
boxScoreThresh Box confidence threshold Filters text boxes Same tuning logic as above
unClipRatio Box expansion ratio Controls text completeness Increase if text is cut off
doAngle Enable angle classifier Fix rotated text Disable if text is always upright
mostAngle Extreme angle support Detect rotated text Enable only for complex scenes

If padding is applied, in an automated scenario, the padding must be subtracted to obtain the correct coordinate position.


🎉 Model Download

Download models from: https://www.modelscope.cn/models/RapidAI/RapidOCR/files

Required files:

Model Type Description
det Detection model
cls Angle classification model
rec Recognition model
dictionary Character dictionary (required)

🎁 Roadmap

  • Web demo support
  • Table structure recognition
  • Automatic model download
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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 netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  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.9.5 150 4/18/2026
0.9.4 151 4/14/2026
0.9.3 100 4/14/2026
0.9.1 98 4/14/2026