summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--facetracknoir/facetracknoir.cpp19
-rw-r--r--ftnoir_filter_accela/ftnoir_filter_accela.cpp17
-rw-r--r--ftnoir_filter_accela/ftnoir_filter_accela.h13
-rw-r--r--ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp27
-rw-r--r--ftnoir_filter_base/ftnoir_filter_base.h4
-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
8 files changed, 101 insertions, 38 deletions
diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp
index da2ce21f..d765ee96 100644
--- a/facetracknoir/facetracknoir.cpp
+++ b/facetracknoir/facetracknoir.cpp
@@ -610,7 +610,7 @@ void FaceTrackNoIR::startTracker( ) {
ui.btnLoad->setEnabled ( false );
ui.btnSave->setEnabled ( false );
ui.btnSaveAs->setEnabled ( false );
- ui.btnShowFilterControls->setEnabled ( false );
+ ui.btnShowFilterControls->setEnabled ( true );
//
// Create the Tracker and setup
@@ -687,14 +687,17 @@ void FaceTrackNoIR::startTracker( ) {
tracker->setInvertAxis(TY, ui.chkInvertY->isChecked() );
tracker->setInvertAxis(TZ, ui.chkInvertZ->isChecked() );
- tracker->start();
-
//
// Register the Tracker instance with the Tracker Dialog (if open)
//
if (pTrackerDialog && Libraries->pTracker) {
pTrackerDialog->registerTracker( Libraries->pTracker );
}
+
+ if (pFilterDialog && Libraries->pFilter)
+ pFilterDialog->registerFilter(Libraries->pFilter);
+
+ tracker->start();
ui.headPoseWidget->show();
@@ -776,7 +779,7 @@ void FaceTrackNoIR::stopTracker( ) {
pProtocolDialog->unRegisterProtocol();
}
if (pFilterDialog)
- pFilterDialog->Initialize(this, NULL);
+ pFilterDialog->unregisterFilter();
//
// Delete the tracker (after stopping things and all).
@@ -911,9 +914,9 @@ void FaceTrackNoIR::showTrackerSettings() {
if (lib) {
pTrackerDialog = (ITrackerDialog*) lib->Dialog();
if (pTrackerDialog) {
- pTrackerDialog->Initialize(this);
if (Libraries && Libraries->pTracker)
pTrackerDialog->registerTracker(Libraries->pTracker);
+ pTrackerDialog->Initialize(this);
}
}
}
@@ -930,9 +933,9 @@ void FaceTrackNoIR::showSecondTrackerSettings() {
if (lib) {
pSecondTrackerDialog = (ITrackerDialog*) lib->Dialog();
if (pSecondTrackerDialog) {
- pSecondTrackerDialog->Initialize(this);
if (Libraries && Libraries->pSecondTracker)
pSecondTrackerDialog->registerTracker(Libraries->pSecondTracker);
+ pSecondTrackerDialog->Initialize(this);
}
}
}
@@ -966,7 +969,9 @@ void FaceTrackNoIR::showFilterControls() {
if (lib && lib->Dialog) {
pFilterDialog = (IFilterDialog*) lib->Dialog();
if (pFilterDialog) {
- pFilterDialog->Initialize(this, Libraries ? Libraries->pFilter : NULL);
+ pFilterDialog->Initialize(this);
+ if (Libraries && Libraries->pFilter)
+ pFilterDialog->registerFilter(Libraries->pFilter);
}
}
}
diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.cpp b/ftnoir_filter_accela/ftnoir_filter_accela.cpp
index f2306204..c2cda351 100644
--- a/ftnoir_filter_accela/ftnoir_filter_accela.cpp
+++ b/ftnoir_filter_accela/ftnoir_filter_accela.cpp
@@ -5,11 +5,13 @@
* copyright notice and this permission notice appear in all copies.
*/
#include "ftnoir_filter_accela/ftnoir_filter_accela.h"
-#include "math.h"
+#include <cmath>
#include <QDebug>
-#include <float.h>
+#include <QMutexLocker>
#include "facetracknoir/global-settings.h"
+using namespace std;
+
FTNoIR_Filter::FTNoIR_Filter()
{
first_run = true;
@@ -34,6 +36,15 @@ void FTNoIR_Filter::loadSettings() {
iniFile.endGroup ();
}
+void FTNoIR_Filter::receiveSettings(double rot, double trans, double zoom_fac)
+{
+ QMutexLocker foo(&mutex);
+
+ rotation_alpha = rot;
+ translation_alpha = trans;
+ zoom_factor = zoom_fac;
+}
+
static double parabola(const double a, const double x)
{
const double a1 = 1./a;
@@ -56,6 +67,8 @@ void FTNoIR_Filter::FilterHeadPoseData(double *current_camera_position,
first_run = false;
return;
}
+
+ QMutexLocker foo(&mutex);
for (int i=0;i<6;i++)
{
diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.h b/ftnoir_filter_accela/ftnoir_filter_accela.h
index a0b7f3ef..0c13c0e8 100644
--- a/ftnoir_filter_accela/ftnoir_filter_accela.h
+++ b/ftnoir_filter_accela/ftnoir_filter_accela.h
@@ -32,6 +32,7 @@
#include "ftnoir_filter_base/ftnoir_filter_base.h"
#include "ui_ftnoir_accela_filtercontrols.h"
#include "facetracknoir/global-settings.h"
+#include <QMutex>
#define ACCELA_SMOOTHING_ROTATION 6.0
#define ACCELA_SMOOTHING_TRANSLATION 3.0
@@ -48,9 +49,10 @@ public:
void Initialize() {
first_run = true;
}
-
+ void receiveSettings(double rot, double trans, double zoom_fac);
private:
- void loadSettings(); // Load the settings from the INI-file
+ QMutex mutex;
+ void loadSettings();
bool first_run;
double rotation_alpha, translation_alpha, zoom_factor;
};
@@ -64,17 +66,18 @@ class FTNOIR_FILTER_BASE_EXPORT FilterControls: public QWidget, public IFilterDi
{
Q_OBJECT
public:
-
explicit FilterControls();
virtual ~FilterControls();
void showEvent ( QShowEvent * event );
- void Initialize(QWidget *parent, IFilter *ptr);
-
+ void Initialize(QWidget *parent);
+ void registerFilter(IFilter* filter);
+ void unregisterFilter();
private:
Ui::AccelaUICFilterControls ui;
void loadSettings();
void save();
bool settingsDirty;
+ FTNoIR_Filter* accela_filter;
private slots:
void doOK();
void doCancel();
diff --git a/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp b/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp
index f0641ea6..97653f94 100644
--- a/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp
+++ b/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp
@@ -39,7 +39,7 @@
// Constructor for server-settings-dialog
//
FilterControls::FilterControls() :
- QWidget()
+ QWidget(), accela_filter(NULL)
{
ui.setupUi( this );
@@ -66,9 +66,9 @@ FilterControls::~FilterControls() {
//
// Initialize tracker-client-dialog
//
-void FilterControls::Initialize(QWidget *parent, IFilter* ptr) {
+void FilterControls::Initialize(QWidget *parent) {
loadSettings();
-
+
QPoint offsetpos(100, 100);
if (parent) {
this->move(parent->pos() + offsetpos);
@@ -76,6 +76,16 @@ void FilterControls::Initialize(QWidget *parent, IFilter* ptr) {
show();
}
+void FilterControls::registerFilter(IFilter* filter)
+{
+ accela_filter = (FTNoIR_Filter*) filter;
+}
+
+void FilterControls::unregisterFilter()
+{
+ accela_filter = NULL;
+}
+
//
// OK clicked on server-dialog
//
@@ -154,14 +164,19 @@ void FilterControls::save() {
QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file)
qDebug() << "FTNoIR_Filter::save() says: iniFile = " << currentFile;
+
+ double rot, trans, zoom;
iniFile.beginGroup ( "Accela" );
- iniFile.setValue("zoom-slowness", ui.slideZoom->value());
- iniFile.setValue("rotation-alpha", ui.rotation_alpha->value());
- iniFile.setValue("translation-alpha", ui.translation_alpha->value());
+ iniFile.setValue("zoom-slowness", zoom = ui.slideZoom->value());
+ iniFile.setValue("rotation-alpha", rot = ui.rotation_alpha->value());
+ iniFile.setValue("translation-alpha", trans = ui.translation_alpha->value());
iniFile.endGroup ();
settingsDirty = false;
+
+ if (accela_filter)
+ accela_filter->receiveSettings(rot, trans, zoom);
}
////////////////////////////////////////////////////////////////////////////////
diff --git a/ftnoir_filter_base/ftnoir_filter_base.h b/ftnoir_filter_base/ftnoir_filter_base.h
index aef76370..9ff286b1 100644
--- a/ftnoir_filter_base/ftnoir_filter_base.h
+++ b/ftnoir_filter_base/ftnoir_filter_base.h
@@ -33,7 +33,9 @@ struct IFilter
struct IFilterDialog
{
virtual ~IFilterDialog() {}
- virtual void Initialize(QWidget *parent, IFilter* ptr) = 0;
+ virtual void Initialize(QWidget *parent) = 0;
+ virtual void registerFilter(IFilter* tracker) = 0;
+ virtual void unregisterFilter() = 0;
};
#endif // FTNOIR_FILTER_BASE_H
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);
}
////////////////////////////////////////////////////////////////////////////////