Open3D点云配准介绍-点对点配准

点对点配准

两个点云中对应的要进行点对点配准的顶点进行严格的点对点配准。

API接口

def registration_ransac_based_on_correspondence(source, target, corres, max_correspondence_distance, estimation_method=None, *args, **kwargs): # real signature unknown; NOTE: unreliably restored from __doc__ 
    """
    registration_ransac_based_on_correspondence(source, target, corres, max_correspondence_distance, estimation_method=TransformationEstimationPointToPoint without scaling., ransac_n=3, checkers=[], criteria=RANSACConvergenceCriteria class with max_iteration=100000, and confidence=9.990000e-01)
    Function for global RANSAC registration based on a set of correspondences
    
    Args:
        source (open3d.geometry.PointCloud): 源点云.
        target (open3d.geometry.PointCloud): 目标点云.
        corres (open3d.utility.Vector2iVector): o3d.utility.Vector2iVector 特征点索引对.
        max_correspondence_distance (float): 最大点对响应距离.
        estimation_method (open3d.pipelines.registration.TransformationEstimation, optional, default=TransformationEstimationPointToPoint without scaling.): 评估方法. One of (``TransformationEstimationPointToPoint``, ``TransformationEstimationPointToPlane``, ``TransformationEstimationForGeneralizedICP``, ``TransformationEstimationForColoredICP``)
        ransac_n (int, optional, default=3): Fit ransac with ``ransac_n`` correspondences
        checkers (List[open3d.pipelines.registration.CorrespondenceChecker], optional, default=[]): Vector of Checker class to check if two point clouds can be aligned. One of (``CorrespondenceCheckerBasedOnEdgeLength``, ``CorrespondenceCheckerBasedOnDistance``, ``CorrespondenceCheckerBasedOnNormal``)
        criteria (open3d.pipelines.registration.RANSACConvergenceCriteria, optional, default=RANSACConvergenceCriteria class with max_iteration=100000, and confidence=9.990000e-01): Convergence criteria
    
    Returns:
        open3d.pipelines.registration.RegistrationResult
    """
    pass

案例

import copy
from open3d.cpu.pybind.pipelines import *
from open3d.cpu.pybind import io, geometry, visualization, utility


def draw_registration_result_original_color(source, target, transformation, show_coord=False, coord_length=200):
    """
    :param source:
    :param target:
    :param transformation:
    :param show_coord: 是否显示坐标轴网格
    """
    source_temp = copy.deepcopy(source)
    source_temp.transform(transformation)

    geomes = [source_temp, target]

    if show_coord:
        # 坐标系网格
        mesh = geometry.TriangleMesh().create_coordinate_frame(size=coord_length)
        geomes.append(mesh)

    visualization.draw_geometries(geomes,
                                  point_show_normal=False,
                                  mesh_show_wireframe=True)
    pass


if __name__ == '__main__':
    # 原点云,要被进行矩阵变换的点云
    pcd_source = io.read_point_cloud(f'./pcd_source.ply')
    # 目标点云,希望变换到该点云位置的点云
    pcd_target = io.read_point_cloud(f'./pcd_target.ply')
    # 要进行点对点配准的 顶点索引对, 最少3个索引对(一定概率失败),建议4个索引对及以上!
    corres = [[0, 0], [1, 1], [2, 2], [7, 23]]
    corres = utility.Vector2iVector(corres)  # 进行格式转换
    # 该参数根据具体点云特征进行适当变更,如果值太小两点云会无法重合!
    max_correspondence_distance = 10

    # 调用点对点配准接口
    result_icp = registration.registration_ransac_based_on_correspondence(
        pcd_source, pcd_target,
        corres, max_correspondence_distance)

    # 获取变换矩阵
    transformation = result_icp.transformation
    print(result_icp)

    # 给点云上色
    pcd_source.paint_uniform_color([1, 0.706, 0])  # source 为黄色
    pcd_target.paint_uniform_color([0, 0.651, 0.929])  # target 为蓝色
    draw_registration_result_original_color(pcd_source, pcd_target, transformation)
    pass

注释

案例中是分别将 源点云的 第 0,1,2,7个点和目标点云的第 0,1,2,23 个点进行点对点配准!

Open3D是一个强大的开源库,用于处理和可视化3D数据。在Open3D中,点云配准是一项重要的任务,可以将多个点云数据对齐,以便进行后续的处理和分析。 要进行点云配准,您可以使用Open3D配准模块,它提供了多种配准算法和工具。配准的目标是找到最佳的变换,将两个或多个点云对齐,使它们在空间中尽可能重合。 在Open3D中,可以使用ICP(最近点迭代法)算法进行点云配准。ICP算法通过迭代的方式,将目标点云的每个点与参考点云中最近的点进行匹配,并计算出最佳的刚性变换参数,以最小化点云之间的距离。 以下是使用Open3D进行点云配准的基本步骤: 1. 读取点云数据:可以使用Open3D的函数来读取点云数据,可以是PCD、PLY、TXT或BIN格式的文件。 2. 进行配准:使用Open3D的ICP算法或其他配准算法来对点云进行配准。您可以选择不同的参数和策略来获得最佳的配准结果。 3. 可视化结果:使用Open3D的可视化工具,可以将配准后的点云数据进行可视化,以便进行进一步的分析和处理。 下面是一个示例代码,展示了如何使用Open3D进行点云配准: ```python import open3d as o3d # 读取目标点云和参考点云 target_pcd = o3d.io.read_point_cloud("target.pcd") source_pcd = o3d.io.read_point_cloud("source.pcd") # 进行点云配准 transformation = o3d.registration.registration_icp( target_pcd, source_pcd, max_correspondence_distance, estimation_method=o3d.registration.TransformationEstimationPointToPoint()) # 将参考点云根据配准结果进行变换 transformed_source_pcd = source_pcd.transform(transformation.transformation) # 可视化配准结果 o3d.visualization.draw_geometries([target_pcd, transformed_source_pcd]) ``` 请注意,上述代码仅提供了一个简单的示例,实际应用中可能需要根据具体情况进行参数调整和优化。 综上所述,Open3D可以通过使用ICP算法来实现点云配准,并提供了方便的函数和工具来读取、处理和可视化点云数据。123 #### 引用[.reference_title] - *1* *2* *3* [Open3d系列 | 1. Open3d实现点云数据读写、点云配准、点云法向量计算](https://blog.csdn.net/weixin_44751294/article/details/127631360)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}} ] [.reference_item] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

码农菌

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值