Kinect原始深度以米为单位的距离

Saa*_*aad 3 depth kinect

我想将Kinect深度图转换为以米为单位的距离.问题是,对于深度图值'1080'及其周围,距离太大,因为分母中的项变得非常接近'0'.对于高于'1090'的值,距离为负.

if (depthValue < 2047) 
{
  depthM = 1.0 / (depthValue*-0.0030711016 + 3.3309495161);
}
Run Code Online (Sandbox Code Playgroud)

duc*_*cas 5

正确答案实际上是对您的问题的评论.给出的数字实际上是以毫米为单位的距离.要获得此数字,您需要使用骨架关节并调用DepthImageFrame的MapFromSkeletonPoint或将原始短值右移由DepthImageFrame.PlayerIndexBitmaskWidth.

比如骷髅

using (var skeletonFrame= e.OpenSkeletonFrame())
using (var depthFrame = e.OpenDepthImageFrame())
{
    skeletonFrame.CopySkeletonDataTo(skeletons);
    var skeletons = new Skeleton[skeletonFrame.SkeletonArrayLength];

    foreach (var skeleton in skeletons)
    {
            if (skeleton.TrackingState != SkeletonTrackingState.Tracked) continue;

            var head = skeleton.Joints[JointType.Head];
            if (head.TrackingState == JointTrackingState.NotTracked) continue;

            var depthImagePoint = depthFrame.MapFromSkeletonPoint(head.Position);

            int depthInMillimeters = depthImagePoint.Depth; // TADA!
    }
}
Run Code Online (Sandbox Code Playgroud)

例如转移

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!
}
Run Code Online (Sandbox Code Playgroud)

以下原始解决方案不再正确:

基于本文的内容 - http://openkinect.org/wiki/Imaging_Information:

if (depthValue <= 2047) {
   depthM = 0.1236 * Math.Tan(depthValue / 2842.5 + 1.1863);
}
Run Code Online (Sandbox Code Playgroud)