Main Content

scanContextDescriptor

Extract scan context descriptor from point cloud

Since R2020b

Description

descriptor = scanContextDescriptor(ptCloud) extracts a scan context descriptor from a point cloud, ptCloud.

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.

example

descriptor = scanContextDescriptor(ptCloud,Name,Value) specifies options using one or more name-value pair arguments.

Examples

collapse all

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

Input Arguments

collapse all

Point cloud, specified as pointCloud object.

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is 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.

Example: 'NumBins',[20 60] sets the number of radial bins to 20, and the number of azimuthal bins to 60.

Number of concentric radial and angular bins, specified as the comma-separated pair consisting of 'NumBins' and a vector of the form [numRadialBins numAzimuthalBins], where 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 power.

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 NaN. To reduce the chances for noise to be included as a bin, increase this value.

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.

Radial bounds of the descriptor used when binning points, specified as the comma-separated pair consisting of 'RadialRange' and a two-element vector in the form [rmin,rmax]. Use this name-value argument to restrict the spatial bounds covered by the descriptor.

Output Arguments

collapse all

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 NumBins property.

The function returns inherits the data type of the Location property of the input point cloud.

Data Types: single | double

Tips

  • 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 scanContextDistance function.

References

[1] G. Kim and A. Kim, "Scan Context: Egocentric Spatial Descriptor for Place Recognition Within 3D Point Cloud Map," 2018 IEEE/RSJ International Conference on Intelligent Robots and Systems (IROS), 2018, pp. 4802-4809, doi: 10.1109/IROS.2018.8593953.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Version History

Introduced in R2020b