程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Python point cloud normalize

編輯:Python

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

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved