fix: update code style to conform to hifi convention

This commit is contained in:
Zu 2014-07-30 09:30:55 +08:00
parent dcd7b81426
commit 113a173577
2 changed files with 125 additions and 138 deletions

View file

@ -30,32 +30,38 @@ static const glm::vec3 DEFAULT_HEAD_ORIGIN(0.0f, 0.0f, 0.0f);
static const float TRANSLATION_SCALE = 1.0f; static const float TRANSLATION_SCALE = 1.0f;
static const int NUM_BLENDSHAPE_COEFF = 30; static const int NUM_BLENDSHAPE_COEFF = 30;
struct CaraPerson struct CaraPerson {
{ struct CaraPose {
struct CaraPose
{
float roll, pitch, yaw; float roll, pitch, yaw;
CaraPose(): roll(0.0f), pitch(0.0f), yaw(0.0f) {} CaraPose() :
roll(0.0f),
pitch(0.0f),
yaw(0.0f)
{
}
}; };
struct CaraEmotion struct CaraEmotion {
{
float smile, surprise, negative, attention; float smile, surprise, negative, attention;
CaraEmotion(): smile(0.0f), surprise(0.0f), negative(0.0f), attention(0.0f) {} CaraEmotion():
smile(0.0f),
surprise(0.0f),
negative(0.0f),
attention(0.0f)
{
}
}; };
enum CaraBlink enum CaraBlink {
{
BLINK_NOT_AVAILABLE, BLINK_NOT_AVAILABLE,
NO_BLINK, NO_BLINK,
BLINK BLINK
}; };
CaraPerson(): CaraPerson() :
id(-1), id(-1),
blink(BLINK_NOT_AVAILABLE) blink(BLINK_NOT_AVAILABLE)
{ {
} }
int id; int id;
@ -63,8 +69,7 @@ struct CaraPerson
CaraEmotion emotion; CaraEmotion emotion;
CaraBlink blink; CaraBlink blink;
QString toString() QString toString() {
{
QString s = QString("id: %1, roll: %2, pitch: %3, yaw: %4, smi: %5, sur: %6, neg: %7, att: %8, blink: %9"). QString s = QString("id: %1, roll: %2, pitch: %3, yaw: %4, smi: %5, sur: %6, neg: %7, att: %8, blink: %9").
arg(id). arg(id).
arg(pose.roll). arg(pose.roll).
@ -75,42 +80,35 @@ struct CaraPerson
arg(emotion.negative). arg(emotion.negative).
arg(emotion.attention). arg(emotion.attention).
arg(blink); arg(blink);
return s; return s;
} }
}; };
class CaraPacketDecoder class CaraPacketDecoder {
{
public: public:
static CaraPerson extractOne(const QByteArray& buffer, QJsonParseError* jsonError) static CaraPerson extractOne(const QByteArray& buffer, QJsonParseError* jsonError) {
{
CaraPerson person; CaraPerson person;
QJsonDocument dom = QJsonDocument::fromJson(buffer, jsonError); QJsonDocument dom = QJsonDocument::fromJson(buffer, jsonError);
//check for errors //check for errors
if(jsonError->error == QJsonParseError::NoError) if(jsonError->error == QJsonParseError::NoError) {
{
//read the dom structure and populate the blend shapes and head poses //read the dom structure and populate the blend shapes and head poses
//qDebug() << "[Info] Cara Face Tracker Packet Parsing Successful!"; //qDebug() << "[Info] Cara Face Tracker Packet Parsing Successful!";
//begin extracting the packet //begin extracting the packet
if(dom.isArray()) if(dom.isArray()) {
{ QJsonArray people = dom.array();
QJsonArray people = dom.array(); //extract the first person in the array
if(people.size() > 0) //extract the first person in the array if(people.size() > 0) {
{
QJsonValue val = people.at(0); QJsonValue val = people.at(0);
if(val.isObject()) if(val.isObject()) {
{
QJsonObject personDOM = val.toObject(); QJsonObject personDOM = val.toObject();
person.id = extractId(personDOM); person.id = extractId(personDOM);
person.pose = extractPose(personDOM); person.pose = extractPose(personDOM);
//extract the classifier outputs //extract the classifier outputs
QJsonObject::const_iterator it = personDOM.constFind("classifiers"); QJsonObject::const_iterator it = personDOM.constFind("classifiers");
if(it != personDOM.constEnd()) if(it != personDOM.constEnd()) {
{
QJsonObject classifierDOM = (*it).toObject(); QJsonObject classifierDOM = (*it).toObject();
person.emotion = extractEmotion(classifierDOM); person.emotion = extractEmotion(classifierDOM);
person.blink = extractBlink(classifierDOM); person.blink = extractBlink(classifierDOM);
@ -124,90 +122,85 @@ public:
} }
private: private:
static int extractId(const QJsonObject& person) static int extractId(const QJsonObject& person) {
{
int id = -1; int id = -1;
QJsonObject::const_iterator it = person.constFind("id"); QJsonObject::const_iterator it = person.constFind("id");
if(it != person.constEnd()) if(it != person.constEnd()) {
id = (*it).toInt(-1); id = (*it).toInt(-1);
}
return id; return id;
} }
static CaraPerson::CaraPose extractPose(const QJsonObject& person) static CaraPerson::CaraPose extractPose(const QJsonObject& person) {
{
CaraPerson::CaraPose pose; CaraPerson::CaraPose pose;
QJsonObject::const_iterator it = person.constFind("pose"); QJsonObject::const_iterator it = person.constFind("pose");
if(it != person.constEnd()) if(it != person.constEnd()) {
{
QJsonObject poseDOM = (*it).toObject(); QJsonObject poseDOM = (*it).toObject();
//look for the roll, pitch, yaw; //look for the roll, pitch, yaw;
QJsonObject::const_iterator poseIt = poseDOM.constFind("roll"); QJsonObject::const_iterator poseIt = poseDOM.constFind("roll");
QJsonObject::const_iterator poseEnd = poseDOM.constEnd(); QJsonObject::const_iterator poseEnd = poseDOM.constEnd();
if(poseIt != poseEnd) if(poseIt != poseEnd) {
pose.roll = (float)(*poseIt).toDouble(0.0); pose.roll = (float)(*poseIt).toDouble(0.0);
}
poseIt = poseDOM.constFind("pitch"); poseIt = poseDOM.constFind("pitch");
if(poseIt != poseEnd) if(poseIt != poseEnd) {
pose.pitch = (float)(*poseIt).toDouble(0.0); pose.pitch = (float)(*poseIt).toDouble(0.0);
}
poseIt = poseDOM.constFind("yaw"); poseIt = poseDOM.constFind("yaw");
if(poseIt != poseEnd) if(poseIt != poseEnd) {
pose.yaw = (float)(*poseIt).toDouble(0.0); pose.yaw = (float)(*poseIt).toDouble(0.0);
}
} }
return pose; return pose;
} }
static CaraPerson::CaraEmotion extractEmotion(const QJsonObject& classifiers) static CaraPerson::CaraEmotion extractEmotion(const QJsonObject& classifiers) {
{
CaraPerson::CaraEmotion emotion; CaraPerson::CaraEmotion emotion;
QJsonObject::const_iterator it = classifiers.constFind("emotion"); QJsonObject::const_iterator it = classifiers.constFind("emotion");
if(it != classifiers.constEnd()) if(it != classifiers.constEnd()) {
{
QJsonObject emotionDOM = (*it).toObject(); QJsonObject emotionDOM = (*it).toObject();
//look for smile, surprise, negative, attention responses //look for smile, surprise, negative, attention responses
QJsonObject::const_iterator emoEnd = emotionDOM.constEnd(); QJsonObject::const_iterator emoEnd = emotionDOM.constEnd();
QJsonObject::const_iterator emoIt = emotionDOM.constFind("smi"); QJsonObject::const_iterator emoIt = emotionDOM.constFind("smi");
if(emoIt != emoEnd) if(emoIt != emoEnd) {
emotion.smile = (float)(*emoIt).toDouble(0.0); emotion.smile = (float)(*emoIt).toDouble(0.0);
}
emoIt = emotionDOM.constFind("sur"); emoIt = emotionDOM.constFind("sur");
if(emoIt != emoEnd) if(emoIt != emoEnd) {
emotion.surprise = (float)(*emoIt).toDouble(0.0); emotion.surprise = (float)(*emoIt).toDouble(0.0);
}
emoIt = emotionDOM.constFind("neg"); emoIt = emotionDOM.constFind("neg");
if(emoIt != emoEnd) if(emoIt != emoEnd) {
emotion.negative = (float)(*emoIt).toDouble(0.0); emotion.negative = (float)(*emoIt).toDouble(0.0);
}
emoIt = emotionDOM.constFind("att"); emoIt = emotionDOM.constFind("att");
if(emoIt != emoEnd) if(emoIt != emoEnd) {
emotion.attention = (float)(*emoIt).toDouble(0.0); emotion.attention = (float)(*emoIt).toDouble(0.0);
}
} }
return emotion; return emotion;
} }
static CaraPerson::CaraBlink extractBlink(const QJsonObject& classifiers) static CaraPerson::CaraBlink extractBlink(const QJsonObject& classifiers) {
{
CaraPerson::CaraBlink blink = CaraPerson::BLINK_NOT_AVAILABLE; CaraPerson::CaraBlink blink = CaraPerson::BLINK_NOT_AVAILABLE;
QJsonObject::const_iterator it = classifiers.constFind("blink"); QJsonObject::const_iterator it = classifiers.constFind("blink");
if(it != classifiers.constEnd()) if(it != classifiers.constEnd()) {
{
int b = (*it).toInt(CaraPerson::BLINK_NOT_AVAILABLE); int b = (*it).toInt(CaraPerson::BLINK_NOT_AVAILABLE);
switch(b) switch(b) {
{ case CaraPerson::BLINK_NOT_AVAILABLE:
case CaraPerson::BLINK_NOT_AVAILABLE: blink = CaraPerson::BLINK_NOT_AVAILABLE;
blink = CaraPerson::BLINK_NOT_AVAILABLE; break;
break; case CaraPerson::NO_BLINK:
case CaraPerson::NO_BLINK: blink = CaraPerson::NO_BLINK;
blink = CaraPerson::NO_BLINK; break;
break; case CaraPerson::BLINK:
case CaraPerson::BLINK: blink = CaraPerson::BLINK;
blink = CaraPerson::BLINK; break;
break; default:
default: blink = CaraPerson::BLINK_NOT_AVAILABLE;
blink = CaraPerson::BLINK_NOT_AVAILABLE; break;
break;
} }
} }
return blink; return blink;
@ -219,9 +212,9 @@ CaraFaceTracker::CaraFaceTracker() :
_previousPitch(0.0f), _previousPitch(0.0f),
_previousYaw(0.0f), _previousYaw(0.0f),
_previousRoll(0.0f), _previousRoll(0.0f),
_eyeGazeLeftPitch(0), _eyeGazeLeftPitch(0.0f),
_eyeGazeLeftYaw(0), _eyeGazeLeftYaw(0.0f),
_eyeGazeRightPitch(0), _eyeGazeRightPitch(0.0f),
_eyeGazeRightYaw(0), _eyeGazeRightYaw(0),
_leftBlinkIndex(0), _leftBlinkIndex(0),
_rightBlinkIndex(1), _rightBlinkIndex(1),
@ -234,7 +227,7 @@ CaraFaceTracker::CaraFaceTracker() :
_browUpRightIndex(18), _browUpRightIndex(18),
_mouthSmileLeftIndex(28), _mouthSmileLeftIndex(28),
_mouthSmileRightIndex(29), _mouthSmileRightIndex(29),
_jawOpenIndex(21) _jawOpenIndex(21)
{ {
connect(&_udpSocket, SIGNAL(readyRead()), SLOT(readPendingDatagrams())); connect(&_udpSocket, SIGNAL(readyRead()), SLOT(readPendingDatagrams()));
connect(&_udpSocket, SIGNAL(error(QAbstractSocket::SocketError)), SLOT(socketErrorOccurred(QAbstractSocket::SocketError))); connect(&_udpSocket, SIGNAL(error(QAbstractSocket::SocketError)), SLOT(socketErrorOccurred(QAbstractSocket::SocketError)));
@ -254,10 +247,10 @@ CaraFaceTracker::CaraFaceTracker(const QHostAddress& host, quint16 port) :
_previousPitch(0.0f), _previousPitch(0.0f),
_previousYaw(0.0f), _previousYaw(0.0f),
_previousRoll(0.0f), _previousRoll(0.0f),
_eyeGazeLeftPitch(0), _eyeGazeLeftPitch(0.0f),
_eyeGazeLeftYaw(0), _eyeGazeLeftYaw(0.0f),
_eyeGazeRightPitch(0), _eyeGazeRightPitch(0.0f),
_eyeGazeRightYaw(0), _eyeGazeRightYaw(0.0f),
_leftBlinkIndex(0), _leftBlinkIndex(0),
_rightBlinkIndex(1), _rightBlinkIndex(1),
_leftEyeOpenIndex(8), _leftEyeOpenIndex(8),
@ -269,7 +262,7 @@ CaraFaceTracker::CaraFaceTracker(const QHostAddress& host, quint16 port) :
_browUpRightIndex(18), _browUpRightIndex(18),
_mouthSmileLeftIndex(28), _mouthSmileLeftIndex(28),
_mouthSmileRightIndex(29), _mouthSmileRightIndex(29),
_jawOpenIndex(21) _jawOpenIndex(21)
{ {
connect(&_udpSocket, SIGNAL(readyRead()), SLOT(readPendingDatagrams())); connect(&_udpSocket, SIGNAL(readyRead()), SLOT(readPendingDatagrams()));
connect(&_udpSocket, SIGNAL(error(QAbstractSocket::SocketError)), SLOT(socketErrorOccurred(QAbstractSocket::SocketError))); connect(&_udpSocket, SIGNAL(error(QAbstractSocket::SocketError)), SLOT(socketErrorOccurred(QAbstractSocket::SocketError)));
@ -282,42 +275,36 @@ CaraFaceTracker::CaraFaceTracker(const QHostAddress& host, quint16 port) :
_blendshapeCoefficients.fill(0.0f); _blendshapeCoefficients.fill(0.0f);
} }
CaraFaceTracker::~CaraFaceTracker() CaraFaceTracker::~CaraFaceTracker() {
{
if(_udpSocket.isOpen()) if(_udpSocket.isOpen())
_udpSocket.close(); _udpSocket.close();
} }
void CaraFaceTracker::init() void CaraFaceTracker::init() {
{
} }
void CaraFaceTracker::reset() void CaraFaceTracker::reset() {
{
} }
void CaraFaceTracker::bindTo(quint16 port) void CaraFaceTracker::bindTo(quint16 port) {
{
bindTo(QHostAddress::Any, port); bindTo(QHostAddress::Any, port);
} }
void CaraFaceTracker::bindTo(const QHostAddress& host, quint16 port) void CaraFaceTracker::bindTo(const QHostAddress& host, quint16 port) {
{ if(_udpSocket.isOpen()) {
if(_udpSocket.isOpen())
_udpSocket.close(); _udpSocket.close();
}
_udpSocket.bind(host, port); _udpSocket.bind(host, port);
} }
bool CaraFaceTracker::isActive() const bool CaraFaceTracker::isActive() const {
{
static const int ACTIVE_TIMEOUT_USECS = 3000000; //3 secs static const int ACTIVE_TIMEOUT_USECS = 3000000; //3 secs
return (usecTimestampNow() - _lastReceiveTimestamp < ACTIVE_TIMEOUT_USECS); return (usecTimestampNow() - _lastReceiveTimestamp < ACTIVE_TIMEOUT_USECS);
} }
void CaraFaceTracker::update() void CaraFaceTracker::update() {
{
// get the euler angles relative to the window // get the euler angles relative to the window
glm::vec3 eulers = glm::degrees(safeEulerAngles(_headRotation * glm::quat(glm::radians(glm::vec3( glm::vec3 eulers = glm::degrees(safeEulerAngles(_headRotation * glm::quat(glm::radians(glm::vec3(
(_eyeGazeLeftPitch + _eyeGazeRightPitch) / 2.0f, (_eyeGazeLeftYaw + _eyeGazeRightYaw) / 2.0f, 0.0f))))); (_eyeGazeLeftPitch + _eyeGazeRightPitch) / 2.0f, (_eyeGazeLeftYaw + _eyeGazeRightYaw) / 2.0f, 0.0f)))));
@ -329,36 +316,39 @@ void CaraFaceTracker::update()
} }
//private slots and methods //private slots and methods
void CaraFaceTracker::socketErrorOccurred(QAbstractSocket::SocketError socketError) void CaraFaceTracker::socketErrorOccurred(QAbstractSocket::SocketError socketError) {
{
qDebug() << "[Error] Cara Face Tracker Socket Error: " << _udpSocket.errorString(); qDebug() << "[Error] Cara Face Tracker Socket Error: " << _udpSocket.errorString();
} }
void CaraFaceTracker::socketStateChanged(QAbstractSocket::SocketState socketState) void CaraFaceTracker::socketStateChanged(QAbstractSocket::SocketState socketState) {
{
QString state; QString state;
switch(socketState) switch(socketState) {
{ case QAbstractSocket::BoundState:
case QAbstractSocket::BoundState: state = "Bounded"; state = "Bounded";
break; break;
case QAbstractSocket::ClosingState: state = "Closing"; case QAbstractSocket::ClosingState:
break; state = "Closing";
case QAbstractSocket::ConnectedState: state = "Connected"; break;
break; case QAbstractSocket::ConnectedState:
case QAbstractSocket::ConnectingState: state = "Connecting"; state = "Connected";
break; break;
case QAbstractSocket::HostLookupState: state = "Host Lookup"; case QAbstractSocket::ConnectingState:
break; state = "Connecting";
case QAbstractSocket::ListeningState: state = "Listening"; break;
break; case QAbstractSocket::HostLookupState:
case QAbstractSocket::UnconnectedState: state = "Unconnected"; state = "Host Lookup";
break; break;
case QAbstractSocket::ListeningState:
state = "Listening";
break;
case QAbstractSocket::UnconnectedState:
state = "Unconnected";
break;
} }
qDebug() << "[Info] Cara Face Tracker Socket: " << socketState; qDebug() << "[Info] Cara Face Tracker Socket: " << socketState;
} }
void CaraFaceTracker::readPendingDatagrams() void CaraFaceTracker::readPendingDatagrams() {
{
QByteArray buffer; QByteArray buffer;
while (_udpSocket.hasPendingDatagrams()) { while (_udpSocket.hasPendingDatagrams()) {
buffer.resize(_udpSocket.pendingDatagramSize()); buffer.resize(_udpSocket.pendingDatagramSize());
@ -367,14 +357,12 @@ void CaraFaceTracker::readPendingDatagrams()
} }
} }
void CaraFaceTracker::decodePacket(const QByteArray& buffer) void CaraFaceTracker::decodePacket(const QByteArray& buffer) {
{
//decode the incoming udp packet //decode the incoming udp packet
QJsonParseError jsonError; QJsonParseError jsonError;
CaraPerson person = CaraPacketDecoder::extractOne(buffer, &jsonError); CaraPerson person = CaraPacketDecoder::extractOne(buffer, &jsonError);
if(jsonError.error == QJsonParseError::NoError) if(jsonError.error == QJsonParseError::NoError) {
{
//do some noise filtering to the head poses //do some noise filtering to the head poses
//reduce the noise first by truncating to 1 dp //reduce the noise first by truncating to 1 dp
person.pose.roll = glm::floor(person.pose.roll * 10) / 10; person.pose.roll = glm::floor(person.pose.roll * 10) / 10;
@ -388,8 +376,7 @@ void CaraFaceTracker::decodePacket(const QByteArray& buffer)
// Compute angular velocity of the head // Compute angular velocity of the head
glm::quat r = newRotation * glm::inverse(_headRotation); glm::quat r = newRotation * glm::inverse(_headRotation);
float theta = 2 * acos(r.w); float theta = 2 * acos(r.w);
if (theta > EPSILON) if (theta > EPSILON) {
{
float rMag = glm::length(glm::vec3(r.x, r.y, r.z)); float rMag = glm::length(glm::vec3(r.x, r.y, r.z));
const float AVERAGE_CARA_FRAME_TIME = 0.033f; const float AVERAGE_CARA_FRAME_TIME = 0.033f;
const float ANGULAR_VELOCITY_MIN = 1.2f; const float ANGULAR_VELOCITY_MIN = 1.2f;
@ -398,18 +385,21 @@ void CaraFaceTracker::decodePacket(const QByteArray& buffer)
_headAngularVelocity = theta / AVERAGE_CARA_FRAME_TIME * glm::vec3(r.x, r.y, r.z) / rMag; _headAngularVelocity = theta / AVERAGE_CARA_FRAME_TIME * glm::vec3(r.x, r.y, r.z) / rMag;
//use the angular velocity for roll and pitch, if it's below the threshold don't move //use the angular velocity for roll and pitch, if it's below the threshold don't move
if(glm::abs(_headAngularVelocity.x) < ANGULAR_VELOCITY_MIN) if(glm::abs(_headAngularVelocity.x) < ANGULAR_VELOCITY_MIN) {
person.pose.pitch = _previousPitch; person.pose.pitch = _previousPitch;
}
if(glm::abs(_headAngularVelocity.z) < ANGULAR_VELOCITY_MIN) if(glm::abs(_headAngularVelocity.z) < ANGULAR_VELOCITY_MIN) {
person.pose.roll = _previousRoll; person.pose.roll = _previousRoll;
}
//for yaw, the jitter is great, you can't use angular velocity because it swings too much //for yaw, the jitter is great, you can't use angular velocity because it swings too much
//use the previous and current yaw, calculate the //use the previous and current yaw, calculate the
//abs difference and move it the difference is above the standard deviation which is around 2.5 //abs difference and move it the difference is above the standard deviation which is around 2.5
// (this will introduce some jerks but will not encounter lag) // (this will introduce some jerks but will not encounter lag)
if(glm::abs(person.pose.yaw - _previousYaw) < YAW_STANDARD_DEV_DEG) // < the standard deviation 2.5 deg, no move
{ // < the standard deviation 2.5 deg, no move
if(glm::abs(person.pose.yaw - _previousYaw) < YAW_STANDARD_DEV_DEG) {
//qDebug() << "Yaw Diff: " << glm::abs(person.pose.yaw - _previousYaw); //qDebug() << "Yaw Diff: " << glm::abs(person.pose.yaw - _previousYaw);
person.pose.yaw = _previousYaw; person.pose.yaw = _previousYaw;
} }
@ -422,8 +412,7 @@ void CaraFaceTracker::decodePacket(const QByteArray& buffer)
//set the new rotation //set the new rotation
newRotation = glm::quat(glm::vec3(DEGTORAD(person.pose.pitch), DEGTORAD(person.pose.yaw), DEGTORAD(-person.pose.roll))); newRotation = glm::quat(glm::vec3(DEGTORAD(person.pose.pitch), DEGTORAD(person.pose.yaw), DEGTORAD(-person.pose.roll)));
} }
else else {
{
//no change in position //no change in position
newRotation = glm::quat(glm::vec3(DEGTORAD(_previousPitch), DEGTORAD(_previousYaw), DEGTORAD(-_previousRoll))); newRotation = glm::quat(glm::vec3(DEGTORAD(_previousPitch), DEGTORAD(_previousYaw), DEGTORAD(-_previousRoll)));
_headAngularVelocity = glm::vec3(0,0,0); _headAngularVelocity = glm::vec3(0,0,0);
@ -434,7 +423,6 @@ void CaraFaceTracker::decodePacket(const QByteArray& buffer)
//TODO: head translation, right now is 0 //TODO: head translation, right now is 0
//Do Blendshapes, clip between 0.0f to 1.0f, neg should be ignored //Do Blendshapes, clip between 0.0f to 1.0f, neg should be ignored
_blendshapeCoefficients[_leftBlinkIndex] = person.blink == CaraPerson::BLINK ? 1.0f : 0.0f; _blendshapeCoefficients[_leftBlinkIndex] = person.blink == CaraPerson::BLINK ? 1.0f : 0.0f;
_blendshapeCoefficients[_rightBlinkIndex] = person.blink == CaraPerson::BLINK ? 1.0f : 0.0f; _blendshapeCoefficients[_rightBlinkIndex] = person.blink == CaraPerson::BLINK ? 1.0f : 0.0f;
@ -450,14 +438,14 @@ void CaraFaceTracker::decodePacket(const QByteArray& buffer)
_blendshapeCoefficients[_mouthSmileLeftIndex] = person.emotion.smile < 0.0f ? 0.0f : person.emotion.smile; _blendshapeCoefficients[_mouthSmileLeftIndex] = person.emotion.smile < 0.0f ? 0.0f : person.emotion.smile;
_blendshapeCoefficients[_mouthSmileRightIndex] = person.emotion.smile < 0.0f ? 0.0f : person.emotion.smile; _blendshapeCoefficients[_mouthSmileRightIndex] = person.emotion.smile < 0.0f ? 0.0f : person.emotion.smile;
} }
else else {
qDebug() << "[Error] Cara Face Tracker Decode Error: " << jsonError.errorString(); qDebug() << "[Error] Cara Face Tracker Decode Error: " << jsonError.errorString();
}
_lastReceiveTimestamp = usecTimestampNow(); _lastReceiveTimestamp = usecTimestampNow();
} }
float CaraFaceTracker::getBlendshapeCoefficient(int index) const float CaraFaceTracker::getBlendshapeCoefficient(int index) const {
{
return (index >= 0 && index < (int)_blendshapeCoefficients.size()) ? _blendshapeCoefficients[index] : 0.0f; return (index >= 0 && index < (int)_blendshapeCoefficients.size()) ? _blendshapeCoefficients[index] : 0.0f;
} }

View file

@ -26,8 +26,7 @@
* host address (eg: 127.0.0.1 for localhost) and destination port 36555. * host address (eg: 127.0.0.1 for localhost) and destination port 36555.
**/ **/
class CaraFaceTracker : public FaceTracker class CaraFaceTracker : public FaceTracker {
{
Q_OBJECT Q_OBJECT
public: public: