文章目录
- 将点特征 转换为 voxel 特征
将点特征 转换为 voxel 特征
https://github.com/skyhehe123/VoxelNet-pytorch/blob/master/data/kitti.py
【Python】np.unique() 介绍与使用
self.T
: # maxiumum number of points per voxel
def preprocess(self, lidar):
# shuffling the points
np.random.shuffle(lidar)
voxel_coords = ((lidar[:, :3] - np.array([self.xrange[0], self.yrange[0], self.zrange[0]])) / (
self.vw, self.vh, self.vd)).astype(np.int32)
# convert to (D, H, W)
voxel_coords = voxel_coords[:,[2,1,0]]
voxel_coords, inv_ind, voxel_counts = np.unique(voxel_coords, axis=0, \
return_inverse=True, return_counts=True)
voxel_features = []
for i in range(len(voxel_coords)):
voxel = np.zeros((self.T, 7), dtype=np.float32)
pts = lidar[inv_ind == i] # 落到同一个voxel上的 点
if voxel_counts[i] > self.T:
pts = pts[:self.T, :]
voxel_counts[i] = self.T
# augment the points
voxel[:pts.shape[0], :] = np.concatenate((pts, pts[:, :3] - np.mean(pts[:, :3], 0)), axis=1)
voxel_features.append(voxel)
return np.array(voxel_features), voxel_coords
输入,输出解释