1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
//! # OAR OCR
//!
//! A Rust OCR library that extracts text from document images using ONNX models.
//! Supports text detection, recognition, document orientation, and rectification.
//!
//! ## Features
//!
//! - Complete OCR pipeline from image to text
//! - High-level builder APIs for easy pipeline configuration
//! - Model adapter system for easy model swapping
//! - Batch processing support
//! - ONNX Runtime integration for fast inference
//!
//! ## Components
//!
//! - **Text Detection**: Find text regions in images
//! - **Text Recognition**: Convert text regions to readable text
//! - **Layout Detection**: Identify document structure elements (text blocks, titles, tables, figures)
//! - **Document Orientation**: Detect document rotation (0°, 90°, 180°, 270°)
//! - **Document Rectification**: Fix perspective distortion
//! - **Text Line Classification**: Detect text line orientation
//! - **Seal Text Detection**: Detect text in circular seals
//! - **Formula Recognition**: Recognize mathematical formulas
//!
//! ## Modules
//!
//! * [`core`] - Core traits, error handling, and batch processing
//! * [`domain`] - Domain types like orientation helpers and prediction models
//! * [`models`] - Model adapters for different OCR tasks
//! * [`oarocr`] - High-level OCR pipeline builders
//! * [`processors`] - Image processing utilities
//! * [`utils`] - Utility functions for images and tensors
//! * [`predictors`] - Task-specific predictor interfaces
//!
//! ## Quick Start
//!
//! ### OCR Pipeline
//!
//! ```rust,no_run
//! use oar_ocr::oarocr::{OAROCRBuilder, OAROCR};
//! use oar_ocr::utils::load_image;
//! use std::path::Path;
//!
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
//! // Create OCR pipeline with required components
//! let ocr = OAROCRBuilder::new(
//! "models/text_detection.onnx",
//! "models/text_recognition.onnx",
//! "models/character_dict.txt"
//! )
//! .with_document_image_orientation_classification("models/doc_orient.onnx")
//! .with_text_line_orientation_classification("models/line_orient.onnx")
//! .image_batch_size(4)
//! .region_batch_size(32)
//! .build()?;
//!
//! // Process images
//! let image = load_image(Path::new("document.jpg"))?;
//! let results = ocr.predict(vec![image])?;
//!
//! for result in results {
//! for region in result.text_regions {
//! if let Some(text) = region.text {
//! println!("Text: {}", text);
//! }
//! }
//! }
//! # Ok(())
//! # }
//! ```
//!
//! ### Document Structure Analysis
//!
//! ```rust,no_run
//! use oar_ocr::oarocr::{OARStructureBuilder, OARStructure};
//! use std::path::Path;
//!
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
//! // Create structure analysis pipeline
//! let structure = OARStructureBuilder::new("models/layout_detection.onnx")
//! .with_table_classification("models/table_classification.onnx")
//! .with_table_cell_detection("models/table_cell_detection.onnx", "wired")
//! .with_table_structure_recognition("models/table_structure.onnx", "wired")
//! .table_structure_dict_path("models/table_structure_dict.txt")
//! .with_formula_recognition(
//! "models/formula_recognition.onnx",
//! "models/tokenizer.json",
//! "pp_formulanet"
//! )
//! .build()?;
//!
//! // Analyze document structure
//! let result = structure.predict("document.jpg")?;
//!
//! println!("Layout elements: {}", result.layout_elements.len());
//! println!("Tables: {}", result.tables.len());
//! println!("Formulas: {}", result.formulas.len());
//! # Ok(())
//! # }
//! ```
// Re-export core modules from oar-ocr-core
// Utils module with re-exports from core and OCR-specific visualization
// High-level OCR API (remains in main crate)
// Re-export derive macros for convenient use
pub use ;
/// Prelude module for convenient imports.
///
/// Bring the essentials into scope with a single use statement:
///
/// ```rust
/// use oar_ocr::prelude::*;
/// ```
///
/// Included items focus on the most common tasks:
/// - Builder APIs (`OAROCRBuilder`, `OARStructureBuilder`)
/// - Edge processors (`EdgeProcessorConfig`)
/// - Results (`OAROCRResult`, `TextRegion`)
/// - Essential error and result types (`OCRError`, `OcrResult`)
/// - Basic image loading (`load_image`, `load_images`)
///
/// For advanced customization (model adapters, traits),
/// import directly from the respective modules (e.g., `oar_ocr::models`, `oar_ocr::core::traits`).