예제 #1
0
        /// <summary>
        /// DepthFrame Manager
        /// </summary>
        /// <param name="refDepthImage"></param>
        private void ManageDepthFrame(DepthImageFrame refDepthImage)
        {
            // If system is locked, draw system lock feedback
            if (IsLocked && PropertiesPluginKinect.Instance.EnableDepthFrameService)
            {
                PropertiesPluginKinect.Instance.DepthFrame = Feedback.FeedbackSystemLocked(PropertiesPluginKinect.Instance.KinectResolutionWidth, PropertiesPluginKinect.Instance.KinectResolutionHeight);
            }
            else // Draw the depth frame feedback
            {
                short[] pixelDataDepth = null;

                // Get the datas pixel
                if (refDepthImage != null)
                {
                    pixelDataDepth = new short[refDepthImage.PixelDataLength];
                    refDepthImage.CopyPixelDataTo(pixelDataDepth);

                    if (m_refKinectInteraction != null)
                    {
                        lock (m_refKinectInteraction)
                        {
                            if (m_refKinectInteraction != null)
                            {
                                m_refKinectInteraction.ProcessDepth(refDepthImage.GetRawPixelData(), refDepthImage.Timestamp);
                            }
                        }
                    }
                }

                if (pixelDataDepth != null && PropertiesPluginKinect.Instance.EnableDepthFrameService)
                {
                    // If the skeleton feedback on depth frame is activated, draw skeleton on depth frame.
                    if (!PropertiesPluginKinect.Instance.EnableSkeletonOnColorDepth)
                    {
                        PropertiesPluginKinect.Instance.DepthFrame = Feedback.FeedbackDepthFrame(pixelDataDepth, PropertiesPluginKinect.Instance.KinectResolutionWidth, PropertiesPluginKinect.Instance.KinectResolutionHeight);
                    }
                    else // Draw only depth frame
                    {
                        PropertiesPluginKinect.Instance.DepthFrame = Feedback.FeedbackDepthFrameWithSkeleton(m_refKinectsensor, m_refListUsers.Values.ToList(), pixelDataDepth, PropertiesPluginKinect.Instance.KinectResolutionWidth, PropertiesPluginKinect.Instance.KinectResolutionHeight);
                    }
                }
            }
        }
 /// <summary>
 /// Handler for the Kinect sensor's DepthFrameReady event
 /// </summary>
 /// <param name="sender">object sending the event</param>
 /// <param name="depthImageFrameReadyEventArgs">event arguments</param>
 public void SensorDepthFrameReady(DepthImageFrame depthFrame)
 {
     if (null != depthFrame)
     {
         try
         {
             // Hand data to Interaction framework to be processed
             this.interactionStream.ProcessDepth(depthFrame.GetRawPixelData(), depthFrame.Timestamp);
         }
         catch (InvalidOperationException)
         {
             // DepthFrame functions may throw when the sensor gets
             // into a bad state.  Ignore the frame in that case.
         }
     }
 }