SRL Archive - Test corner

Symbol Detection Idea


Sir R. M8gic1an

2009-12-13 05:42:18

This is an idea I've have for a while… I'll just qickly explain it, and i'll probably use it for my guildminer.

To first detect the symbols, do an outline search, meaning the black color on the outside of the circle.

From that, get a TBox of the area the symbol covers.

As NPC dots, Item dots and Player dots share the same outline color we have to sort those out.

To do this, search for the greyish color of the inside of a symbol.

Now you should have a TBoxArray or an ATPA or a TPA of the symbols.

With this, search for colors specific to your symbol.

You are now sure you detected the correct symbol :)

~RM

nielsie95

2009-12-13 05:47:13

This has been tried before some time ago, but as far as I know it wasn't good enough. Is the outline color static now? It used to be different than the dots.

I still think my way of finding symbols was a pretty good one (in many cases more accurate and faster than srl's)..

Sir R. M8gic1an

2009-12-13 06:12:46

From: nielsie95
This has been tried before some time ago, but as far as I know it wasn't good enough. Is the outline color static now? It used to be different than the dots.

I still think my way of finding symbols was a pretty good one (in many cases more accurate and faster than srl's)..


Committ it? I only bothered doing this cus i'm not quite happy with SRL's ;)

~RM

nielsie95

2009-12-13 08:07:13

It's ok with me, but some symbol bitmaps would have to be updated (I don't know if my old updater still works).

Sir R. M8gic1an

2009-12-14 02:46:11

I suspect this is much slower than yours niels, but i finished it off anyway :)

works extremely well even when nearly completly crowded :D

The dungeon symbol by the mining guild had an arrow and 3 npcs on top and it still found it :)


Function FindSymbolWithTPA(Which: integer; var Where: TPoint): boolean;
var
TPA : TPointArray;
ATPA: T2DPointArray;
TBArr : TBoxArray;
i, h, t, waste, UniqueColor, UniqueTol: integer;
TIA: TIntegerArray;
begin
if not FindColors(TPA, SYMBOL_OUTLINE, MMX1, MMY1, MMX2, MMY2) then
begin
srl_warn('FindSymbolThroughTPA', 'Could not find symbol', warn_AllVersions);
exit;
end;

ATPA := SplitTPA(TPA, 2);

t := 0;
h := High(ATPA);
SetLength(TIA, h + 1);
SetLength(TBArr, h + 1);

for i:= 0 to h do
begin
TBArr[i] := GetTPABounds(ATPA[i]);
if FindColor(waste, waste, SYMBOL_FILL, TBArr[i].x1, TBArr[i].y1, TBArr[i].x2, TBArr[i].y2) then
begin
TIA[t] := i;
Inc(t);
end;
end;

SetLength(TIA, t);

case which of

SYMBOL_BANK :
begin
UniqueColor := 3455440;
UniqueTol := 45;
end;

SYMBOL_ARROW:
begin
UniqueColor := 6645236;
UniqueTol := 84;
end;
end;

for i:= 0 to t do
begin
h := TIA[i];
if FindColorsTolerance(TPA, UniqueColor, TBArr[h].x1, TBArr[h].y1, TBArr[h].x2, TBArr[h].y2, UniqueTol) then
begin
Where := MiddleTPA(TPA);
Result := true;
exit;
end;
end;

end;

~RM

Sir R. M8gic1an

2009-12-14 03:04:17

I guess that a way to make it way faster would be to just grab a bitmap of the MM and analyse it, rather than doing an API call at each find colors….

~RM

nielsie95

2009-12-16 12:49:14

It's a start :) I'm sure it can be made faster, but another thing you'll have to keep in mind is that some symbols use pretty similar colors (as I see you use pretty high tolerances).

The symbol "fill" color is static too? If so, why even search for the outline?