def test_draw_polygon_mpl_smokescreen_nolinewidth() -> None: """Test drawing polygon with `matplotlib` with no line width.""" ax = plt.axes([1, 1, 1, 1]) # polygon: Numpy array of shape (N,2) or (N,3) polygon = np.array([[0, 0], [1, 1], [1, 0], [0, 0]]) color = "r" draw_polygon_mpl(ax, polygon, color) plt.close("all")
def test_draw_polygon_mpl_smokescreen_with_linewidth() -> None: """""" ax = plt.axes([1, 1, 1, 1]) # polygon: Numpy array of shape (N,2) or (N,3) polygon = np.array([[0, 0], [1, 1], [1, 0], [0, 0]]) color = "r" linewidth = 100 draw_polygon_mpl(ax, polygon, color, linewidth=linewidth) plt.close("all")
def test_draw_polygon_mpl_smokescreen_nolinewidth() -> None: """""" ax = plt.axes([1, 1, 1, 1]) # polygon: Numpy array of shape (N,2) or (N,3) polygon = np.array([[0, 0], [1, 1], [1, 0], [0, 0]]) # color is tuple or Numpy array of shape (3,) representing RGB values color = np.array([255, 0, 0]) draw_polygon_mpl(ax, polygon, color) plt.close("all")
def test_compute_midpoint_line_curved_maintain_4_waypts(): """ Make sure that if we provide left and right boundary polylines, we can get the correct centerline by averaging left and right waypoints. Note that because of the curve and the arc interpolation, the land width and centerline in the middle points will be shifted. """ right_ln_bnds = np.array([[-1, 3], [1, 3], [4, 0], [4, -2]]) left_ln_bnds = np.array([[-1, 1], [1, 1], [2, 0], [2, -2]]) centerline_pts, lane_width = compute_midpoint_line(left_ln_bnds, right_ln_bnds, num_interp_pts=4) from argoverse.utils.mpl_plotting_utils import draw_polygon_mpl fig = plt.figure(figsize=(22.5, 8)) ax = fig.add_subplot(111) draw_polygon_mpl(ax, right_ln_bnds, "g") draw_polygon_mpl(ax, left_ln_bnds, "b") draw_polygon_mpl(ax, centerline_pts, "r") gt_centerline_pts = np.array([[-1, 2], [1, 2], [3, 0], [3, -2]]) gt_lane_width = 2.0 assert np.allclose(centerline_pts[0], gt_centerline_pts[0]) assert np.allclose(centerline_pts[-1], gt_centerline_pts[-1])