コード例 #1
0
        void ReplayFrame(ReplayDepthImageFrame df, ReplayColorImageFrame cf,
                         ReplaySkeletonFrame sf)
        {
            if (df != null)
            {
                labelFrameNumber.Content = df.FrameNumber.ToString();
                if (gtReplayer != null)
                {
                    var data = gtReplayer.GetDataFrame(df.FrameNumber);
                    if (data != null)
                    {
                        UpdateGroundTruthDisplay(data);
                    }
                }
            }
            colorManager.Update(cf, !displayDebug);
            depthManager.Update(df);
            UpdateSkeletonDisplay(sf);
            if (handTracker != null && recogEngine != null)
            {
                var result = handTracker.Update(depthManager.PixelData, colorManager.PixelData,
                                                SkeletonUtil.FirstTrackedSkeleton(sf.Skeletons));
                var gesture = recogEngine.Update(result, viewHog);

                lock (inputServer)
                    inputServer.Send(gesture);

                textGestureEvent.Text = gesture;
                fpsCounter.LogFPS();
                UpdateDisplay(result);
            }
        }
コード例 #2
0
        public void Update(ReplayDepthImageFrame frame)
        {
            var pixelData = new short[frame.PixelDataLength];

            frame.CopyPixelDataTo(pixelData);

            if (depthFrame32 == null)
            {
                depthFrame32 = new byte[frame.Width * frame.Height * 4];
            }

            if (Bitmap == null)
            {
                Bitmap = new WriteableBitmap(frame.Width, frame.Height, 96, 96, PixelFormats.Bgra32, null);
            }

            ConvertDepthFrame(pixelData);

            int       stride    = Bitmap.PixelWidth * Bitmap.Format.BitsPerPixel / 8;
            Int32Rect dirtyRect = new Int32Rect(0, 0, Bitmap.PixelWidth, Bitmap.PixelHeight);

            Bitmap.WritePixels(dirtyRect, depthFrame32, stride, 0);

            RaisePropertyChanged(() => Bitmap);
        }
コード例 #3
0
 /// <summary>
 /// Updates the depth frame pixel data. Each pixel contains both the player and the depth
 /// information.
 /// </summary>
 /// <param name="frame"></param>
 public void UpdatePixelData(ReplayDepthImageFrame frame)
 {
     if (DepthPixelData == null)
     {
         DepthPixelData = new short[frame.PixelDataLength];
     }
     frame.CopyPixelDataTo(DepthPixelData);
 }
コード例 #4
0
        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;
                }
            }
        }
コード例 #5
0
        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;
        }