public static WSRFaceRecognition GetInstance()
 {
     if (manager == null) {
     manager = new WSRFaceRecognition();
       }
       return manager;
 }
Beispiel #2
0
        protected void Init()
        {
            // 1. Setup all Streams
            WSRConfig.GetInstance().logInfo("KINECT", "Setup sensor stream");
            try {
                // Gesture Seated
                if (WSRConfig.GetInstance().IsSeated)
                {
                    Sensor.SkeletonStream.TrackingMode = SkeletonTrackingMode.Seated;
                }

                TransformSmoothParameters smoothingParam = new TransformSmoothParameters();
                smoothingParam.Smoothing          = 0.5f;
                smoothingParam.Correction         = 0.5f;
                smoothingParam.Prediction         = 0.5f;
                smoothingParam.JitterRadius       = 0.05f;
                smoothingParam.MaxDeviationRadius = 0.04f;

                // Speech only
                if (!WSRConfig.GetInstance().SpeechOnly)
                {
                    // Kinect for Windows
                    // Sensor.DepthStream.Range = DepthRange.Near;
                    // Sensor.SkeletonStream.EnableTrackingInNearRange = true;
                    Sensor.SkeletonStream.Enable(smoothingParam);
                    Sensor.ColorStream.Enable(ColorImageFormat.RgbResolution640x480Fps30);
                    Sensor.DepthStream.Enable(DepthImageFormat.Resolution320x240Fps30);

                    Sensor.AllFramesReady += KinectSensorOnAllFramesReady;
                }
            }
            catch (InvalidOperationException ex) { WSRConfig.GetInstance().logError("KINECT", ex); } // Device gone away just eat it.

            // 2. Start Sensor
            WSRConfig.GetInstance().logInfo("KINECT", "Start sensor");
            try { Sensor.Start(); }
            catch (IOException) {
                WSRConfig.GetInstance().logError("KINECT", "No Kinect Sensor: already used");
                Sensor = null; // Some other application is streaming from the same Kinect sensor
                return;
            }

            // Elevation angle +/- 27
            Sensor.ElevationAngle = WSRConfig.GetInstance().SensorElevation;

            // 3. Start periodical tasks
            if (!WSRConfig.GetInstance().SpeechOnly)
            {
                WSRConfig.GetInstance().logInfo("TASKS", "Start tasks");
                FaceManager = new WSRFaceRecognition();
                var dueTime = TimeSpan.FromSeconds(5);

                QRCodeSource  = new CancellationTokenSource();
                GestureSource = new CancellationTokenSource();
                ColorSource   = new CancellationTokenSource();
                FaceSource    = new CancellationTokenSource();
                MotionSource  = new CancellationTokenSource();


                MotionAsync(dueTime, WSRConfig.GetInstance().Motion, MotionSource.Token);
                QRCodeAsync(dueTime, WSRConfig.GetInstance().QRCode, QRCodeSource.Token); // 35%
                GestureAsync(dueTime, WSRConfig.GetInstance().Gesture, GestureSource.Token);
                ColorAsync(dueTime, WSRConfig.GetInstance().Color, ColorSource.Token);
                FaceDetectAsync(dueTime, WSRConfig.GetInstance().FaceDetec, FaceSource.Token); // 7% (15% => 27% - 32%) 56%
                FaceRecognitionAsync(dueTime, WSRConfig.GetInstance().FaceReco, FaceSource.Token);
                FaceTrackingAsync(dueTime, WSRConfig.GetInstance().FaceTrack, FaceSource.Token);
            }
        }
Beispiel #3
0
    protected void Init() {

      // 1. Setup all Streams
      WSRConfig.GetInstance().logInfo("KINECT", "Setup sensor stream");
      try {

        // Gesture Seated
        if (WSRConfig.GetInstance().IsSeated) {
          Sensor.SkeletonStream.TrackingMode = SkeletonTrackingMode.Seated;
        }

        TransformSmoothParameters smoothingParam = new TransformSmoothParameters();
        smoothingParam.Smoothing = 0.5f;
        smoothingParam.Correction = 0.5f;
        smoothingParam.Prediction = 0.5f;
        smoothingParam.JitterRadius = 0.05f;
        smoothingParam.MaxDeviationRadius = 0.04f;

        // Speech only
        if (!WSRConfig.GetInstance().SpeechOnly) {

          // Kinect for Windows
          // Sensor.DepthStream.Range = DepthRange.Near;
          // Sensor.SkeletonStream.EnableTrackingInNearRange = true;
          Sensor.SkeletonStream.Enable(smoothingParam);
          Sensor.ColorStream.Enable(ColorImageFormat.RgbResolution640x480Fps30);
          Sensor.DepthStream.Enable(DepthImageFormat.Resolution320x240Fps30);

          Sensor.AllFramesReady += KinectSensorOnAllFramesReady;
        }
      }
      catch (InvalidOperationException ex) { WSRConfig.GetInstance().logError("KINECT", ex); } // Device gone away just eat it.

      // 2. Start Sensor
      WSRConfig.GetInstance().logInfo("KINECT", "Start sensor");
      try { Sensor.Start(); }
      catch (IOException) {
        WSRConfig.GetInstance().logError("KINECT", "No Kinect Sensor: already used");
        Sensor = null;  // Some other application is streaming from the same Kinect sensor
        return;
      }
      
      // Elevation angle +/- 27
      Sensor.ElevationAngle = WSRConfig.GetInstance().SensorElevation;

      // 3. Start periodical tasks
      if (!WSRConfig.GetInstance().SpeechOnly) {
        WSRConfig.GetInstance().logInfo("TASKS", "Start tasks");
        FaceManager = new WSRFaceRecognition();
        var dueTime = TimeSpan.FromSeconds(5);

        QRCodeSource = new CancellationTokenSource();
        GestureSource = new CancellationTokenSource();
        ColorSource = new CancellationTokenSource();
        FaceSource = new CancellationTokenSource();
        MotionSource = new CancellationTokenSource();


        MotionAsync(dueTime, WSRConfig.GetInstance().Motion, MotionSource.Token);
        QRCodeAsync(dueTime, WSRConfig.GetInstance().QRCode, QRCodeSource.Token); // 35%
        GestureAsync(dueTime, WSRConfig.GetInstance().Gesture, GestureSource.Token);
        ColorAsync(dueTime, WSRConfig.GetInstance().Color, ColorSource.Token);
        FaceDetectAsync(dueTime, WSRConfig.GetInstance().FaceDetec, FaceSource.Token); // 7% (15% => 27% - 32%) 56%
        FaceRecognitionAsync(dueTime, WSRConfig.GetInstance().FaceReco, FaceSource.Token);
        FaceTrackingAsync(dueTime, WSRConfig.GetInstance().FaceTrack, FaceSource.Token);
      }
    }