From acdb0aaf27e2ca623a9e32ea7efcc484aecde498 Mon Sep 17 00:00:00 2001 From: Wim Vriend Date: Mon, 26 Nov 2012 21:00:55 +0000 Subject: Reversed the numTracker tryout to accomodate the secondary Tracker: the user-interface was confusing. Now, the 1st Tracker overwrites the values, if the same axis were selected in both trackers. git-svn-id: svn+ssh://svn.code.sf.net/p/facetracknoir/code@196 19e81ba0-9b1a-49c3-bd6c-561e1906d5fb --- FTNoIR_Tracker_SM/FTNoIR_SM_Controls.ui | 29 +++++- FTNoIR_Tracker_SM/FTNoIR_Tracker_SM.h | 16 +--- FTNoIR_Tracker_SM/ftnoir_tracker_faceapi.cpp | 46 ++-------- .../ftnoir_tracker_faceapi_dialog.cpp | 102 +++++---------------- 4 files changed, 59 insertions(+), 134 deletions(-) (limited to 'FTNoIR_Tracker_SM') diff --git a/FTNoIR_Tracker_SM/FTNoIR_SM_Controls.ui b/FTNoIR_Tracker_SM/FTNoIR_SM_Controls.ui index 170a4a46..9fa1b2e4 100644 --- a/FTNoIR_Tracker_SM/FTNoIR_SM_Controls.ui +++ b/FTNoIR_Tracker_SM/FTNoIR_SM_Controls.ui @@ -391,6 +391,31 @@ + + + + + 0 + 0 + + + + + 70 + 0 + + + + + 100 + 16777215 + + + + Save + + + @@ -406,7 +431,7 @@ - 100 + 70 0 @@ -431,7 +456,7 @@ - 100 + 70 0 diff --git a/FTNoIR_Tracker_SM/FTNoIR_Tracker_SM.h b/FTNoIR_Tracker_SM/FTNoIR_Tracker_SM.h index e62009f5..ce8f5511 100644 --- a/FTNoIR_Tracker_SM/FTNoIR_Tracker_SM.h +++ b/FTNoIR_Tracker_SM/FTNoIR_Tracker_SM.h @@ -40,7 +40,7 @@ public: FTNoIR_Tracker(); ~FTNoIR_Tracker(); - void Initialize( QFrame *videoframe, int numTracker ); + void Initialize( QFrame *videoframe ); void StartTracker( HWND parent_window ); void StopTracker( bool exit ); bool GiveHeadPoseData(THeadPoseData *data); // Returns true if confidence is good @@ -56,7 +56,7 @@ private: HANDLE hSMMutex; QProcess *faceAPI; - int numTracker; +// int numTracker; bool bEnableRoll; bool bEnablePitch; bool bEnableYaw; @@ -82,7 +82,7 @@ public: virtual ~TrackerControls(); void showEvent ( QShowEvent * event ); - void Initialize(QWidget *parent, int numTracker); + void Initialize(QWidget *parent); void registerTracker(ITracker *tracker) { theTracker = (FTNoIR_Tracker *) tracker; // Accept the pointer to the Tracker }; @@ -93,7 +93,6 @@ public: private: Ui::UICSMClientControls ui; void loadSettings(); - void save(); bool SMCreateMapping(); void doCommand( int command ); void doCommand( int command, int value ); @@ -112,18 +111,11 @@ private: QTimer *timUpdateSettings; // Timer to display current settings FTNoIR_Tracker *theTracker; - int numTracker; // Primary (1) or secondary tracker (2) - - int numRoll; // Number of Tracker (1 or 2) which tracks this axis - int numPitch; - int numYaw; - int numX; - int numY; - int numZ; private slots: void doOK(); void doCancel(); + void save(); void settingChanged() { settingsDirty = true; }; void doTimUpdate(); void showSettings( int newState ); diff --git a/FTNoIR_Tracker_SM/ftnoir_tracker_faceapi.cpp b/FTNoIR_Tracker_SM/ftnoir_tracker_faceapi.cpp index 23b973cb..f8320294 100644 --- a/FTNoIR_Tracker_SM/ftnoir_tracker_faceapi.cpp +++ b/FTNoIR_Tracker_SM/ftnoir_tracker_faceapi.cpp @@ -37,7 +37,6 @@ FTNoIR_Tracker::~FTNoIR_Tracker() UnmapViewOfFile ( pMemData ); } - numTracker = 1; bEnableRoll = true; bEnablePitch = true; bEnableYaw = true; @@ -57,7 +56,7 @@ FTNoIR_Tracker::~FTNoIR_Tracker() hSMMemMap = 0; } -void FTNoIR_Tracker::Initialize( QFrame *videoframe, int num) +void FTNoIR_Tracker::Initialize( QFrame *videoframe ) { qDebug() << "FTNoIR_Tracker::Initialize says: Starting "; @@ -68,7 +67,6 @@ void FTNoIR_Tracker::Initialize( QFrame *videoframe, int num) QMessageBox::warning(0,"FaceTrackNoIR Error","Memory mapping not created!",QMessageBox::Ok,QMessageBox::NoButton); } - numTracker = num; loadSettings(); if ( pMemData != NULL ) { @@ -167,12 +165,6 @@ bool FTNoIR_Tracker::GiveHeadPoseData(THeadPoseData *data) // Load the current Settings from the currently 'active' INI-file. // void FTNoIR_Tracker::loadSettings() { -int numRoll; // Number of Tracker (1 or 2) which tracks this axis -int numPitch; -int numYaw; -int numX; -int numY; -int numZ; qDebug() << "FTNoIR_Tracker::loadSettings says: Starting "; QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // Registry settings (in HK_USER) @@ -193,38 +185,14 @@ int numZ; dInvertY = (iniFile.value ( "InvertY", 0 ).toBool()) ? -1.0f : 1.0f; dInvertZ = (iniFile.value ( "InvertZ", 0 ).toBool()) ? -1.0f : 1.0f; - iniFile.endGroup (); - - iniFile.beginGroup ( "HeadTracker" ); - // - // Check if the Tracker is the Primary one. - // If the property is not found in the INI-file, set the value. - // - if (numTracker == 1) { - numRoll = iniFile.value ( "RollTracker", 1 ).toInt(); - numPitch = iniFile.value ( "PitchTracker", 1 ).toInt(); - numYaw = iniFile.value ( "YawTracker", 1 ).toInt(); - numX = iniFile.value ( "XTracker", 0 ).toInt(); - numY = iniFile.value ( "YTracker", 0 ).toInt(); - numZ = iniFile.value ( "ZTracker", 0 ).toInt(); - } - else { - numRoll = iniFile.value ( "RollTracker", 0 ).toInt(); - numPitch = iniFile.value ( "PitchTracker", 0 ).toInt(); - numYaw = iniFile.value ( "YawTracker", 0 ).toInt(); - numX = iniFile.value ( "XTracker", 0 ).toInt(); - numY = iniFile.value ( "YTracker", 0 ).toInt(); - numZ = iniFile.value ( "ZTracker", 0 ).toInt(); - } - bEnableRoll = (numRoll == numTracker); - bEnablePitch = (numPitch == numTracker); - bEnableYaw = (numYaw == numTracker); - bEnableX = (numX == numTracker); - bEnableY = (numY == numTracker); - bEnableZ = (numZ == numTracker); + bEnableRoll = iniFile.value ( "EnableRoll", 1 ).toBool(); + bEnablePitch = iniFile.value ( "EnablePitch", 1 ).toBool(); + bEnableYaw = iniFile.value ( "EnableYaw", 1 ).toBool(); + bEnableX = iniFile.value ( "EnableX", 1 ).toBool(); + bEnableY = iniFile.value ( "EnableY", 1 ).toBool(); + bEnableZ = iniFile.value ( "EnableZ", 1 ).toBool(); iniFile.endGroup (); - } // diff --git a/FTNoIR_Tracker_SM/ftnoir_tracker_faceapi_dialog.cpp b/FTNoIR_Tracker_SM/ftnoir_tracker_faceapi_dialog.cpp index f9d1047f..7d16b3e3 100644 --- a/FTNoIR_Tracker_SM/ftnoir_tracker_faceapi_dialog.cpp +++ b/FTNoIR_Tracker_SM/ftnoir_tracker_faceapi_dialog.cpp @@ -44,6 +44,7 @@ QWidget() connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); connect(ui.btnEngineStart, SIGNAL(clicked()), this, SLOT(doStartEngine())); connect(ui.btnEngineStop, SIGNAL(clicked()), this, SLOT(doStopEngine())); + connect(ui.btnSave, SIGNAL(clicked()), this, SLOT(save())); ui.cbxFilterSetting->addItem("None"); ui.cbxFilterSetting->addItem("Normal"); @@ -90,7 +91,7 @@ TrackerControls::~TrackerControls() { // // Initialize tracker-client-dialog // -void TrackerControls::Initialize(QWidget *parent, int num) { +void TrackerControls::Initialize(QWidget *parent) { QPoint offsetpos(200, 200); if (parent) { @@ -98,7 +99,6 @@ void TrackerControls::Initialize(QWidget *parent, int num) { } // Load the settings from the current .INI-file - numTracker = num; loadSettings(); show(); @@ -165,6 +165,7 @@ void TrackerControls::loadSettings() { iniFile.beginGroup ( "SMTracker" ); ui.cbxFilterSetting->setCurrentIndex(iniFile.value ( "FilterLevel", 1 ).toInt()); + ui.chkInvertRoll->setChecked(iniFile.value ( "InvertRoll", 0 ).toBool()); ui.chkInvertPitch->setChecked(iniFile.value ( "InvertPitch", 0 ).toBool()); ui.chkInvertYaw->setChecked(iniFile.value ( "InvertYaw", 0 ).toBool()); @@ -172,35 +173,13 @@ void TrackerControls::loadSettings() { ui.chkInvertY->setChecked(iniFile.value ( "InvertY", 0 ).toBool()); ui.chkInvertZ->setChecked(iniFile.value ( "InvertZ", 0 ).toBool()); - iniFile.endGroup (); + ui.chkEnableRoll->setChecked(iniFile.value ( "EnableRoll", 1 ).toBool()); + ui.chkEnablePitch->setChecked(iniFile.value ( "EnablePitch", 1 ).toBool()); + ui.chkEnableYaw->setChecked(iniFile.value ( "EnableYaw", 1 ).toBool()); + ui.chkEnableX->setChecked(iniFile.value ( "EnableX", 1 ).toBool()); + ui.chkEnableY->setChecked(iniFile.value ( "EnableY", 1 ).toBool()); + ui.chkEnableZ->setChecked(iniFile.value ( "EnableZ", 1 ).toBool()); - iniFile.beginGroup ( "HeadTracker" ); - // - // Check if the Tracker is the Primary one. - // If the property is not found in the INI-file, set the value. - // - if (numTracker == 1) { - numRoll = iniFile.value ( "RollTracker", 1 ).toInt(); - numPitch = iniFile.value ( "PitchTracker", 1 ).toInt(); - numYaw = iniFile.value ( "YawTracker", 1 ).toInt(); - numX = iniFile.value ( "XTracker", 0 ).toInt(); - numY = iniFile.value ( "YTracker", 0 ).toInt(); - numZ = iniFile.value ( "ZTracker", 0 ).toInt(); - } - else { - numRoll = iniFile.value ( "RollTracker", 0 ).toInt(); - numPitch = iniFile.value ( "PitchTracker", 0 ).toInt(); - numYaw = iniFile.value ( "YawTracker", 0 ).toInt(); - numX = iniFile.value ( "XTracker", 0 ).toInt(); - numY = iniFile.value ( "YTracker", 0 ).toInt(); - numZ = iniFile.value ( "ZTracker", 0 ).toInt(); - } - ui.chkEnableRoll->setChecked(numRoll == numTracker); - ui.chkEnablePitch->setChecked(numPitch == numTracker); - ui.chkEnableYaw->setChecked(numYaw == numTracker); - ui.chkEnableX->setChecked(numX == numTracker); - ui.chkEnableY->setChecked(numY == numTracker); - ui.chkEnableZ->setChecked(numZ == numTracker); iniFile.endGroup (); settingsDirty = false; @@ -224,62 +203,23 @@ void TrackerControls::save() { iniFile.setValue ( "InvertX", ui.chkInvertX->isChecked() ); iniFile.setValue ( "InvertY", ui.chkInvertY->isChecked() ); iniFile.setValue ( "InvertZ", ui.chkInvertZ->isChecked() ); - iniFile.endGroup (); - iniFile.beginGroup ( "HeadTracker" ); - if ( ui.chkEnableRoll->isChecked() ) { - iniFile.setValue ( "RollTracker", numTracker ); - } - else { - if (numRoll == numTracker) { - iniFile.setValue ( "RollTracker", 0 ); - } - } + iniFile.setValue ( "EnableRoll", ui.chkEnableRoll->isChecked() ); + iniFile.setValue ( "EnablePitch", ui.chkEnablePitch->isChecked() ); + iniFile.setValue ( "EnableYaw", ui.chkEnableYaw->isChecked() ); + iniFile.setValue ( "EnableX", ui.chkEnableX->isChecked() ); + iniFile.setValue ( "EnableY", ui.chkEnableY->isChecked() ); + iniFile.setValue ( "EnableZ", ui.chkEnableZ->isChecked() ); - if ( ui.chkEnablePitch->isChecked() ) { - iniFile.setValue ( "PitchTracker", numTracker ); - } - else { - if (numPitch == numTracker) { - iniFile.setValue ( "PitchTracker", 0 ); - } - } + iniFile.endGroup (); - if ( ui.chkEnableYaw->isChecked() ) { - iniFile.setValue ( "YawTracker", numTracker ); - } - else { - if (numYaw == numTracker) { - iniFile.setValue ( "YawTracker", 0 ); - } - } - if ( ui.chkEnableX->isChecked() ) { - iniFile.setValue ( "XTracker", numTracker ); - } - else { - if (numX == numTracker) { - iniFile.setValue ( "XTracker", 0 ); - } - } - if ( ui.chkEnableY->isChecked() ) { - iniFile.setValue ( "YTracker", numTracker ); - } - else { - if (numY == numTracker) { - iniFile.setValue ( "YTracker", 0 ); - } - } - if ( ui.chkEnableZ->isChecked() ) { - iniFile.setValue ( "ZTracker", numTracker ); - } - else { - if (numZ == numTracker) { - iniFile.setValue ( "ZTracker", 0 ); - } + // + // If the Tracker is active, let it load the new Settings. + // + if (theTracker) { + theTracker->loadSettings(); } - iniFile.endGroup (); - settingsDirty = false; } -- cgit v1.2.3