Main Content

detectRectangularPlanePoints

Detect rectangular plane of specified dimensions in point cloud

Description

ptCloudPlanes = detectRectangularPlanePoints(ptCloudIn,planeDimensions) detects and extracts a rectangular plane, ptCloudPlanes, of specified dimensions, planeDimensions, from the input point cloud ptCloudIn.

[ptCloudPlanes,ptCloudUsed] = detectRectangularPlanePoints(ptCloudArray,planeDimensions) detects rectangular planes from a set of point clouds, ptCloudArray. In addition, the function can return is a logical vector, ptCloudUsed, that indicates the point clouds in which it detected a rectangular plane.

___ = detectRectangularPlanePoints(ptCloudFileNames,planeDimensions) detects rectangular planes from a set of point cloud files, ptCloudFileNames, and returns any combination of output arguments from previous syntaxes.

[___,indicesCell] = detectRectangularPlanePoints(ptCloudFileNames,planeDimensions) returns indices to the points within the detected rectangular plane in each point cloud, in addition to any previous combination of arguments.

example

[___] = detectRectangularPlanePoints(___,Name,Value) specifies options using one or more name-value pair arguments. For example, 'RemoveGround',true sets the 'RemoveGround' flag to true, which removes the ground plane from the input point cloud before processing.

Examples

collapse all

Load point cloud data into the workspace. Visualize the point cloud.

ptCloud = pcread('pcCheckerboard.pcd');
pcshow(ptCloud)
title('Input Point Cloud')
xlim([-5 10])
ylim([-5 10])

Set the search dimensions for the rectangular plane.

boardSize = [729 810];

Search for the rectangular plane in the point cloud. Visualize the detected rectangular plane.

lidarCheckerboardPlane = detectRectangularPlanePoints(ptCloud,boardSize, ...
    'RemoveGround',true);
hRect = figure;
panel = uipanel('Parent',hRect,'BackgroundColor',[0 0 0]);
ax = axes('Parent',panel,'Color',[0 0 0]); 
pcshow(lidarCheckerboardPlane,'Parent',ax)
title('Rectangular Plane Points')

Visualize the detected rectangular plane on the input point cloud.

figure
pcshowpair(ptCloud,lidarCheckerboardPlane)
title('Detected Rectangular Plane')
xlim([-5 10])
ylim([-5 10])

Input Arguments

collapse all

Point cloud, specified as a pointCloud object. The function searches within this point cloud for a rectangular plane.

Point cloud array, specified as a P-by-1 array of pointCloud objects. P is the number of pointCloud objects in the array. The function searches within each point cloud for a rectangular plane.

Point cloud file names, specified as a character vector or cell array of character vectors. If specifying multiple file names, you must use a cell array of character vectors.

Data Types: char | cell

Rectangular plane dimensions, specified as a two-element vector of positive real numbers. The elements specify the width and length of the rectangular plane respectively, in millimeters. The function searches the input point cloud for a plane with the same dimensions as planeDimensions.

Data Types: single | double

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: 'RemoveGround',true sets the 'RemoveGround' flag to true, which removes the ground plane from the input point cloud before processing.

Clustering threshold for two adjacent points, specified as the comma-separated pair consisting of 'MinDistance' and a positive scalar in meters. The clustering process is based on the Euclidean distance between adjacent points. If the distance between two adjacent points is less than the clustering threshold, both points belong to the same cluster.

Data Types: single | double

Region of interest (ROI) for detection, specified as the comma-separated pair consisting of 'ROI' and a vector of the form [xmin, xmax, ymin, ymax, zmin, zmax]. The vector specifies the x, y, and z limits of the ROI as the pairs xmin and xmax, ymin and ymax, zmin and zmax respectively.

Data Types: single | double

Tolerance for uncertainty in the rectangular plane dimensions, specified as the comma-separated pair consisting of 'DimensionTolerance' and a positive scalar in the range [0 1]. A higher 'DimensionTolerance' indicates a more tolerant range for the rectangular plane dimensions

Data Types: single | double

Remove the ground plane from the point cloud, specified as the comma-separated pair consisting of 'RemoveGround' and a logical false or true.

The normal of the plane is assumed to point towards the positive direction of the z-axis with the reference vector [0 0 1].

Data Types: logical

Display function progress, specified as the comma-separated pair consisting of 'Verbose' and a logical false or true.

Data Types: logical

Output Arguments

collapse all

Detected rectangular planes, returned as a pointCloud object or 1-by-P array of pointCloud objects, where P specifies the number of input point clouds in which a rectangular plane was detected.

Pattern detection flag, returned as a 1-by-N logical vector. N is the number of input point clouds. A true value indicates that the function detected a rectangular plane in the corresponding point cloud. A false value indicates that the function did not detect a rectangular plane.

Indices of detected rectangular planes, returned as a 1-by-P cell array, where P is the number of input point clouds in which a rectangular plane was detected. Each cell contains a logical vector that specifies the indices of the corresponding point cloud at which the function detected a rectangular plane. The indices can be used to extract the detected plane from the point cloud data.

Introduced in R2020b