Open3D点云配准介绍-点云之间进行配准

Open3D点云配准介绍-点云之间进行配准

点云之间进行配准

两块点云进行配准

API接口

# API官方介绍:
def registration_icp(source, target, max_correspondence_distance, init, *args, **kwargs): # real signature unknown; NOTE: unreliably restored from __doc__ 
    """
    registration_icp(source, target, max_correspondence_distance, init=(with default value), estimation_method=TransformationEstimationPointToPoint without scaling., criteria=ICPConvergenceCriteria class with relative_fitness=1.000000e-06, relative_rmse=1.000000e-06, and max_iteration=30)
    Function for ICP registration
    
    Args:
        source (open3d.geometry.PointCloud): 原点云.
        target (open3d.geometry.PointCloud): 目标点云.
        max_correspondence_distance (float): 最大通信点对距离.
        init (numpy.ndarray[numpy.float64[4, 4]], optional): 初始估计变换矩阵 
        默认值:    
            array([[1., 0., 0., 0.],
            [0., 1., 0., 0.],
            [0., 0., 1., 0.],
            [0., 0., 0., 1.]])
        estimation_method (open3d.pipelines.registration.TransformationEstimation, optional, default=TransformationEstimationPointToPoint without scaling.):配准计算方法. 
        One of (``TransformationEstimationPointToPoint, TransformationEstimationPointToPlane` TransformationEstimationForGeneralizedICP, TransformationEstimationForColoredICP)
        criteria (open3d.pipelines.registration.ICPConvergenceCriteria, optional, default=ICPConvergenceCriteria class with relative_fitness=1.000000e-06, relative_rmse=1.000000e-06, and max_iteration=30): Convergence criteria
    
    Returns:
        open3d.pipelines.registration.RegistrationResult
    """
    pass
    

案例

# 点对点配准
import copy
import numpy as np
from open3d.cpu.pybind.pipelines import *
from open3d.cpu.pybind import io, geometry, visualization


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')
    # 该参数根据具体点云特征进行适当变更,如果值太小两点云会无法重合!
    max_correspondence_distance = 1000
    # 初始变换矩阵, 如果配准之前知道大概的变换矩阵,传入后可加快点云配准速度和成功率!
    init = np.identity(4)

    # 调用配准接口,得到配准结果
    result_icp: registration.RegistrationResult = registration.registration_icp(
        pcd_source, pcd_target,
        max_correspondence_distance, init,
        registration.TransformationEstimationPointToPoint(),
        registration.ICPConvergenceCriteria(relative_fitness=1e-6,
                                            relative_rmse=1e-8,
                                            max_iteration=10000))

    # 获取变换矩阵
    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

注意事项

最终的配准结果 result_icp 是将 pcd_source 变换到 pcd_target 的变换矩阵!别搞反了,这是新手很容易犯的错误!

相关推荐

  1. Open3D介绍-之间进行

    2024-07-19 16:44:02       22 阅读
  2. 基于SVD的

    2024-07-19 16:44:02       22 阅读
  3. 类相关文献阅读记录

    2024-07-19 16:44:02       28 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-19 16:44:02       67 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-19 16:44:02       72 阅读
  3. 在Django里面运行非项目文件

    2024-07-19 16:44:02       58 阅读
  4. Python语言-面向对象

    2024-07-19 16:44:02       69 阅读

热门阅读

  1. windows关闭双击过后的jar 包

    2024-07-19 16:44:02       21 阅读
  2. windows下flutter国内镜像恢复成外网链接

    2024-07-19 16:44:02       17 阅读
  3. Amazon Bedrock 常用场景及 Python 实现

    2024-07-19 16:44:02       19 阅读
  4. go语言web框架:Echo超详细一文搞透

    2024-07-19 16:44:02       19 阅读
  5. OJ-0718

    2024-07-19 16:44:02       21 阅读
  6. 【Python中的垃圾回收机制是什么】

    2024-07-19 16:44:02       22 阅读
  7. 基于深度学习的人脸表情识别系统

    2024-07-19 16:44:02       22 阅读
  8. Rancher

    Rancher

    2024-07-19 16:44:02      20 阅读
  9. 5、在共享内存无指针编程:句柄HANDLE转换为指针

    2024-07-19 16:44:02       21 阅读
  10. 探索单片机的光耦:定义、作用与应用

    2024-07-19 16:44:02       23 阅读