No longer use tesseract for score OCR (tesseract is terrrrrible)
Signed-off-by: prescientmoon <git@moonythm.dev>
This commit is contained in:
parent
86e5debe95
commit
4373b6ca62
20 changed files with 1145 additions and 845 deletions
|
@ -81,7 +81,7 @@ pub async fn magic(
|
|||
};
|
||||
|
||||
edit_reply!(ctx, handle, "Image {}: reading score", i + 1).await?;
|
||||
let score_possibilities = analyzer.read_score(
|
||||
let score = analyzer.read_score(
|
||||
ctx.data(),
|
||||
Some(chart.note_count),
|
||||
&ocr_image,
|
||||
|
@ -89,17 +89,11 @@ pub async fn magic(
|
|||
)?;
|
||||
|
||||
// {{{ Build play
|
||||
let (score, maybe_fars, score_warning) = Score::resolve_ambiguities(
|
||||
score_possibilities,
|
||||
let maybe_fars = Score::resolve_distibution_ambiguities(
|
||||
score,
|
||||
note_distribution,
|
||||
chart.note_count,
|
||||
)
|
||||
.map_err(|err| {
|
||||
format!(
|
||||
"Error occurred when disambiguating scores for '{}' [{:?}] by {}: {}",
|
||||
song.title, difficulty, song.artist, err
|
||||
)
|
||||
})?;
|
||||
);
|
||||
|
||||
let play = CreatePlay::new(score, &chart, &user)
|
||||
.with_attachment(file)
|
||||
|
@ -110,14 +104,10 @@ pub async fn magic(
|
|||
// }}}
|
||||
// }}}
|
||||
// {{{ Deliver embed
|
||||
let (mut embed, attachment) = play
|
||||
let (embed, attachment) = play
|
||||
.to_embed(&ctx.data().db, &user, &song, &chart, i, None)
|
||||
.await?;
|
||||
|
||||
if let Some(warning) = score_warning {
|
||||
embed = embed.description(warning);
|
||||
}
|
||||
|
||||
embeds.push(embed);
|
||||
attachments.extend(attachment);
|
||||
// }}}
|
||||
|
@ -139,9 +129,11 @@ pub async fn magic(
|
|||
|
||||
handle.delete(ctx).await?;
|
||||
|
||||
ctx.channel_id()
|
||||
.send_files(ctx.http(), attachments, CreateMessage::new().embeds(embeds))
|
||||
.await?;
|
||||
if embeds.len() > 0 {
|
||||
ctx.channel_id()
|
||||
.send_files(ctx.http(), attachments, CreateMessage::new().embeds(embeds))
|
||||
.await?;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
|
@ -307,7 +307,7 @@ pub async fn b30(ctx: Context<'_>) -> Result<(), Error> {
|
|||
font,
|
||||
crate::bitmap::TextStyle {
|
||||
size: 25,
|
||||
weight: 800,
|
||||
weight: Some(800),
|
||||
color: Color::WHITE,
|
||||
align: (Align::Center, Align::Center),
|
||||
stroke: None,
|
||||
|
@ -327,7 +327,7 @@ pub async fn b30(ctx: Context<'_>) -> Result<(), Error> {
|
|||
let initial_size = 24;
|
||||
let mut style = crate::bitmap::TextStyle {
|
||||
size: initial_size,
|
||||
weight: 800,
|
||||
weight: Some(800),
|
||||
color: Color::WHITE,
|
||||
align: (Align::Start, Align::Center),
|
||||
stroke: Some((Color::BLACK, 1.5)),
|
||||
|
@ -404,7 +404,7 @@ pub async fn b30(ctx: Context<'_>) -> Result<(), Error> {
|
|||
font,
|
||||
crate::bitmap::TextStyle {
|
||||
size: 25,
|
||||
weight: 600,
|
||||
weight: Some(600),
|
||||
color: Color::from_rgb_int(0xffffff),
|
||||
align: (Align::Center, Align::Center),
|
||||
stroke: None,
|
||||
|
@ -442,7 +442,7 @@ pub async fn b30(ctx: Context<'_>) -> Result<(), Error> {
|
|||
font,
|
||||
crate::bitmap::TextStyle {
|
||||
size: 23,
|
||||
weight: 800,
|
||||
weight: Some(800),
|
||||
color: Color::WHITE,
|
||||
align: (Align::Start, Align::Center),
|
||||
stroke: Some((Color::BLACK, 1.5)),
|
||||
|
@ -490,7 +490,7 @@ pub async fn b30(ctx: Context<'_>) -> Result<(), Error> {
|
|||
font,
|
||||
crate::bitmap::TextStyle {
|
||||
size: if status == 'M' { 30 } else { 36 },
|
||||
weight: if status == 'M' { 800 } else { 500 },
|
||||
weight: Some(if status == 'M' { 800 } else { 500 }),
|
||||
color: Color::WHITE,
|
||||
align: (Align::Center, Align::Center),
|
||||
stroke: None,
|
||||
|
@ -526,7 +526,7 @@ pub async fn b30(ctx: Context<'_>) -> Result<(), Error> {
|
|||
font,
|
||||
crate::bitmap::TextStyle {
|
||||
size: 30,
|
||||
weight: 650,
|
||||
weight: Some(650),
|
||||
color: Color::from_rgb_int(0x203C6B),
|
||||
align: (Align::Center, Align::Center),
|
||||
stroke: Some((Color::WHITE, 1.5)),
|
||||
|
@ -540,7 +540,7 @@ pub async fn b30(ctx: Context<'_>) -> Result<(), Error> {
|
|||
EXO_FONT.with_borrow_mut(|font| -> Result<(), Error> {
|
||||
let mut style = crate::bitmap::TextStyle {
|
||||
size: 12,
|
||||
weight: 600,
|
||||
weight: Some(600),
|
||||
color: Color::WHITE,
|
||||
align: (Align::Center, Align::Center),
|
||||
stroke: None,
|
||||
|
@ -556,7 +556,7 @@ pub async fn b30(ctx: Context<'_>) -> Result<(), Error> {
|
|||
)?;
|
||||
|
||||
style.size = 25;
|
||||
style.weight = 700;
|
||||
style.weight = Some(700);
|
||||
|
||||
drawer.text(
|
||||
top_left_area,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue