SRL Archive - OSR Help

Wizzy Plugin Help :)


GREEN GIANT

2013-07-24 06:22:55

Hi Guys,

I'm in the process of making a procedure that uses TPA's to detect as to whether a double door is open or closed.

I have basically made the TPA for the top of the door, and have then made an ATPA using TPAtoATPA, from here i have debugged the image and found that it finds the door nicely, but also finds a few smaller TPAs such as guard shoes and etc etc

My question is;

If i wanted to GetATPAbounds for just the first instance [0] and from here manipulate the x, y to find whether the door is open/closed how would i best do it?

I tried function SortATPASize to get the biggest TPA (the door) as [0] but how do i, from here find the bounds of ATPA[0] so i can manipulate it?

Heres the basic code i have so far (sorry for lack of standards)


Procedure tttt;
var
h, i: integer;
b: tbox;


begin
setupsrl;

//Door colors
CTS:= GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.13, 0.37);
FindColorsSpiralTolerance(MSCX, MSCY, TPA, 3297134, MSX1, MSY1, MSX2, MSY2, 6);
SetColorSpeed2Modifiers(0.02, 0.02);
ColorToleranceSpeed(CTS);
if length(TPA) < 1 then exit;

//ATPA
ATPA:= TPAtoATPA(TPA, 100);
SortATPASize(atpa, true);

//Open or Close
b:= GetATPABounds(ATPA);
h:= b.y2-b.y1;

if (h >= 25) then
writeln('Door open')
else if (h <= 25) then
Writeln('Door closed')

end;

begin
tttt;
DebugATPABounds(ATPA);
Writeln(GetATPABounds(ATPA));

end.

@@ EDIT @@

Figured it out :) Here's the revised code for anyone interested, it finds the bounds of ATPA[0] giving it a height and width, it then checks to see if h > w then 'Door is open' or if w > h then 'Door is closed'.

Var
TPA: TPointArray;
ATPA: T2DPointArray;
CTS: integer;

Procedure tttt;
var
h, w, i: integer;
b: tbox;

begin
setupsrl;

//Door colors
CTS:= GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.13, 0.37);
FindColorsSpiralTolerance(MSCX, MSCY, TPA, 3297134, MSX1, MSY1, MSX2, MSY2, 6);
SetColorSpeed2Modifiers(0.02, 0.02);
ColorToleranceSpeed(CTS);
if length(TPA) < 1 then exit;

//ATPA
ATPA:= TPAtoATPA(TPA, 30);
SortATPASize(ATPA, true);

//Open or Close
b:= GetTPABounds(ATPA[0]);
h:= (b.y2-b.y1);
w:= (b.x2-b.X1);

if (h > w) then
writeln('Door open')
else if (h < w) then
Writeln('Door closed')

end;

begin
tttt;
DebugATPABounds(ATPA);
Writeln(GetTPABounds(ATPA[0]));

end.