Main Content

scanContextDistance

Distance between scan context descriptors

Description

example

dist = scanContextDistance(descriptor1,descriptor2) computes the normalized distance between scan context descriptors. Determine loop closure candidates using the computed distance.

A scan context descriptor is a 2-D global feature descriptor for a point cloud that can be used to detect loop closures. To extract a scan context descriptor from a point cloud, use the scanContextDescriptor function.

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

Scan context descriptor of point cloud, specified as an M-by-N matrix. To ensure an accurate distance measurement, use the same radial range when extracting this descriptor as for descriptor2.

Data Types: single | double

Scan context descriptor of point cloud, specified as an M-by-N matrix. To ensure an accurate distance measurement, use the same radial range when extracting this descriptor as for descriptor1.

Data Types: single | double

Output Arguments

collapse all

Distance between the scan context descriptors, returned as a scalar in the range [0,1). A small value indicates that the scan contexts are likely to belong to the same location, and are loop closure candidates. The function returns dist as a single data type when either descriptor1 or descriptor2 inputs is of single data type. Otherwise, the function returns dist as a double data type.

Data Types: single | double

Algorithms

  • The function computes the distance between scan context descriptors using a modified cosine distance and normalizes it to the range [0 to 1).

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