Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program new;
- {$I SRL/osr.simba}
- var
- tpa,room,other,door,approx: TPointArray;
- rooms, otherRooms, atpa: T2DPointArray;
- doors: TBoxArray;
- m: TMufasaBitmap;
- i: Int32;
- begin
- srl.FindColors(tpa, CTS2(1776416, 2, 0.2, 0.2), [52,117,553,450]);
- //filter pixel noise
- atpa := tpa.Cluster(2);
- atpa.FilterSize(30, __GT__);
- tpa := atpa.Merge();
- (* you want to filter out XPBar as well*)
- // get the inverted area:
- tpa := tpa.Grow(10);
- tpa := tpa.Invert([52,117,553,450]);
- approx := tpa.Erode(50).Grow(40);
- // extract rooms
- room := tpa.PointsInRangeOf(approx, 0, 35);
- other := ClearTPAFromTPA(TPA, room);
- otherRooms := other.Cluster(2);
- otherRooms.FilterSize(300, __GT__);
- rooms := otherRooms + room.Cluster(2);
- SortATPASize(rooms, True);
- //let's push back the mainroom
- rooms[0] := ClearTPAFromTPA(rooms[0], otherRooms.Merge().Grow(30));
- // extract approximate door areas
- for i:=1 to High(rooms) do
- begin
- door := rooms[0].PointsInRangeOf(rooms[i], 0, 40);
- door += rooms[i].PointsInRangeOf(rooms[0], 0, 40);
- if Length(door) > 10 then
- doors += door.Bounds();
- end;
- m.Init();
- m.FromClient();
- m.DrawATPA(rooms);
- m.DrawTPA(rooms[0].ConvexHull().Connect(), 255);
- m.DrawBoxes(doors, $00ff00);
- m.Debug();
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement