def __init__(self) -> None: """ Initialize the Argoverse Map. """ self.city_name_to_city_id_dict = { "PIT": PITTSBURGH_ID, "MIA": MIAMI_ID } self.render_window_radius = 150 self.im_scale_factor = 50 self.city_lane_centerlines_dict = self.build_centerline_index() self.city_halluc_bbox_table, self.city_halluc_tableidx_to_laneid_map = self.build_hallucinated_lane_bbox_index( ) self.city_rasterized_da_roi_dict = self.build_city_driveable_area_roi_index( ) self.city_rasterized_ground_height_dict = self.build_city_ground_height_index( ) # get hallucinated lane extends and driveable area from binary img self.city_to_lane_polygons_dict: Mapping[str, np.ndarray] = {} self.city_to_driveable_areas_dict: Mapping[str, np.ndarray] = {} self.city_to_lane_bboxes_dict: Mapping[str, np.ndarray] = {} self.city_to_da_bboxes_dict: Mapping[str, np.ndarray] = {} for city_name in self.city_name_to_city_id_dict.keys(): lane_polygons = np.array( self.get_vector_map_lane_polygons(city_name)) driveable_areas = np.array( self.get_vector_map_driveable_areas(city_name)) lane_bboxes = compute_polygon_bboxes(lane_polygons) da_bboxes = compute_polygon_bboxes(driveable_areas) self.city_to_lane_polygons_dict[city_name] = lane_polygons self.city_to_driveable_areas_dict[city_name] = driveable_areas self.city_to_lane_bboxes_dict[city_name] = lane_bboxes self.city_to_da_bboxes_dict[city_name] = da_bboxes
def test_compute_polygon_bboxes( polygons_and_gt_bboxes: Tuple[List[np.ndarray], List[np.ndarray]]) -> None: """Test for correctness of compute_polygon_bboxes.""" polygon_bboxes = compute_polygon_bboxes( np.array(polygons_and_gt_bboxes[0], dtype=object)) gt_polygon_bboxes = np.array(polygons_and_gt_bboxes[1]) assert np.allclose(polygon_bboxes, gt_polygon_bboxes)
def __init__(self, is_nuscenes=False) -> None: """ Initialize the Argoverse Map. """ self.is_nuscenes = is_nuscenes self.city_name_to_city_id_dict = { "PIT": PITTSBURGH_ID, "MIA": MIAMI_ID } if not is_nuscenes else { "BSP": BOSTON_SEAPORT_ID, "SHV": SINGAPORE_HOLLANDVILLAGE_ID, "SON": SINGAPORE_ONENORTH_ID, "SQT": SINGAPORE_QUEENSTOWN_ID } self.render_window_radius = 150 self.im_scale_factor = 50 self.city_lane_centerlines_dict = self.build_centerline_index() ( self.city_halluc_bbox_table, self.city_halluc_tableidx_to_laneid_map, ) = self.build_hallucinated_lane_bbox_index() #self.city_rasterized_da_roi_dict = self.build_city_driveable_area_roi_index() #self.city_rasterized_ground_height_dict = self.build_city_ground_height_index() # get hallucinated lane extends and driveable area from binary img self.city_to_lane_polygons_dict: Mapping[str, np.ndarray] = {} self.city_to_driveable_areas_dict: Mapping[str, np.ndarray] = {} self.city_to_lane_bboxes_dict: Mapping[str, np.ndarray] = {} self.city_to_da_bboxes_dict: Mapping[str, np.ndarray] = {} for city_name in self.city_name_to_city_id_dict.keys(): lane_polygons = np.array( self.get_vector_map_lane_polygons(city_name)) #driveable_areas = np.array(self.get_vector_map_driveable_areas(city_name)) lane_bboxes = compute_polygon_bboxes(lane_polygons) #da_bboxes = compute_polygon_bboxes(driveable_areas) self.city_to_lane_polygons_dict[city_name] = lane_polygons #self.city_to_driveable_areas_dict[city_name] = driveable_areas self.city_to_lane_bboxes_dict[city_name] = lane_bboxes
def test_compute_polygon_bboxes(polygons_and_gt_bboxes): """Test for correctness of compute_polygon_bboxes.""" polygon_bboxes = compute_polygon_bboxes(np.array( polygons_and_gt_bboxes[0])) gt_polygon_bboxes = np.array(polygons_and_gt_bboxes[1]) assert np.allclose(polygon_bboxes, gt_polygon_bboxes)