Results 1 to 6 of 6

Thread: Simba crashing randomly at this function

  1. #1
    Join Date
    May 2009
    Posts
    799
    Mentioned
    2 Post(s)
    Quoted
    16 Post(s)

    Default Simba crashing randomly at this function

    Hi !!!
    I've written this function ages ago and I need it now again.
    The problem is, it crashes with lape and simba, and I have no clue why.

    Simba just freezes and says memory violation.

    Anyone with an idea to fix it ?

    ~caused

    Simba Code:
    // atpax is your atpa, remember to make boxes first with splittpaex or tpatoatpaex for example.
    // minw,maxw -> minimum and maximun box width.
    // minh, maxh -> min and max box height.
    Function FilterATPASize(var ATPAx: T2DPointArray; minw,maxw,minh,maxh:Integer):T2dPointarray;
    var
    B: TBox;
    W,H,i,lengthcounter: Integer;
    temp,temp2,temptpa : T2DPointArray;
    begin
    SortATPASize(ATPAx,True);
    setarraylength(temp,length(atpax));
    lengthcounter:=0;

    for i:= 0 to high(atpax) do
    begin

    B := GetTPABounds(ATPAx[i]);
    W := B.x2 - B.x1;
    H := B.y2 - B.y1;
    // WriteLn('Box '+inttostr(i)+'dimensions: '+inttostr(W)+'*'+inttostr(H));
    If ((W >= minw) AND (W <= maxw) AND (H >= minh) AND (H <= maxh)) then
    begin
    inc(lengthcounter);
    temp[i] := CombineTPA(atpax[i],temp[i]);
    // writeLn('Boxes Found: '+inttostr(lengthcounter));
    end;

    end;
    //InvertAtpa(temp);
    SetArrayLength(temp,lengthcounter+1);
    result := temp;
    end;

  2. #2
    Join Date
    Jan 2012
    Posts
    1,596
    Mentioned
    78 Post(s)
    Quoted
    826 Post(s)

    Question

    you use combinetpa() which combines 2 tpas into 1 tpa.

    thats probably the issue.

    Simba Code:
    Function FilterATPASize2(var ATPAx: T2DPointArray; minw,maxw,minh,maxh:Integer):T2dPointarray;
    var
      i, w, h: integer;
      b: TBox;
    begin
      result := [];
      for i := 0 to high(atpax) do
      begin
        b := getTPABounds(atpax[i]);
        w := abs(b.x2 - b.x1 + 1);
        h := abs(b.y2 - b.y1 + 1);
        if inrange(w, minw, maxw) and inrange(h, minh, maxh) then
          result := result + atpax[i];
      end;
    end;

    just wrote that, might work, might not. didnt test it. not sure if i can just add tpas to atpas or not.

  3. #3
    Join Date
    Feb 2012
    Location
    Norway
    Posts
    995
    Mentioned
    145 Post(s)
    Quoted
    596 Post(s)

    Default

    @Turpinator's code, Simba 1.2 - Minified:
    Simba Code:
    function FilterATPABySize(ATPA: T2DPointArray; minw,maxw,minh,maxh: Int32): T2DPointArray;
    var
      TPA:TPointArray;
    begin
      for TPA in ATPA do
        with GetTPABounds(TPA) do
          if InRange(x2-x1+1, minw, maxw) and InRange(y2-y1+1, minh, maxh) then
            Result += TPA;
    end;
    !No priv. messages please

  4. #4
    Join Date
    Jan 2012
    Posts
    1,596
    Mentioned
    78 Post(s)
    Quoted
    826 Post(s)

    Default

    Quote Originally Posted by slacky View Post
    @Turpinator's code, Simba 1.2 - Minified:
    Simba Code:
    function FilterATPABySize(ATPA: T2DPointArray; minw,maxw,minh,maxh: Int32): T2DPointArray;
    var
      TPA:TPointArray;
    begin
      for TPA in ATPA do
        with GetTPABounds(TPA) do
          if InRange(x2-x1+1, minw, maxw) and InRange(y2-y1+1, minh, maxh) then
            Result += TPA;
    end;
    Since when does this work?
    Code:
    for TPA in ATPA do
    this aint python, m8.

  5. #5
    Join Date
    Feb 2012
    Location
    Norway
    Posts
    995
    Mentioned
    145 Post(s)
    Quoted
    596 Post(s)

    Default

    Quote Originally Posted by Turpinator View Post
    Since when does this work?
    Code:
    for TPA in ATPA do
    this aint python, m8.
    Since Simba 1.2, which uses latest lape. Keep up noob
    !No priv. messages please

  6. #6
    Join Date
    May 2009
    Posts
    799
    Mentioned
    2 Post(s)
    Quoted
    16 Post(s)

    Default

    Thanks alot everyone

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
  •