主要内容

利用特征估计两点云之间的变换

这个例子展示了如何估计两个点云之间的刚性变换。在本例中,您使用特征提取和匹配来显著减少估计所需的点的数量。在您使用extractFPFHFeatures函数从点云中快速提取点特征直方图(FPFH)特征时,可以使用pcmatchfeatures函数在提取的特征中搜索匹配。最后,使用estgeotform3d函数和匹配特征估计刚体变换。

预处理

通过对输入点云应用刚性转换来创建两个点云。

将点云数据读入工作空间。

rng (“默认”ptCld = pcread(“highwayScene.pcd”);ptCld。数
ans = 65536

对点云进行下采样以提高计算速度,因为它包含大约65,000个点。

ptCloud = pcdownsample (ptCld gridAverage = 0.2);ptCloud。数
ans = 24596

创建一个30度旋转和平移5个单位的刚性变换矩阵x- - -y -轴。

rotAngle = 30;Trans = [5 5 0];tform = [0 0 rotAngle],trans);

转换输入点云。

ptCloudTformed = pctransform (ptCloud tform);

想象两个点云。

pcshowpair (ptCloud ptCloudTformed)轴Xlim ([-50 75]) ylim([-40 80]) legend(“原始”“转换”输入TextColor = [1 1 0]),

图中包含一个axes对象。坐标轴对象包含两个散点类型的对象。这些对象代表原始、变形。

特征提取与注册

方法从两个点云提取特征extractFPFHFeatures函数。

fixedFeature = extractFPFHFeatures (ptCloud);movingFeature = extractFPFHFeatures (ptCloudTformed);

查找匹配特征,并显示匹配对的数量。

[matchingPairs,分数]= pcmatchfeatures (fixedFeature movingFeature,...ptCloud ptCloudTformed方法=“详尽”);长度(matchingPairs)
ans = 1814

从点云中选择匹配点。

fixedPts =选择(ptCloud matchingPairs (: 1));matchingPts =选择(ptCloudTformed matchingPairs (:, 2));

利用匹配点估计变换矩阵。

estimatedTform = estgeotform3d (fixedPts。的位置,...matchingPts。的位置,“刚性”);disp (estimatedTform.A)
0.8660 -0.5000 -0.0003 4.9995 0.5000 0.8660 0.0000 5.0022 0.0002 -0.0002 1.0000 0.0020 000 1.000

显示定义的变换矩阵。

disp (tform.A)
0.8660 -0.5000 0 5.0000 0.5000 0.8660 0 5.0000 00 1.0000 0000 1.0000

使用估计的转换进行重新转换ptCloudTformed回到最初的点云。

ptCloudTformed = pctransform (ptCloudTformed,反(estimatedTform));

想象两个点云。

pcshowpair (ptCloud ptCloudTformed)轴Xlim ([-50 50]) ylim([-40 60]) title(“对齐点云”

图中包含一个axes对象。标题为Aligned Point Clouds的axis对象包含2个散点类型的对象。

Baidu
map