zibo-chen/ocr-rs

高性能OCR识别库,支持上百种语言,提供命令行、图形界面及C API多种调用方式,使用便捷高效。 High-performance OCR library powered by PaddleOCR v4/v5/v6 with MNN backend. Supports 10+ languages (Chinese, English, Japanese, Korean, Arabic, Cyrillic, Thai, etc). Provides Rust crate + C API + CLI tools. Fast, lightweight, easy-to-integrate.

What it solves

ocr-rs is a lightweight Rust library that provides Optical Character Recognition (OCR) capabilities. It allows developers to extract text from images, supporting a wide range of languages including Chinese, English, Japanese, and various Latin-script languages, while maintaining high performance through the use of the MNN inference runtime.

How it works

The library acts as a wrapper around PaddleOCR models, utilizing the MNN inference runtime for execution. It supports multiple model tiers (v4, v5, and v6) with different trade-offs between size and accuracy. The system consists of two primary components: a text detection model (to find where text is located) and a text recognition model (to translate those regions into characters).

Key technical features include:

  • Model Conversion: A Python script is provided to convert PaddlePaddle models into the MNN format (often using FP16 to reduce size).
  • Hardware Acceleration: It supports multiple backends including CPU, CUDA, Vulkan, and Metal, with automatic selection of prebuilts where possible.
  • Robust Mode: An opt-in mode for handling images that mix horizontal and vertical text by running detection on rotated copies of the image.
  • Character Alignment: An API that provides the exact coordinates of each character within the detected text, derived from CTC time steps without requiring extra inference passes.

Who it’s for

Rust developers who need to integrate high-performance, local OCR functionality into their applications without relying on external cloud APIs.

Highlights

  • Multi-language Support: Supports 50+ languages across different model versions, including specialized scripts for Korean, Arabic, and Cyrillic.
  • Flexible Inference: Offers end-to-end OCR, detection-only, or recognition-only engines.
  • GPU Acceleration: Native support for Metal, Vulkan, and CUDA to speed up processing.
  • Memory Optimization: Uses OpenCL buffer memory by default to handle very wide text regions that would otherwise exceed GPU image-width limits.
  • Performance Guardrails: Includes built-in Criterion benchmarks and CI-style performance smoke tests to prevent regressions.

相關

  • 專案
  • 專案
  • 專案
  • 專案