c# - 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 米之间的距离(在房间的不同位置),它似乎给了我与现实世界相同的读数。目前,这似乎可行。
推荐阅读
- javascript - 在 React 中使用 useState 钩子将数组插入状态
- assembly - 多个中断级别的用途
- ms-access - 使用前端时出现 ImportExportText 错误 - 您无法记录更改,因为您输入的值违反了为此表定义的设置
- php - 使用 PHP 在 Active Directory 中更改密码时出错
- java - TransformerFactory 仍然容易受到 XXE 攻击
- python - python 与 MicroPython 中的 time.time()
- sql - 使用 bigint 列连接的 HIVE SQL 查询未返回任何结果
- java - @KafkaListener 的单元测试 - 空指针异常
- reactjs - 过滤状态数据不能正常工作 - React (CRA)
- javascript - 使用 webpack 时防止加载每个 .js 文件