refactor(ocr): 优化 HSV 颜色过滤架构,实现快捷预设免检与大一统 Custom 变体

- 重构 `ColorPreset` 枚举,新增 `Custom(Vec<HsvRange>)` 变体。
 - 优化 `ColorFilter` 特征兼容多路组合宏。
 - 新增 `validate_self` 特征多态方法,实现责任分离:库担保的快捷预设 0 运行时开销免检放行,仅对 `Custom` 动态数据进行严格自检。
 - 优化 `OcrBuilder::color_filter` 接收 `&dyn ColorFilter` 特征对象,完美兼容原有声明式宏与链式调用熔断机制。
 - 借鉴 `reqwest` 的延迟错误处理模式,完善 `OcrBuilder` 的链式调用熔断(毒化)状态机。
This commit is contained in:
2026-06-18 17:40:29 +08:00
parent 189f2bd697
commit 62d5e7a0ca
5 changed files with 285 additions and 7 deletions

View File

@@ -66,7 +66,7 @@ fn test_full_classification() {
let ocr = DdddOcrBuilder::new().build().expect("模型加载失败");
// 2. 加载测试图片
let img = image::open("samples/code3.png").expect("测试图片不存在");
let img = image::open("samples/code2.png").expect("测试图片不存在");
// 3. 执行识别
let result = ocr.classification(&img).expect("识别过程出错");