Contenido principal

pcfitcuboidalign

R2026b

Fit aligned cuboid to 3-D point cloud

Since R2026b

Description

model = pcfitcuboidalign(ptCloud) fits a cuboid with orientation constraints over the input point cloud data, and returns the properties of the cuboid. For more information on how the function determines the orientation constraints of the cuboid, see Algorithm.

example

model = pcfitcuboidalign(ptCloud,indices) fits a cuboid over a selected set of points, indices, in the input point cloud.

model = pcfitcuboidalign(___,Name=Value) specifies options using one or more name-value arguments in addition to any combination of input arguments from previous syntaxes. For example, AngleRange=[25 75] sets the range of angles over which to identify the cuboid orientation to between 25 and 75 degrees.

Examples

collapse all

Load a point cloud of a driving scene from a MAT file.

ptCloud = load("drivingLidarPoints.mat").ptCloud;

Transform the point cloud to simulate a tilted sensor.

tform = rigidtform3d([0 10 0],[0 0 0]);
ptCloud = pctransform(ptCloud,tform);

Select a cylindrical region of interest from the point cloud with a 15-meter radius.

radius = 15;
indices = findPointsInCylinder(ptCloud,radius);
ptCloud = select(ptCloud,indices);

Segment the ground using SMR, and fit a plane to the ground points.

[~,ptCloudNoGround,groundPtCloud] = segmentGroundSMRF(ptCloud,ElevationThreshold=0.9);
groundPlane = pcfitplane(groundPtCloud,0.5);

Cluster the non-ground points into objects.

minDistance = 1;
[labels,numClusters] = pcsegdist(ptCloudNoGround,minDistance,NumClusterPoints=50);

Fit a ground-aligned cuboid to each cluster using pcfitcuboidalign, and display the results.

hold on
for i = 1:numClusters
    indices = labels == i;
    ptCloudSegment = select(ptCloudNoGround,indices);
    cuboid = pcfitcuboidalign(ptCloudSegment,NormalVector=groundPlane.Normal);

    pcshow(ptCloudSegment.Location,labels(indices))
    plot(cuboid)
end

Plot the ground plane, and set the view to visualize the cuboids aligned to the ground.

zlim([-4 5])
plot(groundPlane)
view(0,0)

Figure contains an axes object. The axes object contains 9 objects of type scatter, patch.

Input Arguments

collapse all

Point cloud, specified as a pointCloud object.

Indices of selected points, specified as a vector of positive integers.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Name-Value Arguments

collapse all

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.

Example: pcfitcuboidalign(ptCloudIn,AngleRange=[25 75]) sets the range of angles over which to identify the cuboid orientation to between 25 and 75 degrees.

Normal vector of the plane to which the cuboid is aligned, specified as a three-element vector. The default value [0 0 1] aligns the cuboid with the xy-plane.

Range of angles over which to identify the orientation of the cuboid, specified in degrees as a two-element vector of real values in the range [0, 90].

Angle resolution for cuboid fitting, specified in degrees as a positive scalar. The specified value must be less than or equal to the distance between the upper and lower bounds of the angle range. For example, if the range of the angles is [25,75], the specified value must be less than or equal to 50.

Note

Decreasing the angle resolution increases the computation time and memory footprint.

Output Arguments

collapse all

Cuboid model, returned as a cuboidModel object.

Algorithms

  • Use this function when the cuboid orientation must align with a specified coordinate frame. Use the pcfitcuboid function to fit a cuboid without orientation constraints, which can result in a closer fit to the input point cloud.

  • This function uses an L-shape based detection algorithm to fit a cuboid to point cloud data. For every point in the point cloud, the function iterates through all possible directions for a rectangle and finds the corresponding square errors. The possible directions for the rectangle lie within [0, 90] degrees,each adjacent pair of rectangle sides are orthogonal. You can specify a different range of rectangle directions by using the AngleRange argument. The function then selects the direction that has the least error and fits the rectangle along that direction.

References

[1] Zhang, Xiao, Wenda Xu, Chiyu Dong, and John M. Dolan. “Efficient L-Shape Fitting for Vehicle Detection Using Laser Scanners.” 2017 IEEE Intelligent Vehicles Symposium (IV), June 2017, 54–59. https://doi.org/10.1109/IVS.2017.7995698.

Extended Capabilities

expand all

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

GPU Code Generation
Generate CUDA® code for NVIDIA® GPUs using GPU Coder™.

Version History

Introduced in R2026b