1.numpy 归一化
feature_rot= feature - np.expand_dims(np.mean(feature, axis=0), 0) # 去中心化
dist = np.max(np.sqrt(np.sum(feature_rot ** 2, axis=1)), 0) # 计算到原点的最远距离
# print('dist:{}'.format(dist))
feature_rot = feature_rot / dist # scale 归一化
2.numpy旋转
theta = np.random.uniform(0, np.pi * 2)
rotation_matrix = np.array([[1,0,0,0],[0,np.cos(theta), -np.sin(theta),0], [0,np.sin(theta), np.cos(theta),0],[0,0,0,1]])
# print('rotation_matrix:{}'.format(rotation_matrix))
features = feature_rot
features[:, [0, 2]] = features[:, [0, 2]].dot(rotation_matrix) # random rotation
3.open3d也可以进行,具体参考爆肝5万字❤️Open3D 点云数据处理基础(Python版)_没事就要敲代码的博客-CSDN博客
4.归一化到原点
# 点云归一化,以centroid为中心,半径为1
def pc_normalize(pc):
l = pc.shape[0]
centroid = np.mean(pc, axis=0)
pc = pc - centroid
m = np.max(np.sqrt(np.sum(pc**2, axis=1)))
pc = pc / m
return pc