如何在Matlab中找到ICP变换中的相似对应点?

drnojrws  于 8个月前  发布在  Matlab
关注(0)|答案(1)|浏览(70)

我有两组点云,并在Matlab中使用此代码读取它们:

ptCloud1 = pcread('sub2a.ply');
ptCloud2 = pcread('sub2b.ply');

然后用icp(迭代最近点)算法将第二个与第一个注册,如下所示:

[tform,movingReg,rmse] = pcregrigid(ptCloud2,ptCloud1)

答案就在“movingreg”里。现在的问题是,我如何知道'movingReg'的点云中的哪个点是'ptCloud 1'的点云中的对应相似点?

bwleehnv

bwleehnv1#

我不知道matlab的ICP的具体实现。但最简单的情况是创建一个从目标到源的KDTree,然后对每个点进行查询。我将给予一个Python的通用代码,我希望你也能在Matlab中使用它。
使用scipy,

from scipy.spatial import KDTree

def find_correspondences(source_points, target_points):
    tree = KDTree(target_points)
    correspondences_index = []

    for point in source_points:
        _, idx = tree.query(point)
        target_point_index = idx
        correspondences_index.append(target_point_index)

    return correspondences_index

现在,correspondences_index列表保存每个点之间的Map。基本上,correspondences_index[0]将给予源中第一个点的对应点。然后,您可以为相应的目标和源点添加相同的颜色以可视化它们。

相关问题