如何在Matlab中将Kinect原始深度信息转换为米? [英] How to convert Kinect raw depth info to meters in Matlab?

查看:136
本文介绍了如何在Matlab中将Kinect原始深度信息转换为米?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这里进行了一些研究以了解此主题,但未取得良好的结果.我正在使用Windows版Kinect和Kinect SDK 1.7.我正在与matlab合作,以处理原始深度图信息.

I have made some research here to understand this topic but I have not achieved good results. I'm working with a Kinect for Windows and the Kinect SDK 1.7. I'm working with matlab to process raw depth map info.

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

First, I'm using this method (https://stackoverflow.com/a/11732251/3416588) to store Kinect raw depth data to a text file. I got a list with (480x640 = 307200) elements and data like this:

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".

Then in Matlab I convert this values to binary. So, I get 16-bits numbers. The last three numbers that correspond to player index are "000", so I remove them. Now, from the 13 bits numbers, I remove the more significative, which is always "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之间.是什么意思?

Then I follow to this procedure (https://stackoverflow.com/a/9678900/3416588) to convert raw-depth info to meters but i get values in the range from -4.7422 to 0.3055. What do they mean?

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

我的错误在哪里?我究竟做错了什么?预先感谢.

Where is my mistake? What am I doing wrong? Thanks in advance.

PS.对不起,我的英语不好.

PS. Sorry for my bad english.

推荐答案

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

In the second article you read, you will see that the method you use is outdated. Read this.

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.

您还可以按照第二个问题所述,在第一个应用程序中将这些点转换为毫米数

Also you could convert those points to millimeters in your first application as described in the second question

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!
}

这篇关于如何在Matlab中将Kinect原始深度信息转换为米?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆