【PCL】教程correspondence_grouping对点云模型和点云场景进行特征提取,匹配,以及聚类找到模型与场景的匹配...

基于对应分组的 3D 对象识别

本教程旨在解释如何使用 pcl_recognition 模块执行基于对应分组的 3D 对象识别。具体来说,它解释了如何使用对应分组算法将 3D 描述符匹配阶段后的点对点对应集聚合到当前场景中的模型实例中。对于每个聚类,表示场景中的可能模型实例,对应分组算法还输出该模型在当前场景中的 6DOF 姿态估计的变换矩阵。

36e5ea14d8daa595349f2e27755aa775.png

686993e81056d675fc3422b94768521c.png

[done, 727.952 ms : 13704 points]
Available dimensions: x y z rgba

模型点云 milk_color.pcd

5402e7d56c25f95e1d7bcb13a6e9f74a.png

[done, 619.567 ms : 307200 points]
Available dimensions: x y z rgba

场景点云 milk_cartoon_all_small_clorox.pcd

运行测试1

e2ff0598baa696716b1266918a4d0f26.png

命令行参数:milk_color.pcd milk_cartoon_all_small_clorox.pcd

Model total points: 13704; Selected Keypoints: 739
Scene total points: 307200; Selected Keypoints: 3747
[pcl::SHOTEstimation::computeFeature] The local reference frame is not valid! Aborting description of point with index 627
[pcl::SHOTEstimation::computeFeature] The local reference frame is not valid! Aborting description of point with index 1571
[pcl::SHOTEstimation::computeFeature] The local reference frame is not valid! Aborting description of point with index 951
[pcl::SHOTEstimation::createBinDistanceShape] Point 2274 has 1 (2.500000%) NaN normals in its neighbourhood
[pcl::SHOTEstimation::createBinDistanceShape] Point 170 has 1 (4.347826%) NaN normals in its neighbourhood
[pcl::SHOTEstimation::createBinDistanceShape] Point 794 has 1 (4.166667%) NaN normals in its neighbourhood
[pcl::SHOTEstimation::computeFeature] The local reference frame is not valid! Aborting description of point with index 1803
[pcl::SHOTEstimation::computeFeature] The local reference frame is not valid! Aborting description of point with index 1430
[pcl::SHOTEstimation::computeFeature] The local reference frame is not valid! Aborting description of point with index 1856
Correspondences found: 1823
Model instances found: 1


    Instance 1:
        Correspondences belonging to this instance: 37


            |  1.000  0.000  0.000 |
        R = |  0.000  1.000  0.000 |
            |  0.000 -0.000  1.000 |


        t = < -0.000, -0.000, -0.000 >

运行测试2

f9e428855ef6dbe3c965af2a1e5cf64c.png

参数:milk_color.pcd milk_cartoon_all_small_clorox.pcd -k -c

Model total points: 13704; Selected Keypoints: 739
Scene total points: 307200; Selected Keypoints: 3747
[pcl::SHOTEstimation::computeFeature] The local reference frame is not valid! Aborting description of point with index 627
[pcl::SHOTEstimation::computeFeature] The local reference frame is not valid! Aborting description of point with index 1571
[pcl::SHOTEstimation::computeFeature] The local reference frame is not valid! Aborting description of point with index 951
[pcl::SHOTEstimation::createBinDistanceShape] Point 2274 has 1 (2.500000%) NaN normals in its neighbourhood
[pcl::SHOTEstimation::createBinDistanceShape] Point 170 has 1 (4.347826%) NaN normals in its neighbourhood
[pcl::SHOTEstimation::computeFeature] The local reference frame is not valid! Aborting description of point with index 1430
[pcl::SHOTEstimation::createBinDistanceShape] Point 794 has 1 (4.166667%) NaN normals in its neighbourhood
[pcl::SHOTEstimation::computeFeature] The local reference frame is not valid! Aborting description of point with index 1803
[pcl::SHOTEstimation::computeFeature] The local reference frame is not valid! Aborting description of point with index 1856
Correspondences found: 1823
Model instances found: 1


    Instance 1:
        Correspondences belonging to this instance: 37


            |  1.000  0.000  0.000 |
        R = |  0.000  1.000  0.000 |
            |  0.000 -0.000  1.000 |


        t = < -0.000, -0.000, -0.000 >

源码解析

这段代码是使用PCL (Point Cloud Library) 实现的一个点云识别和匹配的程序。它包括了从文件中加载点云,预处理,关键点提取,描述子计算,寻找模型与场景之间的对应关系,以及使用霍夫变换(Hough Transform)或几何一致性算法(Geometric Consistency)进行聚类寻找点云实例。

主要步骤及其对应功能解析如下:

  1. 包含必要的头文件,定义一些别名,例如 PointType, NormalType, RFType (参考框架类型), DescriptorType(描述子类型)等。

  2. 声明一些全局变量,用于存储模型和场景的文件名,算法参数,如采样大小,参考帧半径,描述子半径,聚类大小,聚类阈值等。

  3. showHelp 函数提供使用程序的帮助信息。

  4. parseCommandLine 函数解析命令行参数,并根据这些参数调整程序的行为。

  5. computeCloudResolution 函数计算给定点云的分辨率,这是为了使算法能够处理不同分辨率的点云。

  6. main 函数中实现了程序的主要流程:

  • 解析命令行参数。

  • 加载模型和场景的点云数据。

  • 如果启用了分辨率不变性,就按照模型点云的分辨率调整各种参数值。

  • 通过 pcl::NormalEstimationOMP 为模型和场景点云计算法线。

  • 使用 pcl::UniformSampling 对模型和场景点云进行下采样以提取关键点。

  • 通过 pcl::SHOTEstimationOMP 为关键点计算描述子。

  • 使用 KdTree 找到模型与场景之间的对应关系。

  • 根据选择使用的聚类方法(霍夫变换或几何一致性算法)进行实际的聚类操作。

  • 输出聚类的结果,这包括找到的模型实例数量以及每个实例的具体变换。

  • 最后是可视化,将场景点云、模型点云、关键点、以及匹配对应的线段显示在一个 PCLVisualizer 视图中。

总的来说,这段代码就是对点云模型和点云场景进行特征提取,匹配,以及聚类,找到模型与场景的匹配,并对匹配的部分进行可视化展示。这种类型的点云处理常用于三维模型的识别和定位,在机器人视觉、增强现实等领域有广泛的应用。

// 引入必要的头文件
#include <pcl/io/pcd_io.h> // PCD文件输入输出
#include <pcl/point_cloud.h> // 点云类
#include <pcl/correspondence.h> // 对应关系类
#include <pcl/features/normal_3d_omp.h> // 计算法线的类(带有OMP加速)
#include <pcl/featur
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值