feat: 重构 CTC 解码逻辑
- 重构 ctc_decode 为关联函数并优化内存分配。 - 增加 单元测试和集成测试
This commit is contained in:
16
tests/ocr_test.rs
Normal file
16
tests/ocr_test.rs
Normal file
@@ -0,0 +1,16 @@
|
||||
use ddddocr_rs::DdddOcr; // 假设你的包名是这个
|
||||
|
||||
#[test]
|
||||
fn test_full_classification() {
|
||||
// 1. 初始化模型
|
||||
let ocr = DdddOcr::new("model/common.onnx").expect("模型加载失败");
|
||||
|
||||
// 2. 加载测试图片
|
||||
let img = image::open("samples/code3.png").expect("测试图片不存在");
|
||||
|
||||
// 3. 执行识别
|
||||
let result = ocr.classification(&img).expect("识别过程出错");
|
||||
|
||||
println!("识别结果: {}", result);
|
||||
assert!(!result.is_empty());
|
||||
}
|
||||
Reference in New Issue
Block a user