From d3ff506356286dd7cbff67b8736482539a317006 Mon Sep 17 00:00:00 2001 From: Wim Vriend Date: Mon, 7 Feb 2011 21:36:06 +0000 Subject: Added option to stop tracking, but keep the engine running. Improved KeyboardShortcutDialog git-svn-id: svn+ssh://svn.code.sf.net/p/facetracknoir/code@48 19e81ba0-9b1a-49c3-bd6c-561e1906d5fb --- FaceTrackNoIR/FTNoIR_KeyboardShortcuts.ui | 721 ++++++++++++++++++------------ FaceTrackNoIR/FaceTrackNoIR.cpp | 7 + FaceTrackNoIR/FaceTrackNoIR.h | 1 + FaceTrackNoIR/tracker.cpp | 10 +- FaceTrackNoIR/tracker.h | 1 + 5 files changed, 447 insertions(+), 293 deletions(-) (limited to 'FaceTrackNoIR') diff --git a/FaceTrackNoIR/FTNoIR_KeyboardShortcuts.ui b/FaceTrackNoIR/FTNoIR_KeyboardShortcuts.ui index cbd0514d..3a8b98a8 100644 --- a/FaceTrackNoIR/FTNoIR_KeyboardShortcuts.ui +++ b/FaceTrackNoIR/FTNoIR_KeyboardShortcuts.ui @@ -6,8 +6,8 @@ 0 0 - 638 - 165 + 558 + 270 @@ -25,295 +25,434 @@ - - - - - - 0 - 0 - - - - Center - - - false - - - - - - - - 50 - 16777215 - - - - Shift - - - - - - - - 50 - 16777215 - - - - Ctrl - - - - - - - - 50 - 16777215 - - - - Alt - - - - - - - - 90 - 0 - - - - Select Number - - - QComboBox::InsertAlphabetically - - - - - - - Start/stop - - - - - - - - 50 - 16777215 - - - - Shift - - - - - - - - 50 - 16777215 - - - - Ctrl - - - - - - - - 50 - 16777215 - - - - Alt - - - - - - - - 90 - 0 - - - - - - - - Axis Inhibitor - - - - - - - - 50 - 16777215 - - - - Shift - - - - - - - - 50 - 16777215 - - - - Ctrl - - - - - - - - 50 - 16777215 - - - - Alt - - - - - - - - 90 - 0 - - - - - - - - - 50 - 16777215 - - - - Pitch - - - - - - - - 50 - 16777215 - - - - Yaw - - - - - - - - 50 - 16777215 - - - - Roll - - - - - - - - 30 - 16777215 - - - - X - - - - - - - - 30 - 16777215 - - - - Y - - - - - - - - 30 - 16777215 - - - - Z - - - - - - - Disables: - - - - - - - Zero - - - - - - - Stay - - - - - - - When OFF: - - + + + + + + + Disables: + + + + + + + When OFF: + + + + + + + + 0 + 0 + + + + Center + + + false + + + + + + + Axis Inhibitor + + + + + + + + 50 + 16777215 + + + + Shift + + + + + + + + 50 + 16777215 + + + + Shift + + + + + + + + 50 + 16777215 + + + + Shift + + + + + + + + 50 + 16777215 + + + + Ctrl + + + + + + + + 50 + 16777215 + + + + Ctrl + + + + + + + + 50 + 16777215 + + + + Ctrl + + + + + + + + 50 + 16777215 + + + + Alt + + + + + + + + 50 + 16777215 + + + + Alt + + + + + + + + 50 + 16777215 + + + + Alt + + + + + + + + 90 + 0 + + + + Select Number + + + QComboBox::InsertAlphabetically + + + + + + + + 90 + 0 + + + + + + + + + 90 + 0 + + + + + + + + + 0 + 80 + + + + color: rgb(0, 0, 0); + + + Rotations + + + + + 10 + 20 + 50 + 17 + + + + + 50 + 16777215 + + + + Yaw + + + + + + 10 + 40 + 46 + 17 + + + + + 50 + 16777215 + + + + Pitch + + + + + + 10 + 60 + 50 + 17 + + + + + 50 + 16777215 + + + + Roll + + + + + + + + + 60 + 60 + + + + color: rgb(0, 0, 0); + + + View + + + + + 10 + 20 + 46 + 17 + + + + Zero + + + + + + 10 + 40 + 45 + 17 + + + + Stay + + + + + + + + Start/stop + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + color: rgb(0, 0, 0); + + + Translations + + + + + 10 + 20 + 30 + 17 + + + + + 30 + 16777215 + + + + X + + + + + + 10 + 40 + 30 + 17 + + + + + 30 + 16777215 + + + + Y + + + + + + 10 + 60 + 30 + 17 + + + + + 30 + 16777215 + + + + Z + + + + + + + + + 100 + 0 + + + + color: rgb(0, 0, 0); + + + Engine tracker + + + + + 10 + 20 + 81 + 17 + + + + Stop Engine + + + + + + 10 + 40 + 91 + 17 + + + + Keep tracking + + + + + diff --git a/FaceTrackNoIR/FaceTrackNoIR.cpp b/FaceTrackNoIR/FaceTrackNoIR.cpp index eda9b51b..3502d3c4 100644 --- a/FaceTrackNoIR/FaceTrackNoIR.cpp +++ b/FaceTrackNoIR/FaceTrackNoIR.cpp @@ -23,6 +23,7 @@ *********************************************************************************/ /* Modifications (last one on top): + 20110207 - WVR: RadioButtons for 'Stop engine' added. It is now possible to choose Stop or Keep tracking. 20110109 - WVR: Added minimizeTaskBar option added. It is now possible to choose minimized or tray. */ #include "FaceTrackNoIR.h" @@ -1122,6 +1123,8 @@ QWidget( parent , f) connect(ui.chkStartStopShift, SIGNAL(stateChanged(int)), this, SLOT(keyChanged(int))); connect(ui.chkStartStopCtrl, SIGNAL(stateChanged(int)), this, SLOT(keyChanged(int))); connect(ui.chkStartStopAlt, SIGNAL(stateChanged(int)), this, SLOT(keyChanged(int))); + connect(ui.radioSetZero, SIGNAL(toggled(bool)), this, SLOT(keyChanged(bool))); + connect(ui.radioSetEngineStop, SIGNAL(toggled(bool)), this, SLOT(keyChanged(bool))); connect(ui.cbxInhibitKey, SIGNAL(currentIndexChanged(int)), this, SLOT(keyChanged( int ))); connect(ui.chkInhibitShift, SIGNAL(stateChanged(int)), this, SLOT(keyChanged(int))); @@ -1374,6 +1377,9 @@ int keyindex; ui.chkStartStopCtrl->setChecked (iniFile.value ( "Ctrl_StartStop", 0 ).toBool()); ui.chkStartStopAlt->setChecked (iniFile.value ( "Alt_StartStop", 0 ).toBool()); ui.radioSetZero->setChecked (iniFile.value ( "SetZero", 1 ).toBool()); + ui.radioSetFreeze->setChecked(!ui.radioSetZero->isChecked()); + ui.radioSetEngineStop->setChecked (iniFile.value ( "SetEngineStop", 1 ).toBool()); + ui.radioSetKeepTracking->setChecked(!ui.radioSetEngineStop->isChecked()); // Axis-inhibitor key keyindex = keyList.indexOf ( iniFile.value ( "Keycode_Inhibit", 1 ).toInt() ); @@ -1423,6 +1429,7 @@ void KeyboardShortcutDialog::save() { iniFile.setValue ( "Ctrl_StartStop", ui.chkStartStopCtrl->isChecked() ); iniFile.setValue ( "Alt_StartStop", ui.chkStartStopAlt->isChecked() ); iniFile.setValue ( "SetZero", ui.radioSetZero->isChecked() ); + iniFile.setValue ( "SetEngineStop", ui.radioSetEngineStop->isChecked() ); iniFile.setValue ( "Keycode_Inhibit", keyList.at( ui.cbxInhibitKey->currentIndex() ) ); iniFile.setValue ( "Shift_Inhibit", ui.chkInhibitShift->isChecked() ); diff --git a/FaceTrackNoIR/FaceTrackNoIR.h b/FaceTrackNoIR/FaceTrackNoIR.h index c1d48a4b..af0df504 100644 --- a/FaceTrackNoIR/FaceTrackNoIR.h +++ b/FaceTrackNoIR/FaceTrackNoIR.h @@ -197,6 +197,7 @@ private slots: void doOK(); void doCancel(); void keyChanged( int index ) { settingsDirty = true; }; + void keyChanged( bool index ) { settingsDirty = true; }; }; // Widget that has controls for Keyboard shortcuts. diff --git a/FaceTrackNoIR/tracker.cpp b/FaceTrackNoIR/tracker.cpp index 90efc9d6..91c386c0 100644 --- a/FaceTrackNoIR/tracker.cpp +++ b/FaceTrackNoIR/tracker.cpp @@ -66,6 +66,7 @@ bool Tracker::do_center = false; bool Tracker::do_inhibit = false; bool Tracker::useFilter = false; bool Tracker::setZero = true; +bool Tracker::setEngineStop = true; HANDLE Tracker::hTrackMutex = 0; long Tracker::prevHeadPoseTime = 0; @@ -440,10 +441,14 @@ void Tracker::run() { current_camera_position.pitch = 0.0f; current_camera_position.roll = 0.0f; - _engine->start(); + if (_engine->state() != SM_API_ENGINE_STATE_HT_TRACKING) { + _engine->start(); + } } else { - _engine->stop(); + if (setEngineStop) { // Only stop engine when option is checked + _engine->stop(); + } } qDebug() << "Tracker::run() says StartStop pressed, do_tracking =" << Tracker::do_tracking; } @@ -1082,6 +1087,7 @@ QPointF point1, point2, point3, point4; StartStopKey.ctrl = iniFile.value ( "Ctrl_StartStop", 0 ).toBool(); StartStopKey.alt = iniFile.value ( "Alt_StartStop", 0 ).toBool(); setZero = iniFile.value ( "SetZero", 1 ).toBool(); + setEngineStop = iniFile.value ( "SetEngineStop", 1 ).toBool(); // Inhibit key InhibitKey.keycode = iniFile.value ( "Keycode_Inhibit", 0 ).toInt(); diff --git a/FaceTrackNoIR/tracker.h b/FaceTrackNoIR/tracker.h index 6c436ff8..56be4771 100644 --- a/FaceTrackNoIR/tracker.h +++ b/FaceTrackNoIR/tracker.h @@ -178,6 +178,7 @@ private: static bool useFilter; // Use EWMA-filtering static bool setZero; // Set to zero's, when OFF (one-shot) + static bool setEngineStop; // Stop tracker->engine, when OFF static long prevHeadPoseTime; // Time from previous sample /** QT objects **/ -- cgit v1.2.3