Microsoft Kinect,从3D深度图到2D

时间:2015-01-20 08:03:04

标签: c++ matlab kinect

我尝试使用kinect通过快照获取深度图,然后制作此快照的2D图。目标是制作一个房间的地图。使用的算法如下:

% Matrice della figura
z=snapshot;

% Dati noti

h=size(z,1);    %480 

w=size(z,2);    %640

% M is a constant based on the field of view angle
 M1=1.12032;  % Costante per le X
 M2=0.84024;   % Costante per le Y


for i=1:h  <br>
    for j=1:w


x(i,j)=(j-(w/2))*(320/w)*M1*z(i,j);

if x(i,j)==0
    x(i,j)=NaN;
end


y(i,j)=(i-(h/2))*(240/h)*M2*z(i,j);

if y(i,j)==0
    y(i,j)=NaN;
end

end
end


Z=min(z);

X=min(x);


figure
plot(Z,X)

问题是这个算法没有做它应该做的事情。 有人能帮我吗?

1 个答案:

答案 0 :(得分:0)

您可以删除嵌套循环

x = bsxfun( @times, linspace( -w/2, w/2, w ), z*(320/w)*M1 );
x(x==0) = NaN;
y = bsxfun( @times, linspace( -h/w, h/2, h ).', z*(240/h)*M2 ); 
y( y==0 ) = NaN;