diff options
Diffstat (limited to 'src/ocr.rs')
-rw-r--r-- | src/ocr.rs | 7 |
1 files changed, 3 insertions, 4 deletions
@@ -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<u32> { .collect() } -pub fn ocr(image: DynamicImage) -> Option<u32> { - let grayscale_image = image::imageops::grayscale(&image); +pub fn ocr(image: &GrayImage) -> Option<u32> { 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)) }) |