diff options
author | Melody Horn <melody@boringcactus.com> | 2021-12-03 23:30:52 -0700 |
---|---|---|
committer | Melody Horn <melody@boringcactus.com> | 2021-12-03 23:30:52 -0700 |
commit | ce5be7f783ac7c6589b501433caafd717c6e119f (patch) | |
tree | c6827e1c8b4679501d317a8ab6e1f4a2b136dae0 /src/ocr.rs | |
parent | 7cc6b6414d30e95e763baadee2f493c8f69329ac (diff) | |
download | queue-go-brrr-ce5be7f783ac7c6589b501433caafd717c6e119f.tar.gz queue-go-brrr-ce5be7f783ac7c6589b501433caafd717c6e119f.zip |
swag
Diffstat (limited to 'src/ocr.rs')
-rw-r--r-- | src/ocr.rs | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -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() } |