PDA

View Full Version : Pixel Shift for Animation Detection in RS3 and SRL6 (Quick Tip!)



vwxz
12-23-2013, 05:19 PM
Hey guys. Quick tip here. Just some stuff I figured out while working on my current script, and I hope that it will be useful to others. Not too sure if this should go into the beginner or intermediate section, so feel free to move it.

Thanks to the people on IRC who helped work out the details! Especially to Millenium who gave me the tip about clothes (because I originally thought the opposite by accident)!

What is Pixel Shift?

Pixel shift is a measure of how many pixels in a given region have changed from the beginning and the end of a time period. Average pixel shift is the average over time of many samples of pixel shift.

You can view the SRL6 docs for pixel shift here (http://docs.villavu.com/srl-6/pixelshift.html). Flight has an in-depth tutorial for pixel shift in the context of OSRS here (http://villavu.com/forum/showthread.php?t=74090).

What is different in EOC?

I recommend you go read Flight's tutorial for a more general overview. Here are differences you need to account for in RS3.

The biggest difference is that your character has more details and more significant idle animations. This will cause a lot of noise and false positives in pixel shift if you do not account for it.

1. Your character has frequent, significant idle animations.
2. Your character's clothes will shift significantly during idle animation.

Here are some potential mitigation strategies.

1. You should sample pixel shift over a much larger time region to capture time in between idle animations.
2. You should do some sort of removal of outliers, whether by medians, sampling, etc. since idle animations are not completely avoidable and will cause you some proportion of skew and/or false positives if left in. Just averaging is not enough, because the outliers can be pretty large spikes causing pretty significant skew.
3. You should dress your character as close to solid colors as possible. This minimizes the effect of idle animations on pixel shift at least over the main portion of your character's body.

Example

Here is the script I was using to debug pixel shift. It is similar to Flight's example but expanded to take into account RS3 idle animations etc.

This script periodically prints out whether your character is performing a skilling animation. I've tweaked it to be reasonably accurate, but I hope to improve it before I release my current script.

Notes:

This is approximately equivalent to taking a median of average pixel shift. Note that the median is important since it is less affected by outliers.

I picked a threshold which works well for a mostly solid color outfit character doing woodcutting. This value is by no means universal.

program PixelShiftPrinter;
{$define smart}
{$i srl-6/srl.simba}

var
PixelShiftBox: TBox;

procedure DeclarePlayers
begin
Players.Setup(['zee'], 'default');
Players[0].World := 0;
Players[0].IsActive := True;
end;

procedure SetUpResources
begin
PixelShiftBox := IntToBox(275, 175, 300, 210);
end;

function IsPlayerAnimating: Boolean
var
PixelShiftResult, IX, CX: Integer;
begin
CX := 0;
for IX := 1 to 5 do
begin
PixelShiftResult := GetPixelShiftAverage(PixelShiftBox, 200, 1000);
if (PixelShiftResult > 200) then
begin
CX := CX + 1;
end;
end;
Result := CX > 3;
end;

begin
SetUpSRL;
SetUpResources;
DeclarePlayers;
Players[0].Login;
ExitSquealOfFortune;
MiniMap.ClickCompass;
Mainscreen.SetAngle(MS_ANGLE_HIGH);
repeat
WriteLn(BoolToStr(IsPlayerAnimating));
until False;
end.

Brotein
02-09-2014, 01:02 AM
Thanks for this tutorial. I had lost my old SRL5 scripts and forgot how to do pixelshift, this is going to help me on some of my new scripts.

Wu-Tang Clan
02-09-2014, 03:24 AM
When I was looking into it I just couldn't get used to it, I'll look into it again when I make my next script.
BTW- isn't pixelshift in the thousands or something for rs3?

if (PixelShiftResult > 200) then

I might be too tired to understand this, but I thought average pixelshift was like 2800 in idle animations

Brotein
02-09-2014, 06:22 AM
I changed the bounds of the box for my script, was returning about <1000 for idle, and the actual animation was recording around 5500 or so.

That's at zoomed in, high angle, classic camera.
PixelShiftBox := IntToBox(246, 185, 326, 278);