簡體   English   中英

Kinect V2 UWP 如何計算與用戶的距離

[英]Kinect V2 UWP How to calculate distance from user

我正在嘗試計算從一個人到 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 米之間的距離(在房間的不同位置),它似乎給了我與現實世界相同的讀數。 目前,這似乎可行。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM