Files
ddddocr-rs/ddddocr-core/src/lib.rs
CNWei 4fd38022fd refactor: 重构 core 包目录结构并消除旧版 mod.rs
- 优化 剥离 models,algo 层并平铺业务模块
- 重构 统一使用现代 filename.rs + 文件夹结构替代旧版 mod.rs
2026-07-11 17:38:30 +08:00

38 lines
1.1 KiB
Rust
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

pub mod det;
pub mod error;
pub mod ocr;
mod slide;
pub mod utils;
use crate::error::Result;
pub use crate::slide::{SlideResult, Slider};
pub use crate::det::{DetBuilder, DetectionResult, Detector};
pub use crate::ocr::{Ocr, OcrBuilder, OcrResult};
pub use ocr::metadata::ModelMetadata;
// DetSession
pub enum OcrOutput {
Indices(ndarray::Array1<i64>), // 拥有完整所有权的 1维数组可任意传递和返回
Logits(ndarray::Array2<f32>),
}
/// 2. 目标检测专属的、编译期安全的输出枚举
pub enum DetOutput {
Detection(ndarray::Array3<f32>), // 拥有完整所有权的 2维矩阵可任意传递和返回
}
/// 核心层定义的统一推理引擎接口。
/// 未来的 ddddocr-tract 和 ddddocr-ort 都必须实现这个 Trait
pub trait InferenceEngine {
/// 关联类型:具体的 Session 需要声明自己到底产出什么枚举
type Output;
fn inference(&self, input_array: ndarray::Array4<f32>) -> Result<Self::Output>;
}
pub trait OcrEngine: InferenceEngine<Output = OcrOutput> {
fn metadata(&self) -> &ModelMetadata;
}
pub trait DetEngine: InferenceEngine<Output = DetOutput> {}