public Main() { session = new Session(); for (int i = 0; i < 20; i++) { /*Binding in sideToolsViewModel in comments*/ jointsToObserve[i] = true; } try { //Initiate the FaceRecognition //FaceRecognition.init(); kinect = new KinectDevice(); if (isReady != null) { isReady(this, EventArgs.Empty); } faceRecognition = new EmotionRecognizer.FaceRecognition(); audioProvider = new AudioAnalysis.AudioProvider(kinect); } catch (System.InvalidOperationException e) { if (e.Source != null) { MessageBox.Show("aqui " + e.Message + " in :\n" + e.StackTrace + "\n\n", "System.InvalidOperationException"); } System.Environment.Exit(0); } catch (Exception) { new ErrorMessageBox("KinectError", "No Kinect plugged-in").ShowDialog(); System.Environment.Exit(0); } }
/// <summary> /// Updates the face tracking information for this skeleton /// </summary> internal void OnFrameReady(KinectSensor sensor, ColorImageFormat colorImageFormat, byte[] colorImage, DepthImageFormat depthImageFormat, short[] depthImage) { if (this.faceTracker == null) { try { this.faceTracker = new FaceTracker(sensor); } catch (InvalidOperationException) { // During some shutdown scenarios the FaceTracker // is unable to be instantiated. Catch that exception // and don't track a face. Debug.WriteLine("AllFramesReady - creating a new FaceTracker threw an InvalidOperationException"); this.faceTracker = null; } } if (this.faceTracker != null) { FaceTrackFrame frame = this.faceTracker.Track(colorImageFormat, colorImage, depthImageFormat, depthImage); this.lastFaceTrackSucceeded = frame.TrackSuccessful; if (this.lastFaceTrackSucceeded) { if (faceTriangles == null) { // only need to get this once. It doesn't change. faceTriangles = frame.GetTriangles(); } this.facePoints = frame.GetProjected3DShape(); this.facePoints3D = frame.Get3DShape(); //X-man modification this.AU = frame.GetAnimationUnitCoefficients(); } if (faceTriangles != null && facePoints != null) { faceUpdated(this, new FaceTrackerEventArgs(facePoints, faceTriangles)); } if (FaceRecognition.compare) { FaceRecognition.recognizer(this); } if (mouthOpened.detect) { mouthOpened.mouthRecognizer(); } if (mouthShut.detect) { mouthShut.mouth2Recognizer(); } if (lookingDirection.detect) { lookingDirection.lookRecognizer(); } if (pupilRight.detect) { pupilRight.pupilRecognizer(); } } }