ONNX-based OCR engine using PaddleOCR models, written in Rust.
- Text Detection & Recognition — Complete OCR pipeline with DBNet detection and CRNN recognition
- Document Orientation Classification — PP-LCNet classifier for 0°/90°/180°/270° rotation detection and auto-correction
- Hardware Acceleration — ONNX Runtime with CPU, DirectML, CUDA, OpenVINO, NNAPI, CoreML, CANN support
- Cross-platform — Windows, Linux, macOS, Android (via FFI), iOS (via FFI)
- Concurrent Processing — rayon parallel execution + session pooling
- Fine-grained Control — Step-by-step API: detect → recognize, or full pipeline with ordering modes
- Minimal Dependencies — Only ONNX models needed, no external runtime libraries
use paddleocr_rs_onnx::{OcrEngine, OrderBy};
let det_model = std::fs::read("ch_PP-OCRv4_det_infer.onnx")?;
let rec_model = std::fs::read("ch_PP-OCRv4_rec_infer.onnx")?;
let keys = std::fs::read("ppocr_keys_v1.txt")?;
let engine = OcrEngine::new(&det_model, &rec_model, &keys)?;
let image = image::open("test.png")?;
let blocks = engine.recognize_all(&image, OrderBy::Horizontal)?;
for block in &blocks {
println!("{} ({:.2}%)", block.text, block.confidence * 100.0);
}[dependencies]
paddleocr_rs_onnx = "0.2"- API Overview — Modules, structs, return types
- OcrEngine — Detection and recognition API
- DocOrientationClassifier — Orientation detection and correction
- Hardware Acceleration — AccelerationDevice, platform requirements, EP features
- FFI API — C-compatible API
PaddleOCR-rs supports Android and iOS platforms via C FFI interface.
- CPU: ✅ Supported (via ONNX Runtime)
- NNAPI: ✅ Supported (via nnapi feature)
- Targets: aarch64-linux-android, armv7-linux-androideabi (requires custom build), x86_64-linux-android (requires custom build)
- CPU: ✅ Supported (via ONNX Runtime)
- CoreML: ✅ Supported (via coreml feature)
- Targets: aarch64-apple-ios, aarch64-apple-ios-sim
# Android
./build-android.sh aarch64-linux-android --release
# iOS
./build-ios.sh aarch64-apple-ios --release- xc-ocr-onnx — Tauri 2 desktop GUI app, supports image / DOCX / PDF OCR with dynamic model switching
examples/android-demo/— Android Kotlin exampleexamples/ios-demo/— iOS Swift example
This project is one of several Rust implementations of PaddleOCR. Below is a comprehensive comparison of the three main implementations:
| Platform/Backend | PaddleOCR-rs | paddle-ocr-rs | rust-paddle-ocr |
|---|---|---|---|
| Windows | |||
| CUDA | ✅ (via cuda feature) |
✅ | ✅ |
| DirectML | ✅ | ✅ | ❌ |
| OpenVINO | ✅ (via openvino feature) |
❌ | ❌ |
| Linux | |||
| CUDA | ✅ (via cuda feature) |
✅ | ✅ |
| CANN | ✅ (via cann feature) |
✅ | ❌ |
| OpenVINO | ✅ (via openvino feature) |
❌ | ❌ |
| macOS | |||
| Metal | ✅ (via metal feature) |
❌ | ✅ |
| CoreML | ✅ (via coreml feature) |
❌ | ✅ |
| Android | |||
| NNAPI | ✅ (via nnapi feature) |
❌ | ❌ |
| CPU | ✅ | ✅ | ✅ |
| iOS | |||
| CoreML | ✅ (via coreml feature) |
❌ | ✅ |
| CPU | ✅ | ✅ | ✅ |
| Feature | PaddleOCR-rs | paddle-ocr-rs | rust-paddle-ocr |
|---|---|---|---|
| Model Format Support | ✅ ONNX only | ✅ ONNX format | ✅ MNN format |
| Document Orientation | PP-LCNet classifier | PP-OCR v2.0 classifier | PP-LCNet classifier |
| Concurrency | ✅ rayon parallel + session pooling | ✅ rayon parallel + batch inference | |
| External Interfaces | ✅ Rust API + C FFI API (via ffi feature) |
✅ YAML config + CLI (rapidocr) | ✅ C API (cdylib) + CLI (newbee-ocr-cli) |
| Memory/Type Safety | ✅ Memory-safe Rust + strong typing | ✅ Memory-safe Rust + strong typing | ✅ Memory-safe Rust (mnn-rs) + |
| Concurrency Safety | ✅ Thread-safe by design | ✅ Thread-safe (Arc + Mutex) |
This project is built upon the work of the following projects:
- PaddleOCR - Provides models
- FastDeploy - Provides runtime reference
- MaaFramework - Provides architecture reference
MIT