/// <summary> /// Initializes a new instance of the MainWindow class /// </summary> public MainWindow() { KinectSensor kinectSensor = null; FaceTimer.Interval = new TimeSpan(0, 0, 1); FaceTimer.Tick += new EventHandler(FaceTimer_Tick); // loop through all the Kinects attached to this PC, and start the first that is connected without an error. foreach (KinectSensor kinect in KinectSensor.KinectSensors) { if (kinect.Status == KinectStatus.Connected) { kinectSensor = kinect; break; } } if (kinectSensor == null) { MessageBox.Show("No Kinect found..."); Application.Current.Shutdown(); return; } kinectSensor.SkeletonStream.Enable(); kinectSensor.ColorStream.Enable(ColorImageFormat.RgbResolution640x480Fps30); kinectSensor.DepthStream.Enable(DepthImageFormat.Resolution640x480Fps30); kinectSensor.Start(); AllFramesReadyFrameSource frameSource = new AllFramesReadyFrameSource(kinectSensor); this.engine = new KinectFacialRecognitionEngine(kinectSensor, frameSource); this.engine.RecognitionComplete += this.Engine_RecognitionComplete; this.InitializeComponent(); ArmButton.Background = System.Windows.Media.Brushes.Blue; this.TrainedFaces.ItemsSource = this.targetFaces; }
/// <summary> /// Loads the correct procesor based on the selected radio button /// </summary> private void LoadProcessor() { if (this.viewModel.ProcessorType == ProcessorTypes.FaceModel) { this.activeProcessor = new FaceModelRecognitionProcessor(); } else { this.activeProcessor = new EigenObjectRecognitionProcessor(); } this.LoadAllTargetFaces(); this.UpdateTargetFaces(); if (this.engine == null) { this.engine = new KinectFacialRecognitionEngine(this.kinectSensor, this.activeProcessor); this.engine.RecognitionComplete += this.Engine_RecognitionComplete; } this.engine.Processors = new List <IRecognitionProcessor> { this.activeProcessor }; }