Results 1 to 11 of 11

Thread: Searching for pixels in TPA area

  1. #1
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default Searching for pixels in TPA area

    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:

    Simba Code:
    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;

  2. #2
    Join Date
    Dec 2011
    Location
    Toronto, Ontario
    Posts
    6,424
    Mentioned
    84 Post(s)
    Quoted
    863 Post(s)

    Default

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

    If thats what you mean?

  3. #3
    Join Date
    Jan 2009
    Location
    Turlock/LA, California
    Posts
    1,494
    Mentioned
    3 Post(s)
    Quoted
    66 Post(s)

    Default

    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

  4. #4
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    Quote Originally Posted by x[Warrior]x3500 View Post
    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:

    Simba Code:
    {$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

  5. #5
    Join Date
    Feb 2012
    Location
    Wonderland
    Posts
    1,988
    Mentioned
    41 Post(s)
    Quoted
    272 Post(s)

    Default

    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?

  6. #6
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    Quote Originally Posted by Le Jingle View Post
    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

  7. #7
    Join Date
    Feb 2012
    Location
    Wonderland
    Posts
    1,988
    Mentioned
    41 Post(s)
    Quoted
    272 Post(s)

    Default

    Quote Originally Posted by RJJ95 View Post
    Yes correct
    Which question(s) are correct though? I'm eager to help, so tell me!! (joking, you don't have to tell me ;])

  8. #8
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    Quote Originally Posted by Le Jingle View Post
    Which question(s) are correct though? I'm eager to help, so tell me!! (joking, you don't have to tell me ;])
    Yes it is looking for pixel shift in the boxing

  9. #9
    Join Date
    Feb 2012
    Location
    Wonderland
    Posts
    1,988
    Mentioned
    41 Post(s)
    Quoted
    272 Post(s)

    Default

    Quote Originally Posted by RJJ95 View Post
    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.
    Simba Code:
    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
    Last edited by Le Jingle; 03-14-2013 at 04:25 AM.

  10. #10
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    Quote Originally Posted by Le Jingle View Post
    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.
    Simba Code:
    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

  11. #11
    Join Date
    Mar 2012
    Location
    127.0.0.1
    Posts
    3,383
    Mentioned
    95 Post(s)
    Quoted
    717 Post(s)

    Default

    Simba Code:
    AveragePixelShift
    Is that what you need? o.O

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
  •