示例#1
0
        /// <summary>
        /// Fizbin gestures callback.
        /// </summary>
        /// <param name="gestureType">The gesture type</param>
        /// <param name="trackingID">The tracking ID</param>
        void KinectGestureGenerator_GestureRecognized(GestureType gestureType, int trackingID)
        {
            //This will call the KinectInfo constructor,
            //And then assign gestureType string to Gesture property.
            ServerMessage kinectInfo = new ServerMessage()
            {
                Gesture = gestureType.ToString()
            };

            Webserver.SendToClients(kinectInfo.ToJSON());
        }
示例#2
0
        void Kinect_SkeletonFrameReady(object sender, Microsoft.Kinect.SkeletonFrameReadyEventArgs e)
        {
            ServerMessage info = new ServerMessage();

            info.X          = KinectCursorVisualizer.CurrentXPosition;
            info.Y          = KinectCursorVisualizer.CurrentYPosition;
            info.PressLevel = KinectCursorVisualizer.CurrentPressLevel;
            Console.WriteLine("{0} {1}", info.X, info.Y);
            if (info.X > 0 && info.Y > 0)
            {
                Webserver.SendToClients(info.ToJSON());
            }

            Skeleton[] skeletons = new Skeleton[0];

            using (SkeletonFrame skeletonFrame = e.OpenSkeletonFrame())
            {
                if (skeletonFrame != null)
                {
                    skeletons = new Skeleton[skeletonFrame.SkeletonArrayLength];
                    skeletonFrame.CopySkeletonDataTo(skeletons);
                }
            }

            foreach (Skeleton skeleton in skeletons)
            {
                if (skeleton.TrackingState == SkeletonTrackingState.Tracked)
                {
                    foreach (CustomGesture gesture in CustomGesturesHandler.Instance().Gestures)
                    {
                        if (gesture.Check(skeleton))
                        {
                            ServerMessage gestureInfo = new ServerMessage();
                            gestureInfo.Gesture = gesture.Name;
                            Webserver.SendToClients(gestureInfo.ToJSON());
                        }
                    }
                }
            }
        }