matlab cylinder3,Fit cylinder to 3-D point cloud

该博客介绍了如何使用MATLAB的pcfitcylinder函数从3D点云数据中检测和提取圆柱体。通过设置最大点到圆柱体的距离、区域兴趣、方向约束等参数,实现对点云数据的筛选和拟合。示例代码展示了如何应用这些参数来提取点云中的圆柱形结构,并绘制出提取后的点云。此外,还讨论了输入参数和输出模型的详细信息,以及算法背后的M-estimator样本共识(MSAC)方法。
摘要由CSDN通过智能技术生成

pcfitcylinder

Fit cylinder to 3-D point cloud

Description

[___] = pcfitcylinder(___,Name,Value) uses

additional options specified by one or more Name,Value pair

arguments.

Examples

Extract Cylinder from Point Cloud

Load the point cloud.

load('object3d.mat');

Display the point cloud.

figure

pcshow(ptCloud)

xlabel('X(m)')

ylabel('Y(m)')

zlabel('Z(m)')

title('Original Point Cloud')

b60215c97734cfd420c09b07d1889883.png

Set the maximum point-to-cylinder distance (5 mm) for cylinder fitting.

maxDistance = 0.005;

Set the region of interest to constrain the search.

roi = [0.4,0.6,-inf,0.2,0.1,inf];

sampleIndices = findPointsInROI(ptCloud,roi);

Set the orientation constraint.

referenceVector = [0,0,1];

Detect the cylinder and extract it from the point cloud by specifying the inlier points.

[model,inlierIndices] = pcfitcylinder(ptCloud,maxDistance,...

referenceVector,'SampleIndices',sampleIndices);

pc = select(ptCloud,inlierIndices);

Plot the extracted cylinder.

figure

pcshow(pc)

title('Cylinder Point Cloud')

27a07e7283e27d1e01dec8cb94759f31.png

Detect Cylinder in Point Cloud

Load the point cloud.

load('object3d.mat');

Display point cloud.

figure

pcshow(ptCloud)

xlabel('X(m)')

ylabel('Y(m)')

zlabel('Z(m)')

title('Detect a Cylinder in a Point Cloud')

34278ce78c7aef1b4af9fb6d524d5cdf.png

Set the maximum point-to-cylinder distance (5 mm) for the cylinder fitting.

maxDistance = 0.005;

Set the region of interest to constrain the search.

roi = [0.4,0.6;-inf,0.2;0.1,inf];

sampleIndices = findPointsInROI(ptCloud,roi);

Set the orientation constraint.

referenceVector = [0,0,1];

Detect the cylinder in the point cloud and extract it.

model = pcfitcylinder(ptCloud,maxDistance,referenceVector,...

'SampleIndices',sampleIndices);

Plot the cylinder.

hold on

plot(model)

008144152e0f9e8b49b0e3facdc0666f.png

Input Arguments

ptCloudIn — Point cloud

pointCloud object

Point cloud, specified as a pointCloud object. If the Normal property

of the input ptCloud is empty, the function populates

it with values to meet the requirements of the fitting algorithm.

maxDistance — Maximum distance from an inlier point to the cylinder

scalar value

Maximum distance from an inlier point to the cylinder, 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:single | double

referenceVector — Reference orientation

1-by-3 vector

Reference orientation, specified as a 1-by-3 vector.

maxAngularDistance — Maximum absolute angular distance

5 (default) | scalar value

Maximum absolute angular distance, specified as a scalar value.

The maximum angular distance is measured in degrees between the direction

of the fitted cylinder and the reference orientation.

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:'SampleIndices',[].

'SampleIndices' — Linear indices of points to sample

[] (default) | column vector

Linear indices of points to sample in the input point cloud,

specified as the comma-separated pair consisting of 'SampleIndices'

and a column vector. An empty vector means that all points are candidates

to sample when fitting the cylinder during the RANSAC iteration. If

you specify a subset of points, the function fits the model by sampling

only those points in the subset. Providing a subset of points can

significantly speed up the process by reducing the number of trials.

You can generate the indices vector using the findPointsInROI method

of the pointCloud object.

'MaxNumTrials' — Maximum number of random trials

1000 (default) | positive integer

Maximum number of random trials for finding inliers, specified

as the comma-separated pair consisting of 'MaxNumTrials'

and a positive integer. To improve robustness of the output, increase

this value. However, doing so adds additional computations.

'Confidence' — Percentage for finding maximum number of inliers

99 (default) | numeric scalar in the range (0,100)

Percentage for finding maximum number of inliers, specified

as the comma-separated pair consisting of 'Confidence'

and a numeric scalar, in the range (0 100). To improve the robustness

of the output, increase this value. However, doing so adds additional

computations.

Output Arguments

model — Geometric model of cylinder

cylinderModel object.

Geometric model of cylinder, returned as a cylinderModel object.

The coefficients for the output model are set to zero when:

The input point cloud does not contain enough valid

points.

The algorithm cannot find enough inlier points.

inlierIndices — Linear indices of inlier points

column vector

Linear indices of the inlier points in the input point cloud,

returned as a column vector.

outlierIndices — Linear indices of outlier points

column vector

Linear indices of the outlier points in the input point cloud

returned as a column vector.

meanError — Mean square error

scalar value

Mean error of the distance of inlier points to the model, returned

as a scalar value.

Algorithms

The function returns a geometric model that describes the cylinder.

This function uses the M-estimator SAmple Consensus (MSAC) algorithm

to find the cylinder. The MSAC algorithm is a variant of the RANdom

SAmple Consensus (RANSAC) algorithm.

The fitting algorithm for the pcfitcylinder function

requires point cloud normals. Therefore, if the Normal property

for the input point cloud is empty, the function fills it. When the

function fills the Normal property, it uses six points

to fit the local cylinder. If six points do not work and the fitting

fails, consider calling the pcnormals function

which enables you to select the number of points to use.

References

[1] Torr, P. H. S., and A. Zisserman. “MLESAC:

A New Robust Estimator with Application to Estimating Image Geometry.” Computer

Vision and Image Understanding. Volume 78, Issue 1, April

2000, pp. 138-156.

Extended Capabilities

C/C++ Code Generation

Generate C and C++ code using MATLAB® Coder™.

Introduced in R2015b

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值