def get_bbox(pc, pose=None): ''' get the bounding box for the point cloud if a pose is provided then it will find the bbox for the data aligned to that pose return: bbox array |xmin, xmax| |ymin, ymax| |zmin, zmax| ''' pts = ru.to_array(pc) if pose != None: ps = ru.to_PoseStamped(pose) ps_wrtPC = ru.transformPose(ru.get_frame_id(pc), ps) T = tr.rospose2tr(ps_wrtPC.pose) pts = np.dot(np.linalg.inv(T), np.vstack( (pts.T, np.ones(pts.shape[0])))).T pmin = np.min(pts[:, :3], axis=0) pmax = np.max(pts[:, :3], axis=0) bbox = np.array([pmin, pmax]).T return bbox
def get_bbox(pc, pose=None): ''' get the bounding box for the point cloud if a pose is provided then it will find the bbox for the data aligned to that pose return: bbox array |xmin, xmax| |ymin, ymax| |zmin, zmax| ''' pts = ru.to_array(pc); if pose != None: ps = ru.to_PoseStamped(pose); ps_wrtPC = ru.transformPose(ru.get_frame_id(pc), ps); T = tr.rospose2tr(ps_wrtPC.pose); pts = np.dot(np.linalg.inv(T), np.vstack((pts.T, np.ones(pts.shape[0])))).T; pmin = np.min(pts[:,:3], axis=0); pmax = np.max(pts[:,:3], axis=0); bbox = np.array([pmin, pmax]).T; return bbox;