From 62c60723a77e9d3b984f94924194b1a0ba753916 Mon Sep 17 00:00:00 2001 From: Melody Horn Date: Sun, 5 Dec 2021 21:31:26 -0700 Subject: recognize connection errors too --- src/ocr.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/ocr.rs') diff --git a/src/ocr.rs b/src/ocr.rs index 14021cc..52e0020 100644 --- a/src/ocr.rs +++ b/src/ocr.rs @@ -1,4 +1,4 @@ -use image::{DynamicImage, GrayImage, ImageFormat}; +use image::{GrayImage, ImageFormat}; use imageproc::template_matching::MatchTemplateMethod; use lazy_static::lazy_static; @@ -36,11 +36,10 @@ fn x_matches(image: &GrayImage, template: &GrayImage) -> Vec { .collect() } -pub fn ocr(image: DynamicImage) -> Option { - let grayscale_image = image::imageops::grayscale(&image); +pub fn ocr(image: &GrayImage) -> Option { let mut digit_x_positions: Vec<(u8, u32)> = (0..10) .flat_map(|i| { - x_matches(&grayscale_image, &REFERENCES[i as usize]) + x_matches(image, &REFERENCES[i as usize]) .into_iter() .map(move |x| (i, x)) }) -- cgit v1.2.3