def draw_lane_ids(lane_ids: List[int], am: ArgoverseMap, ax: Axes,
                  city_name: str) -> None:
    """
        Args:
        -   lane_ids
        -   am
        -   ax
        -   city_name

        Returns:
        -   None
    """
    for lane_id in lane_ids:
        centerline = am.get_lane_segment_centerline(int(lane_id), city_name)
        ax.text(centerline[2, 0], centerline[2, 1], f"s_{lane_id}")
        ax.text(centerline[-3, 0], centerline[-3, 1], f"e_{lane_id}")
Example #2
0
def verify_halluc_lane_extent_index(enable_lane_boundaries=False):
    """

        """
    avm = ArgoverseMap()

    city_names = ["MIA", "PIT"]

    for city_name in city_names:
        # get all lane segment IDs inside of this city
        lane_segment_ids = list(
            avm.city_lane_centerlines_dict[city_name].keys())
        for lane_segment_id in lane_segment_ids:
            xmin, ymin, xmax, ymax = find_lane_segment_bounds_in_table(
                adm, city_name, lane_segment_id)

            predecessor_ids = avm.get_lane_segment_predecessor_ids(
                lane_segment_id, city_name)
            successor_ids = avm.get_lane_segment_successor_ids(
                lane_segment_id, city_name)
            (r_neighbor_id, l_neighbor_id) = avm.get_lane_segment_adjacent_ids(
                lane_segment_id, city_name)
            lane_centerline = avm.get_lane_segment_centerline(
                lane_segment_id, city_name)
            halluc_lane_polygon = avm.get_lane_segment_polygon(
                lane_segment_id, city_name)

            fig = plt.figure(figsize=(22.5, 8))
            ax = fig.add_subplot(111)

            # add the lane of interest
            add_lane_segment_to_ax(ax, lane_centerline, halluc_lane_polygon,
                                   "y", xmin, xmax, ymin, ymax)

            if predecessor_ids is not None:
                # add predecessors
                for predecessor_id in predecessor_ids:
                    lane_centerline = avm.get_lane_segment_centerline(
                        predecessor_id, city_name)
                    halluc_lane_polygon = avm.get_lane_segment_polygon(
                        predecessor_id, city_name)
                    xmin, ymin, xmax, ymax = find_lane_segment_bounds_in_table(
                        adm, city_name, predecessor_id)
                    add_lane_segment_to_ax(ax, lane_centerline,
                                           halluc_lane_polygon, "r", xmin,
                                           xmax, ymin, ymax)

            if successor_ids is not None:
                # add successors
                for successor_id in successor_ids:
                    lane_centerline = avm.get_lane_segment_centerline(
                        successor_id, city_name)
                    halluc_lane_polygon = avm.get_lane_segment_polygon(
                        successor_id, city_name)
                    xmin, ymin, xmax, ymax = find_lane_segment_bounds_in_table(
                        adm, city_name, successor_id)
                    add_lane_segment_to_ax(ax, lane_centerline,
                                           halluc_lane_polygon, "b", xmin,
                                           xmax, ymin, ymax)

            # add left neighbor
            if l_neighbor_id is not None:
                lane_centerline = avm.get_lane_segment_centerline(
                    l_neighbor_id, city_name)
                halluc_lane_polygon = avm.get_lane_segment_polygon(
                    l_neighbor_id, city_name)
                xmin, ymin, xmax, ymax = find_lane_segment_bounds_in_table(
                    adm, city_name, l_neighbor_id)
                add_lane_segment_to_ax(ax, lane_centerline,
                                       halluc_lane_polygon, "g", xmin, xmax,
                                       ymin, ymax)

            # add right neighbor
            if r_neighbor_id is not None:
                lane_centerline = avm.get_lane_segment_centerline(
                    r_neighbor_id, city_name)
                halluc_lane_polygon = avm.get_lane_segment_polygon(
                    r_neighbor_id, city_name)
                xmin, ymin, xmax, ymax = find_lane_segment_bounds_in_table(
                    adm, city_name, r_neighbor_id)
                add_lane_segment_to_ax(ax, lane_centerline,
                                       halluc_lane_polygon, "m", xmin, xmax,
                                       ymin, ymax)

            if enable_lane_boundaries:
                # Compare with Argo's proprietary, ground truth lane boundaries
                gt_lane_polygons = avm.city_to_lane_polygons_dict[city_name]
                for gt_lane_polygon in gt_lane_polygons:
                    dist = np.linalg.norm(
                        gt_lane_polygon.mean(axis=0)[:2] -
                        np.array([xmin, ymin]))
                    if dist < 30:
                        ax.plot(gt_lane_polygon[:, 0],
                                gt_lane_polygon[:, 1],
                                color="k",
                                alpha=0.3,
                                zorder=1)

            ax.axis("equal")
            plt.show()
            datetime_str = generate_datetime_string()
            plt.savefig(
                f"lane_segment_id_{lane_segment_id}_@_{datetime_str}.jpg")
            plt.close("all")