aboutsummaryrefslogtreecommitdiff
path: root/src/ocr.rs
diff options
context:
space:
mode:
authorMelody Horn <melody@boringcactus.com>2021-12-03 23:30:52 -0700
committerMelody Horn <melody@boringcactus.com>2021-12-03 23:30:52 -0700
commitce5be7f783ac7c6589b501433caafd717c6e119f (patch)
treec6827e1c8b4679501d317a8ab6e1f4a2b136dae0 /src/ocr.rs
parent7cc6b6414d30e95e763baadee2f493c8f69329ac (diff)
downloadqueue-go-brrr-ce5be7f783ac7c6589b501433caafd717c6e119f.tar.gz
queue-go-brrr-ce5be7f783ac7c6589b501433caafd717c6e119f.zip
swag
Diffstat (limited to 'src/ocr.rs')
-rw-r--r--src/ocr.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/ocr.rs b/src/ocr.rs
index bc7e535..cde116f 100644
--- a/src/ocr.rs
+++ b/src/ocr.rs
@@ -22,12 +22,12 @@ fn x_matches(image: &GrayImage, template: &GrayImage) -> Vec<u32> {
);
match_values
.enumerate_pixels()
- .filter(|(_x, _y, pix)| pix.0[0] > 0.9)
+ .filter(|(_x, _y, pix)| pix.0[0] > 0.95)
.map(|(x, _y, _pix)| x)
.collect()
}
-pub fn ocr(image: DynamicImage) -> u32 {
+pub fn ocr(image: DynamicImage) -> Option<u32> {
let grayscale_image = image::imageops::grayscale(&image);
let mut digit_x_positions: Vec<(u8, u32)> = (0..10)
.flat_map(|i| {
@@ -46,5 +46,5 @@ pub fn ocr(image: DynamicImage) -> u32 {
.map(|(i, _x)| format!("{}", i))
.collect();
dbg!(&digits);
- digits.parse().unwrap()
+ digits.parse().ok()
}