From d6086d8203ae4f4b45f3d97960788d603fc78e16 Mon Sep 17 00:00:00 2001 From: Wim Vriend Date: Mon, 9 Jan 2012 17:01:44 +0000 Subject: Implemented filter-settings changeably while Tracker is active. Should also be handy to have a IFilterPtr, for logging... git-svn-id: svn+ssh://svn.code.sf.net/p/facetracknoir/code@99 19e81ba0-9b1a-49c3-bd6c-561e1906d5fb --- FTNoIR_Filter_EWMA2/FTNoIR_FilterControls.ui | 124 ++++++++++++++++++--- FTNoIR_Filter_EWMA2/FTNoIR_Filter_EWMA2.h | 4 +- FTNoIR_Filter_EWMA2/ftnoir_filter_ewma2.cpp | 28 ++++- FTNoIR_Filter_EWMA2/ftnoir_filter_ewma2_dialog.cpp | 21 +++- 4 files changed, 157 insertions(+), 20 deletions(-) (limited to 'FTNoIR_Filter_EWMA2') diff --git a/FTNoIR_Filter_EWMA2/FTNoIR_FilterControls.ui b/FTNoIR_Filter_EWMA2/FTNoIR_FilterControls.ui index fbc56447..cbd61d53 100644 --- a/FTNoIR_Filter_EWMA2/FTNoIR_FilterControls.ui +++ b/FTNoIR_Filter_EWMA2/FTNoIR_FilterControls.ui @@ -23,6 +23,9 @@ false + + + @@ -41,8 +44,7 @@ - color:#ccc; -background:none; + Min. @@ -64,8 +66,7 @@ background:none; - color:#ccc; -background:none; + Max. @@ -87,8 +88,7 @@ background:none; - color:#ccc; -background:none; + Curve @@ -163,8 +163,7 @@ background:none; - color:#ccc; -background:none; + frames @@ -239,8 +238,7 @@ background:none; - color:#ccc; -background:none; + frames @@ -312,8 +310,7 @@ background:none; - color:#ccc; -background:none; + pow @@ -393,7 +390,7 @@ background:none; - 100 + 52 0 @@ -418,7 +415,7 @@ background:none; - 100 + 52 0 @@ -460,7 +457,104 @@ background:none; btnCancel - + + + minSmooth + valueChanged(int) + spinMinSmooth + setValue(int) + + + 199 + 22 + + + 337 + 23 + + + + + spinMinSmooth + valueChanged(int) + minSmooth + setValue(int) + + + 330 + 12 + + + 185 + 17 + + + + + maxSmooth + valueChanged(int) + spinMaxSmooth + setValue(int) + + + 181 + 48 + + + 335 + 54 + + + + + spinMaxSmooth + valueChanged(int) + maxSmooth + setValue(int) + + + 324 + 42 + + + 259 + 43 + + + + + powCurve + valueChanged(int) + spinPowCurve + setValue(int) + + + 145 + 74 + + + 339 + 78 + + + + + spinPowCurve + valueChanged(int) + powCurve + setValue(int) + + + 330 + 69 + + + 176 + 76 + + + + startEngineClicked() stopEngineClicked() diff --git a/FTNoIR_Filter_EWMA2/FTNoIR_Filter_EWMA2.h b/FTNoIR_Filter_EWMA2/FTNoIR_Filter_EWMA2.h index 398f5e75..feec6f1f 100644 --- a/FTNoIR_Filter_EWMA2/FTNoIR_Filter_EWMA2.h +++ b/FTNoIR_Filter_EWMA2/FTNoIR_Filter_EWMA2.h @@ -52,6 +52,7 @@ public: bool setParameterValue(const int index, const float newvalue); private: + void loadSettings(); // Load the settings from the INI-file THeadPoseData newHeadPose; // Structure with new headpose bool first_run; @@ -97,7 +98,7 @@ public: void showEvent ( QShowEvent * event ); void Release(); // Member functions which are accessible from outside the DLL - void Initialize(QWidget *parent); + void Initialize(QWidget *parent, IFilterPtr ptr); void getFilterFullName(QString *strToBeFilled); void getFilterShortName(QString *strToBeFilled); void getFilterDescription(QString *strToBeFilled); @@ -113,6 +114,7 @@ private: QString filterFullName; // Filters' name and description QString filterShortName; QString filterDescription; + IFilterPtr pFilter; // If the filter was active when the dialog was opened, this will hold a pointer to the Filter instance private slots: void doOK(); diff --git a/FTNoIR_Filter_EWMA2/ftnoir_filter_ewma2.cpp b/FTNoIR_Filter_EWMA2/ftnoir_filter_ewma2.cpp index b119df27..7034a152 100644 --- a/FTNoIR_Filter_EWMA2/ftnoir_filter_ewma2.cpp +++ b/FTNoIR_Filter_EWMA2/ftnoir_filter_ewma2.cpp @@ -75,7 +75,8 @@ FTNoIR_Filter_EWMA2::FTNoIR_Filter_EWMA2() setParameterValue(kSmoothingScaleCurve,10.0f); first_run = true; - alpha_smoothing = 0.02f; //this is a constant for now, might be a parameter later + alpha_smoothing = 0.02f; // this is a constant for now, might be a parameter later + loadSettings(); // Load the Settings } @@ -91,9 +92,34 @@ void FTNoIR_Filter_EWMA2::Release() void FTNoIR_Filter_EWMA2::Initialize() { + qDebug() << "FTNoIR_Filter_EWMA2::Initialize says: Starting "; + loadSettings(); return; } +// +// Load the current Settings from the currently 'active' INI-file. +// +void FTNoIR_Filter_EWMA2::loadSettings() { + qDebug() << "FTNoIR_Filter_EWMA2::loadSettings says: Starting "; + QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // Registry settings (in HK_USER) + + QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) + + qDebug() << "FTNoIR_Filter_EWMA2::loadSettings says: iniFile = " << currentFile; + + // + // The EWMA2-filter-settings are in the Tracking group: this is because they used to be on the Main Form of FaceTrackNoIR + // + iniFile.beginGroup ( "Tracking" ); + setParameterValue(0, iniFile.value ( "minSmooth", 15 ).toInt()); + setParameterValue(1, iniFile.value ( "maxSmooth", 50 ).toInt()); + setParameterValue(2, iniFile.value ( "powCurve", 10 ).toInt()); + iniFile.endGroup (); + +} + void FTNoIR_Filter_EWMA2::FilterHeadPoseData(THeadPoseData *current_camera_position, THeadPoseData *target_camera_position, THeadPoseData *new_camera_position, bool newTarget) { //non-optimised version for clarity diff --git a/FTNoIR_Filter_EWMA2/ftnoir_filter_ewma2_dialog.cpp b/FTNoIR_Filter_EWMA2/ftnoir_filter_ewma2_dialog.cpp index 130bf47b..f2523145 100644 --- a/FTNoIR_Filter_EWMA2/ftnoir_filter_ewma2_dialog.cpp +++ b/FTNoIR_Filter_EWMA2/ftnoir_filter_ewma2_dialog.cpp @@ -56,6 +56,8 @@ QWidget() connect(ui.maxSmooth, SIGNAL(valueChanged(int)), this, SLOT(settingChanged(int))); connect(ui.powCurve, SIGNAL(valueChanged(int)), this, SLOT(settingChanged(int))); + qDebug() << "FilterControls() says: started"; + // Load the settings from the current .INI-file loadSettings(); } @@ -75,8 +77,18 @@ void FilterControls::Release() // // Initialize tracker-client-dialog // -void FilterControls::Initialize(QWidget *parent) { +void FilterControls::Initialize(QWidget *parent, IFilterPtr ptr) { + // + // The dialog can be opened, while the Tracker is running. + // In that case, ptr will point to the active Filter-instance. + // This can be used to update settings, while Tracking and may also be handy to display logging-data and such... + // + pFilter = ptr; + + // + // + // QPoint offsetpos(100, 100); if (parent) { this->move(parent->pos() + offsetpos); @@ -89,6 +101,9 @@ void FilterControls::Initialize(QWidget *parent) { // void FilterControls::doOK() { save(); + if (pFilter) { + pFilter->Initialize(); + } this->close(); } @@ -134,13 +149,13 @@ void FilterControls::doCancel() { // Load the current Settings from the currently 'active' INI-file. // void FilterControls::loadSettings() { -// qDebug() << "loadSettings says: Starting "; + qDebug() << "FilterControls::loadSettings says: Starting "; QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // Registry settings (in HK_USER) QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) -// qDebug() << "loadSettings says: iniFile = " << currentFile; + qDebug() << "FilterControls::loadSettings says: iniFile = " << currentFile; // // The EWMA2-filter-settings are in the Tracking group: this is because they used to be on the Main Form of FaceTrackNoIR -- cgit v1.2.3