adjust configs, update to local-only OCR

This commit is contained in:
Scott Pruett 2022-06-03 22:30:07 -04:00
parent e195158218
commit 8f4c97a238
9 changed files with 126 additions and 25 deletions

View File

@ -40,8 +40,7 @@
"x": 2325,
"y": 222,
"width": 183,
"height": 43,
"use_ocr_cache": false
"height": 43
}
],
"track_region": {
@ -59,7 +58,5 @@
"width": 30,
"height": 30
},
"track_recognition_threshold": 10,
"ocr_server_endpoint": "https://tesserver.spruett.dev/",
"dump_frame_fraction": 0.05
"track_recognition_threshold": 10
}

View File

@ -45,6 +45,5 @@
"threshold": 0.88
}
],
"track_recognition_threshold": 10,
"ocr_server_endpoint": "https://tesserver.spruett.dev/"
"track_recognition_threshold": 10
}

View File

@ -1,7 +1,7 @@
use std::{
collections::HashMap,
thread,
time::{Duration, Instant, SystemTime}, sync::Arc,
time::{Duration, Instant, SystemTime},
};
use anyhow::Result;
@ -142,7 +142,7 @@ fn add_saved_frame(
image: retained,
rgb_image: extracted,
img_hash: hash,
recognized_text: ocr_results.get(&region.name).map(|p| p.clone()),
recognized_text: ocr_results.get(&region.name).cloned(),
},
);
}

View File

@ -4,7 +4,7 @@
"name": "lap",
"x": 2300,
"y": 46,
"width": 142,
"width": 140,
"height": 90
},
{
@ -40,8 +40,7 @@
"x": 2325,
"y": 222,
"width": 183,
"height": 43,
"use_ocr_cache": false
"height": 43
}
],
"track_region": {
@ -52,5 +51,12 @@
"height": 410,
"threshold": 0.85
},
"ocr_server_endpoint": "https://tesserver.spruett.dev/"
"penalty_orange_region": {
"name": "penalty",
"x": 989,
"y": 117,
"width": 30,
"height": 30
},
"track_recognition_threshold": 10
}

View File

@ -0,0 +1,101 @@
{
"learned_chars": {
"//8P+Afw4+fzx/HP+c/5z/nP8c/zx/Pnx/MP+H/+//8=": "0",
"//8H4Afg/+P/4//j/+P/4//j/+P/4//j/+P/4//j//8=": "1",
"//8f+A/g5+fzz/PP88/zn/PP88/zz+fP5+Mf8H/+//8=": "0",
"/////P/8f/4//p//3//H++P78/sBwAGA//v/+//7//8=": "4",
"//8P4A/gD+AP/w//D/gP4AfA/8P/w4fAA+AD8B/8//8=": "5",
"//8P4A/gD+AP/4//D/gH4Afg/8H/wYfgA+AD8B/8//8=": "5",
"//9/4H/wP/Af+A/8B/4DggODAYABgAGAAYD/g/+D//8=": "4",
"/////f/8f/w//5//j//H++f78/MBgP/z//v/+//7//8=": "4",
"/////wfwB+DD4cPBA+AP8Afgw8PDw4PBA+AH8P////8=": "8",
"//8BgAGAAYDhgeGB/8D/wH/gP+A/8B/wH/gP+A/8//8=": "7",
"////z/+fH/4H+AP4w/Dh8eHx4fHh8cPwA/gP/B/+//8=": "0",
"//8H4Afg/+H/4f/h/+H/4f/h/+H/4f/h/+H/4f/h//8=": "1",
"//8P+Afw4+fz5/HP+c/5z/nP+c/zx/Pnx/MP+H////8=": "0",
"///f/w/wB+DH48fhB+AH4APgw8PDw8PDB+AP8P////8=": "8",
"/////w/wB+DH48fjB+AH4Afgw8PDw8PDB+AP8P////8=": "8",
"//8f/Efx8+fz7/vP88fjww/I/8//z//n/+MH+A/+//8=": "9",
"//8/4I/g5//z//P/O/wL4OPH88/zz/fPx8cP4H/8//8=": "6",
"//8P8AfgA8CDgcGDwYPBg8GDwYPBg4OBA8AH4A/w//8=": "0",
"//8f+Afi88/zz/PPx+EP8OPH88/73/Pf48cH4H/+//8=": "8",
"/////wPwA+DD4P/h/+H/4H/wP/gP/gf+A8ADwP////8=": "2",
"//8f+A/g5+fzz/PP88/zz/PP88/zz+fH5+cP8H/+//8=": "0",
"//8D4APg//P/+X/8P/4/8P/H/8//z//P8+cD8D////8=": "3",
"/////wPAA8DDwcPBw+H/4P/wf/A/8D/4P/w/+P////8=": "7",
"//8P+APw++f/7//v/+f/4//x//w//h//z/8DwAPA//8=": "2",
"/////wPAA8Dj4OPg4+B/8H/wP/g/+D/8H/wf/P////8=": "7",
"//8/+A/w5+fjz/PP88/zz/PP88/zz+PP5+cP8D/8//8=": "0",
"//8P+CPw8+f77/vP88fjwQ/M/8//z//n//EH+D////8=": "9",
"//8HwAfA//P/8f/8f/5/8P/H/8//3//P88cD8H/+//8=": "3",
"//8DwAPA+8/75//n//P/8//5//n//H/+f/4//z////8=": "7",
"//8/4Ifg5//z//P/O/wL4OPH88/zz/PP5+cP4H/8//8=": "6",
"//+//Q/4B/CD4cPjw8PDw+PDw+PD4QfgD/Af+H/+//8=": "0",
"//9/7x/AD+AH74f/g/AD4APAg8OHwwfDD8Af4H/7//8=": "6",
"//8f+Afw++f/7//v/+f/4//4f/w//4//x/8DwAPA//8=": "2",
"///f/Q/wB+CH4cPDw8PDw8PDw8PDwwfgB/AP+L/9//8=": "0",
"//9/7x/gD+AH/4P/g/gD4APAg8ODw4fBB+Af8H/9//8=": "6",
"//8H4Afi//P/+P/8f/4/8P/j/8f/z//H8+MD8D/+//8=": "3",
"//8P4A/g7//n/+f/B/wH8P/H/8//3//P88cD8H/+//8=": "5",
"//8DwAPA88/z5//j/+P/8f/5//j//H/+P/4//h////8=": "7",
"//8P8A/wD/CH/4f/B/gH8Afg/8H/wYfgA+AD+B/+//8=": "5",
"//8P8APgAcDBgcGDwYEBgAOAD4L/g//AA8AD4AP4//8=": "9",
"//8f+Afg5+fzz/PP+9/73/vf+9/zz+PP5+cP4B/4//8=": "0",
"/////wfgA+DHwf/B/8H/4H/gP/gf/A/+B8ADwP////8=": "2",
"//9/7x/AD+AH7of/g/AD4APAg8ODwwfDD+Af4H/7//8=": "6",
"/////wfgB+B/4H/gf+B/4H/gf+B/4H/gf+B/4P////8=": "1",
"//8BgAGAAYDhgeGB7cD/wH/gf+A/8D/wH/gP+A/87/8=": "7",
"////+z/4P/wf/g/+D/+H8cPwA8ADwAPAA8D/8P////8=": "4",
"//8f+Afg5+fzz/Pf+9/73/vf+9/zz+PHx+MP8H/+//8=": "0",
"//////////8//B/4H/gf+B/4H/gf+D/8//////////8=": ".",
"//8H4Afg//P/+f/8f/w/4P/H/8//z//P4+cH4D/8//8=": "3",
"//8H4A/g/+P/4//j/+P/4//j/+P/4//j/+P/4//j//8=": "1",
"//8D4APg//P/+X/8f/4/+P/j/8//z//P+8cD8B/8//8=": "3",
"//8DgAOAA8D/4H/wH/AfwB+A/4H/g+OBA4ABwAPw//8=": "3",
"///f+w/wB+CDwcPDw8MHwA/AP8P/w0/gB/AH+F////8=": "9",
"/////f/8f/x//j//n//P8+fz4/MBwAOA//P/8//z//8=": "4",
"//8HwAfA/+P/8//9f/x/8P/H/8//3//P888D4B/4//8=": "3",
"///f/Q/4B/DD48PDw8EHwA/AH8P/4U/gB/AH+F////8=": "9",
"//8/8A/lx//3//P/8/8b4MPH48/z3/PP58eH4D/8//8=": "6",
"/////w/wD/D//////////////////w/wD/AP8H/+//8=": ":",
"//8f/Efh4+fzz/PP88fnwwfY/9//z//v/+On8A/8//8=": "9",
"////////////+D/wP/Af8A/wD/AP8B/4//////////8=": ".",
"//8D4APg//P/+f/8P/4/8P/H/8//z//P88cD8H////8=": "3",
"/////wfgB+Af4H/gf+B/4H/gf+B/4H/gf+B/4P////8=": "1",
"/////wfgB+A/4D/gP+A/4D/gP+A/4D/gP+A/4P////8=": "1",
"//9/7x/AD+AH74f/g/AD4APAg8ODwwfDD8Af4H/7//8=": "6",
"//8f+Afi8+fzz/PP48fHww/Y/8//z//v/+MH+D////8=": "9",
"//8HwAfAB8CD/wP/A+ADwAOA/4H/g+OBA4ABwAPw//8=": "5",
"//8f+Efi5+fzz/vf+9/73/vf+9/zz+PHx+MP8D/8//8=": "0",
"/////wfwA+DD4P/h/+H/4H/wP/gf/Af+B8AHwP////8=": "2",
"//8D4APg//P/+X/8f/4/+P/j/8//z//P+8cD8A/8//8=": "3",
"//8f+Afg5+fzz/vf+9/73/vf+9/zz+PHx+MP8H/+//8=": "0",
"//8P/APw++P/5//n/+f/8//4f/w//4//x/8DwAPA//8=": "2",
"//8P4A/g7//v/+//B/wH4P/P/8//3//P88cD8H/+//8=": "5",
"//8/gA+AB4AD34P/geABgAGAAYOBh4GHA4AHgA/g//8=": "6",
"/////w/wD/D/////////////////////D/AP8P////8=": ":",
"//8f/Afw5+fz5/HP+c/5z/nP+c/xz/Pn5+cP8B/8//8=": "0",
"//9/7x/gD+AH/4P/g/gD4APAg8ODw4fBD+Af8H/9//8=": "6",
"//8BgAGAAYA/gD+AP4A/gD+AP4A/gD+AP4A/gD+A//8=": "1",
"///f/Q/4B/DD4cPDw8EDwA/AH+P/4W/gB/AH+F////8=": "9",
"//8DwAPA+8/75//n//P/8f/5//n//H/+f/4//z////8=": "7",
"//8/gA+AB4AD34H/geABgAGAAYOBh4GHA4AHgA/g//8=": "6",
"//8P+CPw8+f77/vP88fjwQ/M/8//z//n//EH+J////8=": "9",
"//8H8APAAcDDgP+B/4H/wH/gH/AP+Af8A4ADgAOA//8=": "2",
"//8f+A/g5+fzz/PP88/zz/PP88/zz+fH5+cf8H/+//8=": "0",
"///v/QfwA+DD4cPBw8EDwAfAn8H/4UfwB/AD/G////8=": "9",
"/////P/8f/4//p//3//n++P78/sBwAGA//v/+//7//8=": "4",
"/////////////wfgB+AH4AfgB+AH4P////////////8=": "-",
"//8H4Afg/+H/4f/h/+H/4f/h/+H/4f/h/+H/4f/j//8=": "1",
"//8H4AfgB+D/8H/4P/w/8D/g/8P/w4fAA+AD8B/8//8=": "3",
"//8P8APAA8CBgYGDA8AH4APAgYHBg8GDgYEDwAfg//8=": "8",
"//8P+APw++f/7//v/+f/8//x//w//h//z/8DwAPA//8=": "2",
"//8f+Afw4+fzx/HP+c/5z/nP8c/zx/Pnx/MP+H////8=": "0",
"//8HwAfAB8D/4H/wP/g/4D/A/8H/w4fAA8AD8B/8//8=": "3",
"//+//R/4D/CH4cPDw8PDw8PDw8PHwwfgD/Af+H/+//8=": "0",
"//+//R/wD+CH4cfDw8PDw8PDw8PHwwfgD/Af+H/+//8=": "0",
"//////////8//D/8H/gP8A/wH/g//D/8//////////8=": ".",
"////+3/4P/w//B/+D/8H8YfhA8ADwAPAA8D/4f////8=": "4",
"//////////8BgAGAAYABgAGAAYABgAGA//////////8=": "-"
}
}

View File

@ -107,6 +107,6 @@ pub fn hash_image(image: &RgbImage) -> ImageHash {
let have_to_use_other_image_library_version =
img_hash::image::RgbImage::from_raw(image.width(), image.height(), image.as_raw().to_vec())
.unwrap();
let hash = hasher.hash_image(&have_to_use_other_image_library_version);
hash
hasher.hash_image(&have_to_use_other_image_library_version)
}

View File

@ -1,8 +1,7 @@
use std::{collections::HashMap, sync::{Arc, RwLock}};
use std::{collections::HashMap, sync::{RwLock}};
use crate::{
config::{load_config_or_make_default, save_json_config, Config},
image_processing::{extract_and_filter, hash_image}, ocr,
config::{load_config_or_make_default, save_json_config}, ocr,
};
use anyhow::Result;
@ -27,8 +26,8 @@ impl From<&RawOcrDatabase> for OcrDatabase {
let mut state = db.learned_chars.write().unwrap();
for (hash, s) in &raw.learned_chars {
state.push((
ImageHash::from_base64(&hash).unwrap(),
s.chars().nth(0).unwrap(),
ImageHash::from_base64(hash).unwrap(),
s.chars().next().unwrap(),
));
}
}
@ -52,7 +51,7 @@ impl From<&OcrDatabase> for RawOcrDatabase {
impl OcrDatabase {
pub fn load() -> Result<Self> {
let raw: RawOcrDatabase =
load_config_or_make_default("ocr.json", include_str!("configs/learned.default.json"))?;
load_config_or_make_default("ocr.json", include_str!("configs/ocr.default.json"))?;
Ok((&raw).into())
}
pub fn save(&self) -> Result<()> {

View File

@ -1,4 +1,4 @@
use std::{sync::{Arc, Mutex, RwLock}, time::{Duration, Instant, SystemTime}, collections::{HashMap, VecDeque}};
use std::{sync::{Arc, Mutex}, time::{Duration, Instant, SystemTime}, collections::{HashMap, VecDeque}};
use egui_extras::RetainedImage;
use image::RgbImage;
@ -34,7 +34,7 @@ fn parse_duration(time: &str) -> Option<Duration> {
}
fn parse_to_duration(time: Option<&String>) -> Option<Duration> {
parse_duration(&time?)
parse_duration(time?)
}
fn check_0_100(v: usize) -> Option<usize> {

View File

@ -1,6 +1,5 @@
use std::{
io::Write,
path::{PathBuf, Path},
path::{PathBuf},
};
use eframe::{