bg5
06-03-2012, 04:15 AM
procedure FilterTPADistTPA(var TPA1: TPointArray; const MinDist,MaxDist: Extended;var filterTPA : TPointArray);
procedure FilterTPADistTPAEx(var TPA1: TPointArray; const MaxX,MaxY: integer;var filterTPA : TPointArray);
procedure FilterTPADistTPACmpr(var TPA1: TPointArray; const MinDist,MaxDist: Extended;var filterTPA : TPointArray;CmprTPA1 ,CmprFilter : integer);
procedure FilterTPADistTPAExCmpr(var TPA1: TPointArray; const MaxX,MaxY: integer;var filterTPA : TPointArray;CmprTPA1 ,CmprFilter : integer);
AND_TPA returns all points from TPA1 ,which has in neighbourhood any point from filterTPA. FilterTPADistTPA() uses circle (ring) as neighbourhood , FilterTPADistTPAEx uses rectangle ( w = 2*MaxX ; h = 2*MaxY).
Both functions have version with compression. Compression shorten length of base or filter TPA ,reducing time of operation. It's very usefull when working with big tpas ,but I don't recomend it for precise searching. Compression level = 0 means no compression.
On pictures red color is the match.
Example #1
Finding Burthorpe chest
2 layers
Chest has 2 colors: color of wood (green and red debug color) and it's silver ferrule ( white debug color). But, as you see on the picture, that 2 colors matches also to other objects on screen: silver elements are on NPCs' armors and pillars, and 'wood' color matches palisade and top of a barrel.
So to localise our chest we need to find a place where both colors are close to each other. Therefore we tell this plugin to:
Find the place where wood is surrounded by silver
or more technically:
Find all points from green TPA (wood), which are in proper distance from any white(silver) pixel
and red debug color is a result.
ColorToleranceSpeed(2);
SetColorspeed2Modifiers(0.18,0.55);
FindColorsTolerance(TPA2,9737627,msx1,msy1,msx2,ms y2,18); //silver
SetColorspeed2Modifiers(0.06,0.38);
FindColorsTolerance(TPA1,5202030,msx1,msy1,msx2,ms y2,10); //wood
SMART_DRAWDOTSEx(FALSE,TPA1,clgreen);
SMART_DRAWDOTSEx(FALSE,TPA2,clwhite);
FilterTPADistTPA(TPA1,0,20,TPA2);
SMART_DRAWDOTSEx(FALSE,TPA1,clred); // result
http://puu.sh/yjde
Example #2
Finding trapdoor to Rogues' Den
3 layers
http://puu.sh/yjtL
ColorToleranceSpeed(2);
SetColorspeed2Modifiers(0.02,0.37);
FindColorsTolerance(TPA1,4213331,msx1,msy1,msx2,ms y2,1); //brown1
SetColorspeed2Modifiers(0.3,1.02);
FindColorsTolerance(TPA2,3028800,msx1,msy1,msx2,ms y2,4); //brown2
SetColorspeed2Modifiers(0.15,0.17);
FindColorsTolerance(TPA3,9474457,msx1,msy1,msx2,ms y2,13); //silver handle
SMART_DRAWDOTSEx(FALSE,TPA1,clgreen);
SMART_DRAWDOTSEx(FALSE,TPA2,clwhite);
SMART_DRAWDOTSEx(FALSE,TPA3,clblue);
FilterTPADistTPA(TPA1,0,5,TPA2);
FilterTPADistTPAEx(TPA1,5,10,TPA3);
SMART_DRAWDOTSEx(FALSE,TPA1,clred);
SMART_DrawEllipse(FALSE,point(MSCX,MSCY),20,25,TRU E,1);
Example #3
Finding ivy on wall (varock north)
2 layers + compression
http://puu.sh/yiu5
As you see layers are very big ,that's why I compress filterTPA (white wall). Compression visibly decrease time of operation without difference in result (if proper used).
ColorToleranceSpeed(2);
SetColorspeed2Modifiers(0.56,0.59);
FindColorsTolerance(TPA1,3632741,msx1,msy1,msx2,ms y2,11); //green
SetColorspeed2Modifiers(0.28,0.05);
FindColorsTolerance(TPA2,6843501,msx1,msy1,msx2,ms y2,12); // wall
SMART_DRAWDOTSEx(FALSE,TPA1,clgreen);
SMART_DRAWDOTSEx(FALSE,TPA2,clwhite);
FilterTPADistTPAExCmpr(TPA1,10,4,TPA2,0,5);
SMART_DRAWDOTSEx(FALSE,TPA1,clred);
{ // addiotional code for example #4
SMART_Clearcanvas;
FindTPAOutLine(TPA1);
SMART_DRAWDOTSEx(FALSE,TPA1,clyellow); }
Example #4
Using AND_TPA to find outlines of TPA
http://puu.sh/yj6r
function FindTPAOutline (var TPA : TPointArray) : TPointArray;
var
tempTPA : TPointarray;
tempBox : tBox;
begin
tempBox := GetTPABounds(TPA);
TPAFromBoxWrap(tempBox,tempTPA);
ClearTPAFromTPAWrap(tempTPA,TPA,tempTPA);
FilterTPADistTPAEx(TPA,1,1,tempTPA);
end;
S: (http://pastebin.com/pUwvhFyJ)
procedure FilterTPADistTPAEx(var TPA1: TPointArray; const MaxX,MaxY: integer;var filterTPA : TPointArray);
procedure FilterTPADistTPACmpr(var TPA1: TPointArray; const MinDist,MaxDist: Extended;var filterTPA : TPointArray;CmprTPA1 ,CmprFilter : integer);
procedure FilterTPADistTPAExCmpr(var TPA1: TPointArray; const MaxX,MaxY: integer;var filterTPA : TPointArray;CmprTPA1 ,CmprFilter : integer);
AND_TPA returns all points from TPA1 ,which has in neighbourhood any point from filterTPA. FilterTPADistTPA() uses circle (ring) as neighbourhood , FilterTPADistTPAEx uses rectangle ( w = 2*MaxX ; h = 2*MaxY).
Both functions have version with compression. Compression shorten length of base or filter TPA ,reducing time of operation. It's very usefull when working with big tpas ,but I don't recomend it for precise searching. Compression level = 0 means no compression.
On pictures red color is the match.
Example #1
Finding Burthorpe chest
2 layers
Chest has 2 colors: color of wood (green and red debug color) and it's silver ferrule ( white debug color). But, as you see on the picture, that 2 colors matches also to other objects on screen: silver elements are on NPCs' armors and pillars, and 'wood' color matches palisade and top of a barrel.
So to localise our chest we need to find a place where both colors are close to each other. Therefore we tell this plugin to:
Find the place where wood is surrounded by silver
or more technically:
Find all points from green TPA (wood), which are in proper distance from any white(silver) pixel
and red debug color is a result.
ColorToleranceSpeed(2);
SetColorspeed2Modifiers(0.18,0.55);
FindColorsTolerance(TPA2,9737627,msx1,msy1,msx2,ms y2,18); //silver
SetColorspeed2Modifiers(0.06,0.38);
FindColorsTolerance(TPA1,5202030,msx1,msy1,msx2,ms y2,10); //wood
SMART_DRAWDOTSEx(FALSE,TPA1,clgreen);
SMART_DRAWDOTSEx(FALSE,TPA2,clwhite);
FilterTPADistTPA(TPA1,0,20,TPA2);
SMART_DRAWDOTSEx(FALSE,TPA1,clred); // result
http://puu.sh/yjde
Example #2
Finding trapdoor to Rogues' Den
3 layers
http://puu.sh/yjtL
ColorToleranceSpeed(2);
SetColorspeed2Modifiers(0.02,0.37);
FindColorsTolerance(TPA1,4213331,msx1,msy1,msx2,ms y2,1); //brown1
SetColorspeed2Modifiers(0.3,1.02);
FindColorsTolerance(TPA2,3028800,msx1,msy1,msx2,ms y2,4); //brown2
SetColorspeed2Modifiers(0.15,0.17);
FindColorsTolerance(TPA3,9474457,msx1,msy1,msx2,ms y2,13); //silver handle
SMART_DRAWDOTSEx(FALSE,TPA1,clgreen);
SMART_DRAWDOTSEx(FALSE,TPA2,clwhite);
SMART_DRAWDOTSEx(FALSE,TPA3,clblue);
FilterTPADistTPA(TPA1,0,5,TPA2);
FilterTPADistTPAEx(TPA1,5,10,TPA3);
SMART_DRAWDOTSEx(FALSE,TPA1,clred);
SMART_DrawEllipse(FALSE,point(MSCX,MSCY),20,25,TRU E,1);
Example #3
Finding ivy on wall (varock north)
2 layers + compression
http://puu.sh/yiu5
As you see layers are very big ,that's why I compress filterTPA (white wall). Compression visibly decrease time of operation without difference in result (if proper used).
ColorToleranceSpeed(2);
SetColorspeed2Modifiers(0.56,0.59);
FindColorsTolerance(TPA1,3632741,msx1,msy1,msx2,ms y2,11); //green
SetColorspeed2Modifiers(0.28,0.05);
FindColorsTolerance(TPA2,6843501,msx1,msy1,msx2,ms y2,12); // wall
SMART_DRAWDOTSEx(FALSE,TPA1,clgreen);
SMART_DRAWDOTSEx(FALSE,TPA2,clwhite);
FilterTPADistTPAExCmpr(TPA1,10,4,TPA2,0,5);
SMART_DRAWDOTSEx(FALSE,TPA1,clred);
{ // addiotional code for example #4
SMART_Clearcanvas;
FindTPAOutLine(TPA1);
SMART_DRAWDOTSEx(FALSE,TPA1,clyellow); }
Example #4
Using AND_TPA to find outlines of TPA
http://puu.sh/yj6r
function FindTPAOutline (var TPA : TPointArray) : TPointArray;
var
tempTPA : TPointarray;
tempBox : tBox;
begin
tempBox := GetTPABounds(TPA);
TPAFromBoxWrap(tempBox,tempTPA);
ClearTPAFromTPAWrap(tempTPA,TPA,tempTPA);
FilterTPADistTPAEx(TPA,1,1,tempTPA);
end;
S: (http://pastebin.com/pUwvhFyJ)