如何在Matlab中将Kinect原始深度信息转换为米



我在这里做了一些研究来了解这个主题,但是我没有取得很好的结果。我使用的是Windows版Kinect和Kinect SDK 1.7。我正在用matlab处理原始深度图信息。

首先,我使用这种方法(https://stackoverflow.com/a/11732251/3416588)将Kinect原始深度数据存储到文本文件中。我得到了一个包含(480x640 = 307200)元素和数据的列表,如下所示:

23048
23048
23048
-8
-8
-8
-8
-8
-8
-8
-8
6704
6720
6720
6720
6720
6720
6720
6720
6720
6736
6736
6736
6736
6752
0
0

然后在Matlab中我将这些值转换为二进制。所以,我得到16位的数字。与玩家索引对应的最后三个数字是"000",所以我删除了它们。现在,从13位数字中,我删除了更有意义的数字,它总是"0"。

所以,我做了这个:

[0,1,1,0,0,0,1,0,0,0,1,1,1,0,0,0] - 16 bits number
[0,1,1,0,0,0,1,0,0,0,1,1,1] - 13 bits number
[1,1,0,0,0,1,0,0,0,1,1,1] - 12 bits number

然后我按照这个过程(https://stackoverflow.com/a/9678900/3416588)将原始深度信息转换为米,但我得到的值范围从-4.7422到0.3055。它们是什么意思?

clc
clear all
close all
%Get raw depth data from .txt
fileID = fopen('C:Example.txt', 'r');
datos = fscanf(fileID, '%i'); % Data in decimal
fclose(fileID);
% If raw depth data is less than 0, set it to 0
for i = 1 : 640*480
 if(datos(i) < 0)
   datos(i) = 0;
 end
end
% Auxiliar arrays
datosBin = zeros(640*480, 16);
realDepth = zeros(640*480, 12);
% Decimal raw depth data to binary
n = 16;
m = 0;
for i = 1 : 640*480
 a = datos(i);
 datosBin(i,:) = fix(rem(a*pow2(-(n-1):m),2));
end
% Remove player index and msb (more significant bit)
for i = 1 : 640*480
 realDepth(i,:) = datosBin(i,2:13);
end
% Auxiliar array to store raw depth data decimal number
realDepthDec = zeros(640*480,1);
% Raw depth data 12 bits to decimal
for i = 1 : 640*480
 realDepthDec(i) = bin2dec(num2str(realDepth(i,:)));
end
% Auxiliar array
rawDepthMapMeters = zeros(480, 640);
% Create array 640*480 to store bit depth info in meters
for j = 1 : 480
 for i = 1 : 640
   if(realDepthDec(i+j) <= 2046)
    rawDepthMapMeters(j, i) = 0.1236 * tan(realDepthDec(i+j)/2842.5 + 1.1863);
   end
 end
end

我错在哪里?我做错了什么?提前谢谢。

p。对不起,我的英语不好。

在您阅读的第二篇文章中,您将看到您使用的方法已经过时了。读这篇文章。

x = (i - w / 2) * (z + minDistance) * scaleFactor
y = (j - h / 2) * (z + minDistance) * scaleFactor
z = z
Where
minDistance = -10
scaleFactor = .0021.
These values were found by hand.

也可以在第一个应用程序中将这些点转换为毫米,如第二个问题所述

using (var depthFrame = e.OpenDepthImageFrame())
{
    var depthArray = new short[depthFrame.PixelDataLength];
    depthFrame.CopyPixelDataTo(depthArray);
    for (int i = 0; i < depthArray.Length; i++) {
        int depthInMillimeters = 
            depthArray[i] >> DepthImageFrame.PlayerIndexBitmaskWidth;
        // TADAx2!
}

最新更新