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.
Extract and Compare Scan Context Descriptors of Point Clouds
Create a Velodyne® packet capture (PCAP) file reader.
veloReader = velodyneFileReader('lidarData_ConstructionRoad.pcap','HDL32E');
Read the 1st, 2nd, and 30th scan into the workspace.
ptCloud1 = readFrame(veloReader,1); ptCloud2 = readFrame(veloReader,2); ptCloud30 = readFrame(veloReader,30);
Extract scan context descriptors from each of the point clouds.
descriptor1 = scanContextDescriptor(ptCloud1); descriptor2 = scanContextDescriptor(ptCloud2); descriptor30 = scanContextDescriptor(ptCloud30);
Compute the descriptor distance between the 1st and 2nd scan context descriptors, and between the 1st and 30th scan context descriptors.
dist1to2 = scanContextDistance(descriptor1,descriptor2); dist1to30 = scanContextDistance(descriptor1,descriptor30);
Display the scan context descriptor distances.
disp("Descriptor distance from frame 1 to 2: " + num2str(dist1to2))
Descriptor distance from frame 1 to 2: 0.087647
disp("Descriptor distance from frame 1 to 30: " + num2str(dist1to30))
Descriptor distance from frame 1 to 30: 0.31551
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.
Before R2021a, use commas to separate each name and value, and enclose
Name in quotes.
'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
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
full spatial extent of point cloud (default) | two-element vector
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