refactor(ocr): 优化 color_filter.rs
- 重构 `OcrBuilder` 移除is_pixel_matched,filter_image。 - 优化 `OcrBuilder` 的color_filter方法(部分逻辑转移给merge_to_vec) 。 - 新增 `ColorFilter` 特征增加merge_to_vec方法。
This commit is contained in:
11
src/lib.rs
11
src/lib.rs
@@ -98,12 +98,13 @@ impl DdddOcr {
|
||||
pub fn classification(&self, img: &DynamicImage) -> Result<String> {
|
||||
match &self.runtime {
|
||||
// Runtime::Ocr(s) => s.predict(img).run(),
|
||||
Runtime::Ocr(s) => s.builder().predict(img),
|
||||
// Runtime::Ocr(s) => s.builder().charset_restrict(&CharRestrict::Digit).predict(img),
|
||||
Runtime::Ocr(s) => s.builder().color_filter(&ColorPreset::Custom(vec![
|
||||
// 错误:下界 (82, 221, 14) 没问题
|
||||
// 但上界的 H 通道写成了 240,超过了 180 的法定上限!
|
||||
HsvRange::new((82, 221, 14), (240, 203, 82)),
|
||||
])).predict(img),
|
||||
// Runtime::Ocr(s) => s.builder().color_filter(&ColorPreset::Custom(vec![
|
||||
// // 错误:下界 (82, 221, 14) 没问题
|
||||
// // 但上界的 H 通道写成了 240,超过了 180 的法定上限!
|
||||
// HsvRange::new((82, 221, 14), (240, 203, 82)),
|
||||
// ])).predict(img),
|
||||
Runtime::Det(_) => Err(anyhow::anyhow!("当前模型是检测模型,无法执行 OCR")),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user