matlab - 如何在 MATLAB 中从 3D 点云中提取 xyz 坐标

标签 matlab 3d matlab-cvst point-clouds

我正在使用 Windows 版 Kinect 将 3D 图像导入 MATLAB。我希望能够在 3D 场景中找到对象的 3D 坐标。

一个简单的方法是使用找到的clickA3DPoint 函数here , 然后点击我想知道坐标的点。

问题是 clickA3DPoint 需要 3 by N 矩阵中的参数,即 x yN 样本的 z 坐标。当我使用 Kinect 通过 depthToPointCloud 获取点云时,它返回一个 480 * 640 * 3 矩阵。

如何从此矩阵中提取 x、y 和 z 坐标,以便使用 clickA3DPoint 绘制它? (或 scatter3?)

到目前为止我的尝试:

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.

但这只是在 3D 空间中沿对角线绘制点。我如何从 Matlab 中的点云中实际提取 x、y 和 z 坐标?

最佳答案

您可以使用 pcshow 函数绘制您的点,它会直接采用 M-by-N-by-3 数组。然后您可以打开 data tips并单击图中的点以查看它们的坐标。

如果您仍想创建一个 3×N 矩阵,那么最简单的方法如下:

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

关于matlab - 如何在 MATLAB 中从 3D 点云中提取 xyz 坐标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30561420/

相关文章:

3d - VTK:setExtent、setOrigin、setSpacing 在 3D 图像中是什么意思?

c++ - 合并来自kinect的rgb和深度图像

matlab - 什么是最好的相机校准方法?

matlab - rectifyStereoImages 抛出 "Not enough input arguments error"

matlab - mat2gray对multithresh的影响

math - 使用点积确定点是否位于平面上

python画平行六面体

matlab - 使用 cell2mat 将数字矩阵与字符串向量(列标签)连接起来的问题

multithreading - 如何在后台更新 MATLAB GUI?

matlab - 使用 matlab 使用概率随机生成器