1
Fork 0

Got score select recognition to work

Signed-off-by: prescientmoon <git@moonythm.dev>
This commit is contained in:
prescientmoon 2024-08-01 15:41:20 +02:00
parent 6556e81433
commit 0c90628c9d
Signed by: prescientmoon
SSH key fingerprint: SHA256:UUF9JT2s8Xfyv76b8ZuVL7XrmimH4o49p4b+iexbVH4
5 changed files with 101 additions and 39 deletions
src/commands

View file

@ -74,11 +74,8 @@ pub async fn magic(
for (i, file) in files.iter().enumerate() {
if let Some(_) = file.dimensions() {
// {{{ Image pre-processing
// Download image and guess it's format
let bytes = file.download().await?;
let format = image::guess_format(&bytes)?;
let image = image::load_from_memory_with_format(&bytes, format)?;
let image = image::load_from_memory(&bytes)?;
let mut image = image.resize(1024, 1024, FilterType::Nearest);
// }}}
// {{{ Detection
@ -241,7 +238,7 @@ Title error: {:?}
handle.edit(ctx, edited).await?;
let score_possibilities =
match cropper.read_score(Some(chart.note_count), &ocr_image) {
match cropper.read_score(Some(chart.note_count), &ocr_image, kind) {
// {{{ OCR error handling
Err(err) => {
error_with_image(

View file

@ -77,11 +77,11 @@ pub async fn best(
let play = query_as!(
DbPlay,
"
SELECT * FROM plays
WHERE user_id=?
AND chart_id=?
ORDER BY score DESC
",
SELECT * FROM plays
WHERE user_id=?
AND chart_id=?
ORDER BY score DESC
",
user.id,
chart.id
)