一、引言
安装open 3d
pip3 install open3d-python
Open3D是一个开放源代码库,支持快速开发处理3D数据的软件。
二、open3d库读取ply模型
创建点云图
先画一堆云
import open3d as o3d #导入open3d库
import numpy as np #导入numpy
points = np.random.rand(10000, 3)
point_cloud = o3d.PointCloud()
point_cloud.points = o3d.Vector3dVector(points)
o3d.draw_geometries([point_cloud])
再读取一只兔子
import open3d as o3d
import numpy as np
#读点云数据
pcd = o3d.io.read_point_cloud(r"D:\pythonAds2021\open3d\bunny10k.ply")
print(pcd)
o3d.visualization.draw_geometries([pcd],width=800,height=600)
可任意把玩。
法向量估计
import open3d as o3d
# import open3d_tutorial as o3dtut
import numpy as np
print("Open3D read Point Cloud")
pcd = o3d.io.read_triangle_mesh("thu_statue.ply") #newrabbit.pcd")
print(pcd)
pcd.compute_vertex_normals()
pcdmesh = pcd.sample_points_poisson_disk(3000)
o3d.visualization.draw_geometries([pcdmesh],point_show_normal=True)
radii=[0.005, 0.01, 0.02, 0.04]
ballmesh = o3d.geometry.TriangleMesh.create_from_point_cloud_ball_pivoting(pcdmesh,o3d.utility.DoubleVector(radii))
print(ballmesh)
o3d.visualization.draw_geometries([ballmesh])
o3d.visualization.draw_geometries([pcd, ballmesh])
还能再画个球。