簡體   English   中英

如何在MATLAB中從三維點雲中提取xyz坐標

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

我正在使用Kinect for Windows將3D圖像導入MATLAB。 我希望能夠在3D場景中找到對象的3D坐標。

一個簡單的方法是使用此處找到的clickA3DPoint函數,然后單擊我想知道坐標的點。

問題是clickA3DPoint需要3 by N矩陣的參數,即N樣本的x yz坐標。 當我使用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陣列。 然后,您可以打開數據提示並單擊繪圖中的點以查看其坐標。

如果您仍想創建3乘N矩陣,那么最簡單的方法是:

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

您可以使用pointCloud的屬性“位置”來獲取x,y,z。 例如:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM