Results 1 to 4 of 4

Thread: Pixel Shift for Animation Detection in RS3 and SRL6 (Quick Tip!)

  1. #1
    Join Date
    Dec 2013
    Posts
    95
    Mentioned
    2 Post(s)
    Quoted
    37 Post(s)

    Default Pixel Shift for Animation Detection in RS3 and SRL6 (Quick Tip!)

    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. Flight has an in-depth tutorial for pixel shift in the context of OSRS here.

    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.

    Simba Code:
    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.
    Last edited by vwxz; 12-23-2013 at 05:35 PM.

  2. #2
    Join Date
    Jan 2012
    Location
    Long Island, NY
    Posts
    413
    Mentioned
    5 Post(s)
    Quoted
    95 Post(s)

    Default

    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.

  3. #3
    Join Date
    Mar 2013
    Location
    Shaolin
    Posts
    863
    Mentioned
    24 Post(s)
    Quoted
    519 Post(s)

    Default

    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?
    Simba Code:
    if (PixelShiftResult > 200) then
    I might be too tired to understand this, but I thought average pixelshift was like 2800 in idle animations
    You have permission to steal anything I've ever made...

  4. #4
    Join Date
    Jan 2012
    Location
    Long Island, NY
    Posts
    413
    Mentioned
    5 Post(s)
    Quoted
    95 Post(s)

    Default

    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.
    Simba Code:
    PixelShiftBox := IntToBox(246, 185, 326, 278);

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •