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

Function write_oriented_bbox_camera_coord

utils/pc_util.py:231–269  ·  view source on GitHub ↗

Export oriented (around Y axis) scene bbox to meshes Args: scene_bbox: (N x 7 numpy array): xyz pos of center and 3 lengths (dx,dy,dz) and heading angle around Y axis. Z forward, X rightward, Y downward. heading angle of positive X is 0, heading angle

(scene_bbox, out_filename)

Source from the content-addressed store, hash-verified

229
230
231def write_oriented_bbox_camera_coord(scene_bbox, out_filename):
232 """Export oriented (around Y axis) scene bbox to meshes
233 Args:
234 scene_bbox: (N x 7 numpy array): xyz pos of center and 3 lengths (dx,dy,dz)
235 and heading angle around Y axis.
236 Z forward, X rightward, Y downward. heading angle of positive X is 0,
237 heading angle of negative Z is 90 degrees.
238 out_filename: (string) filename
239 """
240
241 def heading2rotmat(heading_angle):
242 pass
243 rotmat = np.zeros((3, 3))
244 rotmat[1, 1] = 1
245 cosval = np.cos(heading_angle)
246 sinval = np.sin(heading_angle)
247 rotmat[0, :] = np.array([cosval, 0, sinval])
248 rotmat[2, :] = np.array([-sinval, 0, cosval])
249 return rotmat
250
251 def convert_oriented_box_to_trimesh_fmt(box):
252 ctr = box[:3]
253 lengths = box[3:6]
254 trns = np.eye(4)
255 trns[0:3, 3] = ctr
256 trns[3, 3] = 1.0
257 trns[0:3, 0:3] = heading2rotmat(box[6])
258 box_trimesh_fmt = trimesh.creation.box(lengths, trns)
259 return box_trimesh_fmt
260
261 scene = trimesh.scene.Scene()
262 for box in scene_bbox:
263 scene.add_geometry(convert_oriented_box_to_trimesh_fmt(box))
264
265 mesh_list = trimesh.util.concatenate(scene.dump())
266 # save to ply file
267 trimesh.io.export.export_mesh(mesh_list, out_filename, file_type="ply")
268
269 return
270
271
272def write_lines_as_cylinders(pcl, filename, rad=0.005, res=64):

Callers

nothing calls this directly

Tested by

no test coverage detected