示例#1
0
        /// <summary>
        /// Draw the frame
        /// </summary>
        /// <param name="framePreProcessor">Frame preprocessor</param>
        public void DrawFrame(FramePreProcessor framePreProcessor)
        {
            this.RegisterFrameRead();

            if ((bool)this.VideoCB.IsChecked)
            {
                this.DrawRGBImage(framePreProcessor);

                this.RgbImage.Opacity = 1.0;
            }
            else
            {
                this.RgbImage.Opacity = 0;
            }

            if ((bool)this.DepthCB.IsChecked)
            {
                this.DrawDepthImage(framePreProcessor);

                this.DepthImage.Opacity = (this.VideoCB.IsChecked == true) ? 0.6 : 1.0;
            }
            else
            {
                this.DepthImage.Opacity = 0;
            }

            this.SkeletonCanvas.Children.Clear();
            if ((bool)this.SkeletalCB.IsChecked)
            {
                this.DrawSkeletons(framePreProcessor);
            }
        }
示例#2
0
        /// <summary>
        /// A method for drawing all joints and bones
        /// </summary>
        /// <param name="framePreProcessor">Pre processed frame, including skeletal data</param>
        private void DrawSkeletons(FramePreProcessor framePreProcessor)
        {
            this.SkeletonQualityText.Text = string.Empty;

            foreach (var skeleton in framePreProcessor.AllSkeletons.Where(skeleton => skeleton.IsSkeletonActive))
            {
                this.DrawBodySegments(skeleton, this.wheatBrush);

                this.DrawJoints(skeleton);

                this.UpdateAdditionalSkeletalInfoField(skeleton);
            }
        }
示例#3
0
        /// <summary>
        /// Overlay depth image
        /// </summary>
        /// <param name="framePreProcessor">Pre processed frame</param>
        private void DrawDepthImage(FramePreProcessor framePreProcessor)
        {
            byte[] depthImageBytes = framePreProcessor.GetDepthBytes();

            this.DepthImage.Source = BitmapSource.Create(
                framePreProcessor.RawFrames.RawDepthFrameInfo.Width,
                framePreProcessor.RawFrames.RawDepthFrameInfo.Height,
                96,
                96,
                PixelFormats.Bgr32,
                null,
                depthImageBytes,
                framePreProcessor.RawFrames.RawDepthFrameInfo.Width * PixelFormats.Bgr32.BitsPerPixel / 8);
        }
示例#4
0
        /// <summary>
        /// Initialize Kinect UI serice
        /// </summary>
        /// <returns>CCR Iterator</returns>
        private IEnumerator <ITask> Initialize()
        {
            this.frameProcessor = new FramePreProcessor(this.kinectPort);

            // create WPF adapter
            this.wpfServicePort = ccrwpf.WpfAdapter.Create(TaskQueue);

            var runWindow = this.wpfServicePort.RunWindow(() => new KinectUI(this));

            yield return((Choice)runWindow);

            var exception = (Exception)runWindow;

            if (exception != null)
            {
                LogError(exception);
                StartFailed();
                yield break;
            }

            // need double cast because WPF adapter doesn't know about derived window types
            this.userInterface = (Window)runWindow as KinectUI;

            yield return(this.kinectPort.Get().Choice(
                             kinectState =>
            {
                this.UpdateState(kinectState);
            },
                             failure =>
            {
                LogError(failure);
            }));

            yield return(this.kinectPort.GetDepthProperties().Choice(
                             GetDepthProperties =>
            {
                KinectUI.MaxValidDepth = GetDepthProperties.MaxDepthValue;
            },
                             failure =>
            {
                LogError(failure);
            }));

            base.Start();

            SpawnIterator(this.ReadKinectLoop);
        }
示例#5
0
        /// <summary>
        /// Draw the RGB Image
        /// </summary>
        /// <param name="framePreProcessor">Frame preprocessor</param>
        private void DrawRGBImage(FramePreProcessor framePreProcessor)
        {
            if (null == framePreProcessor.RawFrames.RawColorFrameData)
            {
                return;
            }

            this.RgbImage.Source = BitmapSource.Create(
                framePreProcessor.RawFrames.RawColorFrameInfo.Width,
                framePreProcessor.RawFrames.RawColorFrameInfo.Height,
                96,
                96,
                PixelFormats.Bgr32,
                null,
                framePreProcessor.RawFrames.RawColorFrameData,
                framePreProcessor.RawFrames.RawColorFrameInfo.Width *
                framePreProcessor.RawFrames.RawColorFrameInfo.BytesPerPixel);
        }
示例#6
0
 /// <summary>
 /// Update the UI for each frame
 /// </summary>
 /// <param name="processedFrames">Processed Frames</param>
 private void UpdateUI(FramePreProcessor processedFrames)
 {
     this.wpfServicePort.Invoke(() => this.userInterface.DrawFrame(processedFrames));
 }