Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] fix bbox_color in Det3DLocalVisualizer #2729

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions mmdet3d/visualization/local_visualizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,8 @@ def set_points(self,
# for better detection performance comparison
def draw_bboxes_3d(self,
bboxes_3d: BaseInstance3DBoxes,
bbox_color: Tuple[float] = (0, 1, 0),
bbox_colors: Union[Tuple[float],
List[Tuple[float]]] = (0, 1, 0),
points_in_box_color: Tuple[float] = (1, 0, 0),
rot_axis: int = 2,
center_mode: str = 'lidar_bottom',
Expand All @@ -272,7 +273,8 @@ def draw_bboxes_3d(self,
Args:
bboxes_3d (:obj:`BaseInstance3DBoxes`): 3D bbox
(x, y, z, x_size, y_size, z_size, yaw) to visualize.
bbox_color (Tuple[float]): The color of 3D bboxes.
bbox_colors (Tuple[float] | List[Tuple[float]]):
The color of 3D bboxes.
Defaults to (0, 1, 0).
points_in_box_color (Tuple[float]): The color of points inside 3D
bboxes. Defaults to (1, 0, 0).
Expand All @@ -294,8 +296,16 @@ def draw_bboxes_3d(self,
bboxes_3d = tensor2ndarray(bboxes_3d.tensor)

# in_box_color = np.array(points_in_box_color)
if isinstance(bbox_colors, list):
assert len(bbox_colors) == len(
bboxes_3d), 'specify color for every bounding box'

for i in range(len(bboxes_3d)):
if isinstance(bbox_colors, tuple):
bbox_color = bbox_colors
else:
bbox_color = bbox_colors[i]

center = bboxes_3d[i, 0:3]
dim = bboxes_3d[i, 3:6]
yaw = np.zeros(3)
Expand All @@ -312,15 +322,17 @@ def draw_bboxes_3d(self,

line_set = geometry.LineSet.create_from_oriented_bounding_box(
box3d)
line_set.paint_uniform_color(np.array(bbox_color[i]) / 255.)
line_set.paint_uniform_color(
np.array(bbox_color, dtype=np.float64))
# draw bboxes on visualizer
self.o3d_vis.add_geometry(line_set)

# change the color of points which are in box
if self.pcd is not None and mode == 'xyz':
indices = box3d.get_point_indices_within_bounding_box(
self.pcd.points)
self.points_colors[indices] = np.array(bbox_color[i]) / 255.
self.points_colors[indices] = np.array(
bbox_color, dtype=np.float64)

# update points colors
if self.pcd is not None:
Expand Down
Loading