MATLAB中的深度图.bin

时间:2015-01-11 13:56:41

标签: c++ matlab kinect kinect-sdk

我有.bin格式的深度图。我想在MATLAB中访问。 我在stackoverflow上找到了一个代码

function [depthImg] = ReadKiectDepthIndivi(loc)
%This function reads in a Kinect depth image from a bin file  
%Input:  
%   loc - location of the bin file  
%Output:    
%   depthImg - depth image  

%Read in the file  
fid = fopen(loc); %read the file in  
[A, count] = fread(fid, 'uint16=>uint16',2); %load and shift  
fclose(fid); %close the stream  

%Convert into structure  
dims = [320 240]; %dims of the depth  

depth = double(A); %convert to double for imaging  

[depthImg.X, depthImg.Y] = meshgrid([1:dims(1)], [1:dims(2)]); %obtain x and y  
depthImg.Z = reshape(depth, dims(1), dims(2))'; %generate depth  
%temp.Z(temp.Z==0)=NaN; % noise clean up (if required)  
end  

但是这段代码给了我错误 转换为双倍后

depth = double(A); %convert to double for imaging

深度的大小是26304003x1

dims=[320 240]

所以它给我错误

depthImg.Z = reshape(depth, dims(1), dims(2))

请有人帮我转换

0 个答案:

没有答案