Open3D将点云数据转换为Mesh格式数据

发布时间:2023年12月27日
import open3d as o3d;
import numpy as np;
import matplotlib.pyplot as plt

mesh_coord_frame = o3d.geometry.TriangleMesh.create_coordinate_frame(size=0.225, origin=[0, 0, 0])
mesh_coord_frame = mesh_coord_frame.translate((0.16, 0.15, 0)) 
 
#加载点云数据
ply = o3d.io.read_point_cloud("source/Foam1.ply") 

#去除无效部分
plane_model, inliers = ply.segment_plane(distance_threshold=0.007,
                                         ransac_n=3,
                                         num_iterations=1000)

[a, b, c, d] = plane_model
print(f"Plane equation: {a:.2f}x + {b:.2f}y + {c:.2f}z + {d:.2f} = 0")

inlier_cloud = ply.select_by_index(inliers) 

outlier_cloud = ply.select_by_index(inliers, invert=True) 
o3d.visualization.draw_geometries([ outlier_cloud],window_name="3D有效数据") 

#点云转Mesh格式
outlier_cloud.estimate_normals()
# estimate radius for rolling ball
distances = outlier_cloud.compute_nearest_neighbor_distance()
avg_dist = np.mean(distances)
radius = 1.5 * avg_dist
mesh = o3d.geometry.TriangleMesh.create_from_point_cloud_ball_pivoting(outlier_cloud, o3d.utility.DoubleVector([radius, radius * 2]))

o3d.visualization.draw_geometries([ mesh],window_name="mesh") 

 

 

文章来源:https://blog.csdn.net/easyboot/article/details/135240244
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。