- 源码 316 文件收编为 rusto-rs/ 文件夹,随本仓库管理 - 移除内部 .git(补丁已存档 docs/rusto-rs-metal-patch-20260912.patch,上游可随时 re-clone) - target/ 与 docs/.yarn 缓存不入库;本地改动:ROCR_* 环境变量调优 + Metal 链接修复 + 预处理测试脚本
6.0 KiB
6.0 KiB
title, description, navigation, seo
| title | description | navigation | seo | ||||||
|---|---|---|---|---|---|---|---|---|---|
| Introduction | High-Performance Pure Rust OCR Library & Multi-Platform Toolkit |
|
|
::project-badges ::
RustO! is a high-performance Optical Character Recognition (OCR) engine and cross-platform toolkit written in pure Rust. Based on RapidOCR and powered by PaddleOCR deep learning models with Alibaba's MNN lightweight inference backend, RustO! delivers sub-second inference speeds, ultra-low memory overhead, zero OpenCV runtime dependencies, and 99.3%+ accuracy parity with native C++ OpenCV implementations.
🎯 Architecture Pipeline
RustO! orchestrates an end-to-end OCR and layout analysis pipeline optimized for edge devices and high-throughput servers:
flowchart TD
A["Input Image Source<br/>(Filesystem Path, Bytes Buffer, or Native URI)"] --> B["1. Preprocessing & Bounded Resize<br/>(Aspect-Ratio Scaling, Padding, Normalization)"]
B --> C["2. DBNet Text Detection<br/>(Heatmap, Binarization, Dilation, Contour Unclipping)"]
C --> D{"3. Line Orientation CLS?<br/>(Optional: Inverted 0° vs 180°)"}
D -->|Enabled| E["Rotate Upside-Down Text 180°"]
D -->|Bypassed / Disabled| F["Perspective Crop & Rayon Parallel Batching"]
E --> F
F --> G["4. CTC Text Recognition<br/>(Batched SVTR/CRNN, 50-Language Dictionary)"]
G --> H{"Output Granularity?"}
H -->|lines / words| I["Structured Output<br/>(TextResult with BoxPoints & Frame)"]
H -->|spatial| J["5. Spatial Layout Reconstruction<br/>(Row Y-Clustering & Column X-Alignment)"]
J --> K["Formatted Spatial Text<br/>(Preserved Tables, Receipts, Indentations)"]
⚡ Key Highlights & Advantages
- 🚀 100% Pure Rust Core: Zero OpenCV runtime dependency. Binarization, contour tracing, polygon clipping, and affine transformations are implemented in memory-safe Rust with SIMD acceleration.
- 📦 Ultra-Small Footprint: Core binaries are ~5 MB (self-contained) compared to 50+ MB for traditional OpenCV + ONNX runtime stacks.
- 📄 Human-Readable Spatial Layouts: Native support for reconstructing invoices, receipts, multi-column tables, and forms directly into visually formatted text.
- 🧠 Comprehensive Model Ecosystem: Out-of-the-box support for PP-OCRv6 (Tiny, Small, Medium), PP-OCRv5 (Mobile, Server), and PP-OCRv4 (Mobile, Server) architectures.
- 🌐 50+ Languages in One Model: PP-OCRv6 uses a unified dictionary supporting Latin, Cyrillic, CJK, Devanagari, Arabic, and more simultaneously.
- 📱 Universal Multi-Platform SDKs: First-class support for Rust, .NET / C#, React Native, iOS (Swift), Android (Kotlin), and C FFI.
📦 Supported Platforms & Ecosystem
| Platform | Target Package / Registry | Support Matrix |
|---|---|---|
| Rust | cargo add rusto-rs (crates.io) |
Linux, macOS, Windows, Android (NDK), iOS |
| .NET / C# | dotnet add package RustODotnet (NuGet) |
.NET 6.0+, .NET 8.0+, .NET Standard 2.0+ (Win/Mac/Linux) |
| React Native | npm install react-native-rusto (npm) |
React Native 0.70+ (New Arch & Paper), Expo |
| iOS | pod 'RustO' (CocoaPods) |
iOS 13.0+, Mac Catalyst (arm64, x86_64) |
| Android | com.github.byrizki.rusto-rs:rusto-android (JitPack) |
Android API 21+ (ARM64-v8a, ARMv7a, x86_64, x86) |
| C / Native | librusto.so / librusto.dylib / rusto.dll |
C99 / C++11 and any language with C FFI bindings |
| CLI | rusto binary |
Standalone command-line tool for desktop & CI pipelines |
📊 Performance & Parity Comparison
Benchmarks conducted on standard document scans (A4 invoice, 150 DPI) on an AMD Ryzen 7 / Apple M-series CPU:
| Metric | RustO! (Pure Rust + MNN) | Traditional OpenCV + C++ Pipeline | Advantage |
|---|---|---|---|
| Detection Speed | ~80 ms | ~85 ms | ⚡ 6% faster |
| Recognition Speed | ~120 ms | ~125 ms | ⚡ 4% faster |
| Accuracy Parity | 99.3%+ | Baseline (100%) | 🎯 Identical bounding boxes |
| Binary Footprint | ~5 MB | ~55 MB+ (libopencv, onnxruntime) | 📦 90% reduction |
| Peak Memory (RAM) | ~120 MB | ~260 MB+ | 🔒 54% lower memory |
| Safety | Memory-safe (Rust guarantees) | Manual pointers / potential leaks | 🛡️ Zero memory bugs |
Next Steps
- Installation Guide — Set up RustO! on your preferred platform.
- Quick Start Tutorial — Run your first OCR scan in under 5 minutes.
- How-To Guides — Deep-dive tutorials for each programming language.
- API Reference — Complete specifications for
InitializeConfigandOcrRunOptions.