open3D点云分割

发布时间:2023年12月18日

?将底面和物体分割开

import time
import open3d as o3d;
import numpy as np;

mesh_box = o3d.geometry.TriangleMesh.create_box(width=0.4,
                                                height=0.6,
                                                depth=0.11)
mesh_box.compute_vertex_normals()
mesh_box.paint_uniform_color([0.9, 0.1, 0.1])

mesh_tx = mesh_box.translate((0.16, 0.15, 0)) 

mesh_box_Floor = o3d.geometry.TriangleMesh.create_box(width=0.9,
                                                height=0.9,
                                                depth=0.005)
mesh_box_Floor.compute_vertex_normals()
mesh_box_Floor.paint_uniform_color([0.3, 0.3, 0.2])
 
pcdmesh = mesh_tx + mesh_box_Floor 

pcd = pcdmesh.sample_points_uniformly(number_of_points=70000)
o3d.visualization.draw_geometries([pcd], window_name="pcd") 

 
# 点云分割
plane_model, inliers = pcd.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 = pcd.select_by_index(inliers)
inlier_cloud.paint_uniform_color([1.0, 0, 0])

outlier_cloud = pcd.select_by_index(inliers, invert=True)
outlier_cloud.paint_uniform_color([0, 0, 1.0])

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


 

原始图像?

分割出来的底面?

?

分割出来的物体?

?

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