Releasing SimdPaddleOCR – a complete OCR inference library in pure C#
说明与用途
SimdPaddleOCR 是一款完全用 C# 编写的 OCR 推理库,消除了对本机依赖的需求,简化了部署,并在相同模型上实现了比纯 C 参考实现更快的推理速度。
问题
Deploying OCR engines in .NET projects often requires native dependencies (P/Invoke, OpenCV DLLs, CUDA, etc.) that complicate distribution and cause runtime failures on different platforms.
结果
SimdPaddleOCR delivers end‑to‑end scene OCR inference entirely in managed code, eliminating native DLLs, reducing deployment friction, and achieving faster inference than a comparable pure‑C implementation on the same model.
工作流
- 1. Add NuGet packages: Sdcb.SimdPaddleOCR, Sdcb.SimdPaddleOCR.Models.ChineseV6Tiny, and an image decoder such as SixLabors.ImageSharp.
- 2. Load the embedded model: await PaddleOcrAll.LoadAsync(ChineseV6TinyModels.Default).
- 3. Decode an image to a raw 8‑bit BGR byte array using any image library (ImageSharp, SkiaSharp, OpenCvSharp, etc.).
- 4. Run inference: PaddleOcrResult result = ocr.Run(bgr, width, height).
- 5. Consume the OCR text from result.Text.
- 6. (Optional) Use other model packages (Small, Medium, TextLineOrientation) or load custom ONNX files from a local path.
证据
SimdPaddleOCR is a complete OCR inference engine written entirely in C#. It does not depend on Paddle Inference, does not depend on ONNX Runtime, and does not ship OpenCV native DLLs.
On the same model, the C# version is faster end-to-end than the pure C version (the trade‑off is higher managed memory; native C still wins there).
Install the core package and the tiny Chinese model in your project (installing tiny automatically pulls in the orientation classification package TextLineOrientation).
- 记录日期: 2026-09-13T20:00:55.965Z