Draw points on visualizer. Args: points (numpy.array | torch.tensor, shape=[N, 3+C]): points to visualize. vis (:obj:`open3d.visualization.Visualizer`): open3d visualizer. points_size (int, optional): the size of points to show on visualizer. Defau
(points,
vis,
points_size=2,
point_color=(0.5, 0.5, 0.5),
mode='xyz')
| 13 | |
| 14 | |
| 15 | def _draw_points(points, |
| 16 | vis, |
| 17 | points_size=2, |
| 18 | point_color=(0.5, 0.5, 0.5), |
| 19 | mode='xyz'): |
| 20 | """Draw points on visualizer. |
| 21 | Args: |
| 22 | points (numpy.array | torch.tensor, shape=[N, 3+C]): |
| 23 | points to visualize. |
| 24 | vis (:obj:`open3d.visualization.Visualizer`): open3d visualizer. |
| 25 | points_size (int, optional): the size of points to show on visualizer. |
| 26 | Default: 2. |
| 27 | point_color (tuple[float], optional): the color of points. |
| 28 | Default: (0.5, 0.5, 0.5). |
| 29 | mode (str, optional): indicate type of the input points, |
| 30 | available mode ['xyz', 'xyzrgb']. Default: 'xyz'. |
| 31 | Returns: |
| 32 | tuple: points, color of each point. |
| 33 | """ |
| 34 | vis.get_render_option().point_size = points_size # set points size |
| 35 | if isinstance(points, torch.Tensor): |
| 36 | points = points.cpu().numpy() |
| 37 | |
| 38 | points = points.copy() |
| 39 | pcd = geometry.PointCloud() |
| 40 | if mode == 'xyz': |
| 41 | pcd.points = o3d.utility.Vector3dVector(points[:, :3]) |
| 42 | points_colors = np.tile(np.array(point_color), (points.shape[0], 1)) |
| 43 | elif mode == 'xyzrgb': |
| 44 | pcd.points = o3d.utility.Vector3dVector(points[:, :3]) |
| 45 | points_colors = points[:, 3:6] |
| 46 | # normalize to [0, 1] for open3d drawing |
| 47 | if not ((points_colors >= 0.0) & (points_colors <= 1.0)).all(): |
| 48 | points_colors /= 255.0 |
| 49 | else: |
| 50 | raise NotImplementedError |
| 51 | |
| 52 | pcd.colors = o3d.utility.Vector3dVector(points_colors) |
| 53 | vis.add_geometry(pcd) |
| 54 | |
| 55 | return pcd, points_colors |
| 56 | |
| 57 | |
| 58 | def _draw_bboxes(bbox3d, |
no outgoing calls
no test coverage detected