Main Content

PCFITPLANE

将飞机适合3-D点云

Description

model= PCFITPLANE(ptCloudIn,,,,maxDistance将平面拟合到一个点云,该点云具有从距离点到平面的最大允许距离。该函数返回描述平面的几何模型。

This function uses the M-estimator SAmple Consensus (MSAC) algorithm to find the plane. The MSAC algorithm is a variant of the RANdom SAmple Consensus (RANSAC) algorithm.

model= PCFITPLANE(ptCloudIn,,,,maxDistance,,,,referenceVector将平面拟合到具有1 by-3指定的其他方向约束的点云referenceVector输入。

例子

model= PCFITPLANE(ptCloudIn,,,,maxDistance,,,,referenceVector,,,,maxangulardistancefits a plane to a point cloud that has a specified maximum angular distance.

[[model,,,,嵌入式,,,,outlierIndices] = PCFITPLANE(ptCloudIn,,,,maxDistanceadditionally returns the linear indices to the inlier and outlier points in the point cloud input.

[[___,,,,MeanError] = PCFITPLANE(ptCloudIn,,,,maxDistance另外,使用前面的任何语法返回inlier点到模型的距离的平均误差。

例子

[[___] = PCFITPLANE(ptCloudIn,,,,maxDistance,,,,姓名,,,,Valueuses additional options specified by one or more姓名,,,,Valuepair arguments.

Examples

collapse all

加载点云。

加载("object3d.mat"

Display and label the point cloud.

图PCSHOW(PTCLOUD)XLABEL(“ x(m)”)ylabel("Y(m)")zlabel(“ Z(M)”)title(“原始点云”

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

设置最大point-to-plane距离(2厘米)plane fitting.

maxDistance = 0.02;

Set the normal vector of the plane.

参考值= [0,0,1];

Set the maximum angular distance to 5 degrees.

maxangulardistance=5;

检测第一个平面,表格,并从点云中提取。

[model1,inlierIndices,utlierIndices] = pcfitplane(ptcloud,...maxDistance,referenceVector,maxAngularDistance); plane1 = select(ptCloud,inlierIndices); remainPtCloud = select(ptCloud,outlierIndices);

Set the region of interest to constrain the search for the second plane, left wall.

ROI = [-inf,inf; 0.4,inf; -inf,inf];sampleIndices = findpointsinroi(retusptCloud,roi);

检测左壁并从其余点云中提取。

[[model2,inlierIndices,outlierIndices] = pcfitplane(remainPtCloud,...maxDistance,SampleIndices=sampleIndices); plane2 = select(remainPtCloud,inlierIndices); remainPtCloud = select(remainPtCloud,outlierIndices);

绘制两架平面和其余点。

图pcshow(plane1)标题(“第一平面”

图包含一个轴对象。带有标题第一平面的轴对象包含类型散点的对象。

图pcshow(plan2)标题("Second Plane"

图包含一个轴对象。The axes object with title Second Plane contains an object of type scatter.

图pcshow(reteptCloud)标题("Remaining Point Cloud"

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

Input Arguments

collapse all

Point cloud, specified as apointCloud目的。

Maximum distance from an inlier point to the plane, specified as a scalar value. Specify the distance in units that are consistent with the units you are using for the point cloud.

Data Types:单身的|double

参考方向约束,指定为1 x-3向量。您必须指定此参数,以便该函数应用方向约束以将平面拟合到输入点云。如果您不指定参考向量,则该函数使用平面方程拟合模型,斧头+经过+CZ+d=0

Data Types:单身的|double

Maximum absolute angular distance between the normal vector of the fitted plane and the reference orientation, specified as a scalar value in degrees.

Data Types:单身的|double

名称值参数

Specify optional pairs of arguments asname1 = value1,...,namen = valuen,,,,where姓名是参数名称和Valueis the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

在R2021a之前,请使用逗号分隔每个名称和值,并附上姓名用引号。

Example:'SampleIndices',,,,[[]

在输入点云中采样的点的线性索引,指定为逗号分隔对,由'样品指标'和列矢量。一个空的矢量意味着所有点都是候选人在勒索迭代中采样以适合平面的候选者。指定子集时,仅对子集中的点进行采样以适合模型。

提供一部分积分可以显着加快流程并减少试验数量。您可以使用findPointsInROImethod of thepointCloud目的。

随机试验的最大数量for finding inliers, specified as the comma-separated pair consisting of 'maxnumtrials' and a positive integer. Increasing this value makes the output more robust but adds additional computations.

找到最大嵌入数量的置信度百分比,指定为逗号分隔对,由'信心'和一个数字标量在[0 100]范围内。增加此值可以使输出更强大,但添加了其他计算。

输出参数

collapse all

平面的几何模型,返回planeModel目的。

当输入点云不包含足够的有效点,或者当函数找不到足够的内部点时,输出模型的系数设置为零。

输入点云中内部点的线性索引,作为列向量返回。

Linear indices of outlier points within the input point cloud, returned as a column vector.

Mean error of the distance of inlier points to the model, returned as a scalar value.

References

[1] Torr,P。H. S.和A. Zisserman。“ MLESAC:一种新的可靠估计器,并应用于估计图像几何形状。”计算机视觉和图像理解。2000。

扩展功能

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

版本历史记录

Introduced in R2015b