🚀a high performance, cross-platform PaddleOCR C# inference library base on OpenCV and ONNX Runtime. Referring to the RapidOCR project, it is a python version of the C# implementation with a redesigned and optimized architecture.
- Supported Languages PP-OCRv6 built on the newly designed PPLCNetV4 unified backbone, a single model supports 50 languages including Chinese, English, Japanese, and 46 Latin-script languages., please refer to the documentation: PP-OCRv6 Introduction.
- Execution Provider CPU, CUDA / TensorRT, OpenVINO, CoreML, DirectML
- Batch processing images Preprocess and Inference are executed asynchronously with Producer/Consumer pattern
- High Performance Inference Memory reuse, GPU Inference with I/O Binding
- Image Processing OpenCvSharp4
- Draw Result Image SkiaSharp
- Inference Engine ONNX Runtime is a cross-platform inference and training machine-learning accelerator.
- PP-OCR Versions Includes support for: PP-OCRv6, PP-OCRv5, PP-OCRv4
For convert the pre-trained PP-OCR model to ONNX format, please refer to the the documentation: Obtaining ONNX Models, or download from rapid-ocr Model List.
Official download of PP-OCRv6 onnx format
Install Nuget packages RapidOCRSharpOnnx, OnnxRuntime, OpenCvSharp4.runtime
dotnet add package RapidOCRSharpOnnx
dotnet add package OpenCvSharp4.runtime.win
dotnet add package Microsoft.ML.OnnxRuntimeusing RapidOCRSharp ocr = new RapidOCRSharp(new ExecutionProviderCPU(new OcrConfig(detectPath, recPath, LangRec.CH, OCRVersion.PPOCRV5, clsMobilePath)));dotnet add package RapidOCRSharpOnnx
dotnet add package OpenCvSharp4.runtime.osx.10.15-x64
dotnet add package Microsoft.ML.OnnxRuntimeusing RapidOCRSharp ocr = new RapidOCRSharp(new ExecutionProviderCoreML(new OcrConfig(detectPath, recPath, LangRec.CH, OCRVersion.PPOCRV5, clsMobilePath)));dotnet add package RapidOCRSharpOnnx
dotnet add package OpenCvSharp4.runtime.win
dotnet add package Microsoft.ML.OnnxRuntime.Gpu.Windowsusing RapidOCRSharp ocr = new RapidOCRSharp(new ExecutionProviderCUDA(new OcrConfig(detectPath, recogPath, LangRec.CH, OCRVersion.PPOCRV5, clsPath), deviceId));
using RapidOCRSharp ocr = new RapidOCRSharp(new ExecutionProviderTensorRT(new OcrConfig(detectPath, recogPath, LangRec.CH, OCRVersion.PPOCRV5, clsPath), deviceId));dotnet add package RapidOCRSharpOnnx
dotnet add package OpenCvSharp4.runtime.win
dotnet add package Microsoft.ML.OnnxRuntime.DirectMLusing RapidOCRSharp ocr = new RapidOCRSharp(new ExecutionProviderDirectML(new OcrConfig(detectPath, recogPath, LangRec.EN, OCRVersion.PPOCRV5, clsPath), deviceId));dotnet add package RapidOCRSharpOnnx
dotnet add package OpenCvSharp4.runtime.win
dotnet add package Intel.ML.OnnxRuntime.OpenVinousing RapidOCRSharp ocr = new RapidOCRSharp(new ExecutionProviderOpenVINO(new OcrConfig(detectPath, recogPath, LangRec.EN, OCRVersion.PPOCRV5, clsPath), IntelDeviceType.NPU));using RapidOCRSharp ocr = new RapidOCRSharp(new ExecutionProviderDirectML(new OcrConfig(detectPath, recogPath, LangRec.EN, OCRVersion.PPOCRV5, clsPath), _deviceId));
string savePath = $"res_{Path.GetFileName(imgPath)}";
var result = ocr.RecognizeText(imgPath, savePath);
Console.WriteLine($"result: {result.ToString()}"); using RapidOCRSharp ocr = new RapidOCRSharp(new ExecutionProviderDirectML(new OcrConfig(detectPath, recogPath, LangRec.CH, OCRVersion.PPOCRV5, clsPath), _deviceId));
var list = Directory.GetFiles(@"C:\code\model\OCRTestImages");
Stopwatch sw = new Stopwatch();
sw.Start();
var resPath = ocr.BatchParallelAsync(list.ToList(), saveDir, receiveAction: ReceiveResult);
sw.Stop();
Console.WriteLine($"BatchAsync Time: {sw.ElapsedMilliseconds} ms");
private static void ReceiveResult(OcrBatchResult batchResult)
{
Console.WriteLine(batchResult.ToString());
Console.WriteLine("------------------------------------------------------------");
}using RapidOCRSharp ocr = new RapidOCRSharp(new ExecutionProviderDirectML(new OcrConfig(detectPath, recogPath, LangRec.CH, OCRVersion.PPOCRV5, clsPath), _deviceId));
var list = Directory.GetFiles(@"D:\code\model\OCRTestImages");
var resPaths = ocr.BatchForeachAsync(list.ToList(), @"D:\code\model\OCRTestImagesResults");
await foreach (var item in resPaths)
{
Console.WriteLine(item.TextBlocks);
}private static void TestImage()
{
string imgPath = @"E:\Hp\ai-image\ADFtools\headerText.png";
string detectPath = @"D:\code\RapidOCRSharpOnnx\RapidOCRSharpOnnx.TestCommon\Models\ch_PP-OCRv5_det_mobile.onnx";
string recogPath = @"D:\code\RapidOCRSharpOnnx\RapidOCRSharpOnnx.TestCommon\Models\ch_PP-OCRv5_rec_mobile.onnx";
string clsPath = @"D:\code\RapidOCRSharpOnnx\RapidOCRSharpOnnx.TestCommon\Models\ch_PP-LCNet_x0_25_textline_ori_cls_mobile.onnx";
string font = @"C:\Windows\Fonts\msyh.ttc";
using RapidOCRSharp ocr = new RapidOCRSharp(new ExecutionProviderDirectML(new OcrConfig(detectPath, recogPath, font, OCRVersion.PPOCRV5, clsPath), _deviceId));
string savePath = $"res_{Path.GetFileName(imgPath)}";
var result = ocr.RecognizeText(imgPath, savePath);
Console.WriteLine($"result: {result.ToString()}");
}| OCR library | Version | language | Inference Engine |
|---|---|---|---|
| PaddleSharp | 3.0.1 | Paddle Inference C API .NET binding | Sdcb.PaddleInference |
| PaddleOCR | 3.5.0 | python | paddlepaddle |
| RapidOCR | 3.8.1 | python | openvino |
| RapidOCRSharpOnnx | 1.0.0 | C# | Intel.ML.OnnxRuntime.OpenVino |
| Hardware | Summary |
|---|---|
| Windows | Windows 11 Pro OS Version 25H2 |
| CPU | Intel Core Ultra 9 285k 3.7GHz |
| RAM | DDR5 128GB speed 4400MT/s |
| Storage | SSD 2TB |
Images: 60 images (image size: 1180x92)
PP-OCR Model: ch_PP-OCRv5_det_mobile, ch_PP-OCRv5_rec_mobile, ch_PP-LCNet_x0_25_textline_ori_cls_mobile
CPU inference time: 48.1769278s
CPU inference time: 9.2447871s
CPU inference time: 62.668516899924725s
CPU inference time: 17.963430000003427 s
| OCR library | Version | language | Inference Engine | Elapsed Time |
|---|---|---|---|---|
| PaddleSharp | 3.0.1 | Paddle Inference C API .NET binding | Sdcb.PaddleInference.runtime.win64.mkl version 3.1.0.54 CPU | 48.1769s |
| PaddleOCR | 3.5.0 | python | paddlepaddle version 3.2.0 CPU | 62.6685s |
| RapidOCR | 3.8.1 | python | openvino version 2026.1.0 21367 CPU | 17.9634s |
| RapidOCRSharpOnnx | 1.0.0 | C# | Intel.ML.OnnxRuntime.OpenVino CPU version 1.24.1 | 9.2447s |


