summaryrefslogtreecommitdiffhomepage
path: root/FTNoIR_Filter_EWMA2
diff options
context:
space:
mode:
authorWim Vriend <facetracknoir@gmail.com>2012-01-09 17:01:44 +0000
committerWim Vriend <facetracknoir@gmail.com>2012-01-09 17:01:44 +0000
commitd6086d8203ae4f4b45f3d97960788d603fc78e16 (patch)
treed27181290c04ca84d27b822aa40b9f7ed904e389 /FTNoIR_Filter_EWMA2
parent10feed03651270c2aa0eb95268e40f0b66fe30d6 (diff)
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
Diffstat (limited to 'FTNoIR_Filter_EWMA2')
-rw-r--r--FTNoIR_Filter_EWMA2/FTNoIR_FilterControls.ui124
-rw-r--r--FTNoIR_Filter_EWMA2/FTNoIR_Filter_EWMA2.h4
-rw-r--r--FTNoIR_Filter_EWMA2/ftnoir_filter_ewma2.cpp28
-rw-r--r--FTNoIR_Filter_EWMA2/ftnoir_filter_ewma2_dialog.cpp21
4 files changed, 157 insertions, 20 deletions
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 @@
<property name="autoFillBackground">
<bool>false</bool>
</property>
+ <property name="styleSheet">
+ <string notr="true"/>
+ </property>
<layout class="QVBoxLayout" name="_vertical_layout">
<item>
<layout class="QGridLayout" name="gridLayout">
@@ -41,8 +44,7 @@
</size>
</property>
<property name="styleSheet">
- <string notr="true">color:#ccc;
-background:none;</string>
+ <string notr="true"/>
</property>
<property name="text">
<string>Min.</string>
@@ -64,8 +66,7 @@ background:none;</string>
</size>
</property>
<property name="styleSheet">
- <string notr="true">color:#ccc;
-background:none;</string>
+ <string notr="true"/>
</property>
<property name="text">
<string>Max.</string>
@@ -87,8 +88,7 @@ background:none;</string>
</size>
</property>
<property name="styleSheet">
- <string notr="true">color:#ccc;
-background:none;</string>
+ <string notr="true"/>
</property>
<property name="text">
<string>Curve</string>
@@ -163,8 +163,7 @@ background:none;</string>
</size>
</property>
<property name="styleSheet">
- <string notr="true">color:#ccc;
-background:none;</string>
+ <string notr="true"/>
</property>
<property name="text">
<string>frames</string>
@@ -239,8 +238,7 @@ background:none;</string>
</size>
</property>
<property name="styleSheet">
- <string notr="true">color:#ccc;
-background:none;</string>
+ <string notr="true"/>
</property>
<property name="text">
<string>frames</string>
@@ -312,8 +310,7 @@ background:none;</string>
</size>
</property>
<property name="styleSheet">
- <string notr="true">color:#ccc;
-background:none;</string>
+ <string notr="true"/>
</property>
<property name="text">
<string>pow</string>
@@ -393,7 +390,7 @@ background:none;</string>
</property>
<property name="minimumSize">
<size>
- <width>100</width>
+ <width>52</width>
<height>0</height>
</size>
</property>
@@ -418,7 +415,7 @@ background:none;</string>
</property>
<property name="minimumSize">
<size>
- <width>100</width>
+ <width>52</width>
<height>0</height>
</size>
</property>
@@ -460,7 +457,104 @@ background:none;</string>
<tabstop>btnCancel</tabstop>
</tabstops>
<resources/>
- <connections/>
+ <connections>
+ <connection>
+ <sender>minSmooth</sender>
+ <signal>valueChanged(int)</signal>
+ <receiver>spinMinSmooth</receiver>
+ <slot>setValue(int)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>199</x>
+ <y>22</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>337</x>
+ <y>23</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>spinMinSmooth</sender>
+ <signal>valueChanged(int)</signal>
+ <receiver>minSmooth</receiver>
+ <slot>setValue(int)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>330</x>
+ <y>12</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>185</x>
+ <y>17</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>maxSmooth</sender>
+ <signal>valueChanged(int)</signal>
+ <receiver>spinMaxSmooth</receiver>
+ <slot>setValue(int)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>181</x>
+ <y>48</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>335</x>
+ <y>54</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>spinMaxSmooth</sender>
+ <signal>valueChanged(int)</signal>
+ <receiver>maxSmooth</receiver>
+ <slot>setValue(int)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>324</x>
+ <y>42</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>259</x>
+ <y>43</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>powCurve</sender>
+ <signal>valueChanged(int)</signal>
+ <receiver>spinPowCurve</receiver>
+ <slot>setValue(int)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>145</x>
+ <y>74</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>339</x>
+ <y>78</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>spinPowCurve</sender>
+ <signal>valueChanged(int)</signal>
+ <receiver>powCurve</receiver>
+ <slot>setValue(int)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>330</x>
+ <y>69</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>176</x>
+ <y>76</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
<slots>
<slot>startEngineClicked()</slot>
<slot>stopEngineClicked()</slot>
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