Example #1
0
 public void HandleGestureComplete(Gesture gesture)
 {
     WSRHttpManager.GetInstance().SendRequest(gesture.Url);
 }
Example #2
0
 // ------------------------------------------
 //  Event
 // ------------------------------------------
 private void fireGesture(Gesture gesture)
 {
     ((WSRKinectMacro)WSRMacro.GetInstance()).HandleGestureComplete(gesture);
 }
Example #3
0
        public GestureState(Gesture gesture)
        {
            this.gesture = gesture;
              ComponentStates = new List<GestureComponentState>();

              foreach (var component in gesture.Components) {
            var state = new GestureComponentState(component);
            ComponentStates.Add(state);
              }

              IsExecuting = false;
        }
Example #4
0
        public void SensorSkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e)
        {
            using (SkeletonFrame skeletonFrameData = e.OpenSkeletonFrame()) {
            if (skeletonFrameData == null) {
              return;
            }

            var allSkeletons = new Skeleton[skeletonFrameData.SkeletonArrayLength];
            skeletonFrameData.CopySkeletonDataTo(allSkeletons);

            foreach (Skeleton sd in allSkeletons) {

              // If this skeleton is no longer being tracked, skip it
              if (sd.TrackingState != SkeletonTrackingState.Tracked) {
            continue;
              }

              // If there is not already a gesture state map for this skeleton, then create one
              if (!userMap.ContainsKey(sd.TrackingId)) {
            var user = new GestureStateUser(gestures);
            userMap.Add(sd.TrackingId, user);
              }

              // WSRConfig.GetInstance().logDebug("GESTURE", "Skeleton " + sd.Position.X + "," + sd.Position.Y + "," + sd.Position.Z);
              Gesture gesture = userMap[sd.TrackingId].Evaluate(sd);
              if (gesture != null) {
            WSRConfig.GetInstance().logInfo("GESTURE", "Active User Gesture complete: " + gesture.Description);

            // Store the Gesture matching the most components
            if (match == null || match.Components.Count <= gesture.Components.Count) {
              match = gesture;
            }

            // Do not fire immediatly, wait a little bit
              }

              // This break prevents multiple player data from being confused during evaluation.
              // If one were going to dis-allow multiple players, this trackingId would facilitate
              // that feat.
              playerId = sd.TrackingId;
            }
              }

              // Reset threshold
              if ((DateTime.Now - threshold).TotalMilliseconds > 1000){
            threshold = DateTime.Now;

            // Fire the latest matching gesture on threshold
            if (match != null) {
              fireGesture(match);
              userMap[playerId].ResetAll();
              match = null;
            }
              }
        }
Example #5
0
        // ------------------------------------------
        //  Parser
        // ------------------------------------------
        public static Gesture Parse(XmlTextReader reader)
        {
            var description = reader.GetAttribute("description");
              var maxexecutiontime = reader.GetAttribute("maxExecutionTime") ?? "0";
              var url = reader.GetAttribute("url");

              var gesture  = new Gesture(description, Convert.ToInt32(maxexecutiontime));
              gesture.Url = url;

              return gesture;
        }
Example #6
0
    protected Gesture MatchGesture() {
      
      // Wait for a given amount of time
      if ((DateTime.Now - Threshold).TotalMilliseconds < 1000) { return null; }

      // Reset threashold
      Threshold = DateTime.Now;

      if (Skeleton != null && userMap.ContainsKey("P_" + Skeleton.TrackingId)) {
        userMap["P_"+Skeleton.TrackingId].ResetAll();
      }

      // No match
      Gesture g = match;
      if (null == g){ return null; }

      // Clean and match
      match = null;
      return g;
    }
Example #7
0
    public Gesture CheckGestures(Skeleton[] skeletons) {

      // Clean Prefetch
      Skeleton = null;

      if (null == skeletons) { return null; }
      foreach (Skeleton sd in skeletons) {

        // Too large array
        if (sd == null) { continue; }

        // If this skeleton is no longer being tracked, skip it
        if (sd.TrackingState != SkeletonTrackingState.Tracked) {
          continue;
        }

        // Prefetch some 
        Prefetch(sd);

        // Validate all joints some data
        if (!Viewport(sd)) { continue; }
        Skeleton = sd;

        // If there is not already a gesture state map for this skeleton, then create one
        if (!userMap.ContainsKey("P_"+sd.TrackingId)) {
          var user = new GestureStateUser(gestures);
          userMap.Add("P_"+sd.TrackingId, user);
        }


        Gesture gesture = userMap["P_" + sd.TrackingId].Evaluate(sd);
        if (null != gesture) {

          // Store the Gesture matching the most components
          if (match == null || match.Components.Count <= gesture.Components.Count) {
            match = gesture;
          }

          // Do not fire immediatly, wait a little bit
          Gesture g = MatchGesture();
          if (g != null) { return g; }
        }

        break; // The skeleton match
      }

      // At last return gesture or null
      return MatchGesture();
    }
Example #8
0
 // ------------------------------------------
 //  Event
 // ------------------------------------------
 private void fireGesture(Gesture gesture)
 {
     ((WSRKinect)WSRConfig.GetInstance().GetWSRMicro()).HandleGestureComplete(gesture);
 }