/** This method is called every frame. * * It fetches the tracking data from the tracker and transforms controlled objects accordingly. * It also fetches vertex, triangle and texture coordinate data to generate 3D face model from the tracker. * And lastly it refreshes the video frame texture with the new frame data. * */ void Update() { if (Input.GetKeyDown(KeyCode.Escape)) { Application.Quit(); } #if (UNITY_IPHONE || UNITY_ANDROID) && UNITY_EDITOR // no tracking on ios while in editor return; #endif // update tracker status, translation and rotation int trackStatus; if (isTracking) { currentOrientation = getDeviceOrientation(); // check if orientation or camera device changed if (currentOrientation != Orientation || currentDevice != device) { OpenCamera(currentOrientation, currentDevice, defaultCameraWidth, defaultCameraHeight, isMirrored); Orientation = currentOrientation; device = currentDevice; Frame = null; } // grab new frame and start face tracking on it VisageTrackerNative._grabFrame(); trackStatus = VisageTrackerNative._track(); VisageTrackerNative._get3DData(out Translation.x, out Translation.y, out Translation.z, out Rotation.x, out Rotation.y, out Rotation.z); TrackerStatus = (TrackStatus)trackStatus; // isTracking = TrackerStatus != 0; } // exit if no tracking if (TrackerStatus == TrackStatus.Off) { return; } // set correct camera field of view GetCameraInfo(); #if UNITY_ANDROID //waiting to get information about frame width and height if (ImageWidth == 0 || ImageHeight == 0) { return; } #endif // update gaze direction float[] gazeDirection = new float[2]; VisageTrackerNative._getGazeDirection(gazeDirection); GazeDirection = new Vector2(gazeDirection [0] * Mathf.Rad2Deg, gazeDirection [1] * Mathf.Rad2Deg); // get image RefreshImage(); // get action units if (ActionUnitsEnabled) { RefreshActionUnits(); } }