如何从深度图像和从Matlab获取的彩色图像生成3D点云

时间:2016-04-27 12:58:15

标签: matlab kinect matlab-cvst point-clouds

我从kinect获得了2组数据 来自场景的尺寸为480 * 640(uint16)的1-深度图像 来自同一场景的相同尺寸(480 * 640 * 3单张)的双色图像 问题是如何将这些数据合并在一起,以便在Matlab中生成带有PLY格式的彩色3D点云。 我需要说不幸的是我再也无法访问kinect了,我应该只使用这些数据。

2 个答案:

答案 0 :(得分:1)

我从来没有尝试过在matlab中这样做,但我认为这就是你要找的:

when and how to use exceptions

该工具位于Computer Vision System Toolbox™内。

答案 1 :(得分:0)

好问题。 您应该使用Burrus的本教程 - 基本上您需要使用深度信息将颜色/深度质心转换为第三维。请注意,Kinect v1深度和颜色流稍有不匹配,因此也要考虑到这一点。

可以在此处找到该教程:http://nicolas.burrus.name/index.php/Research/KinectCalibration 你也可以使用这个作者的作品:Khoshelham,K。,& Elberink,S。O.(2012) - 用于室内地图绘制应用的Kinect深度数据的准确度和分辨率

matlab代码应该是这样的:

% All formulas and values from:
% Khoshelham, K., & Elberink, S. O. (2012).
% Accuracy and resolution of Kinect depth data for indoor mapping applications.
% Sensors (Basel, Switzerland), 12(2), 1437–54. doi:10.3390/s120201437

load('janFrameThousand.mat')
pc=zeros([size(D) 3]);
W=size(D,2);
H=size(D,1);
f=5.453;
for indWidth = 1:W
    for indHeight= 1:H
        % copy z value
        pc(indHeight,indWidth,3)=D(indHeight,indWidth);
        % calc x value
        pc(indHeight,indWidth,1)=-(pc(indHeight,indWidth,3)/f)*...
            ((indWidth-W/2)*0.0093+0.063);
        % calc y value
        pc(indHeight,indWidth,2)=-(pc(indHeight,indWidth,3)/f)*...
            ((indHeight-H/2)*0.0093+0.039);
    end
end
X=pc(:,:,1);
% X=X(:);
Y=pc(:,:,2);
% Y=Y(:);
Z=-pc(:,:,3);
Z(Z==0)=NaN;

Surface=surf(X,Y,Z,'edgecolor','none','facecolor','interp');
lighting gouraud
camlight
% colormap(repmat(winter,20,1))
axis image
axis vis3d
xlabel('X axis')
ylabel('Y axis')
zlabel('Z axis')
相关问题