Esempio n. 1
0
        void kinectRuntime_AllFrameReady(object sender, AllFramesReadyEventArgs e)
        {
            // If replaying, bypass this.
            if (replay != null && !replay.IsFinished)
            {
                return;
            }

            using (var cf = e.OpenColorImageFrame())
                using (var df = e.OpenDepthImageFrame())
                    using (var sf = e.OpenSkeletonFrame()) {
                        try {
                            if (recorder != null && sf != null && df != null && cf != null)
                            {
                                recorder.Record(sf, df, cf);
                            }
                        } catch (ObjectDisposedException) { }

                        if (cf != null)
                        {
                            colorManager.Update(cf, !displayDebug);
                        }

                        if (df != null)
                        {
                            depthFrameNumber = df.FrameNumber;
                            depthManager.Update(df);
                        }

                        if (sf != null)
                        {
                            UpdateSkeletonDisplay(sf);
                            if (handTracker != null && recogEngine != null)
                            {
                                var result = handTracker.Update(depthManager.PixelData, colorManager.PixelData,
                                                                SkeletonUtil.FirstTrackedSkeleton(sf.GetSkeletons()));
                                var gesture = recogEngine.Update(result);
                                lock (inputServer)
                                    inputServer.Send(gesture);
                                UpdateDisplay(result);
                                textGestureEvent.Text = gesture;
                                fpsCounter.LogFPS();
                            }
                        }
                    }
        }