Calculate eye pitch and yaw from DDE coefficients

This commit is contained in:
David Rowe 2015-07-16 10:48:21 -07:00
parent ba733f730b
commit 6b523ada2b
2 changed files with 23 additions and 0 deletions

View file

@ -157,6 +157,10 @@ DdeFaceTracker::DdeFaceTracker(const QHostAddress& host, quint16 serverPort, qui
_reset(false),
_leftBlinkIndex(0), // see http://support.faceshift.com/support/articles/35129-export-of-blendshapes
_rightBlinkIndex(1),
_leftEyeDownIndex(4),
_rightEyeDownIndex(5),
_leftEyeInIndex(6),
_rightEyeInIndex(7),
_leftEyeOpenIndex(8),
_rightEyeOpenIndex(9),
_browDownLeftIndex(14),
@ -173,6 +177,8 @@ DdeFaceTracker::DdeFaceTracker(const QHostAddress& host, quint16 serverPort, qui
_filteredHeadTranslation(glm::vec3(0.0f)),
_lastBrowUp(0.0f),
_filteredBrowUp(0.0f),
_eyeGazePitch(0.0f),
_eyeGazeYaw(0.0f),
_lastEyeBlinks(),
_filteredEyeBlinks(),
_lastEyeCoefficients(),
@ -436,6 +442,15 @@ void DdeFaceTracker::decodePacket(const QByteArray& buffer) {
_coefficients[_mouthSmileLeftIndex] = _coefficients[_mouthSmileLeftIndex] - SMILE_THRESHOLD;
_coefficients[_mouthSmileRightIndex] = _coefficients[_mouthSmileRightIndex] - SMILE_THRESHOLD;
// Eye pitch and yaw
// EyeDown coefficients work better over both +ve and -ve values than EyeUp values.
// EyeIn coefficients work better over both +ve and -ve values than EyeOut values.
// Confusingly, the sign of the EyeIn_R value is the same of EyeIn_L.
const float EYE_GAZE_PITCH_SCALE = -1500.0f; // Sign, scale, and average to be similar to Faceshift values.
_eyeGazePitch = EYE_GAZE_PITCH_SCALE * (_coefficients[_leftEyeDownIndex] + _coefficients[_rightEyeDownIndex]);
const float EYE_GAZE_YAW_SCALE = 2500.0f; // Scale and average to be similar to Faceshift values.
_eyeGazeYaw = EYE_GAZE_YAW_SCALE * (_coefficients[_leftEyeInIndex] + _coefficients[_rightEyeInIndex]);
// Velocity filter EyeBlink values
const float DDE_EYEBLINK_SCALE = 3.0f;
float eyeBlinks[] = { DDE_EYEBLINK_SCALE * _coefficients[_leftBlinkIndex],

View file

@ -93,6 +93,11 @@ private:
int _leftEyeOpenIndex;
int _rightEyeOpenIndex;
int _leftEyeDownIndex;
int _rightEyeDownIndex;
int _leftEyeInIndex;
int _rightEyeInIndex;
int _browDownLeftIndex;
int _browDownRightIndex;
int _browUpCenterIndex;
@ -115,6 +120,9 @@ private:
float _lastBrowUp;
float _filteredBrowUp;
float _eyeGazePitch; // Degrees
float _eyeGazeYaw;
enum EyeState {
EYE_UNCONTROLLED,
EYE_OPEN,