OAR (ONNXRuntime And Rust) OCR
A comprehensive OCR (Optical Character Recognition) library, built in Rust with ONNX Runtime for efficient inference.
Quick Start
Installation
Add OAR OCR to your project's Cargo.toml:
Or manually add it to your Cargo.toml:
[]
= "0.1"
Basic Usage
Here's a simple example of how to use OAR OCR to extract text from an image:
use *;
use Path;
This example creates an OCR pipeline using pre-trained models for text detection and recognition. The pipeline processes the input image and returns the recognized text along with confidence scores.
Running Examples
The library includes several examples to help you get started:
# Complete OCR pipeline example
# Text recognition example
Pre-trained Models
OAR OCR provides several pre-trained models for different OCR tasks. Download them from the GitHub Releases page.
Text Detection Models
Choose between mobile and server variants based on your needs:
- Mobile: Smaller, faster models suitable for real-time applications
- Server: Larger, more accurate models for high-precision requirements
| Model Type | File Name | Size | Download Link |
|---|---|---|---|
| Mobile | ppocrv5_mobile_det.onnx |
4.8MB | Download |
| Server | ppocrv5_server_det.onnx |
87.7MB | Download |
Text Recognition Models
Similar to detection models, recognition models come in mobile and server variants:
| Model Type | File Name | Size | Download Link |
|---|---|---|---|
| Mobile | ppocrv5_mobile_rec.onnx |
16.5MB | Download |
| Server | ppocrv5_server_rec.onnx |
84.1MB | Download |
Character Dictionaries
Character dictionaries are required for text recognition models. Choose the appropriate dictionary for your models:
| Dictionary | File Name | Description | Download Link |
|---|---|---|---|
| PPOCRv5 | ppocrv5_dict.txt |
For PPOCRv5 models | Download |
| PPOCR Keys v1 | ppocr_keys_v1.txt |
For older PPOCR models | Download |
Optional Models
These models provide additional functionality for specialized use cases:
| Model Type | File Name | Size | Description | Download Link |
|---|---|---|---|---|
| Document Orientation | pplcnet_x1_0_doc_ori.onnx |
6.7MB | Detect document rotation | Download |
| Text Line Orientation (Light) | pplcnet_x0_25_textline_ori.onnx |
988KB | Detect text line orientation | Download |
| Text Line Orientation (Standard) | pplcnet_x1_0_textline_ori.onnx |
6.7MB | Detect text line orientation | Download |
| Document Rectification | uvdoc.onnx |
31.6MB | Fix perspective distortion | Download |
Acknowledgments
This project builds upon the excellent work of several open-source projects:
-
ort: Rust bindings for ONNX Runtime by pykeio. This crate provides the Rust interface to ONNX Runtime that powers the efficient inference engine in this OCR library.
-
PaddleOCR: Baidu's awesome multilingual OCR toolkits based on PaddlePaddle. This project utilizes PaddleOCR's pre-trained models, which provide excellent accuracy and performance for text detection and recognition across multiple languages.