From b3b735032dc7f77a209e29be8fa35a1adf28bb4b Mon Sep 17 00:00:00 2001 From: David Rowe Date: Fri, 8 May 2015 18:16:59 -0700 Subject: [PATCH] Automatically calibrate if Use Camera is enabled Do at start up or when Use Camera is first enabled per program run. --- interface/src/devices/DdeFaceTracker.cpp | 16 +++++++++++----- interface/src/devices/DdeFaceTracker.h | 1 + 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/interface/src/devices/DdeFaceTracker.cpp b/interface/src/devices/DdeFaceTracker.cpp index 6ed253c1ec..269e8ac11f 100644 --- a/interface/src/devices/DdeFaceTracker.cpp +++ b/interface/src/devices/DdeFaceTracker.cpp @@ -187,7 +187,8 @@ DdeFaceTracker::DdeFaceTracker(const QHostAddress& host, quint16 serverPort, qui _calibrationCount(0), _calibrationBillboard(NULL), _calibrationBillboardID(0), - _calibrationMessage(QString()) + _calibrationMessage(QString()), + _isCalibrated(false) { _coefficients.resize(NUM_FACESHIFT_BLENDSHAPES); _blendshapeCoefficients.resize(NUM_FACESHIFT_BLENDSHAPES); @@ -344,6 +345,10 @@ void DdeFaceTracker::decodePacket(const QByteArray& buffer) { _lastReceiveTimestamp = usecTimestampNow(); if (buffer.size() > MIN_PACKET_SIZE) { + if (!_isCalibrated) { + calibrate(); + } + bool isFiltering = Menu::getInstance()->isOptionChecked(MenuOption::VelocityFilter); Packet packet; @@ -544,13 +549,13 @@ void DdeFaceTracker::decodePacket(const QByteArray& buffer) { } } -static const int CALIBRATION_BILLBOARD_WIDTH = 240; -static const int CALIBRATION_BILLBOARD_HEIGHT = 180; -static const int CALIBRATION_BILLBOARD_TOP_MARGIN = 60; +static const int CALIBRATION_BILLBOARD_WIDTH = 300; +static const int CALIBRATION_BILLBOARD_HEIGHT = 120; +static const int CALIBRATION_BILLBOARD_TOP_MARGIN = 30; static const int CALIBRATION_BILLBOARD_LEFT_MARGIN = 30; static const int CALIBRATION_BILLBOARD_FONT_SIZE = 16; static const float CALIBRATION_BILLBOARD_ALPHA = 0.5f; -static QString CALIBRATION_INSTRUCTION_MESSAGE = "Hold still to calibrate"; +static QString CALIBRATION_INSTRUCTION_MESSAGE = "Hold still to calibrate camera"; void DdeFaceTracker::calibrate() { if (!_isCalibrating) { @@ -609,6 +614,7 @@ void DdeFaceTracker::finishCalibration() { qApp->getOverlays().deleteOverlay(_calibrationBillboardID); _calibrationBillboard = NULL; _isCalibrating = false; + _isCalibrated = true; for (int i = 0; i < NUM_FACESHIFT_BLENDSHAPES; i++) { _coefficientAverages[i] = _calibrationValues[i] / (float)CALIBRATION_SAMPLES; diff --git a/interface/src/devices/DdeFaceTracker.h b/interface/src/devices/DdeFaceTracker.h index 7019802603..2ec362a9c6 100644 --- a/interface/src/devices/DdeFaceTracker.h +++ b/interface/src/devices/DdeFaceTracker.h @@ -131,6 +131,7 @@ private: TextOverlay* _calibrationBillboard; int _calibrationBillboardID; QString _calibrationMessage; + bool _isCalibrated; void addCalibrationDatum(); void cancelCalibration(); void finishCalibration();