Open3D提取点云外轮廓

一、代码

Python

import numpy as np
import open3d as o3d


def compute_curvature(pcd, k=30):
    curvature = []
    kd_tree = o3d.geometry.KDTreeFlann(pcd)
    for i in range(len(pcd.points)):
        _, idx, _ = kd_tree.search_knn_vector_3d(pcd.points[i], k)
        k_neighbors = np.asarray(pcd.points)[idx, :]
        covariance_matrix = np.cov(k_neighbors.T)
        eigenvalues, _ = np.linalg.eigh(covariance_matrix)
        curvature.append(eigenvalues[0] / np.sum(eigenvalues))
    boundary_indices = np.where(curvature > np.percentile(np.array(curvature), 90))[0]
    boundary_points = np.asarray(pcd.points)[boundary_indices]
    boundary_point_cloud = o3d.geometry.PointCloud()
    boundary_point_

猜你喜欢

转载自blog.csdn.net/qq_58060770/article/details/137867915