Detect road angles in point cloud
Segment Curb Points from Point Cloud
Read point cloud data from a PCD file by using the
ptCloud = pcread("HDL64LidarData.pcd");
Organize the point cloud data by using the
ptCloud = pcorganize(ptCloud,lidarParameters("HDL64E",1024));
Extract a region of interest, which contains a road, from the point cloud data.
roi = [-25 25 -10 24 ptCloud.ZLimits]; indices = findPointsInROI(ptCloud,roi); ptCloud = select(ptCloud,indices,OutputSize="full");
Segment the on-road and off-road points from the point cloud by using the
[~,offRoadPtCloud,onRoadPtCloud] = segmentGroundSMRF(ptCloud);
Detect road angles from the off-road points.
roadAngles = detectRoadAngles(offRoadPtCloud,MinSectorSize=10,SectorMergeThreshold=30);
Segment curb points from the on-road points of the point cloud.
[~,curbPtCloud] = segmentCurbPoints(onRoadPtCloud,roadAngles,NumScanNeighbors=10, ... HeightLimits=[0.001 0.5],HeightDeviationLimits=[0.001 0.5], ... SmoothnessThreshold=0.0001,HorizontalAngularResolution=0.33);
Visualize the segmented curb points.
figure pcshow(ptCloud.Location,"w") hold on; pcshow(curbPtCloud.Location,"r",MarkerSize=200) hold off view(2) title("Curb points")
offRoadPointCloud — Point cloud with off-road points
Point cloud with off-road points, specified as a
pointCloud object. Off-road points usually consist of trees, buildings, and
other objects. You can apply ground segmentation or plane-fitting algorithms to your
point cloud data to extract off-road points. For more details, see Extract On-Road and Off-Road Points from Point Cloud.
Specify optional pairs of arguments as
the argument name and
Value is the corresponding value.
Name-value arguments must appear after other arguments, but the order of the
pairs does not matter.
specifies the minimum sector size required to detect a road segment as 10 degrees.
MinSectorSize — Minimum sector size to detect road segment
5 (default) | scalar in the range [
Minimum sector size to detect a road segment, specified as a scalar in the range
360, in degrees. The function does not
detect any sector smaller than this value as a road segment. Increasing this value can
improve the accuracy of the road angle detection.
must be in the range
SectorMergeThreshold — Minimum merge angle between two sectors
15 (default) | scalar in the range [
Minimum merge angle between two sectors, specified as a scalar in the range
360, in degrees. The function merges two
sectors when the angle between them is lower than the
SectorMergeThreshold value. Increasing this value can improve
the accuracy of the road angle detection.
must be in the range
roadAngles — Road segmentation angles
Road segmentation angles, returned as an M-element vector. M is the number of directions in which the egovehicle can travel, depending on the road type. The values are in degrees, with respect to the lidar sensor coordinate system.
|Road Type||M Value|
|Straight or curved road||2|
|T-shaped or Y-shaped road||3|
The function uses a beam model, followed by a toe-finding algorithm, on the off-road points to detect the road angles.
The beam model follows these steps.
Launch a sequence of beams from the lidar sensor mounted on the ego vehicle. The lidar sensor is the launching point.
Divide the beams into beam zones according to the angular resolution of the sensor.
Determine the beam angles and beam lengths with respect to the launching point.
For each beam zone, determine the distance between the point closest to the launching point and the point farthest from the launching point. Compute the normalized beam length as the ratio of the shortest distance to the longest distance.
The toe-finding algorithm follows these steps.
Introduced in R2022b