Export scene bbox to meshes Args: scene_bbox: (N x 6 numpy array): xyz pos of center and 3 lengths out_filename: (string) filename Note: To visualize the boxes in MeshLab. 1. Select the objects (the boxes) 2. Filters -> Polygon and Quad Mesh -> Turn i
(scene_bbox, out_filename)
| 143 | |
| 144 | |
| 145 | def write_bbox(scene_bbox, out_filename): |
| 146 | """Export scene bbox to meshes |
| 147 | Args: |
| 148 | scene_bbox: (N x 6 numpy array): xyz pos of center and 3 lengths |
| 149 | out_filename: (string) filename |
| 150 | |
| 151 | Note: |
| 152 | To visualize the boxes in MeshLab. |
| 153 | 1. Select the objects (the boxes) |
| 154 | 2. Filters -> Polygon and Quad Mesh -> Turn into Quad-Dominant Mesh |
| 155 | 3. Select Wireframe view. |
| 156 | """ |
| 157 | |
| 158 | def convert_box_to_trimesh_fmt(box): |
| 159 | ctr = box[:3] |
| 160 | lengths = box[3:] |
| 161 | trns = np.eye(4) |
| 162 | trns[0:3, 3] = ctr |
| 163 | trns[3, 3] = 1.0 |
| 164 | box_trimesh_fmt = trimesh.creation.box(lengths, trns) |
| 165 | return box_trimesh_fmt |
| 166 | |
| 167 | scene = trimesh.scene.Scene() |
| 168 | for box in scene_bbox: |
| 169 | scene.add_geometry(convert_box_to_trimesh_fmt(box)) |
| 170 | |
| 171 | mesh_list = trimesh.util.concatenate(scene.dump()) |
| 172 | # save to ply file |
| 173 | trimesh.io.export.export_mesh(mesh_list, out_filename, file_type="ply") |
| 174 | |
| 175 | return |
| 176 | |
| 177 | |
| 178 | def write_oriented_bbox(scene_bbox, out_filename, colors=None): |
nothing calls this directly
no test coverage detected