asw_component/__init__.py +3−0 View file@@ -0,0 +1,3 @@
1 +
from .component import execute 2 +
3 +
__all__ = ["execute"][참조 MVP] 3D 주행환경 인지 A-SW — 3차원 점군을 격자 군집화해 장애물 위치와 경계 상자를 생성합니다.
https://git.agrithing.ai/jbnu/3d-environment-perception.git 456d174 7b37d22 8b9d3f5 2d2177a 914852b 15d0349 d73e993 402fbd3 d73e99373db998389b8aee973308c047e72ae051 asw_component/__init__.py +3−0 View filefrom .component import execute__all__ = ["execute"]asw_component/component.py +17−0 View filefrom __future__ import annotationsfrom collections import defaultdictdef execute(payload: dict) -> dict: cell = float(payload.get("cell_size_m", 1)) minimum = int(payload.get("min_points", 2)) if cell <= 0: raise ValueError("cell_size_m must be positive") buckets = defaultdict(list) for point in payload.get("points", []): buckets[(int(point[0] // cell), int(point[1] // cell))].append(point) obstacles = [] for key, points in buckets.items(): if len(points) < minimum: continue obstacles.append({"cell": list(key), "centroid": [round(sum(p[i] for p in points)/len(points), 3) for i in range(3)], "point_count": len(points), "class": "unknown_obstacle"}) return {"frame": "lidar", "obstacles": obstacles, "obstacle_count": len(obstacles)}examples/input.json +21−0 View file{ "cell_size_m": 1, "min_points": 2, "points": [ [ 1.1, 2.1, 0.3 ], [ 1.2, 2.2, 0.5 ], [ 8, 9, 0.2 ] ]}pyproject.toml +8−0 View file[project]name = "3d_environment_perception"version = "0.1.0"description = "3차원 점군을 격자 군집화해 장애물 위치와 경계 상자를 생성합니다."requires-python = ">=3.11"[tool.unittest]test-path = "tests"run.py +10−0 View filefrom __future__ import annotationsimport jsonimport sysfrom asw_component import executeif __name__ == "__main__": path = sys.argv[1] if len(sys.argv) > 1 else None with open(path, encoding="utf-8") if path else sys.stdin as source: payload = json.load(source) print(json.dumps(execute(payload), ensure_ascii=False, indent=2))