private void AddEventsForHand(List <IInputEvent> events, GestureSource hand,
                                      KinectPayload currentUserPayload, KinectPayload previousUserPayload)
        {
            KinectHandPayload handPayload         = currentUserPayload.HandPayloads.GetValue(hand);
            KinectHandPayload previousHandPayload = null;

            if (previousUserPayload != null)
            {
                previousHandPayload = previousUserPayload.HandPayloads.GetValue(hand);
            }

            if (handPayload != null)
            {
                events.Add(new MovementEvent(handPayload.Position,
                                             previousHandPayload == null
                                        ? handPayload.Position
                                        : previousHandPayload.Position - handPayload.Position));

                if (handPayload.PressExtent >= 1)
                {
                    events.Add(new GestureEvent(
                                   previousHandPayload == null ? GestureType.Activate :
                                   (previousHandPayload.PressExtent >= 1 ? GestureType.HoldActivate : GestureType.Activate),
                                   hand, handPayload.Position));
                }
            }
        }
Example #2
0
        public void Dispose()
        {
            if (Sensor == null)
            {
                return;
            }

            WSRConfig.GetInstance().logInfo("TASKS", "Stop Tasks");
            if (MotionSource != null)
            {
                MotionSource.Cancel();
            }
            if (QRCodeSource != null)
            {
                QRCodeSource.Cancel();
            }
            if (GestureSource != null)
            {
                GestureSource.Cancel();
            }
            if (ColorSource != null)
            {
                ColorSource.Cancel();
            }
            if (FaceSource != null)
            {
                FaceSource.Cancel();
            }

            if (Sensor == null)
            {
                return;
            }
            WSRConfig.GetInstance().logInfo("KINECT", "Stop Sensor");
            try {
                Sensor.AudioSource.Stop();
                Sensor.Stop();
            } catch (Exception) {}
        }
 /// <summary>
 /// Gets all events of the specified type
 /// </summary>
 /// <returns>A list of <see cref="IInputEvent"/>s</returns>
 public static IEnumerable <GestureEvent> GetGestures(this InputAggregator inputAggregator,
                                                      GestureType gestureType, GestureSource gestureSource = GestureSource.Left)
 {
     return(inputAggregator.GetEvents <GestureEvent>().Where(
                ev => (ev.Gesture & gestureType) != 0 && ev.Source == gestureSource));
 }
 /// <summary>
 /// Gets the first event of the specified type, or null if none exists
 /// </summary>
 /// <returns>An <see cref="IInputEvent"/> or null if none exists</returns>
 public static GestureEvent GetGesture(this InputAggregator inputAggregator,
                                       GestureType gestureType, GestureSource gestureSource = GestureSource.Left)
 {
     return(GetGestures(inputAggregator, gestureType, gestureSource).FirstOrDefault());
 }
Example #5
0
 public GestureEvent(GestureType type, GestureSource source, Vector2 position)
 {
     Gesture  = type;
     Location = position;
     Source   = source;
 }
Example #6
0
 public KinectHandPayload GetHandPayload(GestureSource source)
 {
     return(HandPayloads.GetValue(source));
 }