Kinect V2 UWP 如何计算与用户的距离

问题描述

我正在尝试在 UWP c# 中计算人到 Kinect 传感器 v2 的距离。

在 WPF 中,我得到了这个

double distancemm = this.bodies[i].Joints[JointType.Head].Position.Z * 1000; // meters to millimetres

在使用深度框架的 UWP 中,我能够获得最小和最大可靠距离,但我不确定如何获得用户到 Kinect 传感器的距离。

var depthScaleInMeters = vidFrame.DepthMediaFrame.DepthFormat.DepthScaleInMeters;
var depthRangeminimumInMeters = vidFrame.DepthMediaFrame.MinReliableDepth * depthScaleInMeters;
var depthRangeMaximumInMeters = vidFrame.DepthMediaFrame.MaxReliableDepth * depthScaleInMeters;

有人可以帮忙吗?

编辑:

我在深度图像中找到了人脸/物体的 x 和 y 线并获得了它的深度值,但是当我尝试将其转换为以米为单位的距离时,它似乎比现实世界中的值小很多(这应该是1.2米)。

int x = 235;//specify x value here
int y = 215;//specify y value here
int d = (ushort)output[x + y * PixelHeight] ; //PixelHeight  = 512
d = d >> 3;//this is distance in mm
double metersdistance = d  * 0.001; // meters

解决方法

我使用人脸检测从彩色图像中获取人脸坐标。将这些坐标映射到 IR 和深度框架上。这样,我从深度框架中找到了人脸的 x 和 y 线。

int x = 235;//specify x value here
int y = 215;//specify y value here
int d = (ushort)output[x + y * PixelHeight] ; //PixelHeight  = 512
double metersdistance = d  * 0.001; // meters

d 给出深度值并将其乘以 0.001 将其转换为米。我测试了 1 米到 3 米之间的距离(在房间的不同位置),它似乎给了我与现实世界相同的读数。目前,这似乎有效。