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;
        }
Esempio n. 2
0
        private void ProcessDepthImageFrame(ReplayDepthImageFrame frame)
        {
            var pixels = GetColoredBytes(frame);
            if (DepthImageSource == null)
                DepthImageSource = new WriteableBitmap(frame.Width, frame.Height, 96, 96,
                        PixelFormats.Bgra32, null);

            var stride = frame.Width * PixelFormats.Bgr32.BitsPerPixel / 8;
            DepthImageSource.WritePixels(new Int32Rect(0, 0, frame.Width, frame.Height), pixels, stride, 0);
        }
Esempio n. 3
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;
        }
		internal void AddFrames(BinaryReader reader)
		{
			//not the best of approaches - assuming that color frame is the 1st frame followed by depth and skeleton frame
			while (reader.BaseStream.Position < reader.BaseStream.Length)
			{
				var header = (FrameType)reader.ReadInt32();
				switch (header)
				{
					case FrameType.Color:
						var colorFrame = new ReplayColorImageFrame();
						colorFrame.CreateFromReader(reader);
						frames.Add(new ReplayAllFrames { ColorImageFrame = colorFrame });
						break;
					case FrameType.Depth:

						var depthFrame = new ReplayDepthImageFrame();
						depthFrame.CreateFromReader(reader);
						if (frames.Any())
							frames.Last().DepthImageFrame = depthFrame;
						break;
					case FrameType.Skeletons:
						var skeletonFrame = new ReplaySkeletonFrame();
						skeletonFrame.CreateFromReader(reader);
						if (frames.Any())
							frames.Last().SkeletonFrame = skeletonFrame;
						break;
				}
			}
		}