summaryrefslogtreecommitdiffhomepage
path: root/ftnoir_filter_ewma2
diff options
context:
space:
mode:
Diffstat (limited to 'ftnoir_filter_ewma2')
-rw-r--r--ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp12
-rw-r--r--ftnoir_filter_ewma2/ftnoir_filter_ewma2.h14
-rw-r--r--ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp33
3 files changed, 42 insertions, 17 deletions
diff --git a/ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp b/ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp
index b5250593..43cfd102 100644
--- a/ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp
+++ b/ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp
@@ -28,6 +28,7 @@
#include <QWidget>
#include "facetracknoir/global-settings.h"
#include <algorithm>
+#include <QMutexLocker>
//#define LOG_OUTPUT
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -47,6 +48,15 @@ FTNoIR_Filter::~FTNoIR_Filter()
{
}
+void FTNoIR_Filter::receiveSettings(double smin, double smax, double sexpt)
+{
+ QMutexLocker foo(&mutex);
+
+ kMinSmoothing = smin;
+ kMaxSmoothing = smax;
+ kSmoothingScaleCurve = sexpt;
+}
+
//
// Load the current Settings from the currently 'active' INI-file.
//
@@ -88,6 +98,8 @@ void FTNoIR_Filter::FilterHeadPoseData(double *current_camera_position,
first_run=false;
return;
}
+
+ QMutexLocker foo(&mutex);
for (int i=0;i<6;i++) {
// Calculate the delta.
diff --git a/ftnoir_filter_ewma2/ftnoir_filter_ewma2.h b/ftnoir_filter_ewma2/ftnoir_filter_ewma2.h
index a5f3ef24..18fec8d4 100644
--- a/ftnoir_filter_ewma2/ftnoir_filter_ewma2.h
+++ b/ftnoir_filter_ewma2/ftnoir_filter_ewma2.h
@@ -30,6 +30,7 @@
#include "facetracknoir/global-settings.h"
#include "ui_ftnoir_ewma_filtercontrols.h"
#include <QWidget>
+#include <QMutex>
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
@@ -47,6 +48,7 @@ public:
double *target_camera_position,
double *new_camera_position,
double *last_post_filter);
+ void receiveSettings(double smin, double smax, double sexpt);
private:
void loadSettings(); // Load the settings from the INI-file
@@ -59,6 +61,8 @@ private:
double kMinSmoothing;
double kMaxSmoothing;
double kSmoothingScaleCurve;
+
+ QMutex mutex;
};
//*******************************************************************************************************
@@ -73,7 +77,9 @@ public:
explicit FilterControls();
virtual ~FilterControls();
void showEvent ( QShowEvent * event );
- void Initialize(QWidget *parent, IFilter* ptr);
+ void Initialize(QWidget *parent);
+ void registerFilter(IFilter* flt);
+ void unregisterFilter();
private:
Ui::UICFilterControls ui;
@@ -83,13 +89,13 @@ private:
/** helper **/
bool settingsDirty;
- IFilter* pFilter; // If the filter was active when the dialog was opened, this will hold a pointer to the Filter instance
+ FTNoIR_Filter* pFilter;
private slots:
void doOK();
void doCancel();
- void settingChanged() { settingsDirty = true; };
- void settingChanged( int ) { settingsDirty = true; };
+ void settingChanged() { settingsDirty = true; }
+ void settingChanged( int ) { settingsDirty = true; }
};
//*******************************************************************************************************
diff --git a/ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp b/ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp
index eb259572..ebcba5f1 100644
--- a/ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp
+++ b/ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp
@@ -35,7 +35,7 @@
// Constructor for server-settings-dialog
//
FilterControls::FilterControls() :
-QWidget()
+ QWidget(), pFilter(NULL)
{
ui.setupUi( this );
@@ -69,15 +69,7 @@ FilterControls::~FilterControls() {
//
// Initialize tracker-client-dialog
//
-void FilterControls::Initialize(QWidget *parent, IFilter* 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;
-
+void FilterControls::Initialize(QWidget *parent) {
//
//
//
@@ -88,6 +80,16 @@ void FilterControls::Initialize(QWidget *parent, IFilter* ptr) {
show();
}
+void FilterControls::registerFilter(IFilter* flt)
+{
+ pFilter = (FTNoIR_Filter*) flt;
+}
+
+void FilterControls::unregisterFilter()
+{
+ pFilter = NULL;
+}
+
//
// OK clicked on server-dialog
//
@@ -166,14 +168,19 @@ void FilterControls::save() {
QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString();
QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file)
+
+ double smooth_min, smooth_max, smooth_expt;
iniFile.beginGroup ( "Tracking" );
- iniFile.setValue ( "minSmooth", ui.minSmooth->value() );
- iniFile.setValue ( "powCurve", ui.powCurve->value() );
- iniFile.setValue ( "maxSmooth", ui.maxSmooth->value() );
+ iniFile.setValue ( "minSmooth", smooth_min = ui.minSmooth->value() );
+ iniFile.setValue ( "powCurve", smooth_expt = ui.powCurve->value() );
+ iniFile.setValue ( "maxSmooth", smooth_max = ui.maxSmooth->value() );
iniFile.endGroup ();
settingsDirty = false;
+
+ if (pFilter)
+ pFilter->receiveSettings(smooth_min, smooth_max, smooth_expt);
}
////////////////////////////////////////////////////////////////////////////////