SRL Archive - OSR Help

Searching for pixels in TPA area


rj

2013-03-13 21:26:06

So I want the procedue to search for shifting pixels in the TPA area, how do I do that I don't have the slightest clue, here is what I got:

Procedure GetColorsMoving(Color,tol,shift: Integer; hue,sat: Extended);
Var
tmpCTS,i, L,Counter: Integer;
ObjTPA: TPointArray;
ObjATPA: T2DPointArray;
X,Y,DMCount,Moves: Integer;
Begin
Moves:=0;
DMCount:=0;

tmpCTS := GetToleranceSpeed;
SetColorToleranceSpeed(2);

SetToleranceSpeed2Modifiers(0.06, 0.41);
FindColorsTolerance(ObjTPA, 3172740, MSX1, MSY1, MSX2, MSY2, 4);
SplitTPAWrap(ObjTPA, 10, ObjATPA);

SortATPAFromFirstPoint(ObjATPA, Point(MSCX,MSCY));
SetColorToleranceSpeed(tmpCTS);
SetToleranceSpeed2Modifiers(0.02, 0.02);

DMCount:=RandomRange(3,5);
L := High(ObjATPA)
MarkTime(Counter);
For i := 0 To L Do
Begin
MiddleTPAEx(ObjATPA[i], X, Y);
End;
End;

Sin

2013-03-13 21:28:47

PBox := GetTPABounds();
AveragePixelShift() > x?

If thats what you mean?

x[Warrior]x3500

2013-03-13 21:29:27

umm off the top of my head:

1. get initial tpa
2. get colors from tpa and put them in tia (the non
3. check colors again from your already created tpa and put in new tia
4. compare tias

probably slow, but it should work. brain is dead though… been studyin for midterms all week

rj

2013-03-13 22:38:45

From: x[Warrior]x3500
umm off the top of my head:

1. get initial tpa
2. get colors from tpa and put them in tia (the non
3. check colors again from your already created tpa and put in new tia
4. compare tias

probably slow, but it should work. brain is dead though… been studyin for midterms all week


Ok so I got:

{$I SRL/SRL.Simba}
Procedure GetColorsMoving;
Var
tmpCTS,i, L,Counter: Integer;
ObjTPA: TPointArray;
ObjATPA: T2DPointArray;
X,Y,DMCount,Moves: Integer;
PBox:Tbox;
Moving:Boolean;
Begin
Moves:=0;
DMCount:=0;

tmpCTS := GetToleranceSpeed;
SetColorToleranceSpeed(2);

SetToleranceSpeed2Modifiers(0.28, 0.60);
FindColorsTolerance(ObjTPA, 6453124, MSX1, MSY1, MSX2, MSY2, 14);
SplitTPAWrap(ObjTPA, 10, ObjATPA);

SortATPAFromFirstPoint(ObjATPA, Point(MSCX,MSCY));
SetColorToleranceSpeed(tmpCTS);
SetToleranceSpeed2Modifiers(0.02, 0.02);

DMCount:=RandomRange(3,5);
L := High(ObjATPA)
MarkTime(Counter);
For i := 0 To L Do
Begin
MiddleTPAEx(ObjATPA[i], X, Y);
Repeat Begin
Moves:=Moves+1;
if (X <= 15) Or (Y <= 15) Then
Begin
Exit;
End;
PBox := IntToBox(X-18, Y+18, X+18, Y-18);
Moving := (AveragePixelShift(PBox, 250, 350) > 25);
If Moving Then
Begin
Writeln('Found Smoke');
Wait(50000);
Exit;
End;
Writeln('No Smoke');
End; Until (Moves > DMCount)
End;
End;


Begin
Repeat
GetColorsMoving;
Until False;
End.

But it does not seem to be working

Le Jingle

2013-03-13 23:40:06

I'm very confused what you're trying to accomplish.
Is it that you want to get colors that change on the Main Screen (as indicated by the procedure name)?
Are you trying to look for a the Average Pixel shift in a specific TPA?

The code, to me, looks like you're making a box for every element in the ATPA, and testing it for any given pixel shift?

rj

2013-03-13 23:43:08

From: Le Jingle
I'm very confused what you're trying to accomplish.
Is it that you want to get colors that change on the Main Screen (as indicated by the procedure name)?
Are you trying to look for a the Average Pixel shift in a specific TPA?

The code, to me, looks like you're making a box for every element in the ATPA, and testing it for any given pixel shift?

Yes correct

Le Jingle

2013-03-13 23:51:13

From: RJJ95
Yes correct


Which question(s) are correct though? I'm eager to help, so tell me!! :p (joking, you don't have to tell me ;])

rj

2013-03-13 23:55:28

From: Le Jingle
Which question(s) are correct though? I'm eager to help, so tell me!! :p (joking, you don't have to tell me ;])


Yes it is looking for pixel shift in the boxing

Le Jingle

2013-03-14 00:22:53

From: RJJ95
Yes it is looking for pixel shift in the boxing


Alright, well bear with me, I'll make a few assumptions then:
(ex. like trying to find the pixel shift over the best box)

But I think this code is what you are trying to do/find, no?
If you want to save the coords of the changed box, you can in the last for loop, as that loop iterates through the potential shifts on the main screen for your result.

function FindTPAShift(TimeOut: Integer): Boolean;
var
i, TempCTS: Integer;
OldHue, OldSat: Extended;
TIA: TIntegerArray;
TPA: TPointArray;
TBA: TBoxArray;
ATPA: T2DPointArray;
begin
result := false;
GetColorSpeed2Modifiers(OldHue, OldSat);
TempCTS := GetColorToleranceSpeed();
SetColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.28, 0.60);
FindColorsTolerance(TPA, 6453124, MSX1, MSY1, MSX2, MSY2, 14);
SetColorSpeed2Modifiers(OldHue, OldSat);
SetColorToleranceSpeed(TempCTS);

SplitTPAWrap(TPA, 10, ATPA);
SortATPASize(ATPA, true);

SetArrayLength(TBA, Length(ATPA));
for i := 0 to high(ATPA) do
TBA[i] := GetTPABounds(ATPA[i]);

SetArrayLength(TIA, Length(ATPA));
TIA := PixelShiftMulti(TBA, TimeOut);

for i := 0 to high(TIA) do
if (TIA[i] > 25) then
begin
result := true;
break;
end;
end;

Basic idea is that this function finds your TPA,
Splits the TPA into an ATPA,
Filters the ATPA by best 1st,
Makes a box for each each ATPA element,
Searches for pixel shift in each of the ATPA's,
then filters through the shift results, and resulting true if one is over 25 pixels.

Edit: Could be re-used too if you wanted with other objects, given you add the specifications into the arguments (maybe even as a custom object type? ;))

Cheers,
-Lj

rj

2013-03-14 00:26:25

From: Le Jingle
Alright, well bear with me, I'll make a few assumptions then:
(ex. like trying to find the pixel shift over the best box)

But I think this code is what you are trying to do/find, no?
If you want to save the coords of the changed box, you can in the last for loop, as that loop iterates through the potential shifts on the main screen for your result.

function FindTPAShift(TimeOut: Integer): Boolean;
var
i, TempCTS: Integer;
OldHue, OldSat: Extended;
TIA: TIntegerArray;
TPA: TPointArray;
TBA: TBoxArray;
ATPA: T2DPointArray;
begin
result := false;
GetColorSpeed2Modifiers(OldHue, OldSat);
TempCTS := GetColorToleranceSpeed();
SetColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.28, 0.60);
FindColorsTolerance(TPA, 6453124, MSX1, MSY1, MSX2, MSY2, 14);
SetColorSpeed2Modifiers(OldHue, OldSat);
SetColorToleranceSpeed(TempCTS);

SplitTPAWrap(TPA, 10, ATPA);
SortATPASize(ATPA, true);

SetArrayLength(TBA, Length(ATPA));
for i := 0 to high(ATPA) do
TBA[i] := GetTPABounds(ATPA[i]);

SetArrayLength(TIA, Length(ATPA));
TIA := PixelShiftMulti(TBA, TimeOut);

for i := 0 to high(TIA) do
if (TIA[i] > 25) then
begin
result := true;
break;
end;
end;

Basic idea is that this function finds your TPA,
Splits the TPA into an ATPA,
Filters the ATPA by best 1st,
Makes a box for each each ATPA element,
Searches for pixel shift in each of the ATPA's,
then filters through the shift results, and resulting true if one is over 25 pixels.

Edit: Could be re-used too if you wanted with other objects, given you add the specifications into the arguments (maybe even as a custom object type? ;))

Cheers,
-Lj


ty sir will test when i get back on a computer in about 16 hours :p

NKN

2013-03-14 06:43:11

AveragePixelShift
Is that what you need? o.O