Detect rectangular plane of specified dimensions in point cloud
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])
ptCloudIn— Point cloud
Point cloud, specified as a
pointCloud object. The function searches
within this point cloud for a rectangular plane.
ptCloudArray— Point cloud array
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.
ptCloudFileNames— Point cloud file names
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.
planeDimensions— Rectangular plane dimensions
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
comma-separated pairs of
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
'RemoveGround'flag to true, which removes the ground plane from the input point cloud before processing.
'MinDistance'— Clustering threshold for two adjacent points
0.5(default) | positive scalar
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. Low resolution lidars require higher
'MinDistance' threshold and vice-versa.
'ROI'— Region of interest for detection
Region of interest (ROI) for detection, specified as the comma-separated pair
'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.
'DimensionTolerance'— Tolerance for uncertainty in rectangular plane dimensions
0.05(default) | positive scalar in the range [0 1]
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
indicates a more tolerant range for the rectangular plane dimensions.
'RemoveGround'— Remove ground plane from point cloud
Remove the ground plane from the point cloud, specified as the comma-separated
pair consisting of
'RemoveGround' and a logical
The normal of the plane is assumed to be aligned with the positive direction of
the z-axis with the reference vector
'Verbose'— Display function progress
Display function progress, specified as the comma-separated pair consisting of
'Verbose' and a logical
ptCloudPlanes— Detected rectangular planes
pointCloudobject | 1-by-P array of
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.
ptCloudUsed— Pattern detection flag
Pattern detection flag, returned as a 1-by-N logical vector.
N is the number of input point clouds. A
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.
indicesCell— Indices of detected rectangular planes
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.