从点云中提取公路和公路上的点
这个例子展示了如何从点云数据中提取公路上和公路外的点。
道路边界检测是自动驾驶汽车定位和决策的重要组成部分。道路边界通常包括路沿、墙和护堤。
在大多数情况下,道路的边界是由路缘确定的。路缘把道路和人行道连接起来。路沿对安全驾驶很重要,因为它们将可驾驶区域与限制区域区分开。
要提取路缘点,必须首先处理点云数据,以区分道路上和非道路上的点。道路区域包括人行道、路缘和路面。非公路区域通常由树木、建筑物和其他物体组成。根据您的输入数据,您可以使用诸如平面拟合或地面分割等算法提取公路上和公路外的点。
Plane-Fitting方法
预处理点云
将点云数据读入工作空间。
inputPtCloud = pcread(fullfile(toolboxdir))“激光雷达”),“lidardata”,…“sampleWPIPointClouds”,“pointClouds”,“005.纤毛运动”));
从点云中提取一个包含道路区域的感兴趣区域。
xLim = [0 25];yLim = [-10 10];roiIdx = findPointsInROI(inputPtCloud,[xLim yLim inputPtCloud. zlimits]);ptCloud = select(inputPtCloud,roiIdx,OutputSize=“全部”);
将点云划分为网格。
gridSize = [1 1];米%ptCloud = pointCloud(重塑(ptCloud. location (:,:,:),[],3));numGridsX = round(diff(ptCloud.XLimits)/gridSize(1));numGridsY = round(diff(ptCloud.YLimits)/gridSize(2));
从每个网格中提取点索引。
indexes = pcbin(ptCloud,[numGridsX numGridsY 1]);
提取越野点
指定越野高度阈值。
offRoadHeightThreshold = 1.5;米%
从网格中提取出越野点的指标。
offRoadPointsIdx = false(size(ptCloud.Location,1),1);为i = 1: numGridsX * numGridsY如果~isempty(indexes {i}) gridHeight = ptCloud.Location(indexes {i},3);如果(max(gridHeight) - min(gridHeight)) > offRoadHeightThreshold offRoadPointsIdx(indices{i}) = true;结束结束结束
提取越野点云。
offRoadPtCloud = select(inputPtCloud,offRoadPointsIdx);
提取道路积分
方法从点云中的剩余点中提取道路上的点pcfitplane
函数。或者,您也可以使用segmentGroundFromLidarData
函数。
remainingPtCloud = select(inputPtCloud,~offRoadPointsIdx,OutputSize=“全部”);[~,inlierIdx,~] = pcfitplane(remainingPtCloud,1,[0 0 1]);onRoadPtCloud = select(remainingPtCloud,inlierIdx,OutputSize=“全部”);
显示道路上和非道路点。
pcshowpair (offRoadPtCloud onRoadPtCloud)
地面分割法
预处理点云
将点云数据读入工作空间。
ptCloud = pcread(“HDL64LidarData.pcd”);
组织点云。
ptCloud = pcororganize (ptCloud,lidarParameters)“HDL64E”, 1024));
从点云中提取一个包含道路区域的感兴趣区域。
roi = [-25 25 -10 24 ptCloud.ZLimits];index = findPointsInROI(ptCloud,roi);ptCloud = select(ptCloud, indexes,OutputSize=“全部”);
提取道路上和非道路点
方法从点云中分割道路上和越野上的点segmentGroundSMRF
函数。或者,您也可以使用segmentGroundFromLidarData
函数。
[~,offRoadPtCloud,onRoadPtCloud] = segmentGroundSMRF(ptCloud);
显示道路上和非道路点。
pcshowpair (offRoadPtCloud onRoadPtCloud)
探测道路边界
提取道路上和越野点之后,您可以使用detectRoadAngles
功能,识别道路方向。然后,使用segmentCurbPoints
函数从道路上的点云中提取路缘点。