在点云中匹配并可视化相应的特征
方法来匹配点云之间的对应特征pcmatchfeatures
函数并将其可视化pcshowMatchedFeatures
函数。
创建一个velodyneFileReader
对象。
veloReader = velodyneFileReader (“lidarData_ConstructionRoad.pcap”,“HDL32E”);
读两点云从velodyneFileReader
对象。readFrame
方法。
frameNumber = 1;skipFrame = 5;固定= readFrame (veloReader frameNumber);移动= readFrame (veloReader frameNumber + skipFrame);
从固定点云和移动点云中分割并去除地平面。
groundPtsIdxFixed = segmentGroundSMRF(固定);groundPtsIdxMoving = segmentGroundSMRF(移动);~ groundPtsIdxFixed fixedSeg =选择(固定,“OutputSize”,“全部”);~ groundPtsIdxMoving movingSeg =选择(移动,“OutputSize”,“全部”);图pcshowpair(movingSeg,fixedSeg) ylim([-50 60]) title(输入点云的)
叠加的输入点云用颜色编码:
品红色的- - - - - -移动的点云
绿色- - - - - -固定的点云
对点云进行下采样以减少计算时间。下采样减少了要处理的点的数量。
fixedDownsampled = pcdownsample (fixedSeg,“gridAverage”, 0.2);movingDownsampled = pcdownsample (movingSeg,“gridAverage”, 0.2);
方法从点云提取特征extractFPFHFeatures
函数。函数返回两个点云中的有效索引。选择有效点并创建新的参考点云。
[fixedFeature, fixedValidInds] = extractFPFHFeatures (fixedDownsampled);[movingFeature, movingValidInds] = extractFPFHFeatures (movingDownsampled);fixedValidPts =选择(fixedDownsampled fixedValidInds);movingValidPts =选择(movingDownsampled movingValidInds);
利用提取的特征与参考点云进行特征匹配。
indexPairs = pcmatchfeatures (movingFeature fixedFeature movingValidPts,...fixedValidPts);
如果没有相应的点云数据,可以单独使用这两个特征集。的pcmatchfeatures
函数利用点云数据估计与潜在特征匹配相关的点之间的空间关系,并基于空间关系阈值拒绝匹配。
只创建每个点云中的点的点云,并与另一个点云中的特征相匹配。
matchedFixedPts =选择(fixedValidPts indexPairs (:, 2));matchedMovingPts =选择(movingValidPts indexPairs (: 1));
可视化匹配。
图pcshowMatchedFeatures (movingSeg fixedSeg、matchedMovingPts matchedFixedPts,...“方法”,“蒙太奇”) xlim([-40 210]) ylim([-50 50]) title(“匹配点”)
匹配的特征和点云是彩色编码的,以提高可视化:
品红色的- - - - - -移动的点云
绿色- - - - - -固定的点云
红色圆圈- - - - - -移动点云中的匹配点
蓝色星号- - - - - -定点云中的匹配点
黄色的- - - - - -连接匹配特征的线