johnbrown8976
2012-04-30 23:13:15
hi,
I was trying to detect an object with multiple colors using ATPA.
Scenario: The object has 3 colors. I calculated the ATPA of each 3 colors. Now, I want to check if all three colors are close to each other (within specified distance). I am having a hard time how to do it.
Code updated. Thanks ggzz.
I was trying to detect an object with multiple colors using ATPA.
Scenario: The object has 3 colors. I calculated the ATPA of each 3 colors. Now, I want to check if all three colors are close to each other (within specified distance). I am having a hard time how to do it.
Code updated. Thanks ggzz.
program new;
{$i srl/srl.simba}
var
maxDistance: Integer;
i, x, y, color, tol : Array[0..2] of Integer;
tpa : Array[0..2] of TPointArray;
atpa: Array[0..2] of T2DPointArray;
begin
if not FindColorsTolerance(tpa[0], color[0], MSX1, MSY1, MSX2, MSY2, tol[0]) then
exit;
if not FindColorsTolerance(tpa[1], color[1], MSX1, MSY1, MSX2, MSY2, tol[1]) then
exit;
if not FindColorsTolerance(tpa[2], color[2], MSX1, MSY1, MSX2, MSY2, tol[2]) then
exit;
atpa[0] := SplitTPA(tpa[0], 10);
atpa[1] := SplitTPA(tpa[1], 10);
atpa[2] := SplitTPA(tpa[2], 10);
//first ATPA for loop
for i[0]:=0 to High(atpa[0]) do
begin
tpa[0] := atpa[0][i[0]];
if MiddleTPAEx(tpa[0], x[0], y[0]) then
begin
//Second ATPA for loop
for i[1]:=0 to High(atpa[1]) do
begin
tpa[1] := atpa[1][i[1]];
if MiddleTPAEx(tpa[1], x[1], y[1]) then
begin
if not (Distance(x[0], y[0], x[1], y[1])<maxDistance) then
exit;
//Third ATPA for loop
for i[2]:=0 to High(atpa[2]) do
begin
tpa[2] := atpa[2][i[2]];
if MiddleTPAEx(tpa[2], x[2], y[2]) then
begin
if not (Distance(x[0], y[0], x[2], y[2])<maxDistance) or (Distance(x[1], y[1], x[2], y[2])<maxDistance) then
exit
else
writeln('Found the Perfect TPoint P(' + IntToStr(x[2]) + ', ' + IntToStr(y[2]) + ')');
end;
end;
end;
end;
end;
end;
end.