Simba Code:
procedure FindObject;
var
TPA1, TPA2, TPA3: TPointArray;
i, L: Integer;
begin
//NearbyPointInArray(Point, Dist, TPA);
for i:=0 to high(TPA1) do
if NearbyPointInArray(TPA1[i], 10, TPA2) then
begin
L := Length(TPA3);
SetLength(TPA3, L+1);
TPA3[L] := TPA1[i];
end;
end;
TPA1: Red color of your drawing found by using FindColorsTolerance blablabla
TPA2: Green color found the same way
TPA3 is the area where they overlap at any points. You can then split TPA3 to find the largest match.
So all in all something like this
Code:
procedure FindObject;
var
TPA1, TPA2, TPA3: TPointArray;
i, L: Integer;
ATPA: T2DPointArray;
P: TPoint;
begin
//NearbyPointInArray(Point, Dist, TPA);
for i:=0 to high(TPA1) do
if NearbyPointInArray(TPA1[i], 10, TPA2) then
begin
L := Length(TPA3);
SetLength(TPA3, L+1);
TPA3[L] := TPA1[i];
end;
if L > 0 then
begin
SplitTPAWrap(TPA3, 5, ATPA);
SortATPASize(ATPA, True);
P := MiddleTPA(ATPA[0]);
end;
end;