读写操作
1 点云(Point Cloud)
# 读取数据
pcd = o3d.io.read_point_cloud('bun.ply')
# 输出点云个数
print(pcd)
# 输出点云数据
print(np.asarray(pcd.points))
# 保存数据
o3d.io.write_point_cloud('copy.ply', pcd)
>>>>PointCloud with 40256 points.
>>>>[[-0.06325 0.0359793 0.0420873]
>>>> [-0.06275 0.0360343 0.0425949]
>>>> [-0.0645 0.0365101 0.0404362]
>>>> ...
>>>> [-0.01575 0.187201 -0.0220209]
>>>> [-0.01525 0.187218 -0.0237782]
>>>> [-0.018 0.18794 -0.0197253]]
2 网格(Mesh)
mesh = 03d.io.read_triangle_mesh("mesh.ply")
print(mesh)
o3d.io.write_triangle_mesh("copy.ply",mesh)
>>>>TriangleMesh with 1440 points and 2880 triangles.
3 图像(Image)
img = o3d.io.read_image("img.jpg")
print(img)
o3d.io.write_image("copy.jpg", img)
>>>>Image of size 512x512, with 3 channels.
显示数据
o3d.visualization.draw_geometries([pcd], width=800, height=800)