I made an any tree finder, I have only tested it with willows, oaks, trees and yews. I read lorax's tut about in HSL and decided to experiment with HSL, and got this:
SCAR Code:
Function FindTree(Var X, Y : Integer): Boolean;
Var
TPA, TPA2 : TPointArray;
ATPA : T2DPointArray;
I, J, lastCol, Took : Integer;
L : TExtendedArray;
LTol, H, S, tempH, tempS, tempL : Extended;
Begin
LTol := 10.0;
Took := GetTickCount;
FindColorsSpiralTolerance(MSCX, MSCY, TPA, 5869445, MSX1, MSY1, MSX2, MSY2, 15);
If Length(TPA) = 0 Then
Exit;
SetLength(L, Length(TPA));
For I := 0 To High(TPA) Do
ColorToHSL(GetColor(TPA[I].X, TPA[I].Y), H, S, L[I]);
lastCol := GetColor(TPA[Low(TPA)].X, TPA[Low(TPA)].Y);
For J := 0 To High(TPA) Do
Begin
ColorToHSL(lastCol, tempH, tempS, tempL);
If (iAbs(Round(LTol) - Round(Abs(tempL - L[J]))) < 10) And ((Round(tempH) > 15) And (Round(tempH) < 25)) Then
Begin
LTol := tempL - L[J];
SetLength(TPA2, Length(TPA2) + 1);
TPA2[High(TPA2)] := TPA[J];
End;
lastCol := GetColor(TPA[J].X, TPA[J].Y);
End;
Result := Length(TPA2) <> 0;
If Result Then
Begin
Writeln('Found Tree in: ' + IntToStr(GetTickCount - Took) + 'ms');
ATPA := TPAtoATPAex(TPA2, 25, 25);
For I := 0 To High(ATPA) Do
Begin
MiddleTPAex(ATPA[I], X, Y);
MMouse(X, Y, 5, 5);
Wait(100 + Random(100));
If IsUpText('hop') Then
Begin
Result := True;
GetMousePos(X, Y);
Writeln('Luminance Tolerance = ' + FloatToStr(Abs(LTol)));
Exit;
End;
End;
End;
Result := False;
End;
You can change the isuptext('hop') to the uptext of your tree. It takes between 30 - 100 ms to find the tree, depends on how many trees are on the screen. It has never missed a tree