matlab通过points提取roi,Find points within a region of interest in the point cloud

Find points within a cuboid ROI in the organized point cloud data by using the camera projection matrix. Compute the camera projection matrix from sampled point cloud data points and their corresponding image point coordinates.

Load an organized point cloud data into the workspace. The point cloud is generated by using the Kinect depth sensor.

ld = load('object3d.mat');

ptCloud = ld.ptCloud;

Specify the step size for sampling the point cloud data.

stepSize = 100;

Sample the input point cloud and store the sampled 3-D point coordinates as a point cloud object.

indices = 1:stepSize:ptCloud.Count;

tempPtCloud = select(ptCloud,indices);

Remove invalid points from the sampled point cloud.

[tempPtCloud,validIndices] = removeInvalidPoints(tempPtCloud);

Get the 3-D world point coordinates from input point cloud.

worldPoints = tempPtCloud.Location;

Find the 2-D image coordinates corresponding to the 3-D point coordinates of input point cloud.

[Y,X] = ind2sub([size(ptCloud.Location,1),size(ptCloud.Location,2)],indices);

imagePoints = [X(validIndices)' Y(validIndices)'];

Estimate camera projection matrix from the image and the world point coordinates.

camMatrix = estimateCameraMatrix(imagePoints,worldPoints);

Specify a cuboid ROI within the range of the x, y and z coordinates of the input point cloud.

roi = [0.3 0.7 0 0.4 0.1 0.3];

Find the indices of the point cloud data that lie within the cuboid ROI.

indices = findPointsInROI(ptCloud,roi,camMatrix);

Use the point cloud method select to get the point cloud data of points within the ROI.

ptCloudB = select(ptCloud,indices);

Display the input point cloud and the points within the cuboid ROI.

figure

pcshow(ptCloud)

hold on

pcshow(ptCloudB.Location,'r');

legend('Point Cloud','Points within the ROI','Location','southoutside','Color',[1 1 1])

hold off

b0d77a3a03b390ecff5be4cf445b790c.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值