![](/img/trans.png)
[英]How do I make a 3D line object in MatLab from xyz coordinates such that it is usable in a Procrustes Analysis?
[英]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
y
和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陣列。 然后,您可以打開數據提示並單擊繪圖中的點以查看其坐標。
如果您仍想創建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.