MCPcopy Create free account
hub / github.com/OpenMeshLab/MeshXL / write_bbox

Function write_bbox

utils/pc_util.py:145–175  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

143
144
145def 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
178def write_oriented_bbox(scene_bbox, out_filename, colors=None):

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected