From 6999bf3ef1c30d5af447c8cdd98213d1b1106a30 Mon Sep 17 00:00:00 2001 From: Wim Vriend Date: Tue, 5 Oct 2010 20:40:38 +0000 Subject: Beta Curve configuration seems to work... git-svn-id: svn+ssh://svn.code.sf.net/p/facetracknoir/code@22 19e81ba0-9b1a-49c3-bd6c-561e1906d5fb --- FaceTrackNoIR/FGServer.h | 6 +- FaceTrackNoIR/FTIRServer.cpp | 7 + FaceTrackNoIR/FTIRServer.h | 33 +- FaceTrackNoIR/FTServer.h | 30 +- FaceTrackNoIR/FaceTrackNoIR.cpp | 75 +-- FaceTrackNoIR/FaceTrackNoIR.h | 10 - FaceTrackNoIR/FaceTrackNoIR.ui | 1086 ++++++++++----------------------------- FaceTrackNoIR/tracker.cpp | 273 ++++++---- FaceTrackNoIR/tracker.h | 46 +- 9 files changed, 474 insertions(+), 1092 deletions(-) (limited to 'FaceTrackNoIR') diff --git a/FaceTrackNoIR/FGServer.h b/FaceTrackNoIR/FGServer.h index 0df2eb1d..bd849c80 100644 --- a/FaceTrackNoIR/FGServer.h +++ b/FaceTrackNoIR/FGServer.h @@ -86,9 +86,9 @@ public: void setVirtRotX(float rot) { virtRotX = rot; } void setVirtRotY(float rot) { virtRotY = rot; } void setVirtRotZ(float rot) { virtRotZ = rot; } - void setVirtPosX(float pos) { virtPosX = pos; } - void setVirtPosY(float pos) { virtPosY = pos; } - void setVirtPosZ(float pos) { virtPosZ = pos; } + void setVirtPosX(float pos) { virtPosX = pos / 100.0f; } + void setVirtPosY(float pos) { virtPosY = pos / 100.0f; } + void setVirtPosZ(float pos) { virtPosZ = pos / 100.0f; } }; diff --git a/FaceTrackNoIR/FTIRServer.cpp b/FaceTrackNoIR/FTIRServer.cpp index bee31ca0..a3298ace 100644 --- a/FaceTrackNoIR/FTIRServer.cpp +++ b/FaceTrackNoIR/FTIRServer.cpp @@ -97,6 +97,13 @@ void FTIRServer::run() { // qDebug() << "FTIRServer says: virtRotX =" << virtRotX << " virtRotY =" << virtRotY; setposition (virtPosX, virtPosY, virtPosZ, virtRotZ, virtRotX, virtRotY ); + //// Use this for some debug-output to file... + //QFile data("outputFTIR.txt"); + //if (data.open(QFile::WriteOnly | QFile::Append)) { + // QTextStream out(&data); + // out << virtPosX << " " << virtPosY << " " << virtPosZ << virtRotX << " " << virtRotY << " " << virtRotZ << '\n'; + //} + //qDebug() << "FTIRServer says: pMemData.xRot =" << pMemData->data.xRot << " yRot =" << pMemData->data.yRot; ReleaseMutex(hFTIRMutex); } diff --git a/FaceTrackNoIR/FTIRServer.h b/FaceTrackNoIR/FTIRServer.h index 868beaaf..503514ec 100644 --- a/FaceTrackNoIR/FTIRServer.h +++ b/FaceTrackNoIR/FTIRServer.h @@ -68,21 +68,10 @@ private: FTIRMemMap *pMemData; HANDLE hFTIRMutex; - ///** member varables for saving the head pose **/ - //float headPosX; - //float headPosY; - //float headPosZ; - // - //float headRotX; - //float headRotY; - //float headRotZ; - //bool confid; - - // Private properties QString ProgramName; QLibrary FTIRClientLib; - float scale2AnalogLimits( float x, float min_x, float max_x ); + static float scale2AnalogLimits( float x, float min_x, float max_x ); public: @@ -95,21 +84,13 @@ public: static float virtRotY; static float virtRotZ; - //void setHeadPosX(float x) { headPosX = x; } - //void setHeadPosY(float y) { headPosY = y; } - //void setHeadPosZ(float z) { headPosZ = z; } - - //void setHeadRotX(float x) { headRotX = x; } - //void setHeadRotY(float y) { headRotY = y; } - //void setHeadRotZ(float z) { headRotZ = z; } - - void setVirtRotX(float rot) { virtRotX = scale2AnalogLimits (rot, -180.0f, 180.0f); } - void setVirtRotY(float rot) { virtRotY = scale2AnalogLimits (rot, -180.0f, 180.0f); } - void setVirtRotZ(float rot) { virtRotZ = scale2AnalogLimits (rot, -180.0f, 180.0f); } + static void setVirtRotX(float rot) { virtRotX = scale2AnalogLimits (rot, -180.0f, 180.0f); } + static void setVirtRotY(float rot) { virtRotY = scale2AnalogLimits (rot, -180.0f, 180.0f); } + static void setVirtRotZ(float rot) { virtRotZ = scale2AnalogLimits (rot, -180.0f, 180.0f); } - void setVirtPosX(float pos) { virtPosX = scale2AnalogLimits (pos, -50.0f, 50.0f); } - void setVirtPosY(float pos) { virtPosY = scale2AnalogLimits (pos, -50.0f, 50.0f); } - void setVirtPosZ(float pos) { virtPosZ = scale2AnalogLimits (pos, -50.0f, 50.0f); } + static void setVirtPosX(float pos) { virtPosX = scale2AnalogLimits (pos * 10.0f, -500.0f, 500.0f); } + static void setVirtPosY(float pos) { virtPosY = scale2AnalogLimits (pos * 10.0f, -500.0f, 500.0f); } + static void setVirtPosZ(float pos) { virtPosZ = scale2AnalogLimits (pos * 10.0f, -500.0f, 500.0f); } }; diff --git a/FaceTrackNoIR/FTServer.h b/FaceTrackNoIR/FTServer.h index fc4476b4..72642785 100644 --- a/FaceTrackNoIR/FTServer.h +++ b/FaceTrackNoIR/FTServer.h @@ -99,20 +99,22 @@ private: QLibrary FTClientLib; public: - void setHeadPosX(float x) { headPosX = x; } - void setHeadPosY(float y) { headPosY = y; } - void setHeadPosZ(float z) { headPosZ = z; } - - void setHeadRotX(float x) { headRotX = x; } - void setHeadRotY(float y) { headRotY = y; } - void setHeadRotZ(float z) { headRotZ = z; } - - void setVirtRotX(float rot) { virtRotX = rot; } - void setVirtRotY(float rot) { virtRotY = rot; } - void setVirtRotZ(float rot) { virtRotZ = rot; } - void setVirtPosX(float pos) { virtPosX = pos; } - void setVirtPosY(float pos) { virtPosY = pos; } - void setVirtPosZ(float pos) { virtPosZ = pos; } + void setHeadPosX(float x) { headPosX = x * 10; } + void setHeadPosY(float y) { headPosY = y * 10; } + void setHeadPosZ(float z) { headPosZ = z * 10; } + + void setHeadRotX(float x) { headRotX = getRadsFromDegrees(x); } + void setHeadRotY(float y) { headRotY = getRadsFromDegrees(y); } + void setHeadRotZ(float z) { headRotZ = getRadsFromDegrees(z); } + + void setVirtRotX(float rot) { virtRotX = getRadsFromDegrees(rot); } + void setVirtRotY(float rot) { virtRotY = getRadsFromDegrees(rot); } + void setVirtRotZ(float rot) { virtRotZ = getRadsFromDegrees(rot); } + void setVirtPosX(float pos) { virtPosX = pos * 10; } + void setVirtPosY(float pos) { virtPosY = pos * 10; } + void setVirtPosZ(float pos) { virtPosZ = pos * 10; } + + float getRadsFromDegrees ( float degrees ) { return (degrees * 0.017453f); } }; diff --git a/FaceTrackNoIR/FaceTrackNoIR.cpp b/FaceTrackNoIR/FaceTrackNoIR.cpp index d3511c16..ef579436 100644 --- a/FaceTrackNoIR/FaceTrackNoIR.cpp +++ b/FaceTrackNoIR/FaceTrackNoIR.cpp @@ -84,14 +84,7 @@ void FaceTrackNoIR::setupFaceTrackNoIR() { connect(ui.btnStartTracker, SIGNAL(clicked()), this, SLOT(startTracker())); connect(ui.btnStopTracker, SIGNAL(clicked()), this, SLOT(stopTracker())); - // Connect sliders for sensitivity - connect(ui.sensYaw, SIGNAL(valueChanged(int)), this, SLOT(setSensYaw(int))); - connect(ui.sensRoll, SIGNAL(valueChanged(int)), this, SLOT(setSensRoll(int))); - connect(ui.sensPitch, SIGNAL(valueChanged(int)), this, SLOT(setSensPitch(int))); - connect(ui.sensX, SIGNAL(valueChanged(int)), this, SLOT(setSensX(int))); - connect(ui.sensY, SIGNAL(valueChanged(int)), this, SLOT(setSensY(int))); - connect(ui.sensZ, SIGNAL(valueChanged(int)), this, SLOT(setSensZ(int))); - + // Connect checkboxes connect(ui.chkInvertYaw, SIGNAL(stateChanged(int)), this, SLOT(setInvertYaw(int))); connect(ui.chkInvertRoll, SIGNAL(stateChanged(int)), this, SLOT(setInvertRoll(int))); connect(ui.chkInvertPitch, SIGNAL(stateChanged(int)), this, SLOT(setInvertPitch(int))); @@ -109,8 +102,6 @@ void FaceTrackNoIR::setupFaceTrackNoIR() { connect(ui.redY, SIGNAL(valueChanged(int)), this, SLOT(setRedY(int))); connect(ui.redZ, SIGNAL(valueChanged(int)), this, SLOT(setRedZ(int))); - connect(ui.slideNeutralZone, SIGNAL(valueChanged(int)), this, SLOT(setNeutralZone(int))); - // Connect slider for smoothing connect(ui.slideSmoothing, SIGNAL(valueChanged(int)), this, SLOT(setSmoothing(int))); @@ -288,13 +279,6 @@ void FaceTrackNoIR::save() { iniFile.beginGroup ( "Tracking" ); iniFile.setValue ( "Smooth", ui.slideSmoothing->value() ); - iniFile.setValue ( "NeutralZone", ui.slideNeutralZone->value() ); - iniFile.setValue ( "sensYaw", ui.sensYaw->value() ); - iniFile.setValue ( "sensPitch", ui.sensPitch->value() ); - iniFile.setValue ( "sensRoll", ui.sensRoll->value() ); - iniFile.setValue ( "sensX", ui.sensX->value() ); - iniFile.setValue ( "sensY", ui.sensY->value() ); - iniFile.setValue ( "sensZ", ui.sensZ->value() ); iniFile.setValue ( "invertYaw", ui.chkInvertYaw->isChecked() ); iniFile.setValue ( "invertPitch", ui.chkInvertPitch->isChecked() ); iniFile.setValue ( "invertRoll", ui.chkInvertRoll->isChecked() ); @@ -351,13 +335,6 @@ void FaceTrackNoIR::loadSettings() { iniFile.beginGroup ( "Tracking" ); ui.slideSmoothing->setValue (iniFile.value ( "Smooth", 10 ).toInt()); - ui.slideNeutralZone->setValue (iniFile.value ( "NeutralZone", 5 ).toInt()); - ui.sensYaw->setValue (iniFile.value ( "sensYaw", 100 ).toInt()); - ui.sensPitch->setValue (iniFile.value ( "sensPitch", 100 ).toInt()); - ui.sensRoll->setValue (iniFile.value ( "sensRoll", 100 ).toInt()); - ui.sensX->setValue (iniFile.value ( "sensX", 100 ).toInt()); - ui.sensY->setValue (iniFile.value ( "sensY", 100 ).toInt()); - ui.sensZ->setValue (iniFile.value ( "sensZ", 100 ).toInt()); ui.chkInvertYaw->setChecked (iniFile.value ( "invertYaw", 0 ).toBool()); ui.chkInvertPitch->setChecked (iniFile.value ( "invertPitch", 0 ).toBool()); ui.chkInvertRoll->setChecked (iniFile.value ( "invertRoll", 0 ).toBool()); @@ -426,16 +403,8 @@ void FaceTrackNoIR::startTracker( ) { // tracker->setup( ui.headPoseWidget , this); tracker->setSmoothing ( ui.slideSmoothing->value() ); - tracker->setNeutralZone ( ui.slideNeutralZone->value() ); tracker->setUseFilter (ui.chkUseEWMA->isChecked() ); - tracker->setSensYaw (ui.sensYaw->value() ); - tracker->setSensPitch (ui.sensPitch->value() ); - tracker->setSensRoll (ui.sensRoll->value() ); - tracker->setSensX (ui.sensX->value() ); - tracker->setSensY (ui.sensY->value() ); - tracker->setSensZ (ui.sensZ->value() ); - tracker->setInvertYaw (ui.chkInvertYaw->isChecked() ); tracker->setInvertPitch (ui.chkInvertPitch->isChecked() ); tracker->setInvertRoll (ui.chkInvertRoll->isChecked() ); @@ -514,42 +483,6 @@ void FaceTrackNoIR::stopTracker( ) { ui.btnShowServerControls->setEnabled ( true ); } -/** set the sensibility from the slider **/ -void FaceTrackNoIR::setSensYaw( int sens ) { - Tracker::setSensYaw ( sens ); - settingsDirty = true; -} - -/** set the sensibility from the slider **/ -void FaceTrackNoIR::setSensPitch( int sens ) { - Tracker::setSensPitch ( sens ); - settingsDirty = true; -} - -/** set the sensibility from the slider **/ -void FaceTrackNoIR::setSensRoll( int sens ) { - Tracker::setSensRoll ( sens ); - settingsDirty = true; -} - -/** set the sensibility from the slider **/ -void FaceTrackNoIR::setSensX( int sens ) { - Tracker::setSensX ( sens ); - settingsDirty = true; -} - -/** set the sensibility from the slider **/ -void FaceTrackNoIR::setSensY( int sens ) { - Tracker::setSensY ( sens ); - settingsDirty = true; -} - -/** set the sensibility from the slider **/ -void FaceTrackNoIR::setSensZ( int sens ) { - Tracker::setSensZ ( sens ); - settingsDirty = true; -} - /** set the invert from the checkbox **/ void FaceTrackNoIR::setInvertYaw( int invert ) { Tracker::setInvertYaw ( (invert != 0)?true:false ); @@ -628,12 +561,6 @@ void FaceTrackNoIR::setRedZ( int redh ) { settingsDirty = true; } -/** set the Neutral Zone for rotations from the slider **/ -void FaceTrackNoIR::setNeutralZone( int angle ) { - Tracker::setNeutralZone ( angle ); - settingsDirty = true; -} - /** set the smoothing from the slider **/ void FaceTrackNoIR::setSmoothing( int smooth ) { diff --git a/FaceTrackNoIR/FaceTrackNoIR.h b/FaceTrackNoIR/FaceTrackNoIR.h index c14d4e16..923517a4 100644 --- a/FaceTrackNoIR/FaceTrackNoIR.h +++ b/FaceTrackNoIR/FaceTrackNoIR.h @@ -117,14 +117,6 @@ private: void showKeyboardShortcuts(); void showCurveConfiguration(); - // sensibility sliders - void setSensYaw( int sens ); - void setSensPitch( int sens ); - void setSensRoll( int sens ); - void setSensX( int sens ); - void setSensY( int sens ); - void setSensZ( int sens ); - // invert checkboxes void setInvertYaw( int invert ); void setInvertPitch( int invert ); @@ -143,8 +135,6 @@ private: void setRedY( int redh ); void setRedZ( int redh ); - void setNeutralZone( int angle ); - //smoothing slider void setSmoothing( int smooth ); diff --git a/FaceTrackNoIR/FaceTrackNoIR.ui b/FaceTrackNoIR/FaceTrackNoIR.ui index b0889c31..fe4facb4 100644 --- a/FaceTrackNoIR/FaceTrackNoIR.ui +++ b/FaceTrackNoIR/FaceTrackNoIR.ui @@ -90,6 +90,10 @@ QPushButton { min-width: 4em; } +QCheckBox { + background:none; +} + QPushButton:disabled { color: rgb(128, 128, 128); } @@ -942,198 +946,7 @@ color:#000; - - - - - - 25 - 0 - - - - - 150 - 16777215 - - - - color:#ccc; -background:none; - - - Global settings - - - - - - - - 50 - 15 - - - - 1 - - - 120 - - - 10 - - - 10 - - - Qt::Horizontal - - - QSlider::NoTicks - - - - - - - - 50 - 22 - - - - 120 - - - 10 - - - - - - - - - - - - - - - 25 - 0 - - - - - 150 - 16777215 - - - - color:#ccc; -background:none; - - - Use EWMA filtering: - - - - - - - - 25 - 0 - - - - - 150 - 16777215 - - - - color:#ccc; -background:none; - - - Smoothing (samples): - - - - - - - - 50 - 15 - - - - 1 - - - 45 - - - 5 - - - 5 - - - Qt::Horizontal - - - QSlider::NoTicks - - - - - - - - 50 - 22 - - - - 45 - - - 5 - - - 5 - - - - - - - - 25 - 0 - - - - - 150 - 16777215 - - - - color:#ccc; -background:none; - - - Neutral Zone: - - - - + @@ -1285,11 +1098,11 @@ opacity:100; - - + + - 110 + 25 0 @@ -1304,12 +1117,12 @@ opacity:100; background:none; - Sensitivity (100 = x1) + Yaw - - + + 25 @@ -1327,56 +1140,35 @@ background:none; background:none; - Yaw + X - - + + - 50 - 15 + 25 + 0 - - 500 - - - 10 - - - 100 - - - Qt::Horizontal - - - QSlider::NoTicks - - - - - - + - 50 - 22 + 150 + 16777215 - - 500 - - - 10 + + color:#ccc; +background:none; - - 100 + + Pitch - - + + 25 @@ -1394,84 +1186,77 @@ background:none; background:none; - X + Y - - + + - 50 - 15 + 25 + 0 - - 500 - - - 10 - - - 100 + + + 150 + 16777215 + - - Qt::Horizontal + + color:#ccc; +background:none; - - QSlider::NoTicks + + Roll - - + + - 50 - 22 + 25 + 0 - - 500 + + + 150 + 16777215 + - - 10 + + color:#ccc; +background:none; - - 100 + + Z - - - - - 50 - 22 - - - - 500 - - - 10 + + + + background:none; - - 100 + + - - + + - 25 + 0 0 - 150 + 30 16777215 @@ -1480,65 +1265,51 @@ background:none; background:none; - Pitch + Invert - - - - - 50 - 15 - - - - 500 - - - 10 - - - 100 - - - Qt::Horizontal + + + + background:none; - - QSlider::NoTicks + + - - - - - 50 - 22 - + + + + background:none; - - 500 + + - - 10 + + + + + + background:none; - - 100 + + - - + + - 25 + 0 0 - 150 + 30 16777215 @@ -1547,12 +1318,32 @@ background:none; background:none; - Y + Invert - - + + + + background:none; + + + + + + + + + + background:none; + + + + + + + + 50 @@ -1560,13 +1351,13 @@ background:none; - 500 + 100 10 - 100 + 70 Qt::Horizontal @@ -1576,31 +1367,33 @@ background:none; - - + + - 25 - 0 + 50 + 15 - - - 150 - 16777215 - + + 100 - - color:#ccc; -background:none; + + 10 - - Roll + + 70 + + + Qt::Horizontal + + + QSlider::NoTicks - - + + 50 @@ -1608,13 +1401,13 @@ background:none; - 500 + 100 10 - 100 + 70 Qt::Horizontal @@ -1624,154 +1417,83 @@ background:none; - - + + 50 22 + + background:none; + - 500 + 100 - 10 + 5 - 100 + 70 - - + + - 25 - 0 - - - - - 150 - 16777215 + 50 + 22 - color:#ccc; -background:none; - - - Z - - - - - - - - 50 - 15 - + background:none; - 500 - - - 10 - - 100 - - Qt::Horizontal + + 5 - - QSlider::NoTicks + + 70 - - + + 50 22 + + background:none; + - 500 + 100 - 10 + 5 - 100 - - - - - - - - - - - - - - - 0 - 0 - - - - - 30 - 16777215 - - - - color:#ccc; -background:none; - - - Invert - - - - - - - - - - - - - - - - - - - - - + 70 - - + + - 0 + 110 0 - 30 + 150 16777215 @@ -1780,26 +1502,12 @@ background:none; background:none; - Invert - - - - - - - - - - - - - - + Red.factor (100 = 1) - - + + 50 @@ -1823,8 +1531,8 @@ background:none; - - + + 50 @@ -1848,8 +1556,8 @@ background:none; - - + + 50 @@ -1873,14 +1581,17 @@ background:none; - - + + 50 22 + + background:none; + 100 @@ -1892,14 +1603,17 @@ background:none; - - + + 50 22 + + background:none; + 100 @@ -1911,14 +1625,17 @@ background:none; - - + + 50 22 + + background:none; + 100 @@ -1930,8 +1647,8 @@ background:none; - - + + 110 @@ -1953,181 +1670,140 @@ background:none; - - - - - 50 - 15 - - - - 100 - - - 10 - - - 70 - - - Qt::Horizontal + + + + background:none; - - QSlider::NoTicks + + - - + + - 50 - 15 + 25 + 0 - - 100 - - - 10 - - - 70 + + + 150 + 16777215 + - - Qt::Horizontal + + color:#ccc; +background:none; - - QSlider::NoTicks + + Use EWMA filtering: - - + + - 50 - 15 + 25 + 0 - - 100 - - - 10 - - - 70 + + + 150 + 16777215 + - - Qt::Horizontal + + color:#ccc; +background:none; - - QSlider::NoTicks + + Global settings - - + + - 50 - 22 + 25 + 0 - - 100 + + + 150 + 16777215 + - - 5 + + color:#ccc; +background:none; - - 70 + + Smoothing: - - + + 50 - 22 + 15 + + 1 + - 100 + 120 - - 5 + + 10 - 70 + 10 + + + Qt::Horizontal + + + QSlider::NoTicks - - + + 50 22 - - 100 + + background:none; - - 5 + + 120 - 70 - - - - - - - - 110 - 0 - - - - - 150 - 16777215 - - - - color:#ccc; -background:none; - - - Red.factor (100 = 1) + 10 - - - - - 110 - 0 - - - - - 150 - 16777215 - - + + color:#ccc; background:none; - Sensitivity (100 = x1) + (samples) @@ -2370,20 +2046,6 @@ background:none; btnStopTracker btnShowEngineControls iconcomboBox - sensYaw - spinSensYaw - sensPitch - spinSensPitch - sensRoll - spinSensRoll - sensX - spinSensX - sensY - spinSensY - sensZ - spinSensZ - slideSmoothing - spinSmoothing headXLine headRotXLine headYLine @@ -2395,198 +2057,6 @@ background:none; - - sensYaw - valueChanged(int) - spinSensYaw - setValue(int) - - - 391 - 442 - - - 447 - 446 - - - - - spinSensYaw - valueChanged(int) - sensYaw - setValue(int) - - - 447 - 446 - - - 391 - 442 - - - - - sensPitch - valueChanged(int) - spinSensPitch - setValue(int) - - - 391 - 473 - - - 447 - 476 - - - - - spinSensPitch - valueChanged(int) - sensPitch - setValue(int) - - - 447 - 476 - - - 391 - 473 - - - - - sensRoll - valueChanged(int) - spinSensRoll - setValue(int) - - - 391 - 499 - - - 447 - 502 - - - - - spinSensRoll - valueChanged(int) - sensRoll - setValue(int) - - - 447 - 502 - - - 391 - 499 - - - - - sensX - valueChanged(int) - spinSensX - setValue(int) - - - 698 - 442 - - - 754 - 445 - - - - - spinSensX - valueChanged(int) - sensX - setValue(int) - - - 754 - 445 - - - 698 - 442 - - - - - sensY - valueChanged(int) - spinSensY - setValue(int) - - - 698 - 473 - - - 754 - 472 - - - - - spinSensY - valueChanged(int) - sensY - setValue(int) - - - 754 - 472 - - - 698 - 473 - - - - - sensZ - valueChanged(int) - spinSensZ - setValue(int) - - - 698 - 499 - - - 754 - 502 - - - - - spinSensZ - valueChanged(int) - sensZ - setValue(int) - - - 754 - 502 - - - 698 - 499 - - - slideSmoothing valueChanged(int) @@ -2811,37 +2281,5 @@ background:none; - - slideNeutralZone - valueChanged(int) - spinNeutralZone - setValue(int) - - - 701 - 233 - - - 800 - 242 - - - - - spinNeutralZone - valueChanged(int) - slideNeutralZone - setValue(int) - - - 806 - 232 - - - 741 - 231 - - - diff --git a/FaceTrackNoIR/tracker.cpp b/FaceTrackNoIR/tracker.cpp index ce928d66..82f26fc2 100644 --- a/FaceTrackNoIR/tracker.cpp +++ b/FaceTrackNoIR/tracker.cpp @@ -48,7 +48,6 @@ bool Tracker::do_tracking = true; bool Tracker::do_center = false; bool Tracker::useFilter = false; -float Tracker::rotNeutralZone = 0.087f; // Neutral Zone for rotations (rad) long Tracker::prevHeadPoseTime = 0; THeadPoseDOF Tracker::Pitch; // One structure for each of 6DOF's THeadPoseDOF Tracker::Yaw; @@ -231,16 +230,15 @@ void Tracker::run() { bool lastBackKey = false; // Remember state, to detect rising edge bool lastEqualsKey = false; + float rawrotX, rawrotY, rawrotZ; // Locals... + float rawposX, rawposY, rawposZ; + float rotX, rotY, rotZ; // Locals... + float posX, posY, posZ; + SYSTEMTIME now; long newHeadPoseTime; float dT; - //QFile data("output.txt"); - //if (data.open(QFile::WriteOnly | QFile::Truncate)) { - // QTextStream out(&data); - // out << "Polling results"; - //} - // // Setup the DirectInput for keyboard strokes // @@ -364,45 +362,41 @@ void Tracker::run() { // to substract that later... // if(Tracker::set_initial == false) { - Tracker::Z.initial_headPos = Tracker::getHeadPosZ(); + Tracker::X.initial_headPos = Tracker::X.headPos; + Tracker::Y.initial_headPos = Tracker::Y.headPos; + Tracker::Z.initial_headPos = Tracker::Z.headPos; MessageBeep (MB_ICONASTERISK); Tracker::set_initial = true; } - headXLine->setText(QString("%1").arg(Tracker::getHeadPosX()*100, 0, 'f', 1)); - headYLine->setText(QString("%1").arg(Tracker::getHeadPosY()*100, 0, 'f', 1)); - headZLine->setText(QString("%1").arg(Tracker::getHeadPosZ()*100, 0, 'f', 1)); + rawrotX = Tracker::Pitch.headPos; // degrees + rawrotY = Tracker::Yaw.headPos; + rawrotZ = Tracker::Roll.headPos; + rawposX = Tracker::X.headPos; // centimeters + rawposY = Tracker::Y.headPos - Tracker::Y.initial_headPos; + rawposZ = Tracker::Z.headPos - Tracker::Z.initial_headPos; + + headRotXLine->setText(QString("%1").arg( rawrotX, 0, 'f', 1)); // show degrees + headRotYLine->setText(QString("%1").arg( rawrotY, 0, 'f', 1)); + headRotZLine->setText(QString("%1").arg( rawrotZ, 0, 'f', 1)); + + headXLine->setText(QString("%1").arg( rawposX, 0, 'f', 1)); // show centimeters + headYLine->setText(QString("%1").arg( rawposY, 0, 'f', 1)); + headZLine->setText(QString("%1").arg( rawposZ, 0, 'f', 1)); - headRotXLine->setText(QString("%1").arg(Tracker::getHeadRotX()*100, 0, 'f', 1)); - headRotYLine->setText(QString("%1").arg(Tracker::getHeadRotY()*100, 0, 'f', 1)); - headRotZLine->setText(QString("%1").arg(Tracker::getHeadRotZ()*100, 0, 'f', 1)); -//// listener.setTrackedPosition(QPoint(Tracker::getHeadPosX()-50, Tracker::getHeadPosY()-37.5)); // // Copy the Raw values directly to Free-track server // if (server_FT) { - server_FT->setHeadRotX( Tracker::Pitch.headPos ); // rads - server_FT->setHeadRotY( Tracker::Yaw.headPos ); - server_FT->setHeadRotZ( Tracker::Roll.headPos); + //server_FT->setHeadRotX( rawrotX ); // degrees + //server_FT->setHeadRotY( rawrotY ); + //server_FT->setHeadRotZ( rawrotZ ); - server_FT->setHeadPosX( Tracker::X.headPos * 1000.0f); // From m to mm - server_FT->setHeadPosY( Tracker::Y.headPos * 1000.0f); - server_FT->setHeadPosZ( ( Tracker::Z.headPos - Tracker::Z.initial_headPos ) * 1000.0f); + //server_FT->setHeadPosX( rawposX ); // meters + //server_FT->setHeadPosY( rawposY ); + //server_FT->setHeadPosZ( rawposZ ); } - - // - // Copy the Raw values directly to Fake-trackIR server - // - //if (server_FTIR) { - // server_FTIR->setHeadRotX( Tracker::Pitch.headPos ); // rads - // server_FTIR->setHeadRotY( Tracker::Yaw.headPos ); - // server_FTIR->setHeadRotZ( Tracker::Roll.headPos); - - // server_FTIR->setHeadPosX( Tracker::X.headPos * 1000.0f); // From m to mm - // server_FTIR->setHeadPosY( Tracker::Y.headPos * 1000.0f); - // server_FTIR->setHeadPosZ( ( Tracker::Z.headPos - Tracker::Z.initial_headPos ) * 1000.0f); - //} } // @@ -413,99 +407,147 @@ void Tracker::run() { Yaw.offset_headPos = getSmoothFromList( &Yaw.rawList ); Roll.offset_headPos = getSmoothFromList( &Roll.rawList ); X.offset_headPos = getSmoothFromList( &X.rawList ); - Y.offset_headPos = getSmoothFromList( &Y.rawList ); // // Reset the initial distance to the camera // + Y.offset_headPos = getSmoothFromList( &Y.rawList ) - Tracker::Y.initial_headPos; Z.offset_headPos = getSmoothFromList( &Z.rawList ) - Tracker::Z.initial_headPos; Tracker::do_center = false; } if (Tracker::do_tracking && Tracker::confid) { + +////// Use this for some debug-output to file... +//// QFile data("output.txt"); +//// if (data.open(QFile::WriteOnly | QFile::Append)) { +//// QTextStream out(&data); +//// out << Pitch.NeutralZone << " " << getDegreesFromRads(rotX) << " " << getOutputFromCurve(&Pitch.curve, getDegreesFromRads(rotX), Pitch.NeutralZone, Pitch.MaxInput) << '\n'; +////// out << dT << " " << getSmoothFromList( &Pitch.rawList ) << " " << Pitch.offset_headPos << '\n'; +//// } + // Pitch if (Tracker::useFilter) { - Pitch.newPos = lowPassFilter ( getSmoothFromList( &Pitch.rawList ) - Pitch.offset_headPos, + rotX = lowPassFilter ( getSmoothFromList( &Pitch.rawList ) - Pitch.offset_headPos, &Pitch.prevPos, dT, Tracker::Pitch.red ); } else { - Pitch.newPos = getSmoothFromList( &Pitch.rawList ) - Pitch.offset_headPos; + rotX = getSmoothFromList( &Pitch.rawList ) - Pitch.offset_headPos; } - - QFile data("output.txt"); - if (data.open(QFile::WriteOnly | QFile::Append)) { - QTextStream out(&data); - out << "Input = " << getDegreesFromRads(Pitch.newPos) << " Output = " << getOutputFromCurve(&Pitch.curve, getDegreesFromRads(Pitch.newPos)) << '\n'; - } + rotX = Pitch.invert * getOutputFromCurve(&Pitch.curve, rotX, Pitch.NeutralZone, Pitch.MaxInput); // Yaw if (Tracker::useFilter) { - Yaw.newPos = lowPassFilter ( getSmoothFromList( &Yaw.rawList ) - Yaw.offset_headPos, + rotY = lowPassFilter ( getSmoothFromList( &Yaw.rawList ) - Yaw.offset_headPos, &Yaw.prevPos, dT, Tracker::Yaw.red ); } else { - Yaw.newPos = getSmoothFromList( &Yaw.rawList ) - Yaw.offset_headPos; + rotY = getSmoothFromList( &Yaw.rawList ) - Yaw.offset_headPos; } + rotY = Yaw.invert * getOutputFromCurve(&Yaw.curve, rotY, Yaw.NeutralZone, Yaw.MaxInput); // Roll if (Tracker::useFilter) { - Roll.newPos = lowPassFilter ( getSmoothFromList( &Roll.rawList ) - Roll.offset_headPos, + rotZ = lowPassFilter ( getSmoothFromList( &Roll.rawList ) - Roll.offset_headPos, &Roll.prevPos, dT, Tracker::Roll.red ); } else { - Roll.newPos = getSmoothFromList( &Roll.rawList ) - Roll.offset_headPos; + rotZ = getSmoothFromList( &Roll.rawList ) - Roll.offset_headPos; + } + rotZ = Roll.invert * getOutputFromCurve(&Roll.curve, rotZ, Roll.NeutralZone, Roll.MaxInput); + + // X + if (Tracker::useFilter) { + posX = lowPassFilter ( getSmoothFromList( &X.rawList ) - X.offset_headPos, + &X.prevPos, dT, Tracker::X.red ); + } + else { + posX = getSmoothFromList( &X.rawList ) - X.offset_headPos; + } + posX = X.invert * getOutputFromCurve(&X.curve, posX, X.NeutralZone, X.MaxInput); + + // Y + if (Tracker::useFilter) { + posY = lowPassFilter ( getSmoothFromList( &Y.rawList ) - Y.offset_headPos - Y.initial_headPos, + &Y.prevPos, dT, Tracker::Y.red ); + } + else { + posY = getSmoothFromList( &Y.rawList ) - Y.offset_headPos - Y.initial_headPos; + } + posY = Y.invert * getOutputFromCurve(&Y.curve, posY, Y.NeutralZone, Y.MaxInput); + + // Z + if (Tracker::useFilter) { + posZ = lowPassFilter ( getSmoothFromList( &Z.rawList ) - Z.offset_headPos - Z.initial_headPos, + &Z.prevPos, dT, Tracker::Z.red ); + } + else { + posZ = getSmoothFromList( &Z.rawList ) - Z.offset_headPos - Z.initial_headPos; } + posZ = Z.invert * getOutputFromCurve(&Z.curve, posZ, Z.NeutralZone, Z.MaxInput); + // // Also send the Virtual Pose to selected Protocol-Server // // Free-track if (server_FT) { - server_FT->setVirtRotX ( Tracker::Pitch.invert * Tracker::Pitch.sens * Pitch.newPos ); - server_FT->setVirtRotY ( Tracker::Yaw.invert * Tracker::Yaw.sens * Yaw.newPos ); - server_FT->setVirtRotZ ( Tracker::Roll.invert * Tracker::Roll.sens * Roll.newPos ); + server_FT->setVirtRotX ( rotX ); // degrees + server_FT->setVirtRotY ( rotY ); + server_FT->setVirtRotZ ( rotZ ); + + server_FT->setVirtPosX ( posX ); // centimeters + server_FT->setVirtPosY ( posY ); + server_FT->setVirtPosZ ( posZ ); + + server_FT->setHeadRotX( rotX ); // degrees + server_FT->setHeadRotY( rotY ); + server_FT->setHeadRotZ( rotZ ); + + server_FT->setHeadPosX( posX ); // centimeters + server_FT->setHeadPosY( posY ); + server_FT->setHeadPosZ( posZ ); - server_FT->setVirtPosX ( ( Tracker::X.invert * Tracker::X.sens * (getSmoothFromList( &X.rawList ) - X.offset_headPos) ) * 1000.0f); - server_FT->setVirtPosY ( ( Tracker::Y.invert * Tracker::Y.sens * (getSmoothFromList( &Y.rawList ) - Y.offset_headPos) ) * 1000.0f ); - server_FT->setVirtPosZ ( ( Tracker::Z.invert * Tracker::Z.sens * (getSmoothFromList( &Z.rawList ) - Z.offset_headPos - Tracker::Z.initial_headPos) ) * 1000.0f ); } // FlightGear if (server_FG) { - server_FG->setVirtRotX ( getDegreesFromRads ( Tracker::Pitch.invert * Tracker::Pitch.sens * (getSmoothFromList( &Pitch.rawList ) - Pitch.offset_headPos) ) ); - server_FG->setVirtRotY ( getDegreesFromRads ( Tracker::Yaw.invert * Tracker::Yaw.sens * (getSmoothFromList( &Yaw.rawList ) - Yaw.offset_headPos) ) ); - server_FG->setVirtRotZ ( getDegreesFromRads ( Tracker::Roll.invert * Tracker::Roll.sens * (getSmoothFromList( &Roll.rawList ) - Roll.offset_headPos) ) ); - server_FG->setVirtPosX ( Tracker::X.invert * Tracker::X.sens * (getSmoothFromList( &X.rawList ) - X.offset_headPos) ); - server_FG->setVirtPosY ( Tracker::Y.invert * Tracker::Y.sens * (getSmoothFromList( &Y.rawList ) - Y.offset_headPos) ); - server_FG->setVirtPosZ ( Tracker::Z.invert * Tracker::Z.sens * (getSmoothFromList( &Z.rawList ) - Z.offset_headPos - Tracker::Z.initial_headPos) ); + server_FG->setVirtRotX ( rotX ); // degrees + server_FG->setVirtRotY ( rotY ); + server_FG->setVirtRotZ ( rotZ ); + server_FG->setVirtPosX ( posX ); // centimeters + server_FG->setVirtPosY ( posY ); + server_FG->setVirtPosZ ( posZ ); } // PPJoy virtual joystick if (server_PPJoy) { - server_PPJoy->setVirtRotX ( getDegreesFromRads (Tracker::Pitch.invert * Tracker::Pitch.sens * Pitch.newPos ) ); - server_PPJoy->setVirtRotY ( getDegreesFromRads (Tracker::Yaw.invert * Tracker::Yaw.sens * Yaw.newPos ) ); - server_PPJoy->setVirtRotZ ( getDegreesFromRads (Tracker::Roll.invert * Tracker::Roll.sens * Roll.newPos ) ); + server_PPJoy->setVirtRotX ( rotX ); // degrees + server_PPJoy->setVirtRotY ( rotY ); + server_PPJoy->setVirtRotZ ( rotZ ); - server_PPJoy->setVirtPosX ( ( Tracker::X.invert * Tracker::X.sens * (getSmoothFromList( &X.rawList ) - X.offset_headPos) ) * 100.0f); - server_PPJoy->setVirtPosY ( ( Tracker::Y.invert * Tracker::Y.sens * (getSmoothFromList( &Y.rawList ) - Y.offset_headPos) ) * 100.0f ); - server_PPJoy->setVirtPosZ ( ( Tracker::Z.invert * Tracker::Z.sens * (getSmoothFromList( &Z.rawList ) - Z.offset_headPos - Tracker::Z.initial_headPos) ) * 100.0f ); + server_PPJoy->setVirtPosX ( posX ); // centimeters + server_PPJoy->setVirtPosY ( posY ); + server_PPJoy->setVirtPosZ ( posZ ); } // Fake-trackIR if (server_FTIR) { - float rotX = getDegreesFromRads ( Tracker::Pitch.invert * Tracker::Pitch.sens * Pitch.newPos ); - float rotY = getDegreesFromRads ( Tracker::Yaw.invert * Tracker::Yaw.sens * Yaw.newPos ); - float rotZ = getDegreesFromRads ( Tracker::Roll.invert * Tracker::Roll.sens * Roll.newPos ); -// qDebug() << "Tracker::run() says: virtRotX =" << rotX << " virtRotY =" << rotY; + // For some reason (not yet understood) the values only came through after being copied to locals... + // Trying again?! + //float rotX = getDegreesFromRads ( Tracker::Pitch.invert * Tracker::Pitch.sens * rotX ); + //float rotY = getDegreesFromRads ( Tracker::Yaw.invert * Tracker::Yaw.sens * rotY ); + //float rotZ = getDegreesFromRads ( Tracker::Roll.invert * Tracker::Roll.sens * rotZ ); + qDebug() << "Tracker::run() says: virtRotX =" << rotX << " virtRotY =" << rotY; - server_FTIR->setVirtRotX ( rotX ); + server_FTIR->setVirtRotX ( rotX ); // degrees server_FTIR->setVirtRotY ( rotY ); server_FTIR->setVirtRotZ ( rotZ ); - server_FTIR->setVirtPosX ( ( Tracker::X.invert * Tracker::X.sens * (getSmoothFromList( &X.rawList ) - X.offset_headPos) ) * 1000.0f); - server_FTIR->setVirtPosY ( ( Tracker::Y.invert * Tracker::Y.sens * (getSmoothFromList( &Y.rawList ) - Y.offset_headPos) ) * 1000.0f ); - server_FTIR->setVirtPosZ ( ( Tracker::Z.invert * Tracker::Z.sens * (getSmoothFromList( &Z.rawList ) - Z.offset_headPos - Tracker::Z.initial_headPos) ) * 1000.0f ); + server_FTIR->setVirtPosX ( posX ); // centimeters + server_FTIR->setVirtPosY ( posY ); + server_FTIR->setVirtPosZ ( posZ ); } } @@ -568,52 +610,34 @@ void Tracker::receiveHeadPose(void *,smEngineHeadPoseData head_pose, smCameraVid { // // Perform actions, when valid data is received from faceAPI. + // Write the Raw headpose-data and add it to the RawList, for processing... // if( head_pose.confidence > 0 ) { Tracker::confid = true; - Tracker::setHeadPosX(head_pose.head_pos.x); - Tracker::setHeadPosY(head_pose.head_pos.y); - Tracker::setHeadPosZ(head_pose.head_pos.z); - - Tracker::setHeadRotX(head_pose.head_rot.x_rads); - Tracker::setHeadRotY(head_pose.head_rot.y_rads); - Tracker::setHeadRotZ(head_pose.head_rot.z_rads); // Pitch - Pitch.newPos = getCorrectedNewRaw ( Tracker::Pitch.headPos, rotNeutralZone ); - addRaw2List ( &Pitch.rawList, Pitch.maxItems, Pitch.newPos ); + Tracker::Pitch.headPos = head_pose.head_rot.x_rads * 57.295781f; // degrees + addRaw2List ( &Pitch.rawList, Pitch.maxItems, Tracker::Pitch.headPos ); // Yaw - Yaw.newPos = getCorrectedNewRaw ( Tracker::Yaw.headPos, rotNeutralZone ); - addRaw2List ( &Yaw.rawList, Yaw.maxItems, Yaw.newPos ); + Tracker::Yaw.headPos = head_pose.head_rot.y_rads * 57.295781f; // degrees + addRaw2List ( &Yaw.rawList, Yaw.maxItems, Tracker::Yaw.headPos ); // Roll - Roll.newPos = getCorrectedNewRaw ( Tracker::Roll.headPos, rotNeutralZone ); - addRaw2List ( &Roll.rawList, Roll.maxItems, Roll.newPos ); - - // - // Log something - // - //rate = rateLimiter ( Tracker::Pitch.headPos, &Tracker::Pitch.prevRawPos, dT, 1.0f ); - //QFile data("output.txt"); - //if (data.open(QFile::WriteOnly | QFile::Append)) { - // QTextStream out(&data); - // out << "Limited Raw= " << rate << " dT= " << dT << " Raw= " << Tracker::Pitch.headPos << " Filtered= " << Pitch.newPos << '\n'; - //} - - + Tracker::Roll.headPos = head_pose.head_rot.z_rads * 57.295781f; // degrees + addRaw2List ( &Roll.rawList, Roll.maxItems, Tracker::Roll.headPos ); // X-position - X.newPos = Tracker::X.headPos; - addRaw2List ( &X.rawList, X.maxItems, X.newPos ); + Tracker::X.headPos = head_pose.head_pos.x * 100.0f; // centimeters + addRaw2List ( &X.rawList, X.maxItems, Tracker::X.headPos ); // Y-position - Y.newPos = Tracker::Y.headPos; - addRaw2List ( &Y.rawList, Y.maxItems, Y.newPos ); + Tracker::Y.headPos = head_pose.head_pos.y * 100.0f; // centimeters + addRaw2List ( &Y.rawList, Y.maxItems, Tracker::Y.headPos ); // Z-position (distance to camera, absolute!) - Z.newPos = Tracker::Z.headPos; - addRaw2List ( &Z.rawList, Z.maxItems, Z.newPos ); + Tracker::Z.headPos = head_pose.head_pos.z * 100.0f; // centimeters + addRaw2List ( &Z.rawList, Z.maxItems, Tracker::Z.headPos ); } else { Tracker::confid = false; @@ -773,8 +797,25 @@ float clamped_value = 0.0f; // // Get the output from the curve. // -float Tracker::getOutputFromCurve ( QPainterPath *curve, float input ) { - return curve->pointAtPercent(input/100.0f).x(); +float Tracker::getOutputFromCurve ( QPainterPath *curve, float input, float neutralzone, float maxinput ) { +float sign; + + sign = 1.0f; + if (input < 0.0f) { + sign = -1.0f; + } + + // + // Always return 0 inside the NeutralZone + // Always return max. when input larger than expected + // + if (fabs(input) < neutralzone) return 0.0f; + if (fabs(input) > maxinput) return sign * curve->pointAtPercent(1.0).x(); + + // + // Return the value, derived from the Bezier-curve + // + return sign * curve->pointAtPercent((fabs(input) - neutralzone)/maxinput).x(); } // @@ -813,32 +854,38 @@ QPointF point1, point2, point3, point4; iniFile.beginGroup ( "Curves" ); getCurvePoints( &iniFile, "Yaw_", &point1, &point2, &point3, &point4, NeutralZone, sensYaw, 50, 180 ); Yaw.curve.moveTo( QPointF(0,0) ); - Yaw.curve.lineTo(point1); + Yaw.NeutralZone = point1.y(); // Get the Neutral Zone + Yaw.MaxInput = point4.y(); // Get Maximum Input Yaw.curve.cubicTo(point2, point3, point4); getCurvePoints( &iniFile, "Pitch_", &point1, &point2, &point3, &point4, NeutralZone, sensPitch, 50, 180 ); Pitch.curve.moveTo( QPointF(0,0) ); - Pitch.curve.lineTo(point1); - Pitch.curve.cubicTo(point2, point3, point4); + Pitch.NeutralZone = point1.y(); // Get the Neutral Zone + Pitch.MaxInput = point4.y(); // Get Maximum Input + Pitch.curve.cubicTo(point2, point3, point4); getCurvePoints( &iniFile, "Roll_", &point1, &point2, &point3, &point4, NeutralZone, sensRoll, 50, 180 ); Roll.curve.moveTo( QPointF(0,0) ); - Roll.curve.lineTo(point1); + Roll.NeutralZone = point1.y(); // Get the Neutral Zone + Roll.MaxInput = point4.y(); // Get Maximum Input Roll.curve.cubicTo(point2, point3, point4); getCurvePoints( &iniFile, "X_", &point1, &point2, &point3, &point4, NeutralZone, sensX, 50, 180 ); X.curve.moveTo( QPointF(0,0) ); - X.curve.lineTo(point1); + X.NeutralZone = point1.y(); // Get the Neutral Zone + X.MaxInput = point4.y(); // Get Maximum Input X.curve.cubicTo(point2, point3, point4); getCurvePoints( &iniFile, "Y_", &point1, &point2, &point3, &point4, NeutralZone, sensY, 50, 180 ); Y.curve.moveTo( QPointF(0,0) ); - Y.curve.lineTo(point1); + Y.NeutralZone = point1.y(); // Get the Neutral Zone + Y.MaxInput = point4.y(); // Get Maximum Input Y.curve.cubicTo(point2, point3, point4); getCurvePoints( &iniFile, "Z_", &point1, &point2, &point3, &point4, NeutralZone, sensZ, 50, 180 ); Z.curve.moveTo( QPointF(0,0) ); - Z.curve.lineTo(point1); + Z.NeutralZone = point1.y(); // Get the Neutral Zone + Z.MaxInput = point4.y(); // Get Maximum Input Z.curve.cubicTo(point2, point3, point4); iniFile.endGroup (); diff --git a/FaceTrackNoIR/tracker.h b/FaceTrackNoIR/tracker.h index 51d83f41..e3d6063f 100644 --- a/FaceTrackNoIR/tracker.h +++ b/FaceTrackNoIR/tracker.h @@ -74,15 +74,15 @@ struct THeadPoseDOF { float headPos; // Current position (from faceTracker, radials or meters) float initial_headPos; // Position on startup (first valid value) float offset_headPos; // Offset for centering - float sens; // Sensitivity (multiplication factor) float invert; // Invert measured value (= 1.0f or -1.0f) float red; // Reduction factor (used for EWMA-filtering, between 0.0f and 1.0f) QList rawList; // List of 'n' headPos values (used for moving average) int maxItems; // Maximum number of elements is rawList - float newPos; // New Position (used locally) float prevPos; // Previous Position float prevRawPos; // Previous Raw Position QPainterPath curve; // Bezier curve to translate input -> output + int NeutralZone; // Neutral zone + int MaxInput; // Maximum raw input }; // @@ -136,7 +136,6 @@ private: static bool do_center; // Center head-position, using EQUALS key on keyboard static bool useFilter; - static float rotNeutralZone; // Neutral Zone for rotations (rad). static long prevHeadPoseTime; // Time from previous sample /** QT objects **/ @@ -172,33 +171,25 @@ public: bool isShortKeyPressed( TShortKey *key, BYTE *keystate ); QSharedPointer getEngine() { return _engine; }; -// smEngineHandle getEngineHandle() { return _engine->handle(); }; - static float getHeadPosX() {return X.headPos;} - static float getHeadPosY() {return Y.headPos;} - static float getHeadPosZ() {return Z.headPos;} + //static float getHeadPosX() {return X.headPos;} + //static float getHeadPosY() {return Y.headPos;} + //static float getHeadPosZ() {return Z.headPos;} - static void setHeadPosX(float x) { X.headPos = x; } - static void setHeadPosY(float y) { Y.headPos = y; } - static void setHeadPosZ(float z) { Z.headPos = z; } + //static void setHeadPosX(float x) { X.headPos = x; } + //static void setHeadPosY(float y) { Y.headPos = y; } + //static void setHeadPosZ(float z) { Z.headPos = z; } - static float getHeadRotX() {return Pitch.headPos;} - static float getHeadRotY() {return Yaw.headPos;} - static float getHeadRotZ() {return Roll.headPos;} + //static float getHeadRotX() {return Pitch.headPos;} + //static float getHeadRotY() {return Yaw.headPos;} + //static float getHeadRotZ() {return Roll.headPos;} - static void setHeadRotX(float x) { Pitch.headPos = x; } - static void setHeadRotY(float y) { Yaw.headPos = y; } - static void setHeadRotZ(float z) { Roll.headPos = z; } + //static void setHeadRotX(float x) { Pitch.headPos = x; } + //static void setHeadRotY(float y) { Yaw.headPos = y; } + //static void setHeadRotZ(float z) { Roll.headPos = z; } static bool getConfid() { return confid; } - static void setSensPitch(int x) { Pitch.sens = x/100.0f; } - static void setSensYaw(int x) { Yaw.sens = x/100.0f; } - static void setSensRoll(int x) { Roll.sens = x/100.0f; } - static void setSensX(int x) { X.sens = x/100.0f; } - static void setSensY(int x) { Y.sens = x/100.0f; } - static void setSensZ(int x) { Z.sens = x/100.0f; } - static void setInvertPitch(bool invert) { Pitch.invert = invert?-1.0f:+1.0f; } static void setInvertYaw(bool invert) { Yaw.invert = invert?-1.0f:+1.0f; } static void setInvertRoll(bool invert) { Roll.invert = invert?-1.0f:+1.0f; } @@ -215,11 +206,10 @@ public: static void setRedY(int x) { Y.red = x/100.0f; } static void setRedZ(int x) { Z.red = x/100.0f; } - static void setNeutralZone(int x) { rotNeutralZone = (x * 2.0f * 3.14159)/360.0f; } - - float getSmoothFromList ( QList *rawList ); - float getDegreesFromRads ( float rads ) { return (rads * 57.295781f); } - float getOutputFromCurve ( QPainterPath *curve, float input ); + static float getSmoothFromList ( QList *rawList ); + static float getDegreesFromRads ( float rads ) { return (rads * 57.295781f); } + static float getRadsFromDegrees ( float degrees ) { return (degrees * 0.017453f); } + static float getOutputFromCurve ( QPainterPath *curve, float input, float neutralzone, float maxinput ); // For now, use one slider for all void setSmoothing(int x) { -- cgit v1.2.3