Jump to content
bosshunts

Clicking on colors

Recommended Posts

Can I get an example please? ^^

You have to elaborate a bit further for me to be able to help you.

 

Do you mean at 3pm do something.. or do you mean 10 sec after another thing has been done, do something?

 

There are several functions used to find the pos of a color:

» FindColorTol(out x,y:Integer; color, x1,y1,x2,y2, tolerance: Integer);

» FindColorSpiralTol(CenterX,CenterY:Integer; var x,y:Integer; Color, x1,y1,x2,y2, tolerance:Integer);

x and y is the resulting postion of wherer the color was FIRST found:

var
 Pt: TPoint; //TPoint holds and X, and an Y coordinate. So it can always be used instead of: "var x,y: Integer".
begin
 FindColorTol(Pt.x, Pt.y, 255, 0,0,500,500, 10);
 WriteLn(PointToStr(Pt)); // Found color 255 (red) at that location
end;

and then we have more advanced versions, which puts ALL the found results in to an array:

» FindColorTolEx(var TPA:TPointArray; color, x1,y1,x2,y2, tolerance: Integer);

The TPA is an array of all the points found of the given color. This can be manipulated to find groups/clusters where the color is close to each other, and thereby eliminate noise, and allow for even more checks to ensure we are getting the right group, and in the end we often just click the center of that group.

 

EG:

var
 W,H, i: Integer;
 TPA:TPointArray;
 Groups: T2DPointArray;
begin   
 // find all black-ish colors in the area 0,0, to 500,500
 FindColorTolEx(TPA, 1, 0,0,500,500, 10);

 // create groups where colors are close to each other
 // 6 is the max distance between points in that group.
 Groups := SplitTPA(TPA, 6); 

 // go though each group and check if it's the correct size
 for i:=0 to High(Groups) do
 begin
   // get the group width and height
   TPADimensions(Groups[i], W,H);

   if ((W > 5) and (W < 100))  and  ((H > 8) and (H < 20)) then 
     // it passes, we print the middle of that group: TPACenter(Groups[i])
     WriteLn(PointToStr( TPACenter(Groups[i]) ));
 end;
end.

 

To help more I need you to elaborate further.

Edited by slacky
Link to comment
Share on other sites

You have to elaborate a bit further for me to be able to help you.

 

Do you mean at 3pm do something.. or do you mean 10 sec after another thing has been done, do something?

 

There are several functions used to find the pos of a color:

» FindColorTol(out x,y:Integer; color, x1,y1,x2,y2, tolerance: Integer);

» FindColorSpiralTol(CenterX,CenterY:Integer; var x,y:Integer; Color, x1,y1,x2,y2, tolerance:Integer);

x and y is the resulting postion of wherer the color was FIRST found:

var
 Pt: TPoint; //TPoint holds and X, and an Y coordinate. So it can always be used instead of: "var x,y: Integer".
begin
 FindColorTol(Pt.x, Pt.y, 255, 0,0,500,500, 10);
 WriteLn(PointToStr(Pt)); // Found color 255 (red) at that location
end;

and then we have more advanced versions, which puts ALL the found results in to an array:

» FindColorTolEx(var TPA:TPointArray; color, x1,y1,x2,y2, tolerance: Integer);

The TPA is an array of all the points found of the given color. This can be manipulated to find groups/clusters where the color is close to each other, and thereby eliminate noise, and allow for even more checks to ensure we are getting the right group, and in the end we often just click the center of that group.

 

EG:

var
 W,H, i: Integer;
 TPA:TPointArray;
 Groups: T2DPointArray;
begin   
 // find all black-ish colors in the area 0,0, to 500,500
 FindColorTolEx(TPA, 1, 0,0,500,500, 10);

 // create groups where colors are close to each other
 // 6 is the max distance between points in that group.
 Groups := SplitTPA(TPA, 6); 

 // go though each group and check if it's the correct size
 for i:=0 to High(Groups) do
 begin
   // get the group width and height
   TPADimensions(Groups[i], W,H);

   if ((W > 5) and (W < 100))  and  ((H > 8) and (H < 20)) then 
     // it passes, we print the middle of that group: TPACenter(Groups[i])
     WriteLn(PointToStr( TPACenter(Groups[i]) ));
 end;
end.

 

To help more I need you to elaborate further.

This method is obviously a little too advanced for me. I can work without it. Thanks anyway though. :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
  • Create New...