public static CustomGesturesHandler Instance() { if (_gestureHandler == null) { _gestureHandler = new CustomGesturesHandler(); } return(_gestureHandler); }
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()); } } } } }