MCPcopy Create free account
hub / github.com/Thinklab-SJTU/Bench2Drive / draw_dashed_line

Function draw_dashed_line

tools/utils.py:74–101  ·  view source on GitHub ↗

Draw a dashed line on an image. Arguments: - img: The image on which to draw the dashed line. - start_point: The starting point of the dashed line, in the format (x, y). - end_point: The ending point of the dashed line, in the format (x, y). - color: The color of the dashed

(img, start_point, end_point, color, thickness=1, dash_length=5)

Source from the content-addressed store, hash-verified

72 return vertices
73
74def draw_dashed_line(img, start_point, end_point, color, thickness=1, dash_length=5):
75 """
76 Draw a dashed line on an image.
77 Arguments:
78 - img: The image on which to draw the dashed line.
79 - start_point: The starting point of the dashed line, in the format (x, y).
80 - end_point: The ending point of the dashed line, in the format (x, y).
81 - color: The color of the dashed line, in the format (B, G, R).
82 - thickness: The thickness of the line.
83 - dash_length: The length of each dash segment in the dashed line.
84 """
85 # Calculate total length
86 d = np.sqrt((end_point[0] - start_point[0])**2 + (end_point[1] - start_point[1])**2)
87 dx = (end_point[0] - start_point[0]) / d
88 dy = (end_point[1] - start_point[1]) / d
89
90 x, y = start_point[0], start_point[1]
91
92 while d >= dash_length:
93 # Calculate the end point of the next segment
94 x_end = x + dx * dash_length
95 y_end = y + dy * dash_length
96 cv2.line(img, (int(x), int(y)), (int(x_end), int(y_end)), color, thickness)
97
98 # Update starting point and remaining length
99 x = x_end + dx * dash_length
100 y = y_end + dy * dash_length
101 d -= 2 * dash_length
102
103def world_to_ego(point_world, w2e):
104 point_world = np.array([point_world[0], point_world[1], point_world[2], 1])

Callers 1

visualize_dataFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected