网址1
cloud=o3d.io.read_point_cloud(args.ipath) # 读取点云
cloud_xyz=np.asarray(cloud.points) # 获取点云坐标数据
num_of_pts=len(cloud_xyz) # 获取点个数
pcd = o3d.geometry.PointCloud()
pcd.points = o3d.utility.Vector3dVector(xyz)
o3d.io.write_point_cloud("../../TestData/sync.ply", pcd)
import open3d as o3d
import numpy as np
pcd = o3d.io.read_point_cloud("chair.pcd")
# 建立KD树
pcd_tree = o3d.geometry.KDTreeFlann(pcd)
# 使用K近邻,将第1500个点最近的100个点设置为蓝色
k = 100 # 设置K的大小
[nn_k, idx_k, _] = pcd_tree.search_knn_vector_3d(pcd.points[1500], k) # 返回邻域点的个数和索引
import open3d
import numpy as np
mesh = open3d.geometry.TriangleMesh()
np_vertices = np.array([[2, 2, 0],
[5, 2, 0],
[5, 5, 0]])
np_triangles = np.array([[0, 1, 2]]).astype(np.int32)
mesh.vertices = open3d.utility.Vector3dVector(np_vertices)
mesh.triangles = open3d.utility.Vector3iVector(np_triangles)
open3d.visualization.draw_geometries([mesh])
import open3d as o3d
import numpy as np
cloud=o3d.io.read_point_cloud("/home/i9/experiment_nc/church.ply")
cloud_xyz=np.asarray(cloud.points)
print("Let's draw a cubic using o3d.geometry.LineSet.")
points = [
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[1, 1, 0],
[0, 0, 1],
[1, 0, 1],
[0, 1, 1],
[1, 1, 1],
]
lines = [
[0, 1],
[0, 2],
[1, 3],
[2, 3],
[4, 5],
[4, 6],
[5, 7],
[6, 7],
[0, 4],
[1, 5],
[2, 6],
[3, 7],
]
colors = [[1, 0, 0] for i in range(len(lines))]
object = o3d.geometry.LineSet(
points=o3d.utility.Vector3dVector(points),
lines=o3d.utility.Vector2iVector(lines),
)
# o3d.geometry
object.colors = o3d.utility.Vector3dVector(colors)
o3d.visualization.draw_geometries([object, cloud])