Log in

View Full Version : FindColoredAreaToleranceEx



wantonman
04-20-2012, 04:01 AM
can there be a function like this one? FindColoredAreaTolerance is great but is limited to searcharea.. any like it but with more flexable perameters???


im tring to find an area of color thats about 20 by 5 so it needs to be specified...

Abu
04-20-2012, 06:13 AM
FindColoredArea should work just fine for what you are trying to do.

It is not at all limited...

because you can specify the co-ordinates.

wantonman
04-20-2012, 05:18 PM
yeah i thought about that one but it still uses area and thats not great for rectangles... i think findobjex has a custimized search function something like that but yeah...

what i am trying to do is detect weather the door is closed or open by grabbing the the top color of the doors when they are closed... it makes a long brown line...

Abu
04-20-2012, 06:17 PM
yeah i thought about that one but it still uses area and thats not great for rectangles...


/facepalm


You can put the area of the rectangle in the function. Get the top left co-ordinate of the door and the bottom right. Then replace those co-ordinates with xs, ys, xe, ye in the function.

wantonman
04-20-2012, 06:56 PM
okay okay yeah this leads me to beleive that the cordinates arent static... which is a good thing....

so your saying even though the cooradinates are at the top left of the screen it still will retain the shape but also find it at bottom left?

NKN
04-20-2012, 06:58 PM
Yes, yes it will.

Abu
04-20-2012, 06:58 PM
okay okay yeah this leads me to beleive that the cordinates arent static... which is a good thing....

so your saying even though the cooradinates are at the top left of the screen it still will retain the shape but also find it at bottom left?

The co-ordinates are whatever you set it to.

MSX1, MSY1, MSX2, MSY2 are simply used by SRL to grab the mainscreen. You can replace them with whatever you want. For example:

25, 289, 20, 295 (made up co-ordinates)

wantonman
04-20-2012, 07:41 PM
my worry is that the door is not always going to be in the same place...

so having small coords. will not alway work...



uh.. yeah... uhm hmm....


http://i43.tinypic.com/6r4q54.jpg

here is my debug...

as you can see what i am looking for...


many ways but mainly just a simble boolean is all.........

Abu
04-20-2012, 07:43 PM
You can use co-ordiantes which would create a box slightly bigger than the door. That way if you move left and right the door will still be within those co-ordinates. It's better than using the whole screen....

J J
04-20-2012, 07:46 PM
FindObjTPA(X, Y, {color}, {tol}, {CTS}, {ObjWidth}, {ObjHeight}, {mincount}, {uptext})

By using CTS 2 and ACA you can get it pretty accurate ;)

I also made the code for you:

procedure Test;
var
X, Y: integer;

begin
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.17, 1.15);
if FindObjTPA(X, Y, 2172974, 4, 2, 100, 5, 250, ['Open', 'Open door']) then
begin
ClickMouse2(1);
WriteLn('We have clicked on the door, because it has been closed');
end else
begin
WriteLn('The door is still open');
end;
end;
You must choose high values for the FindObjTpa because it can possibly find other objects otherwise that have different uptexts. This one with 100x5 px works great ;)

wantonman
04-20-2012, 08:06 PM
true abu but what if im not to the left or right sometimes? it can hic-up at times... but hmm...


and findobjex it good but i dont want the mouse to spazz around the screen each time i do the door check lol...

like i said just a simple boolean... and abu is on the right track =]]

but man too bad objex didnt have to have up text and too bad it cannot just match that shape everytime :(...

J J
04-21-2012, 10:57 PM
You should try that code because it doesn't "spazz around the screen" at all. You just have to fill in the correct numbers to make it work properly.

Flight
04-22-2012, 01:24 AM
Step 1: Use 'FindColorsSpiralTolerance' (preferably with CTS 2 + modifiers) to get a TPA of all of your "door colors".

Step 2: Use 'SplitTPAEx' to split that TPA into 20x5 TPAs.

Step 3: For each box, get the middle point of each TPA (middleTPA), move the mouse to that middle point, search for the door's uptext.

Step 4: If correct uptext is found for one of your TPAs, break the loop, click/right-click the door.

Easy peasey. :)

Edit:
Refer to this thread (http://villavu.com/forum/showthread.php?t=49067) for all TPA-related methods.