Convert 9-DoF box from array/tensor to open3d.OrientedBoundingBox. Args: box (numpy.ndarray|torch.Tensor|List[float]): 9-DoF box with shape (9,). label (int, optional): Label of the box. Defaults to None. color_selector (:obj:`ColorSelector`, optional):
(box, label=None, color_selector=None, color=None)
| 41 | |
| 42 | |
| 43 | def _9dof_to_box(box, label=None, color_selector=None, color=None): |
| 44 | """Convert 9-DoF box from array/tensor to open3d.OrientedBoundingBox. |
| 45 | |
| 46 | Args: |
| 47 | box (numpy.ndarray|torch.Tensor|List[float]): |
| 48 | 9-DoF box with shape (9,). |
| 49 | label (int, optional): Label of the box. Defaults to None. |
| 50 | color_selector (:obj:`ColorSelector`, optional): |
| 51 | Color selector for boxes. Defaults to None. |
| 52 | color (tuple[int], optional): Color of the box. |
| 53 | You can directly specify the color. |
| 54 | If you do, the color_selector and label will be ignored. |
| 55 | Defaults to None. |
| 56 | """ |
| 57 | if isinstance(box, list): |
| 58 | box = np.array(box) |
| 59 | if isinstance(box, Tensor): |
| 60 | box = box.cpu().numpy() |
| 61 | center = box[:3].reshape(3, 1) |
| 62 | scale = box[3:6].reshape(3, 1) |
| 63 | rot = box[6:].reshape(3, 1) |
| 64 | rot_mat = o3d.geometry.OrientedBoundingBox.get_rotation_matrix_from_zxy( |
| 65 | rot) |
| 66 | geo = o3d.geometry.OrientedBoundingBox(center, rot_mat, scale) |
| 67 | |
| 68 | if color is not None: |
| 69 | geo.color = [x / 255.0 for x in color] |
| 70 | return geo |
| 71 | |
| 72 | if label is not None and color_selector is not None: |
| 73 | color = color_selector.get_color(label) |
| 74 | color = [x / 255.0 for x in color] |
| 75 | geo.color = color |
| 76 | return geo |
| 77 | |
| 78 | |
| 79 | def nms_filter(pred_results, iou_thr=0.15, score_thr=0.075, topk_per_class=10): |
no test coverage detected