예제 #1
0
        private async Task GestureAsync(TimeSpan dueTime, TimeSpan interval, CancellationToken token)
        {
            if (interval.TotalMilliseconds == 0)
            {
                return;
            }
            Stopwatch GestureTH = new Stopwatch();

            GestureTH.Start();

            // Initial wait time before we begin the periodic loop.
            if (dueTime > TimeSpan.Zero)
            {
                await Task.Delay(dueTime, token);
            }

            DateTime LocalTimestamp = Timestamp;

            if (null == GestureManager)
            {
                GestureManager = new GestureManager(this);
                GestureManager.Load();
            }

            // Repeat this loop until cancelled.
            while (!token.IsCancellationRequested)
            {
                // Skip already work with given data
                if (Timestamp == LocalTimestamp)
                {
                    await Task.Delay(interval, token);

                    continue;
                }

                if (WSRConfig.GetInstance().StandByGesture)
                {
                    await Task.Delay(interval, token);

                    continue;
                }

                // Timestamp data
                LocalTimestamp = Timestamp;
                GestureWatch.Again();

                // Do Job
                try {
                    CopySkeletons = true;
                    Gesture gesture = GestureManager.CheckGestures(Skeletons);
                    if (null != gesture && GestureTH.Elapsed > WSRConfig.GetInstance().GestureTH)
                    {
                        WSRHttpManager.GetInstance().SendRequest(gesture.Url);
                        GestureTH.Restart();
                    }
                }
                catch (Exception ex) {
                    WSRConfig.GetInstance().logError("GESTURE", ex);
                }
                GestureWatch.Stop();

                // Wait to repeat again.
                if (interval > TimeSpan.Zero)
                {
                    await Task.Delay(interval, token);
                }
            }
        }
예제 #2
0
        public void SetupSkeletonFrame(KinectSensor sensor)
        {
            if (!WSRConfig.GetInstance().IsGestureMode()) {
            return;
              }

              // Build Gesture Manager
              gestureMgr = new GestureManager();

              // Load Gestures from directories
              foreach (string directory in WSRConfig.GetInstance().directories) {
            DirectoryInfo d = new DirectoryInfo(directory);
            gestureMgr.LoadGestures(d);
              }

              // Plugin in Kinect Sensor
              logInfo("KINECT", "Starting Skeleton sensor");
              // sensor.SkeletonStream.TrackingMode = SkeletonTrackingMode.Seated;
              sensor.SkeletonStream.Enable();
        }
예제 #3
0
    private async Task GestureAsync(TimeSpan dueTime, TimeSpan interval, CancellationToken token) {

      if (interval.TotalMilliseconds == 0)  return;
      Stopwatch GestureTH = new Stopwatch();
      GestureTH.Start();

      // Initial wait time before we begin the periodic loop.
      if (dueTime > TimeSpan.Zero)
        await Task.Delay(dueTime, token);

      DateTime LocalTimestamp = Timestamp;
      
      if (null == GestureManager) {
        GestureManager = new GestureManager(this);
        GestureManager.Load();
      }

      // Repeat this loop until cancelled.
      while (!token.IsCancellationRequested) {

        // Skip already work with given data
        if (Timestamp == LocalTimestamp) {
          await Task.Delay(interval, token);
          continue;
        }

        if (WSRConfig.GetInstance().StandByGesture) {
          await Task.Delay(interval, token);
          continue;
        }

        // Timestamp data
        LocalTimestamp = Timestamp;
        GestureWatch.Again();

        // Do Job
        try {
          CopySkeletons = true;
          Gesture gesture = GestureManager.CheckGestures(Skeletons);
          if (null != gesture && GestureTH.Elapsed > WSRConfig.GetInstance().GestureTH) {
            WSRHttpManager.GetInstance().SendRequest(gesture.Url);
            GestureTH.Restart();
          }
        }
        catch (Exception ex) {
          WSRConfig.GetInstance().logError("GESTURE", ex);
        }
        GestureWatch.Stop();

        // Wait to repeat again.
        if (interval > TimeSpan.Zero)
          await Task.Delay(interval, token);
      }
    }