Log Faceshift FPS after a reset

This commit is contained in:
David Rowe 2015-04-24 12:49:41 -07:00
parent eaaada908a
commit a141ebbf93
2 changed files with 33 additions and 2 deletions

View file

@ -10,6 +10,7 @@
//
#include <QTimer>
#include <QElapsedTimer>
#include <GLMHelpers.h>
#include <PerfStat.h>
@ -30,9 +31,14 @@ const QString DEFAULT_FACESHIFT_HOSTNAME = "localhost";
const quint16 FACESHIFT_PORT = 33433;
const float DEFAULT_FACESHIFT_EYE_DEFLECTION = 0.25f;
const int FPS_TIMER_DELAY = 2000; // ms
const int FPS_TIMER_DURATION = 2000; // ms
Faceshift::Faceshift() :
_eyeDeflection("faceshiftEyeDeflection", DEFAULT_FACESHIFT_EYE_DEFLECTION),
_hostname("faceshiftHostname", DEFAULT_FACESHIFT_HOSTNAME)
_hostname("faceshiftHostname", DEFAULT_FACESHIFT_HOSTNAME),
_isCalculatingFPS(false),
_frameCount(0)
{
#ifdef HAVE_FACESHIFT
connect(&_tcpSocket, SIGNAL(connected()), SLOT(noteConnected()));
@ -81,6 +87,12 @@ void Faceshift::reset() {
string message;
fsBinaryStream::encode_message(message, fsMsgCalibrateNeutral());
send(message);
// Log camera FPS after a reset
if (!_isCalculatingFPS) {
QTimer::singleShot(FPS_TIMER_DELAY, this, SLOT(startFPSTimer()));
_isCalculatingFPS = true;
}
}
_longTermAverageInitialized = false;
}
@ -283,6 +295,10 @@ void Faceshift::receive(const QByteArray& buffer) {
}
}
#endif
// Count frames if timing
if (_isCalculatingFPS) {
_frameCount++;
}
}
void Faceshift::setEyeDeflection(float faceshiftEyeDeflection) {
@ -292,3 +308,13 @@ void Faceshift::setEyeDeflection(float faceshiftEyeDeflection) {
void Faceshift::setHostname(const QString& hostname) {
_hostname.set(hostname);
}
void Faceshift::startFPSTimer() {
_frameCount = 0;
QTimer::singleShot(FPS_TIMER_DURATION, this, SLOT(finishFPSTimer()));
}
void Faceshift::finishFPSTimer() {
qCDebug(interfaceapp) << "Faceshift: FPS =" << (float)_frameCount / ((float)FPS_TIMER_DURATION / 1000.0f);
_isCalculatingFPS = false;
}

View file

@ -95,6 +95,8 @@ private slots:
void noteError(QAbstractSocket::SocketError error);
void readPendingDatagrams();
void readFromSocket();
void startFPSTimer();
void finishFPSTimer();
private:
Faceshift();
@ -152,6 +154,9 @@ private:
int _mouthSmileRightIndex = 29;
int _jawOpenIndex = 21;
bool _isCalculatingFPS;
int _frameCount;
};
#endif // hifi_Faceshift_h