简体   繁体   English

如何在MATLAB中从三维点云中提取xyz坐标

[英]How to extract xyz coordinates from 3D point cloud in MATLAB

I am using a Kinect for Windows to import 3D images into MATLAB. 我正在使用Kinect for Windows将3D图像导入MATLAB。 I want to be able to find the 3D co-ordinates of objects within the 3D scene. 我希望能够在3D场景中找到对象的3D坐标。

One simple way to do this is to use the clickA3DPoint function found here , and then click the point I want to know the co-ordinates of. 一个简单的方法是使用此处找到的clickA3DPoint函数,然后单击我想知道坐标的点。

The problem is clickA3DPoint expects the arguments in a 3 by N matrix, which is the x y and z coordinates of N samples. 问题是clickA3DPoint需要3 by N矩阵的参数,即N样本的x yz坐标。 When I use the Kinect to get a point cloud with depthToPointCloud it returns a 480 * 640 * 3 matrix. 当我使用Kinect获取具有depthToPointCloud的点云时,它返回480 * 640 * 3矩阵。

How can I extract the x, y, and z coordinates from this matrix so I can plot it with clickA3DPoint ? 如何从此矩阵中提取x,y和z坐标,以便我可以使用clickA3DPoint绘制它? (or scatter3 ?) (或scatter3 ?)

My attempt so far: 我到目前为止的尝试:

depthDevice = imaq.VideoDevice('kinect',2)  %this is the kinect depth sensor

depthImage = step(depthDevice);  %this takes a depth image. (A 480 * 640 uint16 array)

xyzPoints = depthToPointCloud(depthImage,depthDevice); %convert the depth image to a point cloud

clickA3DPoint(reshape(xyzPoints,[3,307200])) %I'm guessing each of the 480 * 640 points (307200 points) has an x,y and z coordinate, so this concates the coordinates of all these points.

But this just plots the points along a diagonal line in the 3D space. 但这只是绘制了3D空间中对角线上的点。 How do I actually extract the x, y and z coordinates from a point cloud in Matlab? 如何从Matlab中的点云实际提取x,y和z坐标?

You can use the pcshow function to plot your points, and it will take the M-by-N-by-3 array directly. 您可以使用pcshow函数绘制您的点,它将直接采用M-by-N-by-3阵列。 You can then turn on data tips and click on the points in the plot to see their coordinates. 然后,您可以打开数据提示并单击绘图中的点以查看其坐标。

If you still want to create a 3-by-N matrix, then the easiest way to do that is the following: 如果您仍想创建3乘N矩阵,那么最简单的方法是:

x = xyzPoints(:,:,1);
y = xyzPoints(:,:,2);
z = zyzPoints(:,:,3);
points3D = [x(:)'; y(:)', z(:)'];

you can use the Property 'Location' of pointCloud to get the x,y,z. 您可以使用pointCloud的属性“位置”来获取x,y,z。 for example: 例如:

moving = movingReg.Location;%movingReg is a pointCloud
scatter(moving(:,1),moving(:,2));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何通过xyz坐标在MatLab中制作3D线对象,使其在Procrustes Analysis中可用? - How do I make a 3D line object in MatLab from xyz coordinates such that it is usable in a Procrustes Analysis? 如何在MATLAB中将圆柱体拟合到散射的3D XYZ点数据? - How to fit a cylinder to scattered 3D XYZ point data in MATLAB? 如何在matlab中的3D点云上拟合曲面? - How can I fit a surface on 3D point cloud in matlab? 如何从 Matlab 获取的深度图像和彩色图像生成 3D 点云 - How to generate a 3D point cloud from depth image and color image acquired from Matlab 在MATLAB中如何从具有中心点和X,Y,Z长度的3D体积中提取立方体? - how to extract a cube from a 3D volume having a centre point and lengths of X, Y, Z in MATLAB? Matlab:从视差图到3D坐标 - Matlab: From Disparity Map to 3D coordinates 通过MATLAB从相应的分布式点云中获取XYZ数据 - Make a XYZ data from a corresponding distributed point cloud by MATLAB 获取3D图中的点击点坐标Matlab - Getting clicked point coordinates in 3D figure Matlab 如何从3D点云的边界生成横截面? - How to generate cross section from the boundary of a 3D point cloud? 如何从激光雷达范围数据生成 3D 点云 - How to generate 3D point cloud from Lidar range data
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM