main Content

分段

段将3-D范围数据组织成簇

Description

例子

标签= segmentlidardata(ptcloud,,,,distThreshold细分有组织的3-D范围数据ptcloudinto clusters. The function assigns an integer cluster label to each point in the point cloud and returns the cluster label of all points in标签

这function groups two neighboring points into the same cluster if their Euclidean distance is less thandistThresholdor if the angle between the sensor and two neighboring points is at least 5 degrees.

例子

标签= segmentlidardata(ptcloud,,,,distThreshold,,,,Anglethresholdsets the angle constraint for grouping points into the same cluster toAnglethreshold

[[标签,,,,numClusters] = segmentLidarData(___also returns the number of clusters.

[[___] = segmentLidarData(___,numClusterPoints = [1,Inf])还设置了每个群集中的最小值和最大点,指定为2元素向量或标量值。指定时numClusterPoints作为标量,群集中的最大点是不受限制的。该功能设置标签0当群集不在指定范围内。

Examples

collapse all

创建有组织的合成激光雷达数据,其中包含两个对象。

ldr =零(5,100);ldr(:,1:50)= 10;ldr(:,51:end)= 20;螺距= linspace(-18,18,5);pitch = repmat(俯仰',1,100);yaw = linspace(-90,90,100);yaw = repmat(Yaw,5,1);

Convert to Cartesian coordinates.

X = ldr .* cosd(pitch) .* sind(yaw); Y = ldr .* cosd(pitch) .* cosd(yaw); Z = ldr .* sind(pitch); pc = pointCloud(cat(3,X,Y,Z)); figure pcshow(pc.Location,'r')title('Unclustered Point Cloud'

图包含一个轴对象。带有标题无聚集点云的轴对象包含类型散点的对象。

设置阈值。

距离= 5;

细分LiDAR数据。

标签= SemgentlidardAtata(PC,Distthreshold);

绘制结果。

figure holdontitle('Segmented Clusters')pc1 = select(pc,find(labels == 1));pcshow(pc1.location,'g')pc2 = select(pc,find(labels == 2)); pcshow(pc2.Location,'y'

图包含一个轴对象。带有标题分段簇的轴对象包含2个类型散点的对象。

设置PCAP文件读取器。

veloreader = velodynefilereader('lidarData_ConstructionRoad.pcap',,,,'HDL32E');

从文件开头等待0.3秒,然后从下一帧中读取点云。

veloReader.CurrentTime = veloReader.StartTime + seconds(0.3); ptCloud = readFrame(veloReader);

Segment and remove the ground plane.

gruendptSidx = segmentgroundFromlidArdata(ptCloud);ptcloudwithoutground = select(ptcloud,〜cloverptsidx,“输出尺寸”,,,,'full');

聚集剩余点。距离为米。

distThreshold = 0.5; [labels,numClusters] = segmentLidarData(ptCloudWithoutGround,distThreshold);

为接地平面添加一个额外的标签。

numClusters =数字+1;标签(subporptSidx)=数字;

绘制标记的结果。用黑色显示接地平面。

labelColorIndex = labels+1; pcshow(ptCloud.Location,labelColorIndex) colormap([hsv(numClusters);[0 0 0]]) title(“点云簇”

图包含一个轴对象。这axes object with title Point Cloud Clusters contains an object of type scatter.

Input Arguments

collapse all

Point cloud, specified as apointCloud目的。ptcloudis an organized point cloud that stores point coordinates in anm-by-n-by-3 matrix. The points must be organized by pitch and yaw angles in a sequential scanning order, which is typically obtained from laser range finders and thevelodynefilereader

世界单位中的距离阈值,指定为非负标量。如果它们之间的距离小于距离阈值,则将相邻点分组为相同的群集。为了减少输出簇的数量,请增加distThreshold

数据类型:单身的|double

角度阈值以度为单位,在[0,180]范围内指定为标量。为了减少输出簇的数量,请降低Anglethreshold。如果传感器形成的角度和点大于角阈值,则函数组相邻到同一群集中。例如,在图中,如果传感器,点A和点B形成的角度大于Anglethreshold。For more details, seeAlgorithms

数据类型:单身的|double

输出参数

collapse all

Cluster labels of all points in the point cloudptcloud,,,,returned as anm-by-n矩阵of integers. Each valid point inptcloudbelongs to a cluster. All points in a cluster are assigned the same integer cluster label, ranging from1numClusters。无效的点,例如与Infor坐标,分配标签0

集群数量,作为一个正整数返回。群集的数量不包括对应于无效点的群集,并排除标签值,0,,,,which is reserved for invalid points.

Algorithms

分段function uses distance and angle thresholds to cluster neighboring points. The function groups two neighboring points into the same cluster if their Euclidean distance is less than the inputdistThresholdor if the angle between the sensor and neighboring points is greater than or equal to the inputAnglethreshold。If you do not specifyAnglethreshold,,,,the function sets this angle to5学位。

例如,假设Anglethresholdis set to90。由于图中的角度α和β都大于指定的90度阈值,因此函数组将A,B和C指向同一群集。由于角度σ小于90度阈值,因此函数组将D指向单独的群集。函数用于群集的每个角度都是由从一个点到传感器的线形成的,从同一点到相邻点的线

References

[[1] Bogoslavskyi, I. “Efficient Online Segmentation for Sparse 3D Laser Scans.”摄影测量,遥感和地球信息科学杂志。Vol. 85, Issue 1, 2017, pp. 41–52.

扩展功能

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

版本历史记录

在R2018A中引入