#1 2016-01-05 13:28:14

Jeroonk
Member
Registered: 2015-11-05
Posts: 2

Alt1 fails/incorrectly recognizes text clue

Alt1 fails to recognize the text of this anagram clue:
i/bt8c

It seems Alt1 fails to read the third line (AHA JAR) at all, as indicated by the debug console only printing the first two lines: "This anagram reveals who to speak to next:" (from the clog at line 162 in runeapps.org/apps/clue/scripts.js).


Edit:

It seems that the coldiff threshold of 50 used in solvetextclue is too strict for recognizing the anti-aliased "A".
Adding an overlay for each matched pixel (line 148 of runeapps.org/apps/clue/scripts.js):

if (a < 50) {
    linescore++;
    alt1.overLayRect(a1lib.mixcolor(255,0,255),textinterface.pos.x+x,textinterface.pos.y+y,1,1,1500,1);
}

Shows that the 3rd, 6th and 9th row of pixels have no matches on the "A". The stems of the H, J and R are only good for a linescore of 5 or 4 pixels on rows 3 and 9, resulting in the entire line being discarded:
i/bt8q

Increasing the threshold to 80 seems to do the trick to recognize the third line as text.

Despite this, alt1.bindReadColorString (line 155 of runeapps.org/apps/clue/scripts.js) still has a hard time reading the line, depending on where exactly the center of the text is placed:

  • At textinterface.pos.x+255 (on the stem of the J), it only finds a single character: " ! ".

  • At textinterface.pos.x+235 (on the H), it only recognizes the first word " AHA ", which is not enough for the text comparison to pick "Aha Jar" over "Snah".

  • At textinterface.pos.x+265 (on the A in JAR), it only recognizes the second word but mangles the J into a quote: " 'AR " (Wonderfully enough, this does make the text comparison pick "Aha Jar").

Last edited by Jeroonk (2016-01-05 15:01:36)

Offline

#2 2016-01-05 17:43:56

Skillbert
Administrator
Registered: 2014-12-30
Posts: 1,061

Re: Alt1 fails/incorrectly recognizes text clue

Thanks for the indept analysis! I saw this particular clue before and blamed it on the fact that i didn't complete the font yet. But it seems that it also skips the line completely.
When i originally made this i didn't have enough clues to get a sample for some characters, The characters JQVXYZjz to be precise. It doesn't recognize these character and usually detects some similar other character in its place. I added some code to match the closest match from the known clues using the characters that it does have so it usually doesn't matter.
I still havent gotten around to adding these last few characters, i think i do have them all on screenshots now tho. Adding them became kinda tricky as i changed the font precompiling script since then and the input image has changed. I'm also not completely sure how it works anymore =s

This is the old input image for reference, i changed the precompile script so that it takes a raw image of the characters instead
bt9f.png

I'll dive back into it after diner

Offline

#3 2016-01-05 22:17:36

Skillbert
Administrator
Registered: 2014-12-30
Posts: 1,061

Re: Alt1 fails/incorrectly recognizes text clue

Apparently I already fixed the font issue. I didn't have the J yet so i added that one. I also changed the threshold value like you suggested. It works now on the image that you provided. Only missing Q and Z now.

Offline

#4 2016-01-05 23:37:28

Jeroonk
Member
Registered: 2015-11-05
Posts: 2

Re: Alt1 fails/incorrectly recognizes text clue

Awesome.

I'll keep looking out for an image of Q or Z then. The Z should be relatively common, there are even a few in the cryptics and emote clues I believe.
However Q only appears on a single clue (SEQUIN DIRGE / Queen Sigrid).

How does the OCR work if I may ask? Is it just a best pixel match or something more complicated?
I don't think a missing Q, or a Q being recognized as an O will be a huge problem for the text comparison.

Last edited by Jeroonk (2016-01-05 23:38:26)

Offline

#5 2016-01-06 01:20:11

Skillbert
Administrator
Registered: 2014-12-30
Posts: 1,061

Re: Alt1 fails/incorrectly recognizes text clue

The ocr was designed mainly for reading the xp counters, which is semi-transparent and can have any color background with any type of texture. I ended up with something much like pixel comparison which compensates for how transparent the pixel in the font is. I also realized that Jagex actually uses sprites to render text, so the exact pixels aren't likely to change. I tried to use pattern matching but it ended up being crap as the font is tiny, pixelated, semi-transparent and can have any background.
In case of the clue text it really just comes down to pixel matching as the font doesn't have a shadow and it has an even background with good contrast.

Offline

Board footer

Powered by FluxBB