SRL Archive - OSR Help

DisplayDebugImageWindow


GREEN GIANT

2013-07-23 13:36:46

Hi Guys,

Just wondering how to properly use 'DisplayDebugImageWindow', the parameters, where and when to use etc

I'm currently trying to detect as to whether a door is currently open or closed using Height and Width and would love a debug window so i can see what the script is seeing.

Thanks.

masterBB

2013-07-23 13:41:49

I hope this helps ;)

ClearDebugImg();

yourBitmap := CreateBitmap(400, 400);
DrawTPABitmap(yourBitmap, yourTPA, $FF00FF);

DisplayDebugImgWindow(400, 400); //width height
DrawBitmapDebugImg(yourBitmap);

GREEN GIANT

2013-07-23 14:01:16

From: masterBB
I hope this helps ;)

ClearDebugImg();

yourBitmap := CreateBitmap(400, 400);
DrawTPABitmap(yourBitmap, yourTPA, $FF00FF);


DisplayDebugImgWindow(400, 400); //width height
DrawBitmapDebugImg(yourBitmap);


Hi MasterBB,

Thanks for the input, but i really don't have a clue what to do with this :(

Maybe a small worked example?

EDIT: Sorry, im just being lazy as im rubbish with TPAs and use ACA for all my TPA's, ill work it out for myself, Thanks MasterBB.

masterBB

2013-07-23 14:22:56

From: GREEN GIANT
Hi MasterBB,

Thanks for the input, but i really don't have a clue what to do with this :(

Maybe a small worked example?

EDIT: Sorry, im just being lazy as im rubbish with TPAs and use ACA for all my TPA's, ill work it out for myself, Thanks MasterBB.


The TPA you are looking for is the array of points returned by for example FindColorsTolerance. It is the first parameter of that function. Make sure the width and height are at least as big as your search area from FindColorsTolerance. Otherwise it will return an out of bounds error.

GREEN GIANT

2013-07-23 14:31:14

Ok, i thought i could figure this out but i'm failing hard, this is what i have.

function getDoorState: String;
var
yourbitmap: longint;
b : TBox;
cts,i: Integer;
h, w: longint;
tpa : TPointArray;
atpa : T2DPointArray;
begin
Result := 'I have no bloody idea...'; // By default
cts := getToleranceSpeed;


// First, let's get a TPA of the "TOP" of the door
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.16, 0.15);
FindColorsSpiralTolerance(MSCX, MSCY, tpa, 3034728, MSx1, MSy1, MSx2, MSy2, 12);

SetColorSpeed2Modifiers(0.02, 0.02);
ColorToleranceSpeed(CTS);
ClearDebugImg();

yourBitmap := CreateBitmap(w, h);
DrawTPABitmap(yourBitmap, tpa, $FF00FF);

DisplayDebugImgWindow(w, h);
DrawBitmapDebugImg(yourBitmap);
end;

This keeps returning the following error;

Error: Exception: The Points you passed to DrawATPA exceed the bitmap's bounds at line 28

masterBB

2013-07-23 14:56:48

From: GREEN GIANT
Ok, i thought i could figure this out but i'm failing hard, this is what i have.

function getDoorState: String;
var
yourbitmap: longint;
b : TBox;
cts,i: Integer;
h, w: longint;
tpa : TPointArray;
atpa : T2DPointArray;
begin
Result := 'I have no bloody idea...'; // By default
cts := getToleranceSpeed;


// First, let's get a TPA of the "TOP" of the door
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.16, 0.15);
FindColorsSpiralTolerance(MSCX, MSCY, tpa, 3034728, MSx1, MSy1, MSx2, MSy2, 12);

SetColorSpeed2Modifiers(0.02, 0.02);
ColorToleranceSpeed(CTS);
ClearDebugImg();

yourBitmap := CreateBitmap(w, h);
DrawTPABitmap(yourBitmap, tpa, $FF00FF);

DisplayDebugImgWindow(w, h);
DrawBitmapDebugImg(yourBitmap);
end;

This keeps returning the following error;

Error: Exception: The Points you passed to DrawATPA exceed the bitmap's bounds at line 28


Don't worry. It what I mentioned above. w and h are 0. So it only got zero space to place the points on. MSx2 and MSy2 are the maximum values the points can have. So try:

w := MSx2 + 1;
h := MSy2 + 1;

GREEN GIANT

2013-07-23 15:37:32

Thanks that works great :)