tracking delta positions
This commit is contained in:
parent
aab5eef2db
commit
05fca55c73
|
@ -91,5 +91,5 @@
|
|||
"track_recognition_threshold": 10,
|
||||
"dump_frame_fraction": null,
|
||||
"light_mode": false,
|
||||
"font_scale": 1.3
|
||||
"font_scale": 1.2
|
||||
}
|
|
@ -85,7 +85,7 @@ fn merge_frames(prev: &LapState, next: &LapState) -> LapState {
|
|||
}
|
||||
}
|
||||
fn handle_new_frame(state: &mut AppState, lap_state: LapState, image: &RgbImage) {
|
||||
if lap_state.lap_time.is_some() {
|
||||
if lap_state.lap_time.is_some() || (lap_state.lap.is_some() && lap_state.total_laps.is_some()) {
|
||||
state.last_frame = Some(lap_state.clone());
|
||||
state.frames_without_lap = 0;
|
||||
|
||||
|
@ -109,6 +109,7 @@ fn handle_new_frame(state: &mut AppState, lap_state: LapState, image: &RgbImage)
|
|||
track_hash,
|
||||
track: track_name.unwrap_or_default(),
|
||||
inferred_track,
|
||||
starting_position: lap_state.position.unwrap_or_default(),
|
||||
total_laps: lap_state.total_laps.unwrap_or_default(),
|
||||
total_positions: lap_state.total_positions.unwrap_or_default(),
|
||||
..Default::default()
|
||||
|
|
38
src/main.rs
38
src/main.rs
|
@ -178,11 +178,19 @@ fn show_race_state(
|
|||
config: &Config,
|
||||
ocr_db: &OcrDatabase,
|
||||
) {
|
||||
ui.label(format!("Total laps: {}", race.total_laps));
|
||||
ui.label(format!("Total competitors: {}", race.total_positions));
|
||||
if race.total_laps > 1 {
|
||||
ui.label(format!("Laps: {}", race.total_laps));
|
||||
}
|
||||
if race.total_positions > 1 {
|
||||
ui.label(format!(
|
||||
"Starting position: {}/{}",
|
||||
race.starting_position, race.total_positions
|
||||
));
|
||||
}
|
||||
egui::Grid::new(format!("race:{}", race_name)).show(ui, |ui| {
|
||||
ui.label("Lap");
|
||||
ui.label("Position");
|
||||
ui.label("Δ P");
|
||||
ui.label("Time");
|
||||
ui.label("Δ Previous");
|
||||
ui.label("Δ Best");
|
||||
|
@ -198,6 +206,28 @@ fn show_race_state(
|
|||
ui.label(format!("#{}", lap.lap.unwrap_or(i + 1)));
|
||||
ui.label(format!("P{}", lap.position.unwrap_or_default()));
|
||||
|
||||
match lap
|
||||
.position
|
||||
.unwrap_or_default()
|
||||
.cmp(&race.starting_position)
|
||||
{
|
||||
std::cmp::Ordering::Less => ui.colored_label(
|
||||
Color32::GREEN,
|
||||
format!(
|
||||
"+{}",
|
||||
race.starting_position - lap.position.unwrap_or_default()
|
||||
),
|
||||
),
|
||||
std::cmp::Ordering::Equal => ui.label("--"),
|
||||
std::cmp::Ordering::Greater => ui.colored_label(
|
||||
Color32::RED,
|
||||
format!(
|
||||
"-{}",
|
||||
lap.position.unwrap_or_default() - race.starting_position
|
||||
),
|
||||
),
|
||||
};
|
||||
|
||||
if Some(lap_time) == fastest_lap {
|
||||
ui.colored_label(Color32::GREEN, format_time(lap_time));
|
||||
} else {
|
||||
|
@ -392,7 +422,7 @@ impl eframe::App for AppUi {
|
|||
ui.separator();
|
||||
ui.heading("Strategy");
|
||||
if let Some(tyre_wear) = race.tyre_wear() {
|
||||
ui.label(&format!("Median Tyre Wear: {}", tyre_wear));
|
||||
ui.label(&format!("Tyre Wear: {}", tyre_wear));
|
||||
if let Some(tyres) = frame.tyres {
|
||||
ui.label(&format!(
|
||||
"Out of tires in {:.1} lap(s)",
|
||||
|
@ -401,7 +431,7 @@ impl eframe::App for AppUi {
|
|||
}
|
||||
}
|
||||
if let Some(gas_wear) = race.gas_per_lap() {
|
||||
ui.label(&format!("Median Gas Wear: {}", gas_wear));
|
||||
ui.label(&format!("Gas: {}", gas_wear));
|
||||
if let Some(gas) = frame.gas {
|
||||
ui.label(&format!(
|
||||
"Out of gas in {:.1} lap(s)",
|
||||
|
|
|
@ -107,6 +107,7 @@ pub struct RaceState {
|
|||
pub laps: Vec<LapState>,
|
||||
pub last_lap_record_time: Option<Instant>,
|
||||
|
||||
pub starting_position: usize,
|
||||
pub total_laps: usize,
|
||||
pub total_positions: usize,
|
||||
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
- Autocomplete for car/track
|
||||
- Detect car name from load screen
|
||||
- TTS for pit strategies
|
||||
- Show delta positions
|
||||
- Post race metric charts
|
||||
- [DONE] Show delta positions
|
||||
- [DONE] Track penalties
|
||||
- [DONE] Re-do debug/learn functionality
|
||||
- [DONE] Detect position, max laps
|
||||
|
|
Loading…
Reference in New Issue