pcshowMatchedFeatures

Display point clouds with matched feature points

Description

pcshowMatchedFeatures(ptCloud1,ptCloud2,matchedPtCloud1,matchedPtCloud2) displays point clouds, ptCloud1 and ptCloud2, with their matched feature points, matchedPtCloud1 and matchedPtCloud2, color coded by point cloud and each connected to the corresponding point in the other point cloud by a line.

ax = pcshowMatchedFeatures(___) additionally returns an axes object using the input arguments from the previous syntax.

example

[___] = pcshowMatchedFeatures(___,Name,Value) specifies options using one or more name-value pair arguments in addition to any combination of arguments in previous syntaxes. For example, 'Method','montage' visualizes the point clouds next to each other in the axes.

Examples

collapse all

This example shows how to match corresponding point cloud features and visualize them using the pcmatchfeatures and pcshowMatchedFeatures functions.

Construct a velodyneFileReader object.

veloReader = velodyneFileReader('lidarData_ConstructionRoad.pcap','HDL32E');

Read two point clouds using the velodyneFileReader object.

frameNumber = 1;
skipFrame = 5;
fixed = readFrame(veloReader,frameNumber);
moving = readFrame(veloReader,frameNumber + skipFrame);

Segment and remove the ground plane from the fixed point cloud.

groundPtsIdxFixed = segmentGroundFromLidarData(fixed);
fixedSeg = select(fixed,~groundPtsIdxFixed,'OutputSize','full');

Segment and remove the ground plane from the moving point cloud. Plot both point clouds.

groundPtsIdxMoving = segmentGroundFromLidarData(moving);
movingSeg = select(moving,~groundPtsIdxMoving,'OutputSize','full');
figure
pcshowpair(fixedSeg,movingSeg)
ylim([-50 60])
title('Input Point Clouds')

The superimposed input point clouds are color coded as follows:

  • Magenta - Fixed point cloud

  • Green - Moving Point Cloud

Downsample the point clouds.

fixedDownsampled = pcdownsample(fixedSeg,'gridAverage',0.2);
movingDownsampled = pcdownsample(movingSeg,'gridAverage',0.2);

Extract features from the point clouds.

[fixedFeature,fixedValidInds] = extractFPFHFeatures(fixedDownsampled);
[movingFeature,movingValidInds] = extractFPFHFeatures(movingDownsampled);
fixedValidPts = select(fixedDownsampled,fixedValidInds);
movingValidPts = select(movingDownsampled,movingValidInds);

Match features between the point clouds.

indexPairs = pcmatchfeatures(movingFeature,fixedFeature,movingValidPts, ...
    fixedValidPts);
matchedFixedPts = select(fixedValidPts,indexPairs(:,2));
matchedMovingPts = select(movingValidPts,indexPairs(:,1));

Visualize the matches.

figure
pcshowMatchedFeatures(movingSeg,fixedSeg,matchedMovingPts,matchedFixedPts, ...
    'Method',"montage")
xlim([-40 210])
ylim([-50 50])
title('Matched Points')

The matched features and point clouds are color coded to improve visualization:

  • Magenta - Moving point cloud.

  • Green - Fixed point cloud.

  • Red circle - Matched points in the moving point cloud.

  • Blue asterisk - Matched points in the fixed point cloud.

  • Yellow - Line connecting matched features.

Input Arguments

collapse all

First point cloud, specified as a pointCloud object.

Second point cloud, specified as a pointCloud object.

Matched points in the first point cloud, specified as a pointCloud object. Each point is a feature match for the point with the corresponding index in matchedPtCloud2.

Matched points in the second point cloud, specified as a pointCloud object. Each point is a feature match for the point with the corresponding index in matchedPtCloud1.

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is 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 Name1,Value1,...,NameN,ValueN.

Example: 'Method','montage' visualizes the point clouds next to each other in the axes.

Display method, specified as the comma-separated pair consisting of 'Method' and one of these options:

  • 'overlay' — Overlay ptCloud2 on ptCloud1.

  • 'montage' — Display ptCloud1 and ptCloud2 next to each other in the same axes.

Data Types: char | string

Line style and color options, specified as the comma-separated pair consisting of 'PlotOptions' and a cell array of character vectors of the form {MarkerStyle1, MarkerStyle2, LineStyle}. MarkerStyle1 specifies the color and marker symbol for the matched points matchedPtCloud1 in the first point cloud ptCloud1. MarkerStyle2 specifies the color and marker symbol for the matched points matchedPtCloud2 in the second point cloud ptCloud2. LineStyle specifies the color and line style of the lines connecting the matched points of the first point cloud to the matched points of the second. For more information on line styles, marker symbols, and colors, see LineSpec.

Data Types: char

Output axes, specified as the comma-separated pair consisting of 'Parent' and an axes graphics object.

Output Arguments

collapse all

Axes handle, returned as an axes graphics object.

Introduced in R2020b