SRL Archive - RS3 Help

Tesseract Problem Reading Red Text


askf

2014-09-10 23:22:46

Hey!

So I have been messing around with OCR/Tesseract.
Could someone please explain to me why it won't work for red text? Furthermore, is there a way to overcome this?

The code below works extremely well for all other colours!
writeln(tesseractGetText(testBox, FILTER_SMALL_CHARS)); 

Thanks,

`askf

EDIT:
Intention of the this function is to store all the options into a TSA and then choose an option based on the index. (For example if the text contains "wishes to trade", then choose that option.)
function getChat(): TStringArray;
var
bA: TBoxArray;
i: Integer;
sA: TStringArray;
begin
bA := [intToBox(0, 532, 558, 545), intToBox(0, 546, 558, 560), intToBox(0, 560, 558, 575)];
sA := ['', '', ''];
for i := 0 to 2 do
begin
//Debug
smartImage.drawBox(bA[i], false, clLime);
//Store into TSA
sA[i] := tesseractGetText(bA[i], FILTER_SMALL_CHARS);
end;
Result := sA
end;

Here is a screenshot of the chatbox:
[ATTACH=CONFIG]24002[/ATTACH]

Here is the output I get (notice the red text is gibberish):

You have correctly entered your PIN.
Sending trade offer...
jrhér p\3‘,‘5' j€:, "£1 W3 15‘
Successfully executed.

Turpinator

2014-09-11 01:33:21

Post a picture of the text. Id assume you need to play around with the 'filter' ([int, int, bool]) and set the bool (invert image) to whatever is the opposite of small chars is.

askf

2014-09-11 02:57:31

Thanks for the response!
As I am new to the forum, I can't post pictures just yet, however, the text I am talking about is any red text.
For example, when the chatbox informs you of someone reaching 99 in all skills! Or when someone has the name prefix Ythaar- etc.

To be honest, I have not messed around with the parameters, so I'll give that a go.

Thanks!
`askf

bonsai

2014-09-11 04:57:45

From: askf
Thanks for the response!
As I am new to the forum, I can't post pictures just yet, however, the text I am talking about is any red text.
For example, when the chatbox informs you of someone reaching 99 in all skills! Or when someone has the name prefix Ythaar- etc.

To be honest, I have not messed around with the parameters, so I'll give that a go.

Thanks!
`askf


See this thread. Olly posted a tool to test them out.

slacky

2014-09-11 10:14:55

From: askf
Thanks for the response!
As I am new to the forum, I can't post pictures just yet, however, the text I am talking about is any red text.
For example, when the chatbox informs you of someone reaching 99 in all skills! Or when someone has the name prefix Ythaar- etc.

To be honest, I have not messed around with the parameters, so I'll give that a go.

Thanks!
`askf

As person above posted, read that thread.. use the tool olly posted.
for any one to be able to help further then that, you need to post images as mentioned. I am sure there are some way 4 you to post images..
Since it fails only at red text, I assume the background is rather dark, meaning the only thing you need to adjust is the threshold.

Olly

2014-09-11 10:41:26

From: askf
I can't post pictures just yet


I'm sure you can post attachments if you can't post links.

askf

2014-09-11 21:23:06

Intention of the this function is to store all the options into a TSA and then choose an option based on the index. (For example if the text contains "wishes to trade", then choose that option.)
function getChat(): TStringArray;
var
bA: TBoxArray;
i: Integer;
sA: TStringArray;
begin
bA := [intToBox(0, 532, 558, 545), intToBox(0, 546, 558, 560), intToBox(0, 560, 558, 575)];
sA := ['', '', ''];
for i := 0 to 2 do
begin
//Debug
smartImage.drawBox(bA[i], false, clLime);
//Store into TSA
sA[i] := tesseractGetText(bA[i], FILTER_SMALL_CHARS);
end;
Result := sA
end;

Here is a screenshot of the chatbox:
[ATTACH=CONFIG]24002[/ATTACH]

Here is the output I get (notice the red text is gibberish):

You have correctly entered your PIN.
Sending trade offer...
jrhér p\3‘,‘5' j€:, "£1 W3 15‘
Successfully executed.

slacky

2014-09-18 05:18:51

From: askf
Intention of the this function is to store all the options into a TSA and then choose an option based on the index. (For example if the text contains "wishes to trade", then choose that option.)
function getChat(): TStringArray;
var
bA: TBoxArray;
i: Integer;
sA: TStringArray;
begin
bA := [intToBox(0, 532, 558, 545), intToBox(0, 546, 558, 560), intToBox(0, 560, 558, 575)];
sA := ['', '', ''];
for i := 0 to 2 do
begin
//Debug
smartImage.drawBox(bA[i], false, clLime);
//Store into TSA
sA[i] := tesseractGetText(bA[i], FILTER_SMALL_CHARS);
end;
Result := sA
end;

Here is a screenshot of the chatbox:
[ATTACH=CONFIG]24002[/ATTACH]

Here is the output I get (notice the red text is gibberish):

You have correctly entered your PIN.
Sending trade offer...
jrhér p\3‘,‘5' j€:, "£1 W3 15‘
Successfully executed.

Adjusting / tweaking threshold is all you need to do.

Look at "FILTER_SMALL_CHARS" option in SRLs source-code, using that as a base you can easily create your own filter.

EG:

var
...

const (* Invert, Modifier, Method *)
FILTER_SMALL_CHARS_3: TTesseractFilter = [3, 3, [False, 10, TM_MinMax]];

begin
writeln(tesseractGetText(SomeBox, FILTER_SMALL_CHARS_3));
end;

I'm sorry for the late answer, this thread must have slipped between my fingers..:P

askf

2014-09-18 08:37:05

From: slacky
Adjusting / tweaking threshold is all you need to do.

Look at "FILTER_SMALL_CHARS" option in SRLs source-code, using that as a base you can easily create your own filter.

EG:

var
...

const (* Invert, Modifier, Method *)
FILTER_SMALL_CHARS_3: TTesseractFilter = [3, 3, [False, 10, TM_MinMax]];

begin
writeln(tesseractGetText(SomeBox, FILTER_SMALL_CHARS_3));
end;

I'm sorry for the late answer, this thread must have slipped between my fingers..:P


Thanks heaps for the reply! I will now go back to that, I beleive my problem is solved now. If I have any more trouble I will post here.

——————————————————————————————————————————————————————————————————-

In other news:

Can someone tell me where I would go if I would want to post something like a progress log.
I have created a new skiller to test the scripts I write. It would be nice to create a thread to track my progress and also act as a countdown till I release the script I am currently working on.

91 (92 in 25 minutes!) Thieving in 5 days with a fresh account. Not bad I say!

I will be releasing this script when I get 99.
Do I release under first scripts? (Because it is technically my first script) or do I release in the thieving sub-forum?

Hopefully people will see this here.

`askf

Turpinator

2014-09-18 13:11:42

From: askf
91 (92 in 25 minutes!) Thieving in 5 days with a fresh account. Not bad I say!

I will be releasing this script when I get 99.
Do I release under first scripts? (Because it is technically my first script) or do I release in the thieving sub-forum?

Hopefully people will see this here.

`askf


looks nice! you can post it in either place. the first scripts will probably get you more feedback (from srl users) but less feedback from leechers/etc (and in turn usage). you could always post it in first scripts, then after a bit, request a mod to move it to the correct forum.