基于Open3D的点云处理10-三维质心

三维点云的重心即所有点xyz坐标值的平均值;
P c = 1 n ∑ ( x i , y i , z i ) P_c = \frac{1}{n}\sum(x_i, y_i, z_i) Pc=n1(xi,yi,zi)

open3d中提供了get_center()计算三维质心;

测试用例:

import open3d as o3d
import numpy as np
if __name__ == '__main__':
    pcd = o3d.io.read_point_cloud("./data/bunny.ply")
    # 使用Numpy计算质心
    points = np.array(pcd.points)
    center = np.mean(points, axis=0)
    print(center)
    del center
    
    #直接调用open3d的属性函数计算质心
    center=pcd.get_center()
    print(center)

    # 去重心化操作,将点云平移到原点
    for i,point in enumerate(pcd.points) :
        pcd.points[i]=point-center
    print(pcd.get_center())

你可能感兴趣的:(三维数据处理,Open3d)