Open3d之彩色点云配准

本教程演示了一种同时使用几何形状和颜色进行配准的ICP变体。它实现了这篇文章的算法 [Park2017] ,实现了颜色信息将沿切线平面锁定对齐。这个算法与之前的ICP配准速度相当,但是实现了更高的精度和鲁棒性。本教程使用的符号来自ICP配准

辅助可视化函数

为了演示彩色点云间配准的对齐,draw_registration_result_original_color使用原本的颜色可视化源点云。

# -*- coding: UTF-8 -*-
import copy
import numpy as np
import open3d as o3d


def draw_registration_result_original_color(source, target, transformation):
    source_temp = copy.deepcopy(source)
    source_temp.transform(transformation)
    o3d.visualization.draw_geometries([source_temp, target],
                                      zoom=0.5,
                                      front=[-0.2458, -0.8088, 0.5342],
                                      lookat=[1.7745, 2.2305, 0.9787],
                                      up=[0.3109, -0.5878, -0.7468])

输入

下面的代码从两个文件中读取源点云和目标点云。使用单位矩阵作为配准的初始化。

print("1. 加载两点云并可可视化它们间的位姿关系")
source = o3d.io.read_point_cloud("../../test_data/ColoredICP/frag_115.ply")
target = o3d.io.read_point_cloud("../../test_data/ColoredICP/frag_116.ply")

# 可视化初始的配准
current_transformation = np.identity(4)
draw_registration_result_original_color(source, target, current_transformation)

点到面的ICP

我们首先运行 Point-to-plane ICP 作为一个基准算法.下面的可视化结果展示了未对齐的绿色三角形纹理.这是因为几何约束不能够防止两个平面的滑动.

# 点到面的ICP
current_transformation = np.identity(4)
print("2. 在原始点云上应用点到平面ICP配准来精准对齐,距离阈值0.02。")

result_icp = o3d.pipelines.registration.registration_icp(source, target, 0.02, current_transformation,
                                                         o3d.pipelines.registration.TransformationEstimationPointToPlane())
print(result_icp)
draw_registration_result_original_color(source, target, result_icp.transformation)

彩色点云配准

彩色点云配准的核心函数是 registration_colored_icp .在[Park2017]这篇论文中,它使用的是具有联合优化目标的ICP迭代(细节请看 Point-to-point ICP):

E(T)=(1-\delta )E_{C}(T)+\delta E_{G}(T)
其中的T是被估计旋转矩阵.E_{C}E_{G}分别是光度学和几何学术语. \delta ∈ [ 0 , 1 ] 是通过经验决定的权重变量.
这里的几何项 E_{G}和 Point-to-plane ICP 的目标是相等的.

其中 K 是当前迭代的对应集,n_{p}是对应点 p 的法线.
颜色项E_{C}​ 测量的是 q 点的颜色(用 C_{q}表示)与其在点p的切平面的投影上的颜色之间的差.

其中的C_{p}是在p的切平面上连续定义的预计算函数. 函数f(.)将3D点投影到切平面.更多细节请参看 [Park2017].
为了进一步提高效率, [Park2017]提供了多尺度的配准方案,这已在以下脚本中实现:

# 彩色点云配准
# 在以下论文中实现
# J. Park, Q.-Y. Zhou, V. Koltun,
# Colored Point Cloud Registration Revisited, ICCV 2017
voxel_radius = [0.04, 0.02, 0.01]
max_iter = [50, 30, 14]
current_transformation = np.identity(4)
print("3. 彩色点云配准")
for scale in range(3):
    iter = max_iter[scale]
    radius = voxel_radius[scale]
    print([iter, radius, scale])

    print("3-1. 下采样的点云的体素大小: %.2f" % radius)
    source_down = source.voxel_down_sample(radius)
    target_down = target.voxel_down_sample(radius)

    print("3-2. 法向量估计.")
    source_down.estimate_normals(o3d.geometry.KDTreeSearchParamHybrid(radius=radius * 2, max_nn=30))
    target_down.estimate_normals(o3d.geometry.KDTreeSearchParamHybrid(radius=radius * 2, max_nn=30))

    print("3-3. 应用彩色点云配准")
    result_icp = o3d.pipelines.registration.registration_colored_icp(
        source_down, target_down, radius, current_transformation,
        o3d.pipelines.registration.TransformationEstimationForColoredICP(),
        o3d.pipelines.registration.ICPConvergenceCriteria(relative_fitness=1e-6,
                                                          relative_rmse=1e-6,
                                                          max_iteration=iter))
    current_transformation = result_icp.transformation
    print(result_icp)
# 可视化
draw_registration_result_original_color(source, target,
                                        result_icp.transformation)

 

 使用 voxel_down_sample 创造了三层多分辨率的点云.使用顶点法线估计来计算的法线.核心的配准函数 registration_colored_icp 在每一层从粗糙到精细都有调用.lambda_geometricregistration_colored_icp 中可选的参数,用于确定 \lambda E_{G}(T)+(1-\lambda) E_{C}​ 中的 δ ∈ [ 0 , 1 ]。
输出的是两组紧密对齐的点云,注意看上面的绿色三角形. 

 

  • 1
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 5
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值