Extract scan context descriptor from point cloud
A scan context descriptor is a 2-D global feature descriptor of a point cloud that can be used to detect loop closures. The function computes the descriptor by first binning points from a 3-D point cloud scan into concentric radial and azimuthal bins, and then selecting the maximum z-height of points in each bin.
Create a Velodyne® packet capture (PCAP) file reader.
veloReader = velodyneFileReader('lidarData_ConstructionRoad.pcap','HDL32E');
Read the 1st, 2nd, and 100th scan into the workspace.
ptCloud1 = readFrame(veloReader,1); ptCloud2 = readFrame(veloReader,2); ptCloud100 = readFrame(veloReader,100);
Extract scan context descriptors from each of the point clouds.
descriptor1 = scanContextDescriptor(ptCloud1); descriptor2 = scanContextDescriptor(ptCloud2); descriptor100 = scanContextDescriptor(ptCloud100);
Compute the descriptor distance between the 1st and 2nd scan context descriptors, and between the 1st and 100th scan context descriptors.
dist1to2 = scanContextDistance(descriptor1,descriptor2); dist1to100 = scanContextDistance(descriptor1,descriptor100);
Display the scan context descriptor distances.
disp("Descriptor distance from frame 1 to 2 : " + num2str(dist1to2))
Descriptor distance from frame 1 to 2 : 0.087646
disp("Descriptor distance from frame 1 to 100 : " + num2str(dist1to100))
Descriptor distance from frame 1 to 100 : 0.32427
comma-separated pairs of
the argument name and
Value is the corresponding value.
Name must appear inside quotes. You can specify several name and value
pair arguments in any order as
'NumBins',[20 60]sets the number of radial bins to
20, and the number of azimuthal bins to
'NumBins'— Number of concentric radial and angular bins
[20 60](default) | vector of form [numRadialBins numAzimuthalBins]
Number of concentric radial and angular bins, specified as the
comma-separated pair consisting of
'NumBins' and a
vector of the form [numRadialBins
numRadialBins is a positive integer that
specifies the number of concentric radial bins and
numAzimuthalBins specifies the number of
concentric angular bins. To extract more compact descriptors, you can
decrease the number of bins, but this reduces the discriminative
'MinPointsPerBin'— Minimum number of points to include bin
5(default) | scalar
Minimum number of points for a bin to be included in descriptor,
specified as the comma-separated pair consisting of
'MinPointsPerBin' and a positive integer. Bins
that do not contain the minimum number of points are not included in the
descriptor. For these bins, the function returns
To reduce the chances for noise to be included as a bin, increase this
'SensorOrigin'— Sensor origin
[0 0](default) | two-element vector
Sensor origin, specified as the comma-separated pair consisting of
'SensorOrigin' and a two-element vector. The
elements set the x- and y-axis
coordinate points, respectively, of the sensor origin in world units.
The function centers the bins around the origin of the scan.
'RadialRange'— Radial bounds of descriptor
Radial bounds of the descriptor used when binning points, specified as
the comma-separated pair consisting of
and a two-element vector in the form
[rmin,rmax]. Use this
name-value argument to restrict the spatial bounds covered by the
descriptor— Scan context descriptor
Scan context descriptor, returned as an
M-by-N matrix, where
M and N are the number of
concentric radial and angular bins, respectively, in the descriptor. These
are specified by the
The function returns inherits the data type of the
Location property of the input point cloud.
The scan context descriptor function assumes that the sensor is mounted roughly horizontally and that the input point cloud is in the sensor coordinate system.
To determine loop closure candidates, compare the distance between two scan
context descriptors using the