segmentGroundFromLidarData
Segment ground points from organized lidar data
Syntax
Description
segments organized 3-D lidar data, groundPtsIdx
= segmentGroundFromLidarData(ptCloud
)ptCloud
, into ground and
nonground parts. The lidar sensor must be mounted horizontally such that all ground
points are observed in the lidar scan closest to the sensor.
sets properties using one or more name-value pairs. Enclose each property name in
quotes. For example,
groundPtsIdx
= segmentGroundFromLidarData(ptCloud
,Name,Value
)segmentGroundFromLidarData(ptCloud,'ElevationAngleDelta',5)
Examples
Segment and Plot Organized Lidar Data
Segment ground points and nonground points from an organized lidar point cloud. Create organized point clouds from these segmentations, and display them.
Load an organized lidar, point cloud.
ld = load('drivingLidarPoints.mat');
Segment ground points from the organized lidar point cloud.
groundPtsIdx = segmentGroundFromLidarData(ld.ptCloud);
Create an organized point cloud containing only these ground points by using the select
function. Display this point cloud.
groundPtCloud = select(ld.ptCloud,groundPtsIdx); figure pcshow(groundPtCloud)
Create an organized point cloud containing only the nonground points. Specify a threshold of 0.5 meters.
nonGroundPtCloud = select(ld.ptCloud,~groundPtsIdx,'OutputSize','full'); distThreshold = 0.5; [labels,numClusters] = segmentLidarData(nonGroundPtCloud,distThreshold);
Display the nonground points cloud clusters.
figure
colormap(hsv(numClusters))
pcshow(nonGroundPtCloud.Location,labels)
title('Point Cloud Clusters')
Segment and Plot Ground Plane using PCAP File
Load Velodyne PCAP® to the workspace.
velodyneFileReaderObj = velodyneFileReader('lidarData_ConstructionRoad.pcap','HDL32E');
Create a point cloud player using pcplayer. Define its x-, y-, and z-axes limits, in meters, and label its axes.
xlimits = [-40 40]; ylimits = [-15 15]; zlimits = [-3 3]; player = pcplayer(xlimits,ylimits,zlimits);
Label the pcplayer axes.
xlabel(player.Axes,'X (m)') ylabel(player.Axes,'Y (m)') zlabel(player.Axes,'Z (m)')
Set the colormap for labeling points. Use RGB triplets to specify green for ground-plane points, and red for obstacle points.
colors = [0 1 0; 1 0 0]; greenIdx = 1; redIdx = 2;
Iterate through the first 200 point clouds in the Velodyne PCAP file, using readFrame
to read in the data. Segment the ground points from each point cloud. Color all ground points green and nonground points red. Plot the resulting lidar point cloud.
colormap(player.Axes,colors) title(player.Axes,'Segmented Ground Plane of Lidar Point Cloud'); for i = 1 : 200 % Read current frame. ptCloud = velodyneFileReaderObj.readFrame(i); % Create label array. colorLabels = zeros(size(ptCloud.Location,1),size(ptCloud.Location,2)); % Find the ground points. groundPtsIdx = segmentGroundFromLidarData(ptCloud); % Map color ground points to green. colorLabels(groundPtsIdx (:)) = greenIdx; % Map color nonground points to red. colorLabels(~groundPtsIdx (:)) = redIdx; % Plot the results. view(player,ptCloud.Location,colorLabels) end
Input Arguments
ptCloud
— Point cloud
pointCloud
object
Point cloud, specified as a pointCloud
object.
ptCloud
is an organized point cloud that stores
[x,y,z] point
coordinates in an M-by-N-by-3 matrix.
Name-Value Arguments
Example: 'ElevationAngleDelta',5
ElevationAngleDelta
— Elevation angle difference threshold
5
(default) | nonnegative scalar
Elevation angle difference threshold to identify ground points,
specified as a nonnegative scalar. The function computes the elevation
angle difference between one labeled ground point and its 4-connected
neighbors. The neighborhood point is labeled as ground if the difference
is below the threshold. Typical values for
ElevationAngleDelta
are in the range of [5,15]
degrees. Increase this value to encompass more points from uneven ground
surfaces.
InitialElevationAngle
— Initial elevation angle threshold
30
(default) | non-negative scalar
Initial elevation angle threshold to identify the ground point in the
scanning line closest to the lidar sensor, specified as a non-negative
scalar. The function marks a point as ground when the elevantion angle
falls below this value. Typical values for
InitialElevationAngle
are in the range of 15 and
30 degrees.
Output Arguments
groundPtsIdx
— Ground points index
logical matrix
Ground points index, returned as an
M-by-N logical matrix. Elements
with a true
value, 1
, indicate ground
points. Elements with a false
value,
0
, indicate nonground points.
References
[1] Bogoslavskyi, I. “Efficient Online Segmentation for Sparse 3D Laser Scans.” Journal of Photogrammetry, Remote Sensing and Geoinformation Science. Vol. 85, Number 1, 2017, pp. 41–52.
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
GPU Code Generation
Generate CUDA® code for NVIDIA® GPUs using GPU Coder™.
Because of architectural differences between the CPU and GPU, numerical
verification does not always match. The GPU floating-point units use fused
Floating-Point Multiply-Add (FMAD) instructions while the CPU does not use these
instructions. The CUDA® compiler performs these instruction-level optimizations by default
impacting the accuracy of the computed results. For example, the CUDA compiler fuses floating-point multiply and add instructions into a
single instruction. This Floating-point Multiply-Add (FMAD) operation executes twice
as fast compared to two single instructions but results in the loss of numerical
accuracy. You can achieve tighter control over these optimizations by using compiler
flags. For example, passing --fmad=false
to the
Compiler Flags
property of the code configuration object
instructs the nvcc
compiler to disable contraction of
floating-point multiply and add to a single Floating-Point Multiply-Add (FMAD)
instruction. For more information, see Generate Code by Using the GPU Coder App (GPU Coder) .
Version History
See Also
pointCloud
| pcsegdist
| pcfitplane
| velodyneFileReader
| segmentLidarData
Abrir ejemplo
Tiene una versión modificada de este ejemplo. ¿Desea abrir este ejemplo con sus modificaciones?
Comando de MATLAB
Ha hecho clic en un enlace que corresponde a este comando de MATLAB:
Ejecute el comando introduciéndolo en la ventana de comandos de MATLAB. Los navegadores web no admiten comandos de MATLAB.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)