Advertisement
WarPie90

Barrows rooms - test 2

May 27th, 2023
1,848
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 1.31 KB | None | 0 0
  1. program new;
  2. {$I SRL/osr.simba}
  3.  
  4.  
  5. var
  6.   tpa,room,other,door,approx: TPointArray;
  7.   rooms, otherRooms, atpa: T2DPointArray;
  8.   doors: TBoxArray;
  9.   m: TMufasaBitmap;
  10.   i: Int32;
  11. begin
  12.   srl.FindColors(tpa, CTS2(1776416, 2, 0.2, 0.2), [52,117,553,450]);
  13.  
  14.   //filter pixel noise
  15.   atpa := tpa.Cluster(2);
  16.   atpa.FilterSize(30, __GT__);
  17.   tpa := atpa.Merge();
  18.   (* you want to filter out XPBar as well*)
  19.  
  20.   // get the inverted area:
  21.   tpa := tpa.Grow(10);
  22.   tpa := tpa.Invert([52,117,553,450]);
  23.   approx := tpa.Erode(50).Grow(40);
  24.  
  25.   // extract rooms
  26.   room := tpa.PointsInRangeOf(approx, 0, 35);
  27.   other := ClearTPAFromTPA(TPA, room);
  28.  
  29.   otherRooms := other.Cluster(2);
  30.   otherRooms.FilterSize(300, __GT__);
  31.   rooms := otherRooms + room.Cluster(2);
  32.   SortATPASize(rooms, True);
  33.  
  34.  
  35.   //let's push back the mainroom
  36.   rooms[0] := ClearTPAFromTPA(rooms[0], otherRooms.Merge().Grow(30));
  37.  
  38.   // extract approximate door areas
  39.   for i:=1 to High(rooms) do
  40.   begin
  41.     door := rooms[0].PointsInRangeOf(rooms[i], 0, 40);
  42.     door += rooms[i].PointsInRangeOf(rooms[0], 0, 40);
  43.     if Length(door) > 10 then
  44.       doors += door.Bounds();
  45.   end;
  46.  
  47.  
  48.   m.Init();
  49.   m.FromClient();
  50.   m.DrawATPA(rooms);
  51.  
  52.   m.DrawTPA(rooms[0].ConvexHull().Connect(), 255);
  53.   m.DrawBoxes(doors, $00ff00);
  54.  
  55.   m.Debug();
  56. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement