public void synchronize(
            ReplayDepthImageFrame depthFrame,
            ReplayColorImageFrame colorFrame,
            ReplaySkeletonFrame skletonFrame,
            Boolean isPauseMode
            )
        {
            IsPauseMode = isPauseMode;
            colorFrame.CopyPixelDataTo(_colorByte);
            depthFrame.CopyPixelDataTo(_depthShort);
            for (int i = 0; i < _pixelDepthDataLength; i++)
            {
                _depthByte[i] = (byte)(_depthShort[i] * 0.064-1);
            }

            _isCreation = true;
            IsSkeletonDetected = skletonFrame.IsSkeletonDetected;

            if (skletonFrame.IsSkeletonDetected)
            {
                UserSkeleton[SkeletonDataType.RIGHT_HAND] = new Point(
                    skletonFrame.RightHandPositionX,
                    skletonFrame.RightHandPositionY
                    );

                UserSkeleton[SkeletonDataType.LEFT_HAND] = new Point(
                    skletonFrame.LeftHandPositionX,
                    skletonFrame.LeftHandPositionY
                    );

                UserSkeleton[SkeletonDataType.SPINE] = new Point(
                    skletonFrame.SpinePositionX,
                    skletonFrame.SpinePositionY
                    );
            }
            _isCreation = false;
        }
Example #2
0
        byte[] GetColoredBytes(ReplayDepthImageFrame frame)
        {
            var depthData = new short[frame.PixelDataLength];
            frame.CopyPixelDataTo(depthData);

            var pixels = new byte[frame.Height * frame.Width * 4];

            const int blueIndex = 0;
            const int greenIndex = 1;
            const int redIndex = 2;

            for (int depthIndex = 0, colorIndex = 0;
                 depthIndex < depthData.Length && colorIndex < pixels.Length;
                 depthIndex++, colorIndex += 4)
            {
                var player = depthData[depthIndex] & DepthImageFrame.PlayerIndexBitmask;

                var color = player == 1 ? Colors.Green : Colors.Transparent;
                pixels[colorIndex + blueIndex] = color.B;
                pixels[colorIndex + greenIndex] = color.G;
                pixels[colorIndex + redIndex] = color.R;
                if (player == 1)
                    pixels[colorIndex + redIndex + 1] = 150;
                else
                    pixels[colorIndex + redIndex + 1] = Colors.Transparent.A;
            }
            return pixels;
        }