首页 > 解决方案 > 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

标签: c#image-processinguwpkinectdepth-buffer

解决方案


我使用人脸检测从彩色图像中获取人脸坐标。将这些坐标映射到 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 米之间的距离(在房间的不同位置),它似乎给了我与现实世界相同的读数。目前,这似乎可行。


推荐阅读