SRL Archive - Non-RuneScape Scripts

Motion detection script


basestati0n

2012-05-07 18:03:09

I'm racking my brain but I can't think of a way to detect motion. Essentially I want to write a script to look for a moving object within a given area (the rest of the image will be stationary) and click it - any ideas?

TIA :)

Abu

2012-05-07 18:32:43

Does the moving object have any unique colours?

If so, you might as well just search for the colour rather than try and detect motion…

cause

2012-05-07 19:31:16

Pixel shift?

Ogre

2012-05-07 19:37:04

Isn't there a function for this in MSI?

uz3

2012-05-07 19:47:56

Couldn't you just get a color or range of colors and check every few hundred milliseconds or so and see if they have changed? Is that what the current pixelshift does?

bg5

2012-05-07 23:31:40

You can split area to array of TBox ,then use PixelShiftMulti
BTW. It's quite clever idea.


Edit:

Just commited this:

function MSToTBA (row ,col : integer) : array of TBox;
var
a ,l,w,h :integer;

begin
l := row*col;
w := (MSX2-MSX1)/col;
h := (MSY2-MSY1)/row;

SetLength(Result,l);
for a:= 0 to l-1 do
begin
Result[a].x1 := MSX1 + w * (a mod col);
Result[a].x2 := Result[a].x1 + w;
Result[a].y1 := MSY1 + h * (a div col);
Result[a].y2 := Result[a].y1 + h;
end;

end;



procedure ShowMotion;
var
a,h ,threshold: integer;
TIA : TintegerArray;
TBA : array of TBox;
begin

threshold := 60;

TBA := MStoTBA(20,22);
SMART_DrawBoxes(TRUE,TBA,clred);

h := High(TBA);
wait(2000);
repeat

TIA := PixelShiftMulti(TBA,50);
for a := 0 to h do
if TIA[a] > threshold then SMART_DrawCircle(FALSE,MiddleBox(TBA[a]),4,TRUE,clgreen);

SMART_ClearCanvas;
until (false)

end;

Run and see what happen :)

Olly

2012-05-08 18:34:53

From: beginner5
You can split area to array of TBox ,then use PixelShiftMulti
BTW. It's quite clever idea.


Edit:

Just commited this:

function MSToTBA (row ,col : integer) : array of TBox;
var
a ,l,w,h :integer;

begin
l := row*col;
w := (MSX2-MSX1)/col;
h := (MSY2-MSY1)/row;

SetLength(Result,l);
for a:= 0 to l-1 do
begin
Result[a].x1 := MSX1 + w * (a mod col);
Result[a].x2 := Result[a].x1 + w;
Result[a].y1 := MSY1 + h * (a div col);
Result[a].y2 := Result[a].y1 + h;
end;

end;



procedure ShowMotion;
var
a,h ,threshold: integer;
TIA : TintegerArray;
TBA : array of TBox;
begin

threshold := 60;

TBA := MStoTBA(20,22);
SMART_DrawBoxes(TRUE,TBA,clred);

h := High(TBA);
wait(2000);
repeat

TIA := PixelShiftMulti(TBA,50);
for a := 0 to h do
if TIA[a] > threshold then SMART_DrawCircle(FALSE,MiddleBox(TBA[a]),4,TRUE,clgreen);

SMART_ClearCanvas;
until (false)

end;

Run and see what happen :)


I have no real use for that, but that was very interesting none of the less!