HandInput.Util.PlayerDetector.ToWorldDepth C# (CSharp) Method

ToWorldDepth() public static method

public static ToWorldDepth ( double depth ) : int
depth double
return int
        public static int ToWorldDepth(double depth)
        {
            return (int)(HandInputParams.MaxDepth - depth * HandInputParams.MaxDepth / 255);
        }

Usage Example

Example #1
0
        public static SkeletonPoint DepthToSkeleton(Rectangle rect, byte[,,] depthData, int width,
                                                    int height, CoordinateConverter mapper)
        {
            var aveDepth = 0.0;
            var count    = 0;

            for (int y = rect.Top; y < rect.Top + rect.Height && y < height; y++)
            {
                for (int x = rect.Left; x < rect.Left + rect.Width && x < width; x++)
                {
                    if (x > 0 && y > 0)
                    {
                        aveDepth += depthData[y, x, 0];
                        count++;
                    }
                }
            }

            var depth   = PlayerDetector.ToWorldDepth(aveDepth / count);
            var center  = rect.Center();
            var centerX = Math.Max(0, center.X);

            centerX = Math.Min(centerX, width);
            var centerY = Math.Max(0, center.Y);

            centerY = Math.Min(centerY, height);
            return(mapper.MapDepthPointToSkeletonPoint((int)centerX, (int)centerY, depth));
        }