关键代码(FPS):
pcd_down = pcd.farthest_point_down_sample(1000) # pcd: CloudPoint
如果是mesh采样(不是FPS):
pcl = mesh.sample_points_poisson_disk(number_of_points=10000) # mesh: TriangleMesh. pcl: PointCloud class
最远距离采样:
Downsample a pointcloud into output pointcloud with a set of points has farthest distance.The sampling is performed by selecting the farthest point from previous selected points iteratively
该算法由PointNet提出:均匀采样,使得这些点可以比较好的表征点云的整体轮廓。
import open3d as o3d
if __name__ == "__main__":
# 1. read pcd
# Load bunny data.
bunny = o3d.data.BunnyMesh()
pcd = o3d.io.read_point_cloud(bunny.path)
pcd.paint_uniform_color([0.5, 0.5, 0.5])
# 2. sample
# Get 1000 samples from original point cloud and paint to green.
pcd_down = pcd.farthest_point_down_sample(1000) # pcd: CloudPoint
# pcl = mesh.sample_points_poisson_disk(number_of_points=10000) # mesh: TriangleMesh. pcl: PointCloud class
# 3. view
pcd_down.paint_uniform_color([0, 1, 0])
o3d.visualization.draw_geometries([pcd, pcd_down])
# o3d.visualization.draw([pcd, pcd_down])