Example #1
0
 void runtime_DepthFrameReady(object sender, ImageFrameReadyEventArgs e)
 {
     Dispatcher.BeginInvoke(() =>
     {
         image2.Source = e.ImageFrame.ToBitmapSource();
     });
 }
Example #2
0
        private void KinectWatcherThreadProc(object data)
        {
            while (true)
            {
                WaitHandle.WaitAll(new WaitHandle[] { VideoStream.NextFrameReadyEvent, DepthStream.NextFrameReadyEvent }, 250);
                if (this.VideoStream != null && this.VideoFrameReady != null && VideoFrameReady.GetInvocationList().Length > 0)
                {
                    ImageFrameReadyEventArgs args = new ImageFrameReadyEventArgs();
                    ImageFrame frame = this.VideoStream.GetNextFrame();
                    if (frame != null)
                    {
                        args.ImageFrame = frame;
                        if (VideoFrameReady != null)
                        {
                            VideoFrameReady(this, args);
                        }
                    }
                }

                if (this.DepthStream != null && this.DepthFrameReady != null && DepthFrameReady.GetInvocationList().Length > 0)
                {
                    ImageFrameReadyEventArgs args = new ImageFrameReadyEventArgs();
                    ImageFrame frame = this.DepthStream.GetNextFrame();
                    if (frame != null)
                    {
                        args.ImageFrame = frame;
                        if (DepthFrameReady != null)
                        {
                            DepthFrameReady(this, args);
                        }
                    }
                }
            }
        }