MATLAB 从点云中删除平面代码例程

MATLAB 从点云中删除平面代码例程

Detect Multiple Planes from Point Cloud

从点云中删除多平面

Load the point cloud. 加载点云例程
load('object3d.mat')

Display and label the point cloud. 显示点云和标签

figure
pcshow(ptCloud)
xlabel('X(m)')
ylabel('Y(m)')
zlabel('Z(m)')
title('Original Point Cloud')

Set the maximum point-to-plane distance (2cm) for plane fitting. 设置平面拟合的最大点平面距离(2cm)

maxDistance = 0.02;

Set the normal vector of the plane. 设置平面的法向量

referenceVector = [0,0,1];

Set the maximum angular distance to 5 degrees. 设置最大角度距离为5度。

maxAngularDistance = 5;

Detect the first plane, the table, and extract it from the point cloud. 检测第一个平面,即表,并从点云中提取它.

[model1,inlierIndices,outlierIndices] = 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(remainPtCloud,roi);

Detect the left wall and extract it from the remaining point cloud. 检测左壁并从剩余的点云中提取它。

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

Plot the two planes and the remaining points. 画出两个平面和剩下的点。

figure
pcshow(plane1)
title('First Plane')

figure
pcshow(plane2)
title('Second Plane')

figure
pcshow(remainPtCloud)
title('Remaining Point Cloud')

例程地址:

D:\Users\41644\Documents\MATLAB\Examples\R2019a\vision\DetectMultiplePlanesFromPointCloudExample
其中 "D:\Users\41644\Documents\"是MATLAB安装地址
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值