aboutsummaryrefslogtreecommitdiff
path: root/src/ocr.rs
diff options
context:
space:
mode:
authorMelody Horn <melody@boringcactus.com>2021-12-05 21:31:26 -0700
committerMelody Horn <melody@boringcactus.com>2021-12-05 21:31:26 -0700
commit62c60723a77e9d3b984f94924194b1a0ba753916 (patch)
tree91b95595576e144bebf6164d38ee0e4d6fe0f559 /src/ocr.rs
parentfffdc8aab1086eb60bc9537fafb725ba876c46f2 (diff)
downloadqueue-go-brrr-62c60723a77e9d3b984f94924194b1a0ba753916.tar.gz
queue-go-brrr-62c60723a77e9d3b984f94924194b1a0ba753916.zip
recognize connection errors too
Diffstat (limited to 'src/ocr.rs')
-rw-r--r--src/ocr.rs7
1 files changed, 3 insertions, 4 deletions
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<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))
})