ICP配准和彩色点云配准都被称为局部配准方法,因为它们依赖于粗对准作为初始化。本教程展示了另一类配准方法,称为全局配准。这一系列算法在初始化时不需要对齐。它们通常产生不太紧密的对齐结果,并用作局部方法的初始化。

可视化

此帮助函数将转换后的源点云与目标点云一起可视化:

def draw_registration_result(source, target, transformation):source_temp = copy.deepcopy(source)target_temp = copy.deepcopy(target)source_temp.paint_uniform_color([1, 0.706, 0])target_temp.paint_uniform_color([0, 0.651, 0.929])source_temp.transform(transformation)o3d.visualization.draw_geometries([source_temp, target_temp])

提取几何特征

对点云进行下采样,估计法线,最后计算每个点的FPFH特征。FPFH特征是一个33维向量,描述了一个点的局部几何特性。在33维空间中的最近邻查询可以返回具有相似局部几何结构的点。详细细节请查看 [Rasu2009].

def preprocess_point_cloud(pcd, voxel_size):print(":: 使用大小为为{}的体素下采样点云.".format(voxel_size))pcd_down = pcd.voxel_down_sample(voxel_size)radius_normal = voxel_size * 2print(":: 使用搜索半径为{}估计法线".format(radius_normal))pcd_down.estimate_normals(o3d.geometry.KDTreeSearchParamHybrid(radius=radius_normal, max_nn=30))radius_feature = voxel_size * 5print(":: 使用搜索半径为{}计算FPFH特征".format(radius_feature))pcd_fpfh = o3d.pipelines.registration.compute_fpfh_feature(pcd_down, o3d.geometry.KDTreeSearchParamHybrid(radius=radius_feature, max_nn=100))return pcd_down, pcd_fpfh

输入

下面的代码从两个文件中读取源点云和目标点云。这一对点云使用单位矩阵作为初始矩阵之后是不对齐的.

def prepare_dataset(voxel_size):print(":: 加载点云并转换点云的位姿.")source = o3d.io.read_point_cloud("../../test_data/ICP/cloud_bin_0.pcd")target = o3d.io.read_point_cloud("../../test_data/ICP/cloud_bin_1.pcd")trans_init = np.asarray([[0.0, 0.0, 1.0, 0.0], [1.0, 0.0, 0.0, 0.0],[0.0, 1.0, 0.0, 0.0], [0.0, 0.0, 0.0, 1.0]])source.transform(trans_init)draw_registration_result(source, target, np.identity(4))source_down, source_fpfh = preprocess_point_cloud(source, voxel_size)target_down, target_fpfh = preprocess_point_cloud(target, voxel_size)return source, target, source_down, target_down, source_fpfh, target_fpfh# 相当于使用5cm的体素对点云进行均值操作
voxel_size = 0.05  # means 5cm for this dataset
source, target, source_down, target_down, source_fpfh, target_fpfh = prepare_dataset(voxel_size)

RANSAC

使用RANSAC进行全局配准。在RANSAC迭代中,每次从源点云中选取ransac_n 个随机点.通过在33维FPFH特征空间中查询最近邻,可以检测到它们在目标点云中的对应点。剪枝步骤需要使用快速修剪算法来提早拒绝错误匹配.
Open3D提供以下剪枝算法:

只有通过修剪步骤的匹配才会用于计算变换,并在整个点云上进行验证。核心函数是 registration_ransac_based_on_feature_matching。该函数最重要的超参数是ransaconvergence。它定义了RANSAC迭代的最大次数和验证的最大次数。这两个值越大,那么结果越准确,但同时也要花费更多的时间.
基于[Choi2015]提供的的经验来设置RANSAC的超参数.

def execute_global_registration(source_down, target_down, source_fpfh, target_fpfh, voxel_size):distance_threshold = voxel_size * 1.5print(":: 对下采样的点云进行RANSAC配准.")print("   下采样体素的大小为: %.3f," % voxel_size)print("   使用宽松的距离阈值: %.3f." % distance_threshold)result = o3d.pipelines.registration.registration_ransac_based_on_feature_matching(source_down, target_down, source_fpfh, target_fpfh, True, distance_threshold,o3d.pipelines.registration.TransformationEstimationPointToPoint(False), 3,[o3d.pipelines.registration.CorrespondenceCheckerBasedOnEdgeLength(0.9),o3d.pipelines.registration.CorrespondenceCheckerBasedOnDistance(distance_threshold)], o3d.pipelines.registration.RANSACConvergenceCriteria(100000, 0.999))return resultresult_ransac = execute_global_registration(source_down, target_down, source_fpfh, target_fpfh, voxel_size)
print(result_ransac)
draw_registration_result(source_down, target_down, result_ransac.transformation)

注意:

Open3D为全局配准提供了更快的实现。请参阅快速全局配准。

局部优化

出于性能方面的考虑,全局配准只在大量向下采样的点云上执行。配准的结果不够精细,我们使用 Point-to-plane ICP 去进一步优化配准结果。

def refine_registration(source, target, source_fpfh, target_fpfh, voxel_size):distance_threshold = voxel_size * 0.4print(":: 对原始点云进行点对面ICP配准精细对齐, 这次使用严格的距离阈值: %.3f." % distance_threshold)result = o3d.pipelines.registration.registration_icp(source, target, distance_threshold, result_ransac.transformation,o3d.pipelines.registration.TransformationEstimationPointToPlane())return resultresult_icp = refine_registration(source, target, source_fpfh, target_fpfh, voxel_size)
print(result_icp)
draw_registration_result(source, target, result_icp.transformation)

快速全局配准

由于无数的模型推荐和评估,导致基于RANSAC的全局配准需要很长的时间。[Zhou2016] 提出了一种加速的方法,该方法可快速的优化几乎没有对应关系的线处理权重。由于每次迭代都不涉及模型建议和评估,因此[Zhou 2016]中提出的方法可以节省大量计算时间。
这篇教程比较了基于RANSAC的全局配准和[Zhou2016] 方法的运行时间.

输入

我们使用上面全局配准的输入例子.

voxel_size = 0.05  # 相当于使用5cm的体素对点云进行均值操作
source, target, source_down, target_down, source_fpfh, target_fpfh = prepare_dataset(voxel_size)

基准

在下面代码中,将对全局配准算法计时.

start = time.time()
result_ransac = execute_global_registration(source_down, target_down,source_fpfh, target_fpfh,voxel_size)
print("全局配准花费了: %.3f 秒.\n" % (time.time() - start))
print(result_ransac)
draw_registration_result(source_down, target_down, result_ransac.transformation)

快速全局配准

采用和基准相同的输入,下面的代码调用了论文[Zhou2016]中实现的算法.

def execute_fast_global_registration(source_down, target_down, source_fpfh,target_fpfh, voxel_size):distance_threshold = voxel_size * 0.5print(":: 基于距离阈值为 %.3f的快速全局配准" % distance_threshold)result = o3d.pipelines.registration.registration_fast_based_on_feature_matching(source_down, target_down,source_fpfh, target_fpfh,o3d.pipelines.registration.FastGlobalRegistrationOption(maximum_correspondence_distance=distance_threshold))return resultresult_fast = execute_fast_global_registration(source_down, target_down,source_fpfh, target_fpfh,voxel_size)
print("快速全局配准花费了: %.3f 秒.\n" % (time.time() - start))
print(result_fast)
draw_registration_result(source_down, target_down, result_fast.transformation)

经过适当的配置,快速全局配准的精度甚至可与ICP相媲美.更多实验结果请参阅[Zhou2016].

Open3d之点云全局配准相关推荐

  1. 点云全局配准复现——Super4pcs实现

    点云全局配准复现--Super4pcs实现 代码实现 demo演示 项目地址 复现流程 1.下载源码 2.cmake 3.运行build文件夹下sln文件,生成头文件与lib文件 4. 配置文件 5. ...

  2. Open3d学习计划—高级篇 3(点云全局配准)

    Open3D是一个开源库,支持快速开发和处理3D数据.Open3D在c++和Python中公开了一组精心选择的数据结构和算法.后端是高度优化的,并且是为并行化而设置的. 本系列学习计划有Blue同学作 ...

  3. open3d完成点云ICP配准

    环境:win10,python3.6+open3d==0.8.0 完成点云配准之后的效果图演示 这里直接放上完整的代码 import open3d as o3d import numpy as np# ...

  4. python 点云配准_点云的全局配准

    点云配准就是将当前点云匹配进行变换使其和目标点云匹配上. 先推荐一个python的点云处理库: opend3d. 什么时候需要全局配准?我说我知道的场景相机的角度变化太大了. 极少角度的物体重建. 3 ...

  5. Open3d系列 | 1. Open3d实现点云数据读写、点云配准、点云法向量计算

    如有错误,恳请指出. 从这一篇博客开始,开始利用Open3d来处理点云数据.之后将围绕点云数据的多种处理方式来记录笔记.本篇博客的内容包括点云的文件格式介绍,点云数据的读取,以及点云的配准与点云的法向 ...

  6. 彻底搞懂基于Open3D的点云处理教程!

    背景介绍 点云数据是三维感知的重要手段,具有丰富的几何与结构信息,在自动驾驶.地形测绘.工业测量等领域具有广泛的应用.同时点云数据处理技术也是目前比较火热的研究方向,并且随着深度学习的发展,结合深度学 ...

  7. 点云粗配准算法-4pcs

    4pcs粗配准算法 一,简介 4PCS[1]配准算法使用的是RANSAC算法框架,通过构建与匹配全等四点对(啥意思)的方式来减少空间匹配运算,进而加速配准过程. 4PCS不同于icp和ndt,其是一种 ...

  8. python点云快速配准_分享一个V-SLAM中点云配准算法改进的方法

    近年来,随着自主导航的广泛应用,视觉同时定位与地图构建(Visual simultaneous localization and mapping, V-SLAM)通过自身携带的视觉传感器对周围环境进行 ...

  9. ITK:两个图像的全局配准(BSpline)

    ITK:两个图像的全局配准 内容提要 输出结果 C++实现代码 内容提要 两个图像的全局配准. 输出结果 Intial Parameters = [0, 0, 0, 0, 0, 0, 0, 0, 0, ...

最新文章

  1. 组合计数 ---- Codeforces Round #370 (Div. 2)D. Memory and Scores[dp]
  2. Java创建数组的三种方法
  3. linux端口转发到windows,Linux及Windows基于工具的端口转发
  4. 【转】经济计量学软件包Eviews快速使用
  5. python lua 性能比较 内存_Lua 的速度为什么比 Python 快?
  6. 2018年阿里云NoSQL数据库大事盘点
  7. 阿里云大学python_阿里云大学「学习路线」,一站式从入门到高手——Python、Java、前端、运维、数据库、云原生……...
  8. SpringMvc 系统启动时加载数据到内存中
  9. 物联网通信协议——比较-MQTT、 DDS、 AMQP、XMPP、 JMS、 REST、 CoAP
  10. 年薪 66万+,西澳大学招聘 CV DL Research Fellow(研究员)
  11. bzoj 1797: [Ahoi2009]Mincut 最小割 (网络流)
  12. 音频播放时,将前台服务和通知栏关闭
  13. Gartner:当商业智能成熟度低时,如何加快分析采用率
  14. 红茶三杯的博客-一个IE的博客
  15. 这么有料的福利,你还不赶紧关注一波吗?(代码合集)
  16. html页中加入数学公式,Html+Css+JavaScript实现网页公式编辑器(一)
  17. Magix 促销:让你的音视频制作更加专业
  18. xv6源码解析(一)——系统启动
  19. 2.3 Go语言中的字符型和常量定义
  20. 续订Office365E5订阅

热门文章

  1. 【转载】Delphi获取与设置系统时间格式(长日期与短日期)
  2. 使用zabbix如何自动清理30天前的数据
  3. zabbix监控SNMP
  4. 在DevStack中使用Systemd
  5. 打开excel后,提示更新链接的原因(含批量处理VBA代码)
  6. css属性~(积少成多)
  7. 使用CUDA遇到的坑
  8. 【PL/SQL】用星号拼出金字塔
  9. [Linux] 解决Ubuntu12.10 64位google chrome安装Flash后出现couldn‘t load plug-in的问题;
  10. matlab中提示错误使用* BLAS loading error解决方法