open3d实现点云凸包检测并可视化

open3d实现点云凸包检测并可视化

  • 凸包检测原理
  • code
  • 结果

凸包检测原理

code

from scipy.spatial import Delaunay, ConvexHull
import numpy as np
import open3d as o3d

def Point_Cloud_Show(point1,point2):
    pc_view = o3d.geometry.PointCloud(points=o3d.utility.Vector3dVector(point1))
    key_view = o3d.geometry.PointCloud(points=o3d.utility.Vector3dVector(point2))
    
    vis = o3d.visualization.Visualizer()
    vis.create_window(width=800,height=600)
    opt = vis.get_render_option()
    opt.background_color = np.asarray([128,128,128])  
    # opt.point_size = 5               
    opt.show_coordinate_frame = True    
    key_view.paint_uniform_color([1, 0, 0])  
    pc_view.paint_uniform_color([0, 0, 1])  
    vis.add_geometry(key_view)               
    vis.add_geometry(pc_view) 
    vis.run()                          
    vis.destroy_window()                
    
path = "airplane_0001.txt"
pcd3 = np.genfromtxt(path, delimiter=",")[:,:3]
hull = ConvexHull(pcd3)
idx1 = hull.vertices
set_part1 = set(idx1)
set_all = set([i for i in range(pcd3.shape[0])])
set_part2 = set_all - set_part1
idx2 = list(set_part2)
point1 = pcd3[idx1]
point2 = pcd3[idx2]
Point_Cloud_Show(point1,point2)

结果

open3d实现点云凸包检测并可视化_第1张图片
open3d实现点云凸包检测并可视化_第2张图片

你可能感兴趣的:(点云处理,点云处理,open3d,凸包检测)