MCPcopy Index your code
hub / github.com/InternRobotics/EmbodiedScan / _9dof_to_box

Function _9dof_to_box

embodiedscan/visualization/utils.py:43–76  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

41
42
43def _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
79def nms_filter(pred_results, iou_thr=0.15, score_thr=0.075, topk_per_class=10):

Callers 4

render_sceneMethod · 0.90
show_imageMethod · 0.90
visualize_sceneMethod · 0.90
draw_nextMethod · 0.85

Calls 3

get_colorMethod · 0.80
numpyMethod · 0.45
cpuMethod · 0.45

Tested by

no test coverage detected