Fuse Lidar and Camera Obstacles
You are given two lists of obstacles detected by different sensors: lidar_obstacles and camera_obstacles.
Each obstacle has a box with coordinates [x, y, w, h], where x and y are the center coordinates, and w and h are the width and height.
Write a function fuse(lidar_obstacles: List[LidarObstacle], camera_obstacles: List[CameraObstacle]) -> List[...].
The goal is to merge the two lists into one list of obstacles for the current timestamp.
- Trust lidar obstacles more when a lidar obstacle overlaps with a camera obstacle.
- If there is no overlap, append both obstacles to the result.
- Return the fused list of obstacles.
这道题考察的是双传感器障碍物融合:输入为 lidar 和 camera 两组障碍物,每个障碍物都用中心点加宽高的 box 表示。核心是判断两个障碍物是否重叠,如果重叠则优先保留 lidar 的结果;如果不重叠,则两个都要加入输出列表。实现时通常需要先把 box 转成矩形区间,再用重叠判断完成匹配与合并,重点在于清晰处理“覆盖、冲突、保留双方”这几种情况。