diff --git a/learned.json b/learned.json index 95f2d15..db50105 100644 --- a/learned.json +++ b/learned.json @@ -1,9 +1,13 @@ { "learned_images": {}, "learned_tracks": { + "//8/5J/Ez8MfyX/g/8w/25/C3+nfzx/GH8D/+/////8=": "Tilksport GP", + "////5//Hf8I/4p/gz+DP99/zn4eflx+QP8D///////8=": "Whistle Valley", "////5//Hf+I/4p/gz+DP99/zn4efnx+CP8D///////8=": "Whistle Valley", - "////z//Af55/zj/jn/Hf/c/Bz48Pgw/A//////////8=": "Sugar Hill", "////5//Hf+I/4p/gz+DP99/zn4eflx+EP8D///////8=": "Whistle Valley", - "//8//z//H/gfwB/ET9DP04/MH+D/4f////////////8=": "Maple Ridge" + "////z//Af55/zj/jn/Hf/c/Bz48Pgw/A//////////8=": "Sugar Hill", + "//8//p/8z/0f/X/i/8w/25/C3+nPzx/EH8j///////8=": "Tilksport Club", + "//8//z//H/gfwB/ET9DP04/MH+D/4f////////////8=": "Maple Ridge", + "//8/+B/yT/RPxR/J/9Ofxw/mz8DP2x/BH8D///////8=": "Thunder Point" } } \ No newline at end of file diff --git a/race_stats.csv b/race_stats.csv index 7e7c643..d166a72 100644 --- a/race_stats.csv +++ b/race_stats.csv @@ -75,3 +75,9 @@ 2022-06-01-03:56 (Sugar Hill),Sugar Hill,GP,2,23.252,23.252,86,83,87, 2022-06-01-03:58 (Maple Ridge),Maple Ridge,GP,1,27.517,27.517,100,89,90, 2022-06-01-03:58 (Maple Ridge),Maple Ridge,GP,2,27.885,27.517,,78,79, +2022-06-01-04:18 (Whistle Valley),Whistle Valley,GP,1,23.457,23.457,96,,92, +2022-06-01-04:18 (Whistle Valley),Whistle Valley,GP,2,23.769,23.457,91,84,85, +2022-06-01-04:19 (Tilksport GP),Tilksport GP,GP,1,37.578,36.127,99,85,86, +2022-06-01-04:19 (Tilksport GP),Tilksport GP,GP,2,36.127,36.127,99,71,73, +2022-06-01-04:21 (Tilksport Club),Tilksport Club,GP,1,32.790,32.790,96,88,91, +2022-06-01-04:23 (Thunder Point),Thunder Point,GP,1,36.683,36.683,97,83,89, diff --git a/src/analysis.rs b/src/analysis.rs index c21da6a..6cc1a9f 100644 --- a/src/analysis.rs +++ b/src/analysis.rs @@ -7,6 +7,7 @@ use std::{ use anyhow::Result; use egui_extras::RetainedImage; use image::RgbImage; +use img_hash::ImageHash; use scrap::{Capturer, Display}; use crate::{ @@ -70,6 +71,13 @@ fn get_track_hash(config: &Config, image: &RgbImage) -> Option { fn get_track_name(learned: &LearnedConfig, hash: &Option) -> Option { let hash = hash.as_ref()?; + for (learned_hash_b64, learned_track) in &learned.learned_tracks { + let learned_hash: ImageHash> = img_hash::ImageHash::from_base64(learned_hash_b64).ok()?; + let current_hash: ImageHash> = img_hash::ImageHash::from_base64(hash).ok()?; + if current_hash.dist(&learned_hash) <= 7 { + return Some(learned_track.to_owned()) + } + } learned.learned_tracks.get(hash).cloned() } @@ -90,7 +98,7 @@ fn handle_new_frame(state: &mut AppState, frame: LapState, image: RgbImage) { .expect("failed to save screenshot"), ), race_time: Some(SystemTime::now()), - track_hash: track_hash.clone(), + track_hash, track: track_name.unwrap_or_default(), ..Default::default() }; diff --git a/src/image_processing.rs b/src/image_processing.rs index 4f0a5d7..1640db2 100644 --- a/src/image_processing.rs +++ b/src/image_processing.rs @@ -1,4 +1,4 @@ -use image::{codecs::png::{PngEncoder, PngDecoder}, ColorType, ImageEncoder, Rgb, RgbImage, DynamicImage}; +use image::{codecs::png::{PngEncoder}, ColorType, ImageEncoder, Rgb, RgbImage}; use serde::{Deserialize, Serialize}; diff --git a/src/main.rs b/src/main.rs index b3b1c40..19a7706 100644 --- a/src/main.rs +++ b/src/main.rs @@ -386,14 +386,14 @@ impl eframe::App for AppUi { let learned = state.learned.clone(); let ocr_cache = state.ocr_cache.clone(); if let Some(race) = &mut state.current_race { - ui.heading("Current Race"); + ui.heading(&format!("Current Race: {}", race.name())); show_race_state( ui, &mut self.ui_state, "current", race, config.clone(), - learned.clone(), + learned, ocr_cache.clone(), ); }