使用open3d分离背景和物体点云(三)

一、代码

Python

import numpy as np
import open3d as o3d
import hdbscan


def hdbscanPlaneSeg(pointcloud):
    points = np.asarray(pointcloud.points)
    clusterer = hdbscan.HDBSCAN(min_cluster_size=15, gen_min_span_tree=True)
    labels = clusterer.fit_predict(points)

    # 获取聚类标签的唯一值
    labels_unique, counts = np.unique(labels, return_counts=True)
    # 忽略噪声点,其标签为-1
    counts = counts[labels_unique != -1]
    label = labels_unique[labels_unique != -1]
    # 找到点数最多的聚类的标签
    max_points_cluster_label = label[counts.argmax()]
    # 提取点数最多的聚类
    most_points_cluster_indices = np.where(labels == max_points_cluster_label)[0]
    plane_pcd = pointcloud.select_by_index(most

猜你喜欢

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