Steps of point cloud normalization ( reference pointnet++ Normalization of , I forgot the source code ...):
1. Place the center of the point cloud at the origin (0, 0, 0)
2. according to xyz The longest axis in the axis is scaled to [-1, 1]
Be careful : At this point, the The range of values is [-1, 1]
import numpy as np
def normalize_point_cloud(pc):
centroid = np.mean(pc, axis=0) # Find the center of the point cloud
pc = pc - centroid # Place the center of the point cloud at the origin (0, 0, 0)
m = np.max(np.sqrt(np.sum(pc ** 2, axis=1))) # Find the length of the major axis
pc_normalized = pc / m # Normalize the point cloud to (-1, 1)
return pc_normalized, centroid, m # centroid: Point cloud Center , m: Long axis length , centroid and m Can be used for keypoints The calculation of
if __name__ == '__main__':
pc = np.random.rand(2000, 3)
pc_normalized, centroid, m = normalize_point_cloud(pc)
keypoints = np.random.rand(2, 3)
keypoints_normalized = (keypoints - centroid) / m