File size: 537 Bytes
663494c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
import copy
import numpy as np
from scipy.spatial import Delaunay
def extract_pc_in_box3d(pc: np.ndarray, box3d: np.ndarray):
"""Extract the subsets of points within the requested bounding box
Args:
pc: N x 3 (or more),
box3d: 8 x 3 (or 4)
"""
hull = copy.copy(box3d[:, :3])
if not isinstance(hull, Delaunay):
hull = Delaunay(hull)
box3d_roi_inds: np.ndarray = (
hull.find_simplex(pc[:, :3]) >= 0
) # (N, ) boolean array
return pc[box3d_roi_inds, :], box3d_roi_inds
|