前言
欧式聚类因重复计算导致效率较低,快速欧式聚类有效提高效率。
参考论文:Cao Y, Wang Y, Xue Y, et al. FEC: Fast Euclidean Clustering for Point Cloud Segmentation[J]. Drones, 2022, 6(11): 325.
快速欧式聚类
import time
import numpy
import open3d as o3d
import numpy as np
import matplotlib.pyplot as plt
import warnings
warnings.simplefilter(action='ignore', category=FutureWarning)
class PointIndex_NumberTag(object):
def __init__(self):
self.nPointIndex = 0.0
self.nNumberTag = 0.0
class Struct(object):
def __init__(self, nPointIndex, nNumberTag):
self.nPointIndex = nPointIndex
self.nNumberTag = nNumberTag
def main():
# 通过pcl.load加载pcd文件
min_component_size = 100
tolorance = 0.5
max_n = 50
start = time.perf_counter()
cloud = o3d.io.read_point_cloud("../data/street.ply")
cloud_tree = o3d.geometry.KDTreeFlann(cloud)
point = numpy.asarray(cloud.points)
size = len(point)
marked_indices = [0] * size
if size < min_component_size:
raise("Could not find any cluster")
else