From fa56fc34e44bbb2f35342a7a3f4de13d56e7aa8f Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 19 Aug 2013 12:41:49 +0200 Subject: High-frequency timer does nothing with sleep interval, it turns out --- facetracknoir/main.cpp | 3 --- 1 file changed, 3 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/main.cpp b/facetracknoir/main.cpp index fd0ca1cc..d4e05ab7 100644 --- a/facetracknoir/main.cpp +++ b/facetracknoir/main.cpp @@ -40,9 +40,6 @@ #endif int main(int argc, char** argv) { -#if defined(_WIN32) - (void) timeBeginPeriod(1); -#endif QApplication app(argc, argv); QFont font; font.setFamily(font.defaultFamily()); -- cgit v1.2.3 From 54883f543f45e94810ee48108474efad7f0ba2d6 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 19 Aug 2013 12:42:35 +0200 Subject: Don't assume or use 1ms interval, on Windows it gets rounded to 15.6 ms anyway --- facetracknoir/tracker.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'facetracknoir') diff --git a/facetracknoir/tracker.cpp b/facetracknoir/tracker.cpp index 7eedfea1..7292076b 100644 --- a/facetracknoir/tracker.cpp +++ b/facetracknoir/tracker.cpp @@ -203,7 +203,7 @@ void Tracker::run() { } //for lower cpu load - msleep(1); + msleep(16); } for (int i = 0; i < 6; i++) -- cgit v1.2.3 From c9ea0a95c038f2ed95a725a3d2c97aa4e725c263 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 19 Aug 2013 22:15:03 +0200 Subject: Revert "High-frequency timer does nothing with sleep interval, it turns out" This reverts commit c6e5a5f449f95a833b826ebfae870a2e519fcfa0. Actually, it does for Sleep(x) where x > 1 and x < 15, but only for Windows newer than XP. Next time let's check for ourselves instead of using obsolete info from the 'net... --- facetracknoir/main.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'facetracknoir') diff --git a/facetracknoir/main.cpp b/facetracknoir/main.cpp index d4e05ab7..fd0ca1cc 100644 --- a/facetracknoir/main.cpp +++ b/facetracknoir/main.cpp @@ -40,6 +40,9 @@ #endif int main(int argc, char** argv) { +#if defined(_WIN32) + (void) timeBeginPeriod(1); +#endif QApplication app(argc, argv); QFont font; font.setFamily(font.defaultFamily()); -- cgit v1.2.3 From d446d36911a87eb18dd0a776b40c63f4bcc631c9 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 24 Aug 2013 22:33:18 +0200 Subject: Undo the filtering clusterfuck following discussion with dbaarda --- facetracknoir/tracker.cpp | 2 +- ftnoir_filter_accela/ftnoir_filter_accela.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/tracker.cpp b/facetracknoir/tracker.cpp index 7292076b..a0b827e4 100644 --- a/facetracknoir/tracker.cpp +++ b/facetracknoir/tracker.cpp @@ -203,7 +203,7 @@ void Tracker::run() { } //for lower cpu load - msleep(16); + msleep(8); } for (int i = 0; i < 6; i++) diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.cpp b/ftnoir_filter_accela/ftnoir_filter_accela.cpp index 66744c2f..f2306204 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela.cpp @@ -37,7 +37,7 @@ void FTNoIR_Filter::loadSettings() { static double parabola(const double a, const double x) { const double a1 = 1./a; - return a1 * a1 * x * x; + return a1 * x * x; } void FTNoIR_Filter::FilterHeadPoseData(double *current_camera_position, -- cgit v1.2.3 From 82ffb9b11a6f5bc94c658a10d6c2c21c0f217d18 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 2 Sep 2013 12:59:43 +0200 Subject: UI cleanup, tracking overlay already provides that information. Expose one internal value less. --- facetracknoir/facetracknoir.cpp | 4 ---- facetracknoir/facetracknoir.ui | 35 +---------------------------------- facetracknoir/tracker.cpp | 11 ++++------- facetracknoir/tracker.h | 3 --- 4 files changed, 5 insertions(+), 48 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index bb0cef11..aa49fe90 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -270,7 +270,6 @@ void FaceTrackNoIR::setupFaceTrackNoIR() { //Setup the timer for showing the headpose. connect(&timUpdateHeadPose, SIGNAL(timeout()), this, SLOT(showHeadPose())); - ui.txtTracking->setVisible(false); settingsDirty = false; } @@ -766,7 +765,6 @@ void FaceTrackNoIR::stopTracker( ) { ui.lcdNumOutputRotX->setVisible(false); ui.lcdNumOutputRotY->setVisible(false); ui.lcdNumOutputRotZ->setVisible(false); - ui.txtTracking->setVisible(false); // // Delete the tracker (after stopping things and all). @@ -854,8 +852,6 @@ void FaceTrackNoIR::showHeadPose() { ui.lcdNumRotY->display(QString("%1").arg(newdata[Pitch], 0, 'f', 1)); ui.lcdNumRotZ->display(QString("%1").arg(newdata[Roll], 0, 'f', 1)); - ui.txtTracking->setVisible(tracker->getTrackingActive()); - // // Get the output-pose and also display it. // diff --git a/facetracknoir/facetracknoir.ui b/facetracknoir/facetracknoir.ui index ee5fb5b0..fca13902 100644 --- a/facetracknoir/facetracknoir.ui +++ b/facetracknoir/facetracknoir.ui @@ -1482,7 +1482,7 @@ background:none; 10 - 20 + 12 231 169 @@ -1698,39 +1698,6 @@ color:white; - - - - 10 - 0 - 231 - 50 - - - - Status - - - true - - - - - 110 - 10 - 101 - 16 - - - - border:none; -color: rgb(0, 255, 0); - - - Tracking - - - diff --git a/facetracknoir/tracker.cpp b/facetracknoir/tracker.cpp index a0b827e4..0d584fae 100644 --- a/facetracknoir/tracker.cpp +++ b/facetracknoir/tracker.cpp @@ -70,7 +70,6 @@ /** constructor **/ Tracker::Tracker( FaceTrackNoIR *parent ) : - confid(false), should_quit(false), do_center(false) { @@ -137,7 +136,7 @@ void Tracker::run() { { QMutexLocker foo(&mtx); - confid = bTracker1Confid || bTracker2Confid; + const bool confid = bTracker1Confid || bTracker2Confid; if ( confid ) { for (int i = 0; i < 6; i++) @@ -151,10 +150,8 @@ void Tracker::run() { // // Only copy valid values // - if (confid) { - for (int i = 0; i < 6; i++) - offset_camera.axes[i] = mainApp->axis(i).headPos; - } + for (int i = 0; i < 6; i++) + offset_camera.axes[i] = mainApp->axis(i).headPos; Tracker::do_center = false; @@ -168,7 +165,7 @@ void Tracker::run() { Libraries->pFilter->Initialize(); } - if (getTrackingActive()) { + if (confid) { // get values for (int i = 0; i < 6; i++) target_camera.axes[i] = mainApp->axis(i).headPos; diff --git a/facetracknoir/tracker.h b/facetracknoir/tracker.h index f452395d..c023d54e 100644 --- a/facetracknoir/tracker.h +++ b/facetracknoir/tracker.h @@ -119,7 +119,6 @@ public: Tracker( FaceTrackNoIR *parent ); ~Tracker(); void loadSettings(); // Load settings from the INI-file - bool getTrackingActive() { return confid; } void setInvertAxis(Axis axis, bool invert); @@ -129,8 +128,6 @@ public: volatile bool should_quit; // following are now protected by hTrackMutex volatile bool do_center; // Center head-position, using the shortkey - // Flags to start/stop/reset tracking - volatile bool confid; // Tracker data is OK; T6DOF output_camera; }; -- cgit v1.2.3 From 62d3351f62bc670edc95b4ecc7b17420e899ee26 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 2 Sep 2013 13:15:05 +0200 Subject: Remove dead code --- facetracknoir/facetracknoir.cpp | 5 ----- facetracknoir/facetracknoir.h | 2 -- 2 files changed, 7 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index aa49fe90..2bc625cb 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -1168,11 +1168,6 @@ QWidget( parent , f) connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); - connect(ui.cbxCenterKey, SIGNAL(currentIndexChanged(int)), this, SLOT(keyChanged( int ))); - connect(ui.chkCenterShift, SIGNAL(stateChanged(int)), this, SLOT(keyChanged(int))); - connect(ui.chkCenterCtrl, SIGNAL(stateChanged(int)), this, SLOT(keyChanged(int))); - connect(ui.chkCenterAlt, SIGNAL(stateChanged(int)), this, SLOT(keyChanged(int))); - // Clear the Lists with key-descriptions and keycodes and build the Lists // The strings will all be added to the ListBoxes for each Shortkey // diff --git a/facetracknoir/facetracknoir.h b/facetracknoir/facetracknoir.h index fd9c06a7..c919f765 100644 --- a/facetracknoir/facetracknoir.h +++ b/facetracknoir/facetracknoir.h @@ -231,8 +231,6 @@ private: private slots: void doOK(); void doCancel(); - void keyChanged( int index ) { settingsDirty = true; } - void keyChanged( bool index ) { settingsDirty = true; } }; // Widget that has controls for Keyboard shortcuts. -- cgit v1.2.3 From d31c12fa4bc85897da328287030cb10a6b0db5af Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 13 Sep 2013 13:49:46 +0200 Subject: Allow for changing keyboard shortcuts while the tracker is running --- facetracknoir/facetracknoir.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index 2bc625cb..8224b35f 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -1278,6 +1278,21 @@ void FaceTrackNoIR::bindKeyboardShortcuts() keyCenter.ctrl = iniFile.value("Ctrl_Center", false).toBool(); #endif iniFile.endGroup (); + + if (tracker) /* running already */ + { +#if defined(_WIN32) || defined(__WIN32) + if (keybindingWorker) + { + keybindingWorker->should_quit = true; + keybindingWorker->wait(); + delete keybindingWorker; + keybindingWorker = NULL; + } + keybindingWorker = new KeybindingWorker(*this, keyCenter); + keybindingWorker->start(); +#endif + } } // -- cgit v1.2.3 From c9bfd9b3a6fd40d8d63cb25c8d746e6a4adb532f Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 13 Sep 2013 14:02:08 +0200 Subject: Reorder side effects to avoid use-after-free --- facetracknoir/facetracknoir.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index 8224b35f..da2ce21f 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -765,6 +765,18 @@ void FaceTrackNoIR::stopTracker( ) { ui.lcdNumOutputRotX->setVisible(false); ui.lcdNumOutputRotY->setVisible(false); ui.lcdNumOutputRotZ->setVisible(false); + + // + // UnRegister the Tracker instance with the Tracker Dialog (if open) + // + if (pTrackerDialog) { + pTrackerDialog->unRegisterTracker(); + } + if (pProtocolDialog) { + pProtocolDialog->unRegisterProtocol(); + } + if (pFilterDialog) + pFilterDialog->Initialize(this, NULL); // // Delete the tracker (after stopping things and all). @@ -783,16 +795,6 @@ void FaceTrackNoIR::stopTracker( ) { Libraries = NULL; } } - - // - // UnRegister the Tracker instance with the Tracker Dialog (if open) - // - if (pTrackerDialog) { - pTrackerDialog->unRegisterTracker(); - } - if (pProtocolDialog) { - pProtocolDialog->unRegisterProtocol(); - } ui.btnStartTracker->setEnabled ( true ); ui.btnStopTracker->setEnabled ( false ); // ui.btnShowEngineControls->setEnabled ( false ); -- cgit v1.2.3 From 3195bebe6b59b6f9dc657584570260c28d7937ec Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 13 Sep 2013 14:54:32 +0200 Subject: Allow for editing filter settings while the software is running --- facetracknoir/facetracknoir.cpp | 19 ++++++++----- ftnoir_filter_accela/ftnoir_filter_accela.cpp | 17 +++++++++-- ftnoir_filter_accela/ftnoir_filter_accela.h | 13 +++++---- .../ftnoir_filter_accela_dialog.cpp | 27 ++++++++++++++---- ftnoir_filter_base/ftnoir_filter_base.h | 4 ++- ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp | 12 ++++++++ ftnoir_filter_ewma2/ftnoir_filter_ewma2.h | 14 ++++++--- ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp | 33 +++++++++++++--------- 8 files changed, 101 insertions(+), 38 deletions(-) (limited to 'facetracknoir') 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 #include -#include +#include #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 #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 #include "facetracknoir/global-settings.h" #include +#include //#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 +#include ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // @@ -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); } //////////////////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From 6be2bbea386c0fb98c750927b1ade2c6dd9d3fbe Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 13 Sep 2013 15:02:31 +0200 Subject: Remove per-file version history. Be careful not to touch copyright information. --- faceapi/main.cpp | 9 ----- facetracknoir/facetracknoir.cpp | 24 ------------ facetracknoir/main.cpp | 5 --- facetracknoir/tracker.cpp | 44 ---------------------- facetracknoir/tracker.h | 4 -- facetracknoir/tracker_types.h | 5 --- freetrackclient/freetrackclient.cpp | 6 --- .../ftnoir_filter_accela_dialog.cpp | 4 -- ftnoir_filter_ewma2/ftnoir_filter_ewma_dll.cpp | 8 ---- ftnoir_protocol_fg/ftnoir_protocol_fg.cpp | 6 --- ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp | 6 --- ftnoir_protocol_fg/ftnoir_protocol_fg_dll.cpp | 8 ---- ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp | 6 --- .../ftnoir_protocol_fsuipc_dialog.cpp | 8 ---- .../ftnoir_protocol_fsuipc_dll.cpp | 8 ---- ftnoir_protocol_ft/ftnoir_protocol_ft.cpp | 14 ------- ftnoir_protocol_ft/ftnoir_protocol_ft_dialog.cpp | 8 ---- ftnoir_protocol_ft/ftnoir_protocol_ft_dll.cpp | 8 ---- ftnoir_protocol_ftn/ftnoir_protocol_ftn.cpp | 6 --- ftnoir_protocol_ftn/ftnoir_protocol_ftn_dialog.cpp | 8 ---- ftnoir_protocol_ftn/ftnoir_protocol_ftn_dll.cpp | 8 ---- ftnoir_protocol_mouse/ftnoir_protocol_mouse.cpp | 6 --- .../ftnoir_protocol_mouse_dialog.cpp | 8 ---- .../ftnoir_protocol_mouse_dll.cpp | 8 ---- ftnoir_protocol_sc/ftnoir_protocol_sc.cpp | 6 --- ftnoir_protocol_sc/ftnoir_protocol_sc_dialog.cpp | 8 ---- ftnoir_protocol_sc/ftnoir_protocol_sc_dll.cpp | 8 ---- ftnoir_tracker_sm/ftnoir_tracker_faceapi_dll.cpp | 8 ---- ftnoir_tracker_udp/ftnoir_tracker_udp_dll.cpp | 8 ---- qfunctionconfigurator/qfunctionconfigurator.cpp | 8 ---- 30 files changed, 271 deletions(-) (limited to 'facetracknoir') diff --git a/faceapi/main.cpp b/faceapi/main.cpp index 6cc93112..9fe0af95 100644 --- a/faceapi/main.cpp +++ b/faceapi/main.cpp @@ -21,15 +21,6 @@ * You should have received a copy of the GNU General Public License along * * with this program; if not, see . * *********************************************************************************/ -/* - Modifications (last one on top): - 20130105 - WVR: Set engine state to TERMINATED, when EXIT. - 20110501 - WVR: Added some command to be handled from FaceTrackNoIR (settings dialog). - 20110322 - WVR: Somehow the video-widget of faceAPI version 3.2.6. does not - work with FaceTrackNoIR (Qt issue?!). To be able to use - release 3.2.6 of faceAPI anyway, this console-app is used. - It exchanges data with FaceTrackNoIR via shared-memory... -*/ //Precompiled header #include "stdafx.h" diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index d765ee96..6cd708c7 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -21,30 +21,6 @@ * You should have received a copy of the GNU General Public License along * * with this program; if not, see . * *********************************************************************************/ -/* - Modifications (last one on top): - 20130101 - WVR: Added "None" to filter-listbox to remove "use advanced filtering". - 20121209 - WVR: Pre-v170 DLLs will not be added to the Listbox. Initial selection was changed (made case-insensitive). - 20121014 - WVR: Added second Tracker Source for Arduino solution. The two will be mutually exclusive. - 20120929 - WVR: Disable button Filter-settings when StartTracker. - 20120918 - WVR: When AutoStart is TRUE, the program is not directly minimized any more. - This now depends on the AutoMinimize time. Fixed the 'not showing' of the MIB. - Also disable combo and buttons after 'Start'. - 20120917 - WVR: Added Mouse-buttons to ShortKeys. - 20120717 - WVR: FunctionConfig is now used for the Curves, instead of BezierConfig. - 20120427 - WVR: The Protocol-code was already in separate DLLs, but the ListBox was still filled 'statically'. Now, a Dir() of the - EXE-folder is done, to locate Protocol-DLLs. The Icons were also moved to the DLLs - 20120317 - WVR: The Filter and Tracker-code was moved to separate DLLs. The calling-method - was changed accordingly. The save() and LoadSettings() functions were adapted. - The face-tracker member-functions NotifyZeroed and refreshVideo were added, as - requested by Stanislaw. - 20110813 - WVR: Changed the presentation of the raw inputs: now a decimal digit will even show when '0'. - 20110404 - WVR: Migrated the FlightGear protocol to a separate DLL. The rest must follow... - 20110401 - WVR: The about-dialog was shown 'misplaced'. It was corrected. - 20110328 - WVR: Added the display for output-pose. - 20110207 - WVR: RadioButtons for 'Stop engine' added. It is now possible to choose Stop or Keep tracking. - 20110109 - WVR: Added minimizeTaskBar option added. It is now possible to choose minimized or tray. -*/ #include "facetracknoir.h" #include "tracker.h" #include diff --git a/facetracknoir/main.cpp b/facetracknoir/main.cpp index fd0ca1cc..7ff9f29f 100644 --- a/facetracknoir/main.cpp +++ b/facetracknoir/main.cpp @@ -21,11 +21,6 @@ * You should have received a copy of the GNU General Public License along * * with this program; if not, see . * *********************************************************************************/ -/* - Modifications (last one on top): - 20100520 - WVR: Added class FaceApp, to override winEventFilter. It receives - messages from the Game. -*/ #include "facetracknoir.h" #include "tracker.h" diff --git a/facetracknoir/tracker.cpp b/facetracknoir/tracker.cpp index 0d584fae..f2b4845f 100644 --- a/facetracknoir/tracker.cpp +++ b/facetracknoir/tracker.cpp @@ -21,50 +21,6 @@ * You should have received a copy of the GNU General Public License along * * with this program; if not, see . * *********************************************************************************/ -/* - Modifications (last one on top): - 20121215 - WVR: Fixed crash after message: protocol not installed correctly... by terminating the thread. - 20120921 - WVR: Fixed centering when no filter is selected. - 20120917 - WVR: Added Mouse-buttons to ShortKeys. - 20120827 - WVR: Signal tracking = false to Curve-widget(s) when quitting run(). Also when Alternative Pitch curve is used. - 20120805 - WVR: The FunctionConfig-widget is used to configure the Curves. It was tweaked some more, because the Accela filter now also - uses the Curve(s). ToDo: make the ranges configurable by the user. Development on the Toradex IMU makes us realize, that - a fixed input-range may not be so handy after all.. - 20120427 - WVR: The Protocol-code was already in separate DLLs, but the ListBox was still filled �statically�. Now, a Dir() of the - EXE-folder is done, to locate Protocol-DLLs. The Icons were also moved to the DLLs - 20120317 - WVR: The Filter and Tracker-code was moved to separate DLLs. The calling-method - was changed accordingly. - The face-tracker member-functions NotifyZeroed and refreshVideo were added, as - requested by Stanislaw. - 20110411 - WVR: Finished moving all Protocols to separate C++ projects. Every protocol now - has it's own Class, that's inside it's own DLL. This reduces the size of the program, - makes it more structured and enables a more sophisticated installer. - 20110328 - WVR: Changed the camera-structs into class-instances. This makes initialisation - easier and hopefully solves the remaining 'start-up problem'. - 20110313 - WVR: Removed 'set_initial'. Less is more. - 20110109 - WVR: Added setZero option to define behaviour after STOP tracking via shortkey. - 20110104 - WVR: Removed a few nasty bugs (it was impossible to stop tracker without crash). - 20101224 - WVR: Removed the QThread inheritance of the Base Class for the protocol-servers. - Again, this drastically simplifies the code in the protocols. - 20101217 - WVR: Created Base Class for the protocol-servers. This drastically simplifies - the code needed here. - 20101024 - WVR: Added shortkey to disable/enable one or more axis during tracking. - 20101021 - WVR: Added FSUIPC server for FS2004. - 20101011 - WVR: Added SimConnect server. - 20101007 - WVR: Created 6DOF-curves and drastically changed the tracker for that. - Also eliminated a 'glitch' in the process. - 20100607 - WVR: Re-installed Rotation Neutral Zone and improved reaction - after 'start/stop'. MessageBeep when confidence is back... - 20100604 - WVR: Created structure for DOF-data and changed timing of - ReceiveHeadPose end run(). - 20100602 - WVR: Implemented EWMA-filtering, according to the example of - Melchior Franz. Works like a charm... - 20100601 - WVR: Added DirectInput keyboard-handling. '=' used for center, - 'BACK' for start (+center)/stop. - 20100517 - WVR: Added upstream command(s) from FlightGear - 20100523 - WVR: Checkboxes to invert 6DOF's was implemented. Multiply by - 1 or (-1). -*/ #include "tracker.h" #include "facetracknoir.h" diff --git a/facetracknoir/tracker.h b/facetracknoir/tracker.h index c023d54e..7e2b84cd 100644 --- a/facetracknoir/tracker.h +++ b/facetracknoir/tracker.h @@ -20,10 +20,6 @@ * You should have received a copy of the GNU General Public License along * * with this program; if not, see . * *********************************************************************************/ -/* - Modifications (last one on top): - 20120717 - WVR: FunctionConfig is now used for the Curves, instead of BezierConfig. -*/ #ifndef __TRACKER_H__ #define __TRACKER_H__ diff --git a/facetracknoir/tracker_types.h b/facetracknoir/tracker_types.h index d77a0b87..ebd89e7c 100644 --- a/facetracknoir/tracker_types.h +++ b/facetracknoir/tracker_types.h @@ -20,11 +20,6 @@ * You should have received a copy of the GNU General Public License along * * with this program; if not, see . * *********************************************************************************/ -/* - Modifications (last one on top): - 20120924 - C14: Moved tracker types only used by Tracker to this file (should not be part of public interface) - Modified operators to represent correct frame transitions -*/ #ifndef __TRACKER_TYPES_H__ #define __TRACKER_TYPES_H__ diff --git a/freetrackclient/freetrackclient.cpp b/freetrackclient/freetrackclient.cpp index 98544e2d..52aa6190 100644 --- a/freetrackclient/freetrackclient.cpp +++ b/freetrackclient/freetrackclient.cpp @@ -23,12 +23,6 @@ * with this program; if not, see . * * * ********************************************************************************/ -/* - Modifications (last one on top): - - 20130208 - WVR: The old DLL from FreeTrack seems to crash ArmA2. And we need 64-bit support. - -*/ #define FT_EXPORT(t) extern "C" t __declspec(dllexport) __stdcall #define NP_AXIS_MAX 16383 diff --git a/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp b/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp index 97653f94..8c7cd386 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp @@ -22,10 +22,6 @@ * with this program; if not, see . * * * ********************************************************************************/ -/* - Modifications (last one on top): - 20130102 - WVR: Added 'reduction factor' to accommodate Patrick's need for speed. -*/ #include "ftnoir_filter_accela/ftnoir_filter_accela.h" #include #include diff --git a/ftnoir_filter_ewma2/ftnoir_filter_ewma_dll.cpp b/ftnoir_filter_ewma2/ftnoir_filter_ewma_dll.cpp index a01b0661..48c9d3be 100644 --- a/ftnoir_filter_ewma2/ftnoir_filter_ewma_dll.cpp +++ b/ftnoir_filter_ewma2/ftnoir_filter_ewma_dll.cpp @@ -22,14 +22,6 @@ * with this program; if not, see . * * * ********************************************************************************/ -/* - Modifications (last one on top): - 20120830 - WVR: The Dialog class was used to get general info on the DLL. This - had a big disadvantage: the complete dialog was loaded, just to get - some data and then it was deleted again (without ever showing the dialog). - The FilterDll class solves this. - The functions to get the name(s) and icon were removed from the two other classes. -*/ #include "ftnoir_filter_ewma2.h" #include #include "facetracknoir/global-settings.h" diff --git a/ftnoir_protocol_fg/ftnoir_protocol_fg.cpp b/ftnoir_protocol_fg/ftnoir_protocol_fg.cpp index 7b43e306..abc401fa 100644 --- a/ftnoir_protocol_fg/ftnoir_protocol_fg.cpp +++ b/ftnoir_protocol_fg/ftnoir_protocol_fg.cpp @@ -25,12 +25,6 @@ * to FlightGear, using UDP. * * It is based on the (Linux) example made by Melchior FRANZ. * ********************************************************************************/ -/* - Modifications (last one on top): - 20110401 - WVR: Moved protocol to a DLL, convenient for installation etc. - 20101224 - WVR: Base class is no longer inheriting QThread. sendHeadposeToGame - is called from run() of Tracker.cpp -*/ #include "ftnoir_protocol_fg.h" #include #include "facetracknoir/global-settings.h" diff --git a/ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp b/ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp index c29f6d1a..b01f529b 100644 --- a/ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp +++ b/ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp @@ -25,12 +25,6 @@ * to FlightGear, using UDP. * * It is based on the (Linux) example made by Melchior FRANZ. * ********************************************************************************/ -/* - Modifications (last one on top): - 20110401 - WVR: Moved protocol to a DLL, convenient for installation etc. - 20101224 - WVR: Base class is no longer inheriting QThread. sendHeadposeToGame - is called from run() of Tracker.cpp -*/ #include "ftnoir_protocol_fg.h" #include #include "facetracknoir/global-settings.h" diff --git a/ftnoir_protocol_fg/ftnoir_protocol_fg_dll.cpp b/ftnoir_protocol_fg/ftnoir_protocol_fg_dll.cpp index 45d6271c..8d9dcf8f 100644 --- a/ftnoir_protocol_fg/ftnoir_protocol_fg_dll.cpp +++ b/ftnoir_protocol_fg/ftnoir_protocol_fg_dll.cpp @@ -22,14 +22,6 @@ * with this program; if not, see . * * * ********************************************************************************/ -/* - Modifications (last one on top): - 20120830 - WVR: The Dialog class was used to get general info on the DLL. This - had a big disadvantage: the complete dialog was loaded, just to get - some data and then it was deleted again (without ever showing the dialog). - The ProtocolDll class solves this. - The functions to get the name(s) and icon were removed from the two other classes. -*/ #include "ftnoir_protocol_fg.h" #include #include "facetracknoir/global-settings.h" diff --git a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp index e457d363..e4dbc614 100644 --- a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp +++ b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp @@ -24,12 +24,6 @@ * FSUIPCServer FSUIPCServer is the Class, that communicates headpose-data * * to games, using the FSUIPC.dll. * ********************************************************************************/ -/* - Modifications (last one on top): - 20110401 - WVR: Moved protocol to a DLL, convenient for installation etc. - 20101224 - WVR: Base class is no longer inheriting QThread. sendHeadposeToGame - is called from run() of Tracker.cpp -*/ #include "ftnoir_protocol_fsuipc.h" #include "facetracknoir/global-settings.h" diff --git a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dialog.cpp b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dialog.cpp index 301bc0f4..abe9329c 100644 --- a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dialog.cpp +++ b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dialog.cpp @@ -22,14 +22,6 @@ * with this program; if not, see . * * * ********************************************************************************/ -/* - Modifications (last one on top): - 20120830 - WVR: The Dialog class was used to get general info on the DLL. This - had a big disadvantage: the complete dialog was loaded, just to get - some data and then it was deleted again (without ever showing the dialog). - The ProtocolDll class solves this. - The functions to get the name(s) and icon were removed from the two other classes. -*/ #include "ftnoir_protocol_fsuipc.h" #include "facetracknoir/global-settings.h" diff --git a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dll.cpp b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dll.cpp index 72d99fb9..c6ef3e38 100644 --- a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dll.cpp +++ b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dll.cpp @@ -22,14 +22,6 @@ * with this program; if not, see . * * * ********************************************************************************/ -/* - Modifications (last one on top): - 20120830 - WVR: The Dialog class was used to get general info on the DLL. This - had a big disadvantage: the complete dialog was loaded, just to get - some data and then it was deleted again (without ever showing the dialog). - The ProtocolDll class solves this. - The functions to get the name(s) and icon were removed from the two other classes. -*/ #include "ftnoir_protocol_fsuipc.h" #include #include "facetracknoir/global-settings.h" diff --git a/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp b/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp index bb960696..6e26c412 100644 --- a/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp +++ b/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp @@ -24,20 +24,6 @@ * FTServer FTServer is the Class, that communicates headpose-data * * to games, using the FreeTrackClient.dll. * ********************************************************************************/ -/* - Modifications (last one on top): - 20130209 - WVR: Some games support both interfaces and cause trouble. Added ComboBox to fix this (hide one interface - by clearing the appropriate Registry-setting). - 20130203 - WVR: Added Tirviews and dummy checkboxes to the Settings dialog. This is necessary for CFS3 etc. - 20130125 - WVR: Upgraded to FT2.0: now the FreeTrack protocol supports all TIR-enabled games. - 20110401 - WVR: Moved protocol to a DLL, convenient for installation etc. - 20101224 - WVR: Base class is no longer inheriting QThread. sendHeadposeToGame - is called from run() of Tracker.cpp - 20100601 - WVR: Added Mutex-bit in run(). Thought it wasn't so important (still do...). - 20100523 - WVR: Implemented the Freetrack-protocol just like Freetrack does. Earlier - FaceTrackNoIR only worked with an adapted DLL, with a putdata function. - Now it works direcly in shared memory! -*/ #include #include "ftnoir_protocol_ft.h" #include "ftnoir_csv/csv.h" diff --git a/ftnoir_protocol_ft/ftnoir_protocol_ft_dialog.cpp b/ftnoir_protocol_ft/ftnoir_protocol_ft_dialog.cpp index 8d4ef18f..2442d6b2 100644 --- a/ftnoir_protocol_ft/ftnoir_protocol_ft_dialog.cpp +++ b/ftnoir_protocol_ft/ftnoir_protocol_ft_dialog.cpp @@ -22,14 +22,6 @@ * with this program; if not, see . * * * ********************************************************************************/ -/* - Modifications (last one on top): - 20120830 - WVR: The Dialog class was used to get general info on the DLL. This - had a big disadvantage: the complete dialog was loaded, just to get - some data and then it was deleted again (without ever showing the dialog). - The ProtocolDll class solves this. - The functions to get the name(s) and icon were removed from the two other classes. -*/ #include "ftnoir_protocol_ft.h" #include #include diff --git a/ftnoir_protocol_ft/ftnoir_protocol_ft_dll.cpp b/ftnoir_protocol_ft/ftnoir_protocol_ft_dll.cpp index 5f821f59..5b6087b5 100644 --- a/ftnoir_protocol_ft/ftnoir_protocol_ft_dll.cpp +++ b/ftnoir_protocol_ft/ftnoir_protocol_ft_dll.cpp @@ -22,14 +22,6 @@ * with this program; if not, see . * * * ********************************************************************************/ -/* - Modifications (last one on top): - 20120830 - WVR: The Dialog class was used to get general info on the DLL. This - had a big disadvantage: the complete dialog was loaded, just to get - some data and then it was deleted again (without ever showing the dialog). - The ProtocolDll class solves this. - The functions to get the name(s) and icon were removed from the two other classes. -*/ #include "ftnoir_protocol_ft.h" #include diff --git a/ftnoir_protocol_ftn/ftnoir_protocol_ftn.cpp b/ftnoir_protocol_ftn/ftnoir_protocol_ftn.cpp index bfe83853..1fbc0b43 100644 --- a/ftnoir_protocol_ftn/ftnoir_protocol_ftn.cpp +++ b/ftnoir_protocol_ftn/ftnoir_protocol_ftn.cpp @@ -25,12 +25,6 @@ * to another FaceTrackNoIR program, using UDP. * * It is based on the (Linux) example made by Melchior FRANZ. * ********************************************************************************/ -/* - Modifications (last one on top): - 20110401 - WVR: Moved protocol to a DLL, convenient for installation etc. - 20101224 - WVR: Base class is no longer inheriting QThread. sendHeadposeToGame - is called from run() of Tracker.cpp -*/ #include "ftnoir_protocol_ftn.h" #include #include "facetracknoir/global-settings.h" diff --git a/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dialog.cpp b/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dialog.cpp index a5265275..328d866a 100644 --- a/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dialog.cpp +++ b/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dialog.cpp @@ -22,14 +22,6 @@ * with this program; if not, see . * * * ********************************************************************************/ -/* - Modifications (last one on top): - 20120830 - WVR: The Dialog class was used to get general info on the DLL. This - had a big disadvantage: the complete dialog was loaded, just to get - some data and then it was deleted again (without ever showing the dialog). - The ProtocolDll class solves this. - The functions to get the name(s) and icon were removed from the two other classes. -*/ #include "ftnoir_protocol_ftn.h" #include #include "facetracknoir/global-settings.h" diff --git a/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dll.cpp b/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dll.cpp index 61f06914..c52d6c9e 100644 --- a/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dll.cpp +++ b/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dll.cpp @@ -22,14 +22,6 @@ * with this program; if not, see . * * * ********************************************************************************/ -/* - Modifications (last one on top): - 20120830 - WVR: The Dialog class was used to get general info on the DLL. This - had a big disadvantage: the complete dialog was loaded, just to get - some data and then it was deleted again (without ever showing the dialog). - The ProtocolDll class solves this. - The functions to get the name(s) and icon were removed from the two other classes. -*/ #include "ftnoir_protocol_ftn.h" #include #include "facetracknoir/global-settings.h" diff --git a/ftnoir_protocol_mouse/ftnoir_protocol_mouse.cpp b/ftnoir_protocol_mouse/ftnoir_protocol_mouse.cpp index fc04c2f3..16a501b6 100644 --- a/ftnoir_protocol_mouse/ftnoir_protocol_mouse.cpp +++ b/ftnoir_protocol_mouse/ftnoir_protocol_mouse.cpp @@ -26,12 +26,6 @@ * Many games (like FPS's) support Mouse-look features, * * but no face-tracking. * ********************************************************************************/ -/* - Modifications (last one on top): - 20110401 - WVR: Moved protocol to a DLL, convenient for installation etc. - 20101224 - WVR: Base class is no longer inheriting QThread. sendHeadposeToGame - is called from run() of Tracker.cpp -*/ #include "ftnoir_protocol_mouse.h" #include "facetracknoir/global-settings.h" diff --git a/ftnoir_protocol_mouse/ftnoir_protocol_mouse_dialog.cpp b/ftnoir_protocol_mouse/ftnoir_protocol_mouse_dialog.cpp index 2b737030..c2f68bd2 100644 --- a/ftnoir_protocol_mouse/ftnoir_protocol_mouse_dialog.cpp +++ b/ftnoir_protocol_mouse/ftnoir_protocol_mouse_dialog.cpp @@ -22,14 +22,6 @@ * with this program; if not, see . * * * ********************************************************************************/ -/* - Modifications (last one on top): - 20120830 - WVR: The Dialog class was used to get general info on the DLL. This - had a big disadvantage: the complete dialog was loaded, just to get - some data and then it was deleted again (without ever showing the dialog). - The ProtocolDll class solves this. - The functions to get the name(s) and icon were removed from the two other classes. -*/ #include "ftnoir_protocol_mouse.h" #include #include "facetracknoir/global-settings.h" diff --git a/ftnoir_protocol_mouse/ftnoir_protocol_mouse_dll.cpp b/ftnoir_protocol_mouse/ftnoir_protocol_mouse_dll.cpp index 219f62af..f2250735 100644 --- a/ftnoir_protocol_mouse/ftnoir_protocol_mouse_dll.cpp +++ b/ftnoir_protocol_mouse/ftnoir_protocol_mouse_dll.cpp @@ -22,14 +22,6 @@ * with this program; if not, see . * * * ********************************************************************************/ -/* - Modifications (last one on top): - 20120830 - WVR: The Dialog class was used to get general info on the DLL. This - had a big disadvantage: the complete dialog was loaded, just to get - some data and then it was deleted again (without ever showing the dialog). - The ProtocolDll class solves this. - The functions to get the name(s) and icon were removed from the two other classes. -*/ #include "ftnoir_protocol_mouse.h" #include #include "facetracknoir/global-settings.h" diff --git a/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp b/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp index 3069a3bf..cae11816 100644 --- a/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp +++ b/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp @@ -26,12 +26,6 @@ * SimConnect.dll is a so called 'side-by-side' assembly, so it * * must be treated as such... * ********************************************************************************/ -/* - Modifications (last one on top): - 20110401 - WVR: Moved protocol to a DLL, convenient for installation etc. - 20101224 - WVR: Base class is no longer inheriting QThread. sendHeadposeToGame - is called from run() of Tracker.cpp -*/ #include "ftnoir_protocol_sc.h" #include "facetracknoir/global-settings.h" diff --git a/ftnoir_protocol_sc/ftnoir_protocol_sc_dialog.cpp b/ftnoir_protocol_sc/ftnoir_protocol_sc_dialog.cpp index bbc56e54..41e990dd 100644 --- a/ftnoir_protocol_sc/ftnoir_protocol_sc_dialog.cpp +++ b/ftnoir_protocol_sc/ftnoir_protocol_sc_dialog.cpp @@ -22,14 +22,6 @@ * with this program; if not, see . * * * ********************************************************************************/ -/* - Modifications (last one on top): - 20120830 - WVR: The Dialog class was used to get general info on the DLL. This - had a big disadvantage: the complete dialog was loaded, just to get - some data and then it was deleted again (without ever showing the dialog). - The ProtocolDll class solves this. - The functions to get the name(s) and icon were removed from the two other classes. -*/ #include "ftnoir_protocol_sc.h" #include #include "facetracknoir/global-settings.h" diff --git a/ftnoir_protocol_sc/ftnoir_protocol_sc_dll.cpp b/ftnoir_protocol_sc/ftnoir_protocol_sc_dll.cpp index 72d63c5e..102c7c57 100644 --- a/ftnoir_protocol_sc/ftnoir_protocol_sc_dll.cpp +++ b/ftnoir_protocol_sc/ftnoir_protocol_sc_dll.cpp @@ -22,14 +22,6 @@ * with this program; if not, see . * * * ********************************************************************************/ -/* - Modifications (last one on top): - 20120830 - WVR: The Dialog class was used to get general info on the DLL. This - had a big disadvantage: the complete dialog was loaded, just to get - some data and then it was deleted again (without ever showing the dialog). - The ProtocolDll class solves this. - The functions to get the name(s) and icon were removed from the two other classes. -*/ #include "ftnoir_protocol_SC.h" #include #include "facetracknoir/global-settings.h" diff --git a/ftnoir_tracker_sm/ftnoir_tracker_faceapi_dll.cpp b/ftnoir_tracker_sm/ftnoir_tracker_faceapi_dll.cpp index c824a217..a878a468 100644 --- a/ftnoir_tracker_sm/ftnoir_tracker_faceapi_dll.cpp +++ b/ftnoir_tracker_sm/ftnoir_tracker_faceapi_dll.cpp @@ -22,14 +22,6 @@ * with this program; if not, see . * * * ********************************************************************************/ -/* - Modifications (last one on top): - 20120830 - WVR: The Dialog class was used to get general info on the DLL. This - had a big disadvantage: the complete dialog was loaded, just to get - some data and then it was deleted again (without ever showing the dialog). - The TrackerDll class solves this. - The functions to get the name(s) and icon were removed from the two other classes. -*/ #include "ftnoir_tracker_sm.h" #include #include "facetracknoir/global-settings.h" diff --git a/ftnoir_tracker_udp/ftnoir_tracker_udp_dll.cpp b/ftnoir_tracker_udp/ftnoir_tracker_udp_dll.cpp index 0e794842..d4afb410 100644 --- a/ftnoir_tracker_udp/ftnoir_tracker_udp_dll.cpp +++ b/ftnoir_tracker_udp/ftnoir_tracker_udp_dll.cpp @@ -22,14 +22,6 @@ * with this program; if not, see . * * * ********************************************************************************/ -/* - Modifications (last one on top): - 20120830 - WVR: The Dialog class was used to get general info on the DLL. This - had a big disadvantage: the complete dialog was loaded, just to get - some data and then it was deleted again (without ever showing the dialog). - The TrackerDll class solves this. - The functions to get the name(s) and icon were removed from the two other classes. -*/ #include "ftnoir_tracker_udp.h" #include #include "facetracknoir/global-settings.h" diff --git a/qfunctionconfigurator/qfunctionconfigurator.cpp b/qfunctionconfigurator/qfunctionconfigurator.cpp index 304d252e..17905752 100644 --- a/qfunctionconfigurator/qfunctionconfigurator.cpp +++ b/qfunctionconfigurator/qfunctionconfigurator.cpp @@ -32,14 +32,6 @@ * provided that the above copyright notice and this permission * * notice appear in all copies. * ********************************************************************************/ -/* - Modifications (last one on top): - 20120830 - WVR: Changed functionality a bit. Now only draw the handles, when the function is drawn. - Only check mouseMoves, when they occur 'in range'. Redraw the curve, when a resize occurs. - Somehow, the curve was not drawn correctly, when this was not done (all points were too high). - After a 'Reset' this would disappear... - 20120828 - WVR: Removed bSkipText, which was used to not show a number below each vertical gridline. -*/ #include "qfunctionconfigurator/qfunctionconfigurator.h" #include #include -- cgit v1.2.3 From d6506963fa18ba8344d32668649c9cd1e6be9606 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 13 Sep 2013 15:12:51 +0200 Subject: Reduce copy-pasted code during dynamic library load --- facetracknoir/facetracknoir.cpp | 45 +++++++++++++++++------------------------ 1 file changed, 19 insertions(+), 26 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index 6cd708c7..47ef1787 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -988,6 +988,20 @@ void FaceTrackNoIR::exit() { QCoreApplication::exit(0); } +static bool get_metadata(DynamicLibrary* lib, QString& longName, QIcon& icon) +{ + Metadata* meta; + if (!lib->Metadata || ((meta = lib->Metadata()), !meta)) + { + delete lib; + return false; + } + meta->getFullName(&longName); + meta->getIcon(&icon); + delete meta; + return true; +} + // // Setup the icons for the comboBoxes // @@ -1004,15 +1018,8 @@ void FaceTrackNoIR::createIconGroupBox() DynamicLibrary* lib = new DynamicLibrary(str); qDebug() << "Loading" << str; std::cout.flush(); - Metadata* meta; - if (!lib->Metadata || ((meta = lib->Metadata()), !meta)) - { - delete lib; + if (!get_metadata(lib, longName, icon)) continue; - } - meta->getFullName(&longName); - meta->getIcon(&icon); - delete meta; dlopen_protocols.push_back(lib); ui.iconcomboProtocol->addItem(icon, longName); } @@ -1028,15 +1035,8 @@ void FaceTrackNoIR::createIconGroupBox() DynamicLibrary* lib = new DynamicLibrary(str); qDebug() << "Loading" << str; std::cout.flush(); - Metadata* meta; - if (!lib->Metadata || ((meta = lib->Metadata()), !meta)) - { - delete lib; + if (!get_metadata(lib, longName, icon)) continue; - } - meta->getFullName(&longName); - meta->getIcon(&icon); - delete meta; dlopen_trackers.push_back(lib); ui.iconcomboTrackerSource->addItem(icon, longName); ui.cbxSecondTrackerSource->addItem(icon, longName); @@ -1049,22 +1049,15 @@ void FaceTrackNoIR::createIconGroupBox() QStringList filters = settingsDir.entryList( QStringList() << (LIB_PREFIX "opentrack-filter-*." SONAME), QDir::Files, QDir::Name ); for ( int i = 0; i < filters.size(); i++) { QIcon icon; - QString fullName; + QString longName; QString str = filters.at(i); DynamicLibrary* lib = new DynamicLibrary(str); qDebug() << "Loading" << str; std::cout.flush(); - Metadata* meta; - if (!lib->Metadata || ((meta = lib->Metadata()), !meta)) - { - delete lib; + if (!get_metadata(lib, longName, icon)) continue; - } - meta->getFullName(&fullName); - meta->getIcon(&icon); - delete meta; dlopen_filters.push_back(lib); - ui.iconcomboFilter->addItem(icon, fullName); + ui.iconcomboFilter->addItem(icon, longName); } } -- cgit v1.2.3 From 330ec26d2e045d292e28fb814ebb6587dc977b5c Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 13 Sep 2013 15:20:48 +0200 Subject: Remove copypasta entirely in shared object loading --- facetracknoir/facetracknoir.cpp | 83 ++++++++++++++--------------------------- 1 file changed, 29 insertions(+), 54 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index 47ef1787..2d8b9252 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -1002,64 +1002,39 @@ static bool get_metadata(DynamicLibrary* lib, QString& longName, QIcon& icon) return true; } -// -// Setup the icons for the comboBoxes -// -void FaceTrackNoIR::createIconGroupBox() +static void fill_combobox(const QString& filter, QList& list, QComboBox* cbx) { - QDir settingsDir( QCoreApplication::applicationDirPath() ); - - { - QStringList protocols = settingsDir.entryList( QStringList() << (LIB_PREFIX "opentrack-proto-*." SONAME), QDir::Files, QDir::Name ); - for ( int i = 0; i < protocols.size(); i++) { - QIcon icon; - QString longName; - QString str = protocols.at(i); - DynamicLibrary* lib = new DynamicLibrary(str); - qDebug() << "Loading" << str; - std::cout.flush(); - if (!get_metadata(lib, longName, icon)) - continue; - dlopen_protocols.push_back(lib); - ui.iconcomboProtocol->addItem(icon, longName); - } - } - - { - ui.cbxSecondTrackerSource->addItem(QIcon(), "None"); - QStringList trackers = settingsDir.entryList( QStringList() << (LIB_PREFIX "opentrack-tracker-*." SONAME), QDir::Files, QDir::Name ); - for ( int i = 0; i < trackers.size(); i++) { - QIcon icon; - QString longName; - QString str = trackers.at(i); - DynamicLibrary* lib = new DynamicLibrary(str); - qDebug() << "Loading" << str; - std::cout.flush(); - if (!get_metadata(lib, longName, icon)) - continue; - dlopen_trackers.push_back(lib); - ui.iconcomboTrackerSource->addItem(icon, longName); - ui.cbxSecondTrackerSource->addItem(icon, longName); + QDir settingsDir( QCoreApplication::applicationDirPath() ); + QStringList filenames = settingsDir.entryList( QStringList() << (LIB_PREFIX + filter + SONAME), QDir::Files, QDir::Name ); + for ( int i = 0; i < filenames.size(); i++) { + QIcon icon; + QString longName; + QString str = filenames.at(i); + DynamicLibrary* lib = new DynamicLibrary(str); + qDebug() << "Loading" << str; + std::cout.flush(); + if (!get_metadata(lib, longName, icon)) + { + delete lib; + continue; } + list.push_back(lib); + cbx->addItem(icon, longName); } +} - { - dlopen_filters.push_back((DynamicLibrary*) NULL); - ui.iconcomboFilter->addItem(QIcon(), "None"); - QStringList filters = settingsDir.entryList( QStringList() << (LIB_PREFIX "opentrack-filter-*." SONAME), QDir::Files, QDir::Name ); - for ( int i = 0; i < filters.size(); i++) { - QIcon icon; - QString longName; - QString str = filters.at(i); - DynamicLibrary* lib = new DynamicLibrary(str); - qDebug() << "Loading" << str; - std::cout.flush(); - if (!get_metadata(lib, longName, icon)) - continue; - dlopen_filters.push_back(lib); - ui.iconcomboFilter->addItem(icon, longName); - } - } +// +// Setup the icons for the comboBoxes +// +void FaceTrackNoIR::createIconGroupBox() +{ + ui.cbxSecondTrackerSource->addItem(QIcon(), "None"); + dlopen_filters.push_back((DynamicLibrary*) NULL); + ui.iconcomboFilter->addItem(QIcon(), "None"); + + fill_combobox("opentrack-proto-*.", dlopen_protocols, ui.iconcomboProtocol); + fill_combobox("opentrack-tracker-*.", dlopen_trackers, ui.iconcomboTrackerSource); + fill_combobox("opentrack-filter-*.", dlopen_filters, ui.iconcomboFilter); connect(ui.iconcomboProtocol, SIGNAL(currentIndexChanged(int)), this, SLOT(protocolSelected(int))); connect(ui.iconcomboTrackerSource, SIGNAL(currentIndexChanged(int)), this, SLOT(trackingSourceSelected(int))); -- cgit v1.2.3 From f2968478e5e52edf04ec6c75aa70acf069b72343 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 13 Sep 2013 15:26:01 +0200 Subject: Fix include guard --- facetracknoir/facetracknoir.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.h b/facetracknoir/facetracknoir.h index c919f765..ff0b3642 100644 --- a/facetracknoir/facetracknoir.h +++ b/facetracknoir/facetracknoir.h @@ -259,8 +259,6 @@ private slots: void curveChanged( int change ) { settingsDirty = true; } }; -#endif // FaceTrackNoIR_H - extern QList global_key_sequences; #if defined(__WIN32) || defined(_WIN32) class KeybindingWorkerDummy { @@ -293,3 +291,5 @@ public: KeybindingWorkerDummy::run(); } }; + +#endif // FaceTrackNoIR_H \ No newline at end of file -- cgit v1.2.3 From 463737c1b50246c56a67c35c1116732006348593 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 13 Sep 2013 16:20:25 +0200 Subject: Don't expose filter internal state. Sprinkle some const --- facetracknoir/tracker.cpp | 3 +-- ftnoir_filter_accela/ftnoir_filter_accela.cpp | 5 ++--- ftnoir_filter_accela/ftnoir_filter_accela.h | 3 ++- ftnoir_filter_base/ftnoir_filter_base.h | 2 +- ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp | 5 ++--- ftnoir_filter_ewma2/ftnoir_filter_ewma2.h | 7 +++---- 6 files changed, 11 insertions(+), 14 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/tracker.cpp b/facetracknoir/tracker.cpp index f2b4845f..ff23a3bc 100644 --- a/facetracknoir/tracker.cpp +++ b/facetracknoir/tracker.cpp @@ -56,7 +56,6 @@ static void get_curve(double pos, double& out, THeadPoseDOF& axis) { /** QThread run method @override **/ void Tracker::run() { - T6DOF current_camera; // Used for filtering T6DOF target_camera; T6DOF new_camera; @@ -135,7 +134,7 @@ void Tracker::run() { if (Libraries->pFilter) { for (int i = 0; i < 6; i++) last_post_filter[i] = gameoutput_camera.axes[i]; - Libraries->pFilter->FilterHeadPoseData(current_camera.axes, target_camera.axes, new_camera.axes, last_post_filter); + Libraries->pFilter->FilterHeadPoseData(target_camera.axes, new_camera.axes, last_post_filter); } else { new_camera = target_camera; diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.cpp b/ftnoir_filter_accela/ftnoir_filter_accela.cpp index c2cda351..413702b5 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela.cpp @@ -51,10 +51,9 @@ static double parabola(const double a, const double x) return a1 * x * x; } -void FTNoIR_Filter::FilterHeadPoseData(double *current_camera_position, - double *target_camera_position, +void FTNoIR_Filter::FilterHeadPoseData(const double* target_camera_position, double *new_camera_position, - double *last_post_filter_values) + const double* last_post_filter_values) { if (first_run) { diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.h b/ftnoir_filter_accela/ftnoir_filter_accela.h index fb860136..c5a74d22 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.h +++ b/ftnoir_filter_accela/ftnoir_filter_accela.h @@ -45,7 +45,7 @@ class FTNOIR_FILTER_BASE_EXPORT FTNoIR_Filter : public IFilter public: FTNoIR_Filter(); ~FTNoIR_Filter(); - void FilterHeadPoseData(double *current_camera_position, double *target_camera_position, double *new_camera_position, double *last_post_filter_values); + void FilterHeadPoseData(const double* target_camera_position, double *new_camera_position, const double* last_post_filter_values); void Initialize() { first_run = true; } @@ -55,6 +55,7 @@ private: void loadSettings(); bool first_run; double rotation_alpha, translation_alpha, zoom_factor; + double current_camera_position[6]; }; //******************************************************************************************************* diff --git a/ftnoir_filter_base/ftnoir_filter_base.h b/ftnoir_filter_base/ftnoir_filter_base.h index 9ff286b1..0f73310f 100644 --- a/ftnoir_filter_base/ftnoir_filter_base.h +++ b/ftnoir_filter_base/ftnoir_filter_base.h @@ -26,7 +26,7 @@ struct IFilter { virtual ~IFilter() {} - virtual void FilterHeadPoseData(double *current_camera_position, double *target_camera_position, double *new_camera_position, double *last_post_filter) = 0; + virtual void FilterHeadPoseData(const double *target_camera_position, double *new_camera_position, const double *last_post_filter) = 0; virtual void Initialize() = 0; }; diff --git a/ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp b/ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp index 43cfd102..11af77f7 100644 --- a/ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp +++ b/ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp @@ -79,10 +79,9 @@ void FTNoIR_Filter::loadSettings() { iniFile.endGroup (); } -void FTNoIR_Filter::FilterHeadPoseData(double *current_camera_position, - double *target_camera_position, +void FTNoIR_Filter::FilterHeadPoseData(const double *target_camera_position, double *new_camera_position, - double *last_post_filter) + const double *last_post_filter) { double delta; double new_alpha; diff --git a/ftnoir_filter_ewma2/ftnoir_filter_ewma2.h b/ftnoir_filter_ewma2/ftnoir_filter_ewma2.h index 18fec8d4..e3a264be 100644 --- a/ftnoir_filter_ewma2/ftnoir_filter_ewma2.h +++ b/ftnoir_filter_ewma2/ftnoir_filter_ewma2.h @@ -44,10 +44,9 @@ public: ~FTNoIR_Filter(); void Initialize() {} - void FilterHeadPoseData(double *current_camera_position, - double *target_camera_position, + void FilterHeadPoseData(const double *target_camera_position, double *new_camera_position, - double *last_post_filter); + const double *last_post_filter); void receiveSettings(double smin, double smax, double sexpt); private: @@ -61,7 +60,7 @@ private: double kMinSmoothing; double kMaxSmoothing; double kSmoothingScaleCurve; - + double current_camera_position[6]; QMutex mutex; }; -- cgit v1.2.3 From ab8a2bcd1316abe8073e1751347b6be1db3507f9 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 14 Sep 2013 00:23:18 +0200 Subject: Kludgily restore missing second tracker src --- facetracknoir/facetracknoir.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index 2d8b9252..f3ec8fce 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -1002,7 +1002,7 @@ static bool get_metadata(DynamicLibrary* lib, QString& longName, QIcon& icon) return true; } -static void fill_combobox(const QString& filter, QList& list, QComboBox* cbx) +static void fill_combobox(const QString& filter, QList& list, QComboBox* cbx, QComboBox* cbx2) { QDir settingsDir( QCoreApplication::applicationDirPath() ); QStringList filenames = settingsDir.entryList( QStringList() << (LIB_PREFIX + filter + SONAME), QDir::Files, QDir::Name ); @@ -1020,6 +1020,8 @@ static void fill_combobox(const QString& filter, QList& list, Q } list.push_back(lib); cbx->addItem(icon, longName); + if (cbx2) + cbx2->addItem(icon, longName); } } @@ -1032,9 +1034,9 @@ void FaceTrackNoIR::createIconGroupBox() dlopen_filters.push_back((DynamicLibrary*) NULL); ui.iconcomboFilter->addItem(QIcon(), "None"); - fill_combobox("opentrack-proto-*.", dlopen_protocols, ui.iconcomboProtocol); - fill_combobox("opentrack-tracker-*.", dlopen_trackers, ui.iconcomboTrackerSource); - fill_combobox("opentrack-filter-*.", dlopen_filters, ui.iconcomboFilter); + fill_combobox("opentrack-proto-*.", dlopen_protocols, ui.iconcomboProtocol, NULL); + fill_combobox("opentrack-tracker-*.", dlopen_trackers, ui.iconcomboTrackerSource, ui.cbxSecondTrackerSource); + fill_combobox("opentrack-filter-*.", dlopen_filters, ui.iconcomboFilter, NULL); connect(ui.iconcomboProtocol, SIGNAL(currentIndexChanged(int)), this, SLOT(protocolSelected(int))); connect(ui.iconcomboTrackerSource, SIGNAL(currentIndexChanged(int)), this, SLOT(trackingSourceSelected(int))); -- cgit v1.2.3 From c58c0af311892929dbce4e5437c4035214552438 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 14 Sep 2013 15:34:44 +0200 Subject: Run dos2unix on the tree. No user-facing changes. --- faceapi/build_options.h | 16 +- faceapi/lock.h | 70 +- faceapi/lockfree.h | 130 +- faceapi/main.cpp | 1058 +++---- faceapi/mutex.h | 92 +- faceapi/stdafx.cpp | 16 +- faceapi/stdafx.h | 72 +- faceapi/utils.h | 698 ++--- facetracknoir/facetracknoir.cpp | 3126 ++++++++++---------- facetracknoir/facetracknoir.h | 588 ++-- facetracknoir/main.cpp | 114 +- facetracknoir/rotation.h | 128 +- facetracknoir/tracker.cpp | 436 +-- facetracknoir/tracker.h | 290 +- facetracknoir/tracker_types.cpp | 88 +- facetracknoir/tracker_types.h | 82 +- freetrackclient/ftclient.h | 60 +- ftnoir_filter_accela/ftnoir_filter_accela.cpp | 180 +- ftnoir_filter_accela/ftnoir_filter_accela.h | 214 +- .../ftnoir_filter_accela_dialog.cpp | 380 +-- ftnoir_filter_accela/ftnoir_filter_accela_dll.cpp | 78 +- ftnoir_filter_base/ftnoir_filter_base.h | 82 +- ftnoir_filter_base/ftnoir_filter_base_global.h | 24 +- ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp | 346 +-- ftnoir_filter_ewma2/ftnoir_filter_ewma2.h | 232 +- ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp | 396 +-- ftnoir_filter_ewma2/ftnoir_filter_ewma_dll.cpp | 98 +- ftnoir_posewidget/glwidget.cpp | 458 +-- ftnoir_posewidget/glwidget.h | 232 +- ftnoir_protocol_base/ftnoir_protocol_base.h | 150 +- ftnoir_protocol_base/ftnoir_protocol_base_global.h | 24 +- ftnoir_protocol_fg/fgtypes.h | 54 +- ftnoir_protocol_fg/ftnoir_protocol_fg.cpp | 444 +-- ftnoir_protocol_fg/ftnoir_protocol_fg.h | 242 +- ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp | 430 +-- ftnoir_protocol_fg/ftnoir_protocol_fg_dll.cpp | 98 +- ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp | 410 +-- ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h | 262 +- .../ftnoir_protocol_fsuipc_dialog.cpp | 370 +-- .../ftnoir_protocol_fsuipc_dll.cpp | 98 +- ftnoir_protocol_ft/ftnoir_protocol_ft.cpp | 566 ++-- ftnoir_protocol_ft/ftnoir_protocol_ft.h | 282 +- ftnoir_protocol_ft/ftnoir_protocol_ft_dialog.cpp | 450 +-- ftnoir_protocol_ft/ftnoir_protocol_ft_dll.cpp | 90 +- ftnoir_protocol_ftn/ftnoir_protocol_ftn.cpp | 236 +- ftnoir_protocol_ftn/ftnoir_protocol_ftn.h | 208 +- ftnoir_protocol_ftn/ftnoir_protocol_ftn_dialog.cpp | 360 +-- ftnoir_protocol_ftn/ftnoir_protocol_ftn_dll.cpp | 98 +- ftnoir_protocol_mouse/ftnoir_protocol_mouse.cpp | 202 +- ftnoir_protocol_mouse/ftnoir_protocol_mouse.h | 256 +- .../ftnoir_protocol_mouse_dialog.cpp | 362 +-- .../ftnoir_protocol_mouse_dll.cpp | 98 +- ftnoir_protocol_sc/ftnoir_protocol_sc.cpp | 712 ++--- ftnoir_protocol_sc/ftnoir_protocol_sc.h | 352 +-- ftnoir_protocol_sc/ftnoir_protocol_sc_dialog.cpp | 290 +- ftnoir_protocol_sc/ftnoir_protocol_sc_dll.cpp | 98 +- ftnoir_tracker_base/ftnoir_tracker_base.h | 162 +- ftnoir_tracker_base/ftnoir_tracker_base_global.h | 24 +- ftnoir_tracker_base/ftnoir_tracker_sm_types.h | 72 +- ftnoir_tracker_base/ftnoir_tracker_types.h | 74 +- ftnoir_tracker_pt/camera.cpp | 426 +-- ftnoir_tracker_pt/camera.h | 238 +- ftnoir_tracker_pt/ftnoir_tracker_pt.cpp | 522 ++-- ftnoir_tracker_pt/ftnoir_tracker_pt.h | 192 +- ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.cpp | 674 ++--- ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.h | 204 +- ftnoir_tracker_pt/ftnoir_tracker_pt_dll.cpp | 80 +- ftnoir_tracker_pt/ftnoir_tracker_pt_dll.h | 36 +- ftnoir_tracker_pt/ftnoir_tracker_pt_settings.cpp | 298 +- ftnoir_tracker_pt/ftnoir_tracker_pt_settings.h | 166 +- ftnoir_tracker_pt/point_extractor.cpp | 192 +- ftnoir_tracker_pt/point_extractor.h | 62 +- ftnoir_tracker_pt/point_tracker.cpp | 704 ++--- ftnoir_tracker_pt/point_tracker.h | 228 +- ftnoir_tracker_pt/resource.h | 28 +- ftnoir_tracker_pt/timer.cpp | 128 +- ftnoir_tracker_pt/timer.h | 86 +- ftnoir_tracker_pt/trans_calib.cpp | 86 +- ftnoir_tracker_pt/trans_calib.h | 76 +- ftnoir_tracker_pt/video_widget.cpp | 104 +- ftnoir_tracker_pt/video_widget.h | 84 +- ftnoir_tracker_sm/ftnoir_tracker_faceapi.cpp | 346 +-- .../ftnoir_tracker_faceapi_dialog.cpp | 564 ++-- ftnoir_tracker_sm/ftnoir_tracker_faceapi_dll.cpp | 144 +- ftnoir_tracker_sm/ftnoir_tracker_sm.h | 312 +- ftnoir_tracker_udp/ftnoir_tracker_udp.cpp | 346 +-- ftnoir_tracker_udp/ftnoir_tracker_udp.h | 194 +- ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp | 364 +-- ftnoir_tracker_udp/ftnoir_tracker_udp_dll.cpp | 146 +- qfunctionconfigurator/functionconfig.cpp | 564 ++-- qfunctionconfigurator/functionconfig.h | 156 +- 91 files changed, 12554 insertions(+), 12554 deletions(-) (limited to 'facetracknoir') diff --git a/faceapi/build_options.h b/faceapi/build_options.h index 6bc6a44c..e298686e 100644 --- a/faceapi/build_options.h +++ b/faceapi/build_options.h @@ -1,8 +1,8 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// -// Build Options -// -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -//controls whether or not FaceAPI should use the callback or poll -#define USE_HEADPOSE_CALLBACK 1 +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// +// Build Options +// +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +//controls whether or not FaceAPI should use the callback or poll +#define USE_HEADPOSE_CALLBACK 1 diff --git a/faceapi/lock.h b/faceapi/lock.h index efe38605..bb095675 100644 --- a/faceapi/lock.h +++ b/faceapi/lock.h @@ -1,35 +1,35 @@ -#ifndef SM_API_TESTAPPCONSOLE_LOCK_H -#define SM_API_TESTAPPCONSOLE_LOCK_H - -#include "mutex.h" - -namespace sm -{ - namespace faceapi - { - namespace samplecode - { - // A very simple scoped-lock class for sample code purposes. - // It is recommended that you use the boost threads library. - class Lock - { - public: - Lock(const Mutex &mutex): _mutex(mutex) - { - _mutex.lock(); - } - ~Lock() - { - _mutex.unlock(); - } - private: - // Noncopyable - Lock(const Lock &); - Lock &operator=(const Lock &); - private: - const Mutex &_mutex; - }; - } - } -} -#endif +#ifndef SM_API_TESTAPPCONSOLE_LOCK_H +#define SM_API_TESTAPPCONSOLE_LOCK_H + +#include "mutex.h" + +namespace sm +{ + namespace faceapi + { + namespace samplecode + { + // A very simple scoped-lock class for sample code purposes. + // It is recommended that you use the boost threads library. + class Lock + { + public: + Lock(const Mutex &mutex): _mutex(mutex) + { + _mutex.lock(); + } + ~Lock() + { + _mutex.unlock(); + } + private: + // Noncopyable + Lock(const Lock &); + Lock &operator=(const Lock &); + private: + const Mutex &_mutex; + }; + } + } +} +#endif diff --git a/faceapi/lockfree.h b/faceapi/lockfree.h index ce7d2a64..47b810fa 100644 --- a/faceapi/lockfree.h +++ b/faceapi/lockfree.h @@ -1,65 +1,65 @@ -//lock free queue template class by Herb Sutter -//Dr Dobbs Journal article http://www.drdobbs.com/cpp/210604448;jsessionid=OQGQPSMNL4X4XQE1GHPSKH4ATMY32JVN?pgno=1 - -template class LockFreeQueue -{ -private: - struct Node - { - Node( T val ) : value(val), next(nullptr) { } - T value; - Node* next; - }; - - Node* first; // for producer only - Node* divider, last; // shared - - //not working in VC2008 - //atomic divider, last; // shared - -public: - LockFreeQueue() - { - // add dummy separator - first = divider = last = new Node( T() ); - } - - ~LockFreeQueue() - { - while( first != nullptr ) - { - // release the list - Node* tmp = first; - first = tmp->next; - delete tmp; - } - } - - void Produce( const T& t ) - { - last->next = new Node(t); // add the new item - last = last->next; // publish it - - while( first != divider ) - { - // trim unused nodes - Node* tmp = first; - first = first->next; - delete tmp; - } - } - - bool Consume( T& result ) - { - if( divider != last ) - { - // if queue is nonempty - result = divider->next->value; // copy it back - divider = divider->next; // publish that we took it - return true; // and report success - } - - return false; // else report empty - } -}; - +//lock free queue template class by Herb Sutter +//Dr Dobbs Journal article http://www.drdobbs.com/cpp/210604448;jsessionid=OQGQPSMNL4X4XQE1GHPSKH4ATMY32JVN?pgno=1 + +template class LockFreeQueue +{ +private: + struct Node + { + Node( T val ) : value(val), next(nullptr) { } + T value; + Node* next; + }; + + Node* first; // for producer only + Node* divider, last; // shared + + //not working in VC2008 + //atomic divider, last; // shared + +public: + LockFreeQueue() + { + // add dummy separator + first = divider = last = new Node( T() ); + } + + ~LockFreeQueue() + { + while( first != nullptr ) + { + // release the list + Node* tmp = first; + first = tmp->next; + delete tmp; + } + } + + void Produce( const T& t ) + { + last->next = new Node(t); // add the new item + last = last->next; // publish it + + while( first != divider ) + { + // trim unused nodes + Node* tmp = first; + first = first->next; + delete tmp; + } + } + + bool Consume( T& result ) + { + if( divider != last ) + { + // if queue is nonempty + result = divider->next->value; // copy it back + divider = divider->next; // publish that we took it + return true; // and report success + } + + return false; // else report empty + } +}; + diff --git a/faceapi/main.cpp b/faceapi/main.cpp index 9fe0af95..8128ee97 100644 --- a/faceapi/main.cpp +++ b/faceapi/main.cpp @@ -1,529 +1,529 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of the some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2013 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -*********************************************************************************/ - -//Precompiled header -#include "stdafx.h" - -//FaceAPI headers -#include -#include "ftnoir_tracker_base/ftnoir_tracker_sm_types.h" -#include "utils.h" -#include - -//local headers -#include "build_options.h" - -//namespaces -using namespace std; -using namespace sm::faceapi::samplecode; - -// -// global variables -// -HANDLE hSMMemMap = NULL; -SMMemMap *pMemData; -HANDLE hSMMutex; -smEngineHeadPoseData new_head_pose; -bool stopCommand = false; -bool ftnoirConnected = false; - -//enums -enum GROUP_ID -{ - GROUP0=0, -}; - -enum EVENT_ID -{ - EVENT_PING=0, - EVENT_INIT, -}; - -enum INPUT_ID -{ - INPUT0=0, -}; - -//function definitions -void updateHeadPose(smEngineHeadPoseData* temp_head_pose); -bool SMCreateMapping(); - -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// -//FaceAPI function implementations -// -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -void STDCALL receiveLogMessage(void *, const char *buf, int /*buf_len*/) -{ - Lock lock(g_mutex); // serialize logging calls from different threads to avoid garbled output. - //cout << string(buf); -} - -// Callback function for face-data -void STDCALL receiveFaceData(void *, smEngineFaceData face_data, smCameraVideoFrame video_frame) -{ - Lock lock(g_mutex); - - // Get info including data pointer to original image from camera - smImageInfo video_frame_image_info; - THROW_ON_ERROR(smImageGetInfo(video_frame.image_handle, &video_frame_image_info)); // reentrant, so ok - - // video_frame_image_info.plane_addr[*] now point to the image memory planes. - // The memory is only valid until the end of this routine unless you call smImageAddRef(video_frame.image_handle). - // So you can deep copy the image data here, or use smImageAddRef() and just copy the pointer. - // If you use smImageAddRef() you are responsible for calling smImageDestroy() to avoid a memory leak later. - - // In this callback you will typically want to copy the smEngineFaceData data into your own data-structure. - // Since the smEngineFaceData contains multiple pod types copying it is not atomic and - // a mutex is required to avoid the race-condition with any thread simultaneously - // reading from your data-structure. - // Such a race condition will not crash your code but will create weird noise in the tracking data. - - if (g_do_face_data_printing) - { - //cout << video_frame << " " << face_data; - - // Save any face texture to a PNG file - if (face_data.texture) - { - // Create a unique filename - std::stringstream filename; - filename << "face_" << video_frame.frame_num << ".png"; - // Try saving to a file - if (saveToPNGFile(filename.str(), face_data.texture->image_info) == SM_API_OK) - { - cout << "Saved face-texture to " << filename.str() << std::endl; - } - else - { - cout << "Error saving face-texture to " << filename.str() << std::endl; - } - } - } -} - -// Callback function for head-pose -void STDCALL receiveHeadPose(void *,smEngineHeadPoseData head_pose, smCameraVideoFrame video_frame) -{ - Lock lock(g_mutex); - - // Get info including data pointer to original image from camera - smImageInfo video_frame_image_info; - THROW_ON_ERROR(smImageGetInfo(video_frame.image_handle, &video_frame_image_info)); // reentrant, so ok - - // video_frame_image_info.plane_addr[*] now point to the image memory planes. - // The memory is only valid until the end of this routine unless you call smImageAddRef(video_frame.image_handle). - // So you can deep copy the image data here, or use smImageAddRef() and just copy the pointer. - // If you use smImageAddRef() you are responsible for calling smImageDestroy() to avoid a memory leak later. - - // In this callback you will typically want to copy the smEngineFaceData data into your own data-structure. - // Since the smEngineFaceData contains multiple pod types copying it is not atomic and - // a mutex is required to avoid the race-condition with any thread simultaneously - // reading from your data-structure. - // Such a race condition will not crash your code but will create weird noise in the tracking data. - - if (g_do_head_pose_printing) - { - //cout << video_frame << " " << head_pose << std::endl; - } - - //make a copy of the new head pose data and send it to simconnect - //when we get a simmconnect frame event the new offset will be applied to the camera - updateHeadPose(&head_pose); -} - -// Create the first available camera detected on the system, and return its handle -smCameraHandle createFirstCamera() -{ - // Detect cameras - smCameraInfoList info_list; - THROW_ON_ERROR(smCameraCreateInfoList(&info_list)); - - if (info_list.num_cameras == 0) - { - throw std::exception(); - } - else - { - cout << "The followings cameras were detected: " << endl; - for (int i=0; ihandle,TRUE)); - THROW_ON_ERROR(smHTV2SetHeadPoseFilterLevel(engine_handle, pMemData->initial_filter_level)); - pMemData->handshake = 0; - } - else { - THROW_ON_ERROR(smVideoDisplayCreate(engine_handle,&video_display_handle,0,TRUE)); - } - - // Setup the VideoDisplay - THROW_ON_ERROR(smVideoDisplaySetFlags(video_display_handle,g_overlay_flags)); - - // Get the handle to the window and change the title to "Hello World" - smWindowHandle win_handle = 0; - THROW_ON_ERROR(smVideoDisplayGetWindowHandle(video_display_handle,&win_handle)); - SetWindowText(win_handle, _T("faceAPI Video-widget")); - MoveWindow(win_handle, 0, 0, 250, 180, true); - - // Loop on the keyboard - while (processKeyPress(engine_handle, video_display_handle) && !stopCommand) - { - // Read and print the current head-pose (if not using the callback mechanism) - #if (USE_HEADPOSE_CALLBACK==0) - #pragma message("Polling Headpose Manually") - if (engine_licensed) - { - smEngineHeadPoseData head_pose; - Lock lock(g_mutex); - - THROW_ON_ERROR(smHTCurrentHeadPose(engine_handle,&head_pose)); - if (g_do_head_pose_printing) - { - std::cout << head_pose << std::endl; - } - - } - #endif - - // NOTE: If you have a windows event loop in your program you - // will not need to call smAPIProcessEvents(). This manually redraws the video window. - THROW_ON_ERROR(smAPIProcessEvents()); - - // Prevent CPU overload in our simple loop. - const int frame_period_ms = 10; - Sleep(frame_period_ms); - - // - // Process the command sent by FaceTrackNoIR. - // - if (ftnoirConnected && (pMemData != 0)) { - - // - // Determine the trackers' state and send it to FaceTrackNoIR. - // - THROW_ON_ERROR(smEngineGetState(engine_handle, &state)); - pMemData->state = state; - pMemData->handshake += 1; - - // - // Check if FaceTrackNoIR is still 'in contact'. - // FaceTrackNoIR will reset the handshake, every time in writes data. - // If the value rises too high, this exe will stop itself... - // - if ( pMemData->handshake > 200) { - stopCommand = TRUE; - } - - // - // Check if a command was issued and do something with it! - // - switch (pMemData->command) { - case FT_SM_START: - - // - // Only execute Start, if the engine is not yet tracking. - // - if (state != SM_API_ENGINE_STATE_HT_TRACKING) { - THROW_ON_ERROR(smEngineStart(engine_handle)); // Start tracking - } - pMemData->command = 0; // Reset - break; - - case FT_SM_STOP: - THROW_ON_ERROR(smEngineStop(engine_handle)); // Stop tracking - pMemData->command = 0; // Reset - break; - - case FT_SM_EXIT: - THROW_ON_ERROR(smEngineStop(engine_handle)); // Stop tracking - stopCommand = TRUE; - pMemData->command = 0; // Reset - pMemData->state = SM_API_ENGINE_STATE_TERMINATED; // One last update, before quitting... - break; - - case FT_SM_SET_PAR_FILTER: - THROW_ON_ERROR(smHTV2SetHeadPoseFilterLevel(engine_handle, pMemData->par_val_int)); - pMemData->command = 0; // Reset - break; - - case FT_SM_SHOW_CAM: - THROW_ON_ERROR(smEngineShowCameraControlPanel(engine_handle)); - pMemData->command = 0; // Reset - break; - - default: - pMemData->command = 0; // Reset - // should never be reached - break; - } - } - } // While(1) - - // Destroy engine - THROW_ON_ERROR(smEngineDestroy(&engine_handle)); - // Destroy video display - THROW_ON_ERROR(smVideoDisplayDestroy(&video_display_handle)); - - if (ftnoirConnected) { - if ( pMemData != NULL ) { - UnmapViewOfFile ( pMemData ); - } - - if (hSMMutex != 0) { - CloseHandle( hSMMutex ); - } - hSMMutex = 0; - - if (hSMMemMap != 0) { - CloseHandle( hSMMemMap ); - } - hSMMemMap = 0; - } - -} // run() - -// Application entry point -int _tmain(int /*argc*/, _TCHAR** /*argv*/) -{ - OutputDebugString(_T("_tmain() says: Starting Function\n")); - - try - { - if (SMCreateMapping()) { - run(); - } - } - catch (exception &e) - { - cerr << e.what() << endl; - } - - return smAPIQuit(); -} - -// -// This is called exactly once for each FaceAPI callback and must be within an exclusive lock -// -void updateHeadPose(smEngineHeadPoseData* temp_head_pose) -{ - // - // Check if the pointer is OK and wait for the Mutex. - // - if ( (pMemData != NULL) && (WaitForSingleObject(hSMMutex, 100) == WAIT_OBJECT_0) ) { - - // - // Copy the Raw measurements directly to the client. - // - if (temp_head_pose->confidence > 0.0f) - { - memcpy(&pMemData->data.new_pose,temp_head_pose,sizeof(smEngineHeadPoseData)); - } - ReleaseMutex(hSMMutex); - } -}; - -// -// Create a memory-mapping to the faceAPI data. -// It contains the tracking data, a command-code from FaceTrackNoIR -// -// -bool SMCreateMapping() -{ - OutputDebugString(_T("FTCreateMapping says: Starting Function\n")); - - // - // A FileMapping is used to create 'shared memory' between the faceAPI and FaceTrackNoIR. - // FaceTrackNoIR creates the mapping, this program only opens it. - // If it's not there: the program was apparently started by the user instead of FaceTrackNoIR... - // - // Open an existing FileMapping, Read/Write access - // - hSMMemMap = OpenFileMappingA( FILE_MAP_WRITE , false , (LPCSTR) SM_MM_DATA ); - if ( ( hSMMemMap != 0 ) ) { - ftnoirConnected = true; - OutputDebugString(_T("FTCreateMapping says: FileMapping opened successfully...\n")); - pMemData = (SMMemMap *) MapViewOfFile(hSMMemMap, FILE_MAP_WRITE, 0, 0, sizeof(TFaceData)); - if (pMemData != NULL) { - OutputDebugString(_T("FTCreateMapping says: MapViewOfFile OK.\n")); - pMemData->state = 0; - } - hSMMutex = CreateMutexA(NULL, false, SM_MUTEX); - } - else { - OutputDebugString(_T("FTCreateMapping says: FileMapping not opened...FaceTrackNoIR not connected!\n")); - ftnoirConnected = false; - pMemData = 0; - } - - return true; -} +/******************************************************************************** +* FaceTrackNoIR This program is a private project of the some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2013 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +*********************************************************************************/ + +//Precompiled header +#include "stdafx.h" + +//FaceAPI headers +#include +#include "ftnoir_tracker_base/ftnoir_tracker_sm_types.h" +#include "utils.h" +#include + +//local headers +#include "build_options.h" + +//namespaces +using namespace std; +using namespace sm::faceapi::samplecode; + +// +// global variables +// +HANDLE hSMMemMap = NULL; +SMMemMap *pMemData; +HANDLE hSMMutex; +smEngineHeadPoseData new_head_pose; +bool stopCommand = false; +bool ftnoirConnected = false; + +//enums +enum GROUP_ID +{ + GROUP0=0, +}; + +enum EVENT_ID +{ + EVENT_PING=0, + EVENT_INIT, +}; + +enum INPUT_ID +{ + INPUT0=0, +}; + +//function definitions +void updateHeadPose(smEngineHeadPoseData* temp_head_pose); +bool SMCreateMapping(); + +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// +//FaceAPI function implementations +// +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void STDCALL receiveLogMessage(void *, const char *buf, int /*buf_len*/) +{ + Lock lock(g_mutex); // serialize logging calls from different threads to avoid garbled output. + //cout << string(buf); +} + +// Callback function for face-data +void STDCALL receiveFaceData(void *, smEngineFaceData face_data, smCameraVideoFrame video_frame) +{ + Lock lock(g_mutex); + + // Get info including data pointer to original image from camera + smImageInfo video_frame_image_info; + THROW_ON_ERROR(smImageGetInfo(video_frame.image_handle, &video_frame_image_info)); // reentrant, so ok + + // video_frame_image_info.plane_addr[*] now point to the image memory planes. + // The memory is only valid until the end of this routine unless you call smImageAddRef(video_frame.image_handle). + // So you can deep copy the image data here, or use smImageAddRef() and just copy the pointer. + // If you use smImageAddRef() you are responsible for calling smImageDestroy() to avoid a memory leak later. + + // In this callback you will typically want to copy the smEngineFaceData data into your own data-structure. + // Since the smEngineFaceData contains multiple pod types copying it is not atomic and + // a mutex is required to avoid the race-condition with any thread simultaneously + // reading from your data-structure. + // Such a race condition will not crash your code but will create weird noise in the tracking data. + + if (g_do_face_data_printing) + { + //cout << video_frame << " " << face_data; + + // Save any face texture to a PNG file + if (face_data.texture) + { + // Create a unique filename + std::stringstream filename; + filename << "face_" << video_frame.frame_num << ".png"; + // Try saving to a file + if (saveToPNGFile(filename.str(), face_data.texture->image_info) == SM_API_OK) + { + cout << "Saved face-texture to " << filename.str() << std::endl; + } + else + { + cout << "Error saving face-texture to " << filename.str() << std::endl; + } + } + } +} + +// Callback function for head-pose +void STDCALL receiveHeadPose(void *,smEngineHeadPoseData head_pose, smCameraVideoFrame video_frame) +{ + Lock lock(g_mutex); + + // Get info including data pointer to original image from camera + smImageInfo video_frame_image_info; + THROW_ON_ERROR(smImageGetInfo(video_frame.image_handle, &video_frame_image_info)); // reentrant, so ok + + // video_frame_image_info.plane_addr[*] now point to the image memory planes. + // The memory is only valid until the end of this routine unless you call smImageAddRef(video_frame.image_handle). + // So you can deep copy the image data here, or use smImageAddRef() and just copy the pointer. + // If you use smImageAddRef() you are responsible for calling smImageDestroy() to avoid a memory leak later. + + // In this callback you will typically want to copy the smEngineFaceData data into your own data-structure. + // Since the smEngineFaceData contains multiple pod types copying it is not atomic and + // a mutex is required to avoid the race-condition with any thread simultaneously + // reading from your data-structure. + // Such a race condition will not crash your code but will create weird noise in the tracking data. + + if (g_do_head_pose_printing) + { + //cout << video_frame << " " << head_pose << std::endl; + } + + //make a copy of the new head pose data and send it to simconnect + //when we get a simmconnect frame event the new offset will be applied to the camera + updateHeadPose(&head_pose); +} + +// Create the first available camera detected on the system, and return its handle +smCameraHandle createFirstCamera() +{ + // Detect cameras + smCameraInfoList info_list; + THROW_ON_ERROR(smCameraCreateInfoList(&info_list)); + + if (info_list.num_cameras == 0) + { + throw std::exception(); + } + else + { + cout << "The followings cameras were detected: " << endl; + for (int i=0; ihandle,TRUE)); + THROW_ON_ERROR(smHTV2SetHeadPoseFilterLevel(engine_handle, pMemData->initial_filter_level)); + pMemData->handshake = 0; + } + else { + THROW_ON_ERROR(smVideoDisplayCreate(engine_handle,&video_display_handle,0,TRUE)); + } + + // Setup the VideoDisplay + THROW_ON_ERROR(smVideoDisplaySetFlags(video_display_handle,g_overlay_flags)); + + // Get the handle to the window and change the title to "Hello World" + smWindowHandle win_handle = 0; + THROW_ON_ERROR(smVideoDisplayGetWindowHandle(video_display_handle,&win_handle)); + SetWindowText(win_handle, _T("faceAPI Video-widget")); + MoveWindow(win_handle, 0, 0, 250, 180, true); + + // Loop on the keyboard + while (processKeyPress(engine_handle, video_display_handle) && !stopCommand) + { + // Read and print the current head-pose (if not using the callback mechanism) + #if (USE_HEADPOSE_CALLBACK==0) + #pragma message("Polling Headpose Manually") + if (engine_licensed) + { + smEngineHeadPoseData head_pose; + Lock lock(g_mutex); + + THROW_ON_ERROR(smHTCurrentHeadPose(engine_handle,&head_pose)); + if (g_do_head_pose_printing) + { + std::cout << head_pose << std::endl; + } + + } + #endif + + // NOTE: If you have a windows event loop in your program you + // will not need to call smAPIProcessEvents(). This manually redraws the video window. + THROW_ON_ERROR(smAPIProcessEvents()); + + // Prevent CPU overload in our simple loop. + const int frame_period_ms = 10; + Sleep(frame_period_ms); + + // + // Process the command sent by FaceTrackNoIR. + // + if (ftnoirConnected && (pMemData != 0)) { + + // + // Determine the trackers' state and send it to FaceTrackNoIR. + // + THROW_ON_ERROR(smEngineGetState(engine_handle, &state)); + pMemData->state = state; + pMemData->handshake += 1; + + // + // Check if FaceTrackNoIR is still 'in contact'. + // FaceTrackNoIR will reset the handshake, every time in writes data. + // If the value rises too high, this exe will stop itself... + // + if ( pMemData->handshake > 200) { + stopCommand = TRUE; + } + + // + // Check if a command was issued and do something with it! + // + switch (pMemData->command) { + case FT_SM_START: + + // + // Only execute Start, if the engine is not yet tracking. + // + if (state != SM_API_ENGINE_STATE_HT_TRACKING) { + THROW_ON_ERROR(smEngineStart(engine_handle)); // Start tracking + } + pMemData->command = 0; // Reset + break; + + case FT_SM_STOP: + THROW_ON_ERROR(smEngineStop(engine_handle)); // Stop tracking + pMemData->command = 0; // Reset + break; + + case FT_SM_EXIT: + THROW_ON_ERROR(smEngineStop(engine_handle)); // Stop tracking + stopCommand = TRUE; + pMemData->command = 0; // Reset + pMemData->state = SM_API_ENGINE_STATE_TERMINATED; // One last update, before quitting... + break; + + case FT_SM_SET_PAR_FILTER: + THROW_ON_ERROR(smHTV2SetHeadPoseFilterLevel(engine_handle, pMemData->par_val_int)); + pMemData->command = 0; // Reset + break; + + case FT_SM_SHOW_CAM: + THROW_ON_ERROR(smEngineShowCameraControlPanel(engine_handle)); + pMemData->command = 0; // Reset + break; + + default: + pMemData->command = 0; // Reset + // should never be reached + break; + } + } + } // While(1) + + // Destroy engine + THROW_ON_ERROR(smEngineDestroy(&engine_handle)); + // Destroy video display + THROW_ON_ERROR(smVideoDisplayDestroy(&video_display_handle)); + + if (ftnoirConnected) { + if ( pMemData != NULL ) { + UnmapViewOfFile ( pMemData ); + } + + if (hSMMutex != 0) { + CloseHandle( hSMMutex ); + } + hSMMutex = 0; + + if (hSMMemMap != 0) { + CloseHandle( hSMMemMap ); + } + hSMMemMap = 0; + } + +} // run() + +// Application entry point +int _tmain(int /*argc*/, _TCHAR** /*argv*/) +{ + OutputDebugString(_T("_tmain() says: Starting Function\n")); + + try + { + if (SMCreateMapping()) { + run(); + } + } + catch (exception &e) + { + cerr << e.what() << endl; + } + + return smAPIQuit(); +} + +// +// This is called exactly once for each FaceAPI callback and must be within an exclusive lock +// +void updateHeadPose(smEngineHeadPoseData* temp_head_pose) +{ + // + // Check if the pointer is OK and wait for the Mutex. + // + if ( (pMemData != NULL) && (WaitForSingleObject(hSMMutex, 100) == WAIT_OBJECT_0) ) { + + // + // Copy the Raw measurements directly to the client. + // + if (temp_head_pose->confidence > 0.0f) + { + memcpy(&pMemData->data.new_pose,temp_head_pose,sizeof(smEngineHeadPoseData)); + } + ReleaseMutex(hSMMutex); + } +}; + +// +// Create a memory-mapping to the faceAPI data. +// It contains the tracking data, a command-code from FaceTrackNoIR +// +// +bool SMCreateMapping() +{ + OutputDebugString(_T("FTCreateMapping says: Starting Function\n")); + + // + // A FileMapping is used to create 'shared memory' between the faceAPI and FaceTrackNoIR. + // FaceTrackNoIR creates the mapping, this program only opens it. + // If it's not there: the program was apparently started by the user instead of FaceTrackNoIR... + // + // Open an existing FileMapping, Read/Write access + // + hSMMemMap = OpenFileMappingA( FILE_MAP_WRITE , false , (LPCSTR) SM_MM_DATA ); + if ( ( hSMMemMap != 0 ) ) { + ftnoirConnected = true; + OutputDebugString(_T("FTCreateMapping says: FileMapping opened successfully...\n")); + pMemData = (SMMemMap *) MapViewOfFile(hSMMemMap, FILE_MAP_WRITE, 0, 0, sizeof(TFaceData)); + if (pMemData != NULL) { + OutputDebugString(_T("FTCreateMapping says: MapViewOfFile OK.\n")); + pMemData->state = 0; + } + hSMMutex = CreateMutexA(NULL, false, SM_MUTEX); + } + else { + OutputDebugString(_T("FTCreateMapping says: FileMapping not opened...FaceTrackNoIR not connected!\n")); + ftnoirConnected = false; + pMemData = 0; + } + + return true; +} diff --git a/faceapi/mutex.h b/faceapi/mutex.h index a4f84705..b1a013e8 100644 --- a/faceapi/mutex.h +++ b/faceapi/mutex.h @@ -1,46 +1,46 @@ -#ifndef SM_API_TESTAPPCONSOLE_MUTEX_H -#define SM_API_TESTAPPCONSOLE_MUTEX_H - -#include - -namespace sm -{ - namespace faceapi - { - namespace samplecode - { - // A very simple mutex class for sample code purposes. - // It is recommended that you use the boost threads library. - class Mutex - { - public: - Mutex() - { - if (!InitializeCriticalSectionAndSpinCount(&_cs,0x80000400)) - { - throw std::exception(); - } - } - ~Mutex() - { - DeleteCriticalSection(&_cs); - } - void lock() const - { - EnterCriticalSection(&_cs); - } - void unlock() const - { - LeaveCriticalSection(&_cs); - } - private: - // Noncopyable - Mutex(const Mutex &); - Mutex &operator=(const Mutex &); - private: - mutable CRITICAL_SECTION _cs; - }; - } - } -} -#endif +#ifndef SM_API_TESTAPPCONSOLE_MUTEX_H +#define SM_API_TESTAPPCONSOLE_MUTEX_H + +#include + +namespace sm +{ + namespace faceapi + { + namespace samplecode + { + // A very simple mutex class for sample code purposes. + // It is recommended that you use the boost threads library. + class Mutex + { + public: + Mutex() + { + if (!InitializeCriticalSectionAndSpinCount(&_cs,0x80000400)) + { + throw std::exception(); + } + } + ~Mutex() + { + DeleteCriticalSection(&_cs); + } + void lock() const + { + EnterCriticalSection(&_cs); + } + void unlock() const + { + LeaveCriticalSection(&_cs); + } + private: + // Noncopyable + Mutex(const Mutex &); + Mutex &operator=(const Mutex &); + private: + mutable CRITICAL_SECTION _cs; + }; + } + } +} +#endif diff --git a/faceapi/stdafx.cpp b/faceapi/stdafx.cpp index b4263f59..981c9e33 100644 --- a/faceapi/stdafx.cpp +++ b/faceapi/stdafx.cpp @@ -1,8 +1,8 @@ -// stdafx.cpp : source file that includes just the standard includes -// TestAppConsole.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - -// TODO: reference any additional headers you need in STDAFX.H -// and not in this file +// stdafx.cpp : source file that includes just the standard includes +// TestAppConsole.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + +// TODO: reference any additional headers you need in STDAFX.H +// and not in this file diff --git a/faceapi/stdafx.h b/faceapi/stdafx.h index 1fdab0b1..92e24b3e 100644 --- a/faceapi/stdafx.h +++ b/faceapi/stdafx.h @@ -1,36 +1,36 @@ -#pragma once - -#ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later. -#define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows. -#endif - -#include -#include - -#ifndef _MSC_VER - -#include - -typedef uint64_t u_int64_t; -typedef uint32_t u_int32_t; -typedef uint16_t u_int16_t; -typedef uint8_t u_int8_t; -#endif - -#include -#include -#include -#include -#include -#include -#ifdef SM_API -# undef SM_API -#endif -#ifdef STDCALL -# undef STDCALL -#endif - -#define SM_API(type) type __declspec(dllimport) __stdcall -#define STDCALL __stdcall - -#include +#pragma once + +#ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later. +#define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows. +#endif + +#include +#include + +#ifndef _MSC_VER + +#include + +typedef uint64_t u_int64_t; +typedef uint32_t u_int32_t; +typedef uint16_t u_int16_t; +typedef uint8_t u_int8_t; +#endif + +#include +#include +#include +#include +#include +#include +#ifdef SM_API +# undef SM_API +#endif +#ifdef STDCALL +# undef STDCALL +#endif + +#define SM_API(type) type __declspec(dllimport) __stdcall +#define STDCALL __stdcall + +#include diff --git a/faceapi/utils.h b/faceapi/utils.h index 5d25e9a7..80555d22 100644 --- a/faceapi/utils.h +++ b/faceapi/utils.h @@ -1,349 +1,349 @@ -#ifndef SM_API_TESTAPPCONSOLE_UTILS_H -#define SM_API_TESTAPPCONSOLE_UTILS_H - -#include "lock.h" -#include -#include - -#define THROW_ON_ERROR(x) \ -{ \ - smReturnCode result = (x); \ - if (result < 0) \ - { \ - std::stringstream s; \ - s << "API error code: " << result; \ - std::cerr << s; \ - throw std::exception(); \ - } \ -} - -namespace sm -{ - namespace faceapi - { - namespace samplecode - { - // Global variables - Mutex g_mutex; - bool g_ctrl_c_detected(false); - bool g_do_head_pose_printing(false); - bool g_do_face_data_printing(false); - unsigned short g_overlay_flags(SM_API_VIDEO_DISPLAY_HEAD_MESH | SM_API_VIDEO_DISPLAY_PERFORMANCE); - - // CTRL-C handler function - void __cdecl CtrlCHandler(int) - { - Lock lock(g_mutex); - std::cout << "Ctrl-C detected, stopping..." << std::endl; - g_ctrl_c_detected = true; - } - - // Radians to degrees conversion - float rad2deg(float rad) - { - return rad*57.2957795f; - } - - void toggleFlag(unsigned short &val, unsigned short flag) - { - if (val & flag) - { - val = val & ~flag; - } - else - { - val = val | flag; - } - } - - // Save an image to PNG file - smReturnCode saveToPNGFile(const std::string& filepath, smImageInfo image_info) - { - smBool ok; - smReturnCode error; - - // Create an API string - smStringHandle filepath_handle = 0; - ok = (error = smStringCreate(&filepath_handle)) == SM_API_OK; - ok = ok && (error = smStringReadBuffer(filepath_handle,filepath.c_str(),filepath.size())) == SM_API_OK; - - // Create an API image - smImageHandle image_handle = 0; - smImageMemoryCopyMode copy_mode = SM_API_IMAGE_MEMORYCOPYMODE_AUTO; - ok = ok && (error = smImageCreateFromInfo(&image_info,©_mode,&image_handle)) == SM_API_OK; - - // Save the image as PNG - ok = ok && (error = smImageSaveToPNG(image_handle,filepath_handle)) == SM_API_OK; - - // Destroy the image and string - smStringDestroy(&filepath_handle); - smImageDestroy(&image_handle); - return error; - } - - // Stream operators for printing - - std::ostream &operator<<(std::ostream & os, const smSize2i &s) - { - return os << "[" << s.h << "," << s.h << "]"; - } - - std::ostream &operator<<(std::ostream & os, const smCoord3f &pos) - { - return os << "(" << pos.x << "," << pos.y << "," << pos.z << ")"; - } - - std::ostream &operator<<(std::ostream & os, const smRotEuler &rot) - { - return os << "(" << rad2deg(rot.x_rads) << "," << rad2deg(rot.y_rads) << "," << rad2deg(rot.z_rads) << ")"; - } - - std::ostream &operator<<(std::ostream & os, const smPixel &p) - { - return os << "[" << static_cast(p.x) << "," << static_cast(p.y) << "]"; - } - - std::ostream &operator<<(std::ostream & os, const smFaceTexCoord &ftc) - { - return os << "{" << ftc.u << "," << ftc.v << "}"; - } - - std::ostream &operator<<(std::ostream & os, const smFaceLandmark &lm) - { - return os << "id "<< lm.id << " fc" << lm.fc << " ftc" << lm.ftc << " pc" << lm.pc << " wc" << lm.wc; - } - - std::ostream &operator<<(std::ostream & os, const smImageInfo &im) - { - os << "format "; - switch (im.format) - { - case SM_API_IMAGECODE_GRAY_8U: - os << "GRAY_8U"; - break; - case SM_API_IMAGECODE_GRAY_16U: - os << "GRAY_16U"; - break; - case SM_API_IMAGECODE_YUY2: - os << "YUY2"; - break; - case SM_API_IMAGECODE_I420: - os << "I420"; - break; - case SM_API_IMAGECODE_BGRA_32U: - os << "BGRA_32U"; - break; - case SM_API_IMAGECODE_ARGB_32U: - os << "ARGB_32U"; - break; - case SM_API_IMAGECODE_BGR_24U: - os << "BGR_24U"; - break; - case SM_API_IMAGECODE_RGB_24U: - os << "RGB_24U"; - break; - default: - os << "unknown"; - break; - } - os << " res" << im.res; - os << " plane_addr(" << static_cast(im.plane_addr[0]) << "," - << static_cast(im.plane_addr[1]) << "," - << static_cast(im.plane_addr[2]) << "," - << static_cast(im.plane_addr[3]) << ")"; - os << " step_bytes(" << im.step_bytes[0] << "," << im.step_bytes[1] << "," << im.step_bytes[2] << "," << im.step_bytes[3] << ")"; - os << " user_data " << im.user_data; - return os; - } - - std::ostream &operator<<(std::ostream & os, const smFaceTexture &t) - { - os << "type "; - switch (t.type) - { - case SM_ORTHOGRAPHIC_PROJECTION: - os << "orthographic"; - break; - default: - os << "unknown"; - break; - } - os << " origin" << t.origin << " scale" << t.scale << std::endl; - os << " image_info " << t.image_info << std::endl; - os << " num_mask_landmarks " << t.num_mask_landmarks << std::endl; - for (int i=0; i +#include + +#define THROW_ON_ERROR(x) \ +{ \ + smReturnCode result = (x); \ + if (result < 0) \ + { \ + std::stringstream s; \ + s << "API error code: " << result; \ + std::cerr << s; \ + throw std::exception(); \ + } \ +} + +namespace sm +{ + namespace faceapi + { + namespace samplecode + { + // Global variables + Mutex g_mutex; + bool g_ctrl_c_detected(false); + bool g_do_head_pose_printing(false); + bool g_do_face_data_printing(false); + unsigned short g_overlay_flags(SM_API_VIDEO_DISPLAY_HEAD_MESH | SM_API_VIDEO_DISPLAY_PERFORMANCE); + + // CTRL-C handler function + void __cdecl CtrlCHandler(int) + { + Lock lock(g_mutex); + std::cout << "Ctrl-C detected, stopping..." << std::endl; + g_ctrl_c_detected = true; + } + + // Radians to degrees conversion + float rad2deg(float rad) + { + return rad*57.2957795f; + } + + void toggleFlag(unsigned short &val, unsigned short flag) + { + if (val & flag) + { + val = val & ~flag; + } + else + { + val = val | flag; + } + } + + // Save an image to PNG file + smReturnCode saveToPNGFile(const std::string& filepath, smImageInfo image_info) + { + smBool ok; + smReturnCode error; + + // Create an API string + smStringHandle filepath_handle = 0; + ok = (error = smStringCreate(&filepath_handle)) == SM_API_OK; + ok = ok && (error = smStringReadBuffer(filepath_handle,filepath.c_str(),filepath.size())) == SM_API_OK; + + // Create an API image + smImageHandle image_handle = 0; + smImageMemoryCopyMode copy_mode = SM_API_IMAGE_MEMORYCOPYMODE_AUTO; + ok = ok && (error = smImageCreateFromInfo(&image_info,©_mode,&image_handle)) == SM_API_OK; + + // Save the image as PNG + ok = ok && (error = smImageSaveToPNG(image_handle,filepath_handle)) == SM_API_OK; + + // Destroy the image and string + smStringDestroy(&filepath_handle); + smImageDestroy(&image_handle); + return error; + } + + // Stream operators for printing + + std::ostream &operator<<(std::ostream & os, const smSize2i &s) + { + return os << "[" << s.h << "," << s.h << "]"; + } + + std::ostream &operator<<(std::ostream & os, const smCoord3f &pos) + { + return os << "(" << pos.x << "," << pos.y << "," << pos.z << ")"; + } + + std::ostream &operator<<(std::ostream & os, const smRotEuler &rot) + { + return os << "(" << rad2deg(rot.x_rads) << "," << rad2deg(rot.y_rads) << "," << rad2deg(rot.z_rads) << ")"; + } + + std::ostream &operator<<(std::ostream & os, const smPixel &p) + { + return os << "[" << static_cast(p.x) << "," << static_cast(p.y) << "]"; + } + + std::ostream &operator<<(std::ostream & os, const smFaceTexCoord &ftc) + { + return os << "{" << ftc.u << "," << ftc.v << "}"; + } + + std::ostream &operator<<(std::ostream & os, const smFaceLandmark &lm) + { + return os << "id "<< lm.id << " fc" << lm.fc << " ftc" << lm.ftc << " pc" << lm.pc << " wc" << lm.wc; + } + + std::ostream &operator<<(std::ostream & os, const smImageInfo &im) + { + os << "format "; + switch (im.format) + { + case SM_API_IMAGECODE_GRAY_8U: + os << "GRAY_8U"; + break; + case SM_API_IMAGECODE_GRAY_16U: + os << "GRAY_16U"; + break; + case SM_API_IMAGECODE_YUY2: + os << "YUY2"; + break; + case SM_API_IMAGECODE_I420: + os << "I420"; + break; + case SM_API_IMAGECODE_BGRA_32U: + os << "BGRA_32U"; + break; + case SM_API_IMAGECODE_ARGB_32U: + os << "ARGB_32U"; + break; + case SM_API_IMAGECODE_BGR_24U: + os << "BGR_24U"; + break; + case SM_API_IMAGECODE_RGB_24U: + os << "RGB_24U"; + break; + default: + os << "unknown"; + break; + } + os << " res" << im.res; + os << " plane_addr(" << static_cast(im.plane_addr[0]) << "," + << static_cast(im.plane_addr[1]) << "," + << static_cast(im.plane_addr[2]) << "," + << static_cast(im.plane_addr[3]) << ")"; + os << " step_bytes(" << im.step_bytes[0] << "," << im.step_bytes[1] << "," << im.step_bytes[2] << "," << im.step_bytes[3] << ")"; + os << " user_data " << im.user_data; + return os; + } + + std::ostream &operator<<(std::ostream & os, const smFaceTexture &t) + { + os << "type "; + switch (t.type) + { + case SM_ORTHOGRAPHIC_PROJECTION: + os << "orthographic"; + break; + default: + os << "unknown"; + break; + } + os << " origin" << t.origin << " scale" << t.scale << std::endl; + os << " image_info " << t.image_info << std::endl; + os << " num_mask_landmarks " << t.num_mask_landmarks << std::endl; + for (int i=0; i. * -*********************************************************************************/ -#include "facetracknoir.h" -#include "tracker.h" -#include -#include - -#if defined(__WIN32) || defined(_WIN32) -# include -#endif - -#if defined(__APPLE__) -# define SONAME "dylib" -#elif defined(_WIN32) || defined(__WIN32) -# define SONAME "dll" -#else -# define SONAME "so" -#endif - -#include - -#if defined(__WIN32) || defined(_WIN32) -#undef DIRECTINPUT_VERSION -#define DIRECTINPUT_VERSION 0x0800 -#include -#include - -KeybindingWorkerDummy::~KeybindingWorkerDummy() { - if (dinkeyboard) { - dinkeyboard->Unacquire(); - dinkeyboard->Release(); - } - if (din) - din->Release(); -} - -KeybindingWorkerDummy::KeybindingWorkerDummy(FaceTrackNoIR& w, Key keyCenter) -: kCenter(keyCenter), window(w), should_quit(true), din(0), dinkeyboard(0) -{ - if (DirectInput8Create(GetModuleHandle(NULL), DIRECTINPUT_VERSION, IID_IDirectInput8, (void**)&din, NULL) != DI_OK) { - qDebug() << "setup DirectInput8 Creation failed!" << GetLastError(); - return; - } - if (din->CreateDevice(GUID_SysKeyboard, &dinkeyboard, NULL) != DI_OK) { - din->Release(); - din = 0; - qDebug() << "setup CreateDevice function failed!" << GetLastError(); - return; - } - if (dinkeyboard->SetDataFormat(&c_dfDIKeyboard) != DI_OK) { - qDebug() << "setup SetDataFormat function failed!" << GetLastError(); - dinkeyboard->Release(); - dinkeyboard = 0; - din->Release(); - din = 0; - return; - } - - if (dinkeyboard->SetCooperativeLevel(window.winId(), DISCL_NONEXCLUSIVE | DISCL_BACKGROUND) != DI_OK) { - dinkeyboard->Release(); - din->Release(); - din = 0; - dinkeyboard = 0; - qDebug() << "setup SetCooperativeLevel function failed!" << GetLastError(); - return; - } - if (dinkeyboard->Acquire() != DI_OK) - { - dinkeyboard->Release(); - din->Release(); - din = 0; - dinkeyboard = 0; - qDebug() << "setup dinkeyboard Acquire failed!" << GetLastError(); - return; - } - should_quit = false; -} - -#define PROCESS_KEY(k, s) \ - if (isKeyPressed(&k, keystate) && (!k.ever_pressed ? (k.timer.start(), k.ever_pressed = true) : k.timer.restart() > 100)) \ - window.s(); - -static bool isKeyPressed( const Key *key, const BYTE *keystate ) { - bool shift; - bool ctrl; - bool alt; - - if (keystate[key->keycode] & 0x80) { - shift = ( (keystate[DIK_LSHIFT] & 0x80) || (keystate[DIK_RSHIFT] & 0x80) ); - ctrl = ( (keystate[DIK_LCONTROL] & 0x80) || (keystate[DIK_RCONTROL] & 0x80) ); - alt = ( (keystate[DIK_LALT] & 0x80) || (keystate[DIK_RALT] & 0x80) ); - - // - // If one of the modifiers is needed and not pressed, return false. - // - if (key->shift && !shift) return false; - if (key->ctrl && !ctrl) return false; - if (key->alt && !alt) return false; - - // - // All is well! - // - return true; - } - return false; -} - -void KeybindingWorkerDummy::run() { - BYTE keystate[256]; - while (!should_quit) - { - if (dinkeyboard->GetDeviceState(256, (LPVOID)keystate) != DI_OK) { - qDebug() << "Tracker::run GetDeviceState function failed!" << GetLastError(); - Sleep(25); - continue; - } - - PROCESS_KEY(kCenter, shortcutRecentered); - - Sleep(25); - } -} -#else -#endif - -#ifdef _MSC_VER -# define LIB_PREFIX "" -#else -# define LIB_PREFIX "lib" -#endif - -// -// Setup the Main Dialog -// -FaceTrackNoIR::FaceTrackNoIR(QWidget *parent, Qt::WFlags flags) : - #if defined(__WIN32) || defined(_WIN32) - keybindingWorker(NULL), - #else - keyCenter(0), - #endif - QMainWindow(parent, flags), - pTrackerDialog(NULL), - pSecondTrackerDialog(NULL), - pProtocolDialog(NULL), - pFilterDialog(NULL), - looping(false), - timUpdateHeadPose(this) -{ - ui.setupUi(this); - cameraDetected = false; - - // - // Initialize Widget handles, to prevent memory-access errors. - // - _keyboard_shortcuts = 0; - _curve_config = 0; - - tracker = 0; - - setupFaceTrackNoIR(); - - //Q_INIT_RESOURCE(PoseWidget); - - ui.lblX->setVisible(false); - ui.lblY->setVisible(false); - ui.lblZ->setVisible(false); - ui.lblRotX->setVisible(false); - ui.lblRotY->setVisible(false); - ui.lblRotZ->setVisible(false); - - ui.lcdNumOutputPosX->setVisible(false); - ui.lcdNumOutputPosY->setVisible(false); - ui.lcdNumOutputPosZ->setVisible(false); - ui.lcdNumOutputRotX->setVisible(false); - ui.lcdNumOutputRotY->setVisible(false); - ui.lcdNumOutputRotZ->setVisible(false); -} - -/** sets up all objects and connections to buttons */ -void FaceTrackNoIR::setupFaceTrackNoIR() { - // if we simply place a global variable with THeadPoseData, - // it gets initialized and pulls in QSettings before - // main() starts. program can and will crash. - - ui.headPoseWidget->show(); - ui.video_frame->hide(); - - // menu objects will be connected with the functions in FaceTrackNoIR class - connect(ui.btnLoad, SIGNAL(clicked()), this, SLOT(open())); - connect(ui.btnSave, SIGNAL(clicked()), this, SLOT(save())); - connect(ui.btnSaveAs, SIGNAL(clicked()), this, SLOT(saveAs())); - - connect(ui.btnEditCurves, SIGNAL(clicked()), this, SLOT(showCurveConfiguration())); - connect(ui.btnShortcuts, SIGNAL(clicked()), this, SLOT(showKeyboardShortcuts())); - connect(ui.btnShowEngineControls, SIGNAL(clicked()), this, SLOT(showTrackerSettings())); - connect(ui.btnShowSecondTrackerSettings, SIGNAL(clicked()), this, SLOT(showSecondTrackerSettings())); - connect(ui.btnShowServerControls, SIGNAL(clicked()), this, SLOT(showServerControls())); - connect(ui.btnShowFilterControls, SIGNAL(clicked()), this, SLOT(showFilterControls())); - - // Connect checkboxes - connect(ui.chkInvertYaw, SIGNAL(stateChanged(int)), this, SLOT(setInvertYaw(int))); - connect(ui.chkInvertRoll, SIGNAL(stateChanged(int)), this, SLOT(setInvertRoll(int))); - connect(ui.chkInvertPitch, SIGNAL(stateChanged(int)), this, SLOT(setInvertPitch(int))); - connect(ui.chkInvertX, SIGNAL(stateChanged(int)), this, SLOT(setInvertX(int))); - connect(ui.chkInvertY, SIGNAL(stateChanged(int)), this, SLOT(setInvertY(int))); - connect(ui.chkInvertZ, SIGNAL(stateChanged(int)), this, SLOT(setInvertZ(int))); - - // button methods connect with methods in this class - connect(ui.btnStartTracker, SIGNAL(clicked()), this, SLOT(startTracker())); - connect(ui.btnStopTracker, SIGNAL(clicked()), this, SLOT(stopTracker())); - - //read the camera-name, using DirectShow - GetCameraNameDX(); - - //Create the system-tray and connect the events for that. - createIconGroupBox(); - - //Load the tracker-settings, from the INI-file - loadSettings(); - - connect(ui.iconcomboProtocol, SIGNAL(currentIndexChanged(int)), this, SLOT(protocolSelected(int))); - connect(ui.iconcomboProfile, SIGNAL(currentIndexChanged(int)), this, SLOT(profileSelected(int))); - connect(ui.iconcomboTrackerSource, SIGNAL(currentIndexChanged(int)), this, SLOT(trackingSourceSelected(int))); - connect(ui.iconcomboFilter, SIGNAL(currentIndexChanged(int)), this, SLOT(filterSelected(int))); - - //Setup the timer for showing the headpose. - connect(&timUpdateHeadPose, SIGNAL(timeout()), this, SLOT(showHeadPose())); - settingsDirty = false; -} - -/** destructor stops the engine and quits the faceapi **/ -FaceTrackNoIR::~FaceTrackNoIR() { - - // - // Stop the tracker, by simulating a button-push - // - stopTracker(); - save(); -} - -// -// Update the Settings, after a value has changed. This way, the Tracker does not have to re-start. -// -void FaceTrackNoIR::updateSettings() { - if ( tracker != NULL ) { - tracker->loadSettings(); - } -} - -// -// Get a pointer to the video-widget, to use in the DLL -// -QFrame *FaceTrackNoIR::get_video_widget() { - return ui.video_frame; -} - -/** read the name of the first video-capturing device at start up **/ -/** FaceAPI can only use this first one... **/ -void FaceTrackNoIR::GetCameraNameDX() { -#if defined(_WIN32) - ui.cameraName->setText("No video-capturing device was found in your system: check if it's connected!"); - - // Create the System Device Enumerator. - HRESULT hr; - ICreateDevEnum *pSysDevEnum = NULL; - hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER, IID_ICreateDevEnum, (void **)&pSysDevEnum); - if (FAILED(hr)) - { - qDebug() << "GetWDM says: CoCreateInstance Failed!"; - return; - } - - qDebug() << "GetWDM says: CoCreateInstance succeeded!"; - - // Obtain a class enumerator for the video compressor category. - IEnumMoniker *pEnumCat = NULL; - hr = pSysDevEnum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory, &pEnumCat, 0); - - if (hr == S_OK) { - qDebug() << "GetWDM says: CreateClassEnumerator succeeded!"; - - // Enumerate the monikers. - IMoniker *pMoniker = NULL; - ULONG cFetched; - if (pEnumCat->Next(1, &pMoniker, &cFetched) == S_OK) { - IPropertyBag *pPropBag; - hr = pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void **)&pPropBag); - if (SUCCEEDED(hr)) { - // To retrieve the filter's friendly name, do the following: - VARIANT varName; - VariantInit(&varName); - hr = pPropBag->Read(L"FriendlyName", &varName, 0); - if (SUCCEEDED(hr)) - { - // Display the name in your UI somehow. - QString str((QChar*)varName.bstrVal, wcslen(varName.bstrVal)); - qDebug() << "GetWDM says: Moniker found:" << str; - ui.cameraName->setText(str); - } - VariantClear(&varName); - - ////// To create an instance of the filter, do the following: - ////IBaseFilter *pFilter; - ////hr = pMoniker->BindToObject(NULL, NULL, IID_IBaseFilter, - //// (void**)&pFilter); - // Now add the filter to the graph. - //Remember to release pFilter later. - pPropBag->Release(); - } - pMoniker->Release(); - } - pEnumCat->Release(); - } - pSysDevEnum->Release(); -#endif -} - -// -// Open an INI-file with the QFileDialog -// If succesfull, the settings in it will be read -// -void FaceTrackNoIR::open() { - QFileDialog dialog(this); - dialog.setFileMode(QFileDialog::ExistingFile); - - QString fileName = dialog.getOpenFileName( - this, - tr("Select one FTNoir settings file"), - QCoreApplication::applicationDirPath() + "/Settings/", - tr("Settings file (*.ini);;All Files (*)"), - NULL); - - // - // If a file was selected, save it's name and read it's contents. - // - if (! fileName.isEmpty() ) { - QSettings settings("opentrack"); // Registry settings (in HK_USER) - settings.setValue ("SettingsFile", QFileInfo(fileName).absoluteFilePath()); - loadSettings(); - } -} - -// -// Save the current Settings to the currently 'active' INI-file. -// -void FaceTrackNoIR::save() { - - QSettings settings("opentrack"); // 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) - - iniFile.beginGroup ( "Tracking" ); - iniFile.setValue ( "invertYaw", ui.chkInvertYaw->isChecked() ); - iniFile.setValue ( "invertPitch", ui.chkInvertPitch->isChecked() ); - iniFile.setValue ( "invertRoll", ui.chkInvertRoll->isChecked() ); - iniFile.setValue ( "invertX", ui.chkInvertX->isChecked() ); - iniFile.setValue ( "invertY", ui.chkInvertY->isChecked() ); - iniFile.setValue ( "invertZ", ui.chkInvertZ->isChecked() ); - iniFile.endGroup (); - - iniFile.beginGroup ( "GameProtocol" ); - { - DynamicLibrary* proto = dlopen_protocols.value( ui.iconcomboProtocol->currentIndex(), (DynamicLibrary*) NULL); - iniFile.setValue ( "DLL", proto == NULL ? "" : proto->filename); - } - iniFile.endGroup (); - - iniFile.beginGroup ( "TrackerSource" ); - { - DynamicLibrary* tracker = dlopen_trackers.value( ui.iconcomboTrackerSource->currentIndex(), (DynamicLibrary*) NULL); - iniFile.setValue ( "DLL", tracker == NULL ? "" : tracker->filename); - } - { - DynamicLibrary* tracker = dlopen_trackers.value( ui.cbxSecondTrackerSource->currentIndex() - 1, (DynamicLibrary*) NULL); - iniFile.setValue ( "2ndDLL", tracker == NULL ? "" : tracker->filename); - } - iniFile.endGroup (); - - // - // Save the name of the filter in the INI-file. - // - iniFile.beginGroup ( "Filter" ); - { - DynamicLibrary* filter = dlopen_filters.value( ui.iconcomboFilter->currentIndex(), (DynamicLibrary*) NULL); - iniFile.setValue ( "DLL", filter == NULL ? "" : filter->filename); - } - iniFile.endGroup (); - - settingsDirty = false; -} - -// -// Get the new name of the INI-file and save the settings to it. -// -// The user may choose to overwrite an existing file. This will be deleted, before copying the current file to it. -// -void FaceTrackNoIR::saveAs() -{ - // - // Get the current filename of the INI-file. - // - QSettings settings("opentrack"); // Registry settings (in HK_USER) - QString oldFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); - - // - // Get the new filename of the INI-file. - // - QString fileName = QFileDialog::getSaveFileName(this, tr("Save file"), - oldFile, -// QCoreApplication::applicationDirPath() + "/Settings", - tr("Settings file (*.ini);;All Files (*)")); - if (!fileName.isEmpty()) { - - // - // Remove the file, if it already exists. - // - QFileInfo newFileInfo ( fileName ); - if ((newFileInfo.exists()) && (oldFile != fileName)) { - QFile newFileFile ( fileName ); - newFileFile.remove(); - } - - // - // Copy the current INI-file to the new name. - // - QFileInfo oldFileInfo ( oldFile ); - if (oldFileInfo.exists()) { - QFile oldFileFile ( oldFile ); - oldFileFile.copy( fileName ); - } - - // - // Write the new name to the Registry and save the other INI-values. - // - settings.setValue ("SettingsFile", fileName); - save(); - - // - // Reload the settings, to get the GUI right again... - // - loadSettings(); - } -} - -// -// Load the current Settings from the currently 'active' INI-file. -// -void FaceTrackNoIR::loadSettings() { - looping = true; - qDebug() << "loadSettings says: Starting "; - QSettings settings("opentrack"); // Registry settings (in HK_USER) - - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); - qDebug() << "Config file now" << currentFile; - QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) - - // - // Put the filename in the window-title. - // - QFileInfo pathInfo ( currentFile ); - setWindowTitle ( "opentrack (1.8 alpha) - " + pathInfo.fileName() ); - - // - // Get a List of all the INI-files in the (currently active) Settings-folder. - // - QDir settingsDir( pathInfo.dir() ); - QStringList filters; - filters << "*.ini"; - iniFileList.clear(); - iniFileList = settingsDir.entryList( filters, QDir::Files, QDir::Name ); - - // - // Add strings to the Listbox. - // - ui.iconcomboProfile->clear(); - for ( int i = 0; i < iniFileList.size(); i++) { - ui.iconcomboProfile->addItem(QIcon(":/images/settings16.png"), iniFileList.at(i)); - if (iniFileList.at(i) == pathInfo.fileName()) { - ui.iconcomboProfile->setItemIcon(i, QIcon(":/images/settingsopen16.png")); - ui.iconcomboProfile->setCurrentIndex( i ); - } - } - - qDebug() << "loadSettings says: iniFile = " << currentFile; - - iniFile.beginGroup ( "Tracking" ); - ui.chkInvertYaw->setChecked (iniFile.value ( "invertYaw", 0 ).toBool()); - ui.chkInvertPitch->setChecked (iniFile.value ( "invertPitch", 0 ).toBool()); - ui.chkInvertRoll->setChecked (iniFile.value ( "invertRoll", 0 ).toBool()); - ui.chkInvertX->setChecked (iniFile.value ( "invertX", 0 ).toBool()); - ui.chkInvertY->setChecked (iniFile.value ( "invertY", 0 ).toBool()); - ui.chkInvertZ->setChecked (iniFile.value ( "invertZ", 0 ).toBool()); - iniFile.endGroup (); - - // Read the currently selected Protocol from the INI-file. - // If the setting "DLL" isn't found (pre-1.7 version of INI), then the setting 'Selection' is evaluated. - // - iniFile.beginGroup ( "GameProtocol" ); - QString selectedProtocolName = iniFile.value ( "DLL", "" ).toString(); - iniFile.endGroup (); - - // - // Find the Index of the DLL and set the selection. - // - for ( int i = 0; i < dlopen_protocols.size(); i++) { - if (dlopen_protocols.at(i)->filename.compare( selectedProtocolName, Qt::CaseInsensitive ) == 0) { - ui.iconcomboProtocol->setCurrentIndex( i ); - break; - } - } - - // - // Read the currently selected Tracker from the INI-file. - // If the setting "DLL" isn't found (pre-1.7 version), then the setting 'Selection' is evaluated. - // - iniFile.beginGroup ( "TrackerSource" ); - QString selectedTrackerName = iniFile.value ( "DLL", "" ).toString(); - qDebug() << "loadSettings says: selectedTrackerName = " << selectedTrackerName; - QString secondTrackerName = iniFile.value ( "2ndDLL", "None" ).toString(); - qDebug() << "loadSettings says: secondTrackerName = " << secondTrackerName; - iniFile.endGroup (); - - for ( int i = 0; i < dlopen_trackers.size(); i++) { - DynamicLibrary* foo = dlopen_trackers.at(i); - if (foo && foo->filename.compare( selectedTrackerName, Qt::CaseInsensitive ) == 0) { - ui.iconcomboTrackerSource->setCurrentIndex( i ); - } - if (foo && foo->filename.compare( secondTrackerName, Qt::CaseInsensitive ) == 0) { - ui.cbxSecondTrackerSource->setCurrentIndex( i + 1 ); - } - } - - // - // Read the currently selected Filter from the INI-file. - // - iniFile.beginGroup ( "Filter" ); - QString selectedFilterName = iniFile.value ( "DLL", "" ).toString(); - qDebug() << "createIconGroupBox says: selectedFilterName = " << selectedFilterName; - iniFile.endGroup (); - - // - // Find the Index of the DLL and set the selection. - // - for ( int i = 0; i < dlopen_filters.size(); i++) { - DynamicLibrary* foo = dlopen_filters.at(i); - if (foo && foo->filename.compare( selectedFilterName, Qt::CaseInsensitive ) == 0) { - ui.iconcomboFilter->setCurrentIndex( i ); - break; - } - } - - settingsDirty = false; - looping = false; -} - -/** start tracking the face **/ -void FaceTrackNoIR::startTracker( ) { - bindKeyboardShortcuts(); - - // - // Disable buttons - // - ui.iconcomboProfile->setEnabled ( false ); - ui.btnLoad->setEnabled ( false ); - ui.btnSave->setEnabled ( false ); - ui.btnSaveAs->setEnabled ( false ); - ui.btnShowFilterControls->setEnabled ( true ); - - // - // Create the Tracker and setup - // - - if (Libraries) - delete Libraries; - Libraries = new SelectedLibraries(this); - - if (!Libraries->correct) - { - QMessageBox::warning(this, "Something went wrong", "Tracking can't be initialized, probably protocol prerequisites missing", QMessageBox::Ok, QMessageBox::NoButton); - stopTracker(); - return; - } - -#if defined(_WIN32) || defined(__WIN32) - keybindingWorker = new KeybindingWorker(*this, keyCenter); - keybindingWorker->start(); -#endif - - if (tracker) { - tracker->wait(); - delete tracker; - } - - QSettings settings("opentrack"); // 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) - - for (int i = 0; i < 6; i++) - { - axis(i).curve.loadSettings(iniFile); - axis(i).curveAlt.loadSettings(iniFile); - } - - static const char* names[] = { - "tx_alt", - "ty_alt", - "tz_alt", - "rx_alt", - "ry_alt", - "rz_alt", - }; - - static const char* invert_names[] = { - "invertX", - "invertY", - "invertZ", - "invertYaw", - "invertPitch", - "invertRoll" - }; - - iniFile.beginGroup("Tracking"); - - for (int i = 0; i < 6; i++) { - axis(i).altp = iniFile.value(names[i], false).toBool(); - axis(i).invert = iniFile.value(invert_names[i], false).toBool() ? 1 : -1; - } - - iniFile.endGroup(); - - tracker = new Tracker ( this ); - - // - // Setup the Tracker and send the settings. - // This is necessary, because the events are only triggered 'on change' - // - tracker->setInvertAxis(Yaw, ui.chkInvertYaw->isChecked() ); - tracker->setInvertAxis(Pitch, ui.chkInvertPitch->isChecked() ); - tracker->setInvertAxis(Roll, ui.chkInvertRoll->isChecked() ); - tracker->setInvertAxis(TX, ui.chkInvertX->isChecked() ); - tracker->setInvertAxis(TY, ui.chkInvertY->isChecked() ); - tracker->setInvertAxis(TZ, ui.chkInvertZ->isChecked() ); - - // - // 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(); - - // - ui.btnStartTracker->setEnabled ( false ); - ui.btnStopTracker->setEnabled ( true ); - - // Enable/disable Protocol-server Settings - ui.iconcomboTrackerSource->setEnabled ( false ); - ui.cbxSecondTrackerSource->setEnabled ( false ); - ui.iconcomboProtocol->setEnabled ( false ); - ui.btnShowServerControls->setEnabled ( false ); - ui.iconcomboFilter->setEnabled ( false ); - - // - // Update the camera-name, FaceAPI can only use the 1st one found! - // - GetCameraNameDX(); - - // - // Start the timer to update the head-pose (digits and 'man in black') - // - timUpdateHeadPose.start(40); - - ui.lblX->setVisible(true); - ui.lblY->setVisible(true); - ui.lblZ->setVisible(true); - ui.lblRotX->setVisible(true); - ui.lblRotY->setVisible(true); - ui.lblRotZ->setVisible(true); - - ui.lcdNumOutputPosX->setVisible(true); - ui.lcdNumOutputPosY->setVisible(true); - ui.lcdNumOutputPosZ->setVisible(true); - ui.lcdNumOutputRotX->setVisible(true); - ui.lcdNumOutputRotY->setVisible(true); - ui.lcdNumOutputRotZ->setVisible(true); -} - -/** stop tracking the face **/ -void FaceTrackNoIR::stopTracker( ) { - ui.game_name->setText("Not connected"); -#if defined(_WIN32) || defined(__WIN32) - if (keybindingWorker) - { - keybindingWorker->should_quit = true; - keybindingWorker->wait(); - delete keybindingWorker; - keybindingWorker = NULL; - } -#endif - // - // Stop displaying the head-pose. - // - timUpdateHeadPose.stop(); - ui.pose_display->rotateBy(0, 0, 0); - - ui.lblX->setVisible(false); - ui.lblY->setVisible(false); - ui.lblZ->setVisible(false); - ui.lblRotX->setVisible(false); - ui.lblRotY->setVisible(false); - ui.lblRotZ->setVisible(false); - - ui.lcdNumOutputPosX->setVisible(false); - ui.lcdNumOutputPosY->setVisible(false); - ui.lcdNumOutputPosZ->setVisible(false); - ui.lcdNumOutputRotX->setVisible(false); - ui.lcdNumOutputRotY->setVisible(false); - ui.lcdNumOutputRotZ->setVisible(false); - - // - // UnRegister the Tracker instance with the Tracker Dialog (if open) - // - if (pTrackerDialog) { - pTrackerDialog->unRegisterTracker(); - } - if (pProtocolDialog) { - pProtocolDialog->unRegisterProtocol(); - } - if (pFilterDialog) - pFilterDialog->unregisterFilter(); - - // - // Delete the tracker (after stopping things and all). - // - if ( tracker ) { - qDebug() << "Done with tracking"; - tracker->should_quit = true; - tracker->wait(); - - qDebug() << "stopTracker says: Deleting tracker!"; - delete tracker; - qDebug() << "stopTracker says: Tracker deleted!"; - tracker = 0; - if (Libraries) { - delete Libraries; - Libraries = NULL; - } - } - ui.btnStartTracker->setEnabled ( true ); - ui.btnStopTracker->setEnabled ( false ); -// ui.btnShowEngineControls->setEnabled ( false ); - ui.iconcomboProtocol->setEnabled ( true ); - ui.iconcomboTrackerSource->setEnabled ( true ); - ui.cbxSecondTrackerSource->setEnabled ( true ); - ui.iconcomboFilter->setEnabled ( true ); - - // Enable/disable Protocol-server Settings - ui.btnShowServerControls->setEnabled ( true ); - ui.video_frame->hide(); - - // - ui.iconcomboProfile->setEnabled ( true ); - ui.btnLoad->setEnabled ( true ); - ui.btnSave->setEnabled ( true ); - ui.btnSaveAs->setEnabled ( true ); - ui.btnShowFilterControls->setEnabled ( true ); -} - -/** set the invert from the checkbox **/ -void FaceTrackNoIR::setInvertAxis(Axis axis, int invert ) { - if (tracker) - tracker->setInvertAxis (axis, (invert != 0)?true:false ); - settingsDirty = true; -} - -/** Show the headpose in the widget (triggered by timer) **/ -void FaceTrackNoIR::showHeadPose() { - double newdata[6]; - - ui.lblX->setVisible(true); - ui.lblY->setVisible(true); - ui.lblZ->setVisible(true); - ui.lblRotX->setVisible(true); - ui.lblRotY->setVisible(true); - ui.lblRotZ->setVisible(true); - - ui.lcdNumOutputPosX->setVisible(true); - ui.lcdNumOutputPosY->setVisible(true); - ui.lcdNumOutputPosZ->setVisible(true); - ui.lcdNumOutputRotX->setVisible(true); - ui.lcdNumOutputRotY->setVisible(true); - ui.lcdNumOutputRotZ->setVisible(true); - - // - // Get the pose and also display it. - // Updating the pose from within the Tracker-class caused crashes... - // - tracker->getHeadPose(newdata); - ui.lcdNumX->display(QString("%1").arg(newdata[TX], 0, 'f', 1)); - ui.lcdNumY->display(QString("%1").arg(newdata[TY], 0, 'f', 1)); - ui.lcdNumZ->display(QString("%1").arg(newdata[TZ], 0, 'f', 1)); - - - ui.lcdNumRotX->display(QString("%1").arg(newdata[Yaw], 0, 'f', 1)); - ui.lcdNumRotY->display(QString("%1").arg(newdata[Pitch], 0, 'f', 1)); - ui.lcdNumRotZ->display(QString("%1").arg(newdata[Roll], 0, 'f', 1)); - - // - // Get the output-pose and also display it. - // - tracker->getOutputHeadPose(newdata); - - ui.pose_display->rotateBy(newdata[Yaw], newdata[Roll], newdata[Pitch]); - - ui.lcdNumOutputPosX->display(QString("%1").arg(newdata[TX], 0, 'f', 1)); - ui.lcdNumOutputPosY->display(QString("%1").arg(newdata[TY], 0, 'f', 1)); - ui.lcdNumOutputPosZ->display(QString("%1").arg(newdata[TZ], 0, 'f', 1)); - - - ui.lcdNumOutputRotX->display(QString("%1").arg(newdata[Yaw], 0, 'f', 1)); - ui.lcdNumOutputRotY->display(QString("%1").arg(newdata[Pitch], 0, 'f', 1)); - ui.lcdNumOutputRotZ->display(QString("%1").arg(newdata[Roll], 0, 'f', 1)); - - // - // Update the curves in the curve-configurator. This shows the ball with the red lines. - // - if (_curve_config) { - _curve_config->update(); - } - if (Libraries->pProtocol) - { - QString name = Libraries->pProtocol->getGameName(); - ui.game_name->setText(name); - } -} - -/** toggles Video Widget **/ -void FaceTrackNoIR::showVideoWidget() { - if(ui.video_frame->isHidden()) - ui.video_frame->show(); - else - ui.video_frame->hide(); -} - -/** toggles Video Widget **/ -void FaceTrackNoIR::showHeadPoseWidget() { - if(ui.headPoseWidget->isHidden()) - ui.headPoseWidget->show(); - else - ui.headPoseWidget->hide(); -} - -/** toggles Engine Controls Dialog **/ -void FaceTrackNoIR::showTrackerSettings() { - if (pTrackerDialog) { - delete pTrackerDialog; - pTrackerDialog = NULL; - } - - DynamicLibrary* lib = dlopen_trackers.value(ui.iconcomboTrackerSource->currentIndex(), (DynamicLibrary*) NULL); - - if (lib) { - pTrackerDialog = (ITrackerDialog*) lib->Dialog(); - if (pTrackerDialog) { - if (Libraries && Libraries->pTracker) - pTrackerDialog->registerTracker(Libraries->pTracker); - pTrackerDialog->Initialize(this); - } - } -} - -// Show the Settings dialog for the secondary Tracker -void FaceTrackNoIR::showSecondTrackerSettings() { - if (pSecondTrackerDialog) { - delete pSecondTrackerDialog; - pSecondTrackerDialog = NULL; - } - - DynamicLibrary* lib = dlopen_trackers.value(ui.cbxSecondTrackerSource->currentIndex() - 1, (DynamicLibrary*) NULL); - - if (lib) { - pSecondTrackerDialog = (ITrackerDialog*) lib->Dialog(); - if (pSecondTrackerDialog) { - if (Libraries && Libraries->pSecondTracker) - pSecondTrackerDialog->registerTracker(Libraries->pSecondTracker); - pSecondTrackerDialog->Initialize(this); - } - } -} - -/** toggles Server Controls Dialog **/ -void FaceTrackNoIR::showServerControls() { - if (pProtocolDialog) { - delete pProtocolDialog; - pProtocolDialog = NULL; - } - - DynamicLibrary* lib = dlopen_protocols.value(ui.iconcomboProtocol->currentIndex(), (DynamicLibrary*) NULL); - - if (lib && lib->Dialog) { - pProtocolDialog = (IProtocolDialog*) lib->Dialog(); - if (pProtocolDialog) { - pProtocolDialog->Initialize(this); - } - } -} - -/** toggles Filter Controls Dialog **/ -void FaceTrackNoIR::showFilterControls() { - if (pFilterDialog) { - delete pFilterDialog; - pFilterDialog = NULL; - } - - DynamicLibrary* lib = dlopen_filters.value(ui.iconcomboFilter->currentIndex(), (DynamicLibrary*) NULL); - - if (lib && lib->Dialog) { - pFilterDialog = (IFilterDialog*) lib->Dialog(); - if (pFilterDialog) { - pFilterDialog->Initialize(this); - if (Libraries && Libraries->pFilter) - pFilterDialog->registerFilter(Libraries->pFilter); - } - } -} -/** toggles Keyboard Shortcut Dialog **/ -void FaceTrackNoIR::showKeyboardShortcuts() { - - // Create if new - if (!_keyboard_shortcuts) - { - _keyboard_shortcuts = new KeyboardShortcutDialog( this, this, Qt::Dialog ); - } - - // Show if already created - if (_keyboard_shortcuts) { - _keyboard_shortcuts->show(); - _keyboard_shortcuts->raise(); - } -} - -/** toggles Curve Configuration Dialog **/ -void FaceTrackNoIR::showCurveConfiguration() { - - // Create if new - if (!_curve_config) - { - _curve_config = new CurveConfigurationDialog( this, this, Qt::Dialog ); - } - - // Show if already created - if (_curve_config) { - _curve_config->show(); - _curve_config->raise(); - } -} - -/** exit application **/ -void FaceTrackNoIR::exit() { - QCoreApplication::exit(0); -} - -static bool get_metadata(DynamicLibrary* lib, QString& longName, QIcon& icon) -{ - Metadata* meta; - if (!lib->Metadata || ((meta = lib->Metadata()), !meta)) - { - delete lib; - return false; - } - meta->getFullName(&longName); - meta->getIcon(&icon); - delete meta; - return true; -} - -static void fill_combobox(const QString& filter, QList& list, QComboBox* cbx, QComboBox* cbx2) -{ - QDir settingsDir( QCoreApplication::applicationDirPath() ); - QStringList filenames = settingsDir.entryList( QStringList() << (LIB_PREFIX + filter + SONAME), QDir::Files, QDir::Name ); - for ( int i = 0; i < filenames.size(); i++) { - QIcon icon; - QString longName; - QString str = filenames.at(i); - DynamicLibrary* lib = new DynamicLibrary(str); - qDebug() << "Loading" << str; - std::cout.flush(); - if (!get_metadata(lib, longName, icon)) - { - delete lib; - continue; - } - list.push_back(lib); - cbx->addItem(icon, longName); - if (cbx2) - cbx2->addItem(icon, longName); - } -} - -// -// Setup the icons for the comboBoxes -// -void FaceTrackNoIR::createIconGroupBox() -{ - ui.cbxSecondTrackerSource->addItem(QIcon(), "None"); - dlopen_filters.push_back((DynamicLibrary*) NULL); - ui.iconcomboFilter->addItem(QIcon(), "None"); - - fill_combobox("opentrack-proto-*.", dlopen_protocols, ui.iconcomboProtocol, NULL); - fill_combobox("opentrack-tracker-*.", dlopen_trackers, ui.iconcomboTrackerSource, ui.cbxSecondTrackerSource); - fill_combobox("opentrack-filter-*.", dlopen_filters, ui.iconcomboFilter, NULL); - - connect(ui.iconcomboProtocol, SIGNAL(currentIndexChanged(int)), this, SLOT(protocolSelected(int))); - connect(ui.iconcomboTrackerSource, SIGNAL(currentIndexChanged(int)), this, SLOT(trackingSourceSelected(int))); - connect(ui.iconcomboFilter, SIGNAL(currentIndexChanged(int)), this, SLOT(filterSelected(int))); - connect(ui.cbxSecondTrackerSource, SIGNAL(currentIndexChanged(int)), this, SLOT(trackingSourceSelected(int))); -} - -// -// Handle changes of the Protocol selection -// -void FaceTrackNoIR::protocolSelected(int index) -{ - settingsDirty = true; - ui.btnShowServerControls->setEnabled ( true ); - - //setWindowIcon(QIcon(":/images/FaceTrackNoIR.png")); - //breaks with transparency -sh - //ui.btnShowServerControls->setIcon(icon);] -} - -// -// Handle changes of the Tracking Source selection -// -void FaceTrackNoIR::trackingSourceSelected(int index) -{ - settingsDirty = true; - ui.btnShowEngineControls->setEnabled ( true ); -} - -// -// Handle changes of the Profile selection -// -void FaceTrackNoIR::profileSelected(int index) -{ - if (looping) - return; - // - // Read the current INI-file setting, to get the folder in which it's located... - // - QSettings settings("opentrack"); // Registry settings (in HK_USER) - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); - QFileInfo pathInfo ( currentFile ); - - // - // Save the name of the INI-file in the Registry. - // - settings.setValue ("SettingsFile", pathInfo.absolutePath() + "/" + iniFileList.value(ui.iconcomboProfile->currentIndex(), "")); - loadSettings(); -} - -// -// Handle changes of the Filter selection -// -void FaceTrackNoIR::filterSelected(int index) -{ - settingsDirty = true; - - //QSettings settings("opentrack"); // 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) - - ui.btnShowFilterControls->setEnabled ( true ); -} - -//**************************************************************************************************// -//**************************************************************************************************// -// -// Constructor for Keyboard-shortcuts-dialog -// -KeyboardShortcutDialog::KeyboardShortcutDialog( FaceTrackNoIR *ftnoir, QWidget *parent, Qt::WindowFlags f ) : -QWidget( parent , f) -{ - ui.setupUi( this ); - - QPoint offsetpos(100, 100); - this->move(parent->pos() + offsetpos); - - mainApp = ftnoir; // Preserve a pointer to FTNoIR - - // Connect Qt signals to member-functions - connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); - connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); - - // Clear the Lists with key-descriptions and keycodes and build the Lists - // The strings will all be added to the ListBoxes for each Shortkey - // - - // Add strings to the Listboxes. - // - - for ( int i = 0; i < global_key_sequences.size(); i++) { - ui.cbxCenterKey->addItem(global_key_sequences.at(i)); - } - - // Load the settings from the current .INI-file - loadSettings(); -} - -// -// Destructor for server-dialog -// -KeyboardShortcutDialog::~KeyboardShortcutDialog() { - qDebug() << "~KeyboardShortcutDialog() says: started"; -} - -// -// OK clicked on server-dialog -// -void KeyboardShortcutDialog::doOK() { - save(); - this->close(); - mainApp->bindKeyboardShortcuts(); -} - -// override show event -void KeyboardShortcutDialog::showEvent ( QShowEvent * event ) { - loadSettings(); -} - -// -// Cancel clicked on server-dialog -// -void KeyboardShortcutDialog::doCancel() { - // - // Ask if changed Settings should be saved - // - if (settingsDirty) { - int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard ); - - qDebug() << "doCancel says: answer =" << ret; - - switch (ret) { - case QMessageBox::Save: - save(); - this->close(); - break; - case QMessageBox::Discard: - this->close(); - break; - case QMessageBox::Cancel: - // Cancel was clicked - break; - default: - // should never be reached - break; - } - } - else { - this->close(); - } -} - -void FaceTrackNoIR::bindKeyboardShortcuts() -{ - QSettings settings("opentrack"); // 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) - iniFile.beginGroup ( "KB_Shortcuts" ); - int idxCenter = iniFile.value("Key_index_Center", 0).toInt(); - -#if !defined(_WIN32) && !defined(__WIN32) - if (keyCenter) { - delete keyCenter; - keyCenter = NULL; - } - - if (idxCenter > 0) - { - QString seq(global_key_sequences.value(idxCenter, "")); - if (!seq.isEmpty()) - { - if (iniFile.value("Shift_Center", false).toBool()) - seq = "Shift+" + seq; - if (iniFile.value("Alt_Center", false).toBool()) - seq = "Alt+" + seq; - if (iniFile.value("Ctrl_Center", false).toBool()) - seq = "Ctrl+" + seq; - keyCenter = new QxtGlobalShortcut(QKeySequence(seq)); - connect(keyCenter, SIGNAL(activated()), this, SLOT(shortcutRecentered())); - } - } - -#else - keyCenter.keycode = 0; - keyCenter.shift = keyCenter.alt = keyCenter.ctrl = 0; - if (idxCenter > 0 && idxCenter < global_windows_key_sequences.size()) - keyCenter.keycode = global_windows_key_sequences[idxCenter]; - keyCenter.shift = iniFile.value("Shift_Center", false).toBool(); - keyCenter.alt = iniFile.value("Alt_Center", false).toBool(); - keyCenter.ctrl = iniFile.value("Ctrl_Center", false).toBool(); -#endif - iniFile.endGroup (); - - if (tracker) /* running already */ - { -#if defined(_WIN32) || defined(__WIN32) - if (keybindingWorker) - { - keybindingWorker->should_quit = true; - keybindingWorker->wait(); - delete keybindingWorker; - keybindingWorker = NULL; - } - keybindingWorker = new KeybindingWorker(*this, keyCenter); - keybindingWorker->start(); -#endif - } -} - -// -// Load the current Settings from the currently 'active' INI-file. -// -void KeyboardShortcutDialog::loadSettings() { - qDebug() << "loadSettings says: Starting "; - QSettings settings("opentrack"); // 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; - - iniFile.beginGroup ( "KB_Shortcuts" ); - - ui.chkCenterShift->setChecked (iniFile.value ( "Shift_Center", 0 ).toBool()); - ui.chkCenterCtrl->setChecked (iniFile.value ( "Ctrl_Center", 0 ).toBool()); - ui.chkCenterAlt->setChecked (iniFile.value ( "Alt_Center", 0 ).toBool()); - - ui.cbxCenterKey->setCurrentIndex(iniFile.value("Key_index_Center", 0).toInt()); - - iniFile.endGroup (); - - settingsDirty = false; - -} - -// -// Save the current Settings to the currently 'active' INI-file. -// -void KeyboardShortcutDialog::save() { - - qDebug() << "save() says: started"; - - QSettings settings("opentrack"); // 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) - - iniFile.beginGroup ( "KB_Shortcuts" ); - iniFile.setValue ( "Key_index_Center", ui.cbxCenterKey->currentIndex() ); - iniFile.setValue ( "Shift_Center", ui.chkCenterShift->isChecked() ); - iniFile.setValue ( "Ctrl_Center", ui.chkCenterCtrl->isChecked() ); - iniFile.setValue ( "Alt_Center", ui.chkCenterAlt->isChecked() ); - - iniFile.endGroup (); - - settingsDirty = false; - - // - // Send a message to the main program, to update the Settings (for the tracker) - // - mainApp->updateSettings(); -} - -//**************************************************************************************************// -//**************************************************************************************************// -// -// Constructor for Curve-configuration-dialog -// -CurveConfigurationDialog::CurveConfigurationDialog( FaceTrackNoIR *ftnoir, QWidget *parent, Qt::WindowFlags f ) : -QWidget( parent , f) -{ - ui.setupUi( this ); - - QPoint offsetpos(120, 30); - this->move(parent->pos() + offsetpos); - - mainApp = ftnoir; // Preserve a pointer to FTNoIR - - QSettings settings("opentrack"); // Registry settings (in HK_USER) - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); - - QFunctionConfigurator* configs[6] = { - ui.txconfig, - ui.tyconfig, - ui.tzconfig, - ui.rxconfig, - ui.ryconfig, - ui.rzconfig - }; - - QFunctionConfigurator* alt_configs[6] = { - ui.txconfig_alt, - ui.tyconfig_alt, - ui.tzconfig_alt, - ui.rxconfig_alt, - ui.ryconfig_alt, - ui.rzconfig_alt - }; - - QCheckBox* checkboxes[6] = { - ui.rx_altp, - ui.ry_altp, - ui.rz_altp, - ui.tx_altp, - ui.ty_altp, - ui.tz_altp - }; - - for (int i = 0; i < 6; i++) - { - configs[i]->setConfig(&mainApp->axis(i).curve, currentFile); - alt_configs[i]->setConfig(&mainApp->axis(i).curveAlt, currentFile); - connect(configs[i], SIGNAL(CurveChanged(bool)), this, SLOT(curveChanged(bool))); - connect(alt_configs[i], SIGNAL(CurveChanged(bool)), this, SLOT(curveChanged(bool))); - connect(checkboxes[i], SIGNAL(stateChanged(int)), this, SLOT(curveChanged(int))); - } - - // Connect Qt signals to member-functions - connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); - connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); - - // Load the settings from the current .INI-file - loadSettings(); -} - -// -// Destructor for server-dialog -// -CurveConfigurationDialog::~CurveConfigurationDialog() { - qDebug() << "~CurveConfigurationDialog() says: started"; -} - -// -// OK clicked on server-dialog -// -void CurveConfigurationDialog::doOK() { - save(); - this->close(); -} - -// override show event -void CurveConfigurationDialog::showEvent ( QShowEvent * event ) { - loadSettings(); -} - -// -// Cancel clicked on server-dialog -// -void CurveConfigurationDialog::doCancel() { - // - // Ask if changed Settings should be saved - // - if (settingsDirty) { - int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard ); - - qDebug() << "doCancel says: answer =" << ret; - - switch (ret) { - case QMessageBox::Save: - save(); - this->close(); - break; - case QMessageBox::Discard: - this->close(); - break; - case QMessageBox::Cancel: - // Cancel was clicked - break; - default: - // should never be reached - break; - } - } - else { - this->close(); - } -} - -// -// Load the current Settings from the currently 'active' INI-file. -// -void CurveConfigurationDialog::loadSettings() { - qDebug() << "loadSettings says: Starting "; - QSettings settings("opentrack"); // 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; - - static const char* names[] = { - "tx_alt", - "ty_alt", - "tz_alt", - "rx_alt", - "ry_alt", - "rz_alt" - }; - - iniFile.beginGroup("Tracking"); - - for (int i = 0; i < 6; i++) - mainApp->axis(i).altp = iniFile.value(names[i], false).toBool(); - - QCheckBox* widgets[] = { - ui.tx_altp, - ui.ty_altp, - ui.tz_altp, - ui.rx_altp, - ui.ry_altp, - ui.rz_altp - }; - - for (int i = 0; i < 6; i++) - widgets[i]->setChecked(mainApp->axis(i).altp); - - QDoubleSpinBox* widgets2[] = { - ui.pos_tx, - ui.pos_ty, - ui.pos_tz, - ui.pos_tx, - ui.pos_ry, - ui.pos_rz - }; - - const char* names2[] = { - "zero_tx", - "zero_ty", - "zero_tz", - "zero_rx", - "zero_ry", - "zero_rz" - }; - - for (int i = 0; i < 6; i++) - widgets2[i]->setValue(iniFile.value(names2[i], 0).toDouble()); - - iniFile.endGroup(); - - settingsDirty = false; -} - -// -// Save the current Settings to the currently 'active' INI-file. -// -void CurveConfigurationDialog::save() { - - qDebug() << "save() says: started"; - - QSettings settings("opentrack"); // Registry settings (in HK_USER) - - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); - - ui.rxconfig->saveSettings(currentFile); - ui.ryconfig->saveSettings(currentFile); - ui.rzconfig->saveSettings(currentFile); - ui.txconfig->saveSettings(currentFile); - ui.tyconfig->saveSettings(currentFile); - ui.tzconfig->saveSettings(currentFile); - - ui.txconfig_alt->saveSettings(currentFile); - ui.tyconfig_alt->saveSettings(currentFile); - ui.tzconfig_alt->saveSettings(currentFile); - ui.rxconfig_alt->saveSettings(currentFile); - ui.ryconfig_alt->saveSettings(currentFile); - ui.rzconfig_alt->saveSettings(currentFile); - - QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) - - iniFile.beginGroup("Tracking"); - - iniFile.setValue("rx_alt", ui.rx_altp->checkState() != Qt::Unchecked); - iniFile.setValue("ry_alt", ui.ry_altp->checkState() != Qt::Unchecked); - iniFile.setValue("rz_alt", ui.rz_altp->checkState() != Qt::Unchecked); - iniFile.setValue("tx_alt", ui.tx_altp->checkState() != Qt::Unchecked); - iniFile.setValue("ty_alt", ui.ty_altp->checkState() != Qt::Unchecked); - iniFile.setValue("tz_alt", ui.tz_altp->checkState() != Qt::Unchecked); - - QDoubleSpinBox* widgets2[] = { - ui.pos_tx, - ui.pos_ty, - ui.pos_tz, - ui.pos_tx, - ui.pos_ry, - ui.pos_rz - }; - - const char* names2[] = { - "zero_tx", - "zero_ty", - "zero_tz", - "zero_rx", - "zero_ry", - "zero_rz" - }; - - for (int i = 0; i < 6; i++) - iniFile.setValue(names2[i], widgets2[i]->value()); - - iniFile.endGroup(); - - settingsDirty = false; - - // - // Send a message to the main program, to update the Settings (for the tracker) - // - mainApp->updateSettings(); -} - -void FaceTrackNoIR::shortcutRecentered() -{ - if (tracker) - { -#if defined(__WIN32) || defined(_WIN32) - MessageBeep(MB_OK); -#else - QApplication::beep(); -#endif - qDebug() << "Center"; - tracker->do_center = true; - } -} +/******************************************************************************** +* FaceTrackNoIR This program is a private project of the some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2011 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +*********************************************************************************/ +#include "facetracknoir.h" +#include "tracker.h" +#include +#include + +#if defined(__WIN32) || defined(_WIN32) +# include +#endif + +#if defined(__APPLE__) +# define SONAME "dylib" +#elif defined(_WIN32) || defined(__WIN32) +# define SONAME "dll" +#else +# define SONAME "so" +#endif + +#include + +#if defined(__WIN32) || defined(_WIN32) +#undef DIRECTINPUT_VERSION +#define DIRECTINPUT_VERSION 0x0800 +#include +#include + +KeybindingWorkerDummy::~KeybindingWorkerDummy() { + if (dinkeyboard) { + dinkeyboard->Unacquire(); + dinkeyboard->Release(); + } + if (din) + din->Release(); +} + +KeybindingWorkerDummy::KeybindingWorkerDummy(FaceTrackNoIR& w, Key keyCenter) +: kCenter(keyCenter), window(w), should_quit(true), din(0), dinkeyboard(0) +{ + if (DirectInput8Create(GetModuleHandle(NULL), DIRECTINPUT_VERSION, IID_IDirectInput8, (void**)&din, NULL) != DI_OK) { + qDebug() << "setup DirectInput8 Creation failed!" << GetLastError(); + return; + } + if (din->CreateDevice(GUID_SysKeyboard, &dinkeyboard, NULL) != DI_OK) { + din->Release(); + din = 0; + qDebug() << "setup CreateDevice function failed!" << GetLastError(); + return; + } + if (dinkeyboard->SetDataFormat(&c_dfDIKeyboard) != DI_OK) { + qDebug() << "setup SetDataFormat function failed!" << GetLastError(); + dinkeyboard->Release(); + dinkeyboard = 0; + din->Release(); + din = 0; + return; + } + + if (dinkeyboard->SetCooperativeLevel(window.winId(), DISCL_NONEXCLUSIVE | DISCL_BACKGROUND) != DI_OK) { + dinkeyboard->Release(); + din->Release(); + din = 0; + dinkeyboard = 0; + qDebug() << "setup SetCooperativeLevel function failed!" << GetLastError(); + return; + } + if (dinkeyboard->Acquire() != DI_OK) + { + dinkeyboard->Release(); + din->Release(); + din = 0; + dinkeyboard = 0; + qDebug() << "setup dinkeyboard Acquire failed!" << GetLastError(); + return; + } + should_quit = false; +} + +#define PROCESS_KEY(k, s) \ + if (isKeyPressed(&k, keystate) && (!k.ever_pressed ? (k.timer.start(), k.ever_pressed = true) : k.timer.restart() > 100)) \ + window.s(); + +static bool isKeyPressed( const Key *key, const BYTE *keystate ) { + bool shift; + bool ctrl; + bool alt; + + if (keystate[key->keycode] & 0x80) { + shift = ( (keystate[DIK_LSHIFT] & 0x80) || (keystate[DIK_RSHIFT] & 0x80) ); + ctrl = ( (keystate[DIK_LCONTROL] & 0x80) || (keystate[DIK_RCONTROL] & 0x80) ); + alt = ( (keystate[DIK_LALT] & 0x80) || (keystate[DIK_RALT] & 0x80) ); + + // + // If one of the modifiers is needed and not pressed, return false. + // + if (key->shift && !shift) return false; + if (key->ctrl && !ctrl) return false; + if (key->alt && !alt) return false; + + // + // All is well! + // + return true; + } + return false; +} + +void KeybindingWorkerDummy::run() { + BYTE keystate[256]; + while (!should_quit) + { + if (dinkeyboard->GetDeviceState(256, (LPVOID)keystate) != DI_OK) { + qDebug() << "Tracker::run GetDeviceState function failed!" << GetLastError(); + Sleep(25); + continue; + } + + PROCESS_KEY(kCenter, shortcutRecentered); + + Sleep(25); + } +} +#else +#endif + +#ifdef _MSC_VER +# define LIB_PREFIX "" +#else +# define LIB_PREFIX "lib" +#endif + +// +// Setup the Main Dialog +// +FaceTrackNoIR::FaceTrackNoIR(QWidget *parent, Qt::WFlags flags) : + #if defined(__WIN32) || defined(_WIN32) + keybindingWorker(NULL), + #else + keyCenter(0), + #endif + QMainWindow(parent, flags), + pTrackerDialog(NULL), + pSecondTrackerDialog(NULL), + pProtocolDialog(NULL), + pFilterDialog(NULL), + looping(false), + timUpdateHeadPose(this) +{ + ui.setupUi(this); + cameraDetected = false; + + // + // Initialize Widget handles, to prevent memory-access errors. + // + _keyboard_shortcuts = 0; + _curve_config = 0; + + tracker = 0; + + setupFaceTrackNoIR(); + + //Q_INIT_RESOURCE(PoseWidget); + + ui.lblX->setVisible(false); + ui.lblY->setVisible(false); + ui.lblZ->setVisible(false); + ui.lblRotX->setVisible(false); + ui.lblRotY->setVisible(false); + ui.lblRotZ->setVisible(false); + + ui.lcdNumOutputPosX->setVisible(false); + ui.lcdNumOutputPosY->setVisible(false); + ui.lcdNumOutputPosZ->setVisible(false); + ui.lcdNumOutputRotX->setVisible(false); + ui.lcdNumOutputRotY->setVisible(false); + ui.lcdNumOutputRotZ->setVisible(false); +} + +/** sets up all objects and connections to buttons */ +void FaceTrackNoIR::setupFaceTrackNoIR() { + // if we simply place a global variable with THeadPoseData, + // it gets initialized and pulls in QSettings before + // main() starts. program can and will crash. + + ui.headPoseWidget->show(); + ui.video_frame->hide(); + + // menu objects will be connected with the functions in FaceTrackNoIR class + connect(ui.btnLoad, SIGNAL(clicked()), this, SLOT(open())); + connect(ui.btnSave, SIGNAL(clicked()), this, SLOT(save())); + connect(ui.btnSaveAs, SIGNAL(clicked()), this, SLOT(saveAs())); + + connect(ui.btnEditCurves, SIGNAL(clicked()), this, SLOT(showCurveConfiguration())); + connect(ui.btnShortcuts, SIGNAL(clicked()), this, SLOT(showKeyboardShortcuts())); + connect(ui.btnShowEngineControls, SIGNAL(clicked()), this, SLOT(showTrackerSettings())); + connect(ui.btnShowSecondTrackerSettings, SIGNAL(clicked()), this, SLOT(showSecondTrackerSettings())); + connect(ui.btnShowServerControls, SIGNAL(clicked()), this, SLOT(showServerControls())); + connect(ui.btnShowFilterControls, SIGNAL(clicked()), this, SLOT(showFilterControls())); + + // Connect checkboxes + connect(ui.chkInvertYaw, SIGNAL(stateChanged(int)), this, SLOT(setInvertYaw(int))); + connect(ui.chkInvertRoll, SIGNAL(stateChanged(int)), this, SLOT(setInvertRoll(int))); + connect(ui.chkInvertPitch, SIGNAL(stateChanged(int)), this, SLOT(setInvertPitch(int))); + connect(ui.chkInvertX, SIGNAL(stateChanged(int)), this, SLOT(setInvertX(int))); + connect(ui.chkInvertY, SIGNAL(stateChanged(int)), this, SLOT(setInvertY(int))); + connect(ui.chkInvertZ, SIGNAL(stateChanged(int)), this, SLOT(setInvertZ(int))); + + // button methods connect with methods in this class + connect(ui.btnStartTracker, SIGNAL(clicked()), this, SLOT(startTracker())); + connect(ui.btnStopTracker, SIGNAL(clicked()), this, SLOT(stopTracker())); + + //read the camera-name, using DirectShow + GetCameraNameDX(); + + //Create the system-tray and connect the events for that. + createIconGroupBox(); + + //Load the tracker-settings, from the INI-file + loadSettings(); + + connect(ui.iconcomboProtocol, SIGNAL(currentIndexChanged(int)), this, SLOT(protocolSelected(int))); + connect(ui.iconcomboProfile, SIGNAL(currentIndexChanged(int)), this, SLOT(profileSelected(int))); + connect(ui.iconcomboTrackerSource, SIGNAL(currentIndexChanged(int)), this, SLOT(trackingSourceSelected(int))); + connect(ui.iconcomboFilter, SIGNAL(currentIndexChanged(int)), this, SLOT(filterSelected(int))); + + //Setup the timer for showing the headpose. + connect(&timUpdateHeadPose, SIGNAL(timeout()), this, SLOT(showHeadPose())); + settingsDirty = false; +} + +/** destructor stops the engine and quits the faceapi **/ +FaceTrackNoIR::~FaceTrackNoIR() { + + // + // Stop the tracker, by simulating a button-push + // + stopTracker(); + save(); +} + +// +// Update the Settings, after a value has changed. This way, the Tracker does not have to re-start. +// +void FaceTrackNoIR::updateSettings() { + if ( tracker != NULL ) { + tracker->loadSettings(); + } +} + +// +// Get a pointer to the video-widget, to use in the DLL +// +QFrame *FaceTrackNoIR::get_video_widget() { + return ui.video_frame; +} + +/** read the name of the first video-capturing device at start up **/ +/** FaceAPI can only use this first one... **/ +void FaceTrackNoIR::GetCameraNameDX() { +#if defined(_WIN32) + ui.cameraName->setText("No video-capturing device was found in your system: check if it's connected!"); + + // Create the System Device Enumerator. + HRESULT hr; + ICreateDevEnum *pSysDevEnum = NULL; + hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER, IID_ICreateDevEnum, (void **)&pSysDevEnum); + if (FAILED(hr)) + { + qDebug() << "GetWDM says: CoCreateInstance Failed!"; + return; + } + + qDebug() << "GetWDM says: CoCreateInstance succeeded!"; + + // Obtain a class enumerator for the video compressor category. + IEnumMoniker *pEnumCat = NULL; + hr = pSysDevEnum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory, &pEnumCat, 0); + + if (hr == S_OK) { + qDebug() << "GetWDM says: CreateClassEnumerator succeeded!"; + + // Enumerate the monikers. + IMoniker *pMoniker = NULL; + ULONG cFetched; + if (pEnumCat->Next(1, &pMoniker, &cFetched) == S_OK) { + IPropertyBag *pPropBag; + hr = pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void **)&pPropBag); + if (SUCCEEDED(hr)) { + // To retrieve the filter's friendly name, do the following: + VARIANT varName; + VariantInit(&varName); + hr = pPropBag->Read(L"FriendlyName", &varName, 0); + if (SUCCEEDED(hr)) + { + // Display the name in your UI somehow. + QString str((QChar*)varName.bstrVal, wcslen(varName.bstrVal)); + qDebug() << "GetWDM says: Moniker found:" << str; + ui.cameraName->setText(str); + } + VariantClear(&varName); + + ////// To create an instance of the filter, do the following: + ////IBaseFilter *pFilter; + ////hr = pMoniker->BindToObject(NULL, NULL, IID_IBaseFilter, + //// (void**)&pFilter); + // Now add the filter to the graph. + //Remember to release pFilter later. + pPropBag->Release(); + } + pMoniker->Release(); + } + pEnumCat->Release(); + } + pSysDevEnum->Release(); +#endif +} + +// +// Open an INI-file with the QFileDialog +// If succesfull, the settings in it will be read +// +void FaceTrackNoIR::open() { + QFileDialog dialog(this); + dialog.setFileMode(QFileDialog::ExistingFile); + + QString fileName = dialog.getOpenFileName( + this, + tr("Select one FTNoir settings file"), + QCoreApplication::applicationDirPath() + "/Settings/", + tr("Settings file (*.ini);;All Files (*)"), + NULL); + + // + // If a file was selected, save it's name and read it's contents. + // + if (! fileName.isEmpty() ) { + QSettings settings("opentrack"); // Registry settings (in HK_USER) + settings.setValue ("SettingsFile", QFileInfo(fileName).absoluteFilePath()); + loadSettings(); + } +} + +// +// Save the current Settings to the currently 'active' INI-file. +// +void FaceTrackNoIR::save() { + + QSettings settings("opentrack"); // 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) + + iniFile.beginGroup ( "Tracking" ); + iniFile.setValue ( "invertYaw", ui.chkInvertYaw->isChecked() ); + iniFile.setValue ( "invertPitch", ui.chkInvertPitch->isChecked() ); + iniFile.setValue ( "invertRoll", ui.chkInvertRoll->isChecked() ); + iniFile.setValue ( "invertX", ui.chkInvertX->isChecked() ); + iniFile.setValue ( "invertY", ui.chkInvertY->isChecked() ); + iniFile.setValue ( "invertZ", ui.chkInvertZ->isChecked() ); + iniFile.endGroup (); + + iniFile.beginGroup ( "GameProtocol" ); + { + DynamicLibrary* proto = dlopen_protocols.value( ui.iconcomboProtocol->currentIndex(), (DynamicLibrary*) NULL); + iniFile.setValue ( "DLL", proto == NULL ? "" : proto->filename); + } + iniFile.endGroup (); + + iniFile.beginGroup ( "TrackerSource" ); + { + DynamicLibrary* tracker = dlopen_trackers.value( ui.iconcomboTrackerSource->currentIndex(), (DynamicLibrary*) NULL); + iniFile.setValue ( "DLL", tracker == NULL ? "" : tracker->filename); + } + { + DynamicLibrary* tracker = dlopen_trackers.value( ui.cbxSecondTrackerSource->currentIndex() - 1, (DynamicLibrary*) NULL); + iniFile.setValue ( "2ndDLL", tracker == NULL ? "" : tracker->filename); + } + iniFile.endGroup (); + + // + // Save the name of the filter in the INI-file. + // + iniFile.beginGroup ( "Filter" ); + { + DynamicLibrary* filter = dlopen_filters.value( ui.iconcomboFilter->currentIndex(), (DynamicLibrary*) NULL); + iniFile.setValue ( "DLL", filter == NULL ? "" : filter->filename); + } + iniFile.endGroup (); + + settingsDirty = false; +} + +// +// Get the new name of the INI-file and save the settings to it. +// +// The user may choose to overwrite an existing file. This will be deleted, before copying the current file to it. +// +void FaceTrackNoIR::saveAs() +{ + // + // Get the current filename of the INI-file. + // + QSettings settings("opentrack"); // Registry settings (in HK_USER) + QString oldFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + + // + // Get the new filename of the INI-file. + // + QString fileName = QFileDialog::getSaveFileName(this, tr("Save file"), + oldFile, +// QCoreApplication::applicationDirPath() + "/Settings", + tr("Settings file (*.ini);;All Files (*)")); + if (!fileName.isEmpty()) { + + // + // Remove the file, if it already exists. + // + QFileInfo newFileInfo ( fileName ); + if ((newFileInfo.exists()) && (oldFile != fileName)) { + QFile newFileFile ( fileName ); + newFileFile.remove(); + } + + // + // Copy the current INI-file to the new name. + // + QFileInfo oldFileInfo ( oldFile ); + if (oldFileInfo.exists()) { + QFile oldFileFile ( oldFile ); + oldFileFile.copy( fileName ); + } + + // + // Write the new name to the Registry and save the other INI-values. + // + settings.setValue ("SettingsFile", fileName); + save(); + + // + // Reload the settings, to get the GUI right again... + // + loadSettings(); + } +} + +// +// Load the current Settings from the currently 'active' INI-file. +// +void FaceTrackNoIR::loadSettings() { + looping = true; + qDebug() << "loadSettings says: Starting "; + QSettings settings("opentrack"); // Registry settings (in HK_USER) + + QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + qDebug() << "Config file now" << currentFile; + QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) + + // + // Put the filename in the window-title. + // + QFileInfo pathInfo ( currentFile ); + setWindowTitle ( "opentrack (1.8 alpha) - " + pathInfo.fileName() ); + + // + // Get a List of all the INI-files in the (currently active) Settings-folder. + // + QDir settingsDir( pathInfo.dir() ); + QStringList filters; + filters << "*.ini"; + iniFileList.clear(); + iniFileList = settingsDir.entryList( filters, QDir::Files, QDir::Name ); + + // + // Add strings to the Listbox. + // + ui.iconcomboProfile->clear(); + for ( int i = 0; i < iniFileList.size(); i++) { + ui.iconcomboProfile->addItem(QIcon(":/images/settings16.png"), iniFileList.at(i)); + if (iniFileList.at(i) == pathInfo.fileName()) { + ui.iconcomboProfile->setItemIcon(i, QIcon(":/images/settingsopen16.png")); + ui.iconcomboProfile->setCurrentIndex( i ); + } + } + + qDebug() << "loadSettings says: iniFile = " << currentFile; + + iniFile.beginGroup ( "Tracking" ); + ui.chkInvertYaw->setChecked (iniFile.value ( "invertYaw", 0 ).toBool()); + ui.chkInvertPitch->setChecked (iniFile.value ( "invertPitch", 0 ).toBool()); + ui.chkInvertRoll->setChecked (iniFile.value ( "invertRoll", 0 ).toBool()); + ui.chkInvertX->setChecked (iniFile.value ( "invertX", 0 ).toBool()); + ui.chkInvertY->setChecked (iniFile.value ( "invertY", 0 ).toBool()); + ui.chkInvertZ->setChecked (iniFile.value ( "invertZ", 0 ).toBool()); + iniFile.endGroup (); + + // Read the currently selected Protocol from the INI-file. + // If the setting "DLL" isn't found (pre-1.7 version of INI), then the setting 'Selection' is evaluated. + // + iniFile.beginGroup ( "GameProtocol" ); + QString selectedProtocolName = iniFile.value ( "DLL", "" ).toString(); + iniFile.endGroup (); + + // + // Find the Index of the DLL and set the selection. + // + for ( int i = 0; i < dlopen_protocols.size(); i++) { + if (dlopen_protocols.at(i)->filename.compare( selectedProtocolName, Qt::CaseInsensitive ) == 0) { + ui.iconcomboProtocol->setCurrentIndex( i ); + break; + } + } + + // + // Read the currently selected Tracker from the INI-file. + // If the setting "DLL" isn't found (pre-1.7 version), then the setting 'Selection' is evaluated. + // + iniFile.beginGroup ( "TrackerSource" ); + QString selectedTrackerName = iniFile.value ( "DLL", "" ).toString(); + qDebug() << "loadSettings says: selectedTrackerName = " << selectedTrackerName; + QString secondTrackerName = iniFile.value ( "2ndDLL", "None" ).toString(); + qDebug() << "loadSettings says: secondTrackerName = " << secondTrackerName; + iniFile.endGroup (); + + for ( int i = 0; i < dlopen_trackers.size(); i++) { + DynamicLibrary* foo = dlopen_trackers.at(i); + if (foo && foo->filename.compare( selectedTrackerName, Qt::CaseInsensitive ) == 0) { + ui.iconcomboTrackerSource->setCurrentIndex( i ); + } + if (foo && foo->filename.compare( secondTrackerName, Qt::CaseInsensitive ) == 0) { + ui.cbxSecondTrackerSource->setCurrentIndex( i + 1 ); + } + } + + // + // Read the currently selected Filter from the INI-file. + // + iniFile.beginGroup ( "Filter" ); + QString selectedFilterName = iniFile.value ( "DLL", "" ).toString(); + qDebug() << "createIconGroupBox says: selectedFilterName = " << selectedFilterName; + iniFile.endGroup (); + + // + // Find the Index of the DLL and set the selection. + // + for ( int i = 0; i < dlopen_filters.size(); i++) { + DynamicLibrary* foo = dlopen_filters.at(i); + if (foo && foo->filename.compare( selectedFilterName, Qt::CaseInsensitive ) == 0) { + ui.iconcomboFilter->setCurrentIndex( i ); + break; + } + } + + settingsDirty = false; + looping = false; +} + +/** start tracking the face **/ +void FaceTrackNoIR::startTracker( ) { + bindKeyboardShortcuts(); + + // + // Disable buttons + // + ui.iconcomboProfile->setEnabled ( false ); + ui.btnLoad->setEnabled ( false ); + ui.btnSave->setEnabled ( false ); + ui.btnSaveAs->setEnabled ( false ); + ui.btnShowFilterControls->setEnabled ( true ); + + // + // Create the Tracker and setup + // + + if (Libraries) + delete Libraries; + Libraries = new SelectedLibraries(this); + + if (!Libraries->correct) + { + QMessageBox::warning(this, "Something went wrong", "Tracking can't be initialized, probably protocol prerequisites missing", QMessageBox::Ok, QMessageBox::NoButton); + stopTracker(); + return; + } + +#if defined(_WIN32) || defined(__WIN32) + keybindingWorker = new KeybindingWorker(*this, keyCenter); + keybindingWorker->start(); +#endif + + if (tracker) { + tracker->wait(); + delete tracker; + } + + QSettings settings("opentrack"); // 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) + + for (int i = 0; i < 6; i++) + { + axis(i).curve.loadSettings(iniFile); + axis(i).curveAlt.loadSettings(iniFile); + } + + static const char* names[] = { + "tx_alt", + "ty_alt", + "tz_alt", + "rx_alt", + "ry_alt", + "rz_alt", + }; + + static const char* invert_names[] = { + "invertX", + "invertY", + "invertZ", + "invertYaw", + "invertPitch", + "invertRoll" + }; + + iniFile.beginGroup("Tracking"); + + for (int i = 0; i < 6; i++) { + axis(i).altp = iniFile.value(names[i], false).toBool(); + axis(i).invert = iniFile.value(invert_names[i], false).toBool() ? 1 : -1; + } + + iniFile.endGroup(); + + tracker = new Tracker ( this ); + + // + // Setup the Tracker and send the settings. + // This is necessary, because the events are only triggered 'on change' + // + tracker->setInvertAxis(Yaw, ui.chkInvertYaw->isChecked() ); + tracker->setInvertAxis(Pitch, ui.chkInvertPitch->isChecked() ); + tracker->setInvertAxis(Roll, ui.chkInvertRoll->isChecked() ); + tracker->setInvertAxis(TX, ui.chkInvertX->isChecked() ); + tracker->setInvertAxis(TY, ui.chkInvertY->isChecked() ); + tracker->setInvertAxis(TZ, ui.chkInvertZ->isChecked() ); + + // + // 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(); + + // + ui.btnStartTracker->setEnabled ( false ); + ui.btnStopTracker->setEnabled ( true ); + + // Enable/disable Protocol-server Settings + ui.iconcomboTrackerSource->setEnabled ( false ); + ui.cbxSecondTrackerSource->setEnabled ( false ); + ui.iconcomboProtocol->setEnabled ( false ); + ui.btnShowServerControls->setEnabled ( false ); + ui.iconcomboFilter->setEnabled ( false ); + + // + // Update the camera-name, FaceAPI can only use the 1st one found! + // + GetCameraNameDX(); + + // + // Start the timer to update the head-pose (digits and 'man in black') + // + timUpdateHeadPose.start(40); + + ui.lblX->setVisible(true); + ui.lblY->setVisible(true); + ui.lblZ->setVisible(true); + ui.lblRotX->setVisible(true); + ui.lblRotY->setVisible(true); + ui.lblRotZ->setVisible(true); + + ui.lcdNumOutputPosX->setVisible(true); + ui.lcdNumOutputPosY->setVisible(true); + ui.lcdNumOutputPosZ->setVisible(true); + ui.lcdNumOutputRotX->setVisible(true); + ui.lcdNumOutputRotY->setVisible(true); + ui.lcdNumOutputRotZ->setVisible(true); +} + +/** stop tracking the face **/ +void FaceTrackNoIR::stopTracker( ) { + ui.game_name->setText("Not connected"); +#if defined(_WIN32) || defined(__WIN32) + if (keybindingWorker) + { + keybindingWorker->should_quit = true; + keybindingWorker->wait(); + delete keybindingWorker; + keybindingWorker = NULL; + } +#endif + // + // Stop displaying the head-pose. + // + timUpdateHeadPose.stop(); + ui.pose_display->rotateBy(0, 0, 0); + + ui.lblX->setVisible(false); + ui.lblY->setVisible(false); + ui.lblZ->setVisible(false); + ui.lblRotX->setVisible(false); + ui.lblRotY->setVisible(false); + ui.lblRotZ->setVisible(false); + + ui.lcdNumOutputPosX->setVisible(false); + ui.lcdNumOutputPosY->setVisible(false); + ui.lcdNumOutputPosZ->setVisible(false); + ui.lcdNumOutputRotX->setVisible(false); + ui.lcdNumOutputRotY->setVisible(false); + ui.lcdNumOutputRotZ->setVisible(false); + + // + // UnRegister the Tracker instance with the Tracker Dialog (if open) + // + if (pTrackerDialog) { + pTrackerDialog->unRegisterTracker(); + } + if (pProtocolDialog) { + pProtocolDialog->unRegisterProtocol(); + } + if (pFilterDialog) + pFilterDialog->unregisterFilter(); + + // + // Delete the tracker (after stopping things and all). + // + if ( tracker ) { + qDebug() << "Done with tracking"; + tracker->should_quit = true; + tracker->wait(); + + qDebug() << "stopTracker says: Deleting tracker!"; + delete tracker; + qDebug() << "stopTracker says: Tracker deleted!"; + tracker = 0; + if (Libraries) { + delete Libraries; + Libraries = NULL; + } + } + ui.btnStartTracker->setEnabled ( true ); + ui.btnStopTracker->setEnabled ( false ); +// ui.btnShowEngineControls->setEnabled ( false ); + ui.iconcomboProtocol->setEnabled ( true ); + ui.iconcomboTrackerSource->setEnabled ( true ); + ui.cbxSecondTrackerSource->setEnabled ( true ); + ui.iconcomboFilter->setEnabled ( true ); + + // Enable/disable Protocol-server Settings + ui.btnShowServerControls->setEnabled ( true ); + ui.video_frame->hide(); + + // + ui.iconcomboProfile->setEnabled ( true ); + ui.btnLoad->setEnabled ( true ); + ui.btnSave->setEnabled ( true ); + ui.btnSaveAs->setEnabled ( true ); + ui.btnShowFilterControls->setEnabled ( true ); +} + +/** set the invert from the checkbox **/ +void FaceTrackNoIR::setInvertAxis(Axis axis, int invert ) { + if (tracker) + tracker->setInvertAxis (axis, (invert != 0)?true:false ); + settingsDirty = true; +} + +/** Show the headpose in the widget (triggered by timer) **/ +void FaceTrackNoIR::showHeadPose() { + double newdata[6]; + + ui.lblX->setVisible(true); + ui.lblY->setVisible(true); + ui.lblZ->setVisible(true); + ui.lblRotX->setVisible(true); + ui.lblRotY->setVisible(true); + ui.lblRotZ->setVisible(true); + + ui.lcdNumOutputPosX->setVisible(true); + ui.lcdNumOutputPosY->setVisible(true); + ui.lcdNumOutputPosZ->setVisible(true); + ui.lcdNumOutputRotX->setVisible(true); + ui.lcdNumOutputRotY->setVisible(true); + ui.lcdNumOutputRotZ->setVisible(true); + + // + // Get the pose and also display it. + // Updating the pose from within the Tracker-class caused crashes... + // + tracker->getHeadPose(newdata); + ui.lcdNumX->display(QString("%1").arg(newdata[TX], 0, 'f', 1)); + ui.lcdNumY->display(QString("%1").arg(newdata[TY], 0, 'f', 1)); + ui.lcdNumZ->display(QString("%1").arg(newdata[TZ], 0, 'f', 1)); + + + ui.lcdNumRotX->display(QString("%1").arg(newdata[Yaw], 0, 'f', 1)); + ui.lcdNumRotY->display(QString("%1").arg(newdata[Pitch], 0, 'f', 1)); + ui.lcdNumRotZ->display(QString("%1").arg(newdata[Roll], 0, 'f', 1)); + + // + // Get the output-pose and also display it. + // + tracker->getOutputHeadPose(newdata); + + ui.pose_display->rotateBy(newdata[Yaw], newdata[Roll], newdata[Pitch]); + + ui.lcdNumOutputPosX->display(QString("%1").arg(newdata[TX], 0, 'f', 1)); + ui.lcdNumOutputPosY->display(QString("%1").arg(newdata[TY], 0, 'f', 1)); + ui.lcdNumOutputPosZ->display(QString("%1").arg(newdata[TZ], 0, 'f', 1)); + + + ui.lcdNumOutputRotX->display(QString("%1").arg(newdata[Yaw], 0, 'f', 1)); + ui.lcdNumOutputRotY->display(QString("%1").arg(newdata[Pitch], 0, 'f', 1)); + ui.lcdNumOutputRotZ->display(QString("%1").arg(newdata[Roll], 0, 'f', 1)); + + // + // Update the curves in the curve-configurator. This shows the ball with the red lines. + // + if (_curve_config) { + _curve_config->update(); + } + if (Libraries->pProtocol) + { + QString name = Libraries->pProtocol->getGameName(); + ui.game_name->setText(name); + } +} + +/** toggles Video Widget **/ +void FaceTrackNoIR::showVideoWidget() { + if(ui.video_frame->isHidden()) + ui.video_frame->show(); + else + ui.video_frame->hide(); +} + +/** toggles Video Widget **/ +void FaceTrackNoIR::showHeadPoseWidget() { + if(ui.headPoseWidget->isHidden()) + ui.headPoseWidget->show(); + else + ui.headPoseWidget->hide(); +} + +/** toggles Engine Controls Dialog **/ +void FaceTrackNoIR::showTrackerSettings() { + if (pTrackerDialog) { + delete pTrackerDialog; + pTrackerDialog = NULL; + } + + DynamicLibrary* lib = dlopen_trackers.value(ui.iconcomboTrackerSource->currentIndex(), (DynamicLibrary*) NULL); + + if (lib) { + pTrackerDialog = (ITrackerDialog*) lib->Dialog(); + if (pTrackerDialog) { + if (Libraries && Libraries->pTracker) + pTrackerDialog->registerTracker(Libraries->pTracker); + pTrackerDialog->Initialize(this); + } + } +} + +// Show the Settings dialog for the secondary Tracker +void FaceTrackNoIR::showSecondTrackerSettings() { + if (pSecondTrackerDialog) { + delete pSecondTrackerDialog; + pSecondTrackerDialog = NULL; + } + + DynamicLibrary* lib = dlopen_trackers.value(ui.cbxSecondTrackerSource->currentIndex() - 1, (DynamicLibrary*) NULL); + + if (lib) { + pSecondTrackerDialog = (ITrackerDialog*) lib->Dialog(); + if (pSecondTrackerDialog) { + if (Libraries && Libraries->pSecondTracker) + pSecondTrackerDialog->registerTracker(Libraries->pSecondTracker); + pSecondTrackerDialog->Initialize(this); + } + } +} + +/** toggles Server Controls Dialog **/ +void FaceTrackNoIR::showServerControls() { + if (pProtocolDialog) { + delete pProtocolDialog; + pProtocolDialog = NULL; + } + + DynamicLibrary* lib = dlopen_protocols.value(ui.iconcomboProtocol->currentIndex(), (DynamicLibrary*) NULL); + + if (lib && lib->Dialog) { + pProtocolDialog = (IProtocolDialog*) lib->Dialog(); + if (pProtocolDialog) { + pProtocolDialog->Initialize(this); + } + } +} + +/** toggles Filter Controls Dialog **/ +void FaceTrackNoIR::showFilterControls() { + if (pFilterDialog) { + delete pFilterDialog; + pFilterDialog = NULL; + } + + DynamicLibrary* lib = dlopen_filters.value(ui.iconcomboFilter->currentIndex(), (DynamicLibrary*) NULL); + + if (lib && lib->Dialog) { + pFilterDialog = (IFilterDialog*) lib->Dialog(); + if (pFilterDialog) { + pFilterDialog->Initialize(this); + if (Libraries && Libraries->pFilter) + pFilterDialog->registerFilter(Libraries->pFilter); + } + } +} +/** toggles Keyboard Shortcut Dialog **/ +void FaceTrackNoIR::showKeyboardShortcuts() { + + // Create if new + if (!_keyboard_shortcuts) + { + _keyboard_shortcuts = new KeyboardShortcutDialog( this, this, Qt::Dialog ); + } + + // Show if already created + if (_keyboard_shortcuts) { + _keyboard_shortcuts->show(); + _keyboard_shortcuts->raise(); + } +} + +/** toggles Curve Configuration Dialog **/ +void FaceTrackNoIR::showCurveConfiguration() { + + // Create if new + if (!_curve_config) + { + _curve_config = new CurveConfigurationDialog( this, this, Qt::Dialog ); + } + + // Show if already created + if (_curve_config) { + _curve_config->show(); + _curve_config->raise(); + } +} + +/** exit application **/ +void FaceTrackNoIR::exit() { + QCoreApplication::exit(0); +} + +static bool get_metadata(DynamicLibrary* lib, QString& longName, QIcon& icon) +{ + Metadata* meta; + if (!lib->Metadata || ((meta = lib->Metadata()), !meta)) + { + delete lib; + return false; + } + meta->getFullName(&longName); + meta->getIcon(&icon); + delete meta; + return true; +} + +static void fill_combobox(const QString& filter, QList& list, QComboBox* cbx, QComboBox* cbx2) +{ + QDir settingsDir( QCoreApplication::applicationDirPath() ); + QStringList filenames = settingsDir.entryList( QStringList() << (LIB_PREFIX + filter + SONAME), QDir::Files, QDir::Name ); + for ( int i = 0; i < filenames.size(); i++) { + QIcon icon; + QString longName; + QString str = filenames.at(i); + DynamicLibrary* lib = new DynamicLibrary(str); + qDebug() << "Loading" << str; + std::cout.flush(); + if (!get_metadata(lib, longName, icon)) + { + delete lib; + continue; + } + list.push_back(lib); + cbx->addItem(icon, longName); + if (cbx2) + cbx2->addItem(icon, longName); + } +} + +// +// Setup the icons for the comboBoxes +// +void FaceTrackNoIR::createIconGroupBox() +{ + ui.cbxSecondTrackerSource->addItem(QIcon(), "None"); + dlopen_filters.push_back((DynamicLibrary*) NULL); + ui.iconcomboFilter->addItem(QIcon(), "None"); + + fill_combobox("opentrack-proto-*.", dlopen_protocols, ui.iconcomboProtocol, NULL); + fill_combobox("opentrack-tracker-*.", dlopen_trackers, ui.iconcomboTrackerSource, ui.cbxSecondTrackerSource); + fill_combobox("opentrack-filter-*.", dlopen_filters, ui.iconcomboFilter, NULL); + + connect(ui.iconcomboProtocol, SIGNAL(currentIndexChanged(int)), this, SLOT(protocolSelected(int))); + connect(ui.iconcomboTrackerSource, SIGNAL(currentIndexChanged(int)), this, SLOT(trackingSourceSelected(int))); + connect(ui.iconcomboFilter, SIGNAL(currentIndexChanged(int)), this, SLOT(filterSelected(int))); + connect(ui.cbxSecondTrackerSource, SIGNAL(currentIndexChanged(int)), this, SLOT(trackingSourceSelected(int))); +} + +// +// Handle changes of the Protocol selection +// +void FaceTrackNoIR::protocolSelected(int index) +{ + settingsDirty = true; + ui.btnShowServerControls->setEnabled ( true ); + + //setWindowIcon(QIcon(":/images/FaceTrackNoIR.png")); + //breaks with transparency -sh + //ui.btnShowServerControls->setIcon(icon);] +} + +// +// Handle changes of the Tracking Source selection +// +void FaceTrackNoIR::trackingSourceSelected(int index) +{ + settingsDirty = true; + ui.btnShowEngineControls->setEnabled ( true ); +} + +// +// Handle changes of the Profile selection +// +void FaceTrackNoIR::profileSelected(int index) +{ + if (looping) + return; + // + // Read the current INI-file setting, to get the folder in which it's located... + // + QSettings settings("opentrack"); // Registry settings (in HK_USER) + QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + QFileInfo pathInfo ( currentFile ); + + // + // Save the name of the INI-file in the Registry. + // + settings.setValue ("SettingsFile", pathInfo.absolutePath() + "/" + iniFileList.value(ui.iconcomboProfile->currentIndex(), "")); + loadSettings(); +} + +// +// Handle changes of the Filter selection +// +void FaceTrackNoIR::filterSelected(int index) +{ + settingsDirty = true; + + //QSettings settings("opentrack"); // 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) + + ui.btnShowFilterControls->setEnabled ( true ); +} + +//**************************************************************************************************// +//**************************************************************************************************// +// +// Constructor for Keyboard-shortcuts-dialog +// +KeyboardShortcutDialog::KeyboardShortcutDialog( FaceTrackNoIR *ftnoir, QWidget *parent, Qt::WindowFlags f ) : +QWidget( parent , f) +{ + ui.setupUi( this ); + + QPoint offsetpos(100, 100); + this->move(parent->pos() + offsetpos); + + mainApp = ftnoir; // Preserve a pointer to FTNoIR + + // Connect Qt signals to member-functions + connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); + connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); + + // Clear the Lists with key-descriptions and keycodes and build the Lists + // The strings will all be added to the ListBoxes for each Shortkey + // + + // Add strings to the Listboxes. + // + + for ( int i = 0; i < global_key_sequences.size(); i++) { + ui.cbxCenterKey->addItem(global_key_sequences.at(i)); + } + + // Load the settings from the current .INI-file + loadSettings(); +} + +// +// Destructor for server-dialog +// +KeyboardShortcutDialog::~KeyboardShortcutDialog() { + qDebug() << "~KeyboardShortcutDialog() says: started"; +} + +// +// OK clicked on server-dialog +// +void KeyboardShortcutDialog::doOK() { + save(); + this->close(); + mainApp->bindKeyboardShortcuts(); +} + +// override show event +void KeyboardShortcutDialog::showEvent ( QShowEvent * event ) { + loadSettings(); +} + +// +// Cancel clicked on server-dialog +// +void KeyboardShortcutDialog::doCancel() { + // + // Ask if changed Settings should be saved + // + if (settingsDirty) { + int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard ); + + qDebug() << "doCancel says: answer =" << ret; + + switch (ret) { + case QMessageBox::Save: + save(); + this->close(); + break; + case QMessageBox::Discard: + this->close(); + break; + case QMessageBox::Cancel: + // Cancel was clicked + break; + default: + // should never be reached + break; + } + } + else { + this->close(); + } +} + +void FaceTrackNoIR::bindKeyboardShortcuts() +{ + QSettings settings("opentrack"); // 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) + iniFile.beginGroup ( "KB_Shortcuts" ); + int idxCenter = iniFile.value("Key_index_Center", 0).toInt(); + +#if !defined(_WIN32) && !defined(__WIN32) + if (keyCenter) { + delete keyCenter; + keyCenter = NULL; + } + + if (idxCenter > 0) + { + QString seq(global_key_sequences.value(idxCenter, "")); + if (!seq.isEmpty()) + { + if (iniFile.value("Shift_Center", false).toBool()) + seq = "Shift+" + seq; + if (iniFile.value("Alt_Center", false).toBool()) + seq = "Alt+" + seq; + if (iniFile.value("Ctrl_Center", false).toBool()) + seq = "Ctrl+" + seq; + keyCenter = new QxtGlobalShortcut(QKeySequence(seq)); + connect(keyCenter, SIGNAL(activated()), this, SLOT(shortcutRecentered())); + } + } + +#else + keyCenter.keycode = 0; + keyCenter.shift = keyCenter.alt = keyCenter.ctrl = 0; + if (idxCenter > 0 && idxCenter < global_windows_key_sequences.size()) + keyCenter.keycode = global_windows_key_sequences[idxCenter]; + keyCenter.shift = iniFile.value("Shift_Center", false).toBool(); + keyCenter.alt = iniFile.value("Alt_Center", false).toBool(); + keyCenter.ctrl = iniFile.value("Ctrl_Center", false).toBool(); +#endif + iniFile.endGroup (); + + if (tracker) /* running already */ + { +#if defined(_WIN32) || defined(__WIN32) + if (keybindingWorker) + { + keybindingWorker->should_quit = true; + keybindingWorker->wait(); + delete keybindingWorker; + keybindingWorker = NULL; + } + keybindingWorker = new KeybindingWorker(*this, keyCenter); + keybindingWorker->start(); +#endif + } +} + +// +// Load the current Settings from the currently 'active' INI-file. +// +void KeyboardShortcutDialog::loadSettings() { + qDebug() << "loadSettings says: Starting "; + QSettings settings("opentrack"); // 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; + + iniFile.beginGroup ( "KB_Shortcuts" ); + + ui.chkCenterShift->setChecked (iniFile.value ( "Shift_Center", 0 ).toBool()); + ui.chkCenterCtrl->setChecked (iniFile.value ( "Ctrl_Center", 0 ).toBool()); + ui.chkCenterAlt->setChecked (iniFile.value ( "Alt_Center", 0 ).toBool()); + + ui.cbxCenterKey->setCurrentIndex(iniFile.value("Key_index_Center", 0).toInt()); + + iniFile.endGroup (); + + settingsDirty = false; + +} + +// +// Save the current Settings to the currently 'active' INI-file. +// +void KeyboardShortcutDialog::save() { + + qDebug() << "save() says: started"; + + QSettings settings("opentrack"); // 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) + + iniFile.beginGroup ( "KB_Shortcuts" ); + iniFile.setValue ( "Key_index_Center", ui.cbxCenterKey->currentIndex() ); + iniFile.setValue ( "Shift_Center", ui.chkCenterShift->isChecked() ); + iniFile.setValue ( "Ctrl_Center", ui.chkCenterCtrl->isChecked() ); + iniFile.setValue ( "Alt_Center", ui.chkCenterAlt->isChecked() ); + + iniFile.endGroup (); + + settingsDirty = false; + + // + // Send a message to the main program, to update the Settings (for the tracker) + // + mainApp->updateSettings(); +} + +//**************************************************************************************************// +//**************************************************************************************************// +// +// Constructor for Curve-configuration-dialog +// +CurveConfigurationDialog::CurveConfigurationDialog( FaceTrackNoIR *ftnoir, QWidget *parent, Qt::WindowFlags f ) : +QWidget( parent , f) +{ + ui.setupUi( this ); + + QPoint offsetpos(120, 30); + this->move(parent->pos() + offsetpos); + + mainApp = ftnoir; // Preserve a pointer to FTNoIR + + QSettings settings("opentrack"); // Registry settings (in HK_USER) + QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + + QFunctionConfigurator* configs[6] = { + ui.txconfig, + ui.tyconfig, + ui.tzconfig, + ui.rxconfig, + ui.ryconfig, + ui.rzconfig + }; + + QFunctionConfigurator* alt_configs[6] = { + ui.txconfig_alt, + ui.tyconfig_alt, + ui.tzconfig_alt, + ui.rxconfig_alt, + ui.ryconfig_alt, + ui.rzconfig_alt + }; + + QCheckBox* checkboxes[6] = { + ui.rx_altp, + ui.ry_altp, + ui.rz_altp, + ui.tx_altp, + ui.ty_altp, + ui.tz_altp + }; + + for (int i = 0; i < 6; i++) + { + configs[i]->setConfig(&mainApp->axis(i).curve, currentFile); + alt_configs[i]->setConfig(&mainApp->axis(i).curveAlt, currentFile); + connect(configs[i], SIGNAL(CurveChanged(bool)), this, SLOT(curveChanged(bool))); + connect(alt_configs[i], SIGNAL(CurveChanged(bool)), this, SLOT(curveChanged(bool))); + connect(checkboxes[i], SIGNAL(stateChanged(int)), this, SLOT(curveChanged(int))); + } + + // Connect Qt signals to member-functions + connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); + connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); + + // Load the settings from the current .INI-file + loadSettings(); +} + +// +// Destructor for server-dialog +// +CurveConfigurationDialog::~CurveConfigurationDialog() { + qDebug() << "~CurveConfigurationDialog() says: started"; +} + +// +// OK clicked on server-dialog +// +void CurveConfigurationDialog::doOK() { + save(); + this->close(); +} + +// override show event +void CurveConfigurationDialog::showEvent ( QShowEvent * event ) { + loadSettings(); +} + +// +// Cancel clicked on server-dialog +// +void CurveConfigurationDialog::doCancel() { + // + // Ask if changed Settings should be saved + // + if (settingsDirty) { + int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard ); + + qDebug() << "doCancel says: answer =" << ret; + + switch (ret) { + case QMessageBox::Save: + save(); + this->close(); + break; + case QMessageBox::Discard: + this->close(); + break; + case QMessageBox::Cancel: + // Cancel was clicked + break; + default: + // should never be reached + break; + } + } + else { + this->close(); + } +} + +// +// Load the current Settings from the currently 'active' INI-file. +// +void CurveConfigurationDialog::loadSettings() { + qDebug() << "loadSettings says: Starting "; + QSettings settings("opentrack"); // 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; + + static const char* names[] = { + "tx_alt", + "ty_alt", + "tz_alt", + "rx_alt", + "ry_alt", + "rz_alt" + }; + + iniFile.beginGroup("Tracking"); + + for (int i = 0; i < 6; i++) + mainApp->axis(i).altp = iniFile.value(names[i], false).toBool(); + + QCheckBox* widgets[] = { + ui.tx_altp, + ui.ty_altp, + ui.tz_altp, + ui.rx_altp, + ui.ry_altp, + ui.rz_altp + }; + + for (int i = 0; i < 6; i++) + widgets[i]->setChecked(mainApp->axis(i).altp); + + QDoubleSpinBox* widgets2[] = { + ui.pos_tx, + ui.pos_ty, + ui.pos_tz, + ui.pos_tx, + ui.pos_ry, + ui.pos_rz + }; + + const char* names2[] = { + "zero_tx", + "zero_ty", + "zero_tz", + "zero_rx", + "zero_ry", + "zero_rz" + }; + + for (int i = 0; i < 6; i++) + widgets2[i]->setValue(iniFile.value(names2[i], 0).toDouble()); + + iniFile.endGroup(); + + settingsDirty = false; +} + +// +// Save the current Settings to the currently 'active' INI-file. +// +void CurveConfigurationDialog::save() { + + qDebug() << "save() says: started"; + + QSettings settings("opentrack"); // Registry settings (in HK_USER) + + QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + + ui.rxconfig->saveSettings(currentFile); + ui.ryconfig->saveSettings(currentFile); + ui.rzconfig->saveSettings(currentFile); + ui.txconfig->saveSettings(currentFile); + ui.tyconfig->saveSettings(currentFile); + ui.tzconfig->saveSettings(currentFile); + + ui.txconfig_alt->saveSettings(currentFile); + ui.tyconfig_alt->saveSettings(currentFile); + ui.tzconfig_alt->saveSettings(currentFile); + ui.rxconfig_alt->saveSettings(currentFile); + ui.ryconfig_alt->saveSettings(currentFile); + ui.rzconfig_alt->saveSettings(currentFile); + + QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) + + iniFile.beginGroup("Tracking"); + + iniFile.setValue("rx_alt", ui.rx_altp->checkState() != Qt::Unchecked); + iniFile.setValue("ry_alt", ui.ry_altp->checkState() != Qt::Unchecked); + iniFile.setValue("rz_alt", ui.rz_altp->checkState() != Qt::Unchecked); + iniFile.setValue("tx_alt", ui.tx_altp->checkState() != Qt::Unchecked); + iniFile.setValue("ty_alt", ui.ty_altp->checkState() != Qt::Unchecked); + iniFile.setValue("tz_alt", ui.tz_altp->checkState() != Qt::Unchecked); + + QDoubleSpinBox* widgets2[] = { + ui.pos_tx, + ui.pos_ty, + ui.pos_tz, + ui.pos_tx, + ui.pos_ry, + ui.pos_rz + }; + + const char* names2[] = { + "zero_tx", + "zero_ty", + "zero_tz", + "zero_rx", + "zero_ry", + "zero_rz" + }; + + for (int i = 0; i < 6; i++) + iniFile.setValue(names2[i], widgets2[i]->value()); + + iniFile.endGroup(); + + settingsDirty = false; + + // + // Send a message to the main program, to update the Settings (for the tracker) + // + mainApp->updateSettings(); +} + +void FaceTrackNoIR::shortcutRecentered() +{ + if (tracker) + { +#if defined(__WIN32) || defined(_WIN32) + MessageBeep(MB_OK); +#else + QApplication::beep(); +#endif + qDebug() << "Center"; + tracker->do_center = true; + } +} diff --git a/facetracknoir/facetracknoir.h b/facetracknoir/facetracknoir.h index ff0b3642..768f6107 100644 --- a/facetracknoir/facetracknoir.h +++ b/facetracknoir/facetracknoir.h @@ -1,295 +1,295 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of the some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2010 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -*********************************************************************************/ - -#ifndef FaceTrackNoIR_H -#define FaceTrackNoIR_H - -#undef FTNOIR_PROTOCOL_BASE_LIB -#undef FTNOIR_TRACKER_BASE_LIB -#undef FTNOIR_FILTER_BASE_LIB -#define FTNOIR_PROTOCOL_BASE_EXPORT Q_DECL_IMPORT -#define FTNOIR_TRACKER_BASE_EXPORT Q_DECL_IMPORT -#define FTNOIR_FILTER_BASE_EXPORT Q_DECL_IMPORT - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#if !defined(_WIN32) && !defined(__WIN32) -# include -#else -# include -#endif -#include -#include -#include - - -#include "ui_facetracknoir.h" -#include "ui_ftnoir_keyboardshortcuts.h" -#include "ui_ftnoir_curves.h" - -#include "ftnoir_protocol_base/ftnoir_protocol_base.h" -#include "ftnoir_tracker_base/ftnoir_tracker_base.h" -#include "ftnoir_filter_base/ftnoir_filter_base.h" - -#include "global-settings.h" -#include "tracker.h" - -class Tracker; // pre-define class to avoid circular includes -class FaceTrackNoIR; - -class KeybindingWorker; - -#if defined(__WIN32) || defined(_WIN32) -extern QList global_windows_key_sequences; -#undef DIRECTINPUT_VERSION -#define DIRECTINPUT_VERSION 0x0800 -#include -struct Key { - BYTE keycode; - bool shift; - bool ctrl; - bool alt; - bool ever_pressed; - QElapsedTimer timer; -public: - Key() : keycode(0), shift(false), ctrl(false), alt(false), ever_pressed(false) - { - } -}; -#else -typedef unsigned char BYTE; -struct Key { int foo; }; -#endif - -class FaceTrackNoIR : public QMainWindow, IDynamicLibraryProvider -{ - Q_OBJECT - -public: - FaceTrackNoIR(QWidget *parent = 0, Qt::WFlags flags = 0); - ~FaceTrackNoIR(); - - void updateSettings(); // Update the settings (let Tracker read INI-file). - - QFrame *get_video_widget(); // Get a pointer to the video-widget, to use in the DLL - Tracker *tracker; - void bindKeyboardShortcuts(); - DynamicLibrary* current_tracker1() { - return dlopen_trackers.value(ui.iconcomboTrackerSource->currentIndex(), (DynamicLibrary*) NULL); - } - DynamicLibrary* current_tracker2() { - return dlopen_trackers.value(ui.cbxSecondTrackerSource->currentIndex() - 1, (DynamicLibrary*) NULL); - } - DynamicLibrary* current_protocol() { - return dlopen_protocols.value(ui.iconcomboProtocol->currentIndex(), (DynamicLibrary*) NULL); - } - DynamicLibrary* current_filter() { - return dlopen_filters.value(ui.iconcomboFilter->currentIndex(), (DynamicLibrary*) NULL); - } - THeadPoseDOF& axis(int idx) { - return *pose.axes[idx]; - } - -#if defined(_WIN32) || defined(__WIN32) - Key keyCenter; - KeybindingWorker* keybindingWorker; -#else - QxtGlobalShortcut* keyCenter; -#endif -public slots: - void shortcutRecentered(); - -private: - HeadPoseData pose; - Ui::FaceTrackNoIRClass ui; - QTimer timUpdateHeadPose; // Timer to display headpose - QStringList iniFileList; // List of INI-files, that are present in the Settings folder - - ITrackerDialog* pTrackerDialog; // Pointer to Tracker dialog instance (in DLL) - ITrackerDialog* pSecondTrackerDialog; // Pointer to the second Tracker dialog instance (in DLL) - IProtocolDialog* pProtocolDialog; // Pointer to Protocol dialog instance (in DLL) - IFilterDialog* pFilterDialog; // Pointer to Filter dialog instance (in DLL) - - /** Widget variables **/ - QWidget *_keyboard_shortcuts; - QWidget *_curve_config; - - void createIconGroupBox(); -// void createMessageGroupBox(); - - /** helper **/ - bool cameraDetected; - bool settingsDirty; - - void GetCameraNameDX(); - void loadSettings(); - void setupFaceTrackNoIR(); - - QList dlopen_filters; - QList dlopen_trackers; - QList dlopen_protocols; - - bool looping; - - private slots: - //file menu - void open(); - void save(); - void saveAs(); - void exit(); -// void setIcon(int index); - void profileSelected(int index); - void protocolSelected(int index); - void filterSelected(int index); - void trackingSourceSelected(int index); - - void showVideoWidget(); - void showHeadPoseWidget(); - void showTrackerSettings(); - void showSecondTrackerSettings(); - - void showServerControls(); - void showFilterControls(); - void showKeyboardShortcuts(); - void showCurveConfiguration(); - - void setInvertAxis( Axis axis, int invert ); - void setInvertYaw(int invert) { - setInvertAxis(Yaw, invert); - } - void setInvertPitch(int invert) { - setInvertAxis(Pitch, invert); - } - void setInvertRoll(int invert) { - setInvertAxis(Roll, invert); - } - void setInvertX(int invert) { - setInvertAxis(TX, invert); - } - void setInvertY(int invert) { - setInvertAxis(TY, invert); - } - void setInvertZ(int invert) { - setInvertAxis(TZ, invert); - } - void showHeadPose(); - - void startTracker(); - void stopTracker(); - -}; - -class KeyboardShortcutDialog: public QWidget -{ - Q_OBJECT -public: - - explicit KeyboardShortcutDialog( FaceTrackNoIR *ftnoir, QWidget *parent=0, Qt::WindowFlags f=0 ); - virtual ~KeyboardShortcutDialog(); - void showEvent ( QShowEvent * event ); - -private: - Ui::UICKeyboardShortcutDialog ui; - void loadSettings(); - void save(); - - /** helper **/ - bool settingsDirty; - FaceTrackNoIR *mainApp; - -private slots: - void doOK(); - void doCancel(); -}; - -// Widget that has controls for Keyboard shortcuts. -class CurveConfigurationDialog: public QWidget -{ - Q_OBJECT -public: - - explicit CurveConfigurationDialog( FaceTrackNoIR *ftnoir, QWidget *parent=0, Qt::WindowFlags f=0 ); - virtual ~CurveConfigurationDialog(); - void showEvent ( QShowEvent * event ); - -private: - Ui::UICCurveConfigurationDialog ui; - void loadSettings(); - void save(); - - /** helper **/ - bool settingsDirty; - FaceTrackNoIR *mainApp; - -private slots: - void doOK(); - void doCancel(); - void curveChanged( bool change ) { settingsDirty = true; } - void curveChanged( int change ) { settingsDirty = true; } -}; - -extern QList global_key_sequences; -#if defined(__WIN32) || defined(_WIN32) -class KeybindingWorkerDummy { -private: - LPDIRECTINPUT8 din; - LPDIRECTINPUTDEVICE8 dinkeyboard; - Key kCenter; - FaceTrackNoIR& window; -public: - volatile bool should_quit; - ~KeybindingWorkerDummy(); - KeybindingWorkerDummy(FaceTrackNoIR& w, Key keyCenter); - void run(); -}; -#else -class KeybindingWorkerDummy { -public: - KeybindingWorkerDummy(FaceTrackNoIR& w, Key keyCenter); - void run() {} -}; -#endif - -class KeybindingWorker : public QThread, public KeybindingWorkerDummy { - Q_OBJECT -public: - KeybindingWorker(FaceTrackNoIR& w, Key keyCenter) : KeybindingWorkerDummy(w, keyCenter) - { - } - void run() { - KeybindingWorkerDummy::run(); - } -}; - +/******************************************************************************** +* FaceTrackNoIR This program is a private project of the some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2010 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +*********************************************************************************/ + +#ifndef FaceTrackNoIR_H +#define FaceTrackNoIR_H + +#undef FTNOIR_PROTOCOL_BASE_LIB +#undef FTNOIR_TRACKER_BASE_LIB +#undef FTNOIR_FILTER_BASE_LIB +#define FTNOIR_PROTOCOL_BASE_EXPORT Q_DECL_IMPORT +#define FTNOIR_TRACKER_BASE_EXPORT Q_DECL_IMPORT +#define FTNOIR_FILTER_BASE_EXPORT Q_DECL_IMPORT + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#if !defined(_WIN32) && !defined(__WIN32) +# include +#else +# include +#endif +#include +#include +#include + + +#include "ui_facetracknoir.h" +#include "ui_ftnoir_keyboardshortcuts.h" +#include "ui_ftnoir_curves.h" + +#include "ftnoir_protocol_base/ftnoir_protocol_base.h" +#include "ftnoir_tracker_base/ftnoir_tracker_base.h" +#include "ftnoir_filter_base/ftnoir_filter_base.h" + +#include "global-settings.h" +#include "tracker.h" + +class Tracker; // pre-define class to avoid circular includes +class FaceTrackNoIR; + +class KeybindingWorker; + +#if defined(__WIN32) || defined(_WIN32) +extern QList global_windows_key_sequences; +#undef DIRECTINPUT_VERSION +#define DIRECTINPUT_VERSION 0x0800 +#include +struct Key { + BYTE keycode; + bool shift; + bool ctrl; + bool alt; + bool ever_pressed; + QElapsedTimer timer; +public: + Key() : keycode(0), shift(false), ctrl(false), alt(false), ever_pressed(false) + { + } +}; +#else +typedef unsigned char BYTE; +struct Key { int foo; }; +#endif + +class FaceTrackNoIR : public QMainWindow, IDynamicLibraryProvider +{ + Q_OBJECT + +public: + FaceTrackNoIR(QWidget *parent = 0, Qt::WFlags flags = 0); + ~FaceTrackNoIR(); + + void updateSettings(); // Update the settings (let Tracker read INI-file). + + QFrame *get_video_widget(); // Get a pointer to the video-widget, to use in the DLL + Tracker *tracker; + void bindKeyboardShortcuts(); + DynamicLibrary* current_tracker1() { + return dlopen_trackers.value(ui.iconcomboTrackerSource->currentIndex(), (DynamicLibrary*) NULL); + } + DynamicLibrary* current_tracker2() { + return dlopen_trackers.value(ui.cbxSecondTrackerSource->currentIndex() - 1, (DynamicLibrary*) NULL); + } + DynamicLibrary* current_protocol() { + return dlopen_protocols.value(ui.iconcomboProtocol->currentIndex(), (DynamicLibrary*) NULL); + } + DynamicLibrary* current_filter() { + return dlopen_filters.value(ui.iconcomboFilter->currentIndex(), (DynamicLibrary*) NULL); + } + THeadPoseDOF& axis(int idx) { + return *pose.axes[idx]; + } + +#if defined(_WIN32) || defined(__WIN32) + Key keyCenter; + KeybindingWorker* keybindingWorker; +#else + QxtGlobalShortcut* keyCenter; +#endif +public slots: + void shortcutRecentered(); + +private: + HeadPoseData pose; + Ui::FaceTrackNoIRClass ui; + QTimer timUpdateHeadPose; // Timer to display headpose + QStringList iniFileList; // List of INI-files, that are present in the Settings folder + + ITrackerDialog* pTrackerDialog; // Pointer to Tracker dialog instance (in DLL) + ITrackerDialog* pSecondTrackerDialog; // Pointer to the second Tracker dialog instance (in DLL) + IProtocolDialog* pProtocolDialog; // Pointer to Protocol dialog instance (in DLL) + IFilterDialog* pFilterDialog; // Pointer to Filter dialog instance (in DLL) + + /** Widget variables **/ + QWidget *_keyboard_shortcuts; + QWidget *_curve_config; + + void createIconGroupBox(); +// void createMessageGroupBox(); + + /** helper **/ + bool cameraDetected; + bool settingsDirty; + + void GetCameraNameDX(); + void loadSettings(); + void setupFaceTrackNoIR(); + + QList dlopen_filters; + QList dlopen_trackers; + QList dlopen_protocols; + + bool looping; + + private slots: + //file menu + void open(); + void save(); + void saveAs(); + void exit(); +// void setIcon(int index); + void profileSelected(int index); + void protocolSelected(int index); + void filterSelected(int index); + void trackingSourceSelected(int index); + + void showVideoWidget(); + void showHeadPoseWidget(); + void showTrackerSettings(); + void showSecondTrackerSettings(); + + void showServerControls(); + void showFilterControls(); + void showKeyboardShortcuts(); + void showCurveConfiguration(); + + void setInvertAxis( Axis axis, int invert ); + void setInvertYaw(int invert) { + setInvertAxis(Yaw, invert); + } + void setInvertPitch(int invert) { + setInvertAxis(Pitch, invert); + } + void setInvertRoll(int invert) { + setInvertAxis(Roll, invert); + } + void setInvertX(int invert) { + setInvertAxis(TX, invert); + } + void setInvertY(int invert) { + setInvertAxis(TY, invert); + } + void setInvertZ(int invert) { + setInvertAxis(TZ, invert); + } + void showHeadPose(); + + void startTracker(); + void stopTracker(); + +}; + +class KeyboardShortcutDialog: public QWidget +{ + Q_OBJECT +public: + + explicit KeyboardShortcutDialog( FaceTrackNoIR *ftnoir, QWidget *parent=0, Qt::WindowFlags f=0 ); + virtual ~KeyboardShortcutDialog(); + void showEvent ( QShowEvent * event ); + +private: + Ui::UICKeyboardShortcutDialog ui; + void loadSettings(); + void save(); + + /** helper **/ + bool settingsDirty; + FaceTrackNoIR *mainApp; + +private slots: + void doOK(); + void doCancel(); +}; + +// Widget that has controls for Keyboard shortcuts. +class CurveConfigurationDialog: public QWidget +{ + Q_OBJECT +public: + + explicit CurveConfigurationDialog( FaceTrackNoIR *ftnoir, QWidget *parent=0, Qt::WindowFlags f=0 ); + virtual ~CurveConfigurationDialog(); + void showEvent ( QShowEvent * event ); + +private: + Ui::UICCurveConfigurationDialog ui; + void loadSettings(); + void save(); + + /** helper **/ + bool settingsDirty; + FaceTrackNoIR *mainApp; + +private slots: + void doOK(); + void doCancel(); + void curveChanged( bool change ) { settingsDirty = true; } + void curveChanged( int change ) { settingsDirty = true; } +}; + +extern QList global_key_sequences; +#if defined(__WIN32) || defined(_WIN32) +class KeybindingWorkerDummy { +private: + LPDIRECTINPUT8 din; + LPDIRECTINPUTDEVICE8 dinkeyboard; + Key kCenter; + FaceTrackNoIR& window; +public: + volatile bool should_quit; + ~KeybindingWorkerDummy(); + KeybindingWorkerDummy(FaceTrackNoIR& w, Key keyCenter); + void run(); +}; +#else +class KeybindingWorkerDummy { +public: + KeybindingWorkerDummy(FaceTrackNoIR& w, Key keyCenter); + void run() {} +}; +#endif + +class KeybindingWorker : public QThread, public KeybindingWorkerDummy { + Q_OBJECT +public: + KeybindingWorker(FaceTrackNoIR& w, Key keyCenter) : KeybindingWorkerDummy(w, keyCenter) + { + } + void run() { + KeybindingWorkerDummy::run(); + } +}; + #endif // FaceTrackNoIR_H \ No newline at end of file diff --git a/facetracknoir/main.cpp b/facetracknoir/main.cpp index 7ff9f29f..bc0f973b 100644 --- a/facetracknoir/main.cpp +++ b/facetracknoir/main.cpp @@ -1,57 +1,57 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of the some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2010 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -*********************************************************************************/ - -#include "facetracknoir.h" -#include "tracker.h" -#include -#include -#include -#include - -#if defined(_WIN32) -#include -//#pragma comment(linker, "/SUBSYSTEM:console /ENTRY:mainCRTStartup") -#endif -int main(int argc, char** argv) -{ -#if defined(_WIN32) - (void) timeBeginPeriod(1); -#endif - QApplication app(argc, argv); - QFont font; - font.setFamily(font.defaultFamily()); - font.setPointSize(9); - app.setFont(font); - FaceTrackNoIR w; - // - // Create the Main Window and DeskTop and Exec! - // - QDesktopWidget desktop; - w.move(desktop.screenGeometry().width()/2-w.width()/2, 100); - w.show(); - qApp->exec(); - - return 0; -} - +/******************************************************************************** +* FaceTrackNoIR This program is a private project of the some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2010 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +*********************************************************************************/ + +#include "facetracknoir.h" +#include "tracker.h" +#include +#include +#include +#include + +#if defined(_WIN32) +#include +//#pragma comment(linker, "/SUBSYSTEM:console /ENTRY:mainCRTStartup") +#endif +int main(int argc, char** argv) +{ +#if defined(_WIN32) + (void) timeBeginPeriod(1); +#endif + QApplication app(argc, argv); + QFont font; + font.setFamily(font.defaultFamily()); + font.setPointSize(9); + app.setFont(font); + FaceTrackNoIR w; + // + // Create the Main Window and DeskTop and Exec! + // + QDesktopWidget desktop; + w.move(desktop.screenGeometry().width()/2-w.width()/2, 100); + w.show(); + qApp->exec(); + + return 0; +} + diff --git a/facetracknoir/rotation.h b/facetracknoir/rotation.h index dd70ca77..e97ec0f0 100644 --- a/facetracknoir/rotation.h +++ b/facetracknoir/rotation.h @@ -1,64 +1,64 @@ -/* Copyright (c) 2012 Patrick Ruoff - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - */ - -#ifndef ROTATION_H -#define ROTATION_H -#include -// ---------------------------------------------------------------------------- -class Rotation { - -public: - Rotation() : a(1.0),b(0.0),c(0.0),d(0.0) {} - Rotation(double yaw, double pitch, double roll) { fromEuler(yaw, pitch, roll); } - Rotation(double a, double b, double c, double d) : a(a),b(b),c(c),d(d) {} - - Rotation inv(){ // inverse - return Rotation(a,-b,-c, -d); - } - - - // conversions - // see http://en.wikipedia.org/wiki/Conversion_between_quaternions_and_Euler_angles - void fromEuler(double yaw, double pitch, double roll) - { - - double sin_phi = sin(roll/2.0); - double cos_phi = cos(roll/2.0); - double sin_the = sin(pitch/2.0); - double cos_the = cos(pitch/2.0); - double sin_psi = sin(yaw/2.0); - double cos_psi = cos(yaw/2.0); - - a = cos_phi*cos_the*cos_psi + sin_phi*sin_the*sin_psi; - b = sin_phi*cos_the*cos_psi - cos_phi*sin_the*sin_psi; - c = cos_phi*sin_the*cos_psi + sin_phi*cos_the*sin_psi; - d = cos_phi*cos_the*sin_psi - sin_phi*sin_the*cos_psi; - } - - void toEuler(double& yaw, double& pitch, double& roll) - { - roll = atan2(2.0*(a*b + c*d), 1.0 - 2.0*(b*b + c*c)); - pitch = asin(2.0*(a*c - b*d)); - yaw = atan2(2.0*(a*d + b*c), 1.0 - 2.0*(c*c + d*d)); - } - - const Rotation operator*(const Rotation& B) - { - const Rotation& A = *this; - return Rotation(A.a*B.a - A.b*B.b - A.c*B.c - A.d*B.d, // quaternion multiplication - A.a*B.b + A.b*B.a + A.c*B.d - A.d*B.c, - A.a*B.c - A.b*B.d + A.c*B.a + A.d*B.b, - A.a*B.d + A.b*B.c - A.c*B.b + A.d*B.a); - } - -protected: - double a,b,c,d; // quaternion coefficients -}; - - - -#endif //ROTATION_H +/* Copyright (c) 2012 Patrick Ruoff + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + */ + +#ifndef ROTATION_H +#define ROTATION_H +#include +// ---------------------------------------------------------------------------- +class Rotation { + +public: + Rotation() : a(1.0),b(0.0),c(0.0),d(0.0) {} + Rotation(double yaw, double pitch, double roll) { fromEuler(yaw, pitch, roll); } + Rotation(double a, double b, double c, double d) : a(a),b(b),c(c),d(d) {} + + Rotation inv(){ // inverse + return Rotation(a,-b,-c, -d); + } + + + // conversions + // see http://en.wikipedia.org/wiki/Conversion_between_quaternions_and_Euler_angles + void fromEuler(double yaw, double pitch, double roll) + { + + double sin_phi = sin(roll/2.0); + double cos_phi = cos(roll/2.0); + double sin_the = sin(pitch/2.0); + double cos_the = cos(pitch/2.0); + double sin_psi = sin(yaw/2.0); + double cos_psi = cos(yaw/2.0); + + a = cos_phi*cos_the*cos_psi + sin_phi*sin_the*sin_psi; + b = sin_phi*cos_the*cos_psi - cos_phi*sin_the*sin_psi; + c = cos_phi*sin_the*cos_psi + sin_phi*cos_the*sin_psi; + d = cos_phi*cos_the*sin_psi - sin_phi*sin_the*cos_psi; + } + + void toEuler(double& yaw, double& pitch, double& roll) + { + roll = atan2(2.0*(a*b + c*d), 1.0 - 2.0*(b*b + c*c)); + pitch = asin(2.0*(a*c - b*d)); + yaw = atan2(2.0*(a*d + b*c), 1.0 - 2.0*(c*c + d*d)); + } + + const Rotation operator*(const Rotation& B) + { + const Rotation& A = *this; + return Rotation(A.a*B.a - A.b*B.b - A.c*B.c - A.d*B.d, // quaternion multiplication + A.a*B.b + A.b*B.a + A.c*B.d - A.d*B.c, + A.a*B.c - A.b*B.d + A.c*B.a + A.d*B.b, + A.a*B.d + A.b*B.c - A.c*B.b + A.d*B.a); + } + +protected: + double a,b,c,d; // quaternion coefficients +}; + + + +#endif //ROTATION_H diff --git a/facetracknoir/tracker.cpp b/facetracknoir/tracker.cpp index f2b4845f..47daa697 100644 --- a/facetracknoir/tracker.cpp +++ b/facetracknoir/tracker.cpp @@ -1,218 +1,218 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of the some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2012 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage: http://facetracknoir.sourceforge.net/home/default.htm * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -*********************************************************************************/ -#include "tracker.h" -#include "facetracknoir.h" - -/** constructor **/ -Tracker::Tracker( FaceTrackNoIR *parent ) : - should_quit(false), - do_center(false) -{ - // Retieve the pointer to the parent - mainApp = parent; - // Load the settings from the INI-file - loadSettings(); -} - -Tracker::~Tracker() -{ -} - -static void get_curve(double pos, double& out, THeadPoseDOF& axis) { - bool altp = (pos < 0) && axis.altp; - if (altp) { - out = axis.invert * axis.curveAlt.getValue(pos); - axis.curve.setTrackingActive( false ); - axis.curveAlt.setTrackingActive( true ); - } - else { - out = axis.invert * axis.curve.getValue(pos); - axis.curve.setTrackingActive( true ); - axis.curveAlt.setTrackingActive( false ); - } - out += axis.zero; -} - -/** QThread run method @override **/ -void Tracker::run() { - T6DOF current_camera; // Used for filtering - T6DOF target_camera; - T6DOF new_camera; - - /** Direct Input variables **/ - T6DOF offset_camera; - T6DOF gameoutput_camera; - - bool bTracker1Confid = false; - bool bTracker2Confid = false; - - double newpose[6]; - double last_post_filter[6]; - - forever - { - if (should_quit) - break; - - for (int i = 0; i < 6; i++) - newpose[i] = 0; - - // - // The second tracker serves as 'secondary'. So if an axis is written by the second tracker it CAN be overwritten by the Primary tracker. - // This is enforced by the sequence below. - // - if (Libraries->pSecondTracker) { - bTracker2Confid = Libraries->pSecondTracker->GiveHeadPoseData(newpose); - } - - if (Libraries->pTracker) { - bTracker1Confid = Libraries->pTracker->GiveHeadPoseData(newpose); - } - - { - QMutexLocker foo(&mtx); - const bool confid = bTracker1Confid || bTracker2Confid; - - if ( confid ) { - for (int i = 0; i < 6; i++) - mainApp->axis(i).headPos = newpose[i]; - } - - // - // If Center is pressed, copy the current values to the offsets. - // - if (do_center) { - // - // Only copy valid values - // - for (int i = 0; i < 6; i++) - offset_camera.axes[i] = mainApp->axis(i).headPos; - - Tracker::do_center = false; - - if (Libraries->pTracker) - Libraries->pTracker->NotifyCenter(); - - if (Libraries->pSecondTracker) - Libraries->pSecondTracker->NotifyCenter(); - - if (Libraries->pFilter) - Libraries->pFilter->Initialize(); - } - - if (confid) { - // get values - for (int i = 0; i < 6; i++) - target_camera.axes[i] = mainApp->axis(i).headPos; - - // do the centering - target_camera = target_camera - offset_camera; - - // - // Use advanced filtering, when a filter was selected. - // - if (Libraries->pFilter) { - for (int i = 0; i < 6; i++) - last_post_filter[i] = gameoutput_camera.axes[i]; - Libraries->pFilter->FilterHeadPoseData(current_camera.axes, target_camera.axes, new_camera.axes, last_post_filter); - } - else { - new_camera = target_camera; - } - - for (int i = 0; i < 6; i++) { - get_curve(new_camera.axes[i], output_camera.axes[i], mainApp->axis(i)); - } - - // - // Send the headpose to the game - // - if (Libraries->pProtocol) { - gameoutput_camera = output_camera; - Libraries->pProtocol->sendHeadposeToGame( gameoutput_camera.axes, newpose ); // degrees & centimeters - } - } - } - - //for lower cpu load - msleep(8); - } - - for (int i = 0; i < 6; i++) - { - mainApp->axis(i).curve.setTrackingActive(false); - mainApp->axis(i).curveAlt.setTrackingActive(false); - } -} - -// -// Get the raw headpose, so it can be displayed. -// -void Tracker::getHeadPose( double *data ) { - QMutexLocker foo(&mtx); - for (int i = 0; i < 6; i++) - { - data[i] = mainApp->axis(i).headPos; - } -} - -// -// Get the output-headpose, so it can be displayed. -// -void Tracker::getOutputHeadPose( double *data ) { - QMutexLocker foo(&mtx); - for (int i = 0; i < 6; i++) - data[i] = output_camera.axes[i]; -} - -// -// Load the current Settings from the currently 'active' INI-file. -// -void Tracker::loadSettings() { - qDebug() << "Tracker::loadSettings says: Starting "; - QSettings settings("opentrack"); // 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) - - iniFile.beginGroup("Tracking"); - - qDebug() << "loadSettings says: iniFile = " << currentFile; - - const char* names2[] = { - "zero_tx", - "zero_ty", - "zero_tz", - "zero_rx", - "zero_ry", - "zero_rz" - }; - - for (int i = 0; i < 6; i++) - mainApp->axis(i).zero = iniFile.value(names2[i], 0).toDouble(); - - iniFile.endGroup(); -} - -void Tracker::setInvertAxis(Axis axis, bool invert) { mainApp->axis(axis).invert = invert?-1.0f:1.0f; } +/******************************************************************************** +* FaceTrackNoIR This program is a private project of the some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2012 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage: http://facetracknoir.sourceforge.net/home/default.htm * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +*********************************************************************************/ +#include "tracker.h" +#include "facetracknoir.h" + +/** constructor **/ +Tracker::Tracker( FaceTrackNoIR *parent ) : + should_quit(false), + do_center(false) +{ + // Retieve the pointer to the parent + mainApp = parent; + // Load the settings from the INI-file + loadSettings(); +} + +Tracker::~Tracker() +{ +} + +static void get_curve(double pos, double& out, THeadPoseDOF& axis) { + bool altp = (pos < 0) && axis.altp; + if (altp) { + out = axis.invert * axis.curveAlt.getValue(pos); + axis.curve.setTrackingActive( false ); + axis.curveAlt.setTrackingActive( true ); + } + else { + out = axis.invert * axis.curve.getValue(pos); + axis.curve.setTrackingActive( true ); + axis.curveAlt.setTrackingActive( false ); + } + out += axis.zero; +} + +/** QThread run method @override **/ +void Tracker::run() { + T6DOF current_camera; // Used for filtering + T6DOF target_camera; + T6DOF new_camera; + + /** Direct Input variables **/ + T6DOF offset_camera; + T6DOF gameoutput_camera; + + bool bTracker1Confid = false; + bool bTracker2Confid = false; + + double newpose[6]; + double last_post_filter[6]; + + forever + { + if (should_quit) + break; + + for (int i = 0; i < 6; i++) + newpose[i] = 0; + + // + // The second tracker serves as 'secondary'. So if an axis is written by the second tracker it CAN be overwritten by the Primary tracker. + // This is enforced by the sequence below. + // + if (Libraries->pSecondTracker) { + bTracker2Confid = Libraries->pSecondTracker->GiveHeadPoseData(newpose); + } + + if (Libraries->pTracker) { + bTracker1Confid = Libraries->pTracker->GiveHeadPoseData(newpose); + } + + { + QMutexLocker foo(&mtx); + const bool confid = bTracker1Confid || bTracker2Confid; + + if ( confid ) { + for (int i = 0; i < 6; i++) + mainApp->axis(i).headPos = newpose[i]; + } + + // + // If Center is pressed, copy the current values to the offsets. + // + if (do_center) { + // + // Only copy valid values + // + for (int i = 0; i < 6; i++) + offset_camera.axes[i] = mainApp->axis(i).headPos; + + Tracker::do_center = false; + + if (Libraries->pTracker) + Libraries->pTracker->NotifyCenter(); + + if (Libraries->pSecondTracker) + Libraries->pSecondTracker->NotifyCenter(); + + if (Libraries->pFilter) + Libraries->pFilter->Initialize(); + } + + if (confid) { + // get values + for (int i = 0; i < 6; i++) + target_camera.axes[i] = mainApp->axis(i).headPos; + + // do the centering + target_camera = target_camera - offset_camera; + + // + // Use advanced filtering, when a filter was selected. + // + if (Libraries->pFilter) { + for (int i = 0; i < 6; i++) + last_post_filter[i] = gameoutput_camera.axes[i]; + Libraries->pFilter->FilterHeadPoseData(current_camera.axes, target_camera.axes, new_camera.axes, last_post_filter); + } + else { + new_camera = target_camera; + } + + for (int i = 0; i < 6; i++) { + get_curve(new_camera.axes[i], output_camera.axes[i], mainApp->axis(i)); + } + + // + // Send the headpose to the game + // + if (Libraries->pProtocol) { + gameoutput_camera = output_camera; + Libraries->pProtocol->sendHeadposeToGame( gameoutput_camera.axes, newpose ); // degrees & centimeters + } + } + } + + //for lower cpu load + msleep(8); + } + + for (int i = 0; i < 6; i++) + { + mainApp->axis(i).curve.setTrackingActive(false); + mainApp->axis(i).curveAlt.setTrackingActive(false); + } +} + +// +// Get the raw headpose, so it can be displayed. +// +void Tracker::getHeadPose( double *data ) { + QMutexLocker foo(&mtx); + for (int i = 0; i < 6; i++) + { + data[i] = mainApp->axis(i).headPos; + } +} + +// +// Get the output-headpose, so it can be displayed. +// +void Tracker::getOutputHeadPose( double *data ) { + QMutexLocker foo(&mtx); + for (int i = 0; i < 6; i++) + data[i] = output_camera.axes[i]; +} + +// +// Load the current Settings from the currently 'active' INI-file. +// +void Tracker::loadSettings() { + qDebug() << "Tracker::loadSettings says: Starting "; + QSettings settings("opentrack"); // 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) + + iniFile.beginGroup("Tracking"); + + qDebug() << "loadSettings says: iniFile = " << currentFile; + + const char* names2[] = { + "zero_tx", + "zero_ty", + "zero_tz", + "zero_rx", + "zero_ry", + "zero_rz" + }; + + for (int i = 0; i < 6; i++) + mainApp->axis(i).zero = iniFile.value(names2[i], 0).toDouble(); + + iniFile.endGroup(); +} + +void Tracker::setInvertAxis(Axis axis, bool invert) { mainApp->axis(axis).invert = invert?-1.0f:1.0f; } diff --git a/facetracknoir/tracker.h b/facetracknoir/tracker.h index 7e2b84cd..eeb18dad 100644 --- a/facetracknoir/tracker.h +++ b/facetracknoir/tracker.h @@ -1,145 +1,145 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of the some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2010 - 2012 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -*********************************************************************************/ -#ifndef __TRACKER_H__ -#define __TRACKER_H__ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "global-settings.h" -#include - -//#define DIRECTINPUT_VERSION 0x0800 -//#include -#undef FTNOIR_PROTOCOL_BASE_LIB -#undef FTNOIR_TRACKER_BASE_LIB -#undef FTNOIR_FILTER_BASE_LIB -#undef FTNOIR_PROTOCOL_BASE_EXPORT -#undef FTNOIR_TRACKER_BASE_EXPORT -#undef FTNOIR_FILTER_BASE_EXPORT -#define FTNOIR_PROTOCOL_BASE_EXPORT Q_DECL_IMPORT -#define FTNOIR_TRACKER_BASE_EXPORT Q_DECL_IMPORT -#define FTNOIR_FILTER_BASE_EXPORT Q_DECL_IMPORT - -#include -#include "ftnoir_tracker_base/ftnoir_tracker_base.h" -#include "ftnoir_protocol_base/ftnoir_protocol_base.h" -#include "ftnoir_filter_base/ftnoir_filter_base.h" -#include "tracker_types.h" - -class FaceTrackNoIR; // pre-define parent-class to avoid circular includes - -// -// Structure to hold all variables concerning one of 6 DOF's -// -class THeadPoseDOF { -private: - THeadPoseDOF(const THeadPoseDOF &) {} -public: - THeadPoseDOF() : - headPos(0), - invert(0), - altp(false), - zero(0) - { - } - - THeadPoseDOF(QString primary, - QString secondary, - int maxInput1, - int maxOutput1, - int maxInput2, - int maxOutput2) : - curve(primary, maxInput1, maxOutput1), - curveAlt(secondary, maxInput2, maxOutput2), - headPos(0), - invert(1), - zero(0) - { - QSettings settings("opentrack"); // Registry settings (in HK_USER) - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); - QSettings iniFile( currentFile, QSettings::IniFormat ); - curve.loadSettings(iniFile); - curveAlt.loadSettings(iniFile); - - iniFile.beginGroup("Tracking"); - altp = iniFile.value(secondary).toBool(); - iniFile.endGroup(); - } - double headPos; // Current position (from faceTracker, radials or meters) - float invert; // Invert measured value (= 1.0f or -1.0f) - FunctionConfig curve; // Function to translate input -> output - FunctionConfig curveAlt; - bool altp; - double zero; -}; - -class Tracker : public QThread { - Q_OBJECT - -private: - FaceTrackNoIR *mainApp; - QMutex mtx; - -protected: - // qthread override run method - void run(); - -public: - Tracker( FaceTrackNoIR *parent ); - ~Tracker(); - void loadSettings(); // Load settings from the INI-file - - void setInvertAxis(Axis axis, bool invert); - - void getHeadPose(double *data); // Return the current headpose data - void getOutputHeadPose(double *data); // Return the current (processed) headpose data - - volatile bool should_quit; - // following are now protected by hTrackMutex - volatile bool do_center; // Center head-position, using the shortkey - - T6DOF output_camera; -}; - -class HeadPoseData { -public: - THeadPoseDOF* axes[6]; - HeadPoseData() - { - axes[TX] = new THeadPoseDOF("tx","tx_alt", 100, 100, 100, 100); - axes[TY] = new THeadPoseDOF("ty","ty_alt", 100, 100, 100, 100); - axes[TZ] = new THeadPoseDOF("tz","tz_alt", 100, 100, 100, 100); - axes[Yaw] = new THeadPoseDOF("rx", "rx_alt", 180, 180, 180, 180); - axes[Pitch] = new THeadPoseDOF("ry", "ry_alt", 90, 90, 90, 90); - axes[Roll] = new THeadPoseDOF("rz", "rz_alt", 180, 180, 180, 180); - } -}; - -#endif +/******************************************************************************** +* FaceTrackNoIR This program is a private project of the some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2010 - 2012 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +*********************************************************************************/ +#ifndef __TRACKER_H__ +#define __TRACKER_H__ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "global-settings.h" +#include + +//#define DIRECTINPUT_VERSION 0x0800 +//#include +#undef FTNOIR_PROTOCOL_BASE_LIB +#undef FTNOIR_TRACKER_BASE_LIB +#undef FTNOIR_FILTER_BASE_LIB +#undef FTNOIR_PROTOCOL_BASE_EXPORT +#undef FTNOIR_TRACKER_BASE_EXPORT +#undef FTNOIR_FILTER_BASE_EXPORT +#define FTNOIR_PROTOCOL_BASE_EXPORT Q_DECL_IMPORT +#define FTNOIR_TRACKER_BASE_EXPORT Q_DECL_IMPORT +#define FTNOIR_FILTER_BASE_EXPORT Q_DECL_IMPORT + +#include +#include "ftnoir_tracker_base/ftnoir_tracker_base.h" +#include "ftnoir_protocol_base/ftnoir_protocol_base.h" +#include "ftnoir_filter_base/ftnoir_filter_base.h" +#include "tracker_types.h" + +class FaceTrackNoIR; // pre-define parent-class to avoid circular includes + +// +// Structure to hold all variables concerning one of 6 DOF's +// +class THeadPoseDOF { +private: + THeadPoseDOF(const THeadPoseDOF &) {} +public: + THeadPoseDOF() : + headPos(0), + invert(0), + altp(false), + zero(0) + { + } + + THeadPoseDOF(QString primary, + QString secondary, + int maxInput1, + int maxOutput1, + int maxInput2, + int maxOutput2) : + curve(primary, maxInput1, maxOutput1), + curveAlt(secondary, maxInput2, maxOutput2), + headPos(0), + invert(1), + zero(0) + { + QSettings settings("opentrack"); // Registry settings (in HK_USER) + QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + QSettings iniFile( currentFile, QSettings::IniFormat ); + curve.loadSettings(iniFile); + curveAlt.loadSettings(iniFile); + + iniFile.beginGroup("Tracking"); + altp = iniFile.value(secondary).toBool(); + iniFile.endGroup(); + } + double headPos; // Current position (from faceTracker, radials or meters) + float invert; // Invert measured value (= 1.0f or -1.0f) + FunctionConfig curve; // Function to translate input -> output + FunctionConfig curveAlt; + bool altp; + double zero; +}; + +class Tracker : public QThread { + Q_OBJECT + +private: + FaceTrackNoIR *mainApp; + QMutex mtx; + +protected: + // qthread override run method + void run(); + +public: + Tracker( FaceTrackNoIR *parent ); + ~Tracker(); + void loadSettings(); // Load settings from the INI-file + + void setInvertAxis(Axis axis, bool invert); + + void getHeadPose(double *data); // Return the current headpose data + void getOutputHeadPose(double *data); // Return the current (processed) headpose data + + volatile bool should_quit; + // following are now protected by hTrackMutex + volatile bool do_center; // Center head-position, using the shortkey + + T6DOF output_camera; +}; + +class HeadPoseData { +public: + THeadPoseDOF* axes[6]; + HeadPoseData() + { + axes[TX] = new THeadPoseDOF("tx","tx_alt", 100, 100, 100, 100); + axes[TY] = new THeadPoseDOF("ty","ty_alt", 100, 100, 100, 100); + axes[TZ] = new THeadPoseDOF("tz","tz_alt", 100, 100, 100, 100); + axes[Yaw] = new THeadPoseDOF("rx", "rx_alt", 180, 180, 180, 180); + axes[Pitch] = new THeadPoseDOF("ry", "ry_alt", 90, 90, 90, 90); + axes[Roll] = new THeadPoseDOF("rz", "rz_alt", 180, 180, 180, 180); + } +}; + +#endif diff --git a/facetracknoir/tracker_types.cpp b/facetracknoir/tracker_types.cpp index 11adc985..da246722 100644 --- a/facetracknoir/tracker_types.cpp +++ b/facetracknoir/tracker_types.cpp @@ -1,44 +1,44 @@ -#include "tracker_types.h" -#include "rotation.h" - -#define PI 3.14159265358979323846264 -#define D2R PI/180.0 -#define R2D 180.0/PI - -T6DOF operator-(const T6DOF& A, const T6DOF& B) -{ - Rotation R_A(A.axes[Yaw]*D2R, A.axes[Pitch]*D2R, A.axes[Roll]*D2R); - Rotation R_B(B.axes[Yaw]*D2R, B.axes[Pitch]*D2R, B.axes[Roll]*D2R); - Rotation R_C = R_A * R_B.inv(); - - T6DOF C; - R_C.toEuler(C.axes[Yaw], C.axes[Pitch], C.axes[Roll]); - C.axes[Yaw] *= R2D; - C.axes[Pitch] *= R2D; - C.axes[Roll] *= R2D; - - C.axes[TX] = A.axes[TX] - B.axes[TX]; - C.axes[TY] = A.axes[TY] - B.axes[TY]; - C.axes[TZ] = A.axes[TZ] - B.axes[TZ]; - //C.frame_number? - return C; -} - -T6DOF operator+(const T6DOF& A, const T6DOF& B) -{ - Rotation R_A(A.axes[Yaw]*D2R, A.axes[Pitch]*D2R, A.axes[Roll]*D2R); - Rotation R_B(B.axes[Yaw]*D2R, B.axes[Pitch]*D2R, B.axes[Roll]*D2R); - Rotation R_C = R_A * R_B; - - T6DOF C; - R_C.toEuler(C.axes[Yaw], C.axes[Pitch], C.axes[Roll]); - C.axes[Yaw] *= R2D; - C.axes[Pitch] *= R2D; - C.axes[Roll] *= R2D; - - C.axes[TX] = A.axes[TX] + B.axes[TX]; - C.axes[TY] = A.axes[TY] + B.axes[TY]; - C.axes[TZ] = A.axes[TZ] + B.axes[TZ]; - //C.frame_number? - return C; -} +#include "tracker_types.h" +#include "rotation.h" + +#define PI 3.14159265358979323846264 +#define D2R PI/180.0 +#define R2D 180.0/PI + +T6DOF operator-(const T6DOF& A, const T6DOF& B) +{ + Rotation R_A(A.axes[Yaw]*D2R, A.axes[Pitch]*D2R, A.axes[Roll]*D2R); + Rotation R_B(B.axes[Yaw]*D2R, B.axes[Pitch]*D2R, B.axes[Roll]*D2R); + Rotation R_C = R_A * R_B.inv(); + + T6DOF C; + R_C.toEuler(C.axes[Yaw], C.axes[Pitch], C.axes[Roll]); + C.axes[Yaw] *= R2D; + C.axes[Pitch] *= R2D; + C.axes[Roll] *= R2D; + + C.axes[TX] = A.axes[TX] - B.axes[TX]; + C.axes[TY] = A.axes[TY] - B.axes[TY]; + C.axes[TZ] = A.axes[TZ] - B.axes[TZ]; + //C.frame_number? + return C; +} + +T6DOF operator+(const T6DOF& A, const T6DOF& B) +{ + Rotation R_A(A.axes[Yaw]*D2R, A.axes[Pitch]*D2R, A.axes[Roll]*D2R); + Rotation R_B(B.axes[Yaw]*D2R, B.axes[Pitch]*D2R, B.axes[Roll]*D2R); + Rotation R_C = R_A * R_B; + + T6DOF C; + R_C.toEuler(C.axes[Yaw], C.axes[Pitch], C.axes[Roll]); + C.axes[Yaw] *= R2D; + C.axes[Pitch] *= R2D; + C.axes[Roll] *= R2D; + + C.axes[TX] = A.axes[TX] + B.axes[TX]; + C.axes[TY] = A.axes[TY] + B.axes[TY]; + C.axes[TZ] = A.axes[TZ] + B.axes[TZ]; + //C.frame_number? + return C; +} diff --git a/facetracknoir/tracker_types.h b/facetracknoir/tracker_types.h index ebd89e7c..54d1841e 100644 --- a/facetracknoir/tracker_types.h +++ b/facetracknoir/tracker_types.h @@ -1,41 +1,41 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of the some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2010 - 2012 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -*********************************************************************************/ -#ifndef __TRACKER_TYPES_H__ -#define __TRACKER_TYPES_H__ - -#include "ftnoir_tracker_base/ftnoir_tracker_types.h" - -struct T6DOF { -public: - double axes[6]; - - T6DOF() { - for (int i = 0; i < 6; i++) - axes[i] = 0; - } -}; - -T6DOF operator-(const T6DOF& A, const T6DOF& B); // get new pose with respect to reference pose B -T6DOF operator+(const T6DOF& A, const T6DOF& B); // get new pose with respect to reference pose B^-1 - -#endif //__TRACKER_TYPES_H__ +/******************************************************************************** +* FaceTrackNoIR This program is a private project of the some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2010 - 2012 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +*********************************************************************************/ +#ifndef __TRACKER_TYPES_H__ +#define __TRACKER_TYPES_H__ + +#include "ftnoir_tracker_base/ftnoir_tracker_types.h" + +struct T6DOF { +public: + double axes[6]; + + T6DOF() { + for (int i = 0; i < 6; i++) + axes[i] = 0; + } +}; + +T6DOF operator-(const T6DOF& A, const T6DOF& B); // get new pose with respect to reference pose B +T6DOF operator+(const T6DOF& A, const T6DOF& B); // get new pose with respect to reference pose B^-1 + +#endif //__TRACKER_TYPES_H__ diff --git a/freetrackclient/ftclient.h b/freetrackclient/ftclient.h index 406e1237..5e5d8747 100644 --- a/freetrackclient/ftclient.h +++ b/freetrackclient/ftclient.h @@ -1,30 +1,30 @@ -/** @file - @brief -*/ -#pragma once -#ifndef INCLUDED_FTCLIENT_H -#define INCLUDED_FTCLIENT_H - - - - - - -#include "Windows.h" -#include "SysUtils.h" -#include "FTTypes.h" - -/*__stdcall*/ bool FTGetData(PFreetrackData data); -/*__stdcall*/ void FTReportName(PAnsiChar name); -/*__stdcall*/ char* FTGetDllVersion(); -/*__stdcall*/ char* FTProvider(); - - -bool OpenMapping(); -void DestroyMapping(); - - - - -#endif//INCLUDED_FTCLIENT_H -//END +/** @file + @brief +*/ +#pragma once +#ifndef INCLUDED_FTCLIENT_H +#define INCLUDED_FTCLIENT_H + + + + + + +#include "Windows.h" +#include "SysUtils.h" +#include "FTTypes.h" + +/*__stdcall*/ bool FTGetData(PFreetrackData data); +/*__stdcall*/ void FTReportName(PAnsiChar name); +/*__stdcall*/ char* FTGetDllVersion(); +/*__stdcall*/ char* FTProvider(); + + +bool OpenMapping(); +void DestroyMapping(); + + + + +#endif//INCLUDED_FTCLIENT_H +//END diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.cpp b/ftnoir_filter_accela/ftnoir_filter_accela.cpp index c2cda351..0b3d6518 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela.cpp @@ -1,90 +1,90 @@ -/* Copyright (c) 2012 Stanislaw Halik - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - */ -#include "ftnoir_filter_accela/ftnoir_filter_accela.h" -#include -#include -#include -#include "facetracknoir/global-settings.h" - -using namespace std; - -FTNoIR_Filter::FTNoIR_Filter() -{ - first_run = true; - loadSettings(); -} - -FTNoIR_Filter::~FTNoIR_Filter() -{ - -} - -void FTNoIR_Filter::loadSettings() { - QSettings settings("opentrack"); // 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) - - iniFile.beginGroup ( "Accela" ); - zoom_factor = iniFile.value("zoom-slowness", 0).toDouble(); - rotation_alpha = iniFile.value("rotation-alpha", ACCELA_SMOOTHING_ROTATION).toDouble(); - translation_alpha = iniFile.value("translation-alpha", ACCELA_SMOOTHING_TRANSLATION).toDouble(); - 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; - return a1 * x * x; -} - -void FTNoIR_Filter::FilterHeadPoseData(double *current_camera_position, - double *target_camera_position, - double *new_camera_position, - double *last_post_filter_values) -{ - if (first_run) - { - for (int i = 0; i < 6; i++) - { - new_camera_position[i] = target_camera_position[i]; - current_camera_position[i] = target_camera_position[i]; - } - - first_run = false; - return; - } - - QMutexLocker foo(&mutex); - - for (int i=0;i<6;i++) - { - const double vec = target_camera_position[i] - current_camera_position[i]; - const int sign = vec < 0 ? -1 : 1; - const double x = fabs(vec); - const double a = i >= 3 ? rotation_alpha : translation_alpha; - const double reduction = 1. / std::max(1., 1. + zoom_factor * -last_post_filter_values[TZ] / 1000); - const double velocity = parabola(a, x) * reduction; - const double result = current_camera_position[i] + velocity * sign; - const bool done = sign > 0 ? result >= target_camera_position[i] : result <= target_camera_position[i]; - new_camera_position[i] = current_camera_position[i] = done ? target_camera_position[i] : result; - } -} - -extern "C" FTNOIR_FILTER_BASE_EXPORT IFilter* CALLING_CONVENTION GetConstructor() -{ - return new FTNoIR_Filter; -} +/* Copyright (c) 2012 Stanislaw Halik + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + */ +#include "ftnoir_filter_accela/ftnoir_filter_accela.h" +#include +#include +#include +#include "facetracknoir/global-settings.h" + +using namespace std; + +FTNoIR_Filter::FTNoIR_Filter() +{ + first_run = true; + loadSettings(); +} + +FTNoIR_Filter::~FTNoIR_Filter() +{ + +} + +void FTNoIR_Filter::loadSettings() { + QSettings settings("opentrack"); // 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) + + iniFile.beginGroup ( "Accela" ); + zoom_factor = iniFile.value("zoom-slowness", 0).toDouble(); + rotation_alpha = iniFile.value("rotation-alpha", ACCELA_SMOOTHING_ROTATION).toDouble(); + translation_alpha = iniFile.value("translation-alpha", ACCELA_SMOOTHING_TRANSLATION).toDouble(); + 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; + return a1 * x * x; +} + +void FTNoIR_Filter::FilterHeadPoseData(double *current_camera_position, + double *target_camera_position, + double *new_camera_position, + double *last_post_filter_values) +{ + if (first_run) + { + for (int i = 0; i < 6; i++) + { + new_camera_position[i] = target_camera_position[i]; + current_camera_position[i] = target_camera_position[i]; + } + + first_run = false; + return; + } + + QMutexLocker foo(&mutex); + + for (int i=0;i<6;i++) + { + const double vec = target_camera_position[i] - current_camera_position[i]; + const int sign = vec < 0 ? -1 : 1; + const double x = fabs(vec); + const double a = i >= 3 ? rotation_alpha : translation_alpha; + const double reduction = 1. / std::max(1., 1. + zoom_factor * -last_post_filter_values[TZ] / 1000); + const double velocity = parabola(a, x) * reduction; + const double result = current_camera_position[i] + velocity * sign; + const bool done = sign > 0 ? result >= target_camera_position[i] : result <= target_camera_position[i]; + new_camera_position[i] = current_camera_position[i] = done ? target_camera_position[i] : result; + } +} + +extern "C" FTNOIR_FILTER_BASE_EXPORT IFilter* CALLING_CONVENTION GetConstructor() +{ + return new FTNoIR_Filter; +} diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.h b/ftnoir_filter_accela/ftnoir_filter_accela.h index 0c13c0e8..49b551e7 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.h +++ b/ftnoir_filter_accela/ftnoir_filter_accela.h @@ -1,107 +1,107 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2012 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -********************************************************************************/ -#pragma once -#ifndef INCLUDED_FTN_FILTER_H -#define INCLUDED_FTN_FILTER_H - -#undef FTNOIR_TRACKER_BASE_LIB -#define FTNOIR_TRACKER_BASE_EXPORT Q_DECL_IMPORT - -#include "ftnoir_filter_base/ftnoir_filter_base.h" -#include "ui_ftnoir_accela_filtercontrols.h" -#include "facetracknoir/global-settings.h" -#include - -#define ACCELA_SMOOTHING_ROTATION 6.0 -#define ACCELA_SMOOTHING_TRANSLATION 3.0 - -//******************************************************************************************************* -// FaceTrackNoIR Filter class. -//******************************************************************************************************* -class FTNOIR_FILTER_BASE_EXPORT FTNoIR_Filter : public IFilter -{ -public: - FTNoIR_Filter(); - ~FTNoIR_Filter(); - void FilterHeadPoseData(double *current_camera_position, double *target_camera_position, double *new_camera_position, double *last_post_filter_values); - void Initialize() { - first_run = true; - } - void receiveSettings(double rot, double trans, double zoom_fac); -private: - QMutex mutex; - void loadSettings(); - bool first_run; - double rotation_alpha, translation_alpha, zoom_factor; -}; - -//******************************************************************************************************* -// FaceTrackNoIR Filter Settings-dialog. -//******************************************************************************************************* - -// Widget that has controls for FTNoIR protocol filter-settings. -class FTNOIR_FILTER_BASE_EXPORT FilterControls: public QWidget, public IFilterDialog -{ - Q_OBJECT -public: - explicit FilterControls(); - virtual ~FilterControls(); - void showEvent ( QShowEvent * event ); - 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(); - void settingChanged(bool) { settingsDirty = true; } - void settingChanged(int) { settingsDirty = true; } -}; - -//******************************************************************************************************* -// FaceTrackNoIR Filter DLL. Functions used to get general info on the Filter -//******************************************************************************************************* -class FTNoIR_FilterDll : public Metadata -{ -public: - FTNoIR_FilterDll(); - ~FTNoIR_FilterDll(); - - void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("Accela Filter Mk3"); } - void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("Accela Mk3"); } - void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("Accela filter Mk3"); } - - void getIcon(QIcon *icon){ *icon = QIcon(":/images/filter-16.png"); } -}; - - -#endif //INCLUDED_FTN_FILTER_H -//END - +/******************************************************************************** +* FaceTrackNoIR This program is a private project of some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2012 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +********************************************************************************/ +#pragma once +#ifndef INCLUDED_FTN_FILTER_H +#define INCLUDED_FTN_FILTER_H + +#undef FTNOIR_TRACKER_BASE_LIB +#define FTNOIR_TRACKER_BASE_EXPORT Q_DECL_IMPORT + +#include "ftnoir_filter_base/ftnoir_filter_base.h" +#include "ui_ftnoir_accela_filtercontrols.h" +#include "facetracknoir/global-settings.h" +#include + +#define ACCELA_SMOOTHING_ROTATION 6.0 +#define ACCELA_SMOOTHING_TRANSLATION 3.0 + +//******************************************************************************************************* +// FaceTrackNoIR Filter class. +//******************************************************************************************************* +class FTNOIR_FILTER_BASE_EXPORT FTNoIR_Filter : public IFilter +{ +public: + FTNoIR_Filter(); + ~FTNoIR_Filter(); + void FilterHeadPoseData(double *current_camera_position, double *target_camera_position, double *new_camera_position, double *last_post_filter_values); + void Initialize() { + first_run = true; + } + void receiveSettings(double rot, double trans, double zoom_fac); +private: + QMutex mutex; + void loadSettings(); + bool first_run; + double rotation_alpha, translation_alpha, zoom_factor; +}; + +//******************************************************************************************************* +// FaceTrackNoIR Filter Settings-dialog. +//******************************************************************************************************* + +// Widget that has controls for FTNoIR protocol filter-settings. +class FTNOIR_FILTER_BASE_EXPORT FilterControls: public QWidget, public IFilterDialog +{ + Q_OBJECT +public: + explicit FilterControls(); + virtual ~FilterControls(); + void showEvent ( QShowEvent * event ); + 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(); + void settingChanged(bool) { settingsDirty = true; } + void settingChanged(int) { settingsDirty = true; } +}; + +//******************************************************************************************************* +// FaceTrackNoIR Filter DLL. Functions used to get general info on the Filter +//******************************************************************************************************* +class FTNoIR_FilterDll : public Metadata +{ +public: + FTNoIR_FilterDll(); + ~FTNoIR_FilterDll(); + + void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("Accela Filter Mk3"); } + void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("Accela Mk3"); } + void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("Accela filter Mk3"); } + + void getIcon(QIcon *icon){ *icon = QIcon(":/images/filter-16.png"); } +}; + + +#endif //INCLUDED_FTN_FILTER_H +//END + diff --git a/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp b/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp index 8c7cd386..3e74ad81 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp @@ -1,190 +1,190 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2013 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -********************************************************************************/ -#include "ftnoir_filter_accela/ftnoir_filter_accela.h" -#include -#include -#include -#include "facetracknoir/global-settings.h" - -//******************************************************************************************************* -// FaceTrackNoIR Filter Settings-dialog. -//******************************************************************************************************* -// -// Constructor for server-settings-dialog -// -FilterControls::FilterControls() : - QWidget(), accela_filter(NULL) -{ - ui.setupUi( this ); - - // Load the settings from the current .INI-file - loadSettings(); - connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); - connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); - connect(ui.rotation_alpha, SIGNAL(valueChanged(double)), this, SLOT(settingChanged(int))); - connect(ui.translation_alpha, SIGNAL(valueChanged(double)), this, SLOT(settingChanged(int))); - - connect(ui.slideZoom, SIGNAL(valueChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.spinZoom, SIGNAL(valueChanged(int)), this, SLOT(settingChanged(int))); - - qDebug() << "FilterControls() says: started"; -} - -// -// Destructor for server-dialog -// -FilterControls::~FilterControls() { - qDebug() << "~FilterControls() says: started"; -} - -// -// Initialize tracker-client-dialog -// -void FilterControls::Initialize(QWidget *parent) { - loadSettings(); - - QPoint offsetpos(100, 100); - if (parent) { - this->move(parent->pos() + offsetpos); - } - show(); -} - -void FilterControls::registerFilter(IFilter* filter) -{ - accela_filter = (FTNoIR_Filter*) filter; -} - -void FilterControls::unregisterFilter() -{ - accela_filter = NULL; -} - -// -// OK clicked on server-dialog -// -void FilterControls::doOK() { - save(); - this->close(); -} - -// override show event -void FilterControls::showEvent ( QShowEvent * event ) { -} - -// -// Cancel clicked on server-dialog -// -void FilterControls::doCancel() { - // - // Ask if changed Settings should be saved - // - if (settingsDirty) { - int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard ); - - qDebug() << "doCancel says: answer =" << ret; - - switch (ret) { - case QMessageBox::Save: - save(); - this->close(); - break; - case QMessageBox::Discard: - this->close(); - break; - case QMessageBox::Cancel: - // Cancel was clicked - break; - default: - // should never be reached - break; - } - } - else { - this->close(); - } -} - -// -// Load the current Settings from the currently 'active' INI-file. -// -void FilterControls::loadSettings() { - QSettings settings("opentrack"); // 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::loadSettings2 says: iniFile = " << currentFile; - - //qDebug() << "FTNoIR_Filter::loadSettings2 says: size = " << NUM_OF(defScaleRotation); - - iniFile.beginGroup ( "Accela" ); - ui.slideZoom->setValue(iniFile.value("zoom-slowness", 0).toInt()); - ui.spinZoom->setValue(iniFile.value("zoom-slowness", 0).toInt()); - ui.rotation_alpha->setValue(iniFile.value("rotation-alpha", ACCELA_SMOOTHING_ROTATION).toDouble()); - ui.translation_alpha->setValue(iniFile.value("translation-alpha", ACCELA_SMOOTHING_TRANSLATION).toDouble()); - iniFile.endGroup (); - - settingsDirty = false; -} - -// -// Save the current Settings to the currently 'active' INI-file. -// -void FilterControls::save() { - QSettings settings("opentrack"); // 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::save() says: iniFile = " << currentFile; - - double rot, trans, zoom; - - iniFile.beginGroup ( "Accela" ); - 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); -} - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Filter-settings dialog object. - -// Export both decorated and undecorated names. -// GetFilterDialog - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetFilterDialog@0 - Common name decoration for __stdcall functions in C language. -//#pragma comment(linker, "/export:GetFilterDialog=_GetFilterDialog@0") - -extern "C" FTNOIR_FILTER_BASE_EXPORT IFilterDialog* CALLING_CONVENTION GetDialog() -{ - return new FilterControls; -} +/******************************************************************************** +* FaceTrackNoIR This program is a private project of some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2013 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +********************************************************************************/ +#include "ftnoir_filter_accela/ftnoir_filter_accela.h" +#include +#include +#include +#include "facetracknoir/global-settings.h" + +//******************************************************************************************************* +// FaceTrackNoIR Filter Settings-dialog. +//******************************************************************************************************* +// +// Constructor for server-settings-dialog +// +FilterControls::FilterControls() : + QWidget(), accela_filter(NULL) +{ + ui.setupUi( this ); + + // Load the settings from the current .INI-file + loadSettings(); + connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); + connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); + connect(ui.rotation_alpha, SIGNAL(valueChanged(double)), this, SLOT(settingChanged(int))); + connect(ui.translation_alpha, SIGNAL(valueChanged(double)), this, SLOT(settingChanged(int))); + + connect(ui.slideZoom, SIGNAL(valueChanged(int)), this, SLOT(settingChanged(int))); + connect(ui.spinZoom, SIGNAL(valueChanged(int)), this, SLOT(settingChanged(int))); + + qDebug() << "FilterControls() says: started"; +} + +// +// Destructor for server-dialog +// +FilterControls::~FilterControls() { + qDebug() << "~FilterControls() says: started"; +} + +// +// Initialize tracker-client-dialog +// +void FilterControls::Initialize(QWidget *parent) { + loadSettings(); + + QPoint offsetpos(100, 100); + if (parent) { + this->move(parent->pos() + offsetpos); + } + show(); +} + +void FilterControls::registerFilter(IFilter* filter) +{ + accela_filter = (FTNoIR_Filter*) filter; +} + +void FilterControls::unregisterFilter() +{ + accela_filter = NULL; +} + +// +// OK clicked on server-dialog +// +void FilterControls::doOK() { + save(); + this->close(); +} + +// override show event +void FilterControls::showEvent ( QShowEvent * event ) { +} + +// +// Cancel clicked on server-dialog +// +void FilterControls::doCancel() { + // + // Ask if changed Settings should be saved + // + if (settingsDirty) { + int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard ); + + qDebug() << "doCancel says: answer =" << ret; + + switch (ret) { + case QMessageBox::Save: + save(); + this->close(); + break; + case QMessageBox::Discard: + this->close(); + break; + case QMessageBox::Cancel: + // Cancel was clicked + break; + default: + // should never be reached + break; + } + } + else { + this->close(); + } +} + +// +// Load the current Settings from the currently 'active' INI-file. +// +void FilterControls::loadSettings() { + QSettings settings("opentrack"); // 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::loadSettings2 says: iniFile = " << currentFile; + + //qDebug() << "FTNoIR_Filter::loadSettings2 says: size = " << NUM_OF(defScaleRotation); + + iniFile.beginGroup ( "Accela" ); + ui.slideZoom->setValue(iniFile.value("zoom-slowness", 0).toInt()); + ui.spinZoom->setValue(iniFile.value("zoom-slowness", 0).toInt()); + ui.rotation_alpha->setValue(iniFile.value("rotation-alpha", ACCELA_SMOOTHING_ROTATION).toDouble()); + ui.translation_alpha->setValue(iniFile.value("translation-alpha", ACCELA_SMOOTHING_TRANSLATION).toDouble()); + iniFile.endGroup (); + + settingsDirty = false; +} + +// +// Save the current Settings to the currently 'active' INI-file. +// +void FilterControls::save() { + QSettings settings("opentrack"); // 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::save() says: iniFile = " << currentFile; + + double rot, trans, zoom; + + iniFile.beginGroup ( "Accela" ); + 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); +} + +//////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Filter-settings dialog object. + +// Export both decorated and undecorated names. +// GetFilterDialog - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetFilterDialog@0 - Common name decoration for __stdcall functions in C language. +//#pragma comment(linker, "/export:GetFilterDialog=_GetFilterDialog@0") + +extern "C" FTNOIR_FILTER_BASE_EXPORT IFilterDialog* CALLING_CONVENTION GetDialog() +{ + return new FilterControls; +} diff --git a/ftnoir_filter_accela/ftnoir_filter_accela_dll.cpp b/ftnoir_filter_accela/ftnoir_filter_accela_dll.cpp index 0235c067..d4a11028 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela_dll.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela_dll.cpp @@ -1,39 +1,39 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2012 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -********************************************************************************/ -#include "ftnoir_filter_accela.h" -#include "facetracknoir/global-settings.h" - -FTNoIR_FilterDll::FTNoIR_FilterDll() { -} - -FTNoIR_FilterDll::~FTNoIR_FilterDll() -{ - -} - -extern "C" FTNOIR_FILTER_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata() -{ - return new FTNoIR_FilterDll; -} +/******************************************************************************** +* FaceTrackNoIR This program is a private project of some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2012 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +********************************************************************************/ +#include "ftnoir_filter_accela.h" +#include "facetracknoir/global-settings.h" + +FTNoIR_FilterDll::FTNoIR_FilterDll() { +} + +FTNoIR_FilterDll::~FTNoIR_FilterDll() +{ + +} + +extern "C" FTNOIR_FILTER_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata() +{ + return new FTNoIR_FilterDll; +} diff --git a/ftnoir_filter_base/ftnoir_filter_base.h b/ftnoir_filter_base/ftnoir_filter_base.h index 9ff286b1..49454a7e 100644 --- a/ftnoir_filter_base/ftnoir_filter_base.h +++ b/ftnoir_filter_base/ftnoir_filter_base.h @@ -1,41 +1,41 @@ -#ifndef FTNOIR_FILTER_BASE_H -#define FTNOIR_FILTER_BASE_H - -#include "ftnoir_filter_base_global.h" -#include "ftnoir_tracker_base/ftnoir_tracker_base.h" -#include -#include -#include -#include -#include -#include - -//////////////////////////////////////////////////////////////////////////////// -#ifdef __cplusplus -# define EXTERN_C extern "C" -#else -# define EXTERN_C -#endif // __cplusplus - -//////////////////////////////////////////////////////////////////////////////// -// COM-Like abstract interface. -// This interface doesn't require __declspec(dllexport/dllimport) specifier. -// Method calls are dispatched via virtual table. -// Any C++ compiler can use it. -// Instances are obtained via factory function. -struct IFilter -{ - virtual ~IFilter() {} - virtual void FilterHeadPoseData(double *current_camera_position, double *target_camera_position, double *new_camera_position, double *last_post_filter) = 0; - virtual void Initialize() = 0; -}; - -struct IFilterDialog -{ - virtual ~IFilterDialog() {} - virtual void Initialize(QWidget *parent) = 0; - virtual void registerFilter(IFilter* tracker) = 0; - virtual void unregisterFilter() = 0; -}; - -#endif // FTNOIR_FILTER_BASE_H +#ifndef FTNOIR_FILTER_BASE_H +#define FTNOIR_FILTER_BASE_H + +#include "ftnoir_filter_base_global.h" +#include "ftnoir_tracker_base/ftnoir_tracker_base.h" +#include +#include +#include +#include +#include +#include + +//////////////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +# define EXTERN_C extern "C" +#else +# define EXTERN_C +#endif // __cplusplus + +//////////////////////////////////////////////////////////////////////////////// +// COM-Like abstract interface. +// This interface doesn't require __declspec(dllexport/dllimport) specifier. +// Method calls are dispatched via virtual table. +// Any C++ compiler can use it. +// Instances are obtained via factory function. +struct IFilter +{ + virtual ~IFilter() {} + virtual void FilterHeadPoseData(double *current_camera_position, double *target_camera_position, double *new_camera_position, double *last_post_filter) = 0; + virtual void Initialize() = 0; +}; + +struct IFilterDialog +{ + virtual ~IFilterDialog() {} + 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_base/ftnoir_filter_base_global.h b/ftnoir_filter_base/ftnoir_filter_base_global.h index a923f6cf..02733ace 100644 --- a/ftnoir_filter_base/ftnoir_filter_base_global.h +++ b/ftnoir_filter_base/ftnoir_filter_base_global.h @@ -1,12 +1,12 @@ -#ifndef FTNOIR_FILTER_BASE_GLOBAL_H -#define FTNOIR_FILTER_BASE_GLOBAL_H - -#include - -#ifdef FTNOIR_FILTER_BASE_LIB -# define FTNOIR_FILTER_BASE_EXPORT Q_DECL_EXPORT -#else -# define FTNOIR_FILTER_BASE_EXPORT Q_DECL_IMPORT -#endif - -#endif // FTNOIR_FILTER_BASE_GLOBAL_H +#ifndef FTNOIR_FILTER_BASE_GLOBAL_H +#define FTNOIR_FILTER_BASE_GLOBAL_H + +#include + +#ifdef FTNOIR_FILTER_BASE_LIB +# define FTNOIR_FILTER_BASE_EXPORT Q_DECL_EXPORT +#else +# define FTNOIR_FILTER_BASE_EXPORT Q_DECL_IMPORT +#endif + +#endif // FTNOIR_FILTER_BASE_GLOBAL_H diff --git a/ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp b/ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp index 43cfd102..b127c665 100644 --- a/ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp +++ b/ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp @@ -1,173 +1,173 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2012 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -********************************************************************************/ -#include "ftnoir_filter_ewma2.h" -#include "math.h" -#include -#include -#include "facetracknoir/global-settings.h" -#include -#include -//#define LOG_OUTPUT - -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// -// EWMA Filter: Exponentially Weighted Moving Average filter with dynamic smoothing parameter -// -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -FTNoIR_Filter::FTNoIR_Filter() -{ - first_run = true; - alpha_smoothing = 0.02f; // this is a constant for now, might be a parameter later - loadSettings(); // Load the Settings -} - -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. -// -void FTNoIR_Filter::loadSettings() { - qDebug() << "FTNoIR_Filter::loadSettings says: Starting "; - QSettings settings("opentrack"); // 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::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" ); - kMinSmoothing = iniFile.value ( "minSmooth", 15 ).toInt(); - kMaxSmoothing = iniFile.value ( "maxSmooth", 50 ).toInt(); - kSmoothingScaleCurve = iniFile.value ( "powCurve", 10 ).toInt(); - iniFile.endGroup (); -} - -void FTNoIR_Filter::FilterHeadPoseData(double *current_camera_position, - double *target_camera_position, - double *new_camera_position, - double *last_post_filter) -{ - double delta; - double new_alpha; - double scale[]={0.025f,0.025f,0.025f,6.0f,6.0f,6.0f}; - - //On the first run, initialize to output=target and return. - if (first_run==true) { - for (int i=0;i<6;i++) { - new_camera_position[i] = target_camera_position[i]; - current_camera_position[i] = target_camera_position[i]; - alpha[i] = 0.0f; - } - first_run=false; - return; - } - - QMutexLocker foo(&mutex); - - for (int i=0;i<6;i++) { - // Calculate the delta. - delta=target_camera_position[i]-current_camera_position[i]; - // Normalise the delta. - delta=std::min(std::max(fabs(delta)/scale[i],0.0),1.0); - // Calculate the new alpha from the normalized delta. - new_alpha=1.0/(kMinSmoothing+((1.0-pow(delta,kSmoothingScaleCurve))*(kMaxSmoothing-kMinSmoothing))); - // Update the smoothed alpha. - alpha[i]=(alpha_smoothing*new_alpha)+((1.0f-alpha_smoothing)*alpha[i]); - } - - // Use the same (largest) smoothed alpha for each channel - //NB: larger alpha = *less* lag (opposite to what you'd expect) - float largest_alpha=0.0f; - for (int i=0;i<6;i++) { - largest_alpha=std::max(largest_alpha, alpha[i]); - } - - // Calculate the new camera position. - for (int i=0;i<6;i++) { - new_camera_position[i]=(largest_alpha*target_camera_position[i])+((1.0f-largest_alpha)*current_camera_position[i]); - //new_camera_position[i]=(alpha[i]*target_camera_position[i])+((1.0f-alpha[i])*current_camera_position[i]); - } - -#ifdef LOG_OUTPUT - // Use this for some debug-output to file... - QFile data(QCoreApplication::applicationDirPath() + "\\EWMA_output.txt"); - if (data.open(QFile::WriteOnly | QFile::Append)) { - QTextStream out(&data); - out << "current:\t" << current_camera_position[0] - << "\t" << current_camera_position[1] - << "\t" << current_camera_position[2] - << "\t" << current_camera_position[3] - << "\t" << current_camera_position[4] - << "\t" << current_camera_position[5] << '\n'; - out << "target:\t" << target_camera_position[0] - << "\t" << target_camera_position[1] - << "\t" << target_camera_position[2] - << "\t" << target_camera_position[3] - << "\t" << target_camera_position[4] - << "\t" << target_camera_position[5] << '\n'; - out << "output:\t" << new_camera_position[0] - << "\t" << new_camera_position[1] - << "\t" << new_camera_position[2] - << "\t" << new_camera_position[3] - << "\t" << new_camera_position[4] - << "\t" << new_camera_position[5] << '\n'; - out << "largest_alpha:\t" << largest_alpha << '\n'; - } -#endif - - // Update the current camera position to the new position. - for (int i = 0; i < 6; i++) { - current_camera_position[i] = new_camera_position[i]; - } -} - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Filter object. - -// Export both decorated and undecorated names. -// GetFilter - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetFilter@0 - Common name decoration for __stdcall functions in C language. -//#pragma comment(linker, "/export:GetFilter=_GetFilter@0") - -extern "C" FTNOIR_FILTER_BASE_EXPORT IFilter* CALLING_CONVENTION GetConstructor() -{ - return new FTNoIR_Filter; -} +/******************************************************************************** +* FaceTrackNoIR This program is a private project of some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2012 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +********************************************************************************/ +#include "ftnoir_filter_ewma2.h" +#include "math.h" +#include +#include +#include "facetracknoir/global-settings.h" +#include +#include +//#define LOG_OUTPUT + +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// +// EWMA Filter: Exponentially Weighted Moving Average filter with dynamic smoothing parameter +// +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +FTNoIR_Filter::FTNoIR_Filter() +{ + first_run = true; + alpha_smoothing = 0.02f; // this is a constant for now, might be a parameter later + loadSettings(); // Load the Settings +} + +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. +// +void FTNoIR_Filter::loadSettings() { + qDebug() << "FTNoIR_Filter::loadSettings says: Starting "; + QSettings settings("opentrack"); // 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::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" ); + kMinSmoothing = iniFile.value ( "minSmooth", 15 ).toInt(); + kMaxSmoothing = iniFile.value ( "maxSmooth", 50 ).toInt(); + kSmoothingScaleCurve = iniFile.value ( "powCurve", 10 ).toInt(); + iniFile.endGroup (); +} + +void FTNoIR_Filter::FilterHeadPoseData(double *current_camera_position, + double *target_camera_position, + double *new_camera_position, + double *last_post_filter) +{ + double delta; + double new_alpha; + double scale[]={0.025f,0.025f,0.025f,6.0f,6.0f,6.0f}; + + //On the first run, initialize to output=target and return. + if (first_run==true) { + for (int i=0;i<6;i++) { + new_camera_position[i] = target_camera_position[i]; + current_camera_position[i] = target_camera_position[i]; + alpha[i] = 0.0f; + } + first_run=false; + return; + } + + QMutexLocker foo(&mutex); + + for (int i=0;i<6;i++) { + // Calculate the delta. + delta=target_camera_position[i]-current_camera_position[i]; + // Normalise the delta. + delta=std::min(std::max(fabs(delta)/scale[i],0.0),1.0); + // Calculate the new alpha from the normalized delta. + new_alpha=1.0/(kMinSmoothing+((1.0-pow(delta,kSmoothingScaleCurve))*(kMaxSmoothing-kMinSmoothing))); + // Update the smoothed alpha. + alpha[i]=(alpha_smoothing*new_alpha)+((1.0f-alpha_smoothing)*alpha[i]); + } + + // Use the same (largest) smoothed alpha for each channel + //NB: larger alpha = *less* lag (opposite to what you'd expect) + float largest_alpha=0.0f; + for (int i=0;i<6;i++) { + largest_alpha=std::max(largest_alpha, alpha[i]); + } + + // Calculate the new camera position. + for (int i=0;i<6;i++) { + new_camera_position[i]=(largest_alpha*target_camera_position[i])+((1.0f-largest_alpha)*current_camera_position[i]); + //new_camera_position[i]=(alpha[i]*target_camera_position[i])+((1.0f-alpha[i])*current_camera_position[i]); + } + +#ifdef LOG_OUTPUT + // Use this for some debug-output to file... + QFile data(QCoreApplication::applicationDirPath() + "\\EWMA_output.txt"); + if (data.open(QFile::WriteOnly | QFile::Append)) { + QTextStream out(&data); + out << "current:\t" << current_camera_position[0] + << "\t" << current_camera_position[1] + << "\t" << current_camera_position[2] + << "\t" << current_camera_position[3] + << "\t" << current_camera_position[4] + << "\t" << current_camera_position[5] << '\n'; + out << "target:\t" << target_camera_position[0] + << "\t" << target_camera_position[1] + << "\t" << target_camera_position[2] + << "\t" << target_camera_position[3] + << "\t" << target_camera_position[4] + << "\t" << target_camera_position[5] << '\n'; + out << "output:\t" << new_camera_position[0] + << "\t" << new_camera_position[1] + << "\t" << new_camera_position[2] + << "\t" << new_camera_position[3] + << "\t" << new_camera_position[4] + << "\t" << new_camera_position[5] << '\n'; + out << "largest_alpha:\t" << largest_alpha << '\n'; + } +#endif + + // Update the current camera position to the new position. + for (int i = 0; i < 6; i++) { + current_camera_position[i] = new_camera_position[i]; + } +} + +//////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Filter object. + +// Export both decorated and undecorated names. +// GetFilter - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetFilter@0 - Common name decoration for __stdcall functions in C language. +//#pragma comment(linker, "/export:GetFilter=_GetFilter@0") + +extern "C" FTNOIR_FILTER_BASE_EXPORT IFilter* CALLING_CONVENTION GetConstructor() +{ + return new FTNoIR_Filter; +} diff --git a/ftnoir_filter_ewma2/ftnoir_filter_ewma2.h b/ftnoir_filter_ewma2/ftnoir_filter_ewma2.h index 18fec8d4..91f32816 100644 --- a/ftnoir_filter_ewma2/ftnoir_filter_ewma2.h +++ b/ftnoir_filter_ewma2/ftnoir_filter_ewma2.h @@ -1,116 +1,116 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2012 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -********************************************************************************/ -#pragma once -#ifndef INCLUDED_FTN_FILTER_H -#define INCLUDED_FTN_FILTER_H - -#include "ftnoir_filter_base/ftnoir_filter_base.h" -#include "facetracknoir/global-settings.h" -#include "ui_ftnoir_ewma_filtercontrols.h" -#include -#include - -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// -// EWMA Filter: Exponentially Weighted Moving Average filter with dynamic smoothing parameter -// -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -class FTNoIR_Filter : public IFilter -{ -public: - FTNoIR_Filter(); - ~FTNoIR_Filter(); - void Initialize() {} - - void FilterHeadPoseData(double *current_camera_position, - 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 - double newHeadPose; // Structure with new headpose - - bool first_run; - double alpha_smoothing; - double alpha[6]; - - double kMinSmoothing; - double kMaxSmoothing; - double kSmoothingScaleCurve; - - QMutex mutex; -}; - -//******************************************************************************************************* -// FaceTrackNoIR Filter Settings-dialog. -//******************************************************************************************************* - -// Widget that has controls for FTNoIR protocol filter-settings. -class FilterControls: public QWidget, public IFilterDialog -{ - Q_OBJECT -public: - explicit FilterControls(); - virtual ~FilterControls(); - void showEvent ( QShowEvent * event ); - void Initialize(QWidget *parent); - void registerFilter(IFilter* flt); - void unregisterFilter(); - -private: - Ui::UICFilterControls ui; - void loadSettings(); - void save(); - - /** helper **/ - bool settingsDirty; - - FTNoIR_Filter* pFilter; - -private slots: - void doOK(); - void doCancel(); - void settingChanged() { settingsDirty = true; } - void settingChanged( int ) { settingsDirty = true; } -}; - -//******************************************************************************************************* -// FaceTrackNoIR Filter DLL. Functions used to get general info on the Filter -//******************************************************************************************************* -class FTNoIR_FilterDll : public Metadata -{ -public: - FTNoIR_FilterDll(); - ~FTNoIR_FilterDll(); - void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("EWMA Filter Mk2"); } - void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("EWMA"); } - void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("Exponentially Weighted Moving Average filter with dynamic smoothing parameter"); } - void getIcon(QIcon *icon){ *icon = QIcon(":/images/filter-16.png"); } -}; - -#endif //INCLUDED_FTN_FILTER_H -//END +/******************************************************************************** +* FaceTrackNoIR This program is a private project of some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2012 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +********************************************************************************/ +#pragma once +#ifndef INCLUDED_FTN_FILTER_H +#define INCLUDED_FTN_FILTER_H + +#include "ftnoir_filter_base/ftnoir_filter_base.h" +#include "facetracknoir/global-settings.h" +#include "ui_ftnoir_ewma_filtercontrols.h" +#include +#include + +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// +// EWMA Filter: Exponentially Weighted Moving Average filter with dynamic smoothing parameter +// +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +class FTNoIR_Filter : public IFilter +{ +public: + FTNoIR_Filter(); + ~FTNoIR_Filter(); + void Initialize() {} + + void FilterHeadPoseData(double *current_camera_position, + 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 + double newHeadPose; // Structure with new headpose + + bool first_run; + double alpha_smoothing; + double alpha[6]; + + double kMinSmoothing; + double kMaxSmoothing; + double kSmoothingScaleCurve; + + QMutex mutex; +}; + +//******************************************************************************************************* +// FaceTrackNoIR Filter Settings-dialog. +//******************************************************************************************************* + +// Widget that has controls for FTNoIR protocol filter-settings. +class FilterControls: public QWidget, public IFilterDialog +{ + Q_OBJECT +public: + explicit FilterControls(); + virtual ~FilterControls(); + void showEvent ( QShowEvent * event ); + void Initialize(QWidget *parent); + void registerFilter(IFilter* flt); + void unregisterFilter(); + +private: + Ui::UICFilterControls ui; + void loadSettings(); + void save(); + + /** helper **/ + bool settingsDirty; + + FTNoIR_Filter* pFilter; + +private slots: + void doOK(); + void doCancel(); + void settingChanged() { settingsDirty = true; } + void settingChanged( int ) { settingsDirty = true; } +}; + +//******************************************************************************************************* +// FaceTrackNoIR Filter DLL. Functions used to get general info on the Filter +//******************************************************************************************************* +class FTNoIR_FilterDll : public Metadata +{ +public: + FTNoIR_FilterDll(); + ~FTNoIR_FilterDll(); + void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("EWMA Filter Mk2"); } + void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("EWMA"); } + void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("Exponentially Weighted Moving Average filter with dynamic smoothing parameter"); } + void getIcon(QIcon *icon){ *icon = QIcon(":/images/filter-16.png"); } +}; + +#endif //INCLUDED_FTN_FILTER_H +//END diff --git a/ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp b/ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp index ebcba5f1..91777213 100644 --- a/ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp +++ b/ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp @@ -1,198 +1,198 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2012 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -********************************************************************************/ -#include "ftnoir_filter_ewma2.h" -#include "math.h" -#include -#include "facetracknoir/global-settings.h" -#include "ui_ftnoir_ewma_filtercontrols.h" - -//******************************************************************************************************* -// FaceTrackNoIR Filter Settings-dialog. -//******************************************************************************************************* -// -// Constructor for server-settings-dialog -// -FilterControls::FilterControls() : - QWidget(), pFilter(NULL) -{ - ui.setupUi( this ); - - QPoint offsetpos(100, 100); - //if (parent) { - // this->move(parent->pos() + offsetpos); - //} - - // Connect Qt signals to member-functions - connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); - connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); - - // Connect sliders for reduction factor - connect(ui.minSmooth, SIGNAL(valueChanged(int)), this, SLOT(settingChanged(int))); - 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(); -} - -// -// Destructor for server-dialog -// -FilterControls::~FilterControls() { - qDebug() << "~FilterControls() says: started"; -} - -// -// Initialize tracker-client-dialog -// -void FilterControls::Initialize(QWidget *parent) { - // - // - // - QPoint offsetpos(100, 100); - if (parent) { - this->move(parent->pos() + offsetpos); - } - show(); -} - -void FilterControls::registerFilter(IFilter* flt) -{ - pFilter = (FTNoIR_Filter*) flt; -} - -void FilterControls::unregisterFilter() -{ - pFilter = NULL; -} - -// -// OK clicked on server-dialog -// -void FilterControls::doOK() { - save(); - this->close(); -} - -// override show event -void FilterControls::showEvent ( QShowEvent * event ) { - loadSettings(); -} - -// -// Cancel clicked on server-dialog -// -void FilterControls::doCancel() { - // - // Ask if changed Settings should be saved - // - if (settingsDirty) { - int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard ); - - qDebug() << "doCancel says: answer =" << ret; - - switch (ret) { - case QMessageBox::Save: - save(); - this->close(); - break; - case QMessageBox::Discard: - this->close(); - break; - case QMessageBox::Cancel: - // Cancel was clicked - break; - default: - // should never be reached - break; - } - } - else { - this->close(); - } -} - -// -// Load the current Settings from the currently 'active' INI-file. -// -void FilterControls::loadSettings() { - qDebug() << "FilterControls::loadSettings says: Starting "; - QSettings settings("opentrack"); // 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() << "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 - // - iniFile.beginGroup ( "Tracking" ); - ui.minSmooth->setValue (iniFile.value ( "minSmooth", 15 ).toInt()); - ui.maxSmooth->setValue (iniFile.value ( "maxSmooth", 50 ).toInt()); - ui.powCurve->setValue (iniFile.value ( "powCurve", 10 ).toInt()); - iniFile.endGroup (); - - settingsDirty = false; -} - -// -// Save the current Settings to the currently 'active' INI-file. -// -void FilterControls::save() { - QSettings settings("opentrack"); // 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) - - double smooth_min, smooth_max, smooth_expt; - - iniFile.beginGroup ( "Tracking" ); - 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); -} - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Filter-settings dialog object. - -// Export both decorated and undecorated names. -// GetFilterDialog - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetFilterDialog@0 - Common name decoration for __stdcall functions in C language. -//#pragma comment(linker, "/export:GetFilterDialog=_GetFilterDialog@0") - -extern "C" FTNOIR_FILTER_BASE_EXPORT IFilterDialog* CALLING_CONVENTION GetDialog( ) -{ - return new FilterControls; -} +/******************************************************************************** +* FaceTrackNoIR This program is a private project of some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2012 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +********************************************************************************/ +#include "ftnoir_filter_ewma2.h" +#include "math.h" +#include +#include "facetracknoir/global-settings.h" +#include "ui_ftnoir_ewma_filtercontrols.h" + +//******************************************************************************************************* +// FaceTrackNoIR Filter Settings-dialog. +//******************************************************************************************************* +// +// Constructor for server-settings-dialog +// +FilterControls::FilterControls() : + QWidget(), pFilter(NULL) +{ + ui.setupUi( this ); + + QPoint offsetpos(100, 100); + //if (parent) { + // this->move(parent->pos() + offsetpos); + //} + + // Connect Qt signals to member-functions + connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); + connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); + + // Connect sliders for reduction factor + connect(ui.minSmooth, SIGNAL(valueChanged(int)), this, SLOT(settingChanged(int))); + 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(); +} + +// +// Destructor for server-dialog +// +FilterControls::~FilterControls() { + qDebug() << "~FilterControls() says: started"; +} + +// +// Initialize tracker-client-dialog +// +void FilterControls::Initialize(QWidget *parent) { + // + // + // + QPoint offsetpos(100, 100); + if (parent) { + this->move(parent->pos() + offsetpos); + } + show(); +} + +void FilterControls::registerFilter(IFilter* flt) +{ + pFilter = (FTNoIR_Filter*) flt; +} + +void FilterControls::unregisterFilter() +{ + pFilter = NULL; +} + +// +// OK clicked on server-dialog +// +void FilterControls::doOK() { + save(); + this->close(); +} + +// override show event +void FilterControls::showEvent ( QShowEvent * event ) { + loadSettings(); +} + +// +// Cancel clicked on server-dialog +// +void FilterControls::doCancel() { + // + // Ask if changed Settings should be saved + // + if (settingsDirty) { + int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard ); + + qDebug() << "doCancel says: answer =" << ret; + + switch (ret) { + case QMessageBox::Save: + save(); + this->close(); + break; + case QMessageBox::Discard: + this->close(); + break; + case QMessageBox::Cancel: + // Cancel was clicked + break; + default: + // should never be reached + break; + } + } + else { + this->close(); + } +} + +// +// Load the current Settings from the currently 'active' INI-file. +// +void FilterControls::loadSettings() { + qDebug() << "FilterControls::loadSettings says: Starting "; + QSettings settings("opentrack"); // 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() << "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 + // + iniFile.beginGroup ( "Tracking" ); + ui.minSmooth->setValue (iniFile.value ( "minSmooth", 15 ).toInt()); + ui.maxSmooth->setValue (iniFile.value ( "maxSmooth", 50 ).toInt()); + ui.powCurve->setValue (iniFile.value ( "powCurve", 10 ).toInt()); + iniFile.endGroup (); + + settingsDirty = false; +} + +// +// Save the current Settings to the currently 'active' INI-file. +// +void FilterControls::save() { + QSettings settings("opentrack"); // 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) + + double smooth_min, smooth_max, smooth_expt; + + iniFile.beginGroup ( "Tracking" ); + 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); +} + +//////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Filter-settings dialog object. + +// Export both decorated and undecorated names. +// GetFilterDialog - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetFilterDialog@0 - Common name decoration for __stdcall functions in C language. +//#pragma comment(linker, "/export:GetFilterDialog=_GetFilterDialog@0") + +extern "C" FTNOIR_FILTER_BASE_EXPORT IFilterDialog* CALLING_CONVENTION GetDialog( ) +{ + return new FilterControls; +} diff --git a/ftnoir_filter_ewma2/ftnoir_filter_ewma_dll.cpp b/ftnoir_filter_ewma2/ftnoir_filter_ewma_dll.cpp index 48c9d3be..087ede1b 100644 --- a/ftnoir_filter_ewma2/ftnoir_filter_ewma_dll.cpp +++ b/ftnoir_filter_ewma2/ftnoir_filter_ewma_dll.cpp @@ -1,49 +1,49 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2012 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -********************************************************************************/ -#include "ftnoir_filter_ewma2.h" -#include -#include "facetracknoir/global-settings.h" - -FTNoIR_FilterDll::FTNoIR_FilterDll() { -} - -FTNoIR_FilterDll::~FTNoIR_FilterDll() -{ - -} - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Filter object. - -// Export both decorated and undecorated names. -// GetFilterDll - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetFilterDll@0 - Common name decoration for __stdcall functions in C language. -//#pragma comment(linker, "/export:GetFilterDll=_GetFilterDll@0") - -extern "C" FTNOIR_FILTER_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata() -{ - return new FTNoIR_FilterDll; -} +/******************************************************************************** +* FaceTrackNoIR This program is a private project of some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2012 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +********************************************************************************/ +#include "ftnoir_filter_ewma2.h" +#include +#include "facetracknoir/global-settings.h" + +FTNoIR_FilterDll::FTNoIR_FilterDll() { +} + +FTNoIR_FilterDll::~FTNoIR_FilterDll() +{ + +} + +//////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Filter object. + +// Export both decorated and undecorated names. +// GetFilterDll - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetFilterDll@0 - Common name decoration for __stdcall functions in C language. +//#pragma comment(linker, "/export:GetFilterDll=_GetFilterDll@0") + +extern "C" FTNOIR_FILTER_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata() +{ + return new FTNoIR_FilterDll; +} diff --git a/ftnoir_posewidget/glwidget.cpp b/ftnoir_posewidget/glwidget.cpp index 671dd35d..9f495e0b 100644 --- a/ftnoir_posewidget/glwidget.cpp +++ b/ftnoir_posewidget/glwidget.cpp @@ -1,230 +1,230 @@ -/* Copyright (c) 2013 Stanislaw Halik - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - */ - -#include -#include "glwidget.h" -#include -#include -#include - -GLWidget::GLWidget(QWidget *parent) : QWidget(parent) -{ - front = QImage(QString(":/images/side1.png")); - back = QImage(QString(":/images/side6.png")); - rotateBy(0, 0, 0); -} - -GLWidget::~GLWidget() -{ -} - -void GLWidget::paintEvent ( QPaintEvent * event ) { - QWidget::paintEvent(event); - QPainter p(this); - project_quad_texture(); - p.drawPixmap(event->rect(), pixmap, event->rect()); -} - -void GLWidget::rotateBy(double xAngle, double yAngle, double zAngle) -{ - - double ch = cos(xAngle / 57.295781); - double sh = sin(xAngle / 57.295781); - double ca = cos(yAngle / 57.295781); - double sa = sin(yAngle / 57.295781); - double cb = cos(zAngle / 57.295781); - double sb = sin(zAngle / 57.295781); - - matrix[0 * 3 + 0] = ch * ca; - matrix[0 * 3 + 1]= sh*sb - ch*sa*cb; - matrix[0 * 3 + 2]= ch*sa*sb + sh*cb; - matrix[1 * 3 + 0]= sa; - matrix[1 * 3 + 1]= ca*cb; - matrix[1 * 3 + 2]= -ca*sb; - matrix[2 * 3 + 0]= -sh*ca; - matrix[2 * 3 + 1]= sh*sa*cb + ch*sb; - matrix[2 * 3 + 2]= -sh*sa*sb + ch*cb; - update(); -} - -class Triangle { -public: - Triangle(const Vec2f& p1, - const Vec2f& p2, - const Vec2f& p3) - { - origin = p1; - v0 = Vec2f(p3.x - p1.x, p3.y - p1.y); - v1 = Vec2f(p2.x - p1.x, p2.y - p1.y); - dot00 = dot(v0, v0); - dot01 = dot(v0, v1); - dot11 = dot(v1, v1); - invDenom = 1 / (dot00 * dot11 - dot01 * dot01); - } - bool barycentric_coords(const Vec2f& px, Vec2f& uv) const - { - Vec2f v2(px.x - origin.x, px.y - origin.y); - double dot12 = dot(v1, v2); - double dot02 = dot(v0, v2); - double u = (dot11 * dot02 - dot01 * dot12) * invDenom; - double v = (dot00 * dot12 - dot01 * dot02) * invDenom; - uv.x = u; - uv.y = v; - return (u >= 0) && (v >= 0) && (u + v <= 1); - } - -private: - double dot00, dot01, dot11, invDenom; - Vec2f v0, v1, origin; - double dot(const Vec2f& p1, const Vec2f& p2) const { - return p1.x * p2.x + p1.y * p2.y; - } -}; - -static __inline Vec3f cross(const Vec3f& p1, const Vec3f& p2) -{ - return Vec3f(p1.y * p2.z - p2.y * p1.z, - p2.x * p1.z - p1.x * p2.z, - p1.x * p2.y - p1.y * p2.x); -} - -static __inline Vec3f normal(const Vec3f& p1, const Vec3f& p2, const Vec3f& p3) -{ - Vec3f u(p2.x - p1.x, p2.y - p1.y, p2.z - p1.z); - Vec3f v(p3.x - p1.x, p3.y - p1.y, p3.z - p1.z); - - Vec3f tmp = cross(u, v); - - double i = 1./sqrt(tmp.x * tmp.x + tmp.y * tmp.y + tmp.z * tmp.z); - - return Vec3f(i * tmp.x, i * tmp.y, i * tmp.z); -} - -void GLWidget::project_quad_texture() { - const int sx = width(), sy = height(); - Point pt[4]; - static Vec3f corners[] = { - Vec3f(0, 0, 0), - Vec3f(sx-1, 0, 0), - Vec3f(0, sy-1, 0), - Vec3f(sx-1, sy-1, 0) - }; - - for (int i = 0; i < 4; i++) { - pt[i] = project(Vec3f(corners[i].x - sx/2, corners[i].y - sy/2, 0)); - pt[i].x += sx/2; - pt[i].y += sy/2; - } - - Vec3f normal1(0, 0, 1); - Vec3f normal2; - { - Vec3f foo[3]; - for (int i = 0; i < 3; i++) - foo[i] = project2(corners[i]); - normal2 = normal(foo[0], foo[1], foo[2]); - } - - double dir = normal1.x * normal2.x + normal1.y * normal2.y + normal1.z * normal2.z; - - QImage& tex = dir < 0 ? back : front; - - int ow = tex.width(), oh = tex.height(); - - Vec2f p2[4]; - - for (int i = 0; i < 4; i++) - p2[i] = Vec2f(pt[i].x, pt[i].y); - - QImage texture(QSize(sx, sy), QImage::Format_RGB888); - texture.fill(Qt::black); - - const Vec2f projected[2][3] = { { p2[0], p2[1], p2[2] }, { p2[3], p2[1], p2[2] } }; - const Vec2f origs[2][3] = { - { Vec2f(0, 0), Vec2f(ow-1, 0), Vec2f(0, oh-1) }, - { Vec2f(ow-1, oh-1), Vec2f(ow-1, 0), Vec2f(0, oh-1) } - }; - const Triangle triangles[2] = { - Triangle(projected[0][0], projected[0][1], projected[0][2]), - Triangle(projected[1][0], projected[1][1], projected[1][2]) - }; - - int orig_pitch = tex.bytesPerLine(); - int dest_pitch = texture.bytesPerLine(); - - const unsigned char* orig = tex.bits(); - unsigned char* dest = texture.bits(); - - int orig_depth = tex.depth() / 8; - int dest_depth = texture.depth() / 8; - - /* image breakage? */ - if (orig_depth < 3) - return; - - for (int y = 0; y < sy; y++) - for (int x = 0; x < sx; x++) { - Vec2f pos; - pos.x = x; - pos.y = y; - for (int i = 0; i < 2; i++) { - Vec2f coords; - if (triangles[i].barycentric_coords(pos, coords)) - { - double qx = origs[i][0].x - + coords.x * (origs[i][2].x - origs[i][0].x) - + coords.y * (origs[i][1].x - origs[i][0].x); - double qy = origs[i][0].y - + coords.x * (origs[i][2].y - origs[i][0].y) - + coords.y * (origs[i][1].y - origs[i][0].y); - int qx1 = std::min(ow - 1, std::max(0, qx - 0.5)); - int qy1 = std::min(oh - 1, std::max(0, qy - 0.5)); - int qx2 = std::min(ow - 1, std::max(0, qx + 0.5)); - int qy2 = std::min(oh - 1, std::max(0, qy + 0.5)); - - double dx1 = qx1 - qx; - double dy1 = qy1 - qy; - double dx2 = qx2 - qx; - double dy2 = qy2 - qy; - - double d1 = 2 - (dx1 * dx1 + dy1 * dy1); - double d2 = 2 - (dx2 * dx2 + dy2 * dy2); - double d3 = 2 - (dx2 * dx2 + dy1 * dy1); - double d4 = 2 - (dx1 * dx1 + dy2 * dy2); - - double inv_norm = 1. / (d1 + d2 + d3 + d4); - - d1 *= inv_norm; - d2 *= inv_norm; - d3 *= inv_norm; - d4 *= inv_norm; - - double r = d1 * (double) orig[qy1 * orig_pitch + qx1 * orig_depth + 2] - + d2 * (double) orig[qy2 * orig_pitch + qx2 * orig_depth + 2] - + d3 * (double) orig[qy1 * orig_pitch + qx2 * orig_depth + 2] - + d4 * (double) orig[qy2 * orig_pitch + qx1 * orig_depth + 2]; - - double g = d1 * (double) orig[qy1 * orig_pitch + qx1 * orig_depth + 1] - + d2 * (double) orig[qy2 * orig_pitch + qx2 * orig_depth + 1] - + d3 * (double) orig[qy1 * orig_pitch + qx2 * orig_depth + 1] - + d4 * (double) orig[qy2 * orig_pitch + qx1 * orig_depth + 1]; - - double b = d1 * (double) orig[qy1 * orig_pitch + qx1 * orig_depth + 0] - + d2 * (double) orig[qy2 * orig_pitch + qx2 * orig_depth + 0] - + d3 * (double) orig[qy1 * orig_pitch + qx2 * orig_depth + 0] - + d4 * (double) orig[qy2 * orig_pitch + qx1 * orig_depth + 0]; - - dest[y * dest_pitch + x * dest_depth + 0] = std::max(0, std::min(255, r)); - dest[y * dest_pitch + x * dest_depth + 1] = std::max(0, std::min(255, g)); - dest[y * dest_pitch + x * dest_depth + 2] = std::max(0, std::min(255, b)); - - break; - } - } - } - pixmap = QPixmap::fromImage(texture); +/* Copyright (c) 2013 Stanislaw Halik + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + */ + +#include +#include "glwidget.h" +#include +#include +#include + +GLWidget::GLWidget(QWidget *parent) : QWidget(parent) +{ + front = QImage(QString(":/images/side1.png")); + back = QImage(QString(":/images/side6.png")); + rotateBy(0, 0, 0); +} + +GLWidget::~GLWidget() +{ +} + +void GLWidget::paintEvent ( QPaintEvent * event ) { + QWidget::paintEvent(event); + QPainter p(this); + project_quad_texture(); + p.drawPixmap(event->rect(), pixmap, event->rect()); +} + +void GLWidget::rotateBy(double xAngle, double yAngle, double zAngle) +{ + + double ch = cos(xAngle / 57.295781); + double sh = sin(xAngle / 57.295781); + double ca = cos(yAngle / 57.295781); + double sa = sin(yAngle / 57.295781); + double cb = cos(zAngle / 57.295781); + double sb = sin(zAngle / 57.295781); + + matrix[0 * 3 + 0] = ch * ca; + matrix[0 * 3 + 1]= sh*sb - ch*sa*cb; + matrix[0 * 3 + 2]= ch*sa*sb + sh*cb; + matrix[1 * 3 + 0]= sa; + matrix[1 * 3 + 1]= ca*cb; + matrix[1 * 3 + 2]= -ca*sb; + matrix[2 * 3 + 0]= -sh*ca; + matrix[2 * 3 + 1]= sh*sa*cb + ch*sb; + matrix[2 * 3 + 2]= -sh*sa*sb + ch*cb; + update(); +} + +class Triangle { +public: + Triangle(const Vec2f& p1, + const Vec2f& p2, + const Vec2f& p3) + { + origin = p1; + v0 = Vec2f(p3.x - p1.x, p3.y - p1.y); + v1 = Vec2f(p2.x - p1.x, p2.y - p1.y); + dot00 = dot(v0, v0); + dot01 = dot(v0, v1); + dot11 = dot(v1, v1); + invDenom = 1 / (dot00 * dot11 - dot01 * dot01); + } + bool barycentric_coords(const Vec2f& px, Vec2f& uv) const + { + Vec2f v2(px.x - origin.x, px.y - origin.y); + double dot12 = dot(v1, v2); + double dot02 = dot(v0, v2); + double u = (dot11 * dot02 - dot01 * dot12) * invDenom; + double v = (dot00 * dot12 - dot01 * dot02) * invDenom; + uv.x = u; + uv.y = v; + return (u >= 0) && (v >= 0) && (u + v <= 1); + } + +private: + double dot00, dot01, dot11, invDenom; + Vec2f v0, v1, origin; + double dot(const Vec2f& p1, const Vec2f& p2) const { + return p1.x * p2.x + p1.y * p2.y; + } +}; + +static __inline Vec3f cross(const Vec3f& p1, const Vec3f& p2) +{ + return Vec3f(p1.y * p2.z - p2.y * p1.z, + p2.x * p1.z - p1.x * p2.z, + p1.x * p2.y - p1.y * p2.x); +} + +static __inline Vec3f normal(const Vec3f& p1, const Vec3f& p2, const Vec3f& p3) +{ + Vec3f u(p2.x - p1.x, p2.y - p1.y, p2.z - p1.z); + Vec3f v(p3.x - p1.x, p3.y - p1.y, p3.z - p1.z); + + Vec3f tmp = cross(u, v); + + double i = 1./sqrt(tmp.x * tmp.x + tmp.y * tmp.y + tmp.z * tmp.z); + + return Vec3f(i * tmp.x, i * tmp.y, i * tmp.z); +} + +void GLWidget::project_quad_texture() { + const int sx = width(), sy = height(); + Point pt[4]; + static Vec3f corners[] = { + Vec3f(0, 0, 0), + Vec3f(sx-1, 0, 0), + Vec3f(0, sy-1, 0), + Vec3f(sx-1, sy-1, 0) + }; + + for (int i = 0; i < 4; i++) { + pt[i] = project(Vec3f(corners[i].x - sx/2, corners[i].y - sy/2, 0)); + pt[i].x += sx/2; + pt[i].y += sy/2; + } + + Vec3f normal1(0, 0, 1); + Vec3f normal2; + { + Vec3f foo[3]; + for (int i = 0; i < 3; i++) + foo[i] = project2(corners[i]); + normal2 = normal(foo[0], foo[1], foo[2]); + } + + double dir = normal1.x * normal2.x + normal1.y * normal2.y + normal1.z * normal2.z; + + QImage& tex = dir < 0 ? back : front; + + int ow = tex.width(), oh = tex.height(); + + Vec2f p2[4]; + + for (int i = 0; i < 4; i++) + p2[i] = Vec2f(pt[i].x, pt[i].y); + + QImage texture(QSize(sx, sy), QImage::Format_RGB888); + texture.fill(Qt::black); + + const Vec2f projected[2][3] = { { p2[0], p2[1], p2[2] }, { p2[3], p2[1], p2[2] } }; + const Vec2f origs[2][3] = { + { Vec2f(0, 0), Vec2f(ow-1, 0), Vec2f(0, oh-1) }, + { Vec2f(ow-1, oh-1), Vec2f(ow-1, 0), Vec2f(0, oh-1) } + }; + const Triangle triangles[2] = { + Triangle(projected[0][0], projected[0][1], projected[0][2]), + Triangle(projected[1][0], projected[1][1], projected[1][2]) + }; + + int orig_pitch = tex.bytesPerLine(); + int dest_pitch = texture.bytesPerLine(); + + const unsigned char* orig = tex.bits(); + unsigned char* dest = texture.bits(); + + int orig_depth = tex.depth() / 8; + int dest_depth = texture.depth() / 8; + + /* image breakage? */ + if (orig_depth < 3) + return; + + for (int y = 0; y < sy; y++) + for (int x = 0; x < sx; x++) { + Vec2f pos; + pos.x = x; + pos.y = y; + for (int i = 0; i < 2; i++) { + Vec2f coords; + if (triangles[i].barycentric_coords(pos, coords)) + { + double qx = origs[i][0].x + + coords.x * (origs[i][2].x - origs[i][0].x) + + coords.y * (origs[i][1].x - origs[i][0].x); + double qy = origs[i][0].y + + coords.x * (origs[i][2].y - origs[i][0].y) + + coords.y * (origs[i][1].y - origs[i][0].y); + int qx1 = std::min(ow - 1, std::max(0, qx - 0.5)); + int qy1 = std::min(oh - 1, std::max(0, qy - 0.5)); + int qx2 = std::min(ow - 1, std::max(0, qx + 0.5)); + int qy2 = std::min(oh - 1, std::max(0, qy + 0.5)); + + double dx1 = qx1 - qx; + double dy1 = qy1 - qy; + double dx2 = qx2 - qx; + double dy2 = qy2 - qy; + + double d1 = 2 - (dx1 * dx1 + dy1 * dy1); + double d2 = 2 - (dx2 * dx2 + dy2 * dy2); + double d3 = 2 - (dx2 * dx2 + dy1 * dy1); + double d4 = 2 - (dx1 * dx1 + dy2 * dy2); + + double inv_norm = 1. / (d1 + d2 + d3 + d4); + + d1 *= inv_norm; + d2 *= inv_norm; + d3 *= inv_norm; + d4 *= inv_norm; + + double r = d1 * (double) orig[qy1 * orig_pitch + qx1 * orig_depth + 2] + + d2 * (double) orig[qy2 * orig_pitch + qx2 * orig_depth + 2] + + d3 * (double) orig[qy1 * orig_pitch + qx2 * orig_depth + 2] + + d4 * (double) orig[qy2 * orig_pitch + qx1 * orig_depth + 2]; + + double g = d1 * (double) orig[qy1 * orig_pitch + qx1 * orig_depth + 1] + + d2 * (double) orig[qy2 * orig_pitch + qx2 * orig_depth + 1] + + d3 * (double) orig[qy1 * orig_pitch + qx2 * orig_depth + 1] + + d4 * (double) orig[qy2 * orig_pitch + qx1 * orig_depth + 1]; + + double b = d1 * (double) orig[qy1 * orig_pitch + qx1 * orig_depth + 0] + + d2 * (double) orig[qy2 * orig_pitch + qx2 * orig_depth + 0] + + d3 * (double) orig[qy1 * orig_pitch + qx2 * orig_depth + 0] + + d4 * (double) orig[qy2 * orig_pitch + qx1 * orig_depth + 0]; + + dest[y * dest_pitch + x * dest_depth + 0] = std::max(0, std::min(255, r)); + dest[y * dest_pitch + x * dest_depth + 1] = std::max(0, std::min(255, g)); + dest[y * dest_pitch + x * dest_depth + 2] = std::max(0, std::min(255, b)); + + break; + } + } + } + pixmap = QPixmap::fromImage(texture); } \ No newline at end of file diff --git a/ftnoir_posewidget/glwidget.h b/ftnoir_posewidget/glwidget.h index 9525f7d4..f46f3c9e 100644 --- a/ftnoir_posewidget/glwidget.h +++ b/ftnoir_posewidget/glwidget.h @@ -1,116 +1,116 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of the some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2010 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* Adopted this widget from the 'textures' sample of the Nokia Qt toolkit. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -*********************************************************************************/ - -#ifndef GLWIDGET_H -#define GLWIDGET_H - -#include -#include -#include "ftnoir_tracker_base/ftnoir_tracker_base.h" - -struct Point { - Point(int x, int y) : - x(x), y(y) - { - } - Point() : - x(0), y(0) - { - } - int x, y; -}; - -struct Vec3f { - double x, y, z; - Vec3f(double x, double y, double z) : - x(x), y(y), z(z) - { - } - Vec3f() : - x(0), y(0), z(0) - { - } -}; - -struct Vec2f { - double x, y; - Vec2f(double x, double y) : - x(x), y(y) - { - } - Vec2f() : - x(0), y(0) - { - } -}; - -class FTNOIR_TRACKER_BASE_EXPORT GLWidget : public QWidget -{ - Q_OBJECT - -public: - GLWidget(QWidget *parent); - ~GLWidget(); - void rotateBy(double xAngle, double yAngle, double zAngle); - -protected: - void paintEvent ( QPaintEvent * event ); - -private: - Point project(const Vec3f& point) { - Point rect; - - rect.x = point.x * matrix[0] - + point.y * matrix[1] - + point.z * matrix[2]; - rect.y = point.x * matrix[3] - + point.y * matrix[4] - + point.z * matrix[5]; - - return rect; - } - Vec3f project2(const Vec3f& point) { - Vec3f rect; - - rect.x = point.x * matrix[0] - + point.y * matrix[1] - + point.z * matrix[2]; - rect.y = point.x * matrix[3] - + point.y * matrix[4] - + point.z * matrix[5]; - rect.z = point.x * matrix[6] - + point.y * matrix[7] - + point.z * matrix[8]; - return rect; - } - void project_quad_texture(); - double matrix[9]; - QImage front; - QImage back; - QPixmap pixmap; -}; - -#endif +/******************************************************************************** +* FaceTrackNoIR This program is a private project of the some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2010 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* Adopted this widget from the 'textures' sample of the Nokia Qt toolkit. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +*********************************************************************************/ + +#ifndef GLWIDGET_H +#define GLWIDGET_H + +#include +#include +#include "ftnoir_tracker_base/ftnoir_tracker_base.h" + +struct Point { + Point(int x, int y) : + x(x), y(y) + { + } + Point() : + x(0), y(0) + { + } + int x, y; +}; + +struct Vec3f { + double x, y, z; + Vec3f(double x, double y, double z) : + x(x), y(y), z(z) + { + } + Vec3f() : + x(0), y(0), z(0) + { + } +}; + +struct Vec2f { + double x, y; + Vec2f(double x, double y) : + x(x), y(y) + { + } + Vec2f() : + x(0), y(0) + { + } +}; + +class FTNOIR_TRACKER_BASE_EXPORT GLWidget : public QWidget +{ + Q_OBJECT + +public: + GLWidget(QWidget *parent); + ~GLWidget(); + void rotateBy(double xAngle, double yAngle, double zAngle); + +protected: + void paintEvent ( QPaintEvent * event ); + +private: + Point project(const Vec3f& point) { + Point rect; + + rect.x = point.x * matrix[0] + + point.y * matrix[1] + + point.z * matrix[2]; + rect.y = point.x * matrix[3] + + point.y * matrix[4] + + point.z * matrix[5]; + + return rect; + } + Vec3f project2(const Vec3f& point) { + Vec3f rect; + + rect.x = point.x * matrix[0] + + point.y * matrix[1] + + point.z * matrix[2]; + rect.y = point.x * matrix[3] + + point.y * matrix[4] + + point.z * matrix[5]; + rect.z = point.x * matrix[6] + + point.y * matrix[7] + + point.z * matrix[8]; + return rect; + } + void project_quad_texture(); + double matrix[9]; + QImage front; + QImage back; + QPixmap pixmap; +}; + +#endif diff --git a/ftnoir_protocol_base/ftnoir_protocol_base.h b/ftnoir_protocol_base/ftnoir_protocol_base.h index 8533363d..1ebafdd5 100644 --- a/ftnoir_protocol_base/ftnoir_protocol_base.h +++ b/ftnoir_protocol_base/ftnoir_protocol_base.h @@ -1,75 +1,75 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of the some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2010 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* This class implements a tracker-base * -*********************************************************************************/ -/* - Modifications (last one on top): - - 20121115 - WVR: Added RegisterProtocol() and unRegisterProtocol() to Dialog Class - 20110415 - WVR: Added overloaded operator - and -= -*/ - -#ifndef FTNOIR_PROTOCOL_BASE_H -#define FTNOIR_PROTOCOL_BASE_H - -#include "ftnoir_protocol_base_global.h" -#include "ftnoir_tracker_base/ftnoir_tracker_types.h" -#include -#include -//#include "winbase.h" - -//#include "windows.h" -//#include "winable.h" - -//////////////////////////////////////////////////////////////////////////////// -#ifdef __cplusplus -# define EXTERN_C extern "C" -#else -# define EXTERN_C -#endif // __cplusplus - -//////////////////////////////////////////////////////////////////////////////// -// COM-Like abstract interface. -// This interface doesn't require __declspec(dllexport/dllimport) specifier. -// Method calls are dispatched via virtual table. -// Any C++ compiler can use it. -// Instances are obtained via factory function. -struct IProtocol -{ - virtual ~IProtocol() {} - virtual bool checkServerInstallationOK() = 0; - virtual void sendHeadposeToGame( double *headpose, double *rawheadpose ) = 0; - virtual QString getGameName() = 0; -}; - -struct IProtocolDialog -{ - virtual ~IProtocolDialog() {} - virtual void Initialize(QWidget *parent) = 0; - virtual void showEvent ( QShowEvent * event ) = 0; - - virtual void registerProtocol(IProtocol *protocol) = 0; - virtual void unRegisterProtocol() = 0; -}; - -#endif // FTNOIR_PROTOCOL_BASE_H +/******************************************************************************** +* FaceTrackNoIR This program is a private project of the some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2010 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* This class implements a tracker-base * +*********************************************************************************/ +/* + Modifications (last one on top): + + 20121115 - WVR: Added RegisterProtocol() and unRegisterProtocol() to Dialog Class + 20110415 - WVR: Added overloaded operator - and -= +*/ + +#ifndef FTNOIR_PROTOCOL_BASE_H +#define FTNOIR_PROTOCOL_BASE_H + +#include "ftnoir_protocol_base_global.h" +#include "ftnoir_tracker_base/ftnoir_tracker_types.h" +#include +#include +//#include "winbase.h" + +//#include "windows.h" +//#include "winable.h" + +//////////////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +# define EXTERN_C extern "C" +#else +# define EXTERN_C +#endif // __cplusplus + +//////////////////////////////////////////////////////////////////////////////// +// COM-Like abstract interface. +// This interface doesn't require __declspec(dllexport/dllimport) specifier. +// Method calls are dispatched via virtual table. +// Any C++ compiler can use it. +// Instances are obtained via factory function. +struct IProtocol +{ + virtual ~IProtocol() {} + virtual bool checkServerInstallationOK() = 0; + virtual void sendHeadposeToGame( double *headpose, double *rawheadpose ) = 0; + virtual QString getGameName() = 0; +}; + +struct IProtocolDialog +{ + virtual ~IProtocolDialog() {} + virtual void Initialize(QWidget *parent) = 0; + virtual void showEvent ( QShowEvent * event ) = 0; + + virtual void registerProtocol(IProtocol *protocol) = 0; + virtual void unRegisterProtocol() = 0; +}; + +#endif // FTNOIR_PROTOCOL_BASE_H diff --git a/ftnoir_protocol_base/ftnoir_protocol_base_global.h b/ftnoir_protocol_base/ftnoir_protocol_base_global.h index ca51e26d..9f66d67a 100644 --- a/ftnoir_protocol_base/ftnoir_protocol_base_global.h +++ b/ftnoir_protocol_base/ftnoir_protocol_base_global.h @@ -1,12 +1,12 @@ -#ifndef FTNOIR_PROTOCOL_BASE_GLOBAL_H -#define FTNOIR_PROTOCOL_BASE_GLOBAL_H - -#include - -#ifdef FTNOIR_PROTOCOL_BASE_LIB -# define FTNOIR_PROTOCOL_BASE_EXPORT Q_DECL_EXPORT -#else -# define FTNOIR_PROTOCOL_BASE_EXPORT Q_DECL_IMPORT -#endif - -#endif // FTNOIR_PROTOCOL_BASE_GLOBAL_H +#ifndef FTNOIR_PROTOCOL_BASE_GLOBAL_H +#define FTNOIR_PROTOCOL_BASE_GLOBAL_H + +#include + +#ifdef FTNOIR_PROTOCOL_BASE_LIB +# define FTNOIR_PROTOCOL_BASE_EXPORT Q_DECL_EXPORT +#else +# define FTNOIR_PROTOCOL_BASE_EXPORT Q_DECL_IMPORT +#endif + +#endif // FTNOIR_PROTOCOL_BASE_GLOBAL_H diff --git a/ftnoir_protocol_fg/fgtypes.h b/ftnoir_protocol_fg/fgtypes.h index 68f85877..0f29be3d 100644 --- a/ftnoir_protocol_fg/fgtypes.h +++ b/ftnoir_protocol_fg/fgtypes.h @@ -1,27 +1,27 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of the some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2010 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* Type definitions for the FlightGear server. * -********************************************************************************/ -#pragma once -#ifndef INCLUDED_FGTYPES_H -#define INCLUDED_FGTYPES_H - -// -// x,y,z position in metres, heading, pitch and roll in degrees... -// -#pragma pack(push, 2) -struct TFlightGearData { - double x, y, z, h, p, r; - int status; -}; -#pragma pack(pop) - -#endif//INCLUDED_FGTYPES_H +/******************************************************************************** +* FaceTrackNoIR This program is a private project of the some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2010 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* Type definitions for the FlightGear server. * +********************************************************************************/ +#pragma once +#ifndef INCLUDED_FGTYPES_H +#define INCLUDED_FGTYPES_H + +// +// x,y,z position in metres, heading, pitch and roll in degrees... +// +#pragma pack(push, 2) +struct TFlightGearData { + double x, y, z, h, p, r; + int status; +}; +#pragma pack(pop) + +#endif//INCLUDED_FGTYPES_H diff --git a/ftnoir_protocol_fg/ftnoir_protocol_fg.cpp b/ftnoir_protocol_fg/ftnoir_protocol_fg.cpp index abc401fa..d80791ce 100644 --- a/ftnoir_protocol_fg/ftnoir_protocol_fg.cpp +++ b/ftnoir_protocol_fg/ftnoir_protocol_fg.cpp @@ -1,222 +1,222 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of the some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2010 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -* FGServer FGServer is the Class, that communicates headpose-data * -* to FlightGear, using UDP. * -* It is based on the (Linux) example made by Melchior FRANZ. * -********************************************************************************/ -#include "ftnoir_protocol_fg.h" -#include -#include "facetracknoir/global-settings.h" -#include - -// For Todd and Arda Kutlu -//#define SEND_ASCII_DATA -//#define LOG_OUTPUT - -/** constructor **/ -FTNoIR_Protocol::FTNoIR_Protocol() -{ - blnConnectionActive = false; - loadSettings(); -} - -/** destructor **/ -FTNoIR_Protocol::~FTNoIR_Protocol() -{ - if (inSocket != 0) { - inSocket->close(); - delete inSocket; - } - - if (outSocket != 0) { - outSocket->close(); - delete outSocket; - } -} - -// -// Load the current Settings from the currently 'active' INI-file. -// -void FTNoIR_Protocol::loadSettings() { - QSettings settings("opentrack"); // 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) - - iniFile.beginGroup ( "FG" ); - - bool blnLocalPC = iniFile.value ( "LocalPCOnly", 1 ).toBool(); - if (blnLocalPC) { - destIP = QHostAddress::LocalHost; - } - else { - QString destAddr = iniFile.value ( "IP-1", 192 ).toString() + "." + iniFile.value ( "IP-2", 168 ).toString() + "." + iniFile.value ( "IP-3", 2 ).toString() + "." + iniFile.value ( "IP-4", 1 ).toString(); - destIP = QHostAddress( destAddr ); - } - destPort = iniFile.value ( "PortNumber", 5550 ).toInt(); - - iniFile.endGroup (); - -} - -// -// Update Headpose in Game. -// -void FTNoIR_Protocol::sendHeadposeToGame( double *headpose, double *rawheadpose ) { -int no_bytes; -QHostAddress sender; -quint16 senderPort; - - // - // Copy the Raw measurements directly to the client. - // - FlightData.x = headpose[TX]; - FlightData.y = headpose[Pitch]; - FlightData.z = headpose[TZ]; - FlightData.p = headpose[TY]; - FlightData.h = headpose[Yaw]; - FlightData.r = headpose[Roll]; - FlightData.status = fg_cmd; - - // - // Try to send an UDP-message to the FlightGear - // - -#ifdef SEND_ASCII_DATA - sprintf_s(data, "%.2f %.2f %.2f %.2f %.2f %.2f\n\0", FlightData.x, FlightData.y, FlightData.z, FlightData.p, FlightData.h, FlightData.r); - - if (outSocket != 0) { - no_bytes = outSocket->writeDatagram((const char *) &data, strlen( data ), destIP, destPort); - if ( no_bytes > 0) { - qDebug() << "FGServer::writePendingDatagrams says: bytes send =" << data; - } - else { - qDebug() << "FGServer::writePendingDatagrams says: nothing sent!"; - } - } - -#endif - - #ifdef LOG_OUTPUT - // Use this for some debug-output to file... - QFile datafile(QCoreApplication::applicationDirPath() + "\\FG_output.txt"); - if (datafile.open(QFile::WriteOnly | QFile::Append)) { - QTextStream out(&datafile); - out << "output:\t" << FlightData.x << "\t" << FlightData.y << "\t" << FlightData.z << "\t" << FlightData.p << "\t" << FlightData.h << "\t" << FlightData.r << '\n'; - } - #endif - - #ifndef SEND_ASCII_DATA - //! [1] -// no_bytes = outSocket->writeDatagram((const char *) &FlightData, sizeof( FlightData ), QHostAddress::LocalHost, 5550); - if (outSocket != 0) { - no_bytes = outSocket->writeDatagram((const char *) &FlightData, sizeof( FlightData ), destIP, destPort); - if ( no_bytes > 0) { - // qDebug() << "FGServer::writePendingDatagrams says: bytes send =" << no_bytes << sizeof( double ); - } - else { - qDebug() << "FGServer::writePendingDatagrams says: nothing sent!"; - } - } - #endif - - // - // FlightGear keeps sending data, so we must read that here. - // - if (inSocket != 0) { - while (inSocket->hasPendingDatagrams()) { - - QByteArray datagram; - datagram.resize(inSocket->pendingDatagramSize()); - - inSocket->readDatagram( (char * ) &cmd, sizeof(cmd), &sender, &senderPort); - - fg_cmd = cmd; // Let's just accept that command for now... - if ( cmd > 0 ) { - qDebug() << "FGServer::sendHeadposeToGame hasPendingDatagrams, cmd = " << cmd; -// headTracker->handleGameCommand ( cmd ); // Send it upstream, for the Tracker to handle - } - - if (!blnConnectionActive) { - blnConnectionActive = true; - } - } - } -} - -// -// Check if the Client DLL exists and load it (to test it), if so. -// Returns 'true' if all seems OK. -// -bool FTNoIR_Protocol::checkServerInstallationOK() -{ - // Init. the data - FlightData.x = 0.0f; - FlightData.y = 0.0f; - FlightData.z = 0.0f; - FlightData.h = 0.0f; - FlightData.p = 0.0f; - FlightData.r = 0.0f; - FlightData.status = 0; - fg_cmd = 1; - - inSocket = 0; - outSocket = 0; - - // - // Create UDP-sockets. - // - if (inSocket == 0) { - qDebug() << "FGServer::sendHeadposeToGame creating insocket"; - inSocket = new QUdpSocket(); - - // Connect the inSocket to the port, to receive messages - if (!inSocket->bind(QHostAddress::Any, destPort+1)) { - QMessageBox::warning(0,"FaceTrackNoIR Error", "Unable to bind UDP-port",QMessageBox::Ok,QMessageBox::NoButton); - delete inSocket; - inSocket = 0; - return false; - } - } - - if (outSocket == 0) { - outSocket = new QUdpSocket(); - } - - return true; -} - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Protocol object. - -// Export both decorated and undecorated names. -// GetProtocol - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetProtocol@0 - Common name decoration for __stdcall functions in C language. -//#pragma comment(linker, "/export:GetProtocol=_GetProtocol@0") - -extern "C" FTNOIR_PROTOCOL_BASE_EXPORT IProtocol* CALLING_CONVENTION GetConstructor() -{ - return new FTNoIR_Protocol; -} +/******************************************************************************** +* FaceTrackNoIR This program is a private project of the some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2010 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +* FGServer FGServer is the Class, that communicates headpose-data * +* to FlightGear, using UDP. * +* It is based on the (Linux) example made by Melchior FRANZ. * +********************************************************************************/ +#include "ftnoir_protocol_fg.h" +#include +#include "facetracknoir/global-settings.h" +#include + +// For Todd and Arda Kutlu +//#define SEND_ASCII_DATA +//#define LOG_OUTPUT + +/** constructor **/ +FTNoIR_Protocol::FTNoIR_Protocol() +{ + blnConnectionActive = false; + loadSettings(); +} + +/** destructor **/ +FTNoIR_Protocol::~FTNoIR_Protocol() +{ + if (inSocket != 0) { + inSocket->close(); + delete inSocket; + } + + if (outSocket != 0) { + outSocket->close(); + delete outSocket; + } +} + +// +// Load the current Settings from the currently 'active' INI-file. +// +void FTNoIR_Protocol::loadSettings() { + QSettings settings("opentrack"); // 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) + + iniFile.beginGroup ( "FG" ); + + bool blnLocalPC = iniFile.value ( "LocalPCOnly", 1 ).toBool(); + if (blnLocalPC) { + destIP = QHostAddress::LocalHost; + } + else { + QString destAddr = iniFile.value ( "IP-1", 192 ).toString() + "." + iniFile.value ( "IP-2", 168 ).toString() + "." + iniFile.value ( "IP-3", 2 ).toString() + "." + iniFile.value ( "IP-4", 1 ).toString(); + destIP = QHostAddress( destAddr ); + } + destPort = iniFile.value ( "PortNumber", 5550 ).toInt(); + + iniFile.endGroup (); + +} + +// +// Update Headpose in Game. +// +void FTNoIR_Protocol::sendHeadposeToGame( double *headpose, double *rawheadpose ) { +int no_bytes; +QHostAddress sender; +quint16 senderPort; + + // + // Copy the Raw measurements directly to the client. + // + FlightData.x = headpose[TX]; + FlightData.y = headpose[Pitch]; + FlightData.z = headpose[TZ]; + FlightData.p = headpose[TY]; + FlightData.h = headpose[Yaw]; + FlightData.r = headpose[Roll]; + FlightData.status = fg_cmd; + + // + // Try to send an UDP-message to the FlightGear + // + +#ifdef SEND_ASCII_DATA + sprintf_s(data, "%.2f %.2f %.2f %.2f %.2f %.2f\n\0", FlightData.x, FlightData.y, FlightData.z, FlightData.p, FlightData.h, FlightData.r); + + if (outSocket != 0) { + no_bytes = outSocket->writeDatagram((const char *) &data, strlen( data ), destIP, destPort); + if ( no_bytes > 0) { + qDebug() << "FGServer::writePendingDatagrams says: bytes send =" << data; + } + else { + qDebug() << "FGServer::writePendingDatagrams says: nothing sent!"; + } + } + +#endif + + #ifdef LOG_OUTPUT + // Use this for some debug-output to file... + QFile datafile(QCoreApplication::applicationDirPath() + "\\FG_output.txt"); + if (datafile.open(QFile::WriteOnly | QFile::Append)) { + QTextStream out(&datafile); + out << "output:\t" << FlightData.x << "\t" << FlightData.y << "\t" << FlightData.z << "\t" << FlightData.p << "\t" << FlightData.h << "\t" << FlightData.r << '\n'; + } + #endif + + #ifndef SEND_ASCII_DATA + //! [1] +// no_bytes = outSocket->writeDatagram((const char *) &FlightData, sizeof( FlightData ), QHostAddress::LocalHost, 5550); + if (outSocket != 0) { + no_bytes = outSocket->writeDatagram((const char *) &FlightData, sizeof( FlightData ), destIP, destPort); + if ( no_bytes > 0) { + // qDebug() << "FGServer::writePendingDatagrams says: bytes send =" << no_bytes << sizeof( double ); + } + else { + qDebug() << "FGServer::writePendingDatagrams says: nothing sent!"; + } + } + #endif + + // + // FlightGear keeps sending data, so we must read that here. + // + if (inSocket != 0) { + while (inSocket->hasPendingDatagrams()) { + + QByteArray datagram; + datagram.resize(inSocket->pendingDatagramSize()); + + inSocket->readDatagram( (char * ) &cmd, sizeof(cmd), &sender, &senderPort); + + fg_cmd = cmd; // Let's just accept that command for now... + if ( cmd > 0 ) { + qDebug() << "FGServer::sendHeadposeToGame hasPendingDatagrams, cmd = " << cmd; +// headTracker->handleGameCommand ( cmd ); // Send it upstream, for the Tracker to handle + } + + if (!blnConnectionActive) { + blnConnectionActive = true; + } + } + } +} + +// +// Check if the Client DLL exists and load it (to test it), if so. +// Returns 'true' if all seems OK. +// +bool FTNoIR_Protocol::checkServerInstallationOK() +{ + // Init. the data + FlightData.x = 0.0f; + FlightData.y = 0.0f; + FlightData.z = 0.0f; + FlightData.h = 0.0f; + FlightData.p = 0.0f; + FlightData.r = 0.0f; + FlightData.status = 0; + fg_cmd = 1; + + inSocket = 0; + outSocket = 0; + + // + // Create UDP-sockets. + // + if (inSocket == 0) { + qDebug() << "FGServer::sendHeadposeToGame creating insocket"; + inSocket = new QUdpSocket(); + + // Connect the inSocket to the port, to receive messages + if (!inSocket->bind(QHostAddress::Any, destPort+1)) { + QMessageBox::warning(0,"FaceTrackNoIR Error", "Unable to bind UDP-port",QMessageBox::Ok,QMessageBox::NoButton); + delete inSocket; + inSocket = 0; + return false; + } + } + + if (outSocket == 0) { + outSocket = new QUdpSocket(); + } + + return true; +} + +//////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Protocol object. + +// Export both decorated and undecorated names. +// GetProtocol - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetProtocol@0 - Common name decoration for __stdcall functions in C language. +//#pragma comment(linker, "/export:GetProtocol=_GetProtocol@0") + +extern "C" FTNOIR_PROTOCOL_BASE_EXPORT IProtocol* CALLING_CONVENTION GetConstructor() +{ + return new FTNoIR_Protocol; +} diff --git a/ftnoir_protocol_fg/ftnoir_protocol_fg.h b/ftnoir_protocol_fg/ftnoir_protocol_fg.h index 1c4484b8..5c2531be 100644 --- a/ftnoir_protocol_fg/ftnoir_protocol_fg.h +++ b/ftnoir_protocol_fg/ftnoir_protocol_fg.h @@ -1,121 +1,121 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2013 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -* FGServer FGServer is the Class, that communicates headpose-data * -* to FlightGear, using UDP. * -* It is based on the (Linux) example made by Melchior FRANZ. * -********************************************************************************/ -#pragma once -#ifndef INCLUDED_FGSERVER_H -#define INCLUDED_FGSERVER_H - -#include "ftnoir_protocol_base/ftnoir_protocol_base.h" -#include "ui_ftnoir_fgcontrols.h" -#include "fgtypes.h" -#include -#include -#include -#include -#include -#include "facetracknoir/global-settings.h" - -#define FT_PROGRAMID "FT_ProgramID" - -class FTNoIR_Protocol : public IProtocol -{ -public: - FTNoIR_Protocol(); - ~FTNoIR_Protocol(); - bool checkServerInstallationOK(); - void sendHeadposeToGame( double *headpose, double *rawheadpose ); -private: - - bool blnConnectionActive; - - // Tracker *headTracker; // For upstream messages... - TFlightGearData FlightData; - QUdpSocket *inSocket; // Receive from FligthGear - QUdpSocket *outSocket; // Send to FligthGear - qint32 cmd; - qint32 fg_cmd; // Command from FlightGear - QHostAddress destIP; // Destination IP-address - int destPort; // Destination port-number - void loadSettings(); - QString getGameName() { - return "FlightGear"; - } -}; - -// Widget that has controls for FTNoIR protocol client-settings. -class FGControls: public QWidget, public IProtocolDialog -{ - Q_OBJECT -public: - - explicit FGControls(); - virtual ~FGControls(); - void showEvent ( QShowEvent * event ); - - void Initialize(QWidget *parent); - void registerProtocol(IProtocol *protocol) { - theProtocol = (FTNoIR_Protocol *) protocol; // Accept the pointer to the Protocol - } - void unRegisterProtocol() { - theProtocol = NULL; // Reset the pointer - } - -private: - Ui::UICFGControls ui; - void loadSettings(); - void save(); - - /** helper **/ - bool settingsDirty; - FTNoIR_Protocol *theProtocol; - -private slots: - void doOK(); - void doCancel(); - void chkLocalPCOnlyChanged(); - void settingChanged() { settingsDirty = true; } -}; - -//******************************************************************************************************* -// FaceTrackNoIR Protocol DLL. Functions used to get general info on the Protocol -//******************************************************************************************************* -class FTNoIR_ProtocolDll : public Metadata -{ -public: - FTNoIR_ProtocolDll(); - ~FTNoIR_ProtocolDll(); - - void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("FlightGear"); } - void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("FlightGear"); } - void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("FlightGear UDP protocol"); } - - void getIcon(QIcon *icon) { *icon = QIcon(":/images/flightgear.png"); } -}; - - -#endif//INCLUDED_FGSERVER_H -//END +/******************************************************************************** +* FaceTrackNoIR This program is a private project of some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2013 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +* FGServer FGServer is the Class, that communicates headpose-data * +* to FlightGear, using UDP. * +* It is based on the (Linux) example made by Melchior FRANZ. * +********************************************************************************/ +#pragma once +#ifndef INCLUDED_FGSERVER_H +#define INCLUDED_FGSERVER_H + +#include "ftnoir_protocol_base/ftnoir_protocol_base.h" +#include "ui_ftnoir_fgcontrols.h" +#include "fgtypes.h" +#include +#include +#include +#include +#include +#include "facetracknoir/global-settings.h" + +#define FT_PROGRAMID "FT_ProgramID" + +class FTNoIR_Protocol : public IProtocol +{ +public: + FTNoIR_Protocol(); + ~FTNoIR_Protocol(); + bool checkServerInstallationOK(); + void sendHeadposeToGame( double *headpose, double *rawheadpose ); +private: + + bool blnConnectionActive; + + // Tracker *headTracker; // For upstream messages... + TFlightGearData FlightData; + QUdpSocket *inSocket; // Receive from FligthGear + QUdpSocket *outSocket; // Send to FligthGear + qint32 cmd; + qint32 fg_cmd; // Command from FlightGear + QHostAddress destIP; // Destination IP-address + int destPort; // Destination port-number + void loadSettings(); + QString getGameName() { + return "FlightGear"; + } +}; + +// Widget that has controls for FTNoIR protocol client-settings. +class FGControls: public QWidget, public IProtocolDialog +{ + Q_OBJECT +public: + + explicit FGControls(); + virtual ~FGControls(); + void showEvent ( QShowEvent * event ); + + void Initialize(QWidget *parent); + void registerProtocol(IProtocol *protocol) { + theProtocol = (FTNoIR_Protocol *) protocol; // Accept the pointer to the Protocol + } + void unRegisterProtocol() { + theProtocol = NULL; // Reset the pointer + } + +private: + Ui::UICFGControls ui; + void loadSettings(); + void save(); + + /** helper **/ + bool settingsDirty; + FTNoIR_Protocol *theProtocol; + +private slots: + void doOK(); + void doCancel(); + void chkLocalPCOnlyChanged(); + void settingChanged() { settingsDirty = true; } +}; + +//******************************************************************************************************* +// FaceTrackNoIR Protocol DLL. Functions used to get general info on the Protocol +//******************************************************************************************************* +class FTNoIR_ProtocolDll : public Metadata +{ +public: + FTNoIR_ProtocolDll(); + ~FTNoIR_ProtocolDll(); + + void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("FlightGear"); } + void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("FlightGear"); } + void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("FlightGear UDP protocol"); } + + void getIcon(QIcon *icon) { *icon = QIcon(":/images/flightgear.png"); } +}; + + +#endif//INCLUDED_FGSERVER_H +//END diff --git a/ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp b/ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp index b01f529b..2acd3f9c 100644 --- a/ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp +++ b/ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp @@ -1,215 +1,215 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of the some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2010 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -* FGServer FGServer is the Class, that communicates headpose-data * -* to FlightGear, using UDP. * -* It is based on the (Linux) example made by Melchior FRANZ. * -********************************************************************************/ -#include "ftnoir_protocol_fg.h" -#include -#include "facetracknoir/global-settings.h" - -//******************************************************************************************************* -// FaceTrackNoIR Client Settings-dialog. -//******************************************************************************************************* - -// -// Constructor for server-settings-dialog -// -FGControls::FGControls() : -QWidget() -{ - ui.setupUi( this ); - - QPoint offsetpos(100, 100); - //if (parent) { - // this->move(parent->pos() + offsetpos); - //} - - // Connect Qt signals to member-functions - connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); - connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); - connect(ui.chkLocalPC, SIGNAL(stateChanged(int)), this, SLOT(chkLocalPCOnlyChanged())); - connect(ui.spinIPFirstNibble, SIGNAL(valueChanged(int)), this, SLOT(settingChanged())); - connect(ui.spinIPSecondNibble, SIGNAL(valueChanged(int)), this, SLOT(settingChanged())); - connect(ui.spinIPThirdNibble, SIGNAL(valueChanged(int)), this, SLOT(settingChanged())); - connect(ui.spinIPFourthNibble, SIGNAL(valueChanged(int)), this, SLOT(settingChanged())); - connect(ui.spinPortNumber, SIGNAL(valueChanged(int)), this, SLOT(settingChanged())); - - theProtocol = NULL; - - // Load the settings from the current .INI-file - loadSettings(); -} - -// -// Destructor for server-dialog -// -FGControls::~FGControls() { - qDebug() << "~FGControls() says: started"; -} - -// -// Initialize tracker-client-dialog -// -void FGControls::Initialize(QWidget *parent) { - - QPoint offsetpos(100, 100); - if (parent) { - this->move(parent->pos() + offsetpos); - } - show(); -} - -// -// OK clicked on server-dialog -// -void FGControls::doOK() { - save(); - this->close(); -} - -// override show event -void FGControls::showEvent ( QShowEvent * event ) { - loadSettings(); -} - -// -// Cancel clicked on server-dialog -// -void FGControls::doCancel() { - // - // Ask if changed Settings should be saved - // - if (settingsDirty) { - int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard ); - - qDebug() << "doCancel says: answer =" << ret; - - switch (ret) { - case QMessageBox::Save: - save(); - this->close(); - break; - case QMessageBox::Discard: - this->close(); - break; - case QMessageBox::Cancel: - // Cancel was clicked - break; - default: - // should never be reached - break; - } - } - else { - this->close(); - } -} - -// -// Load the current Settings from the currently 'active' INI-file. -// -void FGControls::loadSettings() { -// qDebug() << "loadSettings says: Starting "; - QSettings settings("opentrack"); // 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; - - iniFile.beginGroup ( "FG" ); - ui.chkLocalPC->setChecked (iniFile.value ( "LocalPCOnly", 1 ).toBool()); - - ui.spinIPFirstNibble->setValue( iniFile.value ( "IP-1", 192 ).toInt() ); - ui.spinIPSecondNibble->setValue( iniFile.value ( "IP-2", 168 ).toInt() ); - ui.spinIPThirdNibble->setValue( iniFile.value ( "IP-3", 2 ).toInt() ); - ui.spinIPFourthNibble->setValue( iniFile.value ( "IP-4", 1 ).toInt() ); - - ui.spinPortNumber->setValue( iniFile.value ( "PortNumber", 5550 ).toInt() ); - iniFile.endGroup (); - - chkLocalPCOnlyChanged(); - settingsDirty = false; -} - -// -// Save the current Settings to the currently 'active' INI-file. -// -void FGControls::save() { - QSettings settings("opentrack"); // 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) - - iniFile.beginGroup ( "FG" ); - iniFile.setValue ( "LocalPCOnly", ui.chkLocalPC->isChecked() ); - iniFile.setValue ( "IP-1", ui.spinIPFirstNibble->value() ); - iniFile.setValue ( "IP-2", ui.spinIPSecondNibble->value() ); - iniFile.setValue ( "IP-3", ui.spinIPThirdNibble->value() ); - iniFile.setValue ( "IP-4", ui.spinIPFourthNibble->value() ); - iniFile.setValue ( "PortNumber", ui.spinPortNumber->value() ); - iniFile.endGroup (); - - settingsDirty = false; -} - -// -// Handle change of the checkbox. -// -void FGControls::chkLocalPCOnlyChanged() { - - if ( ui.chkLocalPC->isChecked() ) { - ui.spinIPFirstNibble->setValue( 127 ); - ui.spinIPFirstNibble->setEnabled ( false ); - ui.spinIPSecondNibble->setValue( 0 ); - ui.spinIPSecondNibble->setEnabled ( false ); - ui.spinIPThirdNibble->setValue( 0 ); - ui.spinIPThirdNibble->setEnabled ( false ); - ui.spinIPFourthNibble->setValue( 1 ); - ui.spinIPFourthNibble->setEnabled ( false ); - } - else { - ui.spinIPFirstNibble->setEnabled ( true ); - ui.spinIPSecondNibble->setEnabled ( true ); - ui.spinIPThirdNibble->setEnabled ( true ); - ui.spinIPFourthNibble->setEnabled ( true ); - } - - settingsDirty = true; -} - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Protocol-settings dialog object. - -// Export both decorated and undecorated names. -// GetProtocolDialog - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetProtocolDialog@0 - Common name decoration for __stdcall functions in C language. -//#pragma comment(linker, "/export:GetProtocolDialog=_GetProtocolDialog@0") - -extern "C" FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDialog* CALLING_CONVENTION GetDialog( ) -{ - return new FGControls; -} +/******************************************************************************** +* FaceTrackNoIR This program is a private project of the some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2010 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +* FGServer FGServer is the Class, that communicates headpose-data * +* to FlightGear, using UDP. * +* It is based on the (Linux) example made by Melchior FRANZ. * +********************************************************************************/ +#include "ftnoir_protocol_fg.h" +#include +#include "facetracknoir/global-settings.h" + +//******************************************************************************************************* +// FaceTrackNoIR Client Settings-dialog. +//******************************************************************************************************* + +// +// Constructor for server-settings-dialog +// +FGControls::FGControls() : +QWidget() +{ + ui.setupUi( this ); + + QPoint offsetpos(100, 100); + //if (parent) { + // this->move(parent->pos() + offsetpos); + //} + + // Connect Qt signals to member-functions + connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); + connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); + connect(ui.chkLocalPC, SIGNAL(stateChanged(int)), this, SLOT(chkLocalPCOnlyChanged())); + connect(ui.spinIPFirstNibble, SIGNAL(valueChanged(int)), this, SLOT(settingChanged())); + connect(ui.spinIPSecondNibble, SIGNAL(valueChanged(int)), this, SLOT(settingChanged())); + connect(ui.spinIPThirdNibble, SIGNAL(valueChanged(int)), this, SLOT(settingChanged())); + connect(ui.spinIPFourthNibble, SIGNAL(valueChanged(int)), this, SLOT(settingChanged())); + connect(ui.spinPortNumber, SIGNAL(valueChanged(int)), this, SLOT(settingChanged())); + + theProtocol = NULL; + + // Load the settings from the current .INI-file + loadSettings(); +} + +// +// Destructor for server-dialog +// +FGControls::~FGControls() { + qDebug() << "~FGControls() says: started"; +} + +// +// Initialize tracker-client-dialog +// +void FGControls::Initialize(QWidget *parent) { + + QPoint offsetpos(100, 100); + if (parent) { + this->move(parent->pos() + offsetpos); + } + show(); +} + +// +// OK clicked on server-dialog +// +void FGControls::doOK() { + save(); + this->close(); +} + +// override show event +void FGControls::showEvent ( QShowEvent * event ) { + loadSettings(); +} + +// +// Cancel clicked on server-dialog +// +void FGControls::doCancel() { + // + // Ask if changed Settings should be saved + // + if (settingsDirty) { + int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard ); + + qDebug() << "doCancel says: answer =" << ret; + + switch (ret) { + case QMessageBox::Save: + save(); + this->close(); + break; + case QMessageBox::Discard: + this->close(); + break; + case QMessageBox::Cancel: + // Cancel was clicked + break; + default: + // should never be reached + break; + } + } + else { + this->close(); + } +} + +// +// Load the current Settings from the currently 'active' INI-file. +// +void FGControls::loadSettings() { +// qDebug() << "loadSettings says: Starting "; + QSettings settings("opentrack"); // 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; + + iniFile.beginGroup ( "FG" ); + ui.chkLocalPC->setChecked (iniFile.value ( "LocalPCOnly", 1 ).toBool()); + + ui.spinIPFirstNibble->setValue( iniFile.value ( "IP-1", 192 ).toInt() ); + ui.spinIPSecondNibble->setValue( iniFile.value ( "IP-2", 168 ).toInt() ); + ui.spinIPThirdNibble->setValue( iniFile.value ( "IP-3", 2 ).toInt() ); + ui.spinIPFourthNibble->setValue( iniFile.value ( "IP-4", 1 ).toInt() ); + + ui.spinPortNumber->setValue( iniFile.value ( "PortNumber", 5550 ).toInt() ); + iniFile.endGroup (); + + chkLocalPCOnlyChanged(); + settingsDirty = false; +} + +// +// Save the current Settings to the currently 'active' INI-file. +// +void FGControls::save() { + QSettings settings("opentrack"); // 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) + + iniFile.beginGroup ( "FG" ); + iniFile.setValue ( "LocalPCOnly", ui.chkLocalPC->isChecked() ); + iniFile.setValue ( "IP-1", ui.spinIPFirstNibble->value() ); + iniFile.setValue ( "IP-2", ui.spinIPSecondNibble->value() ); + iniFile.setValue ( "IP-3", ui.spinIPThirdNibble->value() ); + iniFile.setValue ( "IP-4", ui.spinIPFourthNibble->value() ); + iniFile.setValue ( "PortNumber", ui.spinPortNumber->value() ); + iniFile.endGroup (); + + settingsDirty = false; +} + +// +// Handle change of the checkbox. +// +void FGControls::chkLocalPCOnlyChanged() { + + if ( ui.chkLocalPC->isChecked() ) { + ui.spinIPFirstNibble->setValue( 127 ); + ui.spinIPFirstNibble->setEnabled ( false ); + ui.spinIPSecondNibble->setValue( 0 ); + ui.spinIPSecondNibble->setEnabled ( false ); + ui.spinIPThirdNibble->setValue( 0 ); + ui.spinIPThirdNibble->setEnabled ( false ); + ui.spinIPFourthNibble->setValue( 1 ); + ui.spinIPFourthNibble->setEnabled ( false ); + } + else { + ui.spinIPFirstNibble->setEnabled ( true ); + ui.spinIPSecondNibble->setEnabled ( true ); + ui.spinIPThirdNibble->setEnabled ( true ); + ui.spinIPFourthNibble->setEnabled ( true ); + } + + settingsDirty = true; +} + +//////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Protocol-settings dialog object. + +// Export both decorated and undecorated names. +// GetProtocolDialog - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetProtocolDialog@0 - Common name decoration for __stdcall functions in C language. +//#pragma comment(linker, "/export:GetProtocolDialog=_GetProtocolDialog@0") + +extern "C" FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDialog* CALLING_CONVENTION GetDialog( ) +{ + return new FGControls; +} diff --git a/ftnoir_protocol_fg/ftnoir_protocol_fg_dll.cpp b/ftnoir_protocol_fg/ftnoir_protocol_fg_dll.cpp index 8d9dcf8f..6c7e7c52 100644 --- a/ftnoir_protocol_fg/ftnoir_protocol_fg_dll.cpp +++ b/ftnoir_protocol_fg/ftnoir_protocol_fg_dll.cpp @@ -1,49 +1,49 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2012 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -********************************************************************************/ -#include "ftnoir_protocol_fg.h" -#include -#include "facetracknoir/global-settings.h" - -FTNoIR_ProtocolDll::FTNoIR_ProtocolDll() { -} - -FTNoIR_ProtocolDll::~FTNoIR_ProtocolDll() -{ - -} - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Protocol object. - -// Export both decorated and undecorated names. -// GetProtocolDll - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetProtocolDll@0 - Common name decoration for __stdcall functions in C language. -//#pragma comment(linker, "/export:GetProtocolDll=_GetProtocolDll@0") - -extern "C" FTNOIR_PROTOCOL_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata() -{ - return new FTNoIR_ProtocolDll; -} +/******************************************************************************** +* FaceTrackNoIR This program is a private project of some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2012 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +********************************************************************************/ +#include "ftnoir_protocol_fg.h" +#include +#include "facetracknoir/global-settings.h" + +FTNoIR_ProtocolDll::FTNoIR_ProtocolDll() { +} + +FTNoIR_ProtocolDll::~FTNoIR_ProtocolDll() +{ + +} + +//////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Protocol object. + +// Export both decorated and undecorated names. +// GetProtocolDll - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetProtocolDll@0 - Common name decoration for __stdcall functions in C language. +//#pragma comment(linker, "/export:GetProtocolDll=_GetProtocolDll@0") + +extern "C" FTNOIR_PROTOCOL_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata() +{ + return new FTNoIR_ProtocolDll; +} diff --git a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp index e4dbc614..ba053e11 100644 --- a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp +++ b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp @@ -1,205 +1,205 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of the some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2010-2011 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -* FSUIPCServer FSUIPCServer is the Class, that communicates headpose-data * -* to games, using the FSUIPC.dll. * -********************************************************************************/ -#include "ftnoir_protocol_fsuipc.h" -#include "facetracknoir/global-settings.h" - -/** constructor **/ -FTNoIR_Protocol::FTNoIR_Protocol() -{ - loadSettings(); - ProgramName = "Microsoft FS2004"; - - prevPosX = 0.0f; - prevPosY = 0.0f; - prevPosZ = 0.0f; - prevRotX = 0.0f; - prevRotY = 0.0f; - prevRotZ = 0.0f; -} - -/** destructor **/ -FTNoIR_Protocol::~FTNoIR_Protocol() -{ - // - // Free the DLL - // - FSUIPCLib.unload(); -} - -// -// Scale the measured value to the Joystick values -// -int FTNoIR_Protocol::scale2AnalogLimits( float x, float min_x, float max_x ) { -double y; -double local_x; - - local_x = x; - if (local_x > max_x) { - local_x = max_x; - } - if (local_x < min_x) { - local_x = min_x; - } - y = ( 16383 * local_x ) / max_x; - - return (int) y; -} - -// -// Load the current Settings from the currently 'active' INI-file. -// -void FTNoIR_Protocol::loadSettings() { - QSettings settings("opentrack"); // 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) - - iniFile.beginGroup ( "FSUIPC" ); - LocationOfDLL = iniFile.value ( "LocationOfDLL", FSUIPC_FILENAME ).toString(); - qDebug() << "FSUIPCServer::loadSettings() says: Location of DLL = " << LocationOfDLL; - iniFile.endGroup (); -} - -// -// Update Headpose in Game. -// -void FTNoIR_Protocol::sendHeadposeToGame(double *headpose, double *rawheadpose ) { -DWORD result; -TFSState pitch; -TFSState yaw; -TFSState roll; -WORD FSZoom; - -float virtPosX; -float virtPosY; -float virtPosZ; - -float virtRotX; -float virtRotY; -float virtRotZ; - -// qDebug() << "FSUIPCServer::run() says: started!"; - - virtRotX = -headpose[Pitch]; // degrees - virtRotY = headpose[Yaw]; - virtRotZ = headpose[Roll]; - - virtPosX = 0.0f; // cm, X and Y are not working for FS2002/2004! - virtPosY = 0.0f; - virtPosZ = headpose[TZ]; - - // - // Init. the FSUIPC offsets (derived from Free-track...) - // - pitch.Control = 66503; - yaw.Control = 66504; - roll.Control = 66505; - - // - // Only do this when the data has changed. This way, the HAT-switch can be used when tracking is OFF. - // - if ((prevPosX != virtPosX) || (prevPosY != virtPosY) || (prevPosZ != virtPosZ) || - (prevRotX != virtRotX) || (prevRotY != virtRotY) || (prevRotZ != virtRotZ)) { - // - // Open the connection - // - FSUIPC_Open(SIM_ANY, &result); - - // - // Check the FS-version - // - if (((result == FSUIPC_ERR_OK) || (result == FSUIPC_ERR_OPEN)) && - ((FSUIPC_FS_Version == SIM_FS2K2) || (FSUIPC_FS_Version == SIM_FS2K4))) { -// qDebug() << "FSUIPCServer::run() says: FSUIPC opened succesfully"; - // - // Write the 4! DOF-data to FS. Only rotations and zoom are possible. - // - pitch.Value = scale2AnalogLimits(virtRotX, -180, 180); - FSUIPC_Write(0x3110, 8, &pitch, &result); - - yaw.Value = scale2AnalogLimits(virtRotY, -180, 180); - FSUIPC_Write(0x3110, 8, &yaw, &result); - - roll.Value = scale2AnalogLimits(virtRotZ, -180, 180); - FSUIPC_Write(0x3110, 8, &roll, &result); - - FSZoom = (WORD) (64/50) * virtPosZ + 64; - FSUIPC_Write(0x832E, 2, &FSZoom, &result); - - // - // Write the data, in one go! - // - FSUIPC_Process(&result); - if (result == FSUIPC_ERR_SENDMSG) { - FSUIPC_Close(); //timeout (1 second) so assume FS closed - } - } - } - - prevPosX = virtPosX; - prevPosY = virtPosY; - prevPosZ = virtPosZ; - prevRotX = virtRotX; - prevRotY = virtRotY; - prevRotZ = virtRotZ; -} - -// -// Returns 'true' if all seems OK. -// -bool FTNoIR_Protocol::checkServerInstallationOK() -{ - qDebug() << "checkServerInstallationOK says: Starting Function"; - - // - // Load the DLL. - // - FSUIPCLib.setFileName( LocationOfDLL ); - if (FSUIPCLib.load() != true) { - qDebug() << "checkServerInstallationOK says: Error loading FSUIPC DLL"; - return false; - } - else { - qDebug() << "checkServerInstallationOK says: FSUIPC DLL loaded."; - } - - return true; -} - -/////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Protocol object. - -// Export both decorated and undecorated names. -// GetProtocol - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetProtocol@0 - Common name decoration for __stdcall functions in C language. -//#pragma comment(linker, "/export:GetProtocol=_GetProtocol@0") - -extern "C" FTNOIR_PROTOCOL_BASE_EXPORT FTNoIR_Protocol* CALLING_CONVENTION GetConstructor(void) -{ - return new FTNoIR_Protocol; -} +/******************************************************************************** +* FaceTrackNoIR This program is a private project of the some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2010-2011 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +* FSUIPCServer FSUIPCServer is the Class, that communicates headpose-data * +* to games, using the FSUIPC.dll. * +********************************************************************************/ +#include "ftnoir_protocol_fsuipc.h" +#include "facetracknoir/global-settings.h" + +/** constructor **/ +FTNoIR_Protocol::FTNoIR_Protocol() +{ + loadSettings(); + ProgramName = "Microsoft FS2004"; + + prevPosX = 0.0f; + prevPosY = 0.0f; + prevPosZ = 0.0f; + prevRotX = 0.0f; + prevRotY = 0.0f; + prevRotZ = 0.0f; +} + +/** destructor **/ +FTNoIR_Protocol::~FTNoIR_Protocol() +{ + // + // Free the DLL + // + FSUIPCLib.unload(); +} + +// +// Scale the measured value to the Joystick values +// +int FTNoIR_Protocol::scale2AnalogLimits( float x, float min_x, float max_x ) { +double y; +double local_x; + + local_x = x; + if (local_x > max_x) { + local_x = max_x; + } + if (local_x < min_x) { + local_x = min_x; + } + y = ( 16383 * local_x ) / max_x; + + return (int) y; +} + +// +// Load the current Settings from the currently 'active' INI-file. +// +void FTNoIR_Protocol::loadSettings() { + QSettings settings("opentrack"); // 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) + + iniFile.beginGroup ( "FSUIPC" ); + LocationOfDLL = iniFile.value ( "LocationOfDLL", FSUIPC_FILENAME ).toString(); + qDebug() << "FSUIPCServer::loadSettings() says: Location of DLL = " << LocationOfDLL; + iniFile.endGroup (); +} + +// +// Update Headpose in Game. +// +void FTNoIR_Protocol::sendHeadposeToGame(double *headpose, double *rawheadpose ) { +DWORD result; +TFSState pitch; +TFSState yaw; +TFSState roll; +WORD FSZoom; + +float virtPosX; +float virtPosY; +float virtPosZ; + +float virtRotX; +float virtRotY; +float virtRotZ; + +// qDebug() << "FSUIPCServer::run() says: started!"; + + virtRotX = -headpose[Pitch]; // degrees + virtRotY = headpose[Yaw]; + virtRotZ = headpose[Roll]; + + virtPosX = 0.0f; // cm, X and Y are not working for FS2002/2004! + virtPosY = 0.0f; + virtPosZ = headpose[TZ]; + + // + // Init. the FSUIPC offsets (derived from Free-track...) + // + pitch.Control = 66503; + yaw.Control = 66504; + roll.Control = 66505; + + // + // Only do this when the data has changed. This way, the HAT-switch can be used when tracking is OFF. + // + if ((prevPosX != virtPosX) || (prevPosY != virtPosY) || (prevPosZ != virtPosZ) || + (prevRotX != virtRotX) || (prevRotY != virtRotY) || (prevRotZ != virtRotZ)) { + // + // Open the connection + // + FSUIPC_Open(SIM_ANY, &result); + + // + // Check the FS-version + // + if (((result == FSUIPC_ERR_OK) || (result == FSUIPC_ERR_OPEN)) && + ((FSUIPC_FS_Version == SIM_FS2K2) || (FSUIPC_FS_Version == SIM_FS2K4))) { +// qDebug() << "FSUIPCServer::run() says: FSUIPC opened succesfully"; + // + // Write the 4! DOF-data to FS. Only rotations and zoom are possible. + // + pitch.Value = scale2AnalogLimits(virtRotX, -180, 180); + FSUIPC_Write(0x3110, 8, &pitch, &result); + + yaw.Value = scale2AnalogLimits(virtRotY, -180, 180); + FSUIPC_Write(0x3110, 8, &yaw, &result); + + roll.Value = scale2AnalogLimits(virtRotZ, -180, 180); + FSUIPC_Write(0x3110, 8, &roll, &result); + + FSZoom = (WORD) (64/50) * virtPosZ + 64; + FSUIPC_Write(0x832E, 2, &FSZoom, &result); + + // + // Write the data, in one go! + // + FSUIPC_Process(&result); + if (result == FSUIPC_ERR_SENDMSG) { + FSUIPC_Close(); //timeout (1 second) so assume FS closed + } + } + } + + prevPosX = virtPosX; + prevPosY = virtPosY; + prevPosZ = virtPosZ; + prevRotX = virtRotX; + prevRotY = virtRotY; + prevRotZ = virtRotZ; +} + +// +// Returns 'true' if all seems OK. +// +bool FTNoIR_Protocol::checkServerInstallationOK() +{ + qDebug() << "checkServerInstallationOK says: Starting Function"; + + // + // Load the DLL. + // + FSUIPCLib.setFileName( LocationOfDLL ); + if (FSUIPCLib.load() != true) { + qDebug() << "checkServerInstallationOK says: Error loading FSUIPC DLL"; + return false; + } + else { + qDebug() << "checkServerInstallationOK says: FSUIPC DLL loaded."; + } + + return true; +} + +/////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Protocol object. + +// Export both decorated and undecorated names. +// GetProtocol - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetProtocol@0 - Common name decoration for __stdcall functions in C language. +//#pragma comment(linker, "/export:GetProtocol=_GetProtocol@0") + +extern "C" FTNOIR_PROTOCOL_BASE_EXPORT FTNoIR_Protocol* CALLING_CONVENTION GetConstructor(void) +{ + return new FTNoIR_Protocol; +} diff --git a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h index 5da1d2ca..99478a54 100644 --- a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h +++ b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h @@ -1,131 +1,131 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2010-2011 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -* FSUIPCServer FSUIPCServer is the Class, that communicates headpose-data * -* to games, using the FSUIPC.dll. * -********************************************************************************/ -#pragma once -#ifndef INCLUDED_FSUIPCSERVER_H -#define INCLUDED_FSUIPCSERVER_H - -#include "Windows.h" -#include -#include "FSUIPC_User.h" -#include "facetracknoir/global-settings.h" - -#include "..\ftnoir_protocol_base\ftnoir_protocol_base.h" -#include "ui_FTNoIR_FSUIPCcontrols.h" -#include -#include -#include -#include -#include -#include -#include - -#define FSUIPC_FILENAME "C:\\Program Files\\Microsoft Games\\Flight Simulator 9\\Modules\\FSUIPC.dll" - -// -// Define the structures necessary for the FSUIPC_Write calls -// -#pragma pack(push,1) // All fields in structure must be byte aligned. -typedef struct -{ - int Control; // Control identifier - int Value; // Value of DOF -} TFSState; -#pragma pack(pop) - -class FTNoIR_Protocol : public IProtocol -{ -public: - FTNoIR_Protocol(); - ~FTNoIR_Protocol(); - bool checkServerInstallationOK(); - void sendHeadposeToGame( double *headpose, double *rawheadpose ); - QString getGameName() { - return "Microsoft Flight Simulator X"; - } -private: - // Private properties - QString ProgramName; - QLibrary FSUIPCLib; - QString LocationOfDLL; - float prevPosX, prevPosY, prevPosZ, prevRotX, prevRotY, prevRotZ; - - static int scale2AnalogLimits( float x, float min_x, float max_x ); - void loadSettings(); -}; - -// Widget that has controls for FTNoIR protocol client-settings. -class FSUIPCControls: public QWidget, public IProtocolDialog -{ - Q_OBJECT -public: - - explicit FSUIPCControls(); - virtual ~FSUIPCControls(); - void showEvent ( QShowEvent * event ); - void Initialize(QWidget *parent); - void registerProtocol(IProtocol *protocol) { - theProtocol = (FTNoIR_Protocol *) protocol; // Accept the pointer to the Protocol - } - void unRegisterProtocol() { - theProtocol = NULL; // Reset the pointer - } - -private: - Ui::UICFSUIPCControls ui; - void loadSettings(); - void save(); - - /** helper **/ - bool settingsDirty; - FTNoIR_Protocol *theProtocol; - -private slots: - void doOK(); - void doCancel(); - void settingChanged() { settingsDirty = true; }; - void getLocationOfDLL(); -}; - -//******************************************************************************************************* -// FaceTrackNoIR Protocol DLL. Functions used to get general info on the Protocol -//******************************************************************************************************* -class FTNoIR_ProtocolDll : public Metadata -{ -public: - FTNoIR_ProtocolDll(); - ~FTNoIR_ProtocolDll(); - - void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("FS2002/FS2004"); }; - void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("FSUIPC"); }; - void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("Microsoft FS2004 protocol"); }; - - void getIcon(QIcon *icon) { *icon = QIcon(":/images/fs9.png"); }; -}; - - -#endif//INCLUDED_FSUIPCSERVER_H -//END +/******************************************************************************** +* FaceTrackNoIR This program is a private project of some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2010-2011 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +* FSUIPCServer FSUIPCServer is the Class, that communicates headpose-data * +* to games, using the FSUIPC.dll. * +********************************************************************************/ +#pragma once +#ifndef INCLUDED_FSUIPCSERVER_H +#define INCLUDED_FSUIPCSERVER_H + +#include "Windows.h" +#include +#include "FSUIPC_User.h" +#include "facetracknoir/global-settings.h" + +#include "..\ftnoir_protocol_base\ftnoir_protocol_base.h" +#include "ui_FTNoIR_FSUIPCcontrols.h" +#include +#include +#include +#include +#include +#include +#include + +#define FSUIPC_FILENAME "C:\\Program Files\\Microsoft Games\\Flight Simulator 9\\Modules\\FSUIPC.dll" + +// +// Define the structures necessary for the FSUIPC_Write calls +// +#pragma pack(push,1) // All fields in structure must be byte aligned. +typedef struct +{ + int Control; // Control identifier + int Value; // Value of DOF +} TFSState; +#pragma pack(pop) + +class FTNoIR_Protocol : public IProtocol +{ +public: + FTNoIR_Protocol(); + ~FTNoIR_Protocol(); + bool checkServerInstallationOK(); + void sendHeadposeToGame( double *headpose, double *rawheadpose ); + QString getGameName() { + return "Microsoft Flight Simulator X"; + } +private: + // Private properties + QString ProgramName; + QLibrary FSUIPCLib; + QString LocationOfDLL; + float prevPosX, prevPosY, prevPosZ, prevRotX, prevRotY, prevRotZ; + + static int scale2AnalogLimits( float x, float min_x, float max_x ); + void loadSettings(); +}; + +// Widget that has controls for FTNoIR protocol client-settings. +class FSUIPCControls: public QWidget, public IProtocolDialog +{ + Q_OBJECT +public: + + explicit FSUIPCControls(); + virtual ~FSUIPCControls(); + void showEvent ( QShowEvent * event ); + void Initialize(QWidget *parent); + void registerProtocol(IProtocol *protocol) { + theProtocol = (FTNoIR_Protocol *) protocol; // Accept the pointer to the Protocol + } + void unRegisterProtocol() { + theProtocol = NULL; // Reset the pointer + } + +private: + Ui::UICFSUIPCControls ui; + void loadSettings(); + void save(); + + /** helper **/ + bool settingsDirty; + FTNoIR_Protocol *theProtocol; + +private slots: + void doOK(); + void doCancel(); + void settingChanged() { settingsDirty = true; }; + void getLocationOfDLL(); +}; + +//******************************************************************************************************* +// FaceTrackNoIR Protocol DLL. Functions used to get general info on the Protocol +//******************************************************************************************************* +class FTNoIR_ProtocolDll : public Metadata +{ +public: + FTNoIR_ProtocolDll(); + ~FTNoIR_ProtocolDll(); + + void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("FS2002/FS2004"); }; + void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("FSUIPC"); }; + void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("Microsoft FS2004 protocol"); }; + + void getIcon(QIcon *icon) { *icon = QIcon(":/images/fs9.png"); }; +}; + + +#endif//INCLUDED_FSUIPCSERVER_H +//END diff --git a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dialog.cpp b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dialog.cpp index abe9329c..90ed22b2 100644 --- a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dialog.cpp +++ b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dialog.cpp @@ -1,185 +1,185 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2012 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -********************************************************************************/ -#include "ftnoir_protocol_fsuipc.h" -#include "facetracknoir/global-settings.h" - -//******************************************************************************************************* -// FaceTrackNoIR Client Settings-dialog. -//******************************************************************************************************* - -// -// Constructor for server-settings-dialog -// -FSUIPCControls::FSUIPCControls() : -QWidget() -{ - ui.setupUi( this ); - - // Connect Qt signals to member-functions - connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); - connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); - connect(ui.btnFindDLL, SIGNAL(clicked()), this, SLOT(getLocationOfDLL())); - - theProtocol = NULL; - - // Load the settings from the current .INI-file - loadSettings(); -} - -// -// Destructor for server-dialog -// -FSUIPCControls::~FSUIPCControls() { - qDebug() << "~FSUIPCControls() says: started"; -} - -// -// Initialize tracker-client-dialog -// -void FSUIPCControls::Initialize(QWidget *parent) { - - QPoint offsetpos(100, 100); - if (parent) { - this->move(parent->pos() + offsetpos); - } - show(); -} - -// -// OK clicked on server-dialog -// -void FSUIPCControls::doOK() { - save(); - this->close(); -} - -// override show event -void FSUIPCControls::showEvent ( QShowEvent * event ) { - loadSettings(); -} - -// -// Cancel clicked on server-dialog -// -void FSUIPCControls::doCancel() { - // - // Ask if changed Settings should be saved - // - if (settingsDirty) { - int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard ); - - qDebug() << "doCancel says: answer =" << ret; - - switch (ret) { - case QMessageBox::Save: - save(); - this->close(); - break; - case QMessageBox::Discard: - this->close(); - break; - case QMessageBox::Cancel: - // Cancel was clicked - break; - default: - // should never be reached - break; - } - } - else { - this->close(); - } -} - -// -// Load the current Settings from the currently 'active' INI-file. -// -void FSUIPCControls::loadSettings() { - - qDebug() << "loadSettings says: Starting "; - QSettings settings("opentrack"); // 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; - - iniFile.beginGroup ( "FSUIPC" ); - ui.txtLocationOfDLL->setText(iniFile.value ( "LocationOfDLL", FSUIPC_FILENAME ).toString() ); - iniFile.endGroup (); - - settingsDirty = false; -} - -// -// Save the current Settings to the currently 'active' INI-file. -// -void FSUIPCControls::save() { - - qDebug() << "save() says: started"; - - QSettings settings("opentrack"); // 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) - - iniFile.beginGroup ( "FSUIPC" ); - iniFile.setValue ( "LocationOfDLL", ui.txtLocationOfDLL->text() ); - iniFile.endGroup (); - - settingsDirty = false; -} - -// -// Show the Dialog to set the DLL's location -// -void FSUIPCControls::getLocationOfDLL() -{ - // - // Get the new filename of the INI-file. - // - QString fileName = QFileDialog::getOpenFileName(this, tr("Locate file"), - ui.txtLocationOfDLL->text(), - tr("FSUIPC DLL file (FSUIPC*.dll);;All Files (*)")); - if (!fileName.isEmpty()) { - ui.txtLocationOfDLL->setText( fileName ); - settingsDirty = true; - } -} - - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Protocol-settings dialog object. - -// Export both decorated and undecorated names. -// GetProtocolDialog - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetProtocolDialog@0 - Common name decoration for __stdcall functions in C language. -//#pragma comment(linker, "/export:GetProtocolDialog=_GetProtocolDialog@0") - -extern "C" FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDialog* CALLING_CONVENTION GetDialog(void) -{ - return new FSUIPCControls; -} +/******************************************************************************** +* FaceTrackNoIR This program is a private project of some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2012 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +********************************************************************************/ +#include "ftnoir_protocol_fsuipc.h" +#include "facetracknoir/global-settings.h" + +//******************************************************************************************************* +// FaceTrackNoIR Client Settings-dialog. +//******************************************************************************************************* + +// +// Constructor for server-settings-dialog +// +FSUIPCControls::FSUIPCControls() : +QWidget() +{ + ui.setupUi( this ); + + // Connect Qt signals to member-functions + connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); + connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); + connect(ui.btnFindDLL, SIGNAL(clicked()), this, SLOT(getLocationOfDLL())); + + theProtocol = NULL; + + // Load the settings from the current .INI-file + loadSettings(); +} + +// +// Destructor for server-dialog +// +FSUIPCControls::~FSUIPCControls() { + qDebug() << "~FSUIPCControls() says: started"; +} + +// +// Initialize tracker-client-dialog +// +void FSUIPCControls::Initialize(QWidget *parent) { + + QPoint offsetpos(100, 100); + if (parent) { + this->move(parent->pos() + offsetpos); + } + show(); +} + +// +// OK clicked on server-dialog +// +void FSUIPCControls::doOK() { + save(); + this->close(); +} + +// override show event +void FSUIPCControls::showEvent ( QShowEvent * event ) { + loadSettings(); +} + +// +// Cancel clicked on server-dialog +// +void FSUIPCControls::doCancel() { + // + // Ask if changed Settings should be saved + // + if (settingsDirty) { + int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard ); + + qDebug() << "doCancel says: answer =" << ret; + + switch (ret) { + case QMessageBox::Save: + save(); + this->close(); + break; + case QMessageBox::Discard: + this->close(); + break; + case QMessageBox::Cancel: + // Cancel was clicked + break; + default: + // should never be reached + break; + } + } + else { + this->close(); + } +} + +// +// Load the current Settings from the currently 'active' INI-file. +// +void FSUIPCControls::loadSettings() { + + qDebug() << "loadSettings says: Starting "; + QSettings settings("opentrack"); // 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; + + iniFile.beginGroup ( "FSUIPC" ); + ui.txtLocationOfDLL->setText(iniFile.value ( "LocationOfDLL", FSUIPC_FILENAME ).toString() ); + iniFile.endGroup (); + + settingsDirty = false; +} + +// +// Save the current Settings to the currently 'active' INI-file. +// +void FSUIPCControls::save() { + + qDebug() << "save() says: started"; + + QSettings settings("opentrack"); // 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) + + iniFile.beginGroup ( "FSUIPC" ); + iniFile.setValue ( "LocationOfDLL", ui.txtLocationOfDLL->text() ); + iniFile.endGroup (); + + settingsDirty = false; +} + +// +// Show the Dialog to set the DLL's location +// +void FSUIPCControls::getLocationOfDLL() +{ + // + // Get the new filename of the INI-file. + // + QString fileName = QFileDialog::getOpenFileName(this, tr("Locate file"), + ui.txtLocationOfDLL->text(), + tr("FSUIPC DLL file (FSUIPC*.dll);;All Files (*)")); + if (!fileName.isEmpty()) { + ui.txtLocationOfDLL->setText( fileName ); + settingsDirty = true; + } +} + + +//////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Protocol-settings dialog object. + +// Export both decorated and undecorated names. +// GetProtocolDialog - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetProtocolDialog@0 - Common name decoration for __stdcall functions in C language. +//#pragma comment(linker, "/export:GetProtocolDialog=_GetProtocolDialog@0") + +extern "C" FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDialog* CALLING_CONVENTION GetDialog(void) +{ + return new FSUIPCControls; +} diff --git a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dll.cpp b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dll.cpp index c6ef3e38..b0ca2eee 100644 --- a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dll.cpp +++ b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dll.cpp @@ -1,49 +1,49 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2012 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -********************************************************************************/ -#include "ftnoir_protocol_fsuipc.h" -#include -#include "facetracknoir/global-settings.h" - -FTNoIR_ProtocolDll::FTNoIR_ProtocolDll() { -} - -FTNoIR_ProtocolDll::~FTNoIR_ProtocolDll() -{ - -} - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Protocol object. - -// Export both decorated and undecorated names. -// GetProtocolDll - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetProtocolDll@0 - Common name decoration for __stdcall functions in C language. -//#pragma comment(linker, "/export:GetProtocolDll=_GetProtocolDll@0") - -extern "C" FTNOIR_PROTOCOL_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata(void) -{ - return new FTNoIR_ProtocolDll; -} +/******************************************************************************** +* FaceTrackNoIR This program is a private project of some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2012 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +********************************************************************************/ +#include "ftnoir_protocol_fsuipc.h" +#include +#include "facetracknoir/global-settings.h" + +FTNoIR_ProtocolDll::FTNoIR_ProtocolDll() { +} + +FTNoIR_ProtocolDll::~FTNoIR_ProtocolDll() +{ + +} + +//////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Protocol object. + +// Export both decorated and undecorated names. +// GetProtocolDll - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetProtocolDll@0 - Common name decoration for __stdcall functions in C language. +//#pragma comment(linker, "/export:GetProtocolDll=_GetProtocolDll@0") + +extern "C" FTNOIR_PROTOCOL_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata(void) +{ + return new FTNoIR_ProtocolDll; +} diff --git a/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp b/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp index 6e26c412..597f2a5f 100644 --- a/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp +++ b/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp @@ -1,283 +1,283 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of the some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2013 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -* FTServer FTServer is the Class, that communicates headpose-data * -* to games, using the FreeTrackClient.dll. * -********************************************************************************/ -#include -#include "ftnoir_protocol_ft.h" -#include "ftnoir_csv/csv.h" - -/** constructor **/ -FTNoIR_Protocol::FTNoIR_Protocol() : - shm(FT_MM_DATA, FREETRACK_MUTEX, sizeof(FTMemMap)) -{ - pMemData = (FTMemMap*) shm.mem; - useTIRViews = false; - useDummyExe = false; - intUsedInterface = 0; - - loadSettings(); - - ProgramName = ""; - intGameID = 0; - - viewsStart = 0; - viewsStop = 0; -} - -/** destructor **/ -FTNoIR_Protocol::~FTNoIR_Protocol() -{ - - qDebug()<< "~FTNoIR_Protocol: Destructor started."; - - // - // Stop if started - // - if (viewsStop != NULL) { - qDebug()<< "~FTNoIR_Protocol: Stopping TIRViews."; - viewsStop(); - FTIRViewsLib.unload(); - } -} - -// -// Read the game-data from CSV -// - - -// -// Load the current Settings from the currently 'active' INI-file. -// -void FTNoIR_Protocol::loadSettings() { - QSettings settings("opentrack"); // 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) - - iniFile.beginGroup ( "FT" ); - intUsedInterface = iniFile.value ( "UsedInterface", 0 ).toInt(); - iniFile.endGroup (); - - // - // Use the settings-section from the deprecated fake-TIR protocol, as they are most likely to be found there. - // - iniFile.beginGroup ( "FTIR" ); - useTIRViews = iniFile.value ( "useTIRViews", 0 ).toBool(); - useDummyExe = iniFile.value ( "useDummyExe", 1 ).toBool(); - iniFile.endGroup (); -} - -// -// Update Headpose in Game. -// -void FTNoIR_Protocol::sendHeadposeToGame(double *headpose, double *rawheadpose ) { -float virtPosX; -float virtPosY; -float virtPosZ; - -float virtRotX; -float virtRotY; -float virtRotZ; - -float headPosX; -float headPosY; -float headPosZ; - -float headRotX; -float headRotY; -float headRotZ; - - // - // Scale the Raw measurements to the client measurements. - // - headRotX = getRadsFromDegrees(rawheadpose[Pitch]); - headRotY = getRadsFromDegrees(rawheadpose[Yaw]); - headRotZ = getRadsFromDegrees(rawheadpose[Roll]); - headPosX = rawheadpose[TX] * 10; - headPosY = rawheadpose[TY] * 10; - headPosZ = rawheadpose[TZ] * 10; - - virtRotX = getRadsFromDegrees(headpose[Pitch]); - virtRotY = getRadsFromDegrees(headpose[Yaw]); - virtRotZ = getRadsFromDegrees(headpose[Roll]); - virtPosX = headpose[TX] * 10; - virtPosY = headpose[TY] * 10; - virtPosZ = headpose[TZ] * 10; - - shm.lock(); - - pMemData->data.RawX = headPosX; - pMemData->data.RawY = headPosY; - pMemData->data.RawZ = headPosZ; - pMemData->data.RawPitch = headRotX; - pMemData->data.RawYaw = headRotY; - pMemData->data.RawRoll = headRotZ; - - // - // - pMemData->data.X = virtPosX; - pMemData->data.Y = virtPosY; - pMemData->data.Z = virtPosZ; - pMemData->data.Pitch = virtRotX; - pMemData->data.Yaw = virtRotY; - pMemData->data.Roll = virtRotZ; - - // - // Leave some values 0 yet... - // - pMemData->data.X1 = pMemData->data.DataID + 10; - pMemData->data.X2 = 0; - pMemData->data.X3 = 0; - pMemData->data.X4 = 0; - pMemData->data.Y1 = 0; - pMemData->data.Y2 = 0; - pMemData->data.Y3 = 0; - pMemData->data.Y4 = 0; - - // - // Check if the handle that was sent to the Game, was changed (on x64, this will be done by the ED-API) - // If the "Report Program Name" command arrives (which is a '1', for now), raise the event from here! - // - // - // The game-ID was changed? - // - if (intGameID != pMemData->GameID) - { - QString gamename; - CSV::getGameData(pMemData->GameID, pMemData->table, gamename); - pMemData->GameID2 = pMemData->GameID; - intGameID = pMemData->GameID; - QMutexLocker foo(&this->game_name_mutex); - connected_game = gamename; - } - - pMemData->data.DataID += 1; - - shm.unlock(); -} - -void FTNoIR_Protocol::start_tirviews() { - QString aFileName = QCoreApplication::applicationDirPath() + "/TIRViews.dll"; - if ( QFile::exists( aFileName )) { - FTIRViewsLib.setFileName(aFileName); - FTIRViewsLib.load(); - - viewsStart = (importTIRViewsStart) FTIRViewsLib.resolve("TIRViewsStart"); - if (viewsStart == NULL) { - qDebug() << "FTServer::run() says: TIRViewsStart function not found in DLL!"; - } - else { - qDebug() << "FTServer::run() says: TIRViewsStart executed!"; - viewsStart(); - } - - // - // Load the Stop function from TIRViews.dll. Call it when terminating the thread. - // - viewsStop = (importTIRViewsStop) FTIRViewsLib.resolve("TIRViewsStop"); - if (viewsStop == NULL) { - qDebug() << "FTServer::run() says: TIRViewsStop function not found in DLL!"; - } - } -} - -void FTNoIR_Protocol::start_dummy() { - QString program = QCoreApplication::applicationDirPath() + "/TrackIR.exe"; - dummyTrackIR.startDetached("\"" + program + "\""); - - qDebug() << "FTServer::run() says: TrackIR.exe executed!" << program; -} - -bool FTNoIR_Protocol::checkServerInstallationOK() -{ - QSettings settings("Freetrack", "FreetrackClient"); // Registry settings (in HK_USER) - QSettings settingsTIR("NaturalPoint", "NATURALPOINT\\NPClient Location"); // Registry settings (in HK_USER) - QString aLocation; // Location of Client DLL - - qDebug() << "checkServerInstallationOK says: Starting Function"; - - // - // Write the path in the registry (for FreeTrack and FreeTrack20), for the game(s). - // - aLocation = QCoreApplication::applicationDirPath() + "/"; - - qDebug() << "checkServerInstallationOK says: used interface = " << intUsedInterface; - switch (intUsedInterface) { - case 0: // Use both interfaces - settings.setValue( "Path" , aLocation ); - settingsTIR.setValue( "Path" , aLocation ); - break; - case 1: // Use FreeTrack, disable TrackIR - settings.setValue( "Path" , aLocation ); - settingsTIR.setValue( "Path" , "" ); - break; - case 2: // Use TrackIR, disable FreeTrack - settings.setValue( "Path" , "" ); - settingsTIR.setValue( "Path" , aLocation ); - break; - default: - // should never be reached - break; - } - - // - // TIRViews must be started first, or the NPClient DLL will never be loaded. - // - if (useTIRViews) { - start_tirviews(); - } - - // - // Check if TIRViews or dummy TrackIR.exe is required for this game - // - if (useDummyExe) { - start_dummy(); - } - - if (shm.mem == (void*) 0 || shm.mem == (void*) -1) - return false; - - pMemData->data.DataID = 1; - pMemData->data.CamWidth = 100; - pMemData->data.CamHeight = 250; - pMemData->GameID2 = 0; - memset(pMemData->table, 0, 8); - - return true; -} - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Protocol object. - -// Export both decorated and undecorated names. -// GetProtocol - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetProtocol@0 - Common name decoration for __stdcall functions in C language. -//#pragma comment(linker, "/export:GetProtocol=_GetProtocol@0") - -extern "C" FTNOIR_PROTOCOL_BASE_EXPORT IProtocol* CALLING_CONVENTION GetConstructor() -{ - return new FTNoIR_Protocol; -} +/******************************************************************************** +* FaceTrackNoIR This program is a private project of the some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2013 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +* FTServer FTServer is the Class, that communicates headpose-data * +* to games, using the FreeTrackClient.dll. * +********************************************************************************/ +#include +#include "ftnoir_protocol_ft.h" +#include "ftnoir_csv/csv.h" + +/** constructor **/ +FTNoIR_Protocol::FTNoIR_Protocol() : + shm(FT_MM_DATA, FREETRACK_MUTEX, sizeof(FTMemMap)) +{ + pMemData = (FTMemMap*) shm.mem; + useTIRViews = false; + useDummyExe = false; + intUsedInterface = 0; + + loadSettings(); + + ProgramName = ""; + intGameID = 0; + + viewsStart = 0; + viewsStop = 0; +} + +/** destructor **/ +FTNoIR_Protocol::~FTNoIR_Protocol() +{ + + qDebug()<< "~FTNoIR_Protocol: Destructor started."; + + // + // Stop if started + // + if (viewsStop != NULL) { + qDebug()<< "~FTNoIR_Protocol: Stopping TIRViews."; + viewsStop(); + FTIRViewsLib.unload(); + } +} + +// +// Read the game-data from CSV +// + + +// +// Load the current Settings from the currently 'active' INI-file. +// +void FTNoIR_Protocol::loadSettings() { + QSettings settings("opentrack"); // 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) + + iniFile.beginGroup ( "FT" ); + intUsedInterface = iniFile.value ( "UsedInterface", 0 ).toInt(); + iniFile.endGroup (); + + // + // Use the settings-section from the deprecated fake-TIR protocol, as they are most likely to be found there. + // + iniFile.beginGroup ( "FTIR" ); + useTIRViews = iniFile.value ( "useTIRViews", 0 ).toBool(); + useDummyExe = iniFile.value ( "useDummyExe", 1 ).toBool(); + iniFile.endGroup (); +} + +// +// Update Headpose in Game. +// +void FTNoIR_Protocol::sendHeadposeToGame(double *headpose, double *rawheadpose ) { +float virtPosX; +float virtPosY; +float virtPosZ; + +float virtRotX; +float virtRotY; +float virtRotZ; + +float headPosX; +float headPosY; +float headPosZ; + +float headRotX; +float headRotY; +float headRotZ; + + // + // Scale the Raw measurements to the client measurements. + // + headRotX = getRadsFromDegrees(rawheadpose[Pitch]); + headRotY = getRadsFromDegrees(rawheadpose[Yaw]); + headRotZ = getRadsFromDegrees(rawheadpose[Roll]); + headPosX = rawheadpose[TX] * 10; + headPosY = rawheadpose[TY] * 10; + headPosZ = rawheadpose[TZ] * 10; + + virtRotX = getRadsFromDegrees(headpose[Pitch]); + virtRotY = getRadsFromDegrees(headpose[Yaw]); + virtRotZ = getRadsFromDegrees(headpose[Roll]); + virtPosX = headpose[TX] * 10; + virtPosY = headpose[TY] * 10; + virtPosZ = headpose[TZ] * 10; + + shm.lock(); + + pMemData->data.RawX = headPosX; + pMemData->data.RawY = headPosY; + pMemData->data.RawZ = headPosZ; + pMemData->data.RawPitch = headRotX; + pMemData->data.RawYaw = headRotY; + pMemData->data.RawRoll = headRotZ; + + // + // + pMemData->data.X = virtPosX; + pMemData->data.Y = virtPosY; + pMemData->data.Z = virtPosZ; + pMemData->data.Pitch = virtRotX; + pMemData->data.Yaw = virtRotY; + pMemData->data.Roll = virtRotZ; + + // + // Leave some values 0 yet... + // + pMemData->data.X1 = pMemData->data.DataID + 10; + pMemData->data.X2 = 0; + pMemData->data.X3 = 0; + pMemData->data.X4 = 0; + pMemData->data.Y1 = 0; + pMemData->data.Y2 = 0; + pMemData->data.Y3 = 0; + pMemData->data.Y4 = 0; + + // + // Check if the handle that was sent to the Game, was changed (on x64, this will be done by the ED-API) + // If the "Report Program Name" command arrives (which is a '1', for now), raise the event from here! + // + // + // The game-ID was changed? + // + if (intGameID != pMemData->GameID) + { + QString gamename; + CSV::getGameData(pMemData->GameID, pMemData->table, gamename); + pMemData->GameID2 = pMemData->GameID; + intGameID = pMemData->GameID; + QMutexLocker foo(&this->game_name_mutex); + connected_game = gamename; + } + + pMemData->data.DataID += 1; + + shm.unlock(); +} + +void FTNoIR_Protocol::start_tirviews() { + QString aFileName = QCoreApplication::applicationDirPath() + "/TIRViews.dll"; + if ( QFile::exists( aFileName )) { + FTIRViewsLib.setFileName(aFileName); + FTIRViewsLib.load(); + + viewsStart = (importTIRViewsStart) FTIRViewsLib.resolve("TIRViewsStart"); + if (viewsStart == NULL) { + qDebug() << "FTServer::run() says: TIRViewsStart function not found in DLL!"; + } + else { + qDebug() << "FTServer::run() says: TIRViewsStart executed!"; + viewsStart(); + } + + // + // Load the Stop function from TIRViews.dll. Call it when terminating the thread. + // + viewsStop = (importTIRViewsStop) FTIRViewsLib.resolve("TIRViewsStop"); + if (viewsStop == NULL) { + qDebug() << "FTServer::run() says: TIRViewsStop function not found in DLL!"; + } + } +} + +void FTNoIR_Protocol::start_dummy() { + QString program = QCoreApplication::applicationDirPath() + "/TrackIR.exe"; + dummyTrackIR.startDetached("\"" + program + "\""); + + qDebug() << "FTServer::run() says: TrackIR.exe executed!" << program; +} + +bool FTNoIR_Protocol::checkServerInstallationOK() +{ + QSettings settings("Freetrack", "FreetrackClient"); // Registry settings (in HK_USER) + QSettings settingsTIR("NaturalPoint", "NATURALPOINT\\NPClient Location"); // Registry settings (in HK_USER) + QString aLocation; // Location of Client DLL + + qDebug() << "checkServerInstallationOK says: Starting Function"; + + // + // Write the path in the registry (for FreeTrack and FreeTrack20), for the game(s). + // + aLocation = QCoreApplication::applicationDirPath() + "/"; + + qDebug() << "checkServerInstallationOK says: used interface = " << intUsedInterface; + switch (intUsedInterface) { + case 0: // Use both interfaces + settings.setValue( "Path" , aLocation ); + settingsTIR.setValue( "Path" , aLocation ); + break; + case 1: // Use FreeTrack, disable TrackIR + settings.setValue( "Path" , aLocation ); + settingsTIR.setValue( "Path" , "" ); + break; + case 2: // Use TrackIR, disable FreeTrack + settings.setValue( "Path" , "" ); + settingsTIR.setValue( "Path" , aLocation ); + break; + default: + // should never be reached + break; + } + + // + // TIRViews must be started first, or the NPClient DLL will never be loaded. + // + if (useTIRViews) { + start_tirviews(); + } + + // + // Check if TIRViews or dummy TrackIR.exe is required for this game + // + if (useDummyExe) { + start_dummy(); + } + + if (shm.mem == (void*) 0 || shm.mem == (void*) -1) + return false; + + pMemData->data.DataID = 1; + pMemData->data.CamWidth = 100; + pMemData->data.CamHeight = 250; + pMemData->GameID2 = 0; + memset(pMemData->table, 0, 8); + + return true; +} + +//////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Protocol object. + +// Export both decorated and undecorated names. +// GetProtocol - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetProtocol@0 - Common name decoration for __stdcall functions in C language. +//#pragma comment(linker, "/export:GetProtocol=_GetProtocol@0") + +extern "C" FTNOIR_PROTOCOL_BASE_EXPORT IProtocol* CALLING_CONVENTION GetConstructor() +{ + return new FTNoIR_Protocol; +} diff --git a/ftnoir_protocol_ft/ftnoir_protocol_ft.h b/ftnoir_protocol_ft/ftnoir_protocol_ft.h index f87c7300..05860907 100644 --- a/ftnoir_protocol_ft/ftnoir_protocol_ft.h +++ b/ftnoir_protocol_ft/ftnoir_protocol_ft.h @@ -1,141 +1,141 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2010 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -* FTServer FTServer is the Class, that communicates headpose-data * -* to games, using the FreeTrackClient.dll. * -********************************************************************************/ -#pragma once -#ifndef INCLUDED_FTSERVER_H -#define INCLUDED_FTSERVER_H - -#include "ftnoir_protocol_base/ftnoir_protocol_base.h" -#include "ui_ftnoir_ftcontrols.h" -#include "facetracknoir/global-settings.h" -#include "fttypes.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "compat/compat.h" -//#include "math.h" - -//typedef char *(WINAPI *importProvider)(void); -typedef void (WINAPI *importTIRViewsStart)(void); -typedef void (WINAPI *importTIRViewsStop)(void); - -class FTNoIR_Protocol : public IProtocol -{ -public: - FTNoIR_Protocol(); - ~FTNoIR_Protocol(); - bool checkServerInstallationOK( ); - void sendHeadposeToGame( double *headpose, double *rawheadpose ); - QString getGameName() { - QMutexLocker foo(&game_name_mutex); - return connected_game; - } - -private: - importTIRViewsStart viewsStart; // Functions inside TIRViews.dll - importTIRViewsStop viewsStop; - - FTMemMap *pMemData; - QString game_name; - PortableLockedShm shm; - - // Private properties - QString ProgramName; - QLibrary FTIRViewsLib; - QProcess dummyTrackIR; - int intGameID; - int intUsedInterface; // Determine which interface to use (or to hide from the game) - bool useTIRViews; // Needs to be in the Settings dialog - bool useDummyExe; - float getRadsFromDegrees ( float degrees ) { return (degrees * 0.017453f); } - void loadSettings(); - void start_tirviews(); - void start_dummy(); - - QString connected_game; - QMutex game_name_mutex; -}; - -// Widget that has controls for FTNoIR protocol client-settings. -class FTControls: public QWidget, public IProtocolDialog -{ - Q_OBJECT -public: - - explicit FTControls(); - virtual ~FTControls(); - void showEvent ( QShowEvent * event ); - void Initialize(QWidget *parent); - void registerProtocol(IProtocol *protocol) { - theProtocol = (FTNoIR_Protocol *) protocol; // Accept the pointer to the Protocol - } - void unRegisterProtocol() { - theProtocol = NULL; // Reset the pointer - } - -private: - Ui::UICFTControls ui; - void loadSettings(); - void save(); - - /** helper **/ - bool settingsDirty; - FTNoIR_Protocol *theProtocol; - -private slots: - void selectDLL(); - void doOK(); - void doCancel(); - void settingChanged() { settingsDirty = true; } - void settingChanged(int) { settingsDirty = true; } -}; - -//******************************************************************************************************* -// FaceTrackNoIR Protocol DLL. Functions used to get general info on the Protocol -//******************************************************************************************************* -class FTNoIR_ProtocolDll : public Metadata -{ -public: - FTNoIR_ProtocolDll(); - ~FTNoIR_ProtocolDll(); - - void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("FreeTrack 2.0"); } - void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("FreeTrack 2.0"); } - void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("Enhanced FreeTrack protocol"); } - - void getIcon(QIcon *icon) { *icon = QIcon(":/images/freetrack.png"); } -}; - - -#endif//INCLUDED_FTSERVER_H -//END +/******************************************************************************** +* FaceTrackNoIR This program is a private project of some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2010 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +* FTServer FTServer is the Class, that communicates headpose-data * +* to games, using the FreeTrackClient.dll. * +********************************************************************************/ +#pragma once +#ifndef INCLUDED_FTSERVER_H +#define INCLUDED_FTSERVER_H + +#include "ftnoir_protocol_base/ftnoir_protocol_base.h" +#include "ui_ftnoir_ftcontrols.h" +#include "facetracknoir/global-settings.h" +#include "fttypes.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "compat/compat.h" +//#include "math.h" + +//typedef char *(WINAPI *importProvider)(void); +typedef void (WINAPI *importTIRViewsStart)(void); +typedef void (WINAPI *importTIRViewsStop)(void); + +class FTNoIR_Protocol : public IProtocol +{ +public: + FTNoIR_Protocol(); + ~FTNoIR_Protocol(); + bool checkServerInstallationOK( ); + void sendHeadposeToGame( double *headpose, double *rawheadpose ); + QString getGameName() { + QMutexLocker foo(&game_name_mutex); + return connected_game; + } + +private: + importTIRViewsStart viewsStart; // Functions inside TIRViews.dll + importTIRViewsStop viewsStop; + + FTMemMap *pMemData; + QString game_name; + PortableLockedShm shm; + + // Private properties + QString ProgramName; + QLibrary FTIRViewsLib; + QProcess dummyTrackIR; + int intGameID; + int intUsedInterface; // Determine which interface to use (or to hide from the game) + bool useTIRViews; // Needs to be in the Settings dialog + bool useDummyExe; + float getRadsFromDegrees ( float degrees ) { return (degrees * 0.017453f); } + void loadSettings(); + void start_tirviews(); + void start_dummy(); + + QString connected_game; + QMutex game_name_mutex; +}; + +// Widget that has controls for FTNoIR protocol client-settings. +class FTControls: public QWidget, public IProtocolDialog +{ + Q_OBJECT +public: + + explicit FTControls(); + virtual ~FTControls(); + void showEvent ( QShowEvent * event ); + void Initialize(QWidget *parent); + void registerProtocol(IProtocol *protocol) { + theProtocol = (FTNoIR_Protocol *) protocol; // Accept the pointer to the Protocol + } + void unRegisterProtocol() { + theProtocol = NULL; // Reset the pointer + } + +private: + Ui::UICFTControls ui; + void loadSettings(); + void save(); + + /** helper **/ + bool settingsDirty; + FTNoIR_Protocol *theProtocol; + +private slots: + void selectDLL(); + void doOK(); + void doCancel(); + void settingChanged() { settingsDirty = true; } + void settingChanged(int) { settingsDirty = true; } +}; + +//******************************************************************************************************* +// FaceTrackNoIR Protocol DLL. Functions used to get general info on the Protocol +//******************************************************************************************************* +class FTNoIR_ProtocolDll : public Metadata +{ +public: + FTNoIR_ProtocolDll(); + ~FTNoIR_ProtocolDll(); + + void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("FreeTrack 2.0"); } + void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("FreeTrack 2.0"); } + void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("Enhanced FreeTrack protocol"); } + + void getIcon(QIcon *icon) { *icon = QIcon(":/images/freetrack.png"); } +}; + + +#endif//INCLUDED_FTSERVER_H +//END diff --git a/ftnoir_protocol_ft/ftnoir_protocol_ft_dialog.cpp b/ftnoir_protocol_ft/ftnoir_protocol_ft_dialog.cpp index 2442d6b2..810bef50 100644 --- a/ftnoir_protocol_ft/ftnoir_protocol_ft_dialog.cpp +++ b/ftnoir_protocol_ft/ftnoir_protocol_ft_dialog.cpp @@ -1,225 +1,225 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2012 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -********************************************************************************/ -#include "ftnoir_protocol_ft.h" -#include -#include - -//******************************************************************************************************* -// FaceTrackNoIR Client Settings-dialog. -//******************************************************************************************************* - -// -// Constructor for server-settings-dialog -// -FTControls::FTControls() : -QWidget() -{ - QString aFileName; // File Path and Name - - ui.setupUi( this ); - - // Connect Qt signals to member-functions - connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); - connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); - connect(ui.bntLocateNPClient, SIGNAL(clicked()), this, SLOT(selectDLL())); - connect(ui.chkTIRViews, SIGNAL(stateChanged(int)), this, SLOT(settingChanged())); - connect(ui.chkStartDummy, SIGNAL(stateChanged(int)), this, SLOT(settingChanged())); - connect(ui.cbxSelectInterface, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged( int ))); - - ui.cbxSelectInterface->addItem("Enable both"); - ui.cbxSelectInterface->addItem("Use FreeTrack, hide TrackIR"); - ui.cbxSelectInterface->addItem("Use TrackIR, hide FreeTrack"); - - theProtocol = NULL; - - // Load the settings from the current .INI-file - loadSettings(); - - - aFileName = QCoreApplication::applicationDirPath() + "/TIRViews.dll"; - if ( !QFile::exists( aFileName ) ) { - ui.chkTIRViews->setChecked( false ); - ui.chkTIRViews->setEnabled ( false ); - - // - // Best do this save() last, or it will continually reset the settings... :-( - // - save(); - } - else { - ui.chkTIRViews->setEnabled ( true ); - } - - -} - -// -// Destructor for server-dialog -// -FTControls::~FTControls() { - qDebug() << "~FTControls() says: started"; -} - -// -// Initialize tracker-client-dialog -// -void FTControls::Initialize(QWidget *parent) { - - QPoint offsetpos(100, 100); - if (parent) { - this->move(parent->pos() + offsetpos); - } - show(); -} - -// -// OK clicked on server-dialog -// -void FTControls::doOK() { - save(); - this->close(); -} - -// override show event -void FTControls::showEvent ( QShowEvent * event ) { - loadSettings(); -} - -// -// Cancel clicked on server-dialog -// -void FTControls::doCancel() { - // - // Ask if changed Settings should be saved - // - if (settingsDirty) { - int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard ); - - qDebug() << "doCancel says: answer =" << ret; - - switch (ret) { - case QMessageBox::Save: - save(); - this->close(); - break; - case QMessageBox::Discard: - this->close(); - break; - case QMessageBox::Cancel: - // Cancel was clicked - break; - default: - // should never be reached - break; - } - } - else { - this->close(); - } -} - -// -// Load the current Settings from the currently 'active' INI-file. -// -void FTControls::loadSettings() { - qDebug() << "loadSettings says: Starting "; - QSettings settings("opentrack"); // 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; - - iniFile.beginGroup ( "FT" ); - ui.cbxSelectInterface->setCurrentIndex( iniFile.value ( "UsedInterface", 0 ).toInt() ); - iniFile.endGroup (); - - iniFile.beginGroup ( "FTIR" ); - ui.chkTIRViews->setChecked (iniFile.value ( "useTIRViews", 0 ).toBool()); - ui.chkStartDummy->setChecked (iniFile.value ( "useDummyExe", 1 ).toBool()); - iniFile.endGroup (); - - settingsDirty = false; -} - -// -// Save the current Settings to the currently 'active' INI-file. -// -void FTControls::save() { - QSettings settings("opentrack"); // 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) - - iniFile.beginGroup ( "FT" ); - iniFile.setValue ( "UsedInterface", ui.cbxSelectInterface->currentIndex()); - iniFile.endGroup (); - - iniFile.beginGroup ( "FTIR" ); - iniFile.setValue ( "useTIRViews", ui.chkTIRViews->isChecked() ); - iniFile.setValue ( "useDummyExe", ui.chkStartDummy->isChecked() ); - iniFile.endGroup (); - - settingsDirty = false; -} - -// -// Select a NPClient.dll file, to repair the Location in the Registry. -// Several program distribute their own version of this file. -// -void FTControls::selectDLL() { - QFileDialog::Options options; - QFileDialog::FileMode mode; - - options |= QFileDialog::DontUseNativeDialog; - mode = QFileDialog::ExistingFile; - QString selectedFilter; - QString fileName = QFileDialog::getOpenFileName( this, tr("Select the desired NPClient DLL"), QCoreApplication::applicationDirPath() + "/NPClient.dll", tr("Dll file (*.dll);;All Files (*)")); - - // - // Write the location of the file in the required Registry-key. - // - if (! fileName.isEmpty() ) { - if (fileName.endsWith("NPClient.dll", Qt::CaseInsensitive) ) { - QSettings settingsTIR("NaturalPoint", "NATURALPOINT\\NPClient Location"); // Registry settings (in HK_USER) - QString aLocation = fileName.left(fileName.length() - 12); // Location of Client DLL - - settingsTIR.setValue( "Path" , aLocation ); - } - } -} - - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Protocol-settings dialog object. - -// Export both decorated and undecorated names. -// GetProtocolDialog - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetProtocolDialog@0 - Common name decoration for __stdcall functions in C language. -extern "C" FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDialog* CALLING_CONVENTION GetDialog( ) -{ - return new FTControls; -} +/******************************************************************************** +* FaceTrackNoIR This program is a private project of some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2012 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +********************************************************************************/ +#include "ftnoir_protocol_ft.h" +#include +#include + +//******************************************************************************************************* +// FaceTrackNoIR Client Settings-dialog. +//******************************************************************************************************* + +// +// Constructor for server-settings-dialog +// +FTControls::FTControls() : +QWidget() +{ + QString aFileName; // File Path and Name + + ui.setupUi( this ); + + // Connect Qt signals to member-functions + connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); + connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); + connect(ui.bntLocateNPClient, SIGNAL(clicked()), this, SLOT(selectDLL())); + connect(ui.chkTIRViews, SIGNAL(stateChanged(int)), this, SLOT(settingChanged())); + connect(ui.chkStartDummy, SIGNAL(stateChanged(int)), this, SLOT(settingChanged())); + connect(ui.cbxSelectInterface, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged( int ))); + + ui.cbxSelectInterface->addItem("Enable both"); + ui.cbxSelectInterface->addItem("Use FreeTrack, hide TrackIR"); + ui.cbxSelectInterface->addItem("Use TrackIR, hide FreeTrack"); + + theProtocol = NULL; + + // Load the settings from the current .INI-file + loadSettings(); + + + aFileName = QCoreApplication::applicationDirPath() + "/TIRViews.dll"; + if ( !QFile::exists( aFileName ) ) { + ui.chkTIRViews->setChecked( false ); + ui.chkTIRViews->setEnabled ( false ); + + // + // Best do this save() last, or it will continually reset the settings... :-( + // + save(); + } + else { + ui.chkTIRViews->setEnabled ( true ); + } + + +} + +// +// Destructor for server-dialog +// +FTControls::~FTControls() { + qDebug() << "~FTControls() says: started"; +} + +// +// Initialize tracker-client-dialog +// +void FTControls::Initialize(QWidget *parent) { + + QPoint offsetpos(100, 100); + if (parent) { + this->move(parent->pos() + offsetpos); + } + show(); +} + +// +// OK clicked on server-dialog +// +void FTControls::doOK() { + save(); + this->close(); +} + +// override show event +void FTControls::showEvent ( QShowEvent * event ) { + loadSettings(); +} + +// +// Cancel clicked on server-dialog +// +void FTControls::doCancel() { + // + // Ask if changed Settings should be saved + // + if (settingsDirty) { + int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard ); + + qDebug() << "doCancel says: answer =" << ret; + + switch (ret) { + case QMessageBox::Save: + save(); + this->close(); + break; + case QMessageBox::Discard: + this->close(); + break; + case QMessageBox::Cancel: + // Cancel was clicked + break; + default: + // should never be reached + break; + } + } + else { + this->close(); + } +} + +// +// Load the current Settings from the currently 'active' INI-file. +// +void FTControls::loadSettings() { + qDebug() << "loadSettings says: Starting "; + QSettings settings("opentrack"); // 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; + + iniFile.beginGroup ( "FT" ); + ui.cbxSelectInterface->setCurrentIndex( iniFile.value ( "UsedInterface", 0 ).toInt() ); + iniFile.endGroup (); + + iniFile.beginGroup ( "FTIR" ); + ui.chkTIRViews->setChecked (iniFile.value ( "useTIRViews", 0 ).toBool()); + ui.chkStartDummy->setChecked (iniFile.value ( "useDummyExe", 1 ).toBool()); + iniFile.endGroup (); + + settingsDirty = false; +} + +// +// Save the current Settings to the currently 'active' INI-file. +// +void FTControls::save() { + QSettings settings("opentrack"); // 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) + + iniFile.beginGroup ( "FT" ); + iniFile.setValue ( "UsedInterface", ui.cbxSelectInterface->currentIndex()); + iniFile.endGroup (); + + iniFile.beginGroup ( "FTIR" ); + iniFile.setValue ( "useTIRViews", ui.chkTIRViews->isChecked() ); + iniFile.setValue ( "useDummyExe", ui.chkStartDummy->isChecked() ); + iniFile.endGroup (); + + settingsDirty = false; +} + +// +// Select a NPClient.dll file, to repair the Location in the Registry. +// Several program distribute their own version of this file. +// +void FTControls::selectDLL() { + QFileDialog::Options options; + QFileDialog::FileMode mode; + + options |= QFileDialog::DontUseNativeDialog; + mode = QFileDialog::ExistingFile; + QString selectedFilter; + QString fileName = QFileDialog::getOpenFileName( this, tr("Select the desired NPClient DLL"), QCoreApplication::applicationDirPath() + "/NPClient.dll", tr("Dll file (*.dll);;All Files (*)")); + + // + // Write the location of the file in the required Registry-key. + // + if (! fileName.isEmpty() ) { + if (fileName.endsWith("NPClient.dll", Qt::CaseInsensitive) ) { + QSettings settingsTIR("NaturalPoint", "NATURALPOINT\\NPClient Location"); // Registry settings (in HK_USER) + QString aLocation = fileName.left(fileName.length() - 12); // Location of Client DLL + + settingsTIR.setValue( "Path" , aLocation ); + } + } +} + + +//////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Protocol-settings dialog object. + +// Export both decorated and undecorated names. +// GetProtocolDialog - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetProtocolDialog@0 - Common name decoration for __stdcall functions in C language. +extern "C" FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDialog* CALLING_CONVENTION GetDialog( ) +{ + return new FTControls; +} diff --git a/ftnoir_protocol_ft/ftnoir_protocol_ft_dll.cpp b/ftnoir_protocol_ft/ftnoir_protocol_ft_dll.cpp index 5b6087b5..f4e4a40e 100644 --- a/ftnoir_protocol_ft/ftnoir_protocol_ft_dll.cpp +++ b/ftnoir_protocol_ft/ftnoir_protocol_ft_dll.cpp @@ -1,46 +1,46 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2012 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -********************************************************************************/ -#include "ftnoir_protocol_ft.h" -#include - -FTNoIR_ProtocolDll::FTNoIR_ProtocolDll() { -} - -FTNoIR_ProtocolDll::~FTNoIR_ProtocolDll() -{ - -} - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Protocol object. - -// Export both decorated and undecorated names. -// GetProtocolDll - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetProtocolDll@0 - Common name decoration for __stdcall functions in C language. -extern "C" FTNOIR_PROTOCOL_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata() -{ - return new FTNoIR_ProtocolDll; +/******************************************************************************** +* FaceTrackNoIR This program is a private project of some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2012 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +********************************************************************************/ +#include "ftnoir_protocol_ft.h" +#include + +FTNoIR_ProtocolDll::FTNoIR_ProtocolDll() { +} + +FTNoIR_ProtocolDll::~FTNoIR_ProtocolDll() +{ + +} + +//////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Protocol object. + +// Export both decorated and undecorated names. +// GetProtocolDll - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetProtocolDll@0 - Common name decoration for __stdcall functions in C language. +extern "C" FTNOIR_PROTOCOL_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata() +{ + return new FTNoIR_ProtocolDll; } \ No newline at end of file diff --git a/ftnoir_protocol_ftn/ftnoir_protocol_ftn.cpp b/ftnoir_protocol_ftn/ftnoir_protocol_ftn.cpp index 1fbc0b43..32d11c37 100644 --- a/ftnoir_protocol_ftn/ftnoir_protocol_ftn.cpp +++ b/ftnoir_protocol_ftn/ftnoir_protocol_ftn.cpp @@ -1,118 +1,118 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of the some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2010-2011 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -* FTNServer FTNServer is the Class, that communicates headpose-data * -* to another FaceTrackNoIR program, using UDP. * -* It is based on the (Linux) example made by Melchior FRANZ. * -********************************************************************************/ -#include "ftnoir_protocol_ftn.h" -#include -#include "facetracknoir/global-settings.h" - -/** constructor **/ -FTNoIR_Protocol::FTNoIR_Protocol() -{ - loadSettings(); - outSocket = 0; -} - -/** destructor **/ -FTNoIR_Protocol::~FTNoIR_Protocol() -{ - if (outSocket != 0) { - outSocket->close(); - delete outSocket; - } -} - -// -// Load the current Settings from the currently 'active' INI-file. -// -void FTNoIR_Protocol::loadSettings() { - QSettings settings("opentrack"); // 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) - - iniFile.beginGroup ( "FTN" ); - - QString destAddr = iniFile.value ( "IP-1", 192 ).toString() + "." + iniFile.value ( "IP-2", 168 ).toString() + "." + iniFile.value ( "IP-3", 2 ).toString() + "." + iniFile.value ( "IP-4", 1 ).toString(); - destIP = QHostAddress( destAddr ); - destPort = iniFile.value ( "PortNumber", 5550 ).toInt(); - - iniFile.endGroup (); -} - -// -// Update Headpose in Game. -// -void FTNoIR_Protocol::sendHeadposeToGame(double *headpose, double *rawheadpose ) { - int no_bytes; - double test_data[6]; - // - // Copy the Raw measurements directly to the client. - // - for (int i = 0; i < 6; i++) - test_data[i] = headpose[i]; - // - // Try to send an UDP-message to the receiver - // - - //! [1] - if (outSocket != 0) { - no_bytes = outSocket->writeDatagram((const char *) test_data, sizeof( test_data ), destIP, destPort); - if ( no_bytes > 0) { -// qDebug() << "FTNServer::writePendingDatagrams says: bytes send =" << no_bytes << sizeof( double ); - } - else { - qDebug() << "FTNServer::writePendingDatagrams says: nothing sent!"; - } - } -} - -// -// Check if the Client DLL exists and load it (to test it), if so. -// Returns 'true' if all seems OK. -// -bool FTNoIR_Protocol::checkServerInstallationOK() -{ - if (outSocket == 0) { - outSocket = new QUdpSocket(); - } - - return true; -} - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Protocol object. - -// Export both decorated and undecorated names. -// GetProtocol - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetProtocol@0 - Common name decoration for __stdcall functions in C language. -//#pragma comment(linker, "/export:GetProtocol=_GetProtocol@0") - -extern "C" FTNOIR_PROTOCOL_BASE_EXPORT IProtocol* CALLING_CONVENTION GetConstructor() -{ - return new FTNoIR_Protocol; -} +/******************************************************************************** +* FaceTrackNoIR This program is a private project of the some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2010-2011 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +* FTNServer FTNServer is the Class, that communicates headpose-data * +* to another FaceTrackNoIR program, using UDP. * +* It is based on the (Linux) example made by Melchior FRANZ. * +********************************************************************************/ +#include "ftnoir_protocol_ftn.h" +#include +#include "facetracknoir/global-settings.h" + +/** constructor **/ +FTNoIR_Protocol::FTNoIR_Protocol() +{ + loadSettings(); + outSocket = 0; +} + +/** destructor **/ +FTNoIR_Protocol::~FTNoIR_Protocol() +{ + if (outSocket != 0) { + outSocket->close(); + delete outSocket; + } +} + +// +// Load the current Settings from the currently 'active' INI-file. +// +void FTNoIR_Protocol::loadSettings() { + QSettings settings("opentrack"); // 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) + + iniFile.beginGroup ( "FTN" ); + + QString destAddr = iniFile.value ( "IP-1", 192 ).toString() + "." + iniFile.value ( "IP-2", 168 ).toString() + "." + iniFile.value ( "IP-3", 2 ).toString() + "." + iniFile.value ( "IP-4", 1 ).toString(); + destIP = QHostAddress( destAddr ); + destPort = iniFile.value ( "PortNumber", 5550 ).toInt(); + + iniFile.endGroup (); +} + +// +// Update Headpose in Game. +// +void FTNoIR_Protocol::sendHeadposeToGame(double *headpose, double *rawheadpose ) { + int no_bytes; + double test_data[6]; + // + // Copy the Raw measurements directly to the client. + // + for (int i = 0; i < 6; i++) + test_data[i] = headpose[i]; + // + // Try to send an UDP-message to the receiver + // + + //! [1] + if (outSocket != 0) { + no_bytes = outSocket->writeDatagram((const char *) test_data, sizeof( test_data ), destIP, destPort); + if ( no_bytes > 0) { +// qDebug() << "FTNServer::writePendingDatagrams says: bytes send =" << no_bytes << sizeof( double ); + } + else { + qDebug() << "FTNServer::writePendingDatagrams says: nothing sent!"; + } + } +} + +// +// Check if the Client DLL exists and load it (to test it), if so. +// Returns 'true' if all seems OK. +// +bool FTNoIR_Protocol::checkServerInstallationOK() +{ + if (outSocket == 0) { + outSocket = new QUdpSocket(); + } + + return true; +} + +//////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Protocol object. + +// Export both decorated and undecorated names. +// GetProtocol - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetProtocol@0 - Common name decoration for __stdcall functions in C language. +//#pragma comment(linker, "/export:GetProtocol=_GetProtocol@0") + +extern "C" FTNOIR_PROTOCOL_BASE_EXPORT IProtocol* CALLING_CONVENTION GetConstructor() +{ + return new FTNoIR_Protocol; +} diff --git a/ftnoir_protocol_ftn/ftnoir_protocol_ftn.h b/ftnoir_protocol_ftn/ftnoir_protocol_ftn.h index 1c4b493e..31247d1e 100644 --- a/ftnoir_protocol_ftn/ftnoir_protocol_ftn.h +++ b/ftnoir_protocol_ftn/ftnoir_protocol_ftn.h @@ -1,104 +1,104 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2010-2011 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -* FTNServer FTNServer is the Class, that communicates headpose-data * -* to FlightGear, using UDP. * -* It is based on the (Linux) example made by Melchior FRANZ. * -********************************************************************************/ -#pragma once -#ifndef INCLUDED_FTNSERVER_H -#define INCLUDED_FTNSERVER_H - -#include "ftnoir_protocol_base/ftnoir_protocol_base.h" -#include "ftnoir_tracker_base/ftnoir_tracker_base.h" -#include "ui_ftnoir_ftncontrols.h" -#include -#include -#include -#include -#include -#include "facetracknoir/global-settings.h" - -class FTNoIR_Protocol : public IProtocol -{ -public: - FTNoIR_Protocol(); - ~FTNoIR_Protocol(); - bool checkServerInstallationOK(); - void sendHeadposeToGame( double *headpose, double *rawheadpose ); - QString getGameName() { - return "UDP Tracker"; - } - -private: - QUdpSocket *outSocket; // Send to FaceTrackNoIR - QHostAddress destIP; // Destination IP-address - int destPort; // Destination port-number - void loadSettings(); -}; - -// Widget that has controls for FTNoIR protocol client-settings. -class FTNControls: public QWidget, public IProtocolDialog -{ - Q_OBJECT -public: - - explicit FTNControls(); - virtual ~FTNControls(); - void showEvent ( QShowEvent * event ); - void Initialize(QWidget *parent); - void registerProtocol(IProtocol *protocol) {} - void unRegisterProtocol() {} - -private: - Ui::UICFTNControls ui; - void loadSettings(); - void save(); - - /** helper **/ - bool settingsDirty; - -private slots: - void doOK(); - void doCancel(); - void settingChanged() { settingsDirty = true; } -}; - -//******************************************************************************************************* -// FaceTrackNoIR Protocol DLL. Functions used to get general info on the Protocol -//******************************************************************************************************* -class FTNoIR_ProtocolDll : public Metadata -{ -public: - FTNoIR_ProtocolDll(); - ~FTNoIR_ProtocolDll(); - - void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("FaceTrackNoIR"); } - void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("FTN Client"); } - void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("FaceTrackNoIR Client protocol"); } - - void getIcon(QIcon *icon) { *icon = QIcon(":/images/facetracknoir.png"); } -}; - -#endif//INCLUDED_FTNSERVER_H -//END +/******************************************************************************** +* FaceTrackNoIR This program is a private project of some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2010-2011 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +* FTNServer FTNServer is the Class, that communicates headpose-data * +* to FlightGear, using UDP. * +* It is based on the (Linux) example made by Melchior FRANZ. * +********************************************************************************/ +#pragma once +#ifndef INCLUDED_FTNSERVER_H +#define INCLUDED_FTNSERVER_H + +#include "ftnoir_protocol_base/ftnoir_protocol_base.h" +#include "ftnoir_tracker_base/ftnoir_tracker_base.h" +#include "ui_ftnoir_ftncontrols.h" +#include +#include +#include +#include +#include +#include "facetracknoir/global-settings.h" + +class FTNoIR_Protocol : public IProtocol +{ +public: + FTNoIR_Protocol(); + ~FTNoIR_Protocol(); + bool checkServerInstallationOK(); + void sendHeadposeToGame( double *headpose, double *rawheadpose ); + QString getGameName() { + return "UDP Tracker"; + } + +private: + QUdpSocket *outSocket; // Send to FaceTrackNoIR + QHostAddress destIP; // Destination IP-address + int destPort; // Destination port-number + void loadSettings(); +}; + +// Widget that has controls for FTNoIR protocol client-settings. +class FTNControls: public QWidget, public IProtocolDialog +{ + Q_OBJECT +public: + + explicit FTNControls(); + virtual ~FTNControls(); + void showEvent ( QShowEvent * event ); + void Initialize(QWidget *parent); + void registerProtocol(IProtocol *protocol) {} + void unRegisterProtocol() {} + +private: + Ui::UICFTNControls ui; + void loadSettings(); + void save(); + + /** helper **/ + bool settingsDirty; + +private slots: + void doOK(); + void doCancel(); + void settingChanged() { settingsDirty = true; } +}; + +//******************************************************************************************************* +// FaceTrackNoIR Protocol DLL. Functions used to get general info on the Protocol +//******************************************************************************************************* +class FTNoIR_ProtocolDll : public Metadata +{ +public: + FTNoIR_ProtocolDll(); + ~FTNoIR_ProtocolDll(); + + void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("FaceTrackNoIR"); } + void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("FTN Client"); } + void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("FaceTrackNoIR Client protocol"); } + + void getIcon(QIcon *icon) { *icon = QIcon(":/images/facetracknoir.png"); } +}; + +#endif//INCLUDED_FTNSERVER_H +//END diff --git a/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dialog.cpp b/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dialog.cpp index 328d866a..c902d6f8 100644 --- a/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dialog.cpp +++ b/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dialog.cpp @@ -1,180 +1,180 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2012 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -********************************************************************************/ -#include "ftnoir_protocol_ftn.h" -#include -#include "facetracknoir/global-settings.h" - -//******************************************************************************************************* -// FaceTrackNoIR Client Settings-dialog. -//******************************************************************************************************* - -// -// Constructor for server-settings-dialog -// -FTNControls::FTNControls() : -QWidget() -{ - ui.setupUi( this ); - - QPoint offsetpos(100, 100); - //if (parent) { - // this->move(parent->pos() + offsetpos); - //} - - // Connect Qt signals to member-functions - connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); - connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); - connect(ui.spinIPFirstNibble, SIGNAL(valueChanged(int)), this, SLOT(settingChanged())); - connect(ui.spinIPSecondNibble, SIGNAL(valueChanged(int)), this, SLOT(settingChanged())); - connect(ui.spinIPThirdNibble, SIGNAL(valueChanged(int)), this, SLOT(settingChanged())); - connect(ui.spinIPFourthNibble, SIGNAL(valueChanged(int)), this, SLOT(settingChanged())); - connect(ui.spinPortNumber, SIGNAL(valueChanged(int)), this, SLOT(settingChanged())); - - // Load the settings from the current .INI-file - loadSettings(); -} - -// -// Destructor for server-dialog -// -FTNControls::~FTNControls() { - qDebug() << "~FTNControls() says: started"; -} - -// -// Initialize tracker-client-dialog -// -void FTNControls::Initialize(QWidget *parent) { - - QPoint offsetpos(100, 100); - if (parent) { - this->move(parent->pos() + offsetpos); - } - show(); -} - -// -// OK clicked on server-dialog -// -void FTNControls::doOK() { - save(); - this->close(); -} - -// override show event -void FTNControls::showEvent ( QShowEvent * event ) { - loadSettings(); -} - -// -// Cancel clicked on server-dialog -// -void FTNControls::doCancel() { - // - // Ask if changed Settings should be saved - // - if (settingsDirty) { - int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard ); - - qDebug() << "doCancel says: answer =" << ret; - - switch (ret) { - case QMessageBox::Save: - save(); - this->close(); - break; - case QMessageBox::Discard: - this->close(); - break; - case QMessageBox::Cancel: - // Cancel was clicked - break; - default: - // should never be reached - break; - } - } - else { - this->close(); - } -} - -// -// Load the current Settings from the currently 'active' INI-file. -// -void FTNControls::loadSettings() { -// qDebug() << "loadSettings says: Starting "; - QSettings settings("opentrack"); // 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; - - iniFile.beginGroup ( "FTN" ); - ui.spinIPFirstNibble->setValue( iniFile.value ( "IP-1", 192 ).toInt() ); - ui.spinIPSecondNibble->setValue( iniFile.value ( "IP-2", 168 ).toInt() ); - ui.spinIPThirdNibble->setValue( iniFile.value ( "IP-3", 2 ).toInt() ); - ui.spinIPFourthNibble->setValue( iniFile.value ( "IP-4", 1 ).toInt() ); - - ui.spinPortNumber->setValue( iniFile.value ( "PortNumber", 5550 ).toInt() ); - iniFile.endGroup (); - - settingsDirty = false; -} - -// -// Save the current Settings to the currently 'active' INI-file. -// -void FTNControls::save() { - QSettings settings("opentrack"); // 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) - - iniFile.beginGroup ( "FTN" ); - iniFile.setValue ( "IP-1", ui.spinIPFirstNibble->value() ); - iniFile.setValue ( "IP-2", ui.spinIPSecondNibble->value() ); - iniFile.setValue ( "IP-3", ui.spinIPThirdNibble->value() ); - iniFile.setValue ( "IP-4", ui.spinIPFourthNibble->value() ); - iniFile.setValue ( "PortNumber", ui.spinPortNumber->value() ); - iniFile.endGroup (); - - settingsDirty = false; -} - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Protocol-settings dialog object. - -// Export both decorated and undecorated names. -// GetProtocolDialog - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetProtocolDialog@0 - Common name decoration for __stdcall functions in C language. -//#pragma comment(linker, "/export:GetProtocolDialog=_GetProtocolDialog@0") - -extern "C" FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDialog* CALLING_CONVENTION GetDialog( ) -{ - return new FTNControls; -} +/******************************************************************************** +* FaceTrackNoIR This program is a private project of some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2012 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +********************************************************************************/ +#include "ftnoir_protocol_ftn.h" +#include +#include "facetracknoir/global-settings.h" + +//******************************************************************************************************* +// FaceTrackNoIR Client Settings-dialog. +//******************************************************************************************************* + +// +// Constructor for server-settings-dialog +// +FTNControls::FTNControls() : +QWidget() +{ + ui.setupUi( this ); + + QPoint offsetpos(100, 100); + //if (parent) { + // this->move(parent->pos() + offsetpos); + //} + + // Connect Qt signals to member-functions + connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); + connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); + connect(ui.spinIPFirstNibble, SIGNAL(valueChanged(int)), this, SLOT(settingChanged())); + connect(ui.spinIPSecondNibble, SIGNAL(valueChanged(int)), this, SLOT(settingChanged())); + connect(ui.spinIPThirdNibble, SIGNAL(valueChanged(int)), this, SLOT(settingChanged())); + connect(ui.spinIPFourthNibble, SIGNAL(valueChanged(int)), this, SLOT(settingChanged())); + connect(ui.spinPortNumber, SIGNAL(valueChanged(int)), this, SLOT(settingChanged())); + + // Load the settings from the current .INI-file + loadSettings(); +} + +// +// Destructor for server-dialog +// +FTNControls::~FTNControls() { + qDebug() << "~FTNControls() says: started"; +} + +// +// Initialize tracker-client-dialog +// +void FTNControls::Initialize(QWidget *parent) { + + QPoint offsetpos(100, 100); + if (parent) { + this->move(parent->pos() + offsetpos); + } + show(); +} + +// +// OK clicked on server-dialog +// +void FTNControls::doOK() { + save(); + this->close(); +} + +// override show event +void FTNControls::showEvent ( QShowEvent * event ) { + loadSettings(); +} + +// +// Cancel clicked on server-dialog +// +void FTNControls::doCancel() { + // + // Ask if changed Settings should be saved + // + if (settingsDirty) { + int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard ); + + qDebug() << "doCancel says: answer =" << ret; + + switch (ret) { + case QMessageBox::Save: + save(); + this->close(); + break; + case QMessageBox::Discard: + this->close(); + break; + case QMessageBox::Cancel: + // Cancel was clicked + break; + default: + // should never be reached + break; + } + } + else { + this->close(); + } +} + +// +// Load the current Settings from the currently 'active' INI-file. +// +void FTNControls::loadSettings() { +// qDebug() << "loadSettings says: Starting "; + QSettings settings("opentrack"); // 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; + + iniFile.beginGroup ( "FTN" ); + ui.spinIPFirstNibble->setValue( iniFile.value ( "IP-1", 192 ).toInt() ); + ui.spinIPSecondNibble->setValue( iniFile.value ( "IP-2", 168 ).toInt() ); + ui.spinIPThirdNibble->setValue( iniFile.value ( "IP-3", 2 ).toInt() ); + ui.spinIPFourthNibble->setValue( iniFile.value ( "IP-4", 1 ).toInt() ); + + ui.spinPortNumber->setValue( iniFile.value ( "PortNumber", 5550 ).toInt() ); + iniFile.endGroup (); + + settingsDirty = false; +} + +// +// Save the current Settings to the currently 'active' INI-file. +// +void FTNControls::save() { + QSettings settings("opentrack"); // 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) + + iniFile.beginGroup ( "FTN" ); + iniFile.setValue ( "IP-1", ui.spinIPFirstNibble->value() ); + iniFile.setValue ( "IP-2", ui.spinIPSecondNibble->value() ); + iniFile.setValue ( "IP-3", ui.spinIPThirdNibble->value() ); + iniFile.setValue ( "IP-4", ui.spinIPFourthNibble->value() ); + iniFile.setValue ( "PortNumber", ui.spinPortNumber->value() ); + iniFile.endGroup (); + + settingsDirty = false; +} + +//////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Protocol-settings dialog object. + +// Export both decorated and undecorated names. +// GetProtocolDialog - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetProtocolDialog@0 - Common name decoration for __stdcall functions in C language. +//#pragma comment(linker, "/export:GetProtocolDialog=_GetProtocolDialog@0") + +extern "C" FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDialog* CALLING_CONVENTION GetDialog( ) +{ + return new FTNControls; +} diff --git a/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dll.cpp b/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dll.cpp index c52d6c9e..acd3b990 100644 --- a/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dll.cpp +++ b/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dll.cpp @@ -1,49 +1,49 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2012 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -********************************************************************************/ -#include "ftnoir_protocol_ftn.h" -#include -#include "facetracknoir/global-settings.h" - -FTNoIR_ProtocolDll::FTNoIR_ProtocolDll() { -} - -FTNoIR_ProtocolDll::~FTNoIR_ProtocolDll() -{ - -} - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Protocol object. - -// Export both decorated and undecorated names. -// GetProtocolDll - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetProtocolDll@0 - Common name decoration for __stdcall functions in C language. -//#pragma comment(linker, "/export:GetProtocolDll=_GetProtocolDll@0") - -extern "C" FTNOIR_PROTOCOL_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata() -{ - return new FTNoIR_ProtocolDll; -} +/******************************************************************************** +* FaceTrackNoIR This program is a private project of some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2012 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +********************************************************************************/ +#include "ftnoir_protocol_ftn.h" +#include +#include "facetracknoir/global-settings.h" + +FTNoIR_ProtocolDll::FTNoIR_ProtocolDll() { +} + +FTNoIR_ProtocolDll::~FTNoIR_ProtocolDll() +{ + +} + +//////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Protocol object. + +// Export both decorated and undecorated names. +// GetProtocolDll - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetProtocolDll@0 - Common name decoration for __stdcall functions in C language. +//#pragma comment(linker, "/export:GetProtocolDll=_GetProtocolDll@0") + +extern "C" FTNOIR_PROTOCOL_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata() +{ + return new FTNoIR_ProtocolDll; +} diff --git a/ftnoir_protocol_mouse/ftnoir_protocol_mouse.cpp b/ftnoir_protocol_mouse/ftnoir_protocol_mouse.cpp index 16a501b6..6b013d74 100644 --- a/ftnoir_protocol_mouse/ftnoir_protocol_mouse.cpp +++ b/ftnoir_protocol_mouse/ftnoir_protocol_mouse.cpp @@ -1,101 +1,101 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of the some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2010-2011 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -* FTNoIR_Protocol_Mouse The Class, that communicates headpose-data by * -* generating Mouse commands. * -* Many games (like FPS's) support Mouse-look features, * -* but no face-tracking. * -********************************************************************************/ -#include "ftnoir_protocol_mouse.h" -#include "facetracknoir/global-settings.h" - -/** constructor **/ -FTNoIR_Protocol::FTNoIR_Protocol() -{ - loadSettings(); -} - -/** destructor **/ -FTNoIR_Protocol::~FTNoIR_Protocol() -{ -} - -// -// Load the current Settings from the currently 'active' INI-file. -// -void FTNoIR_Protocol::loadSettings() { - QSettings settings("opentrack"); // 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) - - iniFile.beginGroup ( "Mouse" ); - Mouse_X = (FTN_AngleName) (iniFile.value ( "Mouse_X", 0 ).toInt()); - Mouse_Y = (FTN_AngleName) (iniFile.value ( "Mouse_Y", 0 ).toInt()); - iniFile.endGroup (); -} - -// -// Update Headpose in Game. -// -void FTNoIR_Protocol::sendHeadposeToGame(double *headpose, double *rawheadpose ) { - float fMouse_X = 0; - float fMouse_Y = 0; - - if (Mouse_X > 0 && Mouse_X <= 6) - fMouse_X = headpose[Mouse_X-1] / (Mouse_X < 3 ? 100 : 180); - - if (Mouse_Y > 0 && Mouse_Y <= 6) - fMouse_Y = headpose[Mouse_Y-1] / (Mouse_Y < 3 ? 100 : 180); - - RECT desktop; - const HWND hDesktop = GetDesktopWindow(); - if (hDesktop != NULL && GetWindowRect(hDesktop, &desktop)) { - fMouse_X *= desktop.right; - fMouse_Y *= desktop.bottom; - SetCursorPos(fMouse_X + desktop.right/2, fMouse_Y + desktop.bottom/2); - } -} - -// -// Returns 'true' if all seems OK. -// -bool FTNoIR_Protocol::checkServerInstallationOK() -{ - - return true; -} - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Protocol object. - -// Export both decorated and undecorated names. -// GetProtocol - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetProtocol@0 - Common name decoration for __stdcall functions in C language. -//#pragma comment(linker, "/export:GetProtocol=_GetProtocol@0") - -extern "C" FTNOIR_PROTOCOL_BASE_EXPORT IProtocol* CALLING_CONVENTION GetConstructor() -{ - return new FTNoIR_Protocol; -} +/******************************************************************************** +* FaceTrackNoIR This program is a private project of the some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2010-2011 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +* FTNoIR_Protocol_Mouse The Class, that communicates headpose-data by * +* generating Mouse commands. * +* Many games (like FPS's) support Mouse-look features, * +* but no face-tracking. * +********************************************************************************/ +#include "ftnoir_protocol_mouse.h" +#include "facetracknoir/global-settings.h" + +/** constructor **/ +FTNoIR_Protocol::FTNoIR_Protocol() +{ + loadSettings(); +} + +/** destructor **/ +FTNoIR_Protocol::~FTNoIR_Protocol() +{ +} + +// +// Load the current Settings from the currently 'active' INI-file. +// +void FTNoIR_Protocol::loadSettings() { + QSettings settings("opentrack"); // 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) + + iniFile.beginGroup ( "Mouse" ); + Mouse_X = (FTN_AngleName) (iniFile.value ( "Mouse_X", 0 ).toInt()); + Mouse_Y = (FTN_AngleName) (iniFile.value ( "Mouse_Y", 0 ).toInt()); + iniFile.endGroup (); +} + +// +// Update Headpose in Game. +// +void FTNoIR_Protocol::sendHeadposeToGame(double *headpose, double *rawheadpose ) { + float fMouse_X = 0; + float fMouse_Y = 0; + + if (Mouse_X > 0 && Mouse_X <= 6) + fMouse_X = headpose[Mouse_X-1] / (Mouse_X < 3 ? 100 : 180); + + if (Mouse_Y > 0 && Mouse_Y <= 6) + fMouse_Y = headpose[Mouse_Y-1] / (Mouse_Y < 3 ? 100 : 180); + + RECT desktop; + const HWND hDesktop = GetDesktopWindow(); + if (hDesktop != NULL && GetWindowRect(hDesktop, &desktop)) { + fMouse_X *= desktop.right; + fMouse_Y *= desktop.bottom; + SetCursorPos(fMouse_X + desktop.right/2, fMouse_Y + desktop.bottom/2); + } +} + +// +// Returns 'true' if all seems OK. +// +bool FTNoIR_Protocol::checkServerInstallationOK() +{ + + return true; +} + +//////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Protocol object. + +// Export both decorated and undecorated names. +// GetProtocol - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetProtocol@0 - Common name decoration for __stdcall functions in C language. +//#pragma comment(linker, "/export:GetProtocol=_GetProtocol@0") + +extern "C" FTNOIR_PROTOCOL_BASE_EXPORT IProtocol* CALLING_CONVENTION GetConstructor() +{ + return new FTNoIR_Protocol; +} diff --git a/ftnoir_protocol_mouse/ftnoir_protocol_mouse.h b/ftnoir_protocol_mouse/ftnoir_protocol_mouse.h index fd0058ea..b537fc4e 100644 --- a/ftnoir_protocol_mouse/ftnoir_protocol_mouse.h +++ b/ftnoir_protocol_mouse/ftnoir_protocol_mouse.h @@ -1,128 +1,128 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2010-2011 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* http://facetracknoir.sourceforge.net/home/default.htm * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -* FTNoIR_Protocol_Mouse The Class, that communicates headpose-data by * -* generating Mouse commands. * -* Many games (like FPS's) support Mouse-look features, * -* but no face-tracking. * -********************************************************************************/ -#pragma once -#ifndef INCLUDED_MOUSESERVER_H -#define INCLUDED_MOUSESERVER_H - -#include "ftnoir_protocol_base/ftnoir_protocol_base.h" -#include "ui_ftnoir_mousecontrols.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include "facetracknoir/global-settings.h" - -#define MOUSE_AXIS_MIN 0 -#define MOUSE_AXIS_MAX 65535 - -enum FTN_AngleName { - FTN_YAW = Yaw, - FTN_PITCH = Pitch, - FTN_ROLL = Roll, - FTN_X = TX, - FTN_Y = TY, - FTN_Z = TZ -}; - -class FTNoIR_Protocol : public IProtocol -{ -public: - FTNoIR_Protocol(); - ~FTNoIR_Protocol(); - bool checkServerInstallationOK(); - void sendHeadposeToGame( double *headpose, double *rawheadpose ); - -private: - HANDLE h; - INPUT MouseStruct; - - FTN_AngleName Mouse_X; // Map one of the 6DOF's to this Mouse direction - FTN_AngleName Mouse_Y; - FTN_AngleName Mouse_Wheel; - void loadSettings(); - QString getGameName() { - return "Mouse tracker"; - } -}; - -// Widget that has controls for FTNoIR protocol client-settings. -class MOUSEControls: public QWidget, public IProtocolDialog -{ - Q_OBJECT -public: - - explicit MOUSEControls(); - virtual ~MOUSEControls(); - void showEvent ( QShowEvent * event ); - void Initialize(QWidget *parent); - void registerProtocol(IProtocol *protocol) { - theProtocol = (FTNoIR_Protocol *) protocol; // Accept the pointer to the Protocol - } - void unRegisterProtocol() { - theProtocol = NULL; // Reset the pointer - } - -private: - Ui::UICMOUSEControls ui; - void loadSettings(); - void save(); - - /** helper **/ - bool settingsDirty; - FTNoIR_Protocol *theProtocol; - -private slots: - void doOK(); - void doCancel(); - void settingChanged( int setting ) { settingsDirty = true; } -}; - -//******************************************************************************************************* -// FaceTrackNoIR Protocol DLL. Functions used to get general info on the Protocol -//******************************************************************************************************* -class FTNoIR_ProtocolDll : public Metadata -{ -public: - FTNoIR_ProtocolDll(); - ~FTNoIR_ProtocolDll(); - - void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("Mouse Look"); } - void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("Mouse Look"); } - void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("Mouse Look protocol"); } - - void getIcon(QIcon *icon) { *icon = QIcon(":/images/mouse.png"); } -}; - - -#endif//INCLUDED_MOUSESERVER_H -//END +/******************************************************************************** +* FaceTrackNoIR This program is a private project of some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2010-2011 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* http://facetracknoir.sourceforge.net/home/default.htm * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +* FTNoIR_Protocol_Mouse The Class, that communicates headpose-data by * +* generating Mouse commands. * +* Many games (like FPS's) support Mouse-look features, * +* but no face-tracking. * +********************************************************************************/ +#pragma once +#ifndef INCLUDED_MOUSESERVER_H +#define INCLUDED_MOUSESERVER_H + +#include "ftnoir_protocol_base/ftnoir_protocol_base.h" +#include "ui_ftnoir_mousecontrols.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include "facetracknoir/global-settings.h" + +#define MOUSE_AXIS_MIN 0 +#define MOUSE_AXIS_MAX 65535 + +enum FTN_AngleName { + FTN_YAW = Yaw, + FTN_PITCH = Pitch, + FTN_ROLL = Roll, + FTN_X = TX, + FTN_Y = TY, + FTN_Z = TZ +}; + +class FTNoIR_Protocol : public IProtocol +{ +public: + FTNoIR_Protocol(); + ~FTNoIR_Protocol(); + bool checkServerInstallationOK(); + void sendHeadposeToGame( double *headpose, double *rawheadpose ); + +private: + HANDLE h; + INPUT MouseStruct; + + FTN_AngleName Mouse_X; // Map one of the 6DOF's to this Mouse direction + FTN_AngleName Mouse_Y; + FTN_AngleName Mouse_Wheel; + void loadSettings(); + QString getGameName() { + return "Mouse tracker"; + } +}; + +// Widget that has controls for FTNoIR protocol client-settings. +class MOUSEControls: public QWidget, public IProtocolDialog +{ + Q_OBJECT +public: + + explicit MOUSEControls(); + virtual ~MOUSEControls(); + void showEvent ( QShowEvent * event ); + void Initialize(QWidget *parent); + void registerProtocol(IProtocol *protocol) { + theProtocol = (FTNoIR_Protocol *) protocol; // Accept the pointer to the Protocol + } + void unRegisterProtocol() { + theProtocol = NULL; // Reset the pointer + } + +private: + Ui::UICMOUSEControls ui; + void loadSettings(); + void save(); + + /** helper **/ + bool settingsDirty; + FTNoIR_Protocol *theProtocol; + +private slots: + void doOK(); + void doCancel(); + void settingChanged( int setting ) { settingsDirty = true; } +}; + +//******************************************************************************************************* +// FaceTrackNoIR Protocol DLL. Functions used to get general info on the Protocol +//******************************************************************************************************* +class FTNoIR_ProtocolDll : public Metadata +{ +public: + FTNoIR_ProtocolDll(); + ~FTNoIR_ProtocolDll(); + + void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("Mouse Look"); } + void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("Mouse Look"); } + void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("Mouse Look protocol"); } + + void getIcon(QIcon *icon) { *icon = QIcon(":/images/mouse.png"); } +}; + + +#endif//INCLUDED_MOUSESERVER_H +//END diff --git a/ftnoir_protocol_mouse/ftnoir_protocol_mouse_dialog.cpp b/ftnoir_protocol_mouse/ftnoir_protocol_mouse_dialog.cpp index c2f68bd2..1e03a022 100644 --- a/ftnoir_protocol_mouse/ftnoir_protocol_mouse_dialog.cpp +++ b/ftnoir_protocol_mouse/ftnoir_protocol_mouse_dialog.cpp @@ -1,181 +1,181 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2012 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -********************************************************************************/ -#include "ftnoir_protocol_mouse.h" -#include -#include "facetracknoir/global-settings.h" - -//******************************************************************************************************* -// FaceTrackNoIR Client Settings-dialog. -//******************************************************************************************************* - -// -// Constructor for server-settings-dialog -// -MOUSEControls::MOUSEControls() : -QWidget() -{ - ui.setupUi( this ); - ui.cbxSelectMouse_X->addItem("None"); - ui.cbxSelectMouse_X->addItem("X"); - ui.cbxSelectMouse_X->addItem("Y"); - ui.cbxSelectMouse_X->addItem("Z"); - ui.cbxSelectMouse_X->addItem("Yaw"); - ui.cbxSelectMouse_X->addItem("Pitch"); - ui.cbxSelectMouse_X->addItem("Roll"); - - ui.cbxSelectMouse_Y->addItem("None"); - ui.cbxSelectMouse_Y->addItem("X"); - ui.cbxSelectMouse_Y->addItem("Y"); - ui.cbxSelectMouse_Y->addItem("Z"); - ui.cbxSelectMouse_Y->addItem("Yaw"); - ui.cbxSelectMouse_Y->addItem("Pitch"); - ui.cbxSelectMouse_Y->addItem("Roll"); - // Connect Qt signals to member-functions - connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); - connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); - connect(ui.cbxSelectMouse_X, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged( int ))); - connect(ui.cbxSelectMouse_Y, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged( int ))); - theProtocol = NULL; - // Load the settings from the current .INI-file - loadSettings(); -} - -// -// Destructor for server-dialog -// -MOUSEControls::~MOUSEControls() { - qDebug() << "~MOUSEControls() says: started"; -} - -// -// Initialize tracker-client-dialog -// -void MOUSEControls::Initialize(QWidget *parent) { - - QPoint offsetpos(100, 100); - if (parent) { - this->move(parent->pos() + offsetpos); - } - show(); -} - -// -// OK clicked on server-dialog -// -void MOUSEControls::doOK() { - save(); - this->close(); -} - -// override show event -void MOUSEControls::showEvent ( QShowEvent * event ) { - loadSettings(); -} - -// -// Cancel clicked on server-dialog -// -void MOUSEControls::doCancel() { - // - // Ask if changed Settings should be saved - // - if (settingsDirty) { - int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard ); - - qDebug() << "doCancel says: answer =" << ret; - - switch (ret) { - case QMessageBox::Save: - save(); - this->close(); - break; - case QMessageBox::Discard: - this->close(); - break; - case QMessageBox::Cancel: - // Cancel was clicked - break; - default: - // should never be reached - break; - } - } - else { - this->close(); - } -} - -// -// Load the current Settings from the currently 'active' INI-file. -// -void MOUSEControls::loadSettings() { - qDebug() << "loadSettings says: Starting "; - QSettings settings("opentrack"); // 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; - - iniFile.beginGroup ( "Mouse" ); - ui.cbxSelectMouse_X->setCurrentIndex(iniFile.value ( "Mouse_X", 0 ).toInt() ); - ui.cbxSelectMouse_Y->setCurrentIndex(iniFile.value ( "Mouse_Y", 0 ).toInt() ); - iniFile.endGroup (); - - settingsDirty = false; -} - -// -// Save the current Settings to the currently 'active' INI-file. -// -void MOUSEControls::save() { - qDebug() << "save() says: started"; - - QSettings settings("opentrack"); // 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) - - iniFile.beginGroup ( "Mouse" ); - iniFile.setValue ( "Mouse_X", ui.cbxSelectMouse_X->currentIndex() ); - iniFile.setValue ( "Mouse_Y", ui.cbxSelectMouse_Y->currentIndex() ); - iniFile.endGroup (); - - settingsDirty = false; -} - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Protocol-settings dialog object. - -// Export both decorated and undecorated names. -// GetProtocolDialog - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetProtocolDialog@0 - Common name decoration for __stdcall functions in C language. -//#pragma comment(linker, "/export:GetProtocolDialog=_GetProtocolDialog@0") - -extern "C" FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDialog* CALLING_CONVENTION GetDialog( ) -{ - return new MOUSEControls; -} +/******************************************************************************** +* FaceTrackNoIR This program is a private project of some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2012 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +********************************************************************************/ +#include "ftnoir_protocol_mouse.h" +#include +#include "facetracknoir/global-settings.h" + +//******************************************************************************************************* +// FaceTrackNoIR Client Settings-dialog. +//******************************************************************************************************* + +// +// Constructor for server-settings-dialog +// +MOUSEControls::MOUSEControls() : +QWidget() +{ + ui.setupUi( this ); + ui.cbxSelectMouse_X->addItem("None"); + ui.cbxSelectMouse_X->addItem("X"); + ui.cbxSelectMouse_X->addItem("Y"); + ui.cbxSelectMouse_X->addItem("Z"); + ui.cbxSelectMouse_X->addItem("Yaw"); + ui.cbxSelectMouse_X->addItem("Pitch"); + ui.cbxSelectMouse_X->addItem("Roll"); + + ui.cbxSelectMouse_Y->addItem("None"); + ui.cbxSelectMouse_Y->addItem("X"); + ui.cbxSelectMouse_Y->addItem("Y"); + ui.cbxSelectMouse_Y->addItem("Z"); + ui.cbxSelectMouse_Y->addItem("Yaw"); + ui.cbxSelectMouse_Y->addItem("Pitch"); + ui.cbxSelectMouse_Y->addItem("Roll"); + // Connect Qt signals to member-functions + connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); + connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); + connect(ui.cbxSelectMouse_X, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged( int ))); + connect(ui.cbxSelectMouse_Y, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged( int ))); + theProtocol = NULL; + // Load the settings from the current .INI-file + loadSettings(); +} + +// +// Destructor for server-dialog +// +MOUSEControls::~MOUSEControls() { + qDebug() << "~MOUSEControls() says: started"; +} + +// +// Initialize tracker-client-dialog +// +void MOUSEControls::Initialize(QWidget *parent) { + + QPoint offsetpos(100, 100); + if (parent) { + this->move(parent->pos() + offsetpos); + } + show(); +} + +// +// OK clicked on server-dialog +// +void MOUSEControls::doOK() { + save(); + this->close(); +} + +// override show event +void MOUSEControls::showEvent ( QShowEvent * event ) { + loadSettings(); +} + +// +// Cancel clicked on server-dialog +// +void MOUSEControls::doCancel() { + // + // Ask if changed Settings should be saved + // + if (settingsDirty) { + int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard ); + + qDebug() << "doCancel says: answer =" << ret; + + switch (ret) { + case QMessageBox::Save: + save(); + this->close(); + break; + case QMessageBox::Discard: + this->close(); + break; + case QMessageBox::Cancel: + // Cancel was clicked + break; + default: + // should never be reached + break; + } + } + else { + this->close(); + } +} + +// +// Load the current Settings from the currently 'active' INI-file. +// +void MOUSEControls::loadSettings() { + qDebug() << "loadSettings says: Starting "; + QSettings settings("opentrack"); // 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; + + iniFile.beginGroup ( "Mouse" ); + ui.cbxSelectMouse_X->setCurrentIndex(iniFile.value ( "Mouse_X", 0 ).toInt() ); + ui.cbxSelectMouse_Y->setCurrentIndex(iniFile.value ( "Mouse_Y", 0 ).toInt() ); + iniFile.endGroup (); + + settingsDirty = false; +} + +// +// Save the current Settings to the currently 'active' INI-file. +// +void MOUSEControls::save() { + qDebug() << "save() says: started"; + + QSettings settings("opentrack"); // 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) + + iniFile.beginGroup ( "Mouse" ); + iniFile.setValue ( "Mouse_X", ui.cbxSelectMouse_X->currentIndex() ); + iniFile.setValue ( "Mouse_Y", ui.cbxSelectMouse_Y->currentIndex() ); + iniFile.endGroup (); + + settingsDirty = false; +} + +//////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Protocol-settings dialog object. + +// Export both decorated and undecorated names. +// GetProtocolDialog - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetProtocolDialog@0 - Common name decoration for __stdcall functions in C language. +//#pragma comment(linker, "/export:GetProtocolDialog=_GetProtocolDialog@0") + +extern "C" FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDialog* CALLING_CONVENTION GetDialog( ) +{ + return new MOUSEControls; +} diff --git a/ftnoir_protocol_mouse/ftnoir_protocol_mouse_dll.cpp b/ftnoir_protocol_mouse/ftnoir_protocol_mouse_dll.cpp index f2250735..d142934d 100644 --- a/ftnoir_protocol_mouse/ftnoir_protocol_mouse_dll.cpp +++ b/ftnoir_protocol_mouse/ftnoir_protocol_mouse_dll.cpp @@ -1,49 +1,49 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2012 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -********************************************************************************/ -#include "ftnoir_protocol_mouse.h" -#include -#include "facetracknoir/global-settings.h" - -FTNoIR_ProtocolDll::FTNoIR_ProtocolDll() { -} - -FTNoIR_ProtocolDll::~FTNoIR_ProtocolDll() -{ - -} - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Protocol object. - -// Export both decorated and undecorated names. -// GetProtocolDll - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetProtocolDll@0 - Common name decoration for __stdcall functions in C language. -//#pragma comment(linker, "/export:GetProtocolDll=_GetProtocolDll@0") - -extern "C" FTNOIR_PROTOCOL_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata() -{ - return new FTNoIR_ProtocolDll; -} +/******************************************************************************** +* FaceTrackNoIR This program is a private project of some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2012 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +********************************************************************************/ +#include "ftnoir_protocol_mouse.h" +#include +#include "facetracknoir/global-settings.h" + +FTNoIR_ProtocolDll::FTNoIR_ProtocolDll() { +} + +FTNoIR_ProtocolDll::~FTNoIR_ProtocolDll() +{ + +} + +//////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Protocol object. + +// Export both decorated and undecorated names. +// GetProtocolDll - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetProtocolDll@0 - Common name decoration for __stdcall functions in C language. +//#pragma comment(linker, "/export:GetProtocolDll=_GetProtocolDll@0") + +extern "C" FTNOIR_PROTOCOL_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata() +{ + return new FTNoIR_ProtocolDll; +} diff --git a/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp b/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp index cae11816..ca07fbf6 100644 --- a/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp +++ b/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp @@ -1,356 +1,356 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of the some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2010-2011 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -* FTNoIR_Protocol: the Class, that communicates headpose-data * -* to games, using the SimConnect.dll. * -* SimConnect.dll is a so called 'side-by-side' assembly, so it * -* must be treated as such... * -********************************************************************************/ -#include "ftnoir_protocol_sc.h" -#include "facetracknoir/global-settings.h" - -importSimConnect_CameraSetRelative6DOF FTNoIR_Protocol::simconnect_set6DOF; -HANDLE FTNoIR_Protocol::hSimConnect = 0; // Handle to SimConnect - -float FTNoIR_Protocol::virtSCPosX = 0.0f; // Headpose -float FTNoIR_Protocol::virtSCPosY = 0.0f; -float FTNoIR_Protocol::virtSCPosZ = 0.0f; - -float FTNoIR_Protocol::virtSCRotX = 0.0f; -float FTNoIR_Protocol::virtSCRotY = 0.0f; -float FTNoIR_Protocol::virtSCRotZ = 0.0f; - -float FTNoIR_Protocol::prevSCPosX = 0.0f; // previous Headpose -float FTNoIR_Protocol::prevSCPosY = 0.0f; -float FTNoIR_Protocol::prevSCPosZ = 0.0f; - -float FTNoIR_Protocol::prevSCRotX = 0.0f; -float FTNoIR_Protocol::prevSCRotY = 0.0f; -float FTNoIR_Protocol::prevSCRotZ = 0.0f; - -static QLibrary SCClientLib; - -/** constructor **/ -FTNoIR_Protocol::FTNoIR_Protocol() -{ - ProgramName = "Microsoft FSX"; - blnSimConnectActive = false; - hSimConnect = 0; -} - -/** destructor **/ -FTNoIR_Protocol::~FTNoIR_Protocol() -{ - qDebug() << "~FTNoIR_Protocol says: inside" << FTNoIR_Protocol::hSimConnect; - - if (hSimConnect != 0) { - qDebug() << "~FTNoIR_Protocol says: before simconnect_close"; - if (SUCCEEDED( simconnect_close( FTNoIR_Protocol::hSimConnect ) ) ) { - qDebug() << "~FTNoIR_Protocol says: close SUCCEEDED"; - } - } -// SCClientLib.unload(); Generates crash when tracker is ended... -} - -// -// Load the current Settings from the currently 'active' INI-file. -// -void FTNoIR_Protocol::loadSettings() { -// None yet... -} - -// -// Update Headpose in Game. -// -void FTNoIR_Protocol::sendHeadposeToGame( double *headpose, double *rawheadpose ) { -PDWORD_PTR MsgResult = 0; - - - virtSCRotX = -headpose[Pitch]; // degrees - virtSCRotY = -headpose[Yaw]; - virtSCRotZ = headpose[Roll]; - - virtSCPosX = headpose[TX]/100.f; // cm to meters - virtSCPosY = headpose[TY]/100.f; - virtSCPosZ = -headpose[TZ]/100.f; - - // - // It's only useful to send data, if the connection was made. - // - if (!blnSimConnectActive) { - if (SUCCEEDED(simconnect_open(&hSimConnect, "FaceTrackNoIR", NULL, 0, 0, 0))) { - qDebug() << "FTNoIR_Protocol::sendHeadposeToGame() says: SimConnect active!"; - - //set up the events we want to listen for - HRESULT hr; - - simconnect_subscribetosystemevent(hSimConnect, EVENT_PING, "Frame"); - - hr = simconnect_mapclienteventtosimevent(hSimConnect, EVENT_INIT, ""); - hr = simconnect_addclienteventtonotificationgroup(hSimConnect, GROUP0, EVENT_INIT, false); - hr = simconnect_setnotificationgrouppriority(hSimConnect, GROUP0, SIMCONNECT_GROUP_PRIORITY_HIGHEST); - ////hr = SimConnect_MapInputEventToClientEvent(hSimConnect, INPUT0, "VK_COMMA", EVENT_INIT); - ////hr = SimConnect_SetInputGroupState(hSimConnect, INPUT0, SIMCONNECT_STATE_ON); - - blnSimConnectActive = true; - } - } - else { - // - // Write the 6DOF-data to FSX -// // -// // Only do this when the data has changed. This way, the HAT-switch can be used when tracking is OFF. -// // -// if ((prevPosX != virtPosX) || (prevPosY != virtPosY) || (prevPosZ != virtPosZ) || -// (prevRotX != virtRotX) || (prevRotY != virtRotY) || (prevRotZ != virtRotZ)) { -//// if (S_OK == simconnect_set6DOF(hSimConnect, virtPosX, virtPosY, virtPosZ, virtRotX, virtRotZ, virtRotY)) { -//// qDebug() << "FTNoIR_Protocol::run() says: SimConnect data written!"; -//// } -// } -// -// prevPosX = virtPosX; -// prevPosY = virtPosY; -// prevPosZ = virtPosZ; -// prevRotX = virtRotX; -// prevRotY = virtRotY; -// prevRotZ = virtRotZ; - - if (SUCCEEDED(simconnect_calldispatch(hSimConnect, processNextSimconnectEvent, NULL))) { - qDebug() << "FTNoIR_Protocol::sendHeadposeToGame() says: Dispatching"; - } - else { - qDebug() << "FTNoIR_Protocol::sendHeadposeToGame() says: Error Dispatching!"; - } - } -} - -class ActivationContext { -public: - ActivationContext(const int resid) { - hactctx = INVALID_HANDLE_VALUE; - actctx_cookie = NULL; - ACTCTXA actx = {0}; - actx.cbSize = sizeof(ACTCTXA); - actx.lpResourceName = MAKEINTRESOURCEA(resid); - actx.dwFlags = ACTCTX_FLAG_RESOURCE_NAME_VALID; - QString path = QCoreApplication::applicationDirPath() + "/opentrack-proto-simconnect.dll"; - QByteArray name = QFile::encodeName(path); - actx.lpSource = name.constData(); - hactctx = CreateActCtxA(&actx); - actctx_cookie = 0; - if (hactctx != INVALID_HANDLE_VALUE) { - if (!ActivateActCtx(hactctx, &actctx_cookie)) { - qDebug() << "SC: can't set win32 activation context" << GetLastError(); - ReleaseActCtx(hactctx); - hactctx = INVALID_HANDLE_VALUE; - } - } else { - qDebug() << "SC: can't create win32 activation context"; - } - } - ~ActivationContext() { - if (hactctx != INVALID_HANDLE_VALUE) - { - DeactivateActCtx(0, actctx_cookie); - ReleaseActCtx(hactctx); - } - } -private: - ULONG_PTR actctx_cookie; - HANDLE hactctx; -}; - -// -// Returns 'true' if all seems OK. -// -bool FTNoIR_Protocol::checkServerInstallationOK() -{ - if (!SCClientLib.isLoaded()) - { - qDebug() << "SCCheckClientDLL says: Starting Function"; - - SCClientLib.setFileName("SimConnect.DLL"); - - ActivationContext ctx(142); - - if (!SCClientLib.load()) { - qDebug() << "SC load" << SCClientLib.errorString(); - return false; - } - } else { - qDebug() << "SimConnect already loaded"; - } - - // - // Get the functions from the DLL. - // - simconnect_open = (importSimConnect_Open) SCClientLib.resolve("SimConnect_Open"); - if (simconnect_open == NULL) { - qDebug() << "FTNoIR_Protocol::checkServerInstallationOK() says: SimConnect_Open function not found in DLL!"; - return false; - } - simconnect_set6DOF = (importSimConnect_CameraSetRelative6DOF) SCClientLib.resolve("SimConnect_CameraSetRelative6DOF"); - if (simconnect_set6DOF == NULL) { - qDebug() << "FTNoIR_Protocol::checkServerInstallationOK() says: SimConnect_CameraSetRelative6DOF function not found in DLL!"; - return false; - } - simconnect_close = (importSimConnect_Close) SCClientLib.resolve("SimConnect_Close"); - if (simconnect_close == NULL) { - qDebug() << "FTNoIR_Protocol::checkServerInstallationOK() says: SimConnect_Close function not found in DLL!"; - return false; - } - - //return true; - - simconnect_calldispatch = (importSimConnect_CallDispatch) SCClientLib.resolve("SimConnect_CallDispatch"); - if (simconnect_calldispatch == NULL) { - qDebug() << "FTNoIR_Protocol::checkServerInstallationOK() says: SimConnect_CallDispatch function not found in DLL!"; - return false; - } - - simconnect_subscribetosystemevent = (importSimConnect_SubscribeToSystemEvent) SCClientLib.resolve("SimConnect_SubscribeToSystemEvent"); - if (simconnect_subscribetosystemevent == NULL) { - qDebug() << "FTNoIR_Protocol::checkServerInstallationOK() says: SimConnect_SubscribeToSystemEvent function not found in DLL!"; - return false; - } - - simconnect_mapclienteventtosimevent = (importSimConnect_MapClientEventToSimEvent) SCClientLib.resolve("SimConnect_MapClientEventToSimEvent"); - if (simconnect_subscribetosystemevent == NULL) { - qDebug() << "FTNoIR_Protocol::checkServerInstallationOK() says: SimConnect_MapClientEventToSimEvent function not found in DLL!"; - return false; - } - - simconnect_addclienteventtonotificationgroup = (importSimConnect_AddClientEventToNotificationGroup) SCClientLib.resolve("SimConnect_AddClientEventToNotificationGroup"); - if (simconnect_subscribetosystemevent == NULL) { - qDebug() << "FTNoIR_Protocol::checkServerInstallationOK() says: SimConnect_AddClientEventToNotificationGroup function not found in DLL!"; - return false; - } - - simconnect_setnotificationgrouppriority = (importSimConnect_SetNotificationGroupPriority) SCClientLib.resolve("SimConnect_SetNotificationGroupPriority"); - if (simconnect_subscribetosystemevent == NULL) { - qDebug() << "FTNoIR_Protocol::checkServerInstallationOK() says: SimConnect_SetNotificationGroupPriority function not found in DLL!"; - return false; - } - - qDebug() << "FTNoIR_Protocol::checkServerInstallationOK() says: SimConnect functions resolved in DLL!"; - - return true; -} - -void CALLBACK FTNoIR_Protocol::processNextSimconnectEvent(SIMCONNECT_RECV* pData, DWORD cbData, void *pContext) -{ -// HRESULT hr; - - switch(pData->dwID) - { - case SIMCONNECT_RECV_ID_EVENT: - { - SIMCONNECT_RECV_EVENT *evt = (SIMCONNECT_RECV_EVENT*)pData; - - qDebug() << "FTNoIR_Protocol::processNextSimconnectEvent() says: SimConnect active!"; - //switch(evt->uEventID) - //{ - // //case EVENT_CAMERA_RIGHT: - - // // cameraBank = normalize180( cameraBank + 5.0f); - - // // hr = SimConnect_CameraSetRelative6DOF(hSimConnect, 0.0f, 0.0f, 0.0f, - // // SIMCONNECT_CAMERA_IGNORE_FIELD,SIMCONNECT_CAMERA_IGNORE_FIELD, cameraBank); - - // // printf("\nCamera Bank = %f", cameraBank); - // // break; - - // //case EVENT_CAMERA_LEFT: - // // - // // cameraBank = normalize180( cameraBank - 5.0f); - - // // hr = SimConnect_CameraSetRelative6DOF(hSimConnect, 0.0f, 0.0f, 0.0f, - // // SIMCONNECT_CAMERA_IGNORE_FIELD,SIMCONNECT_CAMERA_IGNORE_FIELD, cameraBank); - // // - // // printf("\nCamera Bank = %f", cameraBank); - // // break; - - // //default: - // // break; - //} - //break; - } - case SIMCONNECT_RECV_ID_EVENT_FRAME: - { -// qDebug() << "FTNoIR_Protocol::processNextSimconnectEvent() says: Frame event!"; - if ((prevSCPosX != virtSCPosX) || (prevSCPosY != virtSCPosY) || (prevSCPosZ != virtSCPosZ) || - (prevSCRotX != virtSCRotX) || (prevSCRotY != virtSCRotY) || (prevSCRotZ != virtSCRotZ)) { - if (S_OK == simconnect_set6DOF(hSimConnect, virtSCPosX, virtSCPosY, virtSCPosZ, virtSCRotX, virtSCRotZ, virtSCRotY)) { - // qDebug() << "FTNoIR_Protocol::run() says: SimConnect data written!"; - } - } - prevSCPosX = virtSCPosX; - prevSCPosY = virtSCPosY; - prevSCPosZ = virtSCPosZ; - prevSCRotX = virtSCRotX; - prevSCRotY = virtSCRotY; - prevSCRotZ = virtSCRotZ; - } - - case SIMCONNECT_RECV_ID_EXCEPTION: - { - SIMCONNECT_RECV_EXCEPTION *except = (SIMCONNECT_RECV_EXCEPTION*)pData; - - switch (except->dwException) - { - case SIMCONNECT_EXCEPTION_ERROR: - printf("\nCamera error"); - break; - - default: - printf("\nException"); - break; - } - break; - } - - case SIMCONNECT_RECV_ID_QUIT: - { - qDebug() << "FTNoIR_Protocol::processNextSimconnectEvent() says: Quit event!"; -// quit = 1; - break; - } - - default: - break; - } -} - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Protocol object. - -// Export both decorated and undecorated names. -// GetProtocol - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetProtocol@0 - Common name decoration for __stdcall functions in C language. -//#pragma comment(linker, "/export:GetProtocol=_GetProtocol@0") - -extern "C" FTNOIR_PROTOCOL_BASE_EXPORT IProtocol* CALLING_CONVENTION GetConstructor() -{ - return new FTNoIR_Protocol; -} +/******************************************************************************** +* FaceTrackNoIR This program is a private project of the some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2010-2011 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +* FTNoIR_Protocol: the Class, that communicates headpose-data * +* to games, using the SimConnect.dll. * +* SimConnect.dll is a so called 'side-by-side' assembly, so it * +* must be treated as such... * +********************************************************************************/ +#include "ftnoir_protocol_sc.h" +#include "facetracknoir/global-settings.h" + +importSimConnect_CameraSetRelative6DOF FTNoIR_Protocol::simconnect_set6DOF; +HANDLE FTNoIR_Protocol::hSimConnect = 0; // Handle to SimConnect + +float FTNoIR_Protocol::virtSCPosX = 0.0f; // Headpose +float FTNoIR_Protocol::virtSCPosY = 0.0f; +float FTNoIR_Protocol::virtSCPosZ = 0.0f; + +float FTNoIR_Protocol::virtSCRotX = 0.0f; +float FTNoIR_Protocol::virtSCRotY = 0.0f; +float FTNoIR_Protocol::virtSCRotZ = 0.0f; + +float FTNoIR_Protocol::prevSCPosX = 0.0f; // previous Headpose +float FTNoIR_Protocol::prevSCPosY = 0.0f; +float FTNoIR_Protocol::prevSCPosZ = 0.0f; + +float FTNoIR_Protocol::prevSCRotX = 0.0f; +float FTNoIR_Protocol::prevSCRotY = 0.0f; +float FTNoIR_Protocol::prevSCRotZ = 0.0f; + +static QLibrary SCClientLib; + +/** constructor **/ +FTNoIR_Protocol::FTNoIR_Protocol() +{ + ProgramName = "Microsoft FSX"; + blnSimConnectActive = false; + hSimConnect = 0; +} + +/** destructor **/ +FTNoIR_Protocol::~FTNoIR_Protocol() +{ + qDebug() << "~FTNoIR_Protocol says: inside" << FTNoIR_Protocol::hSimConnect; + + if (hSimConnect != 0) { + qDebug() << "~FTNoIR_Protocol says: before simconnect_close"; + if (SUCCEEDED( simconnect_close( FTNoIR_Protocol::hSimConnect ) ) ) { + qDebug() << "~FTNoIR_Protocol says: close SUCCEEDED"; + } + } +// SCClientLib.unload(); Generates crash when tracker is ended... +} + +// +// Load the current Settings from the currently 'active' INI-file. +// +void FTNoIR_Protocol::loadSettings() { +// None yet... +} + +// +// Update Headpose in Game. +// +void FTNoIR_Protocol::sendHeadposeToGame( double *headpose, double *rawheadpose ) { +PDWORD_PTR MsgResult = 0; + + + virtSCRotX = -headpose[Pitch]; // degrees + virtSCRotY = -headpose[Yaw]; + virtSCRotZ = headpose[Roll]; + + virtSCPosX = headpose[TX]/100.f; // cm to meters + virtSCPosY = headpose[TY]/100.f; + virtSCPosZ = -headpose[TZ]/100.f; + + // + // It's only useful to send data, if the connection was made. + // + if (!blnSimConnectActive) { + if (SUCCEEDED(simconnect_open(&hSimConnect, "FaceTrackNoIR", NULL, 0, 0, 0))) { + qDebug() << "FTNoIR_Protocol::sendHeadposeToGame() says: SimConnect active!"; + + //set up the events we want to listen for + HRESULT hr; + + simconnect_subscribetosystemevent(hSimConnect, EVENT_PING, "Frame"); + + hr = simconnect_mapclienteventtosimevent(hSimConnect, EVENT_INIT, ""); + hr = simconnect_addclienteventtonotificationgroup(hSimConnect, GROUP0, EVENT_INIT, false); + hr = simconnect_setnotificationgrouppriority(hSimConnect, GROUP0, SIMCONNECT_GROUP_PRIORITY_HIGHEST); + ////hr = SimConnect_MapInputEventToClientEvent(hSimConnect, INPUT0, "VK_COMMA", EVENT_INIT); + ////hr = SimConnect_SetInputGroupState(hSimConnect, INPUT0, SIMCONNECT_STATE_ON); + + blnSimConnectActive = true; + } + } + else { + // + // Write the 6DOF-data to FSX +// // +// // Only do this when the data has changed. This way, the HAT-switch can be used when tracking is OFF. +// // +// if ((prevPosX != virtPosX) || (prevPosY != virtPosY) || (prevPosZ != virtPosZ) || +// (prevRotX != virtRotX) || (prevRotY != virtRotY) || (prevRotZ != virtRotZ)) { +//// if (S_OK == simconnect_set6DOF(hSimConnect, virtPosX, virtPosY, virtPosZ, virtRotX, virtRotZ, virtRotY)) { +//// qDebug() << "FTNoIR_Protocol::run() says: SimConnect data written!"; +//// } +// } +// +// prevPosX = virtPosX; +// prevPosY = virtPosY; +// prevPosZ = virtPosZ; +// prevRotX = virtRotX; +// prevRotY = virtRotY; +// prevRotZ = virtRotZ; + + if (SUCCEEDED(simconnect_calldispatch(hSimConnect, processNextSimconnectEvent, NULL))) { + qDebug() << "FTNoIR_Protocol::sendHeadposeToGame() says: Dispatching"; + } + else { + qDebug() << "FTNoIR_Protocol::sendHeadposeToGame() says: Error Dispatching!"; + } + } +} + +class ActivationContext { +public: + ActivationContext(const int resid) { + hactctx = INVALID_HANDLE_VALUE; + actctx_cookie = NULL; + ACTCTXA actx = {0}; + actx.cbSize = sizeof(ACTCTXA); + actx.lpResourceName = MAKEINTRESOURCEA(resid); + actx.dwFlags = ACTCTX_FLAG_RESOURCE_NAME_VALID; + QString path = QCoreApplication::applicationDirPath() + "/opentrack-proto-simconnect.dll"; + QByteArray name = QFile::encodeName(path); + actx.lpSource = name.constData(); + hactctx = CreateActCtxA(&actx); + actctx_cookie = 0; + if (hactctx != INVALID_HANDLE_VALUE) { + if (!ActivateActCtx(hactctx, &actctx_cookie)) { + qDebug() << "SC: can't set win32 activation context" << GetLastError(); + ReleaseActCtx(hactctx); + hactctx = INVALID_HANDLE_VALUE; + } + } else { + qDebug() << "SC: can't create win32 activation context"; + } + } + ~ActivationContext() { + if (hactctx != INVALID_HANDLE_VALUE) + { + DeactivateActCtx(0, actctx_cookie); + ReleaseActCtx(hactctx); + } + } +private: + ULONG_PTR actctx_cookie; + HANDLE hactctx; +}; + +// +// Returns 'true' if all seems OK. +// +bool FTNoIR_Protocol::checkServerInstallationOK() +{ + if (!SCClientLib.isLoaded()) + { + qDebug() << "SCCheckClientDLL says: Starting Function"; + + SCClientLib.setFileName("SimConnect.DLL"); + + ActivationContext ctx(142); + + if (!SCClientLib.load()) { + qDebug() << "SC load" << SCClientLib.errorString(); + return false; + } + } else { + qDebug() << "SimConnect already loaded"; + } + + // + // Get the functions from the DLL. + // + simconnect_open = (importSimConnect_Open) SCClientLib.resolve("SimConnect_Open"); + if (simconnect_open == NULL) { + qDebug() << "FTNoIR_Protocol::checkServerInstallationOK() says: SimConnect_Open function not found in DLL!"; + return false; + } + simconnect_set6DOF = (importSimConnect_CameraSetRelative6DOF) SCClientLib.resolve("SimConnect_CameraSetRelative6DOF"); + if (simconnect_set6DOF == NULL) { + qDebug() << "FTNoIR_Protocol::checkServerInstallationOK() says: SimConnect_CameraSetRelative6DOF function not found in DLL!"; + return false; + } + simconnect_close = (importSimConnect_Close) SCClientLib.resolve("SimConnect_Close"); + if (simconnect_close == NULL) { + qDebug() << "FTNoIR_Protocol::checkServerInstallationOK() says: SimConnect_Close function not found in DLL!"; + return false; + } + + //return true; + + simconnect_calldispatch = (importSimConnect_CallDispatch) SCClientLib.resolve("SimConnect_CallDispatch"); + if (simconnect_calldispatch == NULL) { + qDebug() << "FTNoIR_Protocol::checkServerInstallationOK() says: SimConnect_CallDispatch function not found in DLL!"; + return false; + } + + simconnect_subscribetosystemevent = (importSimConnect_SubscribeToSystemEvent) SCClientLib.resolve("SimConnect_SubscribeToSystemEvent"); + if (simconnect_subscribetosystemevent == NULL) { + qDebug() << "FTNoIR_Protocol::checkServerInstallationOK() says: SimConnect_SubscribeToSystemEvent function not found in DLL!"; + return false; + } + + simconnect_mapclienteventtosimevent = (importSimConnect_MapClientEventToSimEvent) SCClientLib.resolve("SimConnect_MapClientEventToSimEvent"); + if (simconnect_subscribetosystemevent == NULL) { + qDebug() << "FTNoIR_Protocol::checkServerInstallationOK() says: SimConnect_MapClientEventToSimEvent function not found in DLL!"; + return false; + } + + simconnect_addclienteventtonotificationgroup = (importSimConnect_AddClientEventToNotificationGroup) SCClientLib.resolve("SimConnect_AddClientEventToNotificationGroup"); + if (simconnect_subscribetosystemevent == NULL) { + qDebug() << "FTNoIR_Protocol::checkServerInstallationOK() says: SimConnect_AddClientEventToNotificationGroup function not found in DLL!"; + return false; + } + + simconnect_setnotificationgrouppriority = (importSimConnect_SetNotificationGroupPriority) SCClientLib.resolve("SimConnect_SetNotificationGroupPriority"); + if (simconnect_subscribetosystemevent == NULL) { + qDebug() << "FTNoIR_Protocol::checkServerInstallationOK() says: SimConnect_SetNotificationGroupPriority function not found in DLL!"; + return false; + } + + qDebug() << "FTNoIR_Protocol::checkServerInstallationOK() says: SimConnect functions resolved in DLL!"; + + return true; +} + +void CALLBACK FTNoIR_Protocol::processNextSimconnectEvent(SIMCONNECT_RECV* pData, DWORD cbData, void *pContext) +{ +// HRESULT hr; + + switch(pData->dwID) + { + case SIMCONNECT_RECV_ID_EVENT: + { + SIMCONNECT_RECV_EVENT *evt = (SIMCONNECT_RECV_EVENT*)pData; + + qDebug() << "FTNoIR_Protocol::processNextSimconnectEvent() says: SimConnect active!"; + //switch(evt->uEventID) + //{ + // //case EVENT_CAMERA_RIGHT: + + // // cameraBank = normalize180( cameraBank + 5.0f); + + // // hr = SimConnect_CameraSetRelative6DOF(hSimConnect, 0.0f, 0.0f, 0.0f, + // // SIMCONNECT_CAMERA_IGNORE_FIELD,SIMCONNECT_CAMERA_IGNORE_FIELD, cameraBank); + + // // printf("\nCamera Bank = %f", cameraBank); + // // break; + + // //case EVENT_CAMERA_LEFT: + // // + // // cameraBank = normalize180( cameraBank - 5.0f); + + // // hr = SimConnect_CameraSetRelative6DOF(hSimConnect, 0.0f, 0.0f, 0.0f, + // // SIMCONNECT_CAMERA_IGNORE_FIELD,SIMCONNECT_CAMERA_IGNORE_FIELD, cameraBank); + // // + // // printf("\nCamera Bank = %f", cameraBank); + // // break; + + // //default: + // // break; + //} + //break; + } + case SIMCONNECT_RECV_ID_EVENT_FRAME: + { +// qDebug() << "FTNoIR_Protocol::processNextSimconnectEvent() says: Frame event!"; + if ((prevSCPosX != virtSCPosX) || (prevSCPosY != virtSCPosY) || (prevSCPosZ != virtSCPosZ) || + (prevSCRotX != virtSCRotX) || (prevSCRotY != virtSCRotY) || (prevSCRotZ != virtSCRotZ)) { + if (S_OK == simconnect_set6DOF(hSimConnect, virtSCPosX, virtSCPosY, virtSCPosZ, virtSCRotX, virtSCRotZ, virtSCRotY)) { + // qDebug() << "FTNoIR_Protocol::run() says: SimConnect data written!"; + } + } + prevSCPosX = virtSCPosX; + prevSCPosY = virtSCPosY; + prevSCPosZ = virtSCPosZ; + prevSCRotX = virtSCRotX; + prevSCRotY = virtSCRotY; + prevSCRotZ = virtSCRotZ; + } + + case SIMCONNECT_RECV_ID_EXCEPTION: + { + SIMCONNECT_RECV_EXCEPTION *except = (SIMCONNECT_RECV_EXCEPTION*)pData; + + switch (except->dwException) + { + case SIMCONNECT_EXCEPTION_ERROR: + printf("\nCamera error"); + break; + + default: + printf("\nException"); + break; + } + break; + } + + case SIMCONNECT_RECV_ID_QUIT: + { + qDebug() << "FTNoIR_Protocol::processNextSimconnectEvent() says: Quit event!"; +// quit = 1; + break; + } + + default: + break; + } +} + +//////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Protocol object. + +// Export both decorated and undecorated names. +// GetProtocol - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetProtocol@0 - Common name decoration for __stdcall functions in C language. +//#pragma comment(linker, "/export:GetProtocol=_GetProtocol@0") + +extern "C" FTNOIR_PROTOCOL_BASE_EXPORT IProtocol* CALLING_CONVENTION GetConstructor() +{ + return new FTNoIR_Protocol; +} diff --git a/ftnoir_protocol_sc/ftnoir_protocol_sc.h b/ftnoir_protocol_sc/ftnoir_protocol_sc.h index c22c36c7..b3596722 100644 --- a/ftnoir_protocol_sc/ftnoir_protocol_sc.h +++ b/ftnoir_protocol_sc/ftnoir_protocol_sc.h @@ -1,176 +1,176 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2010-2011 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -* SCServer SCServer is the Class, that communicates headpose-data * -* to games, using the SimConnect.dll. * -* SimConnect.dll is a so called 'side-by-side' assembly, so it * -* must be treated as such... * -********************************************************************************/ -#pragma once -#ifndef INCLUDED_SCSERVER_H -#define INCLUDED_SCSERVER_H -#include "facetracknoir/global-settings.h" -// -// Prevent the SimConnect manifest from being merged in the application-manifest -// This is necessary to run FaceTrackNoIR on a PC without FSX -// -#define SIMCONNECT_H_NOMANIFEST -#define _WIN32_WINNT 0x0502 - -#include -#include - -#include <..\ftnoir_protocol_base\ftnoir_protocol_base.h> -#include -#include -#include -#include -#include -#include -#include -//#include "math.h" - -typedef HRESULT (WINAPI *importSimConnect_Open)(HANDLE * phSimConnect, LPCSTR szName, HWND hWnd, DWORD UserEventWin32, HANDLE hEventHandle, DWORD ConfigIndex); -typedef HRESULT (WINAPI *importSimConnect_Close)(HANDLE hSimConnect); -typedef HRESULT (WINAPI *importSimConnect_CameraSetRelative6DOF)(HANDLE hSimConnect, float fDeltaX, float fDeltaY, float fDeltaZ, float fPitchDeg, float fBankDeg, float fHeadingDeg); -typedef HRESULT (WINAPI *importSimConnect_CallDispatch)(HANDLE hSimConnect, DispatchProc pfcnDispatch, void * pContext); -typedef HRESULT (WINAPI *importSimConnect_SubscribeToSystemEvent)(HANDLE hSimConnect, SIMCONNECT_CLIENT_EVENT_ID EventID, const char * SystemEventName); -typedef HRESULT (WINAPI *importSimConnect_MapClientEventToSimEvent)(HANDLE hSimConnect, SIMCONNECT_CLIENT_EVENT_ID EventID, const char * EventName); -typedef HRESULT (WINAPI *importSimConnect_AddClientEventToNotificationGroup)(HANDLE hSimConnect, SIMCONNECT_NOTIFICATION_GROUP_ID GroupID, SIMCONNECT_CLIENT_EVENT_ID EventID, BOOL bMaskable); -typedef HRESULT (WINAPI *importSimConnect_SetNotificationGroupPriority)(HANDLE hSimConnect, SIMCONNECT_NOTIFICATION_GROUP_ID GroupID, DWORD uPriority); - -#define SC_CLIENT_FILENAME "SimConnect.dll" - -enum GROUP_ID -{ - GROUP0=0, -}; - -enum EVENT_ID -{ - EVENT_PING=0, - EVENT_INIT, -}; - -enum INPUT_ID -{ - INPUT0=0, -}; - -class FTNoIR_Protocol : public IProtocol -{ -public: - FTNoIR_Protocol(); - ~FTNoIR_Protocol(); - bool checkServerInstallationOK(); - void sendHeadposeToGame( double *headpose, double *rawheadpose ); - QString getGameName() { - return "FS2004/FSX"; - } - -private: - // Private properties - QString ProgramName; - - static float virtSCPosX; - static float virtSCPosY; - static float virtSCPosZ; - - static float virtSCRotX; - static float virtSCRotY; - static float virtSCRotZ; - - static float prevSCPosX; - static float prevSCPosY; - static float prevSCPosZ; - - static float prevSCRotX; - static float prevSCRotY; - static float prevSCRotZ; - - bool blnSimConnectActive; - - importSimConnect_Open simconnect_open; // SimConnect function(s) in DLL - importSimConnect_Close simconnect_close; - static importSimConnect_CameraSetRelative6DOF simconnect_set6DOF; - importSimConnect_CallDispatch simconnect_calldispatch; - importSimConnect_SubscribeToSystemEvent simconnect_subscribetosystemevent; - importSimConnect_MapClientEventToSimEvent simconnect_mapclienteventtosimevent; - importSimConnect_AddClientEventToNotificationGroup simconnect_addclienteventtonotificationgroup; - importSimConnect_SetNotificationGroupPriority simconnect_setnotificationgrouppriority; - - static HANDLE hSimConnect; // Handle to SimConnect - static void CALLBACK processNextSimconnectEvent(SIMCONNECT_RECV* pData, DWORD cbData, void *pContext); - void loadSettings(); -}; - -// Widget that has controls for FTNoIR protocol client-settings. -class SCControls: public QWidget, public IProtocolDialog -{ - Q_OBJECT -public: - - explicit SCControls(); - virtual ~SCControls(); - void showEvent ( QShowEvent * event ); - void Initialize(QWidget *parent); - void registerProtocol(IProtocol *protocol) { - theProtocol = (FTNoIR_Protocol *) protocol; // Accept the pointer to the Protocol - } - void unRegisterProtocol() { - theProtocol = NULL; // Reset the pointer - } - -private: - Ui::UICSCControls ui; - void loadSettings(); - void save(); - - /** helper **/ - bool settingsDirty; - FTNoIR_Protocol *theProtocol; - -private slots: - void doOK(); - void doCancel(); - void settingChanged() { settingsDirty = true; }; -}; - -//******************************************************************************************************* -// FaceTrackNoIR Protocol DLL. Functions used to get general info on the Protocol -//******************************************************************************************************* -class FTNoIR_ProtocolDll : public Metadata -{ -public: - FTNoIR_ProtocolDll(); - ~FTNoIR_ProtocolDll(); - - void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("FSX SimConnect"); }; - void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("SimConnect"); }; - void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("Microsoft SimConnect protocol"); }; - - void getIcon(QIcon *icon) { *icon = QIcon(":/images/fsx.png"); }; -}; - -#endif//INCLUDED_SCSERVER_H -//END +/******************************************************************************** +* FaceTrackNoIR This program is a private project of some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2010-2011 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +* SCServer SCServer is the Class, that communicates headpose-data * +* to games, using the SimConnect.dll. * +* SimConnect.dll is a so called 'side-by-side' assembly, so it * +* must be treated as such... * +********************************************************************************/ +#pragma once +#ifndef INCLUDED_SCSERVER_H +#define INCLUDED_SCSERVER_H +#include "facetracknoir/global-settings.h" +// +// Prevent the SimConnect manifest from being merged in the application-manifest +// This is necessary to run FaceTrackNoIR on a PC without FSX +// +#define SIMCONNECT_H_NOMANIFEST +#define _WIN32_WINNT 0x0502 + +#include +#include + +#include <..\ftnoir_protocol_base\ftnoir_protocol_base.h> +#include +#include +#include +#include +#include +#include +#include +//#include "math.h" + +typedef HRESULT (WINAPI *importSimConnect_Open)(HANDLE * phSimConnect, LPCSTR szName, HWND hWnd, DWORD UserEventWin32, HANDLE hEventHandle, DWORD ConfigIndex); +typedef HRESULT (WINAPI *importSimConnect_Close)(HANDLE hSimConnect); +typedef HRESULT (WINAPI *importSimConnect_CameraSetRelative6DOF)(HANDLE hSimConnect, float fDeltaX, float fDeltaY, float fDeltaZ, float fPitchDeg, float fBankDeg, float fHeadingDeg); +typedef HRESULT (WINAPI *importSimConnect_CallDispatch)(HANDLE hSimConnect, DispatchProc pfcnDispatch, void * pContext); +typedef HRESULT (WINAPI *importSimConnect_SubscribeToSystemEvent)(HANDLE hSimConnect, SIMCONNECT_CLIENT_EVENT_ID EventID, const char * SystemEventName); +typedef HRESULT (WINAPI *importSimConnect_MapClientEventToSimEvent)(HANDLE hSimConnect, SIMCONNECT_CLIENT_EVENT_ID EventID, const char * EventName); +typedef HRESULT (WINAPI *importSimConnect_AddClientEventToNotificationGroup)(HANDLE hSimConnect, SIMCONNECT_NOTIFICATION_GROUP_ID GroupID, SIMCONNECT_CLIENT_EVENT_ID EventID, BOOL bMaskable); +typedef HRESULT (WINAPI *importSimConnect_SetNotificationGroupPriority)(HANDLE hSimConnect, SIMCONNECT_NOTIFICATION_GROUP_ID GroupID, DWORD uPriority); + +#define SC_CLIENT_FILENAME "SimConnect.dll" + +enum GROUP_ID +{ + GROUP0=0, +}; + +enum EVENT_ID +{ + EVENT_PING=0, + EVENT_INIT, +}; + +enum INPUT_ID +{ + INPUT0=0, +}; + +class FTNoIR_Protocol : public IProtocol +{ +public: + FTNoIR_Protocol(); + ~FTNoIR_Protocol(); + bool checkServerInstallationOK(); + void sendHeadposeToGame( double *headpose, double *rawheadpose ); + QString getGameName() { + return "FS2004/FSX"; + } + +private: + // Private properties + QString ProgramName; + + static float virtSCPosX; + static float virtSCPosY; + static float virtSCPosZ; + + static float virtSCRotX; + static float virtSCRotY; + static float virtSCRotZ; + + static float prevSCPosX; + static float prevSCPosY; + static float prevSCPosZ; + + static float prevSCRotX; + static float prevSCRotY; + static float prevSCRotZ; + + bool blnSimConnectActive; + + importSimConnect_Open simconnect_open; // SimConnect function(s) in DLL + importSimConnect_Close simconnect_close; + static importSimConnect_CameraSetRelative6DOF simconnect_set6DOF; + importSimConnect_CallDispatch simconnect_calldispatch; + importSimConnect_SubscribeToSystemEvent simconnect_subscribetosystemevent; + importSimConnect_MapClientEventToSimEvent simconnect_mapclienteventtosimevent; + importSimConnect_AddClientEventToNotificationGroup simconnect_addclienteventtonotificationgroup; + importSimConnect_SetNotificationGroupPriority simconnect_setnotificationgrouppriority; + + static HANDLE hSimConnect; // Handle to SimConnect + static void CALLBACK processNextSimconnectEvent(SIMCONNECT_RECV* pData, DWORD cbData, void *pContext); + void loadSettings(); +}; + +// Widget that has controls for FTNoIR protocol client-settings. +class SCControls: public QWidget, public IProtocolDialog +{ + Q_OBJECT +public: + + explicit SCControls(); + virtual ~SCControls(); + void showEvent ( QShowEvent * event ); + void Initialize(QWidget *parent); + void registerProtocol(IProtocol *protocol) { + theProtocol = (FTNoIR_Protocol *) protocol; // Accept the pointer to the Protocol + } + void unRegisterProtocol() { + theProtocol = NULL; // Reset the pointer + } + +private: + Ui::UICSCControls ui; + void loadSettings(); + void save(); + + /** helper **/ + bool settingsDirty; + FTNoIR_Protocol *theProtocol; + +private slots: + void doOK(); + void doCancel(); + void settingChanged() { settingsDirty = true; }; +}; + +//******************************************************************************************************* +// FaceTrackNoIR Protocol DLL. Functions used to get general info on the Protocol +//******************************************************************************************************* +class FTNoIR_ProtocolDll : public Metadata +{ +public: + FTNoIR_ProtocolDll(); + ~FTNoIR_ProtocolDll(); + + void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("FSX SimConnect"); }; + void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("SimConnect"); }; + void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("Microsoft SimConnect protocol"); }; + + void getIcon(QIcon *icon) { *icon = QIcon(":/images/fsx.png"); }; +}; + +#endif//INCLUDED_SCSERVER_H +//END diff --git a/ftnoir_protocol_sc/ftnoir_protocol_sc_dialog.cpp b/ftnoir_protocol_sc/ftnoir_protocol_sc_dialog.cpp index 41e990dd..c2ddb72a 100644 --- a/ftnoir_protocol_sc/ftnoir_protocol_sc_dialog.cpp +++ b/ftnoir_protocol_sc/ftnoir_protocol_sc_dialog.cpp @@ -1,145 +1,145 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2012 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -********************************************************************************/ -#include "ftnoir_protocol_sc.h" -#include -#include "facetracknoir/global-settings.h" - -//******************************************************************************************************* -// FaceTrackNoIR Client Settings-dialog. -//******************************************************************************************************* - -// -// Constructor for server-settings-dialog -// -SCControls::SCControls() : -QWidget() -{ - ui.setupUi( this ); - - // Connect Qt signals to member-functions - connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); - connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); - //connect(ui.cbxSelectPPJoyNumber, SIGNAL(currentIndexChanged(int)), this, SLOT(virtualJoystickSelected( int ))); - - theProtocol = NULL; - - // Load the settings from the current .INI-file - loadSettings(); -} - -// -// Destructor for server-dialog -// -SCControls::~SCControls() { - qDebug() << "~SCControls() says: started"; -} - -// -// Initialize tracker-client-dialog -// -void SCControls::Initialize(QWidget *parent) { - - QPoint offsetpos(100, 100); - if (parent) { - this->move(parent->pos() + offsetpos); - } - show(); -} - -// -// OK clicked on server-dialog -// -void SCControls::doOK() { - save(); - this->close(); -} - -// override show event -void SCControls::showEvent ( QShowEvent * event ) { - loadSettings(); -} - -// -// Cancel clicked on server-dialog -// -void SCControls::doCancel() { - // - // Ask if changed Settings should be saved - // - if (settingsDirty) { - int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard ); - - qDebug() << "doCancel says: answer =" << ret; - - switch (ret) { - case QMessageBox::Save: - save(); - this->close(); - break; - case QMessageBox::Discard: - this->close(); - break; - case QMessageBox::Cancel: - // Cancel was clicked - break; - default: - // should never be reached - break; - } - } - else { - this->close(); - } -} - -// -// Load the current Settings from the currently 'active' INI-file. -// -void SCControls::loadSettings() { - - settingsDirty = false; -} - -// -// Save the current Settings to the currently 'active' INI-file. -// -void SCControls::save() { - - settingsDirty = false; -} - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Protocol-settings dialog object. - -// Export both decorated and undecorated names. -// GetProtocolDialog - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetProtocolDialog@0 - Common name decoration for __stdcall functions in C language. -//#pragma comment(linker, "/export:GetProtocolDialog=_GetProtocolDialog@0") - -extern "C" FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDialog* CALLING_CONVENTION GetDialog( ) -{ - return new SCControls; -} +/******************************************************************************** +* FaceTrackNoIR This program is a private project of some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2012 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +********************************************************************************/ +#include "ftnoir_protocol_sc.h" +#include +#include "facetracknoir/global-settings.h" + +//******************************************************************************************************* +// FaceTrackNoIR Client Settings-dialog. +//******************************************************************************************************* + +// +// Constructor for server-settings-dialog +// +SCControls::SCControls() : +QWidget() +{ + ui.setupUi( this ); + + // Connect Qt signals to member-functions + connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); + connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); + //connect(ui.cbxSelectPPJoyNumber, SIGNAL(currentIndexChanged(int)), this, SLOT(virtualJoystickSelected( int ))); + + theProtocol = NULL; + + // Load the settings from the current .INI-file + loadSettings(); +} + +// +// Destructor for server-dialog +// +SCControls::~SCControls() { + qDebug() << "~SCControls() says: started"; +} + +// +// Initialize tracker-client-dialog +// +void SCControls::Initialize(QWidget *parent) { + + QPoint offsetpos(100, 100); + if (parent) { + this->move(parent->pos() + offsetpos); + } + show(); +} + +// +// OK clicked on server-dialog +// +void SCControls::doOK() { + save(); + this->close(); +} + +// override show event +void SCControls::showEvent ( QShowEvent * event ) { + loadSettings(); +} + +// +// Cancel clicked on server-dialog +// +void SCControls::doCancel() { + // + // Ask if changed Settings should be saved + // + if (settingsDirty) { + int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard ); + + qDebug() << "doCancel says: answer =" << ret; + + switch (ret) { + case QMessageBox::Save: + save(); + this->close(); + break; + case QMessageBox::Discard: + this->close(); + break; + case QMessageBox::Cancel: + // Cancel was clicked + break; + default: + // should never be reached + break; + } + } + else { + this->close(); + } +} + +// +// Load the current Settings from the currently 'active' INI-file. +// +void SCControls::loadSettings() { + + settingsDirty = false; +} + +// +// Save the current Settings to the currently 'active' INI-file. +// +void SCControls::save() { + + settingsDirty = false; +} + +//////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Protocol-settings dialog object. + +// Export both decorated and undecorated names. +// GetProtocolDialog - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetProtocolDialog@0 - Common name decoration for __stdcall functions in C language. +//#pragma comment(linker, "/export:GetProtocolDialog=_GetProtocolDialog@0") + +extern "C" FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDialog* CALLING_CONVENTION GetDialog( ) +{ + return new SCControls; +} diff --git a/ftnoir_protocol_sc/ftnoir_protocol_sc_dll.cpp b/ftnoir_protocol_sc/ftnoir_protocol_sc_dll.cpp index 102c7c57..fce8753a 100644 --- a/ftnoir_protocol_sc/ftnoir_protocol_sc_dll.cpp +++ b/ftnoir_protocol_sc/ftnoir_protocol_sc_dll.cpp @@ -1,49 +1,49 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2012 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -********************************************************************************/ -#include "ftnoir_protocol_SC.h" -#include -#include "facetracknoir/global-settings.h" - -FTNoIR_ProtocolDll::FTNoIR_ProtocolDll() { -} - -FTNoIR_ProtocolDll::~FTNoIR_ProtocolDll() -{ - -} - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Protocol object. - -// Export both decorated and undecorated names. -// GetProtocolDll - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetProtocolDll@0 - Common name decoration for __stdcall functions in C language. -//#pragma comment(linker, "/export:GetProtocolDll=_GetProtocolDll@0") - -extern "C" FTNOIR_PROTOCOL_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata() -{ - return new FTNoIR_ProtocolDll; -} +/******************************************************************************** +* FaceTrackNoIR This program is a private project of some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2012 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +********************************************************************************/ +#include "ftnoir_protocol_SC.h" +#include +#include "facetracknoir/global-settings.h" + +FTNoIR_ProtocolDll::FTNoIR_ProtocolDll() { +} + +FTNoIR_ProtocolDll::~FTNoIR_ProtocolDll() +{ + +} + +//////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Protocol object. + +// Export both decorated and undecorated names. +// GetProtocolDll - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetProtocolDll@0 - Common name decoration for __stdcall functions in C language. +//#pragma comment(linker, "/export:GetProtocolDll=_GetProtocolDll@0") + +extern "C" FTNOIR_PROTOCOL_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata() +{ + return new FTNoIR_ProtocolDll; +} diff --git a/ftnoir_tracker_base/ftnoir_tracker_base.h b/ftnoir_tracker_base/ftnoir_tracker_base.h index 7c2ab442..4d968e59 100644 --- a/ftnoir_tracker_base/ftnoir_tracker_base.h +++ b/ftnoir_tracker_base/ftnoir_tracker_base.h @@ -1,81 +1,81 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of the some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2010 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* This class implements a tracker-base * -*********************************************************************************/ -/* - Modifications (last one on top): - 20122109 - C14: Replaced Release with virtual destructor - 20120009 - WVR: Removed AutoClosePtr (seemed like it didn't work OK) - 20110415 - WVR: Added overloaded operator - and -= -*/ -#ifndef FTNOIR_TRACKER_BASE_H -#define FTNOIR_TRACKER_BASE_H - -#include "ftnoir_tracker_base_global.h" -#include "ftnoir_tracker_types.h" -#include -#include -#include -#include -#include - -//////////////////////////////////////////////////////////////////////////////// -#ifdef __cplusplus -# define EXTERN_C extern "C" -#else -# define EXTERN_C -#endif // __cplusplus - -//////////////////////////////////////////////////////////////////////////////// -// COM-Like abstract interface. -// This interface doesn't require __declspec(dllexport/dllimport) specifier. -// Method calls are dispatched via virtual table. -// Any C++ compiler can use it. -// Instances are obtained via factory function. -struct ITracker -{ - virtual ~ITracker() {} - virtual void StartTracker( QFrame* frame ) = 0; - virtual bool GiveHeadPoseData(double *data) = 0; - - virtual void WaitForExit() = 0; - virtual void NotifyCenter() {} -}; - -typedef ITracker* ITrackerPtr; - -//////////////////////////////////////////////////////////////////////////////// -// COM-Like abstract interface. -// This interface doesn't require __declspec(dllexport/dllimport) specifier. -// Method calls are dispatched via virtual table. -// Any C++ compiler can use it. -// Instances are obtained via factory function. -struct ITrackerDialog -{ - virtual ~ITrackerDialog() {} - virtual void Initialize(QWidget *parent) = 0; - virtual void registerTracker(ITracker *tracker) = 0; - virtual void unRegisterTracker() = 0; -}; - -#endif // FTNOIR_TRACKER_BASE_H +/******************************************************************************** +* FaceTrackNoIR This program is a private project of the some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2010 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* This class implements a tracker-base * +*********************************************************************************/ +/* + Modifications (last one on top): + 20122109 - C14: Replaced Release with virtual destructor + 20120009 - WVR: Removed AutoClosePtr (seemed like it didn't work OK) + 20110415 - WVR: Added overloaded operator - and -= +*/ +#ifndef FTNOIR_TRACKER_BASE_H +#define FTNOIR_TRACKER_BASE_H + +#include "ftnoir_tracker_base_global.h" +#include "ftnoir_tracker_types.h" +#include +#include +#include +#include +#include + +//////////////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +# define EXTERN_C extern "C" +#else +# define EXTERN_C +#endif // __cplusplus + +//////////////////////////////////////////////////////////////////////////////// +// COM-Like abstract interface. +// This interface doesn't require __declspec(dllexport/dllimport) specifier. +// Method calls are dispatched via virtual table. +// Any C++ compiler can use it. +// Instances are obtained via factory function. +struct ITracker +{ + virtual ~ITracker() {} + virtual void StartTracker( QFrame* frame ) = 0; + virtual bool GiveHeadPoseData(double *data) = 0; + + virtual void WaitForExit() = 0; + virtual void NotifyCenter() {} +}; + +typedef ITracker* ITrackerPtr; + +//////////////////////////////////////////////////////////////////////////////// +// COM-Like abstract interface. +// This interface doesn't require __declspec(dllexport/dllimport) specifier. +// Method calls are dispatched via virtual table. +// Any C++ compiler can use it. +// Instances are obtained via factory function. +struct ITrackerDialog +{ + virtual ~ITrackerDialog() {} + virtual void Initialize(QWidget *parent) = 0; + virtual void registerTracker(ITracker *tracker) = 0; + virtual void unRegisterTracker() = 0; +}; + +#endif // FTNOIR_TRACKER_BASE_H diff --git a/ftnoir_tracker_base/ftnoir_tracker_base_global.h b/ftnoir_tracker_base/ftnoir_tracker_base_global.h index a449c282..af9899c5 100644 --- a/ftnoir_tracker_base/ftnoir_tracker_base_global.h +++ b/ftnoir_tracker_base/ftnoir_tracker_base_global.h @@ -1,12 +1,12 @@ -#ifndef FTNOIR_TRACKER_BASE_GLOBAL_H -#define FTNOIR_TRACKER_BASE_GLOBAL_H - -#include - -#ifdef FTNOIR_TRACKER_BASE_LIB -# define FTNOIR_TRACKER_BASE_EXPORT Q_DECL_EXPORT -#else -# define FTNOIR_TRACKER_BASE_EXPORT Q_DECL_IMPORT -#endif - -#endif // FTNOIR_TRACKER_BASE_GLOBAL_H +#ifndef FTNOIR_TRACKER_BASE_GLOBAL_H +#define FTNOIR_TRACKER_BASE_GLOBAL_H + +#include + +#ifdef FTNOIR_TRACKER_BASE_LIB +# define FTNOIR_TRACKER_BASE_EXPORT Q_DECL_EXPORT +#else +# define FTNOIR_TRACKER_BASE_EXPORT Q_DECL_IMPORT +#endif + +#endif // FTNOIR_TRACKER_BASE_GLOBAL_H diff --git a/ftnoir_tracker_base/ftnoir_tracker_sm_types.h b/ftnoir_tracker_base/ftnoir_tracker_sm_types.h index 1faf893f..526f8cdc 100644 --- a/ftnoir_tracker_base/ftnoir_tracker_sm_types.h +++ b/ftnoir_tracker_base/ftnoir_tracker_sm_types.h @@ -1,36 +1,36 @@ -// -// Definitions for the Shared Memory to send the data to FaceTrackNoIR -// -#define SM_MM_DATA "SM_SharedMem" -#define SM_FACEAPI "SM_FaceAPI" -#define SM_MUTEX "SM_Mutex" - -#include "faceapi/stdafx.h" -#include - -struct TFaceData { - int DataID; - smEngineHeadPoseData new_pose; -}; -typedef TFaceData * PFaceData; - -struct SMMemMap { - int command; // Command from FaceTrackNoIR - int status; // Status from faceAPI - TFaceData data; - HANDLE handle; - int state; - int par_val_int; // Value of parameter, indicated by 'command' - int par_val_float; - int initial_filter_level; // Internal faceAPI Filter level - int handshake; -}; -typedef SMMemMap * PSMMemMap; - -enum FTNoIR_Tracker_Command { - FT_SM_START = 10, - FT_SM_STOP = 20, - FT_SM_SHOW_CAM = 30, - FT_SM_SET_PAR_FILTER = 50, - FT_SM_EXIT = 100 -}; +// +// Definitions for the Shared Memory to send the data to FaceTrackNoIR +// +#define SM_MM_DATA "SM_SharedMem" +#define SM_FACEAPI "SM_FaceAPI" +#define SM_MUTEX "SM_Mutex" + +#include "faceapi/stdafx.h" +#include + +struct TFaceData { + int DataID; + smEngineHeadPoseData new_pose; +}; +typedef TFaceData * PFaceData; + +struct SMMemMap { + int command; // Command from FaceTrackNoIR + int status; // Status from faceAPI + TFaceData data; + HANDLE handle; + int state; + int par_val_int; // Value of parameter, indicated by 'command' + int par_val_float; + int initial_filter_level; // Internal faceAPI Filter level + int handshake; +}; +typedef SMMemMap * PSMMemMap; + +enum FTNoIR_Tracker_Command { + FT_SM_START = 10, + FT_SM_STOP = 20, + FT_SM_SHOW_CAM = 30, + FT_SM_SET_PAR_FILTER = 50, + FT_SM_EXIT = 100 +}; diff --git a/ftnoir_tracker_base/ftnoir_tracker_types.h b/ftnoir_tracker_base/ftnoir_tracker_types.h index 8bf12990..591728a6 100644 --- a/ftnoir_tracker_base/ftnoir_tracker_types.h +++ b/ftnoir_tracker_base/ftnoir_tracker_types.h @@ -1,37 +1,37 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of the some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2010 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* This class implements a tracker-base * -*********************************************************************************/ -/* - Modifications (last one on top): - 20120924 - C14: Moved T6DOF to separate file (not pulic interface) - 20110415 - WVR: Added overloaded operator - and -= -*/ -#ifndef FTNOIR_TRACKER_TYPES_H -#define FTNOIR_TRACKER_TYPES_H - - -enum Axis { - TX = 0, TY, TZ, Yaw, Pitch, Roll}; - -#endif // FTNOIR_TRACKER_TYPES_H +/******************************************************************************** +* FaceTrackNoIR This program is a private project of the some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2010 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* This class implements a tracker-base * +*********************************************************************************/ +/* + Modifications (last one on top): + 20120924 - C14: Moved T6DOF to separate file (not pulic interface) + 20110415 - WVR: Added overloaded operator - and -= +*/ +#ifndef FTNOIR_TRACKER_TYPES_H +#define FTNOIR_TRACKER_TYPES_H + + +enum Axis { + TX = 0, TY, TZ, Yaw, Pitch, Roll}; + +#endif // FTNOIR_TRACKER_TYPES_H diff --git a/ftnoir_tracker_pt/camera.cpp b/ftnoir_tracker_pt/camera.cpp index fe39b436..46dd20c5 100644 --- a/ftnoir_tracker_pt/camera.cpp +++ b/ftnoir_tracker_pt/camera.cpp @@ -1,213 +1,213 @@ -/* Copyright (c) 2012 Patrick Ruoff - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - */ - -#include "camera.h" -#include - -using namespace cv; - -// ---------------------------------------------------------------------------- -void Camera::set_index(int index) -{ - if (desired_index != index) - { - desired_index = index; - _set_index(); - - // reset fps - dt_valid = 0; - dt_mean = 0; - active_index = index; - } -} - -void Camera::set_f(float f) -{ - if (cam_desired.f != f) - { - cam_desired.f = f; - _set_f(); - } -} -void Camera::set_fps(int fps) -{ - if (cam_desired.fps != fps) - { - cam_desired.fps = fps; - _set_fps(); - } -} - -void Camera::set_res(int x_res, int y_res) -{ - if (cam_desired.res_x != x_res || cam_desired.res_y != y_res) - { - cam_desired.res_x = x_res; - cam_desired.res_y = y_res; - _set_res(); - } -} - -bool Camera::get_frame(float dt, cv::Mat* frame) -{ - bool new_frame = _get_frame(frame); - // measure fps of valid frames - const float dt_smoothing_const = 0.9; - dt_valid += dt; - if (new_frame) - { - dt_mean = dt_smoothing_const * dt_mean + (1.0 - dt_smoothing_const) * dt_valid; - cam_info.fps = 1.0 / dt_mean; - dt_valid = 0; - } - return new_frame; -} - -// ---------------------------------------------------------------------------- -void CVCamera::start() -{ - cap = new VideoCapture(desired_index); -// extract camera info - active = true; - active_index = desired_index; - cam_info.res_x = cap->get(CV_CAP_PROP_FRAME_WIDTH); - cam_info.res_y = cap->get(CV_CAP_PROP_FRAME_HEIGHT); -} - -void CVCamera::stop() -{ - if (cap) { - cap->release(); - delete cap; - cap = NULL; - } - active = false; -} - -bool CVCamera::_get_frame(Mat* frame) -{ - bool ret = cap->read(*frame); - //if (ret) - // flip(tmp, *frame, 0); - return ret; -} - -void CVCamera::_set_index() -{ - if (active) restart(); -} - -void CVCamera::_set_f() -{ - cam_info.f = cam_desired.f; -} - -void CVCamera::_set_fps() -{ - if (cap) cap->set(CV_CAP_PROP_FPS, cam_desired.fps); -} - -void CVCamera::_set_res() -{ - if (cap) - { - cap->set(CV_CAP_PROP_FRAME_WIDTH, cam_desired.res_x); - cap->set(CV_CAP_PROP_FRAME_HEIGHT, cam_desired.res_y); - cam_info.res_x = cap->get(CV_CAP_PROP_FRAME_WIDTH); - cam_info.res_y = cap->get(CV_CAP_PROP_FRAME_HEIGHT); - } -} - -#if 0 -// ---------------------------------------------------------------------------- -VICamera::VICamera() : frame_buffer(NULL) -{ - VI.listDevices(); -} - -void VICamera::start() -{ - if (desired_index >= 0) - { - - - if (cam_desired.res_x == 0 || cam_desired.res_y == 0) - VI.setupDevice(desired_index); - else - VI.setupDevice(desired_index, cam_desired.res_x, cam_desired.res_y); - - active = true; - active_index = desired_index; - - cam_info.res_x = VI.getWidth(active_index); - cam_info.res_y = VI.getHeight(active_index); - new_frame = cv::Mat(cam_info.res_y, cam_info.res_x, CV_8UC3); - // If matrix is not continuous we have to copy manually via frame_buffer - if (!new_frame.isContinuous()) { - unsigned int size = VI.getSize(active_index); - frame_buffer = new unsigned char[size]; - } - } -} - -void VICamera::stop() -{ - if (active) - { - VI.stopDevice(active_index); - } - if (frame_buffer) - { - delete[] frame_buffer; - frame_buffer = NULL; - } - active = false; -} - -bool VICamera::_get_frame(Mat* frame) -{ - if (active && VI.isFrameNew(active_index)) - { - if (new_frame.isContinuous()) - { - VI.getPixels(active_index, new_frame.data, false, true); - } - else - { - // If matrix is not continuous we have to copy manually via frame_buffer - VI.getPixels(active_index, frame_buffer, false, true); - new_frame = cv::Mat(cam_info.res_y, cam_info.res_x, CV_8UC3, frame_buffer).clone(); - } - *frame = new_frame; - return true; - } - return false; -} - -void VICamera::_set_index() -{ - if (active) restart(); -} - -void VICamera::_set_f() -{ - cam_info.f = cam_desired.f; -} - -void VICamera::_set_fps() -{ - bool was_active = active; - if (active) stop(); - VI.setIdealFramerate(desired_index, cam_desired.fps); - if (was_active) start(); -} - -void VICamera::_set_res() -{ - if (active) restart(); -} -#endif +/* Copyright (c) 2012 Patrick Ruoff + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + */ + +#include "camera.h" +#include + +using namespace cv; + +// ---------------------------------------------------------------------------- +void Camera::set_index(int index) +{ + if (desired_index != index) + { + desired_index = index; + _set_index(); + + // reset fps + dt_valid = 0; + dt_mean = 0; + active_index = index; + } +} + +void Camera::set_f(float f) +{ + if (cam_desired.f != f) + { + cam_desired.f = f; + _set_f(); + } +} +void Camera::set_fps(int fps) +{ + if (cam_desired.fps != fps) + { + cam_desired.fps = fps; + _set_fps(); + } +} + +void Camera::set_res(int x_res, int y_res) +{ + if (cam_desired.res_x != x_res || cam_desired.res_y != y_res) + { + cam_desired.res_x = x_res; + cam_desired.res_y = y_res; + _set_res(); + } +} + +bool Camera::get_frame(float dt, cv::Mat* frame) +{ + bool new_frame = _get_frame(frame); + // measure fps of valid frames + const float dt_smoothing_const = 0.9; + dt_valid += dt; + if (new_frame) + { + dt_mean = dt_smoothing_const * dt_mean + (1.0 - dt_smoothing_const) * dt_valid; + cam_info.fps = 1.0 / dt_mean; + dt_valid = 0; + } + return new_frame; +} + +// ---------------------------------------------------------------------------- +void CVCamera::start() +{ + cap = new VideoCapture(desired_index); +// extract camera info + active = true; + active_index = desired_index; + cam_info.res_x = cap->get(CV_CAP_PROP_FRAME_WIDTH); + cam_info.res_y = cap->get(CV_CAP_PROP_FRAME_HEIGHT); +} + +void CVCamera::stop() +{ + if (cap) { + cap->release(); + delete cap; + cap = NULL; + } + active = false; +} + +bool CVCamera::_get_frame(Mat* frame) +{ + bool ret = cap->read(*frame); + //if (ret) + // flip(tmp, *frame, 0); + return ret; +} + +void CVCamera::_set_index() +{ + if (active) restart(); +} + +void CVCamera::_set_f() +{ + cam_info.f = cam_desired.f; +} + +void CVCamera::_set_fps() +{ + if (cap) cap->set(CV_CAP_PROP_FPS, cam_desired.fps); +} + +void CVCamera::_set_res() +{ + if (cap) + { + cap->set(CV_CAP_PROP_FRAME_WIDTH, cam_desired.res_x); + cap->set(CV_CAP_PROP_FRAME_HEIGHT, cam_desired.res_y); + cam_info.res_x = cap->get(CV_CAP_PROP_FRAME_WIDTH); + cam_info.res_y = cap->get(CV_CAP_PROP_FRAME_HEIGHT); + } +} + +#if 0 +// ---------------------------------------------------------------------------- +VICamera::VICamera() : frame_buffer(NULL) +{ + VI.listDevices(); +} + +void VICamera::start() +{ + if (desired_index >= 0) + { + + + if (cam_desired.res_x == 0 || cam_desired.res_y == 0) + VI.setupDevice(desired_index); + else + VI.setupDevice(desired_index, cam_desired.res_x, cam_desired.res_y); + + active = true; + active_index = desired_index; + + cam_info.res_x = VI.getWidth(active_index); + cam_info.res_y = VI.getHeight(active_index); + new_frame = cv::Mat(cam_info.res_y, cam_info.res_x, CV_8UC3); + // If matrix is not continuous we have to copy manually via frame_buffer + if (!new_frame.isContinuous()) { + unsigned int size = VI.getSize(active_index); + frame_buffer = new unsigned char[size]; + } + } +} + +void VICamera::stop() +{ + if (active) + { + VI.stopDevice(active_index); + } + if (frame_buffer) + { + delete[] frame_buffer; + frame_buffer = NULL; + } + active = false; +} + +bool VICamera::_get_frame(Mat* frame) +{ + if (active && VI.isFrameNew(active_index)) + { + if (new_frame.isContinuous()) + { + VI.getPixels(active_index, new_frame.data, false, true); + } + else + { + // If matrix is not continuous we have to copy manually via frame_buffer + VI.getPixels(active_index, frame_buffer, false, true); + new_frame = cv::Mat(cam_info.res_y, cam_info.res_x, CV_8UC3, frame_buffer).clone(); + } + *frame = new_frame; + return true; + } + return false; +} + +void VICamera::_set_index() +{ + if (active) restart(); +} + +void VICamera::_set_f() +{ + cam_info.f = cam_desired.f; +} + +void VICamera::_set_fps() +{ + bool was_active = active; + if (active) stop(); + VI.setIdealFramerate(desired_index, cam_desired.fps); + if (was_active) start(); +} + +void VICamera::_set_res() +{ + if (active) restart(); +} +#endif diff --git a/ftnoir_tracker_pt/camera.h b/ftnoir_tracker_pt/camera.h index 6fec12da..5f1f56b0 100644 --- a/ftnoir_tracker_pt/camera.h +++ b/ftnoir_tracker_pt/camera.h @@ -1,119 +1,119 @@ -/* Copyright (c) 2012 Patrick Ruoff - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - */ - -#ifndef CAMERA_H -#define CAMERA_H - -#include -#include -//#include "videoInput/videoInput.h" - -// ---------------------------------------------------------------------------- -struct CamInfo -{ - CamInfo() : res_x(0), res_y(0), fps(0), f(1) {} - - int res_x; - int res_y; - int fps; - float f; // (focal length) / (sensor width) -}; - -// ---------------------------------------------------------------------------- -// base class for cameras -class Camera -{ -public: - Camera() : desired_index(0), active_index(-1), active(false), dt_valid(0), dt_mean(0) {} - virtual ~Camera() {} - - // start/stop capturing - virtual void start() = 0; - virtual void stop() = 0; - void restart() { stop(); start(); } - - void set_index(int index); - void set_f(float f); - void set_fps(int fps); - void set_res(int x_res, int y_res); - - // gets a frame from the camera, dt: time since last call in seconds - bool get_frame(float dt, cv::Mat* frame); - - // WARNING: returned references are valid as long as object - const CamInfo& get_info() const { return cam_info; } - const CamInfo& get_desired() const { return cam_desired; } - -protected: - // get a frame from the camera - virtual bool _get_frame(cv::Mat* frame) = 0; - - // update the camera - virtual void _set_index() = 0; - virtual void _set_f() = 0; - virtual void _set_fps() = 0; - virtual void _set_res() = 0; - - int desired_index; - int active_index; - bool active; - float dt_valid; - float dt_mean; - CamInfo cam_info; - CamInfo cam_desired; -}; - - -// ---------------------------------------------------------------------------- -// OpenCV camera - -class CVCamera : public Camera -{ -public: - CVCamera() : cap(NULL) {} - ~CVCamera() { stop(); } - - void start(); - void stop(); - -protected: - bool _get_frame(cv::Mat* frame); - void _set_index(); - void _set_f(); - void _set_fps(); - void _set_res(); - - cv::VideoCapture* cap; -}; - - -// ---------------------------------------------------------------------------- -// videoInput camera -#if 0 -class VICamera : public Camera -{ -public: - VICamera(); - ~VICamera() { stop(); } - - void start(); - void stop(); - -protected: - bool _get_frame(cv::Mat* frame); - void _set_index(); - void _set_f(); - void _set_fps(); - void _set_res(); - - videoInput VI; - cv::Mat new_frame; - unsigned char* frame_buffer; -}; -#endif - -#endif //CAMERA_H +/* Copyright (c) 2012 Patrick Ruoff + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + */ + +#ifndef CAMERA_H +#define CAMERA_H + +#include +#include +//#include "videoInput/videoInput.h" + +// ---------------------------------------------------------------------------- +struct CamInfo +{ + CamInfo() : res_x(0), res_y(0), fps(0), f(1) {} + + int res_x; + int res_y; + int fps; + float f; // (focal length) / (sensor width) +}; + +// ---------------------------------------------------------------------------- +// base class for cameras +class Camera +{ +public: + Camera() : desired_index(0), active_index(-1), active(false), dt_valid(0), dt_mean(0) {} + virtual ~Camera() {} + + // start/stop capturing + virtual void start() = 0; + virtual void stop() = 0; + void restart() { stop(); start(); } + + void set_index(int index); + void set_f(float f); + void set_fps(int fps); + void set_res(int x_res, int y_res); + + // gets a frame from the camera, dt: time since last call in seconds + bool get_frame(float dt, cv::Mat* frame); + + // WARNING: returned references are valid as long as object + const CamInfo& get_info() const { return cam_info; } + const CamInfo& get_desired() const { return cam_desired; } + +protected: + // get a frame from the camera + virtual bool _get_frame(cv::Mat* frame) = 0; + + // update the camera + virtual void _set_index() = 0; + virtual void _set_f() = 0; + virtual void _set_fps() = 0; + virtual void _set_res() = 0; + + int desired_index; + int active_index; + bool active; + float dt_valid; + float dt_mean; + CamInfo cam_info; + CamInfo cam_desired; +}; + + +// ---------------------------------------------------------------------------- +// OpenCV camera + +class CVCamera : public Camera +{ +public: + CVCamera() : cap(NULL) {} + ~CVCamera() { stop(); } + + void start(); + void stop(); + +protected: + bool _get_frame(cv::Mat* frame); + void _set_index(); + void _set_f(); + void _set_fps(); + void _set_res(); + + cv::VideoCapture* cap; +}; + + +// ---------------------------------------------------------------------------- +// videoInput camera +#if 0 +class VICamera : public Camera +{ +public: + VICamera(); + ~VICamera() { stop(); } + + void start(); + void stop(); + +protected: + bool _get_frame(cv::Mat* frame); + void _set_index(); + void _set_f(); + void _set_fps(); + void _set_res(); + + videoInput VI; + cv::Mat new_frame; + unsigned char* frame_buffer; +}; +#endif + +#endif //CAMERA_H diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp b/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp index 99b2f680..48702d19 100644 --- a/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp +++ b/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp @@ -1,261 +1,261 @@ -/* Copyright (c) 2012 Patrick Ruoff - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - */ - -#include "ftnoir_tracker_pt.h" -#include -#include -#include -#include -#include -#include "facetracknoir/global-settings.h" - -using namespace std; -using namespace cv; - -//#define PT_PERF_LOG //log performance - -//----------------------------------------------------------------------------- -Tracker::Tracker() - : tracking_valid(false), frame_count(0), commands(0), video_widget(NULL), fresh(false) -{ - should_quit = false; - qDebug()<<"Tracker::Tracker"; - TrackerSettings settings; - settings.load_ini(); - apply(settings); -} - -Tracker::~Tracker() -{ - qDebug()<<"Tracker::~Tracker"; - set_command(ABORT); - wait(); - if (video_widget) delete video_widget; -} - -void Tracker::set_command(Command command) -{ - //QMutexLocker lock(&mutex); - commands |= command; -} - -void Tracker::reset_command(Command command) -{ - //QMutexLocker lock(&mutex); - commands &= ~command; -} - -void Tracker::run() -{ - qDebug()<<"Tracker:: Thread started"; - -#ifdef PT_PERF_LOG - QFile log_file(QCoreApplication::applicationDirPath() + "/PointTrackerPerformance.txt"); - if (!log_file.open(QIODevice::WriteOnly | QIODevice::Text)) return; - QTextStream log_stream(&log_file); -#endif - - time.start(); - float dt; - bool new_frame; - forever - { - { - QMutexLocker lock(&mutex); - if (should_quit) - break; - - if (commands & ABORT) break; - if (commands & PAUSE) continue; - commands = 0; - - dt = time.elapsed() / 1000.0; - time.restart(); - - new_frame = camera.get_frame(dt, &frame); - if (new_frame && !frame.empty()) - { - const std::vector& points = point_extractor.extract_points(frame, dt, draw_frame); - tracking_valid = point_tracker.track(points, camera.get_info().f, dt); - frame_count++; - fresh = true; - } -#ifdef PT_PERF_LOG - log_stream<<"dt: "<(new PointModel(settings.M01, settings.M02)); - point_tracker.dynamic_pose_resolution = settings.dyn_pose_res; - sleep_time = settings.sleep_time; - point_tracker.dt_reset = settings.reset_time / 1000.0; - draw_frame = settings.video_widget; - cam_pitch = settings.cam_pitch; - - bEnableRoll = settings.bEnableRoll; - bEnablePitch = settings.bEnablePitch; - bEnableYaw = settings.bEnableYaw; - bEnableX = settings.bEnableX; - bEnableY = settings.bEnableY; - bEnableZ = settings.bEnableZ; - - t_MH = settings.t_MH; - qDebug()<<"Tracker::apply ends"; -} - -void Tracker::reset() -{ - QMutexLocker lock(&mutex); - point_tracker.reset(); -} - -void Tracker::center() -{ - point_tracker.reset(); // we also do a reset here since there is no reset shortkey yet - QMutexLocker lock(&mutex); - FrameTrafo X_CM_0 = point_tracker.get_pose(); - FrameTrafo X_MH(Matx33f::eye(), t_MH); - X_CH_0 = X_CM_0 * X_MH; -} - -void Tracker::refreshVideo() -{ - if (video_widget && fresh) - { - Mat frame_copy; - std::auto_ptr< vector > points; - { - //QMutexLocker lock(&mutex); - if (!draw_frame || frame.empty()) return; - - // copy the frame and points from the tracker thread - frame_copy = frame.clone(); - points = std::auto_ptr< vector >(new vector(point_extractor.get_points())); - } - //QMutexLocker lck(&mutex); - video_widget->update_image(frame_copy, points); - } -} - -void Tracker::StartTracker(QFrame* videoframe) -{ - const int VIDEO_FRAME_WIDTH = videoframe->width(); - const int VIDEO_FRAME_HEIGHT = videoframe->height(); - TrackerSettings settings; - settings.load_ini(); - apply(settings); - qDebug("Tracker::Initialize"); - // setup video frame - video_widget = new VideoWidget(videoframe); - QHBoxLayout* layout = new QHBoxLayout(); - layout->setContentsMargins(0, 0, 0, 0); - layout->addWidget(video_widget); - if (videoframe->layout()) delete videoframe->layout(); - videoframe->setLayout(layout); - video_widget->resize(VIDEO_FRAME_WIDTH, VIDEO_FRAME_HEIGHT); - videoframe->show(); - connect(&timer, SIGNAL(timeout()), this, SLOT(paint_widget())); - timer.start(40); - camera.start(); - start(); - reset_command(PAUSE); -} - -void Tracker::paint_widget() { - if (fresh) { - fresh = false; - video_widget->update(); - } -} - -bool Tracker::GiveHeadPoseData(double *data) -{ - const double rad2deg = 180.0/3.14159265; - const double deg2rad = 1.0/rad2deg; - { - QMutexLocker lock(&mutex); - - if (!tracking_valid) return false; - - FrameTrafo X_CM = point_tracker.get_pose(); - FrameTrafo X_MH(Matx33f::eye(), t_MH); - FrameTrafo X_CH = X_CM * X_MH; - - Matx33f R = X_CH.R * X_CH_0.R.t(); - Vec3f t = X_CH.t - X_CH_0.t; - - // correct for camera pitch - Matx33f R_CP( 1, 0, 0, - 0, cos(deg2rad*cam_pitch), sin(deg2rad*cam_pitch), - 0, -sin(deg2rad*cam_pitch), cos(deg2rad*cam_pitch)); - R = R_CP * R * R_CP.t(); - t = R_CP * t; - - // get translation(s) - if (bEnableX) { - data[TX] = t[0] / 10.0; // convert to cm - } - if (bEnableY) { - data[TY] = t[1] / 10.0; - } - if (bEnableZ) { - data[TZ] = t[2] / 10.0; - } - - // translate rotation matrix from opengl (G) to roll-pitch-yaw (R) frame - // -z -> x, y -> z, x -> -y - Matx33f R_RG( 0, 0,-1, - -1, 0, 0, - 0, 1, 0); - R = R_RG * R * R_RG.t(); - - // extract rotation angles - double alpha, beta, gamma; - //beta = atan2( -R(2,0), sqrt(R(0,0)*R(0,0) + R(1,0)*R(1,0)) ); - beta = atan2( -R(2,0), sqrt(R(2,1)*R(2,1) + R(2,2)*R(2,2)) ); - alpha = atan2( R(1,0), R(0,0)); - gamma = atan2( R(2,1), R(2,2)); - - if (bEnableYaw) { - data[Yaw] = rad2deg * alpha; - } - if (bEnablePitch) { - data[Pitch] = rad2deg * beta; - } - if (bEnableRoll) { - data[Roll] = rad2deg * gamma; - } - } - return true; -} - -//----------------------------------------------------------------------------- -//#pragma comment(linker, "/export:GetTracker=_GetTracker@0") - -extern "C" FTNOIR_TRACKER_BASE_EXPORT ITracker* CALLING_CONVENTION GetConstructor() -{ - return new Tracker; -} +/* Copyright (c) 2012 Patrick Ruoff + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + */ + +#include "ftnoir_tracker_pt.h" +#include +#include +#include +#include +#include +#include "facetracknoir/global-settings.h" + +using namespace std; +using namespace cv; + +//#define PT_PERF_LOG //log performance + +//----------------------------------------------------------------------------- +Tracker::Tracker() + : tracking_valid(false), frame_count(0), commands(0), video_widget(NULL), fresh(false) +{ + should_quit = false; + qDebug()<<"Tracker::Tracker"; + TrackerSettings settings; + settings.load_ini(); + apply(settings); +} + +Tracker::~Tracker() +{ + qDebug()<<"Tracker::~Tracker"; + set_command(ABORT); + wait(); + if (video_widget) delete video_widget; +} + +void Tracker::set_command(Command command) +{ + //QMutexLocker lock(&mutex); + commands |= command; +} + +void Tracker::reset_command(Command command) +{ + //QMutexLocker lock(&mutex); + commands &= ~command; +} + +void Tracker::run() +{ + qDebug()<<"Tracker:: Thread started"; + +#ifdef PT_PERF_LOG + QFile log_file(QCoreApplication::applicationDirPath() + "/PointTrackerPerformance.txt"); + if (!log_file.open(QIODevice::WriteOnly | QIODevice::Text)) return; + QTextStream log_stream(&log_file); +#endif + + time.start(); + float dt; + bool new_frame; + forever + { + { + QMutexLocker lock(&mutex); + if (should_quit) + break; + + if (commands & ABORT) break; + if (commands & PAUSE) continue; + commands = 0; + + dt = time.elapsed() / 1000.0; + time.restart(); + + new_frame = camera.get_frame(dt, &frame); + if (new_frame && !frame.empty()) + { + const std::vector& points = point_extractor.extract_points(frame, dt, draw_frame); + tracking_valid = point_tracker.track(points, camera.get_info().f, dt); + frame_count++; + fresh = true; + } +#ifdef PT_PERF_LOG + log_stream<<"dt: "<(new PointModel(settings.M01, settings.M02)); + point_tracker.dynamic_pose_resolution = settings.dyn_pose_res; + sleep_time = settings.sleep_time; + point_tracker.dt_reset = settings.reset_time / 1000.0; + draw_frame = settings.video_widget; + cam_pitch = settings.cam_pitch; + + bEnableRoll = settings.bEnableRoll; + bEnablePitch = settings.bEnablePitch; + bEnableYaw = settings.bEnableYaw; + bEnableX = settings.bEnableX; + bEnableY = settings.bEnableY; + bEnableZ = settings.bEnableZ; + + t_MH = settings.t_MH; + qDebug()<<"Tracker::apply ends"; +} + +void Tracker::reset() +{ + QMutexLocker lock(&mutex); + point_tracker.reset(); +} + +void Tracker::center() +{ + point_tracker.reset(); // we also do a reset here since there is no reset shortkey yet + QMutexLocker lock(&mutex); + FrameTrafo X_CM_0 = point_tracker.get_pose(); + FrameTrafo X_MH(Matx33f::eye(), t_MH); + X_CH_0 = X_CM_0 * X_MH; +} + +void Tracker::refreshVideo() +{ + if (video_widget && fresh) + { + Mat frame_copy; + std::auto_ptr< vector > points; + { + //QMutexLocker lock(&mutex); + if (!draw_frame || frame.empty()) return; + + // copy the frame and points from the tracker thread + frame_copy = frame.clone(); + points = std::auto_ptr< vector >(new vector(point_extractor.get_points())); + } + //QMutexLocker lck(&mutex); + video_widget->update_image(frame_copy, points); + } +} + +void Tracker::StartTracker(QFrame* videoframe) +{ + const int VIDEO_FRAME_WIDTH = videoframe->width(); + const int VIDEO_FRAME_HEIGHT = videoframe->height(); + TrackerSettings settings; + settings.load_ini(); + apply(settings); + qDebug("Tracker::Initialize"); + // setup video frame + video_widget = new VideoWidget(videoframe); + QHBoxLayout* layout = new QHBoxLayout(); + layout->setContentsMargins(0, 0, 0, 0); + layout->addWidget(video_widget); + if (videoframe->layout()) delete videoframe->layout(); + videoframe->setLayout(layout); + video_widget->resize(VIDEO_FRAME_WIDTH, VIDEO_FRAME_HEIGHT); + videoframe->show(); + connect(&timer, SIGNAL(timeout()), this, SLOT(paint_widget())); + timer.start(40); + camera.start(); + start(); + reset_command(PAUSE); +} + +void Tracker::paint_widget() { + if (fresh) { + fresh = false; + video_widget->update(); + } +} + +bool Tracker::GiveHeadPoseData(double *data) +{ + const double rad2deg = 180.0/3.14159265; + const double deg2rad = 1.0/rad2deg; + { + QMutexLocker lock(&mutex); + + if (!tracking_valid) return false; + + FrameTrafo X_CM = point_tracker.get_pose(); + FrameTrafo X_MH(Matx33f::eye(), t_MH); + FrameTrafo X_CH = X_CM * X_MH; + + Matx33f R = X_CH.R * X_CH_0.R.t(); + Vec3f t = X_CH.t - X_CH_0.t; + + // correct for camera pitch + Matx33f R_CP( 1, 0, 0, + 0, cos(deg2rad*cam_pitch), sin(deg2rad*cam_pitch), + 0, -sin(deg2rad*cam_pitch), cos(deg2rad*cam_pitch)); + R = R_CP * R * R_CP.t(); + t = R_CP * t; + + // get translation(s) + if (bEnableX) { + data[TX] = t[0] / 10.0; // convert to cm + } + if (bEnableY) { + data[TY] = t[1] / 10.0; + } + if (bEnableZ) { + data[TZ] = t[2] / 10.0; + } + + // translate rotation matrix from opengl (G) to roll-pitch-yaw (R) frame + // -z -> x, y -> z, x -> -y + Matx33f R_RG( 0, 0,-1, + -1, 0, 0, + 0, 1, 0); + R = R_RG * R * R_RG.t(); + + // extract rotation angles + double alpha, beta, gamma; + //beta = atan2( -R(2,0), sqrt(R(0,0)*R(0,0) + R(1,0)*R(1,0)) ); + beta = atan2( -R(2,0), sqrt(R(2,1)*R(2,1) + R(2,2)*R(2,2)) ); + alpha = atan2( R(1,0), R(0,0)); + gamma = atan2( R(2,1), R(2,2)); + + if (bEnableYaw) { + data[Yaw] = rad2deg * alpha; + } + if (bEnablePitch) { + data[Pitch] = rad2deg * beta; + } + if (bEnableRoll) { + data[Roll] = rad2deg * gamma; + } + } + return true; +} + +//----------------------------------------------------------------------------- +//#pragma comment(linker, "/export:GetTracker=_GetTracker@0") + +extern "C" FTNOIR_TRACKER_BASE_EXPORT ITracker* CALLING_CONVENTION GetConstructor() +{ + return new Tracker; +} diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt.h b/ftnoir_tracker_pt/ftnoir_tracker_pt.h index 0c45c6b6..3825fce7 100644 --- a/ftnoir_tracker_pt/ftnoir_tracker_pt.h +++ b/ftnoir_tracker_pt/ftnoir_tracker_pt.h @@ -1,96 +1,96 @@ -/* Copyright (c) 2012 Patrick Ruoff - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - */ - -#ifndef FTNOIR_TRACKER_PT_H -#define FTNOIR_TRACKER_PT_H - -#include "ftnoir_tracker_base/ftnoir_tracker_base.h" -#include "ftnoir_tracker_pt_settings.h" -#include "camera.h" -#include "point_extractor.h" -#include "point_tracker.h" -#include "video_widget.h" -#include "timer.h" - -#include -#include -#include -#include -#include -#include - -//----------------------------------------------------------------------------- -class Tracker : public QThread, public ITracker -{ - Q_OBJECT -public: - Tracker(); - ~Tracker(); - - // ITracker interface - void StartTracker(QFrame* videoFrame); - bool GiveHeadPoseData(double *data); - - void refreshVideo(); - - void apply(const TrackerSettings& settings); - void center(); - void reset(); // reset the trackers internal state variables - void run(); - void WaitForExit() { - should_quit = true; - wait(); - } - - void get_pose(FrameTrafo* X_CM) { QMutexLocker lock(&mutex); *X_CM = point_tracker.get_pose(); } - int get_n_points() { QMutexLocker lock(&mutex); return point_extractor.get_points().size(); } - void get_cam_info(CamInfo* info) { QMutexLocker lock(&mutex); *info = camera.get_info(); } - -protected: - FrameTrafo X_CH_0; // for centering - cv::Mat frame; // the output frame for display - - enum Command { - ABORT = 1<<0, - PAUSE = 1<<1 - }; - void set_command(Command command); - void reset_command(Command command); - - CVCamera camera; - PointExtractor point_extractor; - PointTracker point_tracker; - bool tracking_valid; - - cv::Vec3f t_MH; - int cam_pitch; - - bool draw_frame; - int sleep_time; - - bool bEnableRoll; - bool bEnablePitch; - bool bEnableYaw; - bool bEnableX; - bool bEnableY; - bool bEnableZ; - - long frame_count; - volatile int commands; - - VideoWidget* video_widget; - Timer time; - QMutex mutex; - volatile bool should_quit; - volatile bool fresh; - QTimer timer; - -protected slots: - void paint_widget(); -}; - -#endif // FTNOIR_TRACKER_PT_H +/* Copyright (c) 2012 Patrick Ruoff + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + */ + +#ifndef FTNOIR_TRACKER_PT_H +#define FTNOIR_TRACKER_PT_H + +#include "ftnoir_tracker_base/ftnoir_tracker_base.h" +#include "ftnoir_tracker_pt_settings.h" +#include "camera.h" +#include "point_extractor.h" +#include "point_tracker.h" +#include "video_widget.h" +#include "timer.h" + +#include +#include +#include +#include +#include +#include + +//----------------------------------------------------------------------------- +class Tracker : public QThread, public ITracker +{ + Q_OBJECT +public: + Tracker(); + ~Tracker(); + + // ITracker interface + void StartTracker(QFrame* videoFrame); + bool GiveHeadPoseData(double *data); + + void refreshVideo(); + + void apply(const TrackerSettings& settings); + void center(); + void reset(); // reset the trackers internal state variables + void run(); + void WaitForExit() { + should_quit = true; + wait(); + } + + void get_pose(FrameTrafo* X_CM) { QMutexLocker lock(&mutex); *X_CM = point_tracker.get_pose(); } + int get_n_points() { QMutexLocker lock(&mutex); return point_extractor.get_points().size(); } + void get_cam_info(CamInfo* info) { QMutexLocker lock(&mutex); *info = camera.get_info(); } + +protected: + FrameTrafo X_CH_0; // for centering + cv::Mat frame; // the output frame for display + + enum Command { + ABORT = 1<<0, + PAUSE = 1<<1 + }; + void set_command(Command command); + void reset_command(Command command); + + CVCamera camera; + PointExtractor point_extractor; + PointTracker point_tracker; + bool tracking_valid; + + cv::Vec3f t_MH; + int cam_pitch; + + bool draw_frame; + int sleep_time; + + bool bEnableRoll; + bool bEnablePitch; + bool bEnableYaw; + bool bEnableX; + bool bEnableY; + bool bEnableZ; + + long frame_count; + volatile int commands; + + VideoWidget* video_widget; + Timer time; + QMutex mutex; + volatile bool should_quit; + volatile bool fresh; + QTimer timer; + +protected slots: + void paint_widget(); +}; + +#endif // FTNOIR_TRACKER_PT_H diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.cpp b/ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.cpp index 4837f4a9..f222085e 100644 --- a/ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.cpp +++ b/ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.cpp @@ -1,337 +1,337 @@ -/* Copyright (c) 2012 Patrick Ruoff - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - */ - -#include "ftnoir_tracker_pt_dialog.h" - -#include -#include -#include "facetracknoir/global-settings.h" - -//----------------------------------------------------------------------------- -TrackerDialog::TrackerDialog() - : settings_dirty(false), tracker(NULL), trans_calib_running(false), timer(this) -{ - qDebug()<<"TrackerDialog::TrackerDialog"; - setAttribute(Qt::WA_DeleteOnClose, false); - - ui.setupUi( this ); - - settings.load_ini(); - dialog_settings.load_ini(); - - // initialize ui values - ui.videowidget_check->setChecked(settings.video_widget); - ui.dynpose_check->setChecked(settings.dyn_pose_res); - ui.sleep_spin->setValue(settings.sleep_time); - ui.reset_spin->setValue(settings.reset_time); - ui.camindex_spin->setValue(settings.cam_index); - ui.f_dspin->setValue(settings.cam_f); - ui.res_x_spin->setValue(settings.cam_res_x); - ui.res_y_spin->setValue(settings.cam_res_y); - ui.fps_spin->setValue(settings.cam_fps); - ui.campitch_spin->setValue(settings.cam_pitch); - ui.threshold_slider->setValue(settings.threshold); - - ui.chkEnableRoll->setChecked(settings.bEnableRoll); - ui.chkEnablePitch->setChecked(settings.bEnablePitch); - ui.chkEnableYaw->setChecked(settings.bEnableYaw); - ui.chkEnableX->setChecked(settings.bEnableX); - ui.chkEnableY->setChecked(settings.bEnableY); - ui.chkEnableZ->setChecked(settings.bEnableZ); - - ui.mindiam_spin->setValue(settings.min_point_size); - ui.maxdiam_spin->setValue(settings.max_point_size); - ui.model_tabs->setCurrentIndex(dialog_settings.active_model_panel); - ui.clip_bheight_spin->setValue(dialog_settings.clip_by); - ui.clip_blength_spin->setValue(dialog_settings.clip_bz); - ui.clip_theight_spin->setValue(dialog_settings.clip_ty); - ui.clip_tlength_spin->setValue(dialog_settings.clip_tz); - ui.cap_width_spin->setValue(dialog_settings.cap_x); - ui.cap_height_spin->setValue(dialog_settings.cap_y); - ui.cap_length_spin->setValue(dialog_settings.cap_z); - ui.m1x_spin->setValue(dialog_settings.M01x); - ui.m1y_spin->setValue(dialog_settings.M01y); - ui.m1z_spin->setValue(dialog_settings.M01z); - ui.m2x_spin->setValue(dialog_settings.M02x); - ui.m2y_spin->setValue(dialog_settings.M02y); - ui.m2z_spin->setValue(dialog_settings.M02z); - ui.tx_spin->setValue(settings.t_MH[0]); - ui.ty_spin->setValue(settings.t_MH[1]); - ui.tz_spin->setValue(settings.t_MH[2]); - - // connect Qt signals and slots - connect( ui.videowidget_check,SIGNAL(toggled(bool)), this,SLOT(set_video_widget(bool)) ); - connect( ui.dynpose_check,SIGNAL(toggled(bool)), this,SLOT(set_dyn_pose_res(bool)) ); - connect( ui.sleep_spin,SIGNAL(valueChanged(int)), this,SLOT(set_sleep_time(int)) ); - connect( ui.reset_spin,SIGNAL(valueChanged(int)), this,SLOT(set_reset_time(int)) ); - connect( ui.camindex_spin,SIGNAL(valueChanged(int)), this,SLOT(set_cam_index(int)) ); - connect( ui.f_dspin,SIGNAL(valueChanged(double)), this,SLOT(set_cam_f(double)) ); - connect( ui.res_x_spin,SIGNAL(valueChanged(int)), this,SLOT(set_cam_res_x(int)) ); - connect( ui.res_y_spin,SIGNAL(valueChanged(int)), this,SLOT(set_cam_res_y(int)) ); - connect( ui.fps_spin,SIGNAL(valueChanged(int)), this,SLOT(set_cam_fps(int)) ); - connect( ui.campitch_spin,SIGNAL(valueChanged(int)), this,SLOT(set_cam_pitch(int)) ); - connect( ui.threshold_slider,SIGNAL(sliderMoved(int)), this,SLOT(set_threshold(int)) ); - - connect( ui.chkEnableRoll,SIGNAL(toggled(bool)), this,SLOT(set_ena_roll(bool)) ); - connect( ui.chkEnablePitch,SIGNAL(toggled(bool)), this,SLOT(set_ena_pitch(bool)) ); - connect( ui.chkEnableYaw,SIGNAL(toggled(bool)), this,SLOT(set_ena_yaw(bool)) ); - connect( ui.chkEnableX,SIGNAL(toggled(bool)), this,SLOT(set_ena_x(bool)) ); - connect( ui.chkEnableY,SIGNAL(toggled(bool)), this,SLOT(set_ena_y(bool)) ); - connect( ui.chkEnableZ,SIGNAL(toggled(bool)), this,SLOT(set_ena_z(bool)) ); - - connect( ui.mindiam_spin,SIGNAL(valueChanged(int)), this,SLOT(set_min_point_size(int)) ); - connect( ui.maxdiam_spin,SIGNAL(valueChanged(int)), this,SLOT(set_max_point_size(int)) ); - connect( ui.model_tabs,SIGNAL(currentChanged(int)), this,SLOT(set_model(int)) ); - connect( ui.clip_theight_spin,SIGNAL(valueChanged(int)), this,SLOT(set_clip_t_height(int)) ); - connect( ui.clip_tlength_spin,SIGNAL(valueChanged(int)), this,SLOT(set_clip_t_length(int)) ); - connect( ui.clip_bheight_spin,SIGNAL(valueChanged(int)), this,SLOT(set_clip_b_height(int)) ); - connect( ui.clip_blength_spin,SIGNAL(valueChanged(int)), this,SLOT(set_clip_b_length(int)) ); - connect( ui.cap_width_spin,SIGNAL(valueChanged(int)), this,SLOT(set_cap_width(int)) ); - connect( ui.cap_height_spin,SIGNAL(valueChanged(int)), this,SLOT(set_cap_height(int)) ); - connect( ui.cap_length_spin,SIGNAL(valueChanged(int)), this,SLOT(set_cap_length(int)) ); - connect( ui.m1x_spin,SIGNAL(valueChanged(int)), this,SLOT(set_m1x(int)) ); - connect( ui.m1y_spin,SIGNAL(valueChanged(int)), this,SLOT(set_m1y(int)) ); - connect( ui.m1z_spin,SIGNAL(valueChanged(int)), this,SLOT(set_m1z(int)) ); - connect( ui.m2x_spin,SIGNAL(valueChanged(int)), this,SLOT(set_m2x(int)) ); - connect( ui.m2y_spin,SIGNAL(valueChanged(int)), this,SLOT(set_m2y(int)) ); - connect( ui.m2z_spin,SIGNAL(valueChanged(int)), this,SLOT(set_m2z(int)) ); - connect( ui.tx_spin,SIGNAL(valueChanged(int)), this,SLOT(set_tx(int)) ); - connect( ui.ty_spin,SIGNAL(valueChanged(int)), this,SLOT(set_ty(int)) ); - connect( ui.tz_spin,SIGNAL(valueChanged(int)), this,SLOT(set_tz(int)) ); - - connect( ui.tcalib_button,SIGNAL(toggled(bool)), this,SLOT(startstop_trans_calib(bool)) ); - - connect(ui.reset_button, SIGNAL(clicked()), this, SLOT(doReset())); - //connect(ui.center_button, SIGNAL(clicked()), this, SLOT(doCenter())); - - connect(ui.ok_button, SIGNAL(clicked()), this, SLOT(doOK())); - connect(ui.cancel_button, SIGNAL(clicked()), this, SLOT(doCancel())); - - connect(&timer,SIGNAL(timeout()), this,SLOT(poll_tracker_info())); - timer.start(100); -} - -TrackerDialog::~TrackerDialog() -{ - qDebug()<<"TrackerDialog::~TrackerDialog"; -} - -void TrackerDialog::set_clip() -{ - settings.M01[0] = 0; - settings.M01[1] = dialog_settings.clip_ty; - settings.M01[2] = -dialog_settings.clip_tz; - settings.M02[0] = 0; - settings.M02[1] = -dialog_settings.clip_by; - settings.M02[2] = -dialog_settings.clip_bz; - - settings_changed(); -} - -void TrackerDialog::set_cap() -{ - settings.M01[0] = -dialog_settings.cap_x; - settings.M01[1] = -dialog_settings.cap_y; - settings.M01[2] = -dialog_settings.cap_z; - settings.M02[0] = dialog_settings.cap_x; - settings.M02[1] = -dialog_settings.cap_y; - settings.M02[2] = -dialog_settings.cap_z; - - settings_changed(); -} - -void TrackerDialog::set_custom() -{ - settings.M01[0] = dialog_settings.M01x; - settings.M01[1] = dialog_settings.M01y; - settings.M01[2] = dialog_settings.M01z; - settings.M02[0] = dialog_settings.M02x; - settings.M02[1] = dialog_settings.M02y; - settings.M02[2] = dialog_settings.M02z; - - settings_changed(); -} - -void TrackerDialog::set_model(int val) -{ - dialog_settings.active_model_panel = val; - - switch (val) { - - case TrackerDialogSettings::MODEL_CLIP: - set_clip(); - break; - - case TrackerDialogSettings::MODEL_CAP: - set_cap(); - break; - - case TrackerDialogSettings::MODEL_CUSTOM: - set_custom(); - break; - - default: - break; - } -} - -void TrackerDialog::startstop_trans_calib(bool start) -{ - if (start) - { - qDebug()<<"TrackerDialog:: Starting translation calibration"; - trans_calib.reset(); - trans_calib_running = true; - } - else - { - qDebug()<<"TrackerDialog:: Stoppping translation calibration"; - trans_calib_running = false; - settings.t_MH = trans_calib.get_estimate(); - settings_changed(); - } -} - -void TrackerDialog::trans_calib_step() -{ - if (tracker) - { - FrameTrafo X_CM; - tracker->get_pose(&X_CM); - trans_calib.update(X_CM.R, X_CM.t); - cv::Vec3f t_MH = trans_calib.get_estimate(); - //qDebug()<<"TrackerDialog:: Current translation estimate: "<setValue(t_MH[0]); - ui.ty_spin->setValue(t_MH[1]); - ui.tz_spin->setValue(t_MH[2]); - } -} - -void TrackerDialog::settings_changed() -{ - settings_dirty = true; - if (tracker) tracker->apply(settings); -} - -void TrackerDialog::doCenter() -{ - if (tracker) tracker->center(); -} - -void TrackerDialog::doReset() -{ - if (tracker) tracker->reset(); -} - -void TrackerDialog::doOK() -{ - settings.save_ini(); - dialog_settings.save_ini(); - close(); -} - -void TrackerDialog::doCancel() -{ - if (settings_dirty) { - int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", - QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard ); - switch (ret) { - case QMessageBox::Save: - settings.save_ini(); - dialog_settings.save_ini(); - close(); - break; - case QMessageBox::Discard: - close(); - break; - case QMessageBox::Cancel: - // Cancel was clicked - break; - default: - // should never be reached - break; - } - } - else { - close(); - } -} - -void TrackerDialog::poll_tracker_info() -{ - if (tracker) - { - QString to_print; - - // display caminfo - CamInfo info; - tracker->get_cam_info(&info); - to_print = QString::number(info.res_x)+"x"+QString::number(info.res_y)+" @ "+QString::number(info.fps)+" FPS"; - ui.caminfo_label->setText(to_print); - ui.caminfo_label_2->setText(to_print); - - // display pointinfo - int n_points = tracker->get_n_points(); - to_print = QString::number(n_points); - if (n_points == 3) - to_print += " OK!"; - else - to_print += " BAD!"; - ui.pointinfo_label->setText(to_print); - ui.pointinfo_label_2->setText(to_print); - - // update calibration - if (trans_calib_running) trans_calib_step(); - } - else - { - QString to_print = "Tracker offline"; - ui.caminfo_label->setText(to_print); - ui.caminfo_label_2->setText(to_print); - ui.pointinfo_label->setText(to_print); - ui.pointinfo_label_2->setText(to_print); - } -} - - -//----------------------------------------------------------------------------- -// ITrackerDialog interface -void TrackerDialog::Initialize(QWidget *parent) -{ - QPoint offsetpos(200, 200); - if (parent) { - this->move(parent->pos() + offsetpos); - } - show(); -} - -void TrackerDialog::registerTracker(ITracker *t) -{ - qDebug()<<"TrackerDialog:: Tracker registered"; - tracker = static_cast(t); - if (isVisible() && settings_dirty) tracker->apply(settings); - ui.tcalib_button->setEnabled(true); - //ui.center_button->setEnabled(true); - ui.reset_button->setEnabled(true); -} - -void TrackerDialog::unRegisterTracker() -{ - qDebug()<<"TrackerDialog:: Tracker un-registered"; - tracker = NULL; - ui.tcalib_button->setEnabled(false); - //ui.center_button->setEnabled(false); - ui.reset_button->setEnabled(false); -} - -//----------------------------------------------------------------------------- -//#pragma comment(linker, "/export:GetTrackerDialog=_GetTrackerDialog@0") - -extern "C" FTNOIR_TRACKER_BASE_EXPORT ITrackerDialog* CALLING_CONVENTION GetDialog( ) -{ - return new TrackerDialog; -} +/* Copyright (c) 2012 Patrick Ruoff + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + */ + +#include "ftnoir_tracker_pt_dialog.h" + +#include +#include +#include "facetracknoir/global-settings.h" + +//----------------------------------------------------------------------------- +TrackerDialog::TrackerDialog() + : settings_dirty(false), tracker(NULL), trans_calib_running(false), timer(this) +{ + qDebug()<<"TrackerDialog::TrackerDialog"; + setAttribute(Qt::WA_DeleteOnClose, false); + + ui.setupUi( this ); + + settings.load_ini(); + dialog_settings.load_ini(); + + // initialize ui values + ui.videowidget_check->setChecked(settings.video_widget); + ui.dynpose_check->setChecked(settings.dyn_pose_res); + ui.sleep_spin->setValue(settings.sleep_time); + ui.reset_spin->setValue(settings.reset_time); + ui.camindex_spin->setValue(settings.cam_index); + ui.f_dspin->setValue(settings.cam_f); + ui.res_x_spin->setValue(settings.cam_res_x); + ui.res_y_spin->setValue(settings.cam_res_y); + ui.fps_spin->setValue(settings.cam_fps); + ui.campitch_spin->setValue(settings.cam_pitch); + ui.threshold_slider->setValue(settings.threshold); + + ui.chkEnableRoll->setChecked(settings.bEnableRoll); + ui.chkEnablePitch->setChecked(settings.bEnablePitch); + ui.chkEnableYaw->setChecked(settings.bEnableYaw); + ui.chkEnableX->setChecked(settings.bEnableX); + ui.chkEnableY->setChecked(settings.bEnableY); + ui.chkEnableZ->setChecked(settings.bEnableZ); + + ui.mindiam_spin->setValue(settings.min_point_size); + ui.maxdiam_spin->setValue(settings.max_point_size); + ui.model_tabs->setCurrentIndex(dialog_settings.active_model_panel); + ui.clip_bheight_spin->setValue(dialog_settings.clip_by); + ui.clip_blength_spin->setValue(dialog_settings.clip_bz); + ui.clip_theight_spin->setValue(dialog_settings.clip_ty); + ui.clip_tlength_spin->setValue(dialog_settings.clip_tz); + ui.cap_width_spin->setValue(dialog_settings.cap_x); + ui.cap_height_spin->setValue(dialog_settings.cap_y); + ui.cap_length_spin->setValue(dialog_settings.cap_z); + ui.m1x_spin->setValue(dialog_settings.M01x); + ui.m1y_spin->setValue(dialog_settings.M01y); + ui.m1z_spin->setValue(dialog_settings.M01z); + ui.m2x_spin->setValue(dialog_settings.M02x); + ui.m2y_spin->setValue(dialog_settings.M02y); + ui.m2z_spin->setValue(dialog_settings.M02z); + ui.tx_spin->setValue(settings.t_MH[0]); + ui.ty_spin->setValue(settings.t_MH[1]); + ui.tz_spin->setValue(settings.t_MH[2]); + + // connect Qt signals and slots + connect( ui.videowidget_check,SIGNAL(toggled(bool)), this,SLOT(set_video_widget(bool)) ); + connect( ui.dynpose_check,SIGNAL(toggled(bool)), this,SLOT(set_dyn_pose_res(bool)) ); + connect( ui.sleep_spin,SIGNAL(valueChanged(int)), this,SLOT(set_sleep_time(int)) ); + connect( ui.reset_spin,SIGNAL(valueChanged(int)), this,SLOT(set_reset_time(int)) ); + connect( ui.camindex_spin,SIGNAL(valueChanged(int)), this,SLOT(set_cam_index(int)) ); + connect( ui.f_dspin,SIGNAL(valueChanged(double)), this,SLOT(set_cam_f(double)) ); + connect( ui.res_x_spin,SIGNAL(valueChanged(int)), this,SLOT(set_cam_res_x(int)) ); + connect( ui.res_y_spin,SIGNAL(valueChanged(int)), this,SLOT(set_cam_res_y(int)) ); + connect( ui.fps_spin,SIGNAL(valueChanged(int)), this,SLOT(set_cam_fps(int)) ); + connect( ui.campitch_spin,SIGNAL(valueChanged(int)), this,SLOT(set_cam_pitch(int)) ); + connect( ui.threshold_slider,SIGNAL(sliderMoved(int)), this,SLOT(set_threshold(int)) ); + + connect( ui.chkEnableRoll,SIGNAL(toggled(bool)), this,SLOT(set_ena_roll(bool)) ); + connect( ui.chkEnablePitch,SIGNAL(toggled(bool)), this,SLOT(set_ena_pitch(bool)) ); + connect( ui.chkEnableYaw,SIGNAL(toggled(bool)), this,SLOT(set_ena_yaw(bool)) ); + connect( ui.chkEnableX,SIGNAL(toggled(bool)), this,SLOT(set_ena_x(bool)) ); + connect( ui.chkEnableY,SIGNAL(toggled(bool)), this,SLOT(set_ena_y(bool)) ); + connect( ui.chkEnableZ,SIGNAL(toggled(bool)), this,SLOT(set_ena_z(bool)) ); + + connect( ui.mindiam_spin,SIGNAL(valueChanged(int)), this,SLOT(set_min_point_size(int)) ); + connect( ui.maxdiam_spin,SIGNAL(valueChanged(int)), this,SLOT(set_max_point_size(int)) ); + connect( ui.model_tabs,SIGNAL(currentChanged(int)), this,SLOT(set_model(int)) ); + connect( ui.clip_theight_spin,SIGNAL(valueChanged(int)), this,SLOT(set_clip_t_height(int)) ); + connect( ui.clip_tlength_spin,SIGNAL(valueChanged(int)), this,SLOT(set_clip_t_length(int)) ); + connect( ui.clip_bheight_spin,SIGNAL(valueChanged(int)), this,SLOT(set_clip_b_height(int)) ); + connect( ui.clip_blength_spin,SIGNAL(valueChanged(int)), this,SLOT(set_clip_b_length(int)) ); + connect( ui.cap_width_spin,SIGNAL(valueChanged(int)), this,SLOT(set_cap_width(int)) ); + connect( ui.cap_height_spin,SIGNAL(valueChanged(int)), this,SLOT(set_cap_height(int)) ); + connect( ui.cap_length_spin,SIGNAL(valueChanged(int)), this,SLOT(set_cap_length(int)) ); + connect( ui.m1x_spin,SIGNAL(valueChanged(int)), this,SLOT(set_m1x(int)) ); + connect( ui.m1y_spin,SIGNAL(valueChanged(int)), this,SLOT(set_m1y(int)) ); + connect( ui.m1z_spin,SIGNAL(valueChanged(int)), this,SLOT(set_m1z(int)) ); + connect( ui.m2x_spin,SIGNAL(valueChanged(int)), this,SLOT(set_m2x(int)) ); + connect( ui.m2y_spin,SIGNAL(valueChanged(int)), this,SLOT(set_m2y(int)) ); + connect( ui.m2z_spin,SIGNAL(valueChanged(int)), this,SLOT(set_m2z(int)) ); + connect( ui.tx_spin,SIGNAL(valueChanged(int)), this,SLOT(set_tx(int)) ); + connect( ui.ty_spin,SIGNAL(valueChanged(int)), this,SLOT(set_ty(int)) ); + connect( ui.tz_spin,SIGNAL(valueChanged(int)), this,SLOT(set_tz(int)) ); + + connect( ui.tcalib_button,SIGNAL(toggled(bool)), this,SLOT(startstop_trans_calib(bool)) ); + + connect(ui.reset_button, SIGNAL(clicked()), this, SLOT(doReset())); + //connect(ui.center_button, SIGNAL(clicked()), this, SLOT(doCenter())); + + connect(ui.ok_button, SIGNAL(clicked()), this, SLOT(doOK())); + connect(ui.cancel_button, SIGNAL(clicked()), this, SLOT(doCancel())); + + connect(&timer,SIGNAL(timeout()), this,SLOT(poll_tracker_info())); + timer.start(100); +} + +TrackerDialog::~TrackerDialog() +{ + qDebug()<<"TrackerDialog::~TrackerDialog"; +} + +void TrackerDialog::set_clip() +{ + settings.M01[0] = 0; + settings.M01[1] = dialog_settings.clip_ty; + settings.M01[2] = -dialog_settings.clip_tz; + settings.M02[0] = 0; + settings.M02[1] = -dialog_settings.clip_by; + settings.M02[2] = -dialog_settings.clip_bz; + + settings_changed(); +} + +void TrackerDialog::set_cap() +{ + settings.M01[0] = -dialog_settings.cap_x; + settings.M01[1] = -dialog_settings.cap_y; + settings.M01[2] = -dialog_settings.cap_z; + settings.M02[0] = dialog_settings.cap_x; + settings.M02[1] = -dialog_settings.cap_y; + settings.M02[2] = -dialog_settings.cap_z; + + settings_changed(); +} + +void TrackerDialog::set_custom() +{ + settings.M01[0] = dialog_settings.M01x; + settings.M01[1] = dialog_settings.M01y; + settings.M01[2] = dialog_settings.M01z; + settings.M02[0] = dialog_settings.M02x; + settings.M02[1] = dialog_settings.M02y; + settings.M02[2] = dialog_settings.M02z; + + settings_changed(); +} + +void TrackerDialog::set_model(int val) +{ + dialog_settings.active_model_panel = val; + + switch (val) { + + case TrackerDialogSettings::MODEL_CLIP: + set_clip(); + break; + + case TrackerDialogSettings::MODEL_CAP: + set_cap(); + break; + + case TrackerDialogSettings::MODEL_CUSTOM: + set_custom(); + break; + + default: + break; + } +} + +void TrackerDialog::startstop_trans_calib(bool start) +{ + if (start) + { + qDebug()<<"TrackerDialog:: Starting translation calibration"; + trans_calib.reset(); + trans_calib_running = true; + } + else + { + qDebug()<<"TrackerDialog:: Stoppping translation calibration"; + trans_calib_running = false; + settings.t_MH = trans_calib.get_estimate(); + settings_changed(); + } +} + +void TrackerDialog::trans_calib_step() +{ + if (tracker) + { + FrameTrafo X_CM; + tracker->get_pose(&X_CM); + trans_calib.update(X_CM.R, X_CM.t); + cv::Vec3f t_MH = trans_calib.get_estimate(); + //qDebug()<<"TrackerDialog:: Current translation estimate: "<setValue(t_MH[0]); + ui.ty_spin->setValue(t_MH[1]); + ui.tz_spin->setValue(t_MH[2]); + } +} + +void TrackerDialog::settings_changed() +{ + settings_dirty = true; + if (tracker) tracker->apply(settings); +} + +void TrackerDialog::doCenter() +{ + if (tracker) tracker->center(); +} + +void TrackerDialog::doReset() +{ + if (tracker) tracker->reset(); +} + +void TrackerDialog::doOK() +{ + settings.save_ini(); + dialog_settings.save_ini(); + close(); +} + +void TrackerDialog::doCancel() +{ + if (settings_dirty) { + int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", + QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard ); + switch (ret) { + case QMessageBox::Save: + settings.save_ini(); + dialog_settings.save_ini(); + close(); + break; + case QMessageBox::Discard: + close(); + break; + case QMessageBox::Cancel: + // Cancel was clicked + break; + default: + // should never be reached + break; + } + } + else { + close(); + } +} + +void TrackerDialog::poll_tracker_info() +{ + if (tracker) + { + QString to_print; + + // display caminfo + CamInfo info; + tracker->get_cam_info(&info); + to_print = QString::number(info.res_x)+"x"+QString::number(info.res_y)+" @ "+QString::number(info.fps)+" FPS"; + ui.caminfo_label->setText(to_print); + ui.caminfo_label_2->setText(to_print); + + // display pointinfo + int n_points = tracker->get_n_points(); + to_print = QString::number(n_points); + if (n_points == 3) + to_print += " OK!"; + else + to_print += " BAD!"; + ui.pointinfo_label->setText(to_print); + ui.pointinfo_label_2->setText(to_print); + + // update calibration + if (trans_calib_running) trans_calib_step(); + } + else + { + QString to_print = "Tracker offline"; + ui.caminfo_label->setText(to_print); + ui.caminfo_label_2->setText(to_print); + ui.pointinfo_label->setText(to_print); + ui.pointinfo_label_2->setText(to_print); + } +} + + +//----------------------------------------------------------------------------- +// ITrackerDialog interface +void TrackerDialog::Initialize(QWidget *parent) +{ + QPoint offsetpos(200, 200); + if (parent) { + this->move(parent->pos() + offsetpos); + } + show(); +} + +void TrackerDialog::registerTracker(ITracker *t) +{ + qDebug()<<"TrackerDialog:: Tracker registered"; + tracker = static_cast(t); + if (isVisible() && settings_dirty) tracker->apply(settings); + ui.tcalib_button->setEnabled(true); + //ui.center_button->setEnabled(true); + ui.reset_button->setEnabled(true); +} + +void TrackerDialog::unRegisterTracker() +{ + qDebug()<<"TrackerDialog:: Tracker un-registered"; + tracker = NULL; + ui.tcalib_button->setEnabled(false); + //ui.center_button->setEnabled(false); + ui.reset_button->setEnabled(false); +} + +//----------------------------------------------------------------------------- +//#pragma comment(linker, "/export:GetTrackerDialog=_GetTrackerDialog@0") + +extern "C" FTNOIR_TRACKER_BASE_EXPORT ITrackerDialog* CALLING_CONVENTION GetDialog( ) +{ + return new TrackerDialog; +} diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.h b/ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.h index ada331e5..f13fe13e 100644 --- a/ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.h +++ b/ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.h @@ -1,102 +1,102 @@ -/* Copyright (c) 2012 Patrick Ruoff - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - */ - -#ifndef FTNOIR_TRACKER_PT_DIALOG_H -#define FTNOIR_TRACKER_PT_DIALOG_H - -#include "ftnoir_tracker_base/ftnoir_tracker_base.h" -#include "ftnoir_tracker_pt_settings.h" -#include "ftnoir_tracker_pt.h" -#include "ui_ftnoir_pt_controls.h" -#include "trans_calib.h" - -#include - -//----------------------------------------------------------------------------- -class TrackerDialog : public QWidget, public ITrackerDialog -{ - Q_OBJECT -public: - TrackerDialog(); - ~TrackerDialog(); - - // ITrackerDialog interface - void Initialize(QWidget *parent); - void registerTracker(ITracker *tracker); - void unRegisterTracker(); - - void trans_calib_step(); - -protected slots: - // ugly qt stuff - void set_video_widget(bool val) { settings.video_widget = val; settings_changed(); } - void set_dyn_pose_res(bool val) { settings.dyn_pose_res = val; settings_changed(); } - void set_sleep_time(int val) { settings.sleep_time = val; settings_changed(); } - void set_reset_time(int val) { settings.reset_time = val; settings_changed(); } - void set_cam_index(int val) { settings.cam_index = val; settings_changed(); } - void set_cam_f(double val) { settings.cam_f = val; settings_changed(); } - void set_cam_res_x(int val) { settings.cam_res_x = val; settings_changed(); } - void set_cam_res_y(int val) { settings.cam_res_y = val; settings_changed(); } - void set_cam_fps(int val) { settings.cam_fps = val; settings_changed(); } - void set_cam_pitch(int val) { settings.cam_pitch = val; settings_changed(); } - void set_min_point_size(int val) { settings.min_point_size = val; settings_changed(); } - void set_max_point_size(int val) { settings.max_point_size = val; settings_changed(); } - void set_threshold(int val) { settings.threshold = val; settings_changed(); } - void set_ena_roll(bool val) { settings.bEnableRoll = val; settings_changed(); } - void set_ena_pitch(bool val) { settings.bEnablePitch = val; settings_changed(); } - void set_ena_yaw(bool val) { settings.bEnableYaw = val; settings_changed(); } - void set_ena_x(bool val) { settings.bEnableX = val; settings_changed(); } - void set_ena_y(bool val) { settings.bEnableY = val; settings_changed(); } - void set_ena_z(bool val) { settings.bEnableZ = val; settings_changed(); } - - void set_clip_t_height(int val) { dialog_settings.clip_ty = val; set_clip(); } - void set_clip_t_length(int val) { dialog_settings.clip_tz = val; set_clip(); } - void set_clip_b_height(int val) { dialog_settings.clip_by = val; set_clip(); } - void set_clip_b_length(int val) { dialog_settings.clip_bz = val; set_clip(); } - void set_cap_width(int val) { dialog_settings.cap_x = val; set_cap(); } - void set_cap_height(int val) { dialog_settings.cap_y = val; set_cap(); } - void set_cap_length(int val) { dialog_settings.cap_z = val; set_cap(); } - void set_m1x(int val) { dialog_settings.M01x = val; set_custom(); } - void set_m1y(int val) { dialog_settings.M01y = val; set_custom(); } - void set_m1z(int val) { dialog_settings.M01z = val; set_custom(); } - void set_m2x(int val) { dialog_settings.M02x = val; set_custom(); } - void set_m2y(int val) { dialog_settings.M02y = val; set_custom(); } - void set_m2z(int val) { dialog_settings.M02z = val; set_custom(); } - void set_tx(int val) { settings.t_MH[0] = val; settings_changed(); } - void set_ty(int val) { settings.t_MH[1] = val; settings_changed(); } - void set_tz(int val) { settings.t_MH[2] = val; settings_changed(); } - void set_model(int model_id); - - void doCenter(); - void doReset(); - - void doOK(); - void doCancel(); - - void startstop_trans_calib(bool start); - - void poll_tracker_info(); - -protected: - void set_clip(); - void set_cap(); - void set_custom(); - - void settings_changed(); - - TrackerSettings settings; - TrackerDialogSettings dialog_settings; - bool settings_dirty; - - Tracker* tracker; - TranslationCalibrator trans_calib; - bool trans_calib_running; - QTimer timer; - Ui::UICPTClientControls ui; -}; - -#endif //FTNOIR_TRACKER_PT_DIALOG_H +/* Copyright (c) 2012 Patrick Ruoff + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + */ + +#ifndef FTNOIR_TRACKER_PT_DIALOG_H +#define FTNOIR_TRACKER_PT_DIALOG_H + +#include "ftnoir_tracker_base/ftnoir_tracker_base.h" +#include "ftnoir_tracker_pt_settings.h" +#include "ftnoir_tracker_pt.h" +#include "ui_ftnoir_pt_controls.h" +#include "trans_calib.h" + +#include + +//----------------------------------------------------------------------------- +class TrackerDialog : public QWidget, public ITrackerDialog +{ + Q_OBJECT +public: + TrackerDialog(); + ~TrackerDialog(); + + // ITrackerDialog interface + void Initialize(QWidget *parent); + void registerTracker(ITracker *tracker); + void unRegisterTracker(); + + void trans_calib_step(); + +protected slots: + // ugly qt stuff + void set_video_widget(bool val) { settings.video_widget = val; settings_changed(); } + void set_dyn_pose_res(bool val) { settings.dyn_pose_res = val; settings_changed(); } + void set_sleep_time(int val) { settings.sleep_time = val; settings_changed(); } + void set_reset_time(int val) { settings.reset_time = val; settings_changed(); } + void set_cam_index(int val) { settings.cam_index = val; settings_changed(); } + void set_cam_f(double val) { settings.cam_f = val; settings_changed(); } + void set_cam_res_x(int val) { settings.cam_res_x = val; settings_changed(); } + void set_cam_res_y(int val) { settings.cam_res_y = val; settings_changed(); } + void set_cam_fps(int val) { settings.cam_fps = val; settings_changed(); } + void set_cam_pitch(int val) { settings.cam_pitch = val; settings_changed(); } + void set_min_point_size(int val) { settings.min_point_size = val; settings_changed(); } + void set_max_point_size(int val) { settings.max_point_size = val; settings_changed(); } + void set_threshold(int val) { settings.threshold = val; settings_changed(); } + void set_ena_roll(bool val) { settings.bEnableRoll = val; settings_changed(); } + void set_ena_pitch(bool val) { settings.bEnablePitch = val; settings_changed(); } + void set_ena_yaw(bool val) { settings.bEnableYaw = val; settings_changed(); } + void set_ena_x(bool val) { settings.bEnableX = val; settings_changed(); } + void set_ena_y(bool val) { settings.bEnableY = val; settings_changed(); } + void set_ena_z(bool val) { settings.bEnableZ = val; settings_changed(); } + + void set_clip_t_height(int val) { dialog_settings.clip_ty = val; set_clip(); } + void set_clip_t_length(int val) { dialog_settings.clip_tz = val; set_clip(); } + void set_clip_b_height(int val) { dialog_settings.clip_by = val; set_clip(); } + void set_clip_b_length(int val) { dialog_settings.clip_bz = val; set_clip(); } + void set_cap_width(int val) { dialog_settings.cap_x = val; set_cap(); } + void set_cap_height(int val) { dialog_settings.cap_y = val; set_cap(); } + void set_cap_length(int val) { dialog_settings.cap_z = val; set_cap(); } + void set_m1x(int val) { dialog_settings.M01x = val; set_custom(); } + void set_m1y(int val) { dialog_settings.M01y = val; set_custom(); } + void set_m1z(int val) { dialog_settings.M01z = val; set_custom(); } + void set_m2x(int val) { dialog_settings.M02x = val; set_custom(); } + void set_m2y(int val) { dialog_settings.M02y = val; set_custom(); } + void set_m2z(int val) { dialog_settings.M02z = val; set_custom(); } + void set_tx(int val) { settings.t_MH[0] = val; settings_changed(); } + void set_ty(int val) { settings.t_MH[1] = val; settings_changed(); } + void set_tz(int val) { settings.t_MH[2] = val; settings_changed(); } + void set_model(int model_id); + + void doCenter(); + void doReset(); + + void doOK(); + void doCancel(); + + void startstop_trans_calib(bool start); + + void poll_tracker_info(); + +protected: + void set_clip(); + void set_cap(); + void set_custom(); + + void settings_changed(); + + TrackerSettings settings; + TrackerDialogSettings dialog_settings; + bool settings_dirty; + + Tracker* tracker; + TranslationCalibrator trans_calib; + bool trans_calib_running; + QTimer timer; + Ui::UICPTClientControls ui; +}; + +#endif //FTNOIR_TRACKER_PT_DIALOG_H diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt_dll.cpp b/ftnoir_tracker_pt/ftnoir_tracker_pt_dll.cpp index 22c4a33d..1c486382 100644 --- a/ftnoir_tracker_pt/ftnoir_tracker_pt_dll.cpp +++ b/ftnoir_tracker_pt/ftnoir_tracker_pt_dll.cpp @@ -1,40 +1,40 @@ -/* Copyright (c) 2012 Patrick Ruoff - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - */ - -#include "ftnoir_tracker_pt_dll.h" -#include -#include "facetracknoir/global-settings.h" - -//----------------------------------------------------------------------------- -void TrackerDll::getFullName(QString *strToBeFilled) -{ - *strToBeFilled = "PointTracker 1.0"; -} - -void TrackerDll::getShortName(QString *strToBeFilled) -{ - *strToBeFilled = "PointTracker"; -} - -void TrackerDll::getDescription(QString *strToBeFilled) -{ - *strToBeFilled = "Tracks a 3-point model with know geometry like Freetrack / TrackIR"; -} - -void TrackerDll::getIcon(QIcon *icon) -{ - *icon = QIcon(":/resources/icon.png"); -} - - -//----------------------------------------------------------------------------- -//#pragma comment(linker, "/export:GetTrackerDll=_GetTrackerDll@0") - -extern "C" FTNOIR_TRACKER_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata() -{ - return new TrackerDll; -} +/* Copyright (c) 2012 Patrick Ruoff + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + */ + +#include "ftnoir_tracker_pt_dll.h" +#include +#include "facetracknoir/global-settings.h" + +//----------------------------------------------------------------------------- +void TrackerDll::getFullName(QString *strToBeFilled) +{ + *strToBeFilled = "PointTracker 1.0"; +} + +void TrackerDll::getShortName(QString *strToBeFilled) +{ + *strToBeFilled = "PointTracker"; +} + +void TrackerDll::getDescription(QString *strToBeFilled) +{ + *strToBeFilled = "Tracks a 3-point model with know geometry like Freetrack / TrackIR"; +} + +void TrackerDll::getIcon(QIcon *icon) +{ + *icon = QIcon(":/resources/icon.png"); +} + + +//----------------------------------------------------------------------------- +//#pragma comment(linker, "/export:GetTrackerDll=_GetTrackerDll@0") + +extern "C" FTNOIR_TRACKER_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata() +{ + return new TrackerDll; +} diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt_dll.h b/ftnoir_tracker_pt/ftnoir_tracker_pt_dll.h index dde0bc9f..4dc94173 100644 --- a/ftnoir_tracker_pt/ftnoir_tracker_pt_dll.h +++ b/ftnoir_tracker_pt/ftnoir_tracker_pt_dll.h @@ -1,18 +1,18 @@ -/* Copyright (c) 2012 Patrick Ruoff - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - */ - -#include "ftnoir_tracker_base/ftnoir_tracker_base.h" -#include "facetracknoir/global-settings.h" - -//----------------------------------------------------------------------------- -class TrackerDll : public Metadata -{ - void getFullName(QString *strToBeFilled); - void getShortName(QString *strToBeFilled); - void getDescription(QString *strToBeFilled); - void getIcon(QIcon *icon); -}; +/* Copyright (c) 2012 Patrick Ruoff + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + */ + +#include "ftnoir_tracker_base/ftnoir_tracker_base.h" +#include "facetracknoir/global-settings.h" + +//----------------------------------------------------------------------------- +class TrackerDll : public Metadata +{ + void getFullName(QString *strToBeFilled); + void getShortName(QString *strToBeFilled); + void getDescription(QString *strToBeFilled); + void getIcon(QIcon *icon); +}; diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt_settings.cpp b/ftnoir_tracker_pt/ftnoir_tracker_pt_settings.cpp index 3164b291..b0249813 100644 --- a/ftnoir_tracker_pt/ftnoir_tracker_pt_settings.cpp +++ b/ftnoir_tracker_pt/ftnoir_tracker_pt_settings.cpp @@ -1,150 +1,150 @@ -/* Copyright (c) 2012 Patrick Ruoff - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - */ - -#include "ftnoir_tracker_pt.h" -#include -#include - -//----------------------------------------------------------------------------- -void TrackerSettings::load_ini() -{ - qDebug("TrackerSettings::load_ini()"); - - QSettings settings("opentrack"); // 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) - - iniFile.beginGroup( "PointTracker" ); - - cam_index = iniFile.value("CameraId", 0).toInt(); - cam_f = iniFile.value("CameraF", 1).toFloat(); - cam_res_x = iniFile.value("CameraResX", 640).toInt(); - cam_res_y = iniFile.value("CameraResY", 480).toInt(); - cam_fps = iniFile.value("CameraFPS", 30).toInt(); - cam_pitch = iniFile.value("CameraPitch", 0).toInt(); - threshold = iniFile.value("PointExtractThreshold", 128).toInt(); - min_point_size = iniFile.value("PointExtractMinSize", 2).toInt(); - max_point_size = iniFile.value("PointExtractMaxSize", 50).toInt(); - M01[0] = iniFile.value("PointModelM01x", 0).toFloat(); - M01[1] = iniFile.value("PointModelM01y", 40).toFloat(); - M01[2] = iniFile.value("PointModelM01z", -30).toFloat(); - M02[0] = iniFile.value("PointModelM02x", 0).toFloat(); - M02[1] = iniFile.value("PointModelM02y", -70).toFloat(); - M02[2] = iniFile.value("PointModelM02z", -80).toFloat(); - t_MH[0] = iniFile.value("tMHx", 0).toFloat(); - t_MH[1] = iniFile.value("tMHy", 0).toFloat(); - t_MH[2] = iniFile.value("tMHz", 0).toFloat(); - dyn_pose_res = iniFile.value("DynamicPoseResolution", true).toBool(); - video_widget = iniFile.value("VideoWidget", true).toBool(); - sleep_time = iniFile.value("SleepTime", 10).toInt(); - reset_time = iniFile.value("ResetTime", 1000).toInt(); - - 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(); -} - -void TrackerSettings::save_ini() const -{ - qDebug("TrackerSettings::save_ini()"); - - QSettings settings("opentrack"); // 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) - - iniFile.beginGroup ( "PointTracker" ); - - iniFile.setValue("CameraId", cam_index); - iniFile.setValue("CameraF", cam_f); - iniFile.setValue("CameraResX", cam_res_x); - iniFile.setValue("CameraResY", cam_res_y); - iniFile.setValue("CameraFPS", cam_fps); - iniFile.setValue("CameraPitch", cam_pitch); - iniFile.setValue("PointExtractThreshold", threshold); - iniFile.setValue("PointExtractMinSize", min_point_size); - iniFile.setValue("PointExtractMaxSize", max_point_size); - iniFile.setValue("PointModelM01x", M01[0]); - iniFile.setValue("PointModelM01y", M01[1]); - iniFile.setValue("PointModelM01z", M01[2]); - iniFile.setValue("PointModelM02x", M02[0]); - iniFile.setValue("PointModelM02y", M02[1]); - iniFile.setValue("PointModelM02z", M02[2]); - iniFile.setValue("tMHx", t_MH[0]); - iniFile.setValue("tMHy", t_MH[1]); - iniFile.setValue("tMHz", t_MH[2]); - iniFile.setValue("DynamicPoseResolution", dyn_pose_res); - iniFile.setValue("VideoWidget", video_widget); - iniFile.setValue("SleepTime", sleep_time); - iniFile.setValue("ResetTime", reset_time); - - iniFile.setValue( "EnableRoll", bEnableRoll ); - iniFile.setValue( "EnablePitch", bEnablePitch ); - iniFile.setValue( "EnableYaw", bEnableYaw ); - iniFile.setValue( "EnableX", bEnableX ); - iniFile.setValue( "EnableY", bEnableY ); - iniFile.setValue( "EnableZ", bEnableZ ); - - iniFile.endGroup(); -} - -//----------------------------------------------------------------------------- -void TrackerDialogSettings::load_ini() -{ - qDebug("TrackerDialogSettings::load_ini()"); - - QSettings settings("opentrack"); // 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) - - iniFile.beginGroup( "PointTrackerDialog" ); - - active_model_panel = iniFile.value("ActiveModelPanel", MODEL_CLIP).toInt(); - M01x = iniFile.value("CustomM01x", 0).toInt(); - M01y = iniFile.value("CustomM01y", 40).toInt(); - M01z = iniFile.value("CustomM01z", -30).toInt(); - M02x = iniFile.value("CustomM02x", 0).toInt(); - M02y = iniFile.value("CustomM02y", -70).toInt(); - M02z = iniFile.value("CustomM02z", -80).toInt(); - clip_ty = iniFile.value("ClipTopHeight", 40).toInt(); - clip_tz = iniFile.value("ClipTopLength", 30).toInt(); - clip_by = iniFile.value("ClipBottomHeight", 70).toInt(); - clip_bz = iniFile.value("ClipBottomLength", 80).toInt(); - cap_x = iniFile.value("CapHalfWidth", 40).toInt(); - cap_y = iniFile.value("CapHeight", 60).toInt(); - cap_z = iniFile.value("CapLength", 100).toInt(); -} - -void TrackerDialogSettings::save_ini() const -{ - qDebug("TrackerDialogSettings::save_ini()"); - - QSettings settings("opentrack"); // 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) - - iniFile.beginGroup ( "PointTrackerDialog" ); - - iniFile.setValue("ActiveModelPanel", active_model_panel); - iniFile.setValue("CustomM01x", M01x); - iniFile.setValue("CustomM01y", M01y); - iniFile.setValue("CustomM01z", M01z); - iniFile.setValue("CustomM02x", M02x); - iniFile.setValue("CustomM02y", M02y); - iniFile.setValue("CustomM02z", M02z); - iniFile.setValue("ClipTopHeight", clip_ty); - iniFile.setValue("ClipTopLength", clip_tz); - iniFile.setValue("ClipBottomHeight", clip_by); - iniFile.setValue("ClipBottomLength", clip_bz); - iniFile.setValue("CapHalfWidth", cap_x); - iniFile.setValue("CapHeight", cap_y); - iniFile.setValue("CapLength", cap_z); +/* Copyright (c) 2012 Patrick Ruoff + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + */ + +#include "ftnoir_tracker_pt.h" +#include +#include + +//----------------------------------------------------------------------------- +void TrackerSettings::load_ini() +{ + qDebug("TrackerSettings::load_ini()"); + + QSettings settings("opentrack"); // 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) + + iniFile.beginGroup( "PointTracker" ); + + cam_index = iniFile.value("CameraId", 0).toInt(); + cam_f = iniFile.value("CameraF", 1).toFloat(); + cam_res_x = iniFile.value("CameraResX", 640).toInt(); + cam_res_y = iniFile.value("CameraResY", 480).toInt(); + cam_fps = iniFile.value("CameraFPS", 30).toInt(); + cam_pitch = iniFile.value("CameraPitch", 0).toInt(); + threshold = iniFile.value("PointExtractThreshold", 128).toInt(); + min_point_size = iniFile.value("PointExtractMinSize", 2).toInt(); + max_point_size = iniFile.value("PointExtractMaxSize", 50).toInt(); + M01[0] = iniFile.value("PointModelM01x", 0).toFloat(); + M01[1] = iniFile.value("PointModelM01y", 40).toFloat(); + M01[2] = iniFile.value("PointModelM01z", -30).toFloat(); + M02[0] = iniFile.value("PointModelM02x", 0).toFloat(); + M02[1] = iniFile.value("PointModelM02y", -70).toFloat(); + M02[2] = iniFile.value("PointModelM02z", -80).toFloat(); + t_MH[0] = iniFile.value("tMHx", 0).toFloat(); + t_MH[1] = iniFile.value("tMHy", 0).toFloat(); + t_MH[2] = iniFile.value("tMHz", 0).toFloat(); + dyn_pose_res = iniFile.value("DynamicPoseResolution", true).toBool(); + video_widget = iniFile.value("VideoWidget", true).toBool(); + sleep_time = iniFile.value("SleepTime", 10).toInt(); + reset_time = iniFile.value("ResetTime", 1000).toInt(); + + 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(); +} + +void TrackerSettings::save_ini() const +{ + qDebug("TrackerSettings::save_ini()"); + + QSettings settings("opentrack"); // 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) + + iniFile.beginGroup ( "PointTracker" ); + + iniFile.setValue("CameraId", cam_index); + iniFile.setValue("CameraF", cam_f); + iniFile.setValue("CameraResX", cam_res_x); + iniFile.setValue("CameraResY", cam_res_y); + iniFile.setValue("CameraFPS", cam_fps); + iniFile.setValue("CameraPitch", cam_pitch); + iniFile.setValue("PointExtractThreshold", threshold); + iniFile.setValue("PointExtractMinSize", min_point_size); + iniFile.setValue("PointExtractMaxSize", max_point_size); + iniFile.setValue("PointModelM01x", M01[0]); + iniFile.setValue("PointModelM01y", M01[1]); + iniFile.setValue("PointModelM01z", M01[2]); + iniFile.setValue("PointModelM02x", M02[0]); + iniFile.setValue("PointModelM02y", M02[1]); + iniFile.setValue("PointModelM02z", M02[2]); + iniFile.setValue("tMHx", t_MH[0]); + iniFile.setValue("tMHy", t_MH[1]); + iniFile.setValue("tMHz", t_MH[2]); + iniFile.setValue("DynamicPoseResolution", dyn_pose_res); + iniFile.setValue("VideoWidget", video_widget); + iniFile.setValue("SleepTime", sleep_time); + iniFile.setValue("ResetTime", reset_time); + + iniFile.setValue( "EnableRoll", bEnableRoll ); + iniFile.setValue( "EnablePitch", bEnablePitch ); + iniFile.setValue( "EnableYaw", bEnableYaw ); + iniFile.setValue( "EnableX", bEnableX ); + iniFile.setValue( "EnableY", bEnableY ); + iniFile.setValue( "EnableZ", bEnableZ ); + + iniFile.endGroup(); +} + +//----------------------------------------------------------------------------- +void TrackerDialogSettings::load_ini() +{ + qDebug("TrackerDialogSettings::load_ini()"); + + QSettings settings("opentrack"); // 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) + + iniFile.beginGroup( "PointTrackerDialog" ); + + active_model_panel = iniFile.value("ActiveModelPanel", MODEL_CLIP).toInt(); + M01x = iniFile.value("CustomM01x", 0).toInt(); + M01y = iniFile.value("CustomM01y", 40).toInt(); + M01z = iniFile.value("CustomM01z", -30).toInt(); + M02x = iniFile.value("CustomM02x", 0).toInt(); + M02y = iniFile.value("CustomM02y", -70).toInt(); + M02z = iniFile.value("CustomM02z", -80).toInt(); + clip_ty = iniFile.value("ClipTopHeight", 40).toInt(); + clip_tz = iniFile.value("ClipTopLength", 30).toInt(); + clip_by = iniFile.value("ClipBottomHeight", 70).toInt(); + clip_bz = iniFile.value("ClipBottomLength", 80).toInt(); + cap_x = iniFile.value("CapHalfWidth", 40).toInt(); + cap_y = iniFile.value("CapHeight", 60).toInt(); + cap_z = iniFile.value("CapLength", 100).toInt(); +} + +void TrackerDialogSettings::save_ini() const +{ + qDebug("TrackerDialogSettings::save_ini()"); + + QSettings settings("opentrack"); // 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) + + iniFile.beginGroup ( "PointTrackerDialog" ); + + iniFile.setValue("ActiveModelPanel", active_model_panel); + iniFile.setValue("CustomM01x", M01x); + iniFile.setValue("CustomM01y", M01y); + iniFile.setValue("CustomM01z", M01z); + iniFile.setValue("CustomM02x", M02x); + iniFile.setValue("CustomM02y", M02y); + iniFile.setValue("CustomM02z", M02z); + iniFile.setValue("ClipTopHeight", clip_ty); + iniFile.setValue("ClipTopLength", clip_tz); + iniFile.setValue("ClipBottomHeight", clip_by); + iniFile.setValue("ClipBottomLength", clip_bz); + iniFile.setValue("CapHalfWidth", cap_x); + iniFile.setValue("CapHeight", cap_y); + iniFile.setValue("CapLength", cap_z); } \ No newline at end of file diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt_settings.h b/ftnoir_tracker_pt/ftnoir_tracker_pt_settings.h index 88162c86..a1523898 100644 --- a/ftnoir_tracker_pt/ftnoir_tracker_pt_settings.h +++ b/ftnoir_tracker_pt/ftnoir_tracker_pt_settings.h @@ -1,84 +1,84 @@ -/* Copyright (c) 2012 Patrick Ruoff - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - */ - -#ifndef FTNOIR_TRACKER_PT_SETTINGS_H -#define FTNOIR_TRACKER_PT_SETTINGS_H - -#include -#include "point_tracker.h" - - -//----------------------------------------------------------------------------- -struct TrackerSettings -{ - // camera - int cam_index; - float cam_f; - int cam_res_x; - int cam_res_y; - int cam_fps; - int cam_pitch; - - // point extraction - int threshold; - int min_point_size; - int max_point_size; - - // point tracking - cv::Vec3f M01; - cv::Vec3f M02; - bool dyn_pose_res; - - // head to model translation - cv::Vec3f t_MH; - - int sleep_time; // in ms - int reset_time; // in ms - bool video_widget; - - bool bEnableRoll; - bool bEnablePitch; - bool bEnableYaw; - bool bEnableX; - bool bEnableY; - bool bEnableZ; - - void load_ini(); - void save_ini() const; -}; - - -//----------------------------------------------------------------------------- -struct TrackerDialogSettings -{ - enum - { - MODEL_CLIP, - MODEL_CAP, - MODEL_CUSTOM - }; - int active_model_panel; - - int M01x; - int M01y; - int M01z; - int M02x; - int M02y; - int M02z; - int clip_ty; - int clip_tz; - int clip_by; - int clip_bz; - int cap_x; - int cap_y; - int cap_z; - - void load_ini(); - void save_ini() const; -}; - +/* Copyright (c) 2012 Patrick Ruoff + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + */ + +#ifndef FTNOIR_TRACKER_PT_SETTINGS_H +#define FTNOIR_TRACKER_PT_SETTINGS_H + +#include +#include "point_tracker.h" + + +//----------------------------------------------------------------------------- +struct TrackerSettings +{ + // camera + int cam_index; + float cam_f; + int cam_res_x; + int cam_res_y; + int cam_fps; + int cam_pitch; + + // point extraction + int threshold; + int min_point_size; + int max_point_size; + + // point tracking + cv::Vec3f M01; + cv::Vec3f M02; + bool dyn_pose_res; + + // head to model translation + cv::Vec3f t_MH; + + int sleep_time; // in ms + int reset_time; // in ms + bool video_widget; + + bool bEnableRoll; + bool bEnablePitch; + bool bEnableYaw; + bool bEnableX; + bool bEnableY; + bool bEnableZ; + + void load_ini(); + void save_ini() const; +}; + + +//----------------------------------------------------------------------------- +struct TrackerDialogSettings +{ + enum + { + MODEL_CLIP, + MODEL_CAP, + MODEL_CUSTOM + }; + int active_model_panel; + + int M01x; + int M01y; + int M01z; + int M02x; + int M02y; + int M02z; + int clip_ty; + int clip_tz; + int clip_by; + int clip_bz; + int cap_x; + int cap_y; + int cap_z; + + void load_ini(); + void save_ini() const; +}; + #endif //FTNOIR_TRACKER_PT_SETTINGS_H \ No newline at end of file diff --git a/ftnoir_tracker_pt/point_extractor.cpp b/ftnoir_tracker_pt/point_extractor.cpp index 61e86bec..09be967a 100644 --- a/ftnoir_tracker_pt/point_extractor.cpp +++ b/ftnoir_tracker_pt/point_extractor.cpp @@ -1,96 +1,96 @@ -/* Copyright (c) 2012 Patrick Ruoff - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - */ - -#include "point_extractor.h" -#include - -using namespace cv; -using namespace std; - -// ---------------------------------------------------------------------------- -const vector& PointExtractor::extract_points(Mat frame, float dt, bool draw_output) -{ - const int W = frame.cols; - const int H = frame.rows; - - // clear old points - points.clear(); - - // convert to grayscale - Mat frame_grey; - cvtColor(frame, frame_grey, COLOR_BGR2GRAY); - - // convert to binary - Mat frame_bin; - threshold(frame_grey, frame_bin, threshold_val, 255, THRESH_BINARY); - - unsigned int region_size_min = 3.14*min_size*min_size; - unsigned int region_size_max = 3.14*max_size*max_size; - - int blob_index = 1; - for (int y=0; y(y,x) != 255) continue; - Rect rect; - floodFill(frame_bin, Point(x,y), Scalar(blob_index), &rect, Scalar(0), Scalar(0), FLOODFILL_FIXED_RANGE); - blob_index++; - - // calculate the size of the connected component - unsigned int region_size = 0; - for (int i=rect.y; i < (rect.y+rect.height); i++) - { - for (int j=rect.x; j < (rect.x+rect.width); j++) - { - if (frame_bin.at(i,j) != blob_index-1) continue; - region_size++; - } - } - - if (region_size < region_size_min || region_size > region_size_max) continue; - - // calculate the center of mass: - // mx = (sum_ij j*f(frame_grey_ij)) / (sum_ij f(frame_grey_ij)) - // my = ... - // f maps from [threshold,256] -> [0, 1], lower values are mapped to 0 - float m = 0; - float mx = 0; - float my = 0; - for (int i=rect.y; i < (rect.y+rect.height); i++) - { - for (int j=rect.x; j < (rect.x+rect.width); j++) - { - if (frame_bin.at(i,j) != blob_index-1) continue; - float val = frame_grey.at(i,j); - val = float(val - threshold_val)/(256 - threshold_val); - val = val*val; // makes it more stable (less emphasis on low values, more on the peak) - m += val; - mx += j * val; - my += i * val; - } - } - - // convert to centered camera coordinate system with y axis upwards - Vec2f c; - c[0] = (mx/m - W/2)/W; - c[1] = -(my/m - H/2)/W; - points.push_back(c); - - if (blob_index >= 255) break; - } - if (blob_index >= 255) break; - } - - // draw output image - if (draw_output) { - frame.setTo(Scalar(255,0,0), frame_bin); - } - - return points; -} +/* Copyright (c) 2012 Patrick Ruoff + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + */ + +#include "point_extractor.h" +#include + +using namespace cv; +using namespace std; + +// ---------------------------------------------------------------------------- +const vector& PointExtractor::extract_points(Mat frame, float dt, bool draw_output) +{ + const int W = frame.cols; + const int H = frame.rows; + + // clear old points + points.clear(); + + // convert to grayscale + Mat frame_grey; + cvtColor(frame, frame_grey, COLOR_BGR2GRAY); + + // convert to binary + Mat frame_bin; + threshold(frame_grey, frame_bin, threshold_val, 255, THRESH_BINARY); + + unsigned int region_size_min = 3.14*min_size*min_size; + unsigned int region_size_max = 3.14*max_size*max_size; + + int blob_index = 1; + for (int y=0; y(y,x) != 255) continue; + Rect rect; + floodFill(frame_bin, Point(x,y), Scalar(blob_index), &rect, Scalar(0), Scalar(0), FLOODFILL_FIXED_RANGE); + blob_index++; + + // calculate the size of the connected component + unsigned int region_size = 0; + for (int i=rect.y; i < (rect.y+rect.height); i++) + { + for (int j=rect.x; j < (rect.x+rect.width); j++) + { + if (frame_bin.at(i,j) != blob_index-1) continue; + region_size++; + } + } + + if (region_size < region_size_min || region_size > region_size_max) continue; + + // calculate the center of mass: + // mx = (sum_ij j*f(frame_grey_ij)) / (sum_ij f(frame_grey_ij)) + // my = ... + // f maps from [threshold,256] -> [0, 1], lower values are mapped to 0 + float m = 0; + float mx = 0; + float my = 0; + for (int i=rect.y; i < (rect.y+rect.height); i++) + { + for (int j=rect.x; j < (rect.x+rect.width); j++) + { + if (frame_bin.at(i,j) != blob_index-1) continue; + float val = frame_grey.at(i,j); + val = float(val - threshold_val)/(256 - threshold_val); + val = val*val; // makes it more stable (less emphasis on low values, more on the peak) + m += val; + mx += j * val; + my += i * val; + } + } + + // convert to centered camera coordinate system with y axis upwards + Vec2f c; + c[0] = (mx/m - W/2)/W; + c[1] = -(my/m - H/2)/W; + points.push_back(c); + + if (blob_index >= 255) break; + } + if (blob_index >= 255) break; + } + + // draw output image + if (draw_output) { + frame.setTo(Scalar(255,0,0), frame_bin); + } + + return points; +} diff --git a/ftnoir_tracker_pt/point_extractor.h b/ftnoir_tracker_pt/point_extractor.h index b142d2bb..9a6f7f2c 100644 --- a/ftnoir_tracker_pt/point_extractor.h +++ b/ftnoir_tracker_pt/point_extractor.h @@ -1,31 +1,31 @@ -/* Copyright (c) 2012 Patrick Ruoff - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - */ - -#ifndef POINTEXTRACTOR_H -#define POINTEXTRACTOR_H - -#include - -// ---------------------------------------------------------------------------- -// Extracts points from an opencv image -class PointExtractor -{ -public: - // extracts points from frame and draws some processing info into frame, if draw_output is set - // dt: time since last call in seconds - // WARNING: returned reference is valid as long as object - const std::vector& extract_points(cv::Mat frame, float dt, bool draw_output); - const std::vector& get_points() { return points; } - - int threshold_val; - int min_size, max_size; - -protected: - std::vector points; -}; - -#endif //POINTEXTRACTOR_H +/* Copyright (c) 2012 Patrick Ruoff + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + */ + +#ifndef POINTEXTRACTOR_H +#define POINTEXTRACTOR_H + +#include + +// ---------------------------------------------------------------------------- +// Extracts points from an opencv image +class PointExtractor +{ +public: + // extracts points from frame and draws some processing info into frame, if draw_output is set + // dt: time since last call in seconds + // WARNING: returned reference is valid as long as object + const std::vector& extract_points(cv::Mat frame, float dt, bool draw_output); + const std::vector& get_points() { return points; } + + int threshold_val; + int min_size, max_size; + +protected: + std::vector points; +}; + +#endif //POINTEXTRACTOR_H diff --git a/ftnoir_tracker_pt/point_tracker.cpp b/ftnoir_tracker_pt/point_tracker.cpp index c08d6d83..210ed2eb 100644 --- a/ftnoir_tracker_pt/point_tracker.cpp +++ b/ftnoir_tracker_pt/point_tracker.cpp @@ -1,352 +1,352 @@ -/* Copyright (c) 2012 Patrick Ruoff - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - */ - -#include "point_tracker.h" - -#include -#include -#include - -#include - -using namespace cv; -using namespace std; - -const float PI = 3.14159265358979323846f; - -// ---------------------------------------------------------------------------- -static void get_row(const Matx33f& m, int i, Vec3f& v) -{ - v[0] = m(i,0); - v[1] = m(i,1); - v[2] = m(i,2); -} - -static void set_row(Matx33f& m, int i, const Vec3f& v) -{ - m(i,0) = v[0]; - m(i,1) = v[1]; - m(i,2) = v[2]; -} - -// ---------------------------------------------------------------------------- -PointModel::PointModel(Vec3f M01, Vec3f M02) - : M01(M01), M02(M02) -{ - // calculate u - u = M01.cross(M02); - u /= norm(u); - - // calculate projection matrix on M01,M02 plane - float s11 = M01.dot(M01); - float s12 = M01.dot(M02); - float s22 = M02.dot(M02); - P = 1.0/(s11*s22-s12*s12) * Matx22f(s22, -s12, - -s12, s11); - - // calculate d and d_order for simple freetrack-like point correspondence - vector points; - points.push_back(Vec2f(0,0)); - points.push_back(Vec2f(M01[0], M01[1])); - points.push_back(Vec2f(M02[0], M02[1])); - // fit line to orthographically projected points - // ERROR: yields wrong results with colinear points?! - /* - Vec4f line; - fitLine(points, line, CV_DIST_L2, 0, 0.01, 0.01); - d[0] = line[0]; d[1] = line[1]; - */ - // TODO: fix this - d = Vec2f(M01[0]-M02[0], M01[1]-M02[1]); - - // sort model points - get_d_order(points, d_order); -} - -static bool d_vals_sort(const pair a, const pair b) -{ - return a.first < b.first; -} - -void PointModel::get_d_order(const std::vector& points, int d_order[]) const -{ - // get sort indices with respect to d scalar product - vector< pair > d_vals; - for (int i = 0; i<(int)points.size(); ++i) - d_vals.push_back(pair(d.dot(points[i]), i)); - - sort(d_vals.begin(), d_vals.end(), d_vals_sort); - - for (int i = 0; i<(int)points.size(); ++i) - d_order[i] = d_vals[i].second; -} - - -// ---------------------------------------------------------------------------- -PointTracker::PointTracker() : dynamic_pose_resolution(true), dt_reset(1), init_phase(true), dt_valid(0), v_t(0,0,0), v_r(0,0,0) -{ - X_CM.t[2] = 1000; // default position: 1 m away from cam; -} - -void PointTracker::reset() -{ - // enter init phase and reset velocities - init_phase = true; - dt_valid = 0; - reset_velocities(); -} - -void PointTracker::reset_velocities() -{ - v_t = Vec3f(0,0,0); - v_r = Vec3f(0,0,0); -} - - -bool PointTracker::track(const vector& points, float f, float dt) -{ - if (!dynamic_pose_resolution) init_phase = true; - - dt_valid += dt; - // if there was no valid tracking result for too long, do a reset - if (dt_valid > dt_reset) - { - //qDebug()<<"dt_valid "< dt_reset "<& points, float f) -{ - if (init_phase) { - // We do a simple freetrack-like sorting in the init phase... - // sort points - int point_d_order[PointModel::N_POINTS]; - point_model->get_d_order(points, point_d_order); - - // set correspondences - for (int i=0; id_order[i]] = points[point_d_order[i]]; - } - } - else { - // ... otherwise we look at the distance to the projection of the expected model points - // project model points under current pose - p_exp[0] = project(Vec3f(0,0,0), f); - p_exp[1] = project(point_model->M01, f); - p_exp[2] = project(point_model->M02, f); - - // set correspondences by minimum distance to projected model point - bool point_taken[PointModel::N_POINTS]; - for (int i=0; iM01)/Z0; - epsilon_2 = k.dot(point_model->M02)/Z0; - - // vector of scalar products and - Vec2f I0_M0i(p[1][0]*(1.0 + epsilon_1) - p[0][0], - p[2][0]*(1.0 + epsilon_2) - p[0][0]); - Vec2f J0_M0i(p[1][1]*(1.0 + epsilon_1) - p[0][1], - p[2][1]*(1.0 + epsilon_2) - p[0][1]); - - // construct projection of I, J onto M0i plane: I0 and J0 - I0_coeff = point_model->P * I0_M0i; - J0_coeff = point_model->P * J0_M0i; - I0 = I0_coeff[0]*point_model->M01 + I0_coeff[1]*point_model->M02; - J0 = J0_coeff[0]*point_model->M01 + J0_coeff[1]*point_model->M02; - - // calculate u component of I, J - float II0 = I0.dot(I0); - float IJ0 = I0.dot(J0); - float JJ0 = J0.dot(J0); - float rho, theta; - if (JJ0 == II0) { - rho = sqrt(abs(2*IJ0)); - theta = -PI/4; - if (IJ0<0) theta *= -1; - } - else { - rho = sqrt(sqrt( (JJ0-II0)*(JJ0-II0) + 4*IJ0*IJ0 )); - theta = atan( -2*IJ0 / (JJ0-II0) ); - if (JJ0 - II0 < 0) theta += PI; - theta /= 2; - } - - // construct the two solutions - I_1 = I0 + rho*cos(theta)*point_model->u; - I_2 = I0 - rho*cos(theta)*point_model->u; - - J_1 = J0 + rho*sin(theta)*point_model->u; - J_2 = J0 - rho*sin(theta)*point_model->u; - - float norm_const = 1.0/norm(I_1); // all have the same norm - - // create rotation matrices - I_1 *= norm_const; J_1 *= norm_const; - I_2 *= norm_const; J_2 *= norm_const; - - set_row(R_1, 0, I_1); - set_row(R_1, 1, J_1); - set_row(R_1, 2, I_1.cross(J_1)); - - set_row(R_2, 0, I_2); - set_row(R_2, 1, J_2); - set_row(R_2, 2, I_2.cross(J_2)); - - // the single translation solution - Z0 = norm_const * f; - - // pick the rotation solution closer to the expected one - // in simple metric d(A,B) = || I - A * B^T || - float R_1_deviation = norm(Matx33f::eye() - R_expected * R_1.t()); - float R_2_deviation = norm(Matx33f::eye() - R_expected * R_2.t()); - - if (R_1_deviation < R_2_deviation) - R_current = &R_1; - else - R_current = &R_2; - - get_row(*R_current, 2, k); - - // check for convergence condition - if (abs(epsilon_1 - old_epsilon_1) + abs(epsilon_2 - old_epsilon_2) < EPS_THRESHOLD) - break; - old_epsilon_1 = epsilon_1; - old_epsilon_2 = epsilon_2; - } - - // apply results - X_CM.R = *R_current; - X_CM.t[0] = p[0][0] * Z0/f; - X_CM.t[1] = p[0][1] * Z0/f; - X_CM.t[2] = Z0; - - return i; - - //Rodrigues(X_CM.R, r); - //qDebug()<<"iter: "< +#include +#include + +#include + +using namespace cv; +using namespace std; + +const float PI = 3.14159265358979323846f; + +// ---------------------------------------------------------------------------- +static void get_row(const Matx33f& m, int i, Vec3f& v) +{ + v[0] = m(i,0); + v[1] = m(i,1); + v[2] = m(i,2); +} + +static void set_row(Matx33f& m, int i, const Vec3f& v) +{ + m(i,0) = v[0]; + m(i,1) = v[1]; + m(i,2) = v[2]; +} + +// ---------------------------------------------------------------------------- +PointModel::PointModel(Vec3f M01, Vec3f M02) + : M01(M01), M02(M02) +{ + // calculate u + u = M01.cross(M02); + u /= norm(u); + + // calculate projection matrix on M01,M02 plane + float s11 = M01.dot(M01); + float s12 = M01.dot(M02); + float s22 = M02.dot(M02); + P = 1.0/(s11*s22-s12*s12) * Matx22f(s22, -s12, + -s12, s11); + + // calculate d and d_order for simple freetrack-like point correspondence + vector points; + points.push_back(Vec2f(0,0)); + points.push_back(Vec2f(M01[0], M01[1])); + points.push_back(Vec2f(M02[0], M02[1])); + // fit line to orthographically projected points + // ERROR: yields wrong results with colinear points?! + /* + Vec4f line; + fitLine(points, line, CV_DIST_L2, 0, 0.01, 0.01); + d[0] = line[0]; d[1] = line[1]; + */ + // TODO: fix this + d = Vec2f(M01[0]-M02[0], M01[1]-M02[1]); + + // sort model points + get_d_order(points, d_order); +} + +static bool d_vals_sort(const pair a, const pair b) +{ + return a.first < b.first; +} + +void PointModel::get_d_order(const std::vector& points, int d_order[]) const +{ + // get sort indices with respect to d scalar product + vector< pair > d_vals; + for (int i = 0; i<(int)points.size(); ++i) + d_vals.push_back(pair(d.dot(points[i]), i)); + + sort(d_vals.begin(), d_vals.end(), d_vals_sort); + + for (int i = 0; i<(int)points.size(); ++i) + d_order[i] = d_vals[i].second; +} + + +// ---------------------------------------------------------------------------- +PointTracker::PointTracker() : dynamic_pose_resolution(true), dt_reset(1), init_phase(true), dt_valid(0), v_t(0,0,0), v_r(0,0,0) +{ + X_CM.t[2] = 1000; // default position: 1 m away from cam; +} + +void PointTracker::reset() +{ + // enter init phase and reset velocities + init_phase = true; + dt_valid = 0; + reset_velocities(); +} + +void PointTracker::reset_velocities() +{ + v_t = Vec3f(0,0,0); + v_r = Vec3f(0,0,0); +} + + +bool PointTracker::track(const vector& points, float f, float dt) +{ + if (!dynamic_pose_resolution) init_phase = true; + + dt_valid += dt; + // if there was no valid tracking result for too long, do a reset + if (dt_valid > dt_reset) + { + //qDebug()<<"dt_valid "< dt_reset "<& points, float f) +{ + if (init_phase) { + // We do a simple freetrack-like sorting in the init phase... + // sort points + int point_d_order[PointModel::N_POINTS]; + point_model->get_d_order(points, point_d_order); + + // set correspondences + for (int i=0; id_order[i]] = points[point_d_order[i]]; + } + } + else { + // ... otherwise we look at the distance to the projection of the expected model points + // project model points under current pose + p_exp[0] = project(Vec3f(0,0,0), f); + p_exp[1] = project(point_model->M01, f); + p_exp[2] = project(point_model->M02, f); + + // set correspondences by minimum distance to projected model point + bool point_taken[PointModel::N_POINTS]; + for (int i=0; iM01)/Z0; + epsilon_2 = k.dot(point_model->M02)/Z0; + + // vector of scalar products and + Vec2f I0_M0i(p[1][0]*(1.0 + epsilon_1) - p[0][0], + p[2][0]*(1.0 + epsilon_2) - p[0][0]); + Vec2f J0_M0i(p[1][1]*(1.0 + epsilon_1) - p[0][1], + p[2][1]*(1.0 + epsilon_2) - p[0][1]); + + // construct projection of I, J onto M0i plane: I0 and J0 + I0_coeff = point_model->P * I0_M0i; + J0_coeff = point_model->P * J0_M0i; + I0 = I0_coeff[0]*point_model->M01 + I0_coeff[1]*point_model->M02; + J0 = J0_coeff[0]*point_model->M01 + J0_coeff[1]*point_model->M02; + + // calculate u component of I, J + float II0 = I0.dot(I0); + float IJ0 = I0.dot(J0); + float JJ0 = J0.dot(J0); + float rho, theta; + if (JJ0 == II0) { + rho = sqrt(abs(2*IJ0)); + theta = -PI/4; + if (IJ0<0) theta *= -1; + } + else { + rho = sqrt(sqrt( (JJ0-II0)*(JJ0-II0) + 4*IJ0*IJ0 )); + theta = atan( -2*IJ0 / (JJ0-II0) ); + if (JJ0 - II0 < 0) theta += PI; + theta /= 2; + } + + // construct the two solutions + I_1 = I0 + rho*cos(theta)*point_model->u; + I_2 = I0 - rho*cos(theta)*point_model->u; + + J_1 = J0 + rho*sin(theta)*point_model->u; + J_2 = J0 - rho*sin(theta)*point_model->u; + + float norm_const = 1.0/norm(I_1); // all have the same norm + + // create rotation matrices + I_1 *= norm_const; J_1 *= norm_const; + I_2 *= norm_const; J_2 *= norm_const; + + set_row(R_1, 0, I_1); + set_row(R_1, 1, J_1); + set_row(R_1, 2, I_1.cross(J_1)); + + set_row(R_2, 0, I_2); + set_row(R_2, 1, J_2); + set_row(R_2, 2, I_2.cross(J_2)); + + // the single translation solution + Z0 = norm_const * f; + + // pick the rotation solution closer to the expected one + // in simple metric d(A,B) = || I - A * B^T || + float R_1_deviation = norm(Matx33f::eye() - R_expected * R_1.t()); + float R_2_deviation = norm(Matx33f::eye() - R_expected * R_2.t()); + + if (R_1_deviation < R_2_deviation) + R_current = &R_1; + else + R_current = &R_2; + + get_row(*R_current, 2, k); + + // check for convergence condition + if (abs(epsilon_1 - old_epsilon_1) + abs(epsilon_2 - old_epsilon_2) < EPS_THRESHOLD) + break; + old_epsilon_1 = epsilon_1; + old_epsilon_2 = epsilon_2; + } + + // apply results + X_CM.R = *R_current; + X_CM.t[0] = p[0][0] * Z0/f; + X_CM.t[1] = p[0][1] * Z0/f; + X_CM.t[2] = Z0; + + return i; + + //Rodrigues(X_CM.R, r); + //qDebug()<<"iter: "< -#include -#include - -// ---------------------------------------------------------------------------- -// Afine frame trafo -class FrameTrafo -{ -public: - FrameTrafo() : R(cv::Matx33f::eye()), t(0,0,0) {} - FrameTrafo(const cv::Matx33f& R, const cv::Vec3f& t) : R(R),t(t) {} - - cv::Matx33f R; - cv::Vec3f t; -}; - -inline FrameTrafo operator*(const FrameTrafo& X, const FrameTrafo& Y) -{ - return FrameTrafo(X.R*Y.R, X.R*Y.t + X.t); -} - -inline cv::Vec3f operator*(const FrameTrafo& X, const cv::Vec3f& v) -{ - return X.R*v + X.t; -} - -// ---------------------------------------------------------------------------- -// Describes a 3-point model -// nomenclature as in -// [Denis Oberkampf, Daniel F. DeMenthon, Larry S. Davis: "Iterative Pose Estimation Using Coplanar Feature Points"] -class PointModel -{ - friend class PointTracker; -public: - static const int N_POINTS = 3; - - PointModel(cv::Vec3f M01, cv::Vec3f M02); - - const cv::Vec3f& get_M01() const { return M01; }; - const cv::Vec3f& get_M02() const { return M02; }; - -protected: - cv::Vec3f M01; // M01 in model frame - cv::Vec3f M02; // M02 in model frame - - cv::Vec3f u; // unit vector perpendicular to M01,M02-plane - - cv::Matx22f P; - - cv::Vec2f d; // discrimant vector for point correspondence - int d_order[3]; // sorting of projected model points with respect to d scalar product - - void get_d_order(const std::vector& points, int d_order[]) const; -}; - -// ---------------------------------------------------------------------------- -// Tracks a 3-point model -// implementing the POSIT algorithm for coplanar points as presented in -// [Denis Oberkampf, Daniel F. DeMenthon, Larry S. Davis: "Iterative Pose Estimation Using Coplanar Feature Points"] -class PointTracker -{ -public: - PointTracker(); - - // track the pose using the set of normalized point coordinates (x pos in range -0.5:0.5) - // f : (focal length)/(sensor width) - // dt : time since last call - bool track(const std::vector& points, float f, float dt); - std::auto_ptr point_model; - - bool dynamic_pose_resolution; - float dt_reset; - - FrameTrafo get_pose() const { return X_CM; } - void reset(); - -protected: - inline cv::Vec2f project(const cv::Vec3f& v_M, float f) - { - cv::Vec3f v_C = X_CM * v_M; - return cv::Vec2f(f*v_C[0]/v_C[2], f*v_C[1]/v_C[2]); - } - - bool find_correspondences(const std::vector& points, float f); - - cv::Vec2f p[PointModel::N_POINTS]; // the points in model order - cv::Vec2f p_exp[PointModel::N_POINTS]; // the expected point positions - - void predict(float dt); - void update_velocities(float dt); - void reset_velocities(); - - - int POSIT(float f); // The POSIT algorithm, returns the number of iterations - - bool init_phase; - float dt_valid; // time since last valid tracking result - cv::Vec3f v_t; // velocities - cv::Vec3f v_r; - FrameTrafo X_CM; // trafo from model to camera - FrameTrafo X_CM_old; -}; - -#endif //POINTTRACKER_H +/* Copyright (c) 2012 Patrick Ruoff + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + */ + +#ifndef POINTTRACKER_H +#define POINTTRACKER_H + +#include +#include +#include + +// ---------------------------------------------------------------------------- +// Afine frame trafo +class FrameTrafo +{ +public: + FrameTrafo() : R(cv::Matx33f::eye()), t(0,0,0) {} + FrameTrafo(const cv::Matx33f& R, const cv::Vec3f& t) : R(R),t(t) {} + + cv::Matx33f R; + cv::Vec3f t; +}; + +inline FrameTrafo operator*(const FrameTrafo& X, const FrameTrafo& Y) +{ + return FrameTrafo(X.R*Y.R, X.R*Y.t + X.t); +} + +inline cv::Vec3f operator*(const FrameTrafo& X, const cv::Vec3f& v) +{ + return X.R*v + X.t; +} + +// ---------------------------------------------------------------------------- +// Describes a 3-point model +// nomenclature as in +// [Denis Oberkampf, Daniel F. DeMenthon, Larry S. Davis: "Iterative Pose Estimation Using Coplanar Feature Points"] +class PointModel +{ + friend class PointTracker; +public: + static const int N_POINTS = 3; + + PointModel(cv::Vec3f M01, cv::Vec3f M02); + + const cv::Vec3f& get_M01() const { return M01; }; + const cv::Vec3f& get_M02() const { return M02; }; + +protected: + cv::Vec3f M01; // M01 in model frame + cv::Vec3f M02; // M02 in model frame + + cv::Vec3f u; // unit vector perpendicular to M01,M02-plane + + cv::Matx22f P; + + cv::Vec2f d; // discrimant vector for point correspondence + int d_order[3]; // sorting of projected model points with respect to d scalar product + + void get_d_order(const std::vector& points, int d_order[]) const; +}; + +// ---------------------------------------------------------------------------- +// Tracks a 3-point model +// implementing the POSIT algorithm for coplanar points as presented in +// [Denis Oberkampf, Daniel F. DeMenthon, Larry S. Davis: "Iterative Pose Estimation Using Coplanar Feature Points"] +class PointTracker +{ +public: + PointTracker(); + + // track the pose using the set of normalized point coordinates (x pos in range -0.5:0.5) + // f : (focal length)/(sensor width) + // dt : time since last call + bool track(const std::vector& points, float f, float dt); + std::auto_ptr point_model; + + bool dynamic_pose_resolution; + float dt_reset; + + FrameTrafo get_pose() const { return X_CM; } + void reset(); + +protected: + inline cv::Vec2f project(const cv::Vec3f& v_M, float f) + { + cv::Vec3f v_C = X_CM * v_M; + return cv::Vec2f(f*v_C[0]/v_C[2], f*v_C[1]/v_C[2]); + } + + bool find_correspondences(const std::vector& points, float f); + + cv::Vec2f p[PointModel::N_POINTS]; // the points in model order + cv::Vec2f p_exp[PointModel::N_POINTS]; // the expected point positions + + void predict(float dt); + void update_velocities(float dt); + void reset_velocities(); + + + int POSIT(float f); // The POSIT algorithm, returns the number of iterations + + bool init_phase; + float dt_valid; // time since last valid tracking result + cv::Vec3f v_t; // velocities + cv::Vec3f v_r; + FrameTrafo X_CM; // trafo from model to camera + FrameTrafo X_CM_old; +}; + +#endif //POINTTRACKER_H diff --git a/ftnoir_tracker_pt/resource.h b/ftnoir_tracker_pt/resource.h index c14e94ad..4ca527a3 100644 --- a/ftnoir_tracker_pt/resource.h +++ b/ftnoir_tracker_pt/resource.h @@ -1,14 +1,14 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by FTNoIR_Tracker_PT.rc - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 101 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1001 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by FTNoIR_Tracker_PT.rc + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 101 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1001 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/ftnoir_tracker_pt/timer.cpp b/ftnoir_tracker_pt/timer.cpp index 9e6ca8b8..07379853 100644 --- a/ftnoir_tracker_pt/timer.cpp +++ b/ftnoir_tracker_pt/timer.cpp @@ -1,65 +1,65 @@ -/* Copyright (c) 2012 Patrick Ruoff - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - */ - -#include "timer.h" - -#include - -// ---------------------------------------------------------------------------- -Timer::Timer() -: startTime(0), endTime(0), running(false) -{ -#ifdef WIN32 - QueryPerformanceFrequency(&frequency); - startCount.QuadPart = 0; - endCount.QuadPart = 0; -#else - startCount.tv_sec = startCount.tv_usec = 0; - endCount.tv_sec = endCount.tv_usec = 0; -#endif -} - - -void Timer::start() -{ -#ifdef WIN32 - QueryPerformanceCounter(&startCount); -#else - gettimeofday(&startCount, NULL); -#endif - running = true; -} - - -void Timer::stop() -{ -#ifdef WIN32 - QueryPerformanceCounter(&endCount); -#else - gettimeofday(&endCount, NULL); -#endif - running = false; -} - - -double Timer::elapsed() -{ -#ifdef WIN32 - if (running) - QueryPerformanceCounter(&endCount); - - startTime = startCount.QuadPart * (1e3 / frequency.QuadPart); - endTime = endCount.QuadPart * (1e3 / frequency.QuadPart); -#else - (void) gettimeofday(&endCount, NULL); - - startTime = (startCount.tv_sec * 1e3) + startCount.tv_usec; - endTime = (endCount.tv_sec * 1e3) + endCount.tv_usec; -#endif - - return endTime - startTime; +/* Copyright (c) 2012 Patrick Ruoff + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + */ + +#include "timer.h" + +#include + +// ---------------------------------------------------------------------------- +Timer::Timer() +: startTime(0), endTime(0), running(false) +{ +#ifdef WIN32 + QueryPerformanceFrequency(&frequency); + startCount.QuadPart = 0; + endCount.QuadPart = 0; +#else + startCount.tv_sec = startCount.tv_usec = 0; + endCount.tv_sec = endCount.tv_usec = 0; +#endif +} + + +void Timer::start() +{ +#ifdef WIN32 + QueryPerformanceCounter(&startCount); +#else + gettimeofday(&startCount, NULL); +#endif + running = true; +} + + +void Timer::stop() +{ +#ifdef WIN32 + QueryPerformanceCounter(&endCount); +#else + gettimeofday(&endCount, NULL); +#endif + running = false; +} + + +double Timer::elapsed() +{ +#ifdef WIN32 + if (running) + QueryPerformanceCounter(&endCount); + + startTime = startCount.QuadPart * (1e3 / frequency.QuadPart); + endTime = endCount.QuadPart * (1e3 / frequency.QuadPart); +#else + (void) gettimeofday(&endCount, NULL); + + startTime = (startCount.tv_sec * 1e3) + startCount.tv_usec; + endTime = (endCount.tv_sec * 1e3) + endCount.tv_usec; +#endif + + return endTime - startTime; } \ No newline at end of file diff --git a/ftnoir_tracker_pt/timer.h b/ftnoir_tracker_pt/timer.h index 2aaf725a..1c2c3559 100644 --- a/ftnoir_tracker_pt/timer.h +++ b/ftnoir_tracker_pt/timer.h @@ -1,44 +1,44 @@ -/* Copyright (c) 2012 Patrick Ruoff - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - */ - -#ifndef PT_TIMER_H -#define PT_TIMER_H - -#ifdef WIN32 // Windows system specific -#include -#else // Unix based system specific -#include -#endif - -// ---------------------------------------------------------------------------- -// high resolution timer based on http://www.songho.ca/misc/timer/timer.html -class Timer -{ -public: - Timer(); - - void start(); - void stop(); - void restart() { start(); } // for Qt compatibility - double elapsed(); // get elapsed time in ms - -protected: - double startTime; // starting time in ms - double endTime; // ending time in ms - bool running; - -#ifdef WIN32 - LARGE_INTEGER frequency; // ticks per second - LARGE_INTEGER startCount; - LARGE_INTEGER endCount; -#else - timeval startCount; - timeval endCount; -#endif -}; - +/* Copyright (c) 2012 Patrick Ruoff + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + */ + +#ifndef PT_TIMER_H +#define PT_TIMER_H + +#ifdef WIN32 // Windows system specific +#include +#else // Unix based system specific +#include +#endif + +// ---------------------------------------------------------------------------- +// high resolution timer based on http://www.songho.ca/misc/timer/timer.html +class Timer +{ +public: + Timer(); + + void start(); + void stop(); + void restart() { start(); } // for Qt compatibility + double elapsed(); // get elapsed time in ms + +protected: + double startTime; // starting time in ms + double endTime; // ending time in ms + bool running; + +#ifdef WIN32 + LARGE_INTEGER frequency; // ticks per second + LARGE_INTEGER startCount; + LARGE_INTEGER endCount; +#else + timeval startCount; + timeval endCount; +#endif +}; + #endif //PT_TIMER_H \ No newline at end of file diff --git a/ftnoir_tracker_pt/trans_calib.cpp b/ftnoir_tracker_pt/trans_calib.cpp index 9b75a1b6..729a0b7f 100644 --- a/ftnoir_tracker_pt/trans_calib.cpp +++ b/ftnoir_tracker_pt/trans_calib.cpp @@ -1,44 +1,44 @@ -/* Copyright (c) 2012 Patrick Ruoff - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - */ - -#include "trans_calib.h" - -using namespace cv; - -//----------------------------------------------------------------------------- -TranslationCalibrator::TranslationCalibrator() -{ - reset(); -} - -void TranslationCalibrator::reset() -{ - P = Matx66f::zeros(); - y = Vec6f(0,0,0, 0,0,0); -} - -void TranslationCalibrator::update(const Matx33f& R_CM_k, const Vec3f& t_CM_k) -{ - Matx H_k_T = Matx::zeros(); - for (int i=0; i<3; ++i) { - for (int j=0; j<3; ++j) { - H_k_T(i,j) = R_CM_k(j,i); - } - } - for (int i=0; i<3; ++i) - { - H_k_T(3+i,i) = 1.0; - } - P += H_k_T * H_k_T.t(); - y += H_k_T * t_CM_k; -} - -Vec3f TranslationCalibrator::get_estimate() -{ - Vec6f x = P.inv() * y; - return Vec3f(-x[0], -x[1], -x[2]); +/* Copyright (c) 2012 Patrick Ruoff + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + */ + +#include "trans_calib.h" + +using namespace cv; + +//----------------------------------------------------------------------------- +TranslationCalibrator::TranslationCalibrator() +{ + reset(); +} + +void TranslationCalibrator::reset() +{ + P = Matx66f::zeros(); + y = Vec6f(0,0,0, 0,0,0); +} + +void TranslationCalibrator::update(const Matx33f& R_CM_k, const Vec3f& t_CM_k) +{ + Matx H_k_T = Matx::zeros(); + for (int i=0; i<3; ++i) { + for (int j=0; j<3; ++j) { + H_k_T(i,j) = R_CM_k(j,i); + } + } + for (int i=0; i<3; ++i) + { + H_k_T(3+i,i) = 1.0; + } + P += H_k_T * H_k_T.t(); + y += H_k_T * t_CM_k; +} + +Vec3f TranslationCalibrator::get_estimate() +{ + Vec6f x = P.inv() * y; + return Vec3f(-x[0], -x[1], -x[2]); } \ No newline at end of file diff --git a/ftnoir_tracker_pt/trans_calib.h b/ftnoir_tracker_pt/trans_calib.h index 4024d011..6288546a 100644 --- a/ftnoir_tracker_pt/trans_calib.h +++ b/ftnoir_tracker_pt/trans_calib.h @@ -1,39 +1,39 @@ -/* Copyright (c) 2012 Patrick Ruoff - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - */ - -#ifndef TRANSCALIB_H -#define TRANSCALIB_H - -#include - -//----------------------------------------------------------------------------- -// calibrates the translation from head to model = t_MH -// by recursive least squares / -// kalman filter in information form with identity noise covariance -// measurement equation when head position = t_CH is fixed: -// (R_CM_k , Id)*(-t_MH, t_CH) = t_CM_k - -class TranslationCalibrator -{ -public: - TranslationCalibrator(); - - // reset the calibration process - void reset(); - - // update the current estimate - void update(const cv::Matx33f& R_CM_k, const cv::Vec3f& t_CM_k); - - // get the current estimate for t_MH - cv::Vec3f get_estimate(); - -protected: - cv::Matx66f P; // normalized precision matrix = inverse covariance - cv::Vec6f y; // P*(-t_MH, t_CH) -}; - +/* Copyright (c) 2012 Patrick Ruoff + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + */ + +#ifndef TRANSCALIB_H +#define TRANSCALIB_H + +#include + +//----------------------------------------------------------------------------- +// calibrates the translation from head to model = t_MH +// by recursive least squares / +// kalman filter in information form with identity noise covariance +// measurement equation when head position = t_CH is fixed: +// (R_CM_k , Id)*(-t_MH, t_CH) = t_CM_k + +class TranslationCalibrator +{ +public: + TranslationCalibrator(); + + // reset the calibration process + void reset(); + + // update the current estimate + void update(const cv::Matx33f& R_CM_k, const cv::Vec3f& t_CM_k); + + // get the current estimate for t_MH + cv::Vec3f get_estimate(); + +protected: + cv::Matx66f P; // normalized precision matrix = inverse covariance + cv::Vec6f y; // P*(-t_MH, t_CH) +}; + #endif //TRANSCALIB_H \ No newline at end of file diff --git a/ftnoir_tracker_pt/video_widget.cpp b/ftnoir_tracker_pt/video_widget.cpp index a13542ba..2b554aba 100644 --- a/ftnoir_tracker_pt/video_widget.cpp +++ b/ftnoir_tracker_pt/video_widget.cpp @@ -1,52 +1,52 @@ -/* Copyright (c) 2012 Patrick Ruoff - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - */ - -#include "video_widget.h" - -#include - -using namespace cv; -using namespace std; - -void VideoWidget::update_image(Mat frame, std::auto_ptr< vector >) -{ - QMutexLocker foo(&mtx); - - if (frame.channels() != 3 && frame.channels() != 1) - return; - - int width = frame.cols, height = frame.rows; - unsigned char* src = frame.data; - - QImage qframe(width, height, QImage::Format_RGB888); - if (frame.channels() == 3) - { - uchar* data = qframe.bits(); - const int pitch = qframe.bytesPerLine(); - for (int y = 0; y < height; y++) - for (int x = 0; x < width; x++) - { - const int pos = 3 * (y*width + x); - data[y * pitch + x * 3 + 0] = src[pos + 2]; - data[y * pitch + x * 3 + 1] = src[pos + 1]; - data[y * pitch + x * 3 + 2] = src[pos + 0]; - } - } else { - uchar* data = qframe.bits(); - const int pitch = qframe.bytesPerLine(); - for (int y = 0; y < height; y++) - for (int x = 0; x < width; x++) - { - const int pos = (y*width + x); - data[y * pitch + x * 3 + 0] = src[pos]; - data[y * pitch + x * 3 + 1] = src[pos]; - data[y * pitch + x * 3 + 2] = src[pos]; - } - } - qframe = qframe.scaled(size(), Qt::IgnoreAspectRatio, Qt::FastTransformation); - pixmap = QPixmap::fromImage(qframe); -} +/* Copyright (c) 2012 Patrick Ruoff + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + */ + +#include "video_widget.h" + +#include + +using namespace cv; +using namespace std; + +void VideoWidget::update_image(Mat frame, std::auto_ptr< vector >) +{ + QMutexLocker foo(&mtx); + + if (frame.channels() != 3 && frame.channels() != 1) + return; + + int width = frame.cols, height = frame.rows; + unsigned char* src = frame.data; + + QImage qframe(width, height, QImage::Format_RGB888); + if (frame.channels() == 3) + { + uchar* data = qframe.bits(); + const int pitch = qframe.bytesPerLine(); + for (int y = 0; y < height; y++) + for (int x = 0; x < width; x++) + { + const int pos = 3 * (y*width + x); + data[y * pitch + x * 3 + 0] = src[pos + 2]; + data[y * pitch + x * 3 + 1] = src[pos + 1]; + data[y * pitch + x * 3 + 2] = src[pos + 0]; + } + } else { + uchar* data = qframe.bits(); + const int pitch = qframe.bytesPerLine(); + for (int y = 0; y < height; y++) + for (int x = 0; x < width; x++) + { + const int pos = (y*width + x); + data[y * pitch + x * 3 + 0] = src[pos]; + data[y * pitch + x * 3 + 1] = src[pos]; + data[y * pitch + x * 3 + 2] = src[pos]; + } + } + qframe = qframe.scaled(size(), Qt::IgnoreAspectRatio, Qt::FastTransformation); + pixmap = QPixmap::fromImage(qframe); +} diff --git a/ftnoir_tracker_pt/video_widget.h b/ftnoir_tracker_pt/video_widget.h index 66959fde..3051919b 100644 --- a/ftnoir_tracker_pt/video_widget.h +++ b/ftnoir_tracker_pt/video_widget.h @@ -1,42 +1,42 @@ -/* Copyright (c) 2012 Patrick Ruoff - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - */ - -#ifndef VIDEOWIDGET_H -#define VIDEOWIDGET_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// ---------------------------------------------------------------------------- -class VideoWidget : public QWidget -{ - Q_OBJECT - -public: - VideoWidget(QWidget *parent) : QWidget(parent), mtx() { - } - void update_image(cv::Mat frame, std::auto_ptr< std::vector >); -protected slots: - void paintEvent( QPaintEvent* e ) { - QMutexLocker foo(&mtx); - QPainter painter(this); - painter.drawPixmap(e->rect(), pixmap, e->rect()); - } - -private: - QMutex mtx; - QPixmap pixmap; -}; - -#endif // VIDEOWIDGET_H +/* Copyright (c) 2012 Patrick Ruoff + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + */ + +#ifndef VIDEOWIDGET_H +#define VIDEOWIDGET_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// ---------------------------------------------------------------------------- +class VideoWidget : public QWidget +{ + Q_OBJECT + +public: + VideoWidget(QWidget *parent) : QWidget(parent), mtx() { + } + void update_image(cv::Mat frame, std::auto_ptr< std::vector >); +protected slots: + void paintEvent( QPaintEvent* e ) { + QMutexLocker foo(&mtx); + QPainter painter(this); + painter.drawPixmap(e->rect(), pixmap, e->rect()); + } + +private: + QMutex mtx; + QPixmap pixmap; +}; + +#endif // VIDEOWIDGET_H diff --git a/ftnoir_tracker_sm/ftnoir_tracker_faceapi.cpp b/ftnoir_tracker_sm/ftnoir_tracker_faceapi.cpp index 74e1d3d2..06c8b206 100644 --- a/ftnoir_tracker_sm/ftnoir_tracker_faceapi.cpp +++ b/ftnoir_tracker_sm/ftnoir_tracker_faceapi.cpp @@ -1,173 +1,173 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2012 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage: http://facetracknoir.sourceforge.net/home/default.htm * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -********************************************************************************/ -#include "ftnoir_tracker_sm.h" -#include -#include "facetracknoir/global-settings.h" - -FTNoIR_Tracker::FTNoIR_Tracker() : lck_shm(SM_MM_DATA, SM_MUTEX, sizeof(SMMemMap)) -{ - pMemData = (SMMemMap*) lck_shm.mem; -} - -FTNoIR_Tracker::~FTNoIR_Tracker() -{ - qDebug() << "~FTNoIR_Tracker says: cleaning up"; - - bEnableRoll = true; - bEnablePitch = true; - bEnableYaw = true; - bEnableX = true; - bEnableY = true; - bEnableZ = true; -} - -void FTNoIR_Tracker::StartTracker(QFrame *videoframe ) -{ - qDebug() << "FTNoIR_Tracker::Initialize says: Starting "; - - loadSettings(); - - if ( pMemData != NULL ) { - pMemData->command = 0; // Reset any and all commands - if (videoframe != NULL) { - pMemData->handle = videoframe->winId(); // Handle of Videoframe widget - } - else { - pMemData->handle = NULL; // reset Handle of Videoframe widget - } - } - - // - // Start FTNoIR_FaceAPI_EXE.exe. The exe contains all faceAPI-stuff and is non-Qt... - // - // XXX TODO isolate it into separate directory - faceAPI = new QProcess(); - faceAPI->setWorkingDirectory(QCoreApplication::applicationDirPath() + "/faceapi"); - faceAPI->start("\"" + QCoreApplication::applicationDirPath() + "/faceapi/opentrack-faceapi-wrapper" + "\""); - // Show the video widget - qDebug() << "FTNoIR_Tracker::Initialize says: videoframe = " << videoframe; - - if (videoframe != NULL) { - videoframe->show(); - } - if ( pMemData != NULL ) { - pMemData->command = FT_SM_START; // Start command - } -} - -void FTNoIR_Tracker::WaitForExit() -{ - - qDebug() << "FTNoIR_Tracker::StopTracker says: Starting "; - // stops the faceapi engine - if ( pMemData != NULL ) { -// if (exit == true) { - pMemData->command = FT_SM_EXIT; - //} - //else { - // pMemData->command = FT_SM_STOP; // Issue 'stop' command - //} - } -} - -bool FTNoIR_Tracker::GiveHeadPoseData(double *data) -{ - // - // Check if the pointer is OK and wait for the Mutex. - // - lck_shm.lock(); - - // - // Copy the measurements to FaceTrackNoIR. - // - if (bEnableX) { - data[TX] = pMemData->data.new_pose.head_pos.x * 100.0f; // From meters to centimeters - } - if (bEnableY) { - data[TY] = pMemData->data.new_pose.head_pos.y * 100.0f; - } - if (bEnableZ) { - data[TZ] = pMemData->data.new_pose.head_pos.z * 100.0f; - } - if (bEnableYaw) { - data[Yaw] = pMemData->data.new_pose.head_rot.y_rads * 57.295781f; // From rads to degrees - } - if (bEnablePitch) { - data[Pitch] = pMemData->data.new_pose.head_rot.x_rads * 57.295781f; - } - if (bEnableRoll) { - data[Roll] = pMemData->data.new_pose.head_rot.z_rads * 57.295781f; - } - - // - // Reset the handshake, to let faceAPI know we're still here! - // - pMemData->handshake = 0; - lck_shm.unlock(); - - return ( pMemData->data.new_pose.confidence > 0 ); -} - -// -// Load the current Settings from the currently 'active' INI-file. -// -void FTNoIR_Tracker::loadSettings() { - - qDebug() << "FTNoIR_Tracker::loadSettings says: Starting "; - QSettings settings("opentrack"); // 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_Tracker::loadSettings says: iniFile = " << currentFile; - - iniFile.beginGroup ( "SMTracker" ); - if (pMemData) { - pMemData->initial_filter_level = iniFile.value ( "FilterLevel", 1 ).toInt(); - } - - 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 (); -} - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Tracker object. - -// Export both decorated and undecorated names. -// GetTracker - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetTracker@0 - Common name decoration for __stdcall functions in C language. -//#pragma comment(linker, "/export:GetTracker=_GetTracker@0") - -extern "C" FTNOIR_TRACKER_BASE_EXPORT ITracker* CALLING_CONVENTION GetConstructor() -{ - return new FTNoIR_Tracker; -} +/******************************************************************************** +* FaceTrackNoIR This program is a private project of some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2012 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage: http://facetracknoir.sourceforge.net/home/default.htm * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +********************************************************************************/ +#include "ftnoir_tracker_sm.h" +#include +#include "facetracknoir/global-settings.h" + +FTNoIR_Tracker::FTNoIR_Tracker() : lck_shm(SM_MM_DATA, SM_MUTEX, sizeof(SMMemMap)) +{ + pMemData = (SMMemMap*) lck_shm.mem; +} + +FTNoIR_Tracker::~FTNoIR_Tracker() +{ + qDebug() << "~FTNoIR_Tracker says: cleaning up"; + + bEnableRoll = true; + bEnablePitch = true; + bEnableYaw = true; + bEnableX = true; + bEnableY = true; + bEnableZ = true; +} + +void FTNoIR_Tracker::StartTracker(QFrame *videoframe ) +{ + qDebug() << "FTNoIR_Tracker::Initialize says: Starting "; + + loadSettings(); + + if ( pMemData != NULL ) { + pMemData->command = 0; // Reset any and all commands + if (videoframe != NULL) { + pMemData->handle = videoframe->winId(); // Handle of Videoframe widget + } + else { + pMemData->handle = NULL; // reset Handle of Videoframe widget + } + } + + // + // Start FTNoIR_FaceAPI_EXE.exe. The exe contains all faceAPI-stuff and is non-Qt... + // + // XXX TODO isolate it into separate directory + faceAPI = new QProcess(); + faceAPI->setWorkingDirectory(QCoreApplication::applicationDirPath() + "/faceapi"); + faceAPI->start("\"" + QCoreApplication::applicationDirPath() + "/faceapi/opentrack-faceapi-wrapper" + "\""); + // Show the video widget + qDebug() << "FTNoIR_Tracker::Initialize says: videoframe = " << videoframe; + + if (videoframe != NULL) { + videoframe->show(); + } + if ( pMemData != NULL ) { + pMemData->command = FT_SM_START; // Start command + } +} + +void FTNoIR_Tracker::WaitForExit() +{ + + qDebug() << "FTNoIR_Tracker::StopTracker says: Starting "; + // stops the faceapi engine + if ( pMemData != NULL ) { +// if (exit == true) { + pMemData->command = FT_SM_EXIT; + //} + //else { + // pMemData->command = FT_SM_STOP; // Issue 'stop' command + //} + } +} + +bool FTNoIR_Tracker::GiveHeadPoseData(double *data) +{ + // + // Check if the pointer is OK and wait for the Mutex. + // + lck_shm.lock(); + + // + // Copy the measurements to FaceTrackNoIR. + // + if (bEnableX) { + data[TX] = pMemData->data.new_pose.head_pos.x * 100.0f; // From meters to centimeters + } + if (bEnableY) { + data[TY] = pMemData->data.new_pose.head_pos.y * 100.0f; + } + if (bEnableZ) { + data[TZ] = pMemData->data.new_pose.head_pos.z * 100.0f; + } + if (bEnableYaw) { + data[Yaw] = pMemData->data.new_pose.head_rot.y_rads * 57.295781f; // From rads to degrees + } + if (bEnablePitch) { + data[Pitch] = pMemData->data.new_pose.head_rot.x_rads * 57.295781f; + } + if (bEnableRoll) { + data[Roll] = pMemData->data.new_pose.head_rot.z_rads * 57.295781f; + } + + // + // Reset the handshake, to let faceAPI know we're still here! + // + pMemData->handshake = 0; + lck_shm.unlock(); + + return ( pMemData->data.new_pose.confidence > 0 ); +} + +// +// Load the current Settings from the currently 'active' INI-file. +// +void FTNoIR_Tracker::loadSettings() { + + qDebug() << "FTNoIR_Tracker::loadSettings says: Starting "; + QSettings settings("opentrack"); // 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_Tracker::loadSettings says: iniFile = " << currentFile; + + iniFile.beginGroup ( "SMTracker" ); + if (pMemData) { + pMemData->initial_filter_level = iniFile.value ( "FilterLevel", 1 ).toInt(); + } + + 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 (); +} + +//////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Tracker object. + +// Export both decorated and undecorated names. +// GetTracker - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetTracker@0 - Common name decoration for __stdcall functions in C language. +//#pragma comment(linker, "/export:GetTracker=_GetTracker@0") + +extern "C" FTNOIR_TRACKER_BASE_EXPORT ITracker* CALLING_CONVENTION GetConstructor() +{ + return new FTNoIR_Tracker; +} diff --git a/ftnoir_tracker_sm/ftnoir_tracker_faceapi_dialog.cpp b/ftnoir_tracker_sm/ftnoir_tracker_faceapi_dialog.cpp index f515dedc..332a619e 100644 --- a/ftnoir_tracker_sm/ftnoir_tracker_faceapi_dialog.cpp +++ b/ftnoir_tracker_sm/ftnoir_tracker_faceapi_dialog.cpp @@ -1,282 +1,282 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2012 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage: http://facetracknoir.sourceforge.net/home/default.htm * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -********************************************************************************/ -#include "ftnoir_tracker_sm.h" -#include -#include "facetracknoir/global-settings.h" - -//******************************************************************************************************* -// faceAPI Client Settings-dialog. -//******************************************************************************************************* - -// -// Constructor for server-settings-dialog -// -TrackerControls::TrackerControls() : - QWidget(), - shm(SM_MM_DATA, SM_MUTEX, sizeof(TFaceData)) -{ - pMemData = (SMMemMap*) shm.mem; - - ui.setupUi( this ); - - theTracker = NULL; - prev_state = -1; - - // Connect Qt signals to member-functions - connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); - 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"); - ui.cbxFilterSetting->addItem("High"); - connect(ui.cbxFilterSetting, SIGNAL(currentIndexChanged(int)), this, SLOT(doSetFilter( int ))); - connect(ui.btnCameraSettings, SIGNAL(clicked()), this, SLOT(doShowCam())); - - //Setup the timer for showing the headpose. - timUpdateSettings = new QTimer(this); - connect(timUpdateSettings, SIGNAL(timeout()), this, SLOT(doTimUpdate())); - timUpdateSettings->start(100); - connect(this, SIGNAL(stateChanged( int )), this, SLOT(showSettings( int ))); - - connect(ui.chkEnableRoll, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.chkEnablePitch, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.chkEnableYaw, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.chkEnableX, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.chkEnableY, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.chkEnableZ, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); -} - -// -// Destructor for server-dialog -// -TrackerControls::~TrackerControls() { - qDebug() << "~TrackerControls() says: started"; -} - -// -// Initialize tracker-client-dialog -// -void TrackerControls::Initialize(QWidget *parent) { - - QPoint offsetpos(200, 200); - if (parent) { - this->move(parent->pos() + offsetpos); - } - - // Load the settings from the current .INI-file - loadSettings(); - - show(); -} - -// -// OK clicked on server-dialog -// -void TrackerControls::doOK() { - save(); - this->close(); -} - -// override show event -void TrackerControls::showEvent ( QShowEvent * event ) { - prev_state = -1; - loadSettings(); -} - -// -// Cancel clicked on server-dialog -// -void TrackerControls::doCancel() { - // - // Ask if changed Settings should be saved - // - if (settingsDirty) { - int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard ); - - qDebug() << "doCancel says: answer =" << ret; - - switch (ret) { - case QMessageBox::Save: - save(); - this->close(); - break; - case QMessageBox::Discard: - this->close(); - break; - case QMessageBox::Cancel: - // Cancel was clicked - break; - default: - // should never be reached - break; - } - } - else { - this->close(); - } -} - -// -// Load the current Settings from the currently 'active' INI-file. -// -void TrackerControls::loadSettings() { - -// qDebug() << "loadSettings says: Starting "; - QSettings settings("opentrack"); // 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; - - iniFile.beginGroup ( "SMTracker" ); - ui.cbxFilterSetting->setCurrentIndex(iniFile.value ( "FilterLevel", 1 ).toInt()); - - 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.endGroup (); - - settingsDirty = false; -} - -// -// Save the current Settings to the currently 'active' INI-file. -// -void TrackerControls::save() { - - QSettings settings("opentrack"); // 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) - - iniFile.beginGroup ( "SMTracker" ); - iniFile.setValue ( "FilterLevel", ui.cbxFilterSetting->currentIndex() ); - - 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() ); - - iniFile.endGroup (); - - // - // If the Tracker is active, let it load the new Settings. - // - if (theTracker) { - theTracker->loadSettings(); - } - - settingsDirty = false; -} - -// Show the current engine-settings etc. -// -void TrackerControls::doTimUpdate() -{ - int state = pMemData->state; - if ( state != prev_state) { - emit stateChanged(state); - prev_state = state; - } -} - -// -// Show the current engine-settings etc. -// -void TrackerControls::showSettings( int newState ) -{ - qDebug() << "TrackerControls::showSettings says: Starting Function"; - switch (newState) - { - case SM_API_ENGINE_STATE_TERMINATED: - ui._engine_state_label->setText("TERMINATED"); - break; - case SM_API_ENGINE_STATE_INVALID: - ui._engine_state_label->setText("INVALID"); - break; - case SM_API_ENGINE_STATE_IDLE: - ui._engine_state_label->setText("IDLE"); - break; - case SM_API_ENGINE_STATE_HT_INITIALIZING: - ui._engine_state_label->setText("INITIALIZING"); - break; - case SM_API_ENGINE_STATE_HT_TRACKING: - ui._engine_state_label->setText("TRACKING"); - break; - case SM_API_ENGINE_STATE_HT_SEARCHING: - ui._engine_state_label->setText("SEARCHING"); - break; - default: - ui._engine_state_label->setText("Unknown State!"); - break; - } - - ui.cbxFilterSetting->setEnabled( (newState == SM_API_ENGINE_STATE_IDLE) ); -} - -// -// Send a command without parameter-value to the tracking Engine. -// -void TrackerControls::doCommand(int command) -{ - shm.lock(); - pMemData->command = command; - shm.unlock(); -} - -// -// Send a command with integer parameter-value to the tracking Engine. -// -void TrackerControls::doCommand(int command, int value) -{ - shm.lock(); - pMemData->command = command; // Send command - pMemData->par_val_int = value; - shm.unlock(); -} - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Tracker-settings dialog object. - -// Export both decorated and undecorated names. -// GetTrackerDialog - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetTrackerDialog@0 - Common name decoration for __stdcall functions in C language. -//#pragma comment(linker, "/export:GetTrackerDialog=_GetTrackerDialog@0") - -extern "C" FTNOIR_TRACKER_BASE_EXPORT ITrackerDialog* CALLING_CONVENTION GetDialog() -{ - return new TrackerControls; -} +/******************************************************************************** +* FaceTrackNoIR This program is a private project of some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2012 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage: http://facetracknoir.sourceforge.net/home/default.htm * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +********************************************************************************/ +#include "ftnoir_tracker_sm.h" +#include +#include "facetracknoir/global-settings.h" + +//******************************************************************************************************* +// faceAPI Client Settings-dialog. +//******************************************************************************************************* + +// +// Constructor for server-settings-dialog +// +TrackerControls::TrackerControls() : + QWidget(), + shm(SM_MM_DATA, SM_MUTEX, sizeof(TFaceData)) +{ + pMemData = (SMMemMap*) shm.mem; + + ui.setupUi( this ); + + theTracker = NULL; + prev_state = -1; + + // Connect Qt signals to member-functions + connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); + 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"); + ui.cbxFilterSetting->addItem("High"); + connect(ui.cbxFilterSetting, SIGNAL(currentIndexChanged(int)), this, SLOT(doSetFilter( int ))); + connect(ui.btnCameraSettings, SIGNAL(clicked()), this, SLOT(doShowCam())); + + //Setup the timer for showing the headpose. + timUpdateSettings = new QTimer(this); + connect(timUpdateSettings, SIGNAL(timeout()), this, SLOT(doTimUpdate())); + timUpdateSettings->start(100); + connect(this, SIGNAL(stateChanged( int )), this, SLOT(showSettings( int ))); + + connect(ui.chkEnableRoll, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); + connect(ui.chkEnablePitch, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); + connect(ui.chkEnableYaw, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); + connect(ui.chkEnableX, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); + connect(ui.chkEnableY, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); + connect(ui.chkEnableZ, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); +} + +// +// Destructor for server-dialog +// +TrackerControls::~TrackerControls() { + qDebug() << "~TrackerControls() says: started"; +} + +// +// Initialize tracker-client-dialog +// +void TrackerControls::Initialize(QWidget *parent) { + + QPoint offsetpos(200, 200); + if (parent) { + this->move(parent->pos() + offsetpos); + } + + // Load the settings from the current .INI-file + loadSettings(); + + show(); +} + +// +// OK clicked on server-dialog +// +void TrackerControls::doOK() { + save(); + this->close(); +} + +// override show event +void TrackerControls::showEvent ( QShowEvent * event ) { + prev_state = -1; + loadSettings(); +} + +// +// Cancel clicked on server-dialog +// +void TrackerControls::doCancel() { + // + // Ask if changed Settings should be saved + // + if (settingsDirty) { + int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard ); + + qDebug() << "doCancel says: answer =" << ret; + + switch (ret) { + case QMessageBox::Save: + save(); + this->close(); + break; + case QMessageBox::Discard: + this->close(); + break; + case QMessageBox::Cancel: + // Cancel was clicked + break; + default: + // should never be reached + break; + } + } + else { + this->close(); + } +} + +// +// Load the current Settings from the currently 'active' INI-file. +// +void TrackerControls::loadSettings() { + +// qDebug() << "loadSettings says: Starting "; + QSettings settings("opentrack"); // 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; + + iniFile.beginGroup ( "SMTracker" ); + ui.cbxFilterSetting->setCurrentIndex(iniFile.value ( "FilterLevel", 1 ).toInt()); + + 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.endGroup (); + + settingsDirty = false; +} + +// +// Save the current Settings to the currently 'active' INI-file. +// +void TrackerControls::save() { + + QSettings settings("opentrack"); // 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) + + iniFile.beginGroup ( "SMTracker" ); + iniFile.setValue ( "FilterLevel", ui.cbxFilterSetting->currentIndex() ); + + 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() ); + + iniFile.endGroup (); + + // + // If the Tracker is active, let it load the new Settings. + // + if (theTracker) { + theTracker->loadSettings(); + } + + settingsDirty = false; +} + +// Show the current engine-settings etc. +// +void TrackerControls::doTimUpdate() +{ + int state = pMemData->state; + if ( state != prev_state) { + emit stateChanged(state); + prev_state = state; + } +} + +// +// Show the current engine-settings etc. +// +void TrackerControls::showSettings( int newState ) +{ + qDebug() << "TrackerControls::showSettings says: Starting Function"; + switch (newState) + { + case SM_API_ENGINE_STATE_TERMINATED: + ui._engine_state_label->setText("TERMINATED"); + break; + case SM_API_ENGINE_STATE_INVALID: + ui._engine_state_label->setText("INVALID"); + break; + case SM_API_ENGINE_STATE_IDLE: + ui._engine_state_label->setText("IDLE"); + break; + case SM_API_ENGINE_STATE_HT_INITIALIZING: + ui._engine_state_label->setText("INITIALIZING"); + break; + case SM_API_ENGINE_STATE_HT_TRACKING: + ui._engine_state_label->setText("TRACKING"); + break; + case SM_API_ENGINE_STATE_HT_SEARCHING: + ui._engine_state_label->setText("SEARCHING"); + break; + default: + ui._engine_state_label->setText("Unknown State!"); + break; + } + + ui.cbxFilterSetting->setEnabled( (newState == SM_API_ENGINE_STATE_IDLE) ); +} + +// +// Send a command without parameter-value to the tracking Engine. +// +void TrackerControls::doCommand(int command) +{ + shm.lock(); + pMemData->command = command; + shm.unlock(); +} + +// +// Send a command with integer parameter-value to the tracking Engine. +// +void TrackerControls::doCommand(int command, int value) +{ + shm.lock(); + pMemData->command = command; // Send command + pMemData->par_val_int = value; + shm.unlock(); +} + +//////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Tracker-settings dialog object. + +// Export both decorated and undecorated names. +// GetTrackerDialog - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetTrackerDialog@0 - Common name decoration for __stdcall functions in C language. +//#pragma comment(linker, "/export:GetTrackerDialog=_GetTrackerDialog@0") + +extern "C" FTNOIR_TRACKER_BASE_EXPORT ITrackerDialog* CALLING_CONVENTION GetDialog() +{ + return new TrackerControls; +} diff --git a/ftnoir_tracker_sm/ftnoir_tracker_faceapi_dll.cpp b/ftnoir_tracker_sm/ftnoir_tracker_faceapi_dll.cpp index a878a468..b1ab1d75 100644 --- a/ftnoir_tracker_sm/ftnoir_tracker_faceapi_dll.cpp +++ b/ftnoir_tracker_sm/ftnoir_tracker_faceapi_dll.cpp @@ -1,72 +1,72 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2012 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -********************************************************************************/ -#include "ftnoir_tracker_sm.h" -#include -#include "facetracknoir/global-settings.h" - -FTNoIR_TrackerDll::FTNoIR_TrackerDll() { - //populate the description strings - trackerFullName = "faceAPI V3.2.6"; - trackerShortName = "faceAPI"; - trackerDescription = "SeeingMachines faceAPI V3.2.6"; -} - -FTNoIR_TrackerDll::~FTNoIR_TrackerDll() -{ - -} -void FTNoIR_TrackerDll::getFullName(QString *strToBeFilled) -{ - *strToBeFilled = trackerFullName; -}; - -void FTNoIR_TrackerDll::getShortName(QString *strToBeFilled) -{ - *strToBeFilled = trackerShortName; -}; - -void FTNoIR_TrackerDll::getDescription(QString *strToBeFilled) -{ - *strToBeFilled = trackerDescription; -}; - -void FTNoIR_TrackerDll::getIcon(QIcon *icon) -{ - *icon = QIcon(":/images/sm.png"); -}; - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Tracker object. - -// Export both decorated and undecorated names. -// GetTrackerDll - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetTrackerDll@0 - Common name decoration for __stdcall functions in C language. -//#pragma comment(linker, "/export:GetTrackerDll=_GetTrackerDll@0") - -extern "C" FTNOIR_TRACKER_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata() -{ - return new FTNoIR_TrackerDll; -} +/******************************************************************************** +* FaceTrackNoIR This program is a private project of some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2012 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +********************************************************************************/ +#include "ftnoir_tracker_sm.h" +#include +#include "facetracknoir/global-settings.h" + +FTNoIR_TrackerDll::FTNoIR_TrackerDll() { + //populate the description strings + trackerFullName = "faceAPI V3.2.6"; + trackerShortName = "faceAPI"; + trackerDescription = "SeeingMachines faceAPI V3.2.6"; +} + +FTNoIR_TrackerDll::~FTNoIR_TrackerDll() +{ + +} +void FTNoIR_TrackerDll::getFullName(QString *strToBeFilled) +{ + *strToBeFilled = trackerFullName; +}; + +void FTNoIR_TrackerDll::getShortName(QString *strToBeFilled) +{ + *strToBeFilled = trackerShortName; +}; + +void FTNoIR_TrackerDll::getDescription(QString *strToBeFilled) +{ + *strToBeFilled = trackerDescription; +}; + +void FTNoIR_TrackerDll::getIcon(QIcon *icon) +{ + *icon = QIcon(":/images/sm.png"); +}; + +//////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Tracker object. + +// Export both decorated and undecorated names. +// GetTrackerDll - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetTrackerDll@0 - Common name decoration for __stdcall functions in C language. +//#pragma comment(linker, "/export:GetTrackerDll=_GetTrackerDll@0") + +extern "C" FTNOIR_TRACKER_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata() +{ + return new FTNoIR_TrackerDll; +} diff --git a/ftnoir_tracker_sm/ftnoir_tracker_sm.h b/ftnoir_tracker_sm/ftnoir_tracker_sm.h index 33cfb9ef..5d692ea0 100644 --- a/ftnoir_tracker_sm/ftnoir_tracker_sm.h +++ b/ftnoir_tracker_sm/ftnoir_tracker_sm.h @@ -1,156 +1,156 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2012 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage: http://facetracknoir.sourceforge.net/home/default.htm * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -********************************************************************************/ -#include "..\ftnoir_tracker_base\ftnoir_tracker_base.h" -#include "..\ftnoir_tracker_base\ftnoir_tracker_sm_types.h" -#include "ui_FTNoIR_SM_controls.h" - -#include -#include -#include -#include "Windows.h" -#include "math.h" -#include "facetracknoir/global-settings.h" -#include "compat/compat.h" -#include - -using namespace std; - -class FTNoIR_Tracker : public ITracker -{ -public: - FTNoIR_Tracker(); - ~FTNoIR_Tracker(); - - void StartTracker( QFrame* parent_window ); - void StopTracker( bool exit ); - bool GiveHeadPoseData(double *data); // Returns true if confidence is good - void WaitForExit(); - - void loadSettings(); - -private: - // - // global variables - // - PortableLockedShm lck_shm; - SMMemMap *pMemData; - QProcess *faceAPI; - - bool bEnableRoll; - bool bEnablePitch; - bool bEnableYaw; - bool bEnableX; - bool bEnableY; - bool bEnableZ; -}; - -// Widget that has controls for SMoIR protocol client-settings. -class TrackerControls: public QWidget, public ITrackerDialog -{ - Q_OBJECT -public: - - explicit TrackerControls(); - virtual ~TrackerControls(); - void showEvent ( QShowEvent * event ); - - void Initialize(QWidget *parent); - void registerTracker(ITracker *tracker) { - theTracker = (FTNoIR_Tracker *) tracker; // Accept the pointer to the Tracker - } - void unRegisterTracker() { - theTracker = NULL; // Reset the pointer - } - -private: - Ui::UICSMClientControls ui; - void loadSettings(); - void doCommand( int command ); - void doCommand( int command, int value ); - - /** helper **/ - bool settingsDirty; - int prev_state; // Previous engine state - - // - // global variables - // - SMMemMap *pMemData; - - smEngineHandle *engine_handle; - QTimer *timUpdateSettings; // Timer to display current settings - - FTNoIR_Tracker *theTracker; - PortableLockedShm shm; - -private slots: - void doOK(); - void doCancel(); - void save(); - void settingChanged() { settingsDirty = true; } - void doTimUpdate(); - void showSettings( int newState ); - void doStartEngine(){ - doCommand(FT_SM_START); - } - void doStopEngine(){ - doCommand(FT_SM_STOP); - } - void doShowCam(){ - doCommand(FT_SM_SHOW_CAM); - } - void doSetFilter(int value){ - doCommand(FT_SM_SET_PAR_FILTER, value); - } - void settingChanged(int dummy) { - settingsDirty = true; - } - -signals: - void stateChanged(int newState); - -}; - -//******************************************************************************************************* -// FaceTrackNoIR Tracker DLL. Functions used to get general info on the Tracker -//******************************************************************************************************* -class FTNoIR_TrackerDll : public Metadata -{ -public: - FTNoIR_TrackerDll(); - ~FTNoIR_TrackerDll(); - - void Initialize(); - - void getFullName(QString *strToBeFilled); - void getShortName(QString *strToBeFilled); - void getDescription(QString *strToBeFilled); - void getIcon(QIcon *icon); - -private: - QString trackerFullName; // Trackers' name and description - QString trackerShortName; - QString trackerDescription; -}; +/******************************************************************************** +* FaceTrackNoIR This program is a private project of some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2012 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage: http://facetracknoir.sourceforge.net/home/default.htm * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +********************************************************************************/ +#include "..\ftnoir_tracker_base\ftnoir_tracker_base.h" +#include "..\ftnoir_tracker_base\ftnoir_tracker_sm_types.h" +#include "ui_FTNoIR_SM_controls.h" + +#include +#include +#include +#include "Windows.h" +#include "math.h" +#include "facetracknoir/global-settings.h" +#include "compat/compat.h" +#include + +using namespace std; + +class FTNoIR_Tracker : public ITracker +{ +public: + FTNoIR_Tracker(); + ~FTNoIR_Tracker(); + + void StartTracker( QFrame* parent_window ); + void StopTracker( bool exit ); + bool GiveHeadPoseData(double *data); // Returns true if confidence is good + void WaitForExit(); + + void loadSettings(); + +private: + // + // global variables + // + PortableLockedShm lck_shm; + SMMemMap *pMemData; + QProcess *faceAPI; + + bool bEnableRoll; + bool bEnablePitch; + bool bEnableYaw; + bool bEnableX; + bool bEnableY; + bool bEnableZ; +}; + +// Widget that has controls for SMoIR protocol client-settings. +class TrackerControls: public QWidget, public ITrackerDialog +{ + Q_OBJECT +public: + + explicit TrackerControls(); + virtual ~TrackerControls(); + void showEvent ( QShowEvent * event ); + + void Initialize(QWidget *parent); + void registerTracker(ITracker *tracker) { + theTracker = (FTNoIR_Tracker *) tracker; // Accept the pointer to the Tracker + } + void unRegisterTracker() { + theTracker = NULL; // Reset the pointer + } + +private: + Ui::UICSMClientControls ui; + void loadSettings(); + void doCommand( int command ); + void doCommand( int command, int value ); + + /** helper **/ + bool settingsDirty; + int prev_state; // Previous engine state + + // + // global variables + // + SMMemMap *pMemData; + + smEngineHandle *engine_handle; + QTimer *timUpdateSettings; // Timer to display current settings + + FTNoIR_Tracker *theTracker; + PortableLockedShm shm; + +private slots: + void doOK(); + void doCancel(); + void save(); + void settingChanged() { settingsDirty = true; } + void doTimUpdate(); + void showSettings( int newState ); + void doStartEngine(){ + doCommand(FT_SM_START); + } + void doStopEngine(){ + doCommand(FT_SM_STOP); + } + void doShowCam(){ + doCommand(FT_SM_SHOW_CAM); + } + void doSetFilter(int value){ + doCommand(FT_SM_SET_PAR_FILTER, value); + } + void settingChanged(int dummy) { + settingsDirty = true; + } + +signals: + void stateChanged(int newState); + +}; + +//******************************************************************************************************* +// FaceTrackNoIR Tracker DLL. Functions used to get general info on the Tracker +//******************************************************************************************************* +class FTNoIR_TrackerDll : public Metadata +{ +public: + FTNoIR_TrackerDll(); + ~FTNoIR_TrackerDll(); + + void Initialize(); + + void getFullName(QString *strToBeFilled); + void getShortName(QString *strToBeFilled); + void getDescription(QString *strToBeFilled); + void getIcon(QIcon *icon); + +private: + QString trackerFullName; // Trackers' name and description + QString trackerShortName; + QString trackerDescription; +}; diff --git a/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp b/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp index 83f518fa..1364ee1c 100644 --- a/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp +++ b/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp @@ -1,173 +1,173 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2012 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage: http://facetracknoir.sourceforge.net/home/default.htm * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -********************************************************************************/ -#include "ftnoir_tracker_udp.h" -#include "facetracknoir/global-settings.h" - -FTNoIR_Tracker::FTNoIR_Tracker() -{ - inSocket = 0; - outSocket = 0; - - bEnableRoll = true; - bEnablePitch = true; - bEnableYaw = true; - bEnableX = true; - bEnableY = true; - bEnableZ = true; - portAddress = 5551; - should_quit = false; - - for (int i = 0; i < 6; i++) - newHeadPose[i] = 0; -} - -FTNoIR_Tracker::~FTNoIR_Tracker() -{ - if (inSocket) { - inSocket->close(); - delete inSocket; - } - - if (outSocket) { - outSocket->close(); - delete outSocket; - } -} - -/** QThread run @override **/ -void FTNoIR_Tracker::run() { - -QHostAddress sender; -quint16 senderPort; - - // - // Read the data that was received. - // - forever { - if (should_quit) - break; - if (inSocket != 0) { - while (inSocket->hasPendingDatagrams()) { - - QByteArray datagram; - datagram.resize(inSocket->pendingDatagramSize()); - mutex.lock(); - inSocket->readDatagram( (char * ) &newHeadPose, sizeof(newHeadPose), &sender, &senderPort); - mutex.unlock(); - } - } - else { - break; - } - - usleep(10000); - } -} - -void FTNoIR_Tracker::StartTracker(QFrame* videoFrame) -{ - loadSettings(); - // - // Create UDP-sockets if they don't exist already. - // They must be created here, because they must be in the new thread (FTNoIR_Tracker::run()) - // - if (inSocket == 0) { - qDebug() << "FTNoIR_Tracker::Initialize() creating insocket"; - inSocket = new QUdpSocket(); - // Connect the inSocket to the port, to receive messages - - if (!inSocket->bind(QHostAddress::Any, (int) portAddress, QUdpSocket::ShareAddress | QUdpSocket::ReuseAddressHint)) { - QMessageBox::warning(0,"FaceTrackNoIR Error", "Unable to bind UDP-port",QMessageBox::Ok,QMessageBox::NoButton); - delete inSocket; - inSocket = 0; - } - } - start(); - return; -} - -bool FTNoIR_Tracker::GiveHeadPoseData(double *data) -{ - mutex.lock(); - if (bEnableX) { - data[TX] = newHeadPose[TX]; - } - if (bEnableX) { - data[TY] = newHeadPose[TY]; - } - if (bEnableX) { - data[TZ] = newHeadPose[TZ]; - } - if (bEnableYaw) { - data[Yaw] = newHeadPose[Yaw]; - } - if (bEnablePitch) { - data[Pitch] = newHeadPose[Pitch]; - } - if (bEnableRoll) { - data[Roll] = newHeadPose[Roll]; - } - mutex.unlock(); - return true; -} - -// -// Load the current Settings from the currently 'active' INI-file. -// -void FTNoIR_Tracker::loadSettings() { - - qDebug() << "FTNoIR_Tracker::loadSettings says: Starting "; - QSettings settings("opentrack"); // 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_Tracker::loadSettings says: iniFile = " << currentFile; - - iniFile.beginGroup ( "FTNClient" ); - 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(); - portAddress = (float) iniFile.value ( "PortNumber", 5550 ).toInt(); - iniFile.endGroup (); -} - - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Tracker object. - -// Export both decorated and undecorated names. -// GetTracker - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetTracker@0 - Common name decoration for __stdcall functions in C language. -//#pragma comment(linker, "/export:GetTracker=_GetTracker@0") - -extern "C" FTNOIR_TRACKER_BASE_EXPORT ITracker* CALLING_CONVENTION GetConstructor() -{ - return new FTNoIR_Tracker; -} +/******************************************************************************** +* FaceTrackNoIR This program is a private project of some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2012 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage: http://facetracknoir.sourceforge.net/home/default.htm * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +********************************************************************************/ +#include "ftnoir_tracker_udp.h" +#include "facetracknoir/global-settings.h" + +FTNoIR_Tracker::FTNoIR_Tracker() +{ + inSocket = 0; + outSocket = 0; + + bEnableRoll = true; + bEnablePitch = true; + bEnableYaw = true; + bEnableX = true; + bEnableY = true; + bEnableZ = true; + portAddress = 5551; + should_quit = false; + + for (int i = 0; i < 6; i++) + newHeadPose[i] = 0; +} + +FTNoIR_Tracker::~FTNoIR_Tracker() +{ + if (inSocket) { + inSocket->close(); + delete inSocket; + } + + if (outSocket) { + outSocket->close(); + delete outSocket; + } +} + +/** QThread run @override **/ +void FTNoIR_Tracker::run() { + +QHostAddress sender; +quint16 senderPort; + + // + // Read the data that was received. + // + forever { + if (should_quit) + break; + if (inSocket != 0) { + while (inSocket->hasPendingDatagrams()) { + + QByteArray datagram; + datagram.resize(inSocket->pendingDatagramSize()); + mutex.lock(); + inSocket->readDatagram( (char * ) &newHeadPose, sizeof(newHeadPose), &sender, &senderPort); + mutex.unlock(); + } + } + else { + break; + } + + usleep(10000); + } +} + +void FTNoIR_Tracker::StartTracker(QFrame* videoFrame) +{ + loadSettings(); + // + // Create UDP-sockets if they don't exist already. + // They must be created here, because they must be in the new thread (FTNoIR_Tracker::run()) + // + if (inSocket == 0) { + qDebug() << "FTNoIR_Tracker::Initialize() creating insocket"; + inSocket = new QUdpSocket(); + // Connect the inSocket to the port, to receive messages + + if (!inSocket->bind(QHostAddress::Any, (int) portAddress, QUdpSocket::ShareAddress | QUdpSocket::ReuseAddressHint)) { + QMessageBox::warning(0,"FaceTrackNoIR Error", "Unable to bind UDP-port",QMessageBox::Ok,QMessageBox::NoButton); + delete inSocket; + inSocket = 0; + } + } + start(); + return; +} + +bool FTNoIR_Tracker::GiveHeadPoseData(double *data) +{ + mutex.lock(); + if (bEnableX) { + data[TX] = newHeadPose[TX]; + } + if (bEnableX) { + data[TY] = newHeadPose[TY]; + } + if (bEnableX) { + data[TZ] = newHeadPose[TZ]; + } + if (bEnableYaw) { + data[Yaw] = newHeadPose[Yaw]; + } + if (bEnablePitch) { + data[Pitch] = newHeadPose[Pitch]; + } + if (bEnableRoll) { + data[Roll] = newHeadPose[Roll]; + } + mutex.unlock(); + return true; +} + +// +// Load the current Settings from the currently 'active' INI-file. +// +void FTNoIR_Tracker::loadSettings() { + + qDebug() << "FTNoIR_Tracker::loadSettings says: Starting "; + QSettings settings("opentrack"); // 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_Tracker::loadSettings says: iniFile = " << currentFile; + + iniFile.beginGroup ( "FTNClient" ); + 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(); + portAddress = (float) iniFile.value ( "PortNumber", 5550 ).toInt(); + iniFile.endGroup (); +} + + +//////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Tracker object. + +// Export both decorated and undecorated names. +// GetTracker - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetTracker@0 - Common name decoration for __stdcall functions in C language. +//#pragma comment(linker, "/export:GetTracker=_GetTracker@0") + +extern "C" FTNOIR_TRACKER_BASE_EXPORT ITracker* CALLING_CONVENTION GetConstructor() +{ + return new FTNoIR_Tracker; +} diff --git a/ftnoir_tracker_udp/ftnoir_tracker_udp.h b/ftnoir_tracker_udp/ftnoir_tracker_udp.h index c4c85372..76fcacf2 100644 --- a/ftnoir_tracker_udp/ftnoir_tracker_udp.h +++ b/ftnoir_tracker_udp/ftnoir_tracker_udp.h @@ -1,97 +1,97 @@ -#include "ftnoir_tracker_base/ftnoir_tracker_base.h" -#include "ui_ftnoir_ftnclientcontrols.h" -#include -#include -#include -#include -#include -#include -#include -#include "facetracknoir/global-settings.h" - -class FTNoIR_Tracker : public ITracker, public QThread -{ -public: - FTNoIR_Tracker(); - ~FTNoIR_Tracker(); - - void StartTracker( QFrame *videoframe ); - bool GiveHeadPoseData(double *data); - void loadSettings(); - volatile bool should_quit; - void WaitForExit() { - should_quit = true; - wait(); - } - -protected: - void run(); // qthread override run method - -private: - // UDP socket-variables - QUdpSocket *inSocket; // Receive from ... - QUdpSocket *outSocket; // Send to ... - QHostAddress destIP; // Destination IP-address - QHostAddress srcIP; // Source IP-address - - double newHeadPose[6]; // Structure with new headpose - - float portAddress; // Port-number - bool bEnableRoll; - bool bEnablePitch; - bool bEnableYaw; - bool bEnableX; - bool bEnableY; - bool bEnableZ; - QMutex mutex; -}; - -// Widget that has controls for FTNoIR protocol client-settings. -class TrackerControls: public QWidget, public ITrackerDialog -{ - Q_OBJECT -public: - - explicit TrackerControls(); - ~TrackerControls(); - void showEvent ( QShowEvent * event ); - - void Initialize(QWidget *parent); - void registerTracker(ITracker *tracker) {}; - void unRegisterTracker() {}; - -private: - Ui::UICFTNClientControls ui; - void loadSettings(); - void save(); - - /** helper **/ - bool settingsDirty; - -private slots: - void doOK(); - void doCancel(); - void settingChanged() { settingsDirty = true; }; - void settingChanged(int) { settingsDirty = true; }; -}; - -//******************************************************************************************************* -// FaceTrackNoIR Tracker DLL. Functions used to get general info on the Tracker -//******************************************************************************************************* -class FTNoIR_TrackerDll : public Metadata -{ -public: - FTNoIR_TrackerDll(); - ~FTNoIR_TrackerDll(); - - void getFullName(QString *strToBeFilled); - void getShortName(QString *strToBeFilled); - void getDescription(QString *strToBeFilled); - void getIcon(QIcon *icon); - -private: - QString trackerFullName; // Trackers' name and description - QString trackerShortName; - QString trackerDescription; -}; - +#include "ftnoir_tracker_base/ftnoir_tracker_base.h" +#include "ui_ftnoir_ftnclientcontrols.h" +#include +#include +#include +#include +#include +#include +#include +#include "facetracknoir/global-settings.h" + +class FTNoIR_Tracker : public ITracker, public QThread +{ +public: + FTNoIR_Tracker(); + ~FTNoIR_Tracker(); + + void StartTracker( QFrame *videoframe ); + bool GiveHeadPoseData(double *data); + void loadSettings(); + volatile bool should_quit; + void WaitForExit() { + should_quit = true; + wait(); + } + +protected: + void run(); // qthread override run method + +private: + // UDP socket-variables + QUdpSocket *inSocket; // Receive from ... + QUdpSocket *outSocket; // Send to ... + QHostAddress destIP; // Destination IP-address + QHostAddress srcIP; // Source IP-address + + double newHeadPose[6]; // Structure with new headpose + + float portAddress; // Port-number + bool bEnableRoll; + bool bEnablePitch; + bool bEnableYaw; + bool bEnableX; + bool bEnableY; + bool bEnableZ; + QMutex mutex; +}; + +// Widget that has controls for FTNoIR protocol client-settings. +class TrackerControls: public QWidget, public ITrackerDialog +{ + Q_OBJECT +public: + + explicit TrackerControls(); + ~TrackerControls(); + void showEvent ( QShowEvent * event ); + + void Initialize(QWidget *parent); + void registerTracker(ITracker *tracker) {}; + void unRegisterTracker() {}; + +private: + Ui::UICFTNClientControls ui; + void loadSettings(); + void save(); + + /** helper **/ + bool settingsDirty; + +private slots: + void doOK(); + void doCancel(); + void settingChanged() { settingsDirty = true; }; + void settingChanged(int) { settingsDirty = true; }; +}; + +//******************************************************************************************************* +// FaceTrackNoIR Tracker DLL. Functions used to get general info on the Tracker +//******************************************************************************************************* +class FTNoIR_TrackerDll : public Metadata +{ +public: + FTNoIR_TrackerDll(); + ~FTNoIR_TrackerDll(); + + void getFullName(QString *strToBeFilled); + void getShortName(QString *strToBeFilled); + void getDescription(QString *strToBeFilled); + void getIcon(QIcon *icon); + +private: + QString trackerFullName; // Trackers' name and description + QString trackerShortName; + QString trackerDescription; +}; + diff --git a/ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp b/ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp index 4fe0d8c8..5c0d7b1c 100644 --- a/ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp +++ b/ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp @@ -1,182 +1,182 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2012 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage: http://facetracknoir.sourceforge.net/home/default.htm * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -********************************************************************************/ -#include "ftnoir_tracker_udp.h" -#include "facetracknoir/global-settings.h" - -//******************************************************************************************************* -// FaceTrackNoIR Client Settings-dialog. -//******************************************************************************************************* - -// -// Constructor for server-settings-dialog -// -TrackerControls::TrackerControls() : -QWidget() -{ - ui.setupUi( this ); - - // Connect Qt signals to member-functions - connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); - connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); - connect(ui.spinPortNumber, SIGNAL(valueChanged(int)), this, SLOT(settingChanged())); - - connect(ui.chkEnableRoll, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.chkEnablePitch, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.chkEnableYaw, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.chkEnableX, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.chkEnableY, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.chkEnableZ, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); - - // Load the settings from the current .INI-file - loadSettings(); -} - -// -// Destructor for server-dialog -// -TrackerControls::~TrackerControls() { - qDebug() << "~TrackerControls() says: started"; -} - -// -// Initialize tracker-client-dialog -// -void TrackerControls::Initialize(QWidget *parent) { - - QPoint offsetpos(100, 100); - if (parent) { - this->move(parent->pos() + offsetpos); - } - show(); -} - -// -// OK clicked on server-dialog -// -void TrackerControls::doOK() { - save(); - this->close(); -} - -// override show event -void TrackerControls::showEvent ( QShowEvent * event ) { - loadSettings(); -} - -// -// Cancel clicked on server-dialog -// -void TrackerControls::doCancel() { - // - // Ask if changed Settings should be saved - // - if (settingsDirty) { - int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard ); - - qDebug() << "doCancel says: answer =" << ret; - - switch (ret) { - case QMessageBox::Save: - save(); - this->close(); - break; - case QMessageBox::Discard: - this->close(); - break; - case QMessageBox::Cancel: - // Cancel was clicked - break; - default: - // should never be reached - break; - } - } - else { - this->close(); - } -} - - -// -// Load the current Settings from the currently 'active' INI-file. -// -void TrackerControls::loadSettings() { - -// qDebug() << "loadSettings says: Starting "; - QSettings settings("opentrack"); // 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; - - iniFile.beginGroup ( "FTNClient" ); - 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()); - - ui.spinPortNumber->setValue( iniFile.value ( "PortNumber", 5550 ).toInt() ); - iniFile.endGroup (); - - settingsDirty = false; -} - -// -// Save the current Settings to the currently 'active' INI-file. -// -void TrackerControls::save() { - QSettings settings("opentrack"); // 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) - - iniFile.beginGroup ( "FTNClient" ); - 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() ); - iniFile.setValue ( "PortNumber", ui.spinPortNumber->value() ); - iniFile.endGroup (); - - settingsDirty = false; -} -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Tracker-settings dialog object. - -// Export both decorated and undecorated names. -// GetTrackerDialog - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetTrackerDialog@0 - Common name decoration for __stdcall functions in C language. -//#pragma comment(linker, "/export:GetTrackerDialog=_GetTrackerDialog@0") - -extern "C" FTNOIR_TRACKER_BASE_EXPORT ITrackerDialog* CALLING_CONVENTION GetDialog( ) -{ - return new TrackerControls; -} +/******************************************************************************** +* FaceTrackNoIR This program is a private project of some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2012 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage: http://facetracknoir.sourceforge.net/home/default.htm * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +********************************************************************************/ +#include "ftnoir_tracker_udp.h" +#include "facetracknoir/global-settings.h" + +//******************************************************************************************************* +// FaceTrackNoIR Client Settings-dialog. +//******************************************************************************************************* + +// +// Constructor for server-settings-dialog +// +TrackerControls::TrackerControls() : +QWidget() +{ + ui.setupUi( this ); + + // Connect Qt signals to member-functions + connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); + connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); + connect(ui.spinPortNumber, SIGNAL(valueChanged(int)), this, SLOT(settingChanged())); + + connect(ui.chkEnableRoll, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); + connect(ui.chkEnablePitch, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); + connect(ui.chkEnableYaw, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); + connect(ui.chkEnableX, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); + connect(ui.chkEnableY, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); + connect(ui.chkEnableZ, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); + + // Load the settings from the current .INI-file + loadSettings(); +} + +// +// Destructor for server-dialog +// +TrackerControls::~TrackerControls() { + qDebug() << "~TrackerControls() says: started"; +} + +// +// Initialize tracker-client-dialog +// +void TrackerControls::Initialize(QWidget *parent) { + + QPoint offsetpos(100, 100); + if (parent) { + this->move(parent->pos() + offsetpos); + } + show(); +} + +// +// OK clicked on server-dialog +// +void TrackerControls::doOK() { + save(); + this->close(); +} + +// override show event +void TrackerControls::showEvent ( QShowEvent * event ) { + loadSettings(); +} + +// +// Cancel clicked on server-dialog +// +void TrackerControls::doCancel() { + // + // Ask if changed Settings should be saved + // + if (settingsDirty) { + int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard ); + + qDebug() << "doCancel says: answer =" << ret; + + switch (ret) { + case QMessageBox::Save: + save(); + this->close(); + break; + case QMessageBox::Discard: + this->close(); + break; + case QMessageBox::Cancel: + // Cancel was clicked + break; + default: + // should never be reached + break; + } + } + else { + this->close(); + } +} + + +// +// Load the current Settings from the currently 'active' INI-file. +// +void TrackerControls::loadSettings() { + +// qDebug() << "loadSettings says: Starting "; + QSettings settings("opentrack"); // 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; + + iniFile.beginGroup ( "FTNClient" ); + 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()); + + ui.spinPortNumber->setValue( iniFile.value ( "PortNumber", 5550 ).toInt() ); + iniFile.endGroup (); + + settingsDirty = false; +} + +// +// Save the current Settings to the currently 'active' INI-file. +// +void TrackerControls::save() { + QSettings settings("opentrack"); // 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) + + iniFile.beginGroup ( "FTNClient" ); + 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() ); + iniFile.setValue ( "PortNumber", ui.spinPortNumber->value() ); + iniFile.endGroup (); + + settingsDirty = false; +} +//////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Tracker-settings dialog object. + +// Export both decorated and undecorated names. +// GetTrackerDialog - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetTrackerDialog@0 - Common name decoration for __stdcall functions in C language. +//#pragma comment(linker, "/export:GetTrackerDialog=_GetTrackerDialog@0") + +extern "C" FTNOIR_TRACKER_BASE_EXPORT ITrackerDialog* CALLING_CONVENTION GetDialog( ) +{ + return new TrackerControls; +} diff --git a/ftnoir_tracker_udp/ftnoir_tracker_udp_dll.cpp b/ftnoir_tracker_udp/ftnoir_tracker_udp_dll.cpp index d4afb410..dcdbe487 100644 --- a/ftnoir_tracker_udp/ftnoir_tracker_udp_dll.cpp +++ b/ftnoir_tracker_udp/ftnoir_tracker_udp_dll.cpp @@ -1,73 +1,73 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2012 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -********************************************************************************/ -#include "ftnoir_tracker_udp.h" -#include -#include "facetracknoir/global-settings.h" - -FTNoIR_TrackerDll::FTNoIR_TrackerDll() { - //populate the description strings - trackerFullName = "FaceTrackNoIR UDP"; - trackerShortName = "UDP"; - trackerDescription = "FaceTrackNoIR UDP"; -} - -FTNoIR_TrackerDll::~FTNoIR_TrackerDll() -{ - -} - -void FTNoIR_TrackerDll::getFullName(QString *strToBeFilled) -{ - *strToBeFilled = trackerFullName; -} - -void FTNoIR_TrackerDll::getShortName(QString *strToBeFilled) -{ - *strToBeFilled = trackerShortName; -} - -void FTNoIR_TrackerDll::getDescription(QString *strToBeFilled) -{ - *strToBeFilled = trackerDescription; -} - -void FTNoIR_TrackerDll::getIcon(QIcon *icon) -{ - *icon = QIcon(":/images/facetracknoir.png"); -} - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Tracker object. - -// Export both decorated and undecorated names. -// GetTrackerDll - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetTrackerDll@0 - Common name decoration for __stdcall functions in C language. -//#pragma comment(linker, "/export:GetTrackerDll=_GetTrackerDll@0") - -extern "C" FTNOIR_TRACKER_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata() -{ - return new FTNoIR_TrackerDll; -} +/******************************************************************************** +* FaceTrackNoIR This program is a private project of some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2012 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +********************************************************************************/ +#include "ftnoir_tracker_udp.h" +#include +#include "facetracknoir/global-settings.h" + +FTNoIR_TrackerDll::FTNoIR_TrackerDll() { + //populate the description strings + trackerFullName = "FaceTrackNoIR UDP"; + trackerShortName = "UDP"; + trackerDescription = "FaceTrackNoIR UDP"; +} + +FTNoIR_TrackerDll::~FTNoIR_TrackerDll() +{ + +} + +void FTNoIR_TrackerDll::getFullName(QString *strToBeFilled) +{ + *strToBeFilled = trackerFullName; +} + +void FTNoIR_TrackerDll::getShortName(QString *strToBeFilled) +{ + *strToBeFilled = trackerShortName; +} + +void FTNoIR_TrackerDll::getDescription(QString *strToBeFilled) +{ + *strToBeFilled = trackerDescription; +} + +void FTNoIR_TrackerDll::getIcon(QIcon *icon) +{ + *icon = QIcon(":/images/facetracknoir.png"); +} + +//////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Tracker object. + +// Export both decorated and undecorated names. +// GetTrackerDll - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetTrackerDll@0 - Common name decoration for __stdcall functions in C language. +//#pragma comment(linker, "/export:GetTrackerDll=_GetTrackerDll@0") + +extern "C" FTNOIR_TRACKER_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata() +{ + return new FTNoIR_TrackerDll; +} diff --git a/qfunctionconfigurator/functionconfig.cpp b/qfunctionconfigurator/functionconfig.cpp index 1b06bdc2..e0807859 100644 --- a/qfunctionconfigurator/functionconfig.cpp +++ b/qfunctionconfigurator/functionconfig.cpp @@ -1,282 +1,282 @@ -/* Copyright (c) 2012, 2013 Stanisław Halik - - * Permission to use, copy, modify, and/or distribute this - * software for any purpose with or without fee is hereby granted, - * provided that the above copyright notice and this permission - * notice appear in all copies. - */ - -#include -#include -#include -#include -#include "functionconfig.h" -#include -#include -#include -#include -#include -#include - -// -// Constructor with List of Points in argument. -// -FunctionConfig::FunctionConfig(QString title, int intMaxInput, int intMaxOutput) -{ - _mutex = new QMutex(QMutex::Recursive); - _title = title; - _points = QList(); - _data = 0; - _size = 0; - lastValueTracked = QPointF(0,0); - _tracking_active = false; - _max_Input = intMaxInput; // Added WVR 20120805 - _max_Output = intMaxOutput; - QSettings settings("opentrack"); // Registry settings (in HK_USER) - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); - QSettings iniFile( currentFile, QSettings::IniFormat ); - loadSettings(iniFile); - reload(); -} - -FunctionConfig::FunctionConfig() : - _tracking_active(false), - _max_Input(0), - _max_Output(0), - _data(0), - _mutex(0), - _size(0) -{ - _mutex = new QMutex(); -} - -// -// Calculate the value of the function, given the input 'x'. -// Used to draw the curve and, most importantly, to translate input to output. -// The return-value is also stored internally, so the Widget can show the current value, when the Tracker is running. -// -float FunctionConfig::getValue(float x) { - QMutexLocker foo(_mutex); - int x2 = (int) (std::min(std::max(x, -360), 360) * MEMOIZE_PRECISION); - float ret = getValueInternal(x2); - lastValueTracked.setX(x); - lastValueTracked.setY(ret); - return ret; -} - -// -// The return-value is also stored internally, so the Widget can show the current value, when the Tracker is running. -// -bool FunctionConfig::getLastPoint(QPointF& point ) { - QMutexLocker foo(_mutex); - point = lastValueTracked; - return _tracking_active; -} - -float FunctionConfig::getValueInternal(int x) { - float sign = x < 0 ? -1 : 1; - x = x < 0 ? -x : x; - float ret; - if (!_data) - ret = 0; - else if (_size == 0) - ret = 0; - else if (x < 0) - ret = 0; - else if (x < _size && x >= 0) - ret = _data[x]; - else - ret = _data[_size - 1]; - return ret * sign; -} - -static __inline QPointF ensureInBounds(QList points, int i) { - int siz = points.size(); - if (siz == 0 || i < 0) - return QPointF(0, 0); - if (siz > i) - return points[i]; - return points[siz - 1]; -} - -static bool sortFn(const QPointF& one, const QPointF& two) { - return one.x() < two.x(); -} - -void FunctionConfig::reload() { - _size = 0; - - if (_points.size()) - qStableSort(_points.begin(), _points.end(), sortFn); - - if (_data) - delete[] _data; - _data = NULL; - if (_points.size()) { - _data = new float[_size = MEMOIZE_PRECISION * _points[_points.size() - 1].x()]; - - for (int i = 0; i < _size; i++) - _data[i] = -1e6; - - for (int k = 0; k < _points[0].x() * MEMOIZE_PRECISION; k++) { - if (k < _size) - _data[k] = _points[0].y() * k / (_points[0].x() * MEMOIZE_PRECISION); - } - - for (int i = 0; i < _points.size(); i++) { - QPointF p0 = ensureInBounds(_points, i - 1); - QPointF p1 = ensureInBounds(_points, i); - QPointF p2 = ensureInBounds(_points, i + 1); - QPointF p3 = ensureInBounds(_points, i + 2); - - int end = p2.x() * MEMOIZE_PRECISION; - int start = p1.x() * MEMOIZE_PRECISION; - - for (int j = start; j < end && j < _size; j++) { - float t = (j - start) / (float) (end - start); - float t2 = t*t; - float t3 = t*t*t; - - int x = .5 * ((2 * p1.x()) + - (-p0.x() + p2.x()) * t + - (2 * p0.x() - 5 * p1.x() + 4 * p2.x() - p3.x()) * t2 + - (-p0.x() + 3 * p1.x() - 3 * p2.x() + p3.x()) * t3) - * MEMOIZE_PRECISION; - - float y = .5 * ((2 * p1.y()) + - (-p0.y() + p2.y()) * t + - (2 * p0.y() - 5 * p1.y() + 4 * p2.y() - p3.y()) * t2 + - (-p0.y() + 3 * p1.y() - 3 * p2.y() + p3.y()) * t3); - - if (x >= 0 && x < _size) - _data[x] = y; - } - } - - float last = 0; - - for (int i = 0; i < _size; i++) - { - if (_data[i] == -1e6) - _data[i] = last; - last = _data[i]; - } - } -} - -FunctionConfig::~FunctionConfig() { - if (_data) - delete[] _data; - if (_mutex) - delete _mutex; -} - -// -// Remove a Point from the Function. -// Used by the Widget. -// -void FunctionConfig::removePoint(int i) { - QMutexLocker foo(_mutex); - if (i >= 0 && i < _points.size()) - { - _points.removeAt(i); - reload(); - } -} - -// -// Add a Point to the Function. -// Used by the Widget and by loadSettings. -// -void FunctionConfig::addPoint(QPointF pt) { - QMutexLocker foo(_mutex); - _points.append(pt); - reload(); -} - -// -// Move a Function Point. -// Used by the Widget. -// -void FunctionConfig::movePoint(int idx, QPointF pt) { - QMutexLocker foo(_mutex); - if (idx >= 0 && idx < _points.size()) - { - _points[idx] = pt; - reload(); - } -} - -// -// Return the List of Points. -// Used by the Widget. -// -QList FunctionConfig::getPoints() { - QList ret; - QMutexLocker foo(_mutex); - for (int i = 0; i < _points.size(); i++) { - ret.append(_points[i]); - } - return ret; -} - -// -// Load the Points for the Function from the INI-file designated by settings. -// Settings for a specific Curve are loaded from their own Group in the INI-file. -// -void FunctionConfig::loadSettings(QSettings& settings) { - QMutexLocker foo(_mutex); - QPointF newPoint; - - QList points; - settings.beginGroup(QString("Curves-%1").arg(_title)); - - int max = settings.value("point-count", 0).toInt(); - - qDebug() << _title << "count" << max; - - for (int i = 0; i < max; i++) { - newPoint = QPointF(settings.value(QString("point-%1-x").arg(i), (i + 1) * _max_Input/2).toFloat(), - settings.value(QString("point-%1-y").arg(i), (i + 1) * _max_Output/2).toFloat()); - // - // Make sure the new Point fits in the Function Range. - // Maybe this can be improved? - // - if (newPoint.x() > _max_Input) { - newPoint.setX(_max_Input); - } - if (newPoint.y() > _max_Output) { - newPoint.setY(_max_Output); - } - points.append(newPoint); - } - settings.endGroup(); - _points = points; - reload(); -} - -// -// Save the Points for the Function to the INI-file designated by settings. -// Settings for a specific Curve are saved in their own Group in the INI-file. -// The number of Points is also saved, to make loading more convenient. -// -void FunctionConfig::saveSettings(QSettings& settings) { - QMutexLocker foo(_mutex); - settings.beginGroup(QString("Curves-%1").arg(_title)); - int max = _points.size(); - settings.setValue("point-count", max); - for (int i = 0; i < max; i++) { - settings.setValue(QString("point-%1-x").arg(i), _points[i].x()); - settings.setValue(QString("point-%1-y").arg(i), _points[i].y()); - } - - for (int i = max; true; i++) - { - QString x = QString("point-%1-x").arg(i); - if (!settings.contains(x)) - break; - settings.remove(x); - settings.remove(QString("point-%1-y").arg(i)); - } - settings.endGroup(); -} +/* Copyright (c) 2012, 2013 Stanisław Halik + + * Permission to use, copy, modify, and/or distribute this + * software for any purpose with or without fee is hereby granted, + * provided that the above copyright notice and this permission + * notice appear in all copies. + */ + +#include +#include +#include +#include +#include "functionconfig.h" +#include +#include +#include +#include +#include +#include + +// +// Constructor with List of Points in argument. +// +FunctionConfig::FunctionConfig(QString title, int intMaxInput, int intMaxOutput) +{ + _mutex = new QMutex(QMutex::Recursive); + _title = title; + _points = QList(); + _data = 0; + _size = 0; + lastValueTracked = QPointF(0,0); + _tracking_active = false; + _max_Input = intMaxInput; // Added WVR 20120805 + _max_Output = intMaxOutput; + QSettings settings("opentrack"); // Registry settings (in HK_USER) + QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + QSettings iniFile( currentFile, QSettings::IniFormat ); + loadSettings(iniFile); + reload(); +} + +FunctionConfig::FunctionConfig() : + _tracking_active(false), + _max_Input(0), + _max_Output(0), + _data(0), + _mutex(0), + _size(0) +{ + _mutex = new QMutex(); +} + +// +// Calculate the value of the function, given the input 'x'. +// Used to draw the curve and, most importantly, to translate input to output. +// The return-value is also stored internally, so the Widget can show the current value, when the Tracker is running. +// +float FunctionConfig::getValue(float x) { + QMutexLocker foo(_mutex); + int x2 = (int) (std::min(std::max(x, -360), 360) * MEMOIZE_PRECISION); + float ret = getValueInternal(x2); + lastValueTracked.setX(x); + lastValueTracked.setY(ret); + return ret; +} + +// +// The return-value is also stored internally, so the Widget can show the current value, when the Tracker is running. +// +bool FunctionConfig::getLastPoint(QPointF& point ) { + QMutexLocker foo(_mutex); + point = lastValueTracked; + return _tracking_active; +} + +float FunctionConfig::getValueInternal(int x) { + float sign = x < 0 ? -1 : 1; + x = x < 0 ? -x : x; + float ret; + if (!_data) + ret = 0; + else if (_size == 0) + ret = 0; + else if (x < 0) + ret = 0; + else if (x < _size && x >= 0) + ret = _data[x]; + else + ret = _data[_size - 1]; + return ret * sign; +} + +static __inline QPointF ensureInBounds(QList points, int i) { + int siz = points.size(); + if (siz == 0 || i < 0) + return QPointF(0, 0); + if (siz > i) + return points[i]; + return points[siz - 1]; +} + +static bool sortFn(const QPointF& one, const QPointF& two) { + return one.x() < two.x(); +} + +void FunctionConfig::reload() { + _size = 0; + + if (_points.size()) + qStableSort(_points.begin(), _points.end(), sortFn); + + if (_data) + delete[] _data; + _data = NULL; + if (_points.size()) { + _data = new float[_size = MEMOIZE_PRECISION * _points[_points.size() - 1].x()]; + + for (int i = 0; i < _size; i++) + _data[i] = -1e6; + + for (int k = 0; k < _points[0].x() * MEMOIZE_PRECISION; k++) { + if (k < _size) + _data[k] = _points[0].y() * k / (_points[0].x() * MEMOIZE_PRECISION); + } + + for (int i = 0; i < _points.size(); i++) { + QPointF p0 = ensureInBounds(_points, i - 1); + QPointF p1 = ensureInBounds(_points, i); + QPointF p2 = ensureInBounds(_points, i + 1); + QPointF p3 = ensureInBounds(_points, i + 2); + + int end = p2.x() * MEMOIZE_PRECISION; + int start = p1.x() * MEMOIZE_PRECISION; + + for (int j = start; j < end && j < _size; j++) { + float t = (j - start) / (float) (end - start); + float t2 = t*t; + float t3 = t*t*t; + + int x = .5 * ((2 * p1.x()) + + (-p0.x() + p2.x()) * t + + (2 * p0.x() - 5 * p1.x() + 4 * p2.x() - p3.x()) * t2 + + (-p0.x() + 3 * p1.x() - 3 * p2.x() + p3.x()) * t3) + * MEMOIZE_PRECISION; + + float y = .5 * ((2 * p1.y()) + + (-p0.y() + p2.y()) * t + + (2 * p0.y() - 5 * p1.y() + 4 * p2.y() - p3.y()) * t2 + + (-p0.y() + 3 * p1.y() - 3 * p2.y() + p3.y()) * t3); + + if (x >= 0 && x < _size) + _data[x] = y; + } + } + + float last = 0; + + for (int i = 0; i < _size; i++) + { + if (_data[i] == -1e6) + _data[i] = last; + last = _data[i]; + } + } +} + +FunctionConfig::~FunctionConfig() { + if (_data) + delete[] _data; + if (_mutex) + delete _mutex; +} + +// +// Remove a Point from the Function. +// Used by the Widget. +// +void FunctionConfig::removePoint(int i) { + QMutexLocker foo(_mutex); + if (i >= 0 && i < _points.size()) + { + _points.removeAt(i); + reload(); + } +} + +// +// Add a Point to the Function. +// Used by the Widget and by loadSettings. +// +void FunctionConfig::addPoint(QPointF pt) { + QMutexLocker foo(_mutex); + _points.append(pt); + reload(); +} + +// +// Move a Function Point. +// Used by the Widget. +// +void FunctionConfig::movePoint(int idx, QPointF pt) { + QMutexLocker foo(_mutex); + if (idx >= 0 && idx < _points.size()) + { + _points[idx] = pt; + reload(); + } +} + +// +// Return the List of Points. +// Used by the Widget. +// +QList FunctionConfig::getPoints() { + QList ret; + QMutexLocker foo(_mutex); + for (int i = 0; i < _points.size(); i++) { + ret.append(_points[i]); + } + return ret; +} + +// +// Load the Points for the Function from the INI-file designated by settings. +// Settings for a specific Curve are loaded from their own Group in the INI-file. +// +void FunctionConfig::loadSettings(QSettings& settings) { + QMutexLocker foo(_mutex); + QPointF newPoint; + + QList points; + settings.beginGroup(QString("Curves-%1").arg(_title)); + + int max = settings.value("point-count", 0).toInt(); + + qDebug() << _title << "count" << max; + + for (int i = 0; i < max; i++) { + newPoint = QPointF(settings.value(QString("point-%1-x").arg(i), (i + 1) * _max_Input/2).toFloat(), + settings.value(QString("point-%1-y").arg(i), (i + 1) * _max_Output/2).toFloat()); + // + // Make sure the new Point fits in the Function Range. + // Maybe this can be improved? + // + if (newPoint.x() > _max_Input) { + newPoint.setX(_max_Input); + } + if (newPoint.y() > _max_Output) { + newPoint.setY(_max_Output); + } + points.append(newPoint); + } + settings.endGroup(); + _points = points; + reload(); +} + +// +// Save the Points for the Function to the INI-file designated by settings. +// Settings for a specific Curve are saved in their own Group in the INI-file. +// The number of Points is also saved, to make loading more convenient. +// +void FunctionConfig::saveSettings(QSettings& settings) { + QMutexLocker foo(_mutex); + settings.beginGroup(QString("Curves-%1").arg(_title)); + int max = _points.size(); + settings.setValue("point-count", max); + for (int i = 0; i < max; i++) { + settings.setValue(QString("point-%1-x").arg(i), _points[i].x()); + settings.setValue(QString("point-%1-y").arg(i), _points[i].y()); + } + + for (int i = max; true; i++) + { + QString x = QString("point-%1-x").arg(i); + if (!settings.contains(x)) + break; + settings.remove(x); + settings.remove(QString("point-%1-y").arg(i)); + } + settings.endGroup(); +} diff --git a/qfunctionconfigurator/functionconfig.h b/qfunctionconfigurator/functionconfig.h index 0f60c979..21e9e43e 100644 --- a/qfunctionconfigurator/functionconfig.h +++ b/qfunctionconfigurator/functionconfig.h @@ -1,78 +1,78 @@ -/* Copyright (c) 2011-2012, Stanislaw Halik - - * Permission to use, copy, modify, and/or distribute this - * software for any purpose with or without fee is hereby granted, - * provided that the above copyright notice and this permission - * notice appear in all copies. - */ - -#include -#include -#include -#include -#include -#include "ftnoir_tracker_base/ftnoir_tracker_base.h" - -#ifndef FUNCTION_CONFIG_H -#define FUNCTION_CONFIG_H - -#define MEMOIZE_PRECISION 500 - -class FTNOIR_TRACKER_BASE_EXPORT FunctionConfig { -private: - QMutex* _mutex; - QList _points; - void reload(); - float* _data; - int _size; - QString _title; - float getValueInternal(int x); - QPointF lastValueTracked; // The last input value requested by the Tracker, with it's output-value. - volatile bool _tracking_active; - int _max_Input; - int _max_Output; - FunctionConfig(const FunctionConfig&) {} -public: - // - // Contructor(s) and destructor - // - FunctionConfig(); - FunctionConfig(QString title, int intMaxInput, int intMaxOutput); - virtual ~FunctionConfig(); - - float getValue(float x); - bool getLastPoint(QPointF& point); // Get the last Point that was requested. - - // - // Functions to manipulate the Function - // - void removePoint(int i); - void removeAllPoints() { - QMutexLocker foo(_mutex); - _points.clear(); - reload(); - } - - void addPoint(QPointF pt); - void movePoint(int idx, QPointF pt); - QList getPoints(); - void setMaxInput(int MaxInput) { - _max_Input = MaxInput; - } - void setMaxOutput(int MaxOutput) { - _max_Output = MaxOutput; - } - - // - // Functions to load/save the Function-Points to an INI-file - // - void saveSettings(QSettings& settings); - void loadSettings(QSettings& settings); - - void setTrackingActive(bool blnActive) { - _tracking_active = blnActive; - } - QString getTitle() { return _title; } -}; - -#endif +/* Copyright (c) 2011-2012, Stanislaw Halik + + * Permission to use, copy, modify, and/or distribute this + * software for any purpose with or without fee is hereby granted, + * provided that the above copyright notice and this permission + * notice appear in all copies. + */ + +#include +#include +#include +#include +#include +#include "ftnoir_tracker_base/ftnoir_tracker_base.h" + +#ifndef FUNCTION_CONFIG_H +#define FUNCTION_CONFIG_H + +#define MEMOIZE_PRECISION 500 + +class FTNOIR_TRACKER_BASE_EXPORT FunctionConfig { +private: + QMutex* _mutex; + QList _points; + void reload(); + float* _data; + int _size; + QString _title; + float getValueInternal(int x); + QPointF lastValueTracked; // The last input value requested by the Tracker, with it's output-value. + volatile bool _tracking_active; + int _max_Input; + int _max_Output; + FunctionConfig(const FunctionConfig&) {} +public: + // + // Contructor(s) and destructor + // + FunctionConfig(); + FunctionConfig(QString title, int intMaxInput, int intMaxOutput); + virtual ~FunctionConfig(); + + float getValue(float x); + bool getLastPoint(QPointF& point); // Get the last Point that was requested. + + // + // Functions to manipulate the Function + // + void removePoint(int i); + void removeAllPoints() { + QMutexLocker foo(_mutex); + _points.clear(); + reload(); + } + + void addPoint(QPointF pt); + void movePoint(int idx, QPointF pt); + QList getPoints(); + void setMaxInput(int MaxInput) { + _max_Input = MaxInput; + } + void setMaxOutput(int MaxOutput) { + _max_Output = MaxOutput; + } + + // + // Functions to load/save the Function-Points to an INI-file + // + void saveSettings(QSettings& settings); + void loadSettings(QSettings& settings); + + void setTrackingActive(bool blnActive) { + _tracking_active = blnActive; + } + QString getTitle() { return _title; } +}; + +#endif -- cgit v1.2.3 From 611f781ea5a9f2260f3fa305cc2274bca48ec60d Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 14 Sep 2013 15:35:21 +0200 Subject: Downcase settings directory. Only affects Linux --- facetracknoir/facetracknoir.cpp | 28 +++++++++++----------- facetracknoir/tracker.cpp | 2 +- facetracknoir/tracker.h | 2 +- ftnoir_filter_accela/ftnoir_filter_accela.cpp | 2 +- .../ftnoir_filter_accela_dialog.cpp | 4 ++-- ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp | 2 +- ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp | 4 ++-- ftnoir_protocol_fg/ftnoir_protocol_fg.cpp | 2 +- ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp | 4 ++-- ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp | 2 +- .../ftnoir_protocol_fsuipc_dialog.cpp | 4 ++-- ftnoir_protocol_ft/ftnoir_protocol_ft.cpp | 2 +- ftnoir_protocol_ft/ftnoir_protocol_ft_dialog.cpp | 4 ++-- ftnoir_protocol_ftn/ftnoir_protocol_ftn.cpp | 2 +- ftnoir_protocol_ftn/ftnoir_protocol_ftn_dialog.cpp | 4 ++-- ftnoir_protocol_mouse/ftnoir_protocol_mouse.cpp | 2 +- .../ftnoir_protocol_mouse_dialog.cpp | 4 ++-- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 6 ++--- ftnoir_tracker_ht/ftnoir_tracker_ht.cpp | 6 ++--- ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp | 2 +- .../ftnoir_tracker_hydra_dialog.cpp | 4 ++-- ftnoir_tracker_pt/ftnoir_tracker_pt_settings.cpp | 8 +++---- ftnoir_tracker_rift/ftnoir_tracker_rift.cpp | 2 +- ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp | 4 ++-- ftnoir_tracker_sm/ftnoir_tracker_faceapi.cpp | 2 +- .../ftnoir_tracker_faceapi_dialog.cpp | 4 ++-- ftnoir_tracker_udp/ftnoir_tracker_udp.cpp | 2 +- ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp | 4 ++-- qfunctionconfigurator/functionconfig.cpp | 2 +- 29 files changed, 60 insertions(+), 60 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index fe8ce36b..e834b6be 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -347,7 +347,7 @@ void FaceTrackNoIR::open() { QString fileName = dialog.getOpenFileName( this, tr("Select one FTNoir settings file"), - QCoreApplication::applicationDirPath() + "/Settings/", + QCoreApplication::applicationDirPath() + "/settings/", tr("Settings file (*.ini);;All Files (*)"), NULL); @@ -368,7 +368,7 @@ void FaceTrackNoIR::save() { QSettings settings("opentrack"); // Registry settings (in HK_USER) - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) iniFile.beginGroup ( "Tracking" ); @@ -422,14 +422,14 @@ void FaceTrackNoIR::saveAs() // Get the current filename of the INI-file. // QSettings settings("opentrack"); // Registry settings (in HK_USER) - QString oldFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + QString oldFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); // // Get the new filename of the INI-file. // QString fileName = QFileDialog::getSaveFileName(this, tr("Save file"), oldFile, -// QCoreApplication::applicationDirPath() + "/Settings", +// QCoreApplication::applicationDirPath() + "/settings", tr("Settings file (*.ini);;All Files (*)")); if (!fileName.isEmpty()) { @@ -472,7 +472,7 @@ void FaceTrackNoIR::loadSettings() { qDebug() << "loadSettings says: Starting "; QSettings settings("opentrack"); // Registry settings (in HK_USER) - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); qDebug() << "Config file now" << currentFile; QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) @@ -614,7 +614,7 @@ void FaceTrackNoIR::startTracker( ) { } QSettings settings("opentrack"); // Registry settings (in HK_USER) - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) for (int i = 0; i < 6; i++) @@ -1077,7 +1077,7 @@ void FaceTrackNoIR::profileSelected(int index) // Read the current INI-file setting, to get the folder in which it's located... // QSettings settings("opentrack"); // Registry settings (in HK_USER) - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); QFileInfo pathInfo ( currentFile ); // @@ -1096,7 +1096,7 @@ void FaceTrackNoIR::filterSelected(int index) //QSettings settings("opentrack"); // Registry settings (in HK_USER) - //QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + //QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); //QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) ui.btnShowFilterControls->setEnabled ( true ); @@ -1194,7 +1194,7 @@ void FaceTrackNoIR::bindKeyboardShortcuts() { QSettings settings("opentrack"); // Registry settings (in HK_USER) - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) iniFile.beginGroup ( "KB_Shortcuts" ); int idxCenter = iniFile.value("Key_index_Center", 0).toInt(); @@ -1255,7 +1255,7 @@ void KeyboardShortcutDialog::loadSettings() { qDebug() << "loadSettings says: Starting "; QSettings settings("opentrack"); // Registry settings (in HK_USER) - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + 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; @@ -1283,7 +1283,7 @@ void KeyboardShortcutDialog::save() { QSettings settings("opentrack"); // Registry settings (in HK_USER) - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) iniFile.beginGroup ( "KB_Shortcuts" ); @@ -1318,7 +1318,7 @@ QWidget( parent , f) mainApp = ftnoir; // Preserve a pointer to FTNoIR QSettings settings("opentrack"); // Registry settings (in HK_USER) - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); QFunctionConfigurator* configs[6] = { ui.txconfig, @@ -1424,7 +1424,7 @@ void CurveConfigurationDialog::loadSettings() { qDebug() << "loadSettings says: Starting "; QSettings settings("opentrack"); // Registry settings (in HK_USER) - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + 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; @@ -1490,7 +1490,7 @@ void CurveConfigurationDialog::save() { QSettings settings("opentrack"); // Registry settings (in HK_USER) - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); ui.rxconfig->saveSettings(currentFile); ui.ryconfig->saveSettings(currentFile); diff --git a/facetracknoir/tracker.cpp b/facetracknoir/tracker.cpp index 47daa697..cdf28d40 100644 --- a/facetracknoir/tracker.cpp +++ b/facetracknoir/tracker.cpp @@ -193,7 +193,7 @@ void Tracker::loadSettings() { qDebug() << "Tracker::loadSettings says: Starting "; QSettings settings("opentrack"); // Registry settings (in HK_USER) - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) iniFile.beginGroup("Tracking"); diff --git a/facetracknoir/tracker.h b/facetracknoir/tracker.h index eeb18dad..0476eec4 100644 --- a/facetracknoir/tracker.h +++ b/facetracknoir/tracker.h @@ -83,7 +83,7 @@ public: zero(0) { QSettings settings("opentrack"); // Registry settings (in HK_USER) - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); QSettings iniFile( currentFile, QSettings::IniFormat ); curve.loadSettings(iniFile); curveAlt.loadSettings(iniFile); diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.cpp b/ftnoir_filter_accela/ftnoir_filter_accela.cpp index 0b3d6518..2c0765e8 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela.cpp @@ -26,7 +26,7 @@ FTNoIR_Filter::~FTNoIR_Filter() void FTNoIR_Filter::loadSettings() { QSettings settings("opentrack"); // Registry settings (in HK_USER) - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) iniFile.beginGroup ( "Accela" ); diff --git a/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp b/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp index 3e74ad81..0e3660d6 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp @@ -133,7 +133,7 @@ void FilterControls::doCancel() { void FilterControls::loadSettings() { QSettings settings("opentrack"); // Registry settings (in HK_USER) - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) qDebug() << "FTNoIR_Filter::loadSettings2 says: iniFile = " << currentFile; @@ -156,7 +156,7 @@ void FilterControls::loadSettings() { void FilterControls::save() { QSettings settings("opentrack"); // Registry settings (in HK_USER) - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) qDebug() << "FTNoIR_Filter::save() says: iniFile = " << currentFile; diff --git a/ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp b/ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp index b127c665..bb9fd4c9 100644 --- a/ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp +++ b/ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp @@ -64,7 +64,7 @@ void FTNoIR_Filter::loadSettings() { qDebug() << "FTNoIR_Filter::loadSettings says: Starting "; QSettings settings("opentrack"); // Registry settings (in HK_USER) - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) qDebug() << "FTNoIR_Filter::loadSettings says: iniFile = " << currentFile; diff --git a/ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp b/ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp index 91777213..f4b8aad2 100644 --- a/ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp +++ b/ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp @@ -143,7 +143,7 @@ void FilterControls::loadSettings() { qDebug() << "FilterControls::loadSettings says: Starting "; QSettings settings("opentrack"); // Registry settings (in HK_USER) - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) qDebug() << "FilterControls::loadSettings says: iniFile = " << currentFile; @@ -166,7 +166,7 @@ void FilterControls::loadSettings() { void FilterControls::save() { QSettings settings("opentrack"); // Registry settings (in HK_USER) - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + 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; diff --git a/ftnoir_protocol_fg/ftnoir_protocol_fg.cpp b/ftnoir_protocol_fg/ftnoir_protocol_fg.cpp index d80791ce..dc76d193 100644 --- a/ftnoir_protocol_fg/ftnoir_protocol_fg.cpp +++ b/ftnoir_protocol_fg/ftnoir_protocol_fg.cpp @@ -61,7 +61,7 @@ FTNoIR_Protocol::~FTNoIR_Protocol() void FTNoIR_Protocol::loadSettings() { QSettings settings("opentrack"); // Registry settings (in HK_USER) - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) iniFile.beginGroup ( "FG" ); diff --git a/ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp b/ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp index 2acd3f9c..b670bdd3 100644 --- a/ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp +++ b/ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp @@ -134,7 +134,7 @@ void FGControls::loadSettings() { // qDebug() << "loadSettings says: Starting "; QSettings settings("opentrack"); // Registry settings (in HK_USER) - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + 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; @@ -160,7 +160,7 @@ void FGControls::loadSettings() { void FGControls::save() { QSettings settings("opentrack"); // Registry settings (in HK_USER) - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) iniFile.beginGroup ( "FG" ); diff --git a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp index ba053e11..df25e9ed 100644 --- a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp +++ b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp @@ -75,7 +75,7 @@ double local_x; void FTNoIR_Protocol::loadSettings() { QSettings settings("opentrack"); // Registry settings (in HK_USER) - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) iniFile.beginGroup ( "FSUIPC" ); diff --git a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dialog.cpp b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dialog.cpp index 90ed22b2..985915b4 100644 --- a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dialog.cpp +++ b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dialog.cpp @@ -121,7 +121,7 @@ void FSUIPCControls::loadSettings() { qDebug() << "loadSettings says: Starting "; QSettings settings("opentrack"); // Registry settings (in HK_USER) - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + 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; @@ -142,7 +142,7 @@ void FSUIPCControls::save() { QSettings settings("opentrack"); // Registry settings (in HK_USER) - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) iniFile.beginGroup ( "FSUIPC" ); diff --git a/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp b/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp index 597f2a5f..b72adb22 100644 --- a/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp +++ b/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp @@ -73,7 +73,7 @@ FTNoIR_Protocol::~FTNoIR_Protocol() void FTNoIR_Protocol::loadSettings() { QSettings settings("opentrack"); // Registry settings (in HK_USER) - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) iniFile.beginGroup ( "FT" ); diff --git a/ftnoir_protocol_ft/ftnoir_protocol_ft_dialog.cpp b/ftnoir_protocol_ft/ftnoir_protocol_ft_dialog.cpp index 810bef50..eb2d0e76 100644 --- a/ftnoir_protocol_ft/ftnoir_protocol_ft_dialog.cpp +++ b/ftnoir_protocol_ft/ftnoir_protocol_ft_dialog.cpp @@ -147,7 +147,7 @@ void FTControls::loadSettings() { qDebug() << "loadSettings says: Starting "; QSettings settings("opentrack"); // Registry settings (in HK_USER) - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + 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; @@ -170,7 +170,7 @@ void FTControls::loadSettings() { void FTControls::save() { QSettings settings("opentrack"); // Registry settings (in HK_USER) - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) iniFile.beginGroup ( "FT" ); diff --git a/ftnoir_protocol_ftn/ftnoir_protocol_ftn.cpp b/ftnoir_protocol_ftn/ftnoir_protocol_ftn.cpp index 32d11c37..d29c80c9 100644 --- a/ftnoir_protocol_ftn/ftnoir_protocol_ftn.cpp +++ b/ftnoir_protocol_ftn/ftnoir_protocol_ftn.cpp @@ -51,7 +51,7 @@ FTNoIR_Protocol::~FTNoIR_Protocol() void FTNoIR_Protocol::loadSettings() { QSettings settings("opentrack"); // Registry settings (in HK_USER) - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) iniFile.beginGroup ( "FTN" ); diff --git a/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dialog.cpp b/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dialog.cpp index c902d6f8..0b61fd48 100644 --- a/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dialog.cpp +++ b/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dialog.cpp @@ -128,7 +128,7 @@ void FTNControls::loadSettings() { // qDebug() << "loadSettings says: Starting "; QSettings settings("opentrack"); // Registry settings (in HK_USER) - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + 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; @@ -151,7 +151,7 @@ void FTNControls::loadSettings() { void FTNControls::save() { QSettings settings("opentrack"); // Registry settings (in HK_USER) - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) iniFile.beginGroup ( "FTN" ); diff --git a/ftnoir_protocol_mouse/ftnoir_protocol_mouse.cpp b/ftnoir_protocol_mouse/ftnoir_protocol_mouse.cpp index 6b013d74..8601bdfd 100644 --- a/ftnoir_protocol_mouse/ftnoir_protocol_mouse.cpp +++ b/ftnoir_protocol_mouse/ftnoir_protocol_mouse.cpp @@ -46,7 +46,7 @@ FTNoIR_Protocol::~FTNoIR_Protocol() void FTNoIR_Protocol::loadSettings() { QSettings settings("opentrack"); // Registry settings (in HK_USER) - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) iniFile.beginGroup ( "Mouse" ); diff --git a/ftnoir_protocol_mouse/ftnoir_protocol_mouse_dialog.cpp b/ftnoir_protocol_mouse/ftnoir_protocol_mouse_dialog.cpp index 1e03a022..c8d62a58 100644 --- a/ftnoir_protocol_mouse/ftnoir_protocol_mouse_dialog.cpp +++ b/ftnoir_protocol_mouse/ftnoir_protocol_mouse_dialog.cpp @@ -134,7 +134,7 @@ void MOUSEControls::loadSettings() { qDebug() << "loadSettings says: Starting "; QSettings settings("opentrack"); // Registry settings (in HK_USER) - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + 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; @@ -155,7 +155,7 @@ void MOUSEControls::save() { QSettings settings("opentrack"); // Registry settings (in HK_USER) - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) iniFile.beginGroup ( "Mouse" ); diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index 6fff39d3..dcd91994 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -101,7 +101,7 @@ static resolution_tuple resolution_choices[] = { void Tracker::load_settings() { QSettings settings("opentrack"); - QString currentFile = settings.value( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + QString currentFile = settings.value( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); QSettings iniFile( currentFile, QSettings::IniFormat ); iniFile.beginGroup( "aruco-Tracker" ); @@ -396,7 +396,7 @@ void TrackerControls::loadSettings() names.prepend("Any available"); ui.cameraName->addItems(names); QSettings settings("opentrack"); - QString currentFile = settings.value( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + QString currentFile = settings.value( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); QSettings iniFile( currentFile, QSettings::IniFormat ); iniFile.beginGroup( "aruco-Tracker" ); ui.cameraName->setCurrentIndex(iniFile.value("camera-index", -1).toInt() + 1); @@ -440,7 +440,7 @@ void TrackerControls::loadSettings() void TrackerControls::save() { QSettings settings("opentrack"); - QString currentFile = settings.value( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + QString currentFile = settings.value( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); QSettings iniFile( currentFile, QSettings::IniFormat ); iniFile.beginGroup( "aruco-Tracker" ); diff --git a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp index b755010c..45c62f55 100644 --- a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp +++ b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp @@ -91,7 +91,7 @@ static resolution_tuple resolution_choices[] = { static void load_settings(ht_config_t* config, Tracker* tracker) { QSettings settings("opentrack"); - QString currentFile = settings.value( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + QString currentFile = settings.value( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); QSettings iniFile( currentFile, QSettings::IniFormat ); iniFile.beginGroup( "HT-Tracker" ); @@ -318,7 +318,7 @@ void TrackerControls::loadSettings() names.prepend("Any available"); ui.cameraName->addItems(names); QSettings settings("opentrack"); - QString currentFile = settings.value( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + QString currentFile = settings.value( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); QSettings iniFile( currentFile, QSettings::IniFormat ); iniFile.beginGroup( "HT-Tracker" ); ui.cameraName->setCurrentIndex(iniFile.value("camera-index", -1).toInt() + 1); @@ -362,7 +362,7 @@ void TrackerControls::loadSettings() void TrackerControls::save() { QSettings settings("opentrack"); - QString currentFile = settings.value( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + QString currentFile = settings.value( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); QSettings iniFile( currentFile, QSettings::IniFormat ); iniFile.beginGroup( "HT-Tracker" ); diff --git a/ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp b/ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp index 3789c7bf..81307cd6 100644 --- a/ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp +++ b/ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp @@ -124,7 +124,7 @@ void Hydra_Tracker::loadSettings() { qDebug() << "FTNoIR_Tracker::loadSettings says: Starting "; QSettings settings("opentrack"); // Registry settings (in HK_USER) - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) qDebug() << "FTNoIR_Tracker::loadSettings says: iniFile = " << currentFile; diff --git a/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dialog.cpp b/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dialog.cpp index 77d4963b..913f8070 100644 --- a/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dialog.cpp +++ b/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dialog.cpp @@ -127,7 +127,7 @@ void TrackerControls::loadSettings() { // qDebug() << "loadSettings says: Starting "; QSettings settings("opentrack"); // Registry settings (in HK_USER) - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + 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; @@ -151,7 +151,7 @@ void TrackerControls::loadSettings() { void TrackerControls::save() { QSettings settings("opentrack"); // Registry settings (in HK_USER) - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) iniFile.beginGroup ( "Hydra" ); diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt_settings.cpp b/ftnoir_tracker_pt/ftnoir_tracker_pt_settings.cpp index b0249813..787a5265 100644 --- a/ftnoir_tracker_pt/ftnoir_tracker_pt_settings.cpp +++ b/ftnoir_tracker_pt/ftnoir_tracker_pt_settings.cpp @@ -15,7 +15,7 @@ void TrackerSettings::load_ini() qDebug("TrackerSettings::load_ini()"); QSettings settings("opentrack"); // Registry settings (in HK_USER) - QString currentFile = settings.value( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + QString currentFile = settings.value( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) iniFile.beginGroup( "PointTracker" ); @@ -58,7 +58,7 @@ void TrackerSettings::save_ini() const qDebug("TrackerSettings::save_ini()"); QSettings settings("opentrack"); // Registry settings (in HK_USER) - QString currentFile = settings.value( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + QString currentFile = settings.value( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) iniFile.beginGroup ( "PointTracker" ); @@ -102,7 +102,7 @@ void TrackerDialogSettings::load_ini() qDebug("TrackerDialogSettings::load_ini()"); QSettings settings("opentrack"); // Registry settings (in HK_USER) - QString currentFile = settings.value( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + QString currentFile = settings.value( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) iniFile.beginGroup( "PointTrackerDialog" ); @@ -128,7 +128,7 @@ void TrackerDialogSettings::save_ini() const qDebug("TrackerDialogSettings::save_ini()"); QSettings settings("opentrack"); // Registry settings (in HK_USER) - QString currentFile = settings.value( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + QString currentFile = settings.value( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) iniFile.beginGroup ( "PointTrackerDialog" ); diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp b/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp index eb05d5f9..f5e1f5fa 100644 --- a/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp +++ b/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp @@ -142,7 +142,7 @@ void Rift_Tracker::loadSettings() { qDebug() << "FTNoIR_Tracker::loadSettings says: Starting "; QSettings settings("opentrack"); // Registry settings (in HK_USER) - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) qDebug() << "FTNoIR_Tracker::loadSettings says: iniFile = " << currentFile; diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp b/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp index 0b644723..26fbbc9f 100644 --- a/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp +++ b/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp @@ -127,7 +127,7 @@ void TrackerControls::loadSettings() { // qDebug() << "loadSettings says: Starting "; QSettings settings("opentrack"); // Registry settings (in HK_USER) - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + 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; @@ -152,7 +152,7 @@ void TrackerControls::loadSettings() { void TrackerControls::save() { QSettings settings("opentrack"); // Registry settings (in HK_USER) - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) iniFile.beginGroup ( "Rift" ); diff --git a/ftnoir_tracker_sm/ftnoir_tracker_faceapi.cpp b/ftnoir_tracker_sm/ftnoir_tracker_faceapi.cpp index 06c8b206..71e9c558 100644 --- a/ftnoir_tracker_sm/ftnoir_tracker_faceapi.cpp +++ b/ftnoir_tracker_sm/ftnoir_tracker_faceapi.cpp @@ -138,7 +138,7 @@ void FTNoIR_Tracker::loadSettings() { qDebug() << "FTNoIR_Tracker::loadSettings says: Starting "; QSettings settings("opentrack"); // Registry settings (in HK_USER) - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) qDebug() << "FTNoIR_Tracker::loadSettings says: iniFile = " << currentFile; diff --git a/ftnoir_tracker_sm/ftnoir_tracker_faceapi_dialog.cpp b/ftnoir_tracker_sm/ftnoir_tracker_faceapi_dialog.cpp index 332a619e..8c3cd922 100644 --- a/ftnoir_tracker_sm/ftnoir_tracker_faceapi_dialog.cpp +++ b/ftnoir_tracker_sm/ftnoir_tracker_faceapi_dialog.cpp @@ -149,7 +149,7 @@ void TrackerControls::loadSettings() { // qDebug() << "loadSettings says: Starting "; QSettings settings("opentrack"); // Registry settings (in HK_USER) - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + 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; @@ -176,7 +176,7 @@ void TrackerControls::save() { QSettings settings("opentrack"); // Registry settings (in HK_USER) - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) iniFile.beginGroup ( "SMTracker" ); diff --git a/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp b/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp index 1364ee1c..e71d13bb 100644 --- a/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp +++ b/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp @@ -141,7 +141,7 @@ void FTNoIR_Tracker::loadSettings() { qDebug() << "FTNoIR_Tracker::loadSettings says: Starting "; QSettings settings("opentrack"); // Registry settings (in HK_USER) - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) qDebug() << "FTNoIR_Tracker::loadSettings says: iniFile = " << currentFile; diff --git a/ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp b/ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp index 5c0d7b1c..55bb6c97 100644 --- a/ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp +++ b/ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp @@ -127,7 +127,7 @@ void TrackerControls::loadSettings() { // qDebug() << "loadSettings says: Starting "; QSettings settings("opentrack"); // Registry settings (in HK_USER) - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + 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; @@ -152,7 +152,7 @@ void TrackerControls::loadSettings() { void TrackerControls::save() { QSettings settings("opentrack"); // Registry settings (in HK_USER) - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) iniFile.beginGroup ( "FTNClient" ); diff --git a/qfunctionconfigurator/functionconfig.cpp b/qfunctionconfigurator/functionconfig.cpp index e0807859..af350143 100644 --- a/qfunctionconfigurator/functionconfig.cpp +++ b/qfunctionconfigurator/functionconfig.cpp @@ -33,7 +33,7 @@ FunctionConfig::FunctionConfig(QString title, int intMaxInput, int intMaxOutput) _max_Input = intMaxInput; // Added WVR 20120805 _max_Output = intMaxOutput; QSettings settings("opentrack"); // Registry settings (in HK_USER) - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); QSettings iniFile( currentFile, QSettings::IniFormat ); loadSettings(iniFile); reload(); -- cgit v1.2.3 From b8fd03ece0aca5ac01b04d5df1beee1c93438ec0 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 14 Sep 2013 15:42:57 +0200 Subject: Remove unused member variable --- facetracknoir/facetracknoir.cpp | 8 +++++++- facetracknoir/facetracknoir.h | 6 ++---- 2 files changed, 9 insertions(+), 5 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index e834b6be..58381c13 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -168,7 +168,6 @@ FaceTrackNoIR::FaceTrackNoIR(QWidget *parent, Qt::WFlags flags) : timUpdateHeadPose(this) { ui.setupUi(this); - cameraDetected = false; // // Initialize Widget handles, to prevent memory-access errors. @@ -571,6 +570,13 @@ void FaceTrackNoIR::loadSettings() { } } + if (!_curve_config) + { + _curve_config = new CurveConfigurationDialog( this, this, Qt::Dialog ); + } + + ((CurveConfigurationDialog*) _curve_config)->loadSettings(); + settingsDirty = false; looping = false; } diff --git a/facetracknoir/facetracknoir.h b/facetracknoir/facetracknoir.h index 768f6107..ee4e9132 100644 --- a/facetracknoir/facetracknoir.h +++ b/facetracknoir/facetracknoir.h @@ -149,7 +149,6 @@ private: // void createMessageGroupBox(); /** helper **/ - bool cameraDetected; bool settingsDirty; void GetCameraNameDX(); @@ -242,10 +241,9 @@ public: explicit CurveConfigurationDialog( FaceTrackNoIR *ftnoir, QWidget *parent=0, Qt::WindowFlags f=0 ); virtual ~CurveConfigurationDialog(); void showEvent ( QShowEvent * event ); - + void loadSettings(); private: Ui::UICCurveConfigurationDialog ui; - void loadSettings(); void save(); /** helper **/ @@ -292,4 +290,4 @@ public: } }; -#endif // FaceTrackNoIR_H \ No newline at end of file +#endif // FaceTrackNoIR_H -- cgit v1.2.3 From a847cac005d6e42b302fbc9cb58caa0e9acd4ebd Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 14 Sep 2013 16:18:24 +0200 Subject: Fix splines not loading from ini without restart It's still a mess, though. --- facetracknoir/facetracknoir.cpp | 99 ++++++++++++++----------- qfunctionconfigurator/qfunctionconfigurator.cpp | 23 +++--- 2 files changed, 68 insertions(+), 54 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index 58381c13..8e368b8d 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -198,6 +198,9 @@ FaceTrackNoIR::FaceTrackNoIR(QWidget *parent, Qt::WFlags flags) : /** sets up all objects and connections to buttons */ void FaceTrackNoIR::setupFaceTrackNoIR() { + // this is needed for Wine plugin subprocess + QDir::setCurrent(QCoreApplication::applicationDirPath()); + // if we simply place a global variable with THeadPoseData, // it gets initialized and pulls in QSettings before // main() starts. program can and will crash. @@ -354,8 +357,10 @@ void FaceTrackNoIR::open() { // If a file was selected, save it's name and read it's contents. // if (! fileName.isEmpty() ) { - QSettings settings("opentrack"); // Registry settings (in HK_USER) - settings.setValue ("SettingsFile", QFileInfo(fileName).absoluteFilePath()); + { + QSettings settings("opentrack"); // Registry settings (in HK_USER) + settings.setValue ("SettingsFile", QFileInfo(fileName).absoluteFilePath()); + } loadSettings(); } } @@ -570,12 +575,18 @@ void FaceTrackNoIR::loadSettings() { } } + for (int i = 0; i < 6; i++) + { + axis(i).curve.loadSettings(iniFile); + axis(i).curveAlt.loadSettings(iniFile); + } + if (!_curve_config) { _curve_config = new CurveConfigurationDialog( this, this, Qt::Dialog ); } - ((CurveConfigurationDialog*) _curve_config)->loadSettings(); + ((CurveConfigurationDialog*)_curve_config)->loadSettings(); settingsDirty = false; looping = false; @@ -1323,45 +1334,6 @@ QWidget( parent , f) mainApp = ftnoir; // Preserve a pointer to FTNoIR - QSettings settings("opentrack"); // Registry settings (in HK_USER) - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); - - QFunctionConfigurator* configs[6] = { - ui.txconfig, - ui.tyconfig, - ui.tzconfig, - ui.rxconfig, - ui.ryconfig, - ui.rzconfig - }; - - QFunctionConfigurator* alt_configs[6] = { - ui.txconfig_alt, - ui.tyconfig_alt, - ui.tzconfig_alt, - ui.rxconfig_alt, - ui.ryconfig_alt, - ui.rzconfig_alt - }; - - QCheckBox* checkboxes[6] = { - ui.rx_altp, - ui.ry_altp, - ui.rz_altp, - ui.tx_altp, - ui.ty_altp, - ui.tz_altp - }; - - for (int i = 0; i < 6; i++) - { - configs[i]->setConfig(&mainApp->axis(i).curve, currentFile); - alt_configs[i]->setConfig(&mainApp->axis(i).curveAlt, currentFile); - connect(configs[i], SIGNAL(CurveChanged(bool)), this, SLOT(curveChanged(bool))); - connect(alt_configs[i], SIGNAL(CurveChanged(bool)), this, SLOT(curveChanged(bool))); - connect(checkboxes[i], SIGNAL(stateChanged(int)), this, SLOT(curveChanged(int))); - } - // Connect Qt signals to member-functions connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); @@ -1427,13 +1399,13 @@ void CurveConfigurationDialog::doCancel() { // Load the current Settings from the currently 'active' INI-file. // void CurveConfigurationDialog::loadSettings() { - qDebug() << "loadSettings says: Starting "; + qDebug() << "CurveConfigurationDialog::loadSettings says: Starting "; QSettings settings("opentrack"); // 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() << "CurveConfigurationDialog::loadSettings says: iniFile = " << currentFile; static const char* names[] = { "tx_alt", @@ -1478,11 +1450,48 @@ void CurveConfigurationDialog::loadSettings() { "zero_ry", "zero_rz" }; - + + for (int i = 0; i < 6; i++) widgets2[i]->setValue(iniFile.value(names2[i], 0).toDouble()); iniFile.endGroup(); + + QFunctionConfigurator* configs[6] = { + ui.txconfig, + ui.tyconfig, + ui.tzconfig, + ui.rxconfig, + ui.ryconfig, + ui.rzconfig + }; + + QFunctionConfigurator* alt_configs[6] = { + ui.txconfig_alt, + ui.tyconfig_alt, + ui.tzconfig_alt, + ui.rxconfig_alt, + ui.ryconfig_alt, + ui.rzconfig_alt + }; + + QCheckBox* checkboxes[6] = { + ui.rx_altp, + ui.ry_altp, + ui.rz_altp, + ui.tx_altp, + ui.ty_altp, + ui.tz_altp + }; + + for (int i = 0; i < 6; i++) + { + configs[i]->setConfig(&mainApp->axis(i).curve, currentFile); + alt_configs[i]->setConfig(&mainApp->axis(i).curveAlt, currentFile); + connect(configs[i], SIGNAL(CurveChanged(bool)), this, SLOT(curveChanged(bool))); + connect(alt_configs[i], SIGNAL(CurveChanged(bool)), this, SLOT(curveChanged(bool))); + connect(checkboxes[i], SIGNAL(stateChanged(int)), this, SLOT(curveChanged(int))); + } settingsDirty = false; } diff --git a/qfunctionconfigurator/qfunctionconfigurator.cpp b/qfunctionconfigurator/qfunctionconfigurator.cpp index 17905752..05ebbc4a 100644 --- a/qfunctionconfigurator/qfunctionconfigurator.cpp +++ b/qfunctionconfigurator/qfunctionconfigurator.cpp @@ -89,16 +89,22 @@ QFunctionConfigurator::QFunctionConfigurator(QWidget *parent) // Attach an existing FunctionConfig to the Widget. // void QFunctionConfigurator::setConfig(FunctionConfig* config, QString settingsFile) { -QPointF currentPoint; -QPointF drawPoint; -qreal x; + QPointF currentPoint; + QPointF drawPoint; + qreal x; - _config = config; - _points = config->getPoints(); - strSettingsFile = settingsFile; // Remember for Reset() + QSettings settings("opentrack"); // 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) + config->loadSettings(iniFile); + + _config = config; + + _points = config->getPoints(); + strSettingsFile = settingsFile; // Remember for Reset() - qDebug() << "QFunctionConfigurator::setConfig" << config->getTitle(); - setCaption(config->getTitle()); + qDebug() << "QFunctionConfigurator::setConfig" << config->getTitle(); + setCaption(config->getTitle()); // // Get the Function Points, one for each pixel in the horizontal range. @@ -132,7 +138,6 @@ void QFunctionConfigurator::loadSettings(QString settingsFile) { qDebug() << "QFunctionConfigurator::loadSettings = " << settingsFile; if (_config) { _config->loadSettings(iniFile); - setConfig(_config, settingsFile); } } -- cgit v1.2.3 From 8c3c17c9e0e9d377a69ad44c4a3e350bf9f1d505 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 14 Sep 2013 17:11:36 +0200 Subject: Move spline configuration into separate file Unfortunately, there's still a circular dependency between spline configuration and the main widget which *still* contains the most logic for the software. --- facetracknoir/curve-config.cpp | 248 ++++++++++++++++++++++++++++++++++++++++ facetracknoir/curve-config.h | 28 +++++ facetracknoir/facetracknoir.cpp | 244 --------------------------------------- facetracknoir/facetracknoir.h | 63 +++------- 4 files changed, 295 insertions(+), 288 deletions(-) create mode 100644 facetracknoir/curve-config.cpp create mode 100644 facetracknoir/curve-config.h (limited to 'facetracknoir') diff --git a/facetracknoir/curve-config.cpp b/facetracknoir/curve-config.cpp new file mode 100644 index 00000000..05b2e065 --- /dev/null +++ b/facetracknoir/curve-config.cpp @@ -0,0 +1,248 @@ +#include "facetracknoir/facetracknoir.h" +#include "facetracknoir/curve-config.h" +#include +//**************************************************************************************************// +//**************************************************************************************************// +// +// Constructor for Curve-configuration-dialog +// +CurveConfigurationDialog::CurveConfigurationDialog( FaceTrackNoIR *ftnoir, QWidget *parent, Qt::WindowFlags f ) : +QWidget( parent , f) +{ + ui.setupUi( this ); + + QPoint offsetpos(120, 30); + this->move(parent->pos() + offsetpos); + + mainApp = ftnoir; // Preserve a pointer to FTNoIR + + // Connect Qt signals to member-functions + connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); + connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); + + // Load the settings from the current .INI-file + loadSettings(); +} + +// +// Destructor for server-dialog +// +CurveConfigurationDialog::~CurveConfigurationDialog() { + qDebug() << "~CurveConfigurationDialog() says: started"; +} + +// +// OK clicked on server-dialog +// +void CurveConfigurationDialog::doOK() { + save(); + this->close(); +} + +// override show event +void CurveConfigurationDialog::showEvent ( QShowEvent * event ) { + loadSettings(); +} + +// +// Cancel clicked on server-dialog +// +void CurveConfigurationDialog::doCancel() { + // + // Ask if changed Settings should be saved + // + if (settingsDirty) { + int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard ); + + qDebug() << "doCancel says: answer =" << ret; + + switch (ret) { + case QMessageBox::Save: + save(); + this->close(); + break; + case QMessageBox::Discard: + this->close(); + break; + case QMessageBox::Cancel: + // Cancel was clicked + break; + default: + // should never be reached + break; + } + } + else { + this->close(); + } +} + +// +// Load the current Settings from the currently 'active' INI-file. +// +void CurveConfigurationDialog::loadSettings() { + qDebug() << "CurveConfigurationDialog::loadSettings says: Starting "; + QSettings settings("opentrack"); // 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() << "CurveConfigurationDialog::loadSettings says: iniFile = " << currentFile; + + static const char* names[] = { + "tx_alt", + "ty_alt", + "tz_alt", + "rx_alt", + "ry_alt", + "rz_alt" + }; + + iniFile.beginGroup("Tracking"); + + for (int i = 0; i < 6; i++) + mainApp->axis(i).altp = iniFile.value(names[i], false).toBool(); + + QCheckBox* widgets[] = { + ui.tx_altp, + ui.ty_altp, + ui.tz_altp, + ui.rx_altp, + ui.ry_altp, + ui.rz_altp + }; + + for (int i = 0; i < 6; i++) + widgets[i]->setChecked(mainApp->axis(i).altp); + + QDoubleSpinBox* widgets2[] = { + ui.pos_tx, + ui.pos_ty, + ui.pos_tz, + ui.pos_tx, + ui.pos_ry, + ui.pos_rz + }; + + const char* names2[] = { + "zero_tx", + "zero_ty", + "zero_tz", + "zero_rx", + "zero_ry", + "zero_rz" + }; + + + for (int i = 0; i < 6; i++) + widgets2[i]->setValue(iniFile.value(names2[i], 0).toDouble()); + + iniFile.endGroup(); + + QFunctionConfigurator* configs[6] = { + ui.txconfig, + ui.tyconfig, + ui.tzconfig, + ui.rxconfig, + ui.ryconfig, + ui.rzconfig + }; + + QFunctionConfigurator* alt_configs[6] = { + ui.txconfig_alt, + ui.tyconfig_alt, + ui.tzconfig_alt, + ui.rxconfig_alt, + ui.ryconfig_alt, + ui.rzconfig_alt + }; + + QCheckBox* checkboxes[6] = { + ui.rx_altp, + ui.ry_altp, + ui.rz_altp, + ui.tx_altp, + ui.ty_altp, + ui.tz_altp + }; + + for (int i = 0; i < 6; i++) + { + configs[i]->setConfig(&mainApp->axis(i).curve, currentFile); + alt_configs[i]->setConfig(&mainApp->axis(i).curveAlt, currentFile); + configs[i]->loadSettings(currentFile); + alt_configs[i]->loadSettings(currentFile); + connect(configs[i], SIGNAL(CurveChanged(bool)), this, SLOT(curveChanged(bool))); + connect(alt_configs[i], SIGNAL(CurveChanged(bool)), this, SLOT(curveChanged(bool))); + connect(checkboxes[i], SIGNAL(stateChanged(int)), this, SLOT(curveChanged(int))); + } + + settingsDirty = false; +} + +// +// Save the current Settings to the currently 'active' INI-file. +// +void CurveConfigurationDialog::save() { + + qDebug() << "save() says: started"; + + QSettings settings("opentrack"); // Registry settings (in HK_USER) + + QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); + + ui.rxconfig->saveSettings(currentFile); + ui.ryconfig->saveSettings(currentFile); + ui.rzconfig->saveSettings(currentFile); + ui.txconfig->saveSettings(currentFile); + ui.tyconfig->saveSettings(currentFile); + ui.tzconfig->saveSettings(currentFile); + + ui.txconfig_alt->saveSettings(currentFile); + ui.tyconfig_alt->saveSettings(currentFile); + ui.tzconfig_alt->saveSettings(currentFile); + ui.rxconfig_alt->saveSettings(currentFile); + ui.ryconfig_alt->saveSettings(currentFile); + ui.rzconfig_alt->saveSettings(currentFile); + + QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) + + iniFile.beginGroup("Tracking"); + + iniFile.setValue("rx_alt", ui.rx_altp->checkState() != Qt::Unchecked); + iniFile.setValue("ry_alt", ui.ry_altp->checkState() != Qt::Unchecked); + iniFile.setValue("rz_alt", ui.rz_altp->checkState() != Qt::Unchecked); + iniFile.setValue("tx_alt", ui.tx_altp->checkState() != Qt::Unchecked); + iniFile.setValue("ty_alt", ui.ty_altp->checkState() != Qt::Unchecked); + iniFile.setValue("tz_alt", ui.tz_altp->checkState() != Qt::Unchecked); + + QDoubleSpinBox* widgets2[] = { + ui.pos_tx, + ui.pos_ty, + ui.pos_tz, + ui.pos_tx, + ui.pos_ry, + ui.pos_rz + }; + + const char* names2[] = { + "zero_tx", + "zero_ty", + "zero_tz", + "zero_rx", + "zero_ry", + "zero_rz" + }; + + for (int i = 0; i < 6; i++) + iniFile.setValue(names2[i], widgets2[i]->value()); + + iniFile.endGroup(); + + settingsDirty = false; + + // + // Send a message to the main program, to update the Settings (for the tracker) + // + mainApp->updateSettings(); +} diff --git a/facetracknoir/curve-config.h b/facetracknoir/curve-config.h new file mode 100644 index 00000000..e783dd33 --- /dev/null +++ b/facetracknoir/curve-config.h @@ -0,0 +1,28 @@ +#pragma once +#include +#include "ui_ftnoir_curves.h" + +class FaceTrackNoIR; + +class CurveConfigurationDialog: public QWidget +{ + Q_OBJECT +public: + + explicit CurveConfigurationDialog( FaceTrackNoIR *ftnoir, QWidget *parent=0, Qt::WindowFlags f=0 ); + virtual ~CurveConfigurationDialog(); + void showEvent ( QShowEvent * event ); + void loadSettings(); +private: + Ui::UICCurveConfigurationDialog ui; + void save(); + + bool settingsDirty; + FaceTrackNoIR *mainApp; + +private slots: + void doOK(); + void doCancel(); + void curveChanged( bool change ) { settingsDirty = true; } + void curveChanged( int change ) { settingsDirty = true; } +}; diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index 8e368b8d..313673c6 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -1319,250 +1319,6 @@ void KeyboardShortcutDialog::save() { mainApp->updateSettings(); } -//**************************************************************************************************// -//**************************************************************************************************// -// -// Constructor for Curve-configuration-dialog -// -CurveConfigurationDialog::CurveConfigurationDialog( FaceTrackNoIR *ftnoir, QWidget *parent, Qt::WindowFlags f ) : -QWidget( parent , f) -{ - ui.setupUi( this ); - - QPoint offsetpos(120, 30); - this->move(parent->pos() + offsetpos); - - mainApp = ftnoir; // Preserve a pointer to FTNoIR - - // Connect Qt signals to member-functions - connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); - connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); - - // Load the settings from the current .INI-file - loadSettings(); -} - -// -// Destructor for server-dialog -// -CurveConfigurationDialog::~CurveConfigurationDialog() { - qDebug() << "~CurveConfigurationDialog() says: started"; -} - -// -// OK clicked on server-dialog -// -void CurveConfigurationDialog::doOK() { - save(); - this->close(); -} - -// override show event -void CurveConfigurationDialog::showEvent ( QShowEvent * event ) { - loadSettings(); -} - -// -// Cancel clicked on server-dialog -// -void CurveConfigurationDialog::doCancel() { - // - // Ask if changed Settings should be saved - // - if (settingsDirty) { - int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard ); - - qDebug() << "doCancel says: answer =" << ret; - - switch (ret) { - case QMessageBox::Save: - save(); - this->close(); - break; - case QMessageBox::Discard: - this->close(); - break; - case QMessageBox::Cancel: - // Cancel was clicked - break; - default: - // should never be reached - break; - } - } - else { - this->close(); - } -} - -// -// Load the current Settings from the currently 'active' INI-file. -// -void CurveConfigurationDialog::loadSettings() { - qDebug() << "CurveConfigurationDialog::loadSettings says: Starting "; - QSettings settings("opentrack"); // 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() << "CurveConfigurationDialog::loadSettings says: iniFile = " << currentFile; - - static const char* names[] = { - "tx_alt", - "ty_alt", - "tz_alt", - "rx_alt", - "ry_alt", - "rz_alt" - }; - - iniFile.beginGroup("Tracking"); - - for (int i = 0; i < 6; i++) - mainApp->axis(i).altp = iniFile.value(names[i], false).toBool(); - - QCheckBox* widgets[] = { - ui.tx_altp, - ui.ty_altp, - ui.tz_altp, - ui.rx_altp, - ui.ry_altp, - ui.rz_altp - }; - - for (int i = 0; i < 6; i++) - widgets[i]->setChecked(mainApp->axis(i).altp); - - QDoubleSpinBox* widgets2[] = { - ui.pos_tx, - ui.pos_ty, - ui.pos_tz, - ui.pos_tx, - ui.pos_ry, - ui.pos_rz - }; - - const char* names2[] = { - "zero_tx", - "zero_ty", - "zero_tz", - "zero_rx", - "zero_ry", - "zero_rz" - }; - - - for (int i = 0; i < 6; i++) - widgets2[i]->setValue(iniFile.value(names2[i], 0).toDouble()); - - iniFile.endGroup(); - - QFunctionConfigurator* configs[6] = { - ui.txconfig, - ui.tyconfig, - ui.tzconfig, - ui.rxconfig, - ui.ryconfig, - ui.rzconfig - }; - - QFunctionConfigurator* alt_configs[6] = { - ui.txconfig_alt, - ui.tyconfig_alt, - ui.tzconfig_alt, - ui.rxconfig_alt, - ui.ryconfig_alt, - ui.rzconfig_alt - }; - - QCheckBox* checkboxes[6] = { - ui.rx_altp, - ui.ry_altp, - ui.rz_altp, - ui.tx_altp, - ui.ty_altp, - ui.tz_altp - }; - - for (int i = 0; i < 6; i++) - { - configs[i]->setConfig(&mainApp->axis(i).curve, currentFile); - alt_configs[i]->setConfig(&mainApp->axis(i).curveAlt, currentFile); - connect(configs[i], SIGNAL(CurveChanged(bool)), this, SLOT(curveChanged(bool))); - connect(alt_configs[i], SIGNAL(CurveChanged(bool)), this, SLOT(curveChanged(bool))); - connect(checkboxes[i], SIGNAL(stateChanged(int)), this, SLOT(curveChanged(int))); - } - - settingsDirty = false; -} - -// -// Save the current Settings to the currently 'active' INI-file. -// -void CurveConfigurationDialog::save() { - - qDebug() << "save() says: started"; - - QSettings settings("opentrack"); // Registry settings (in HK_USER) - - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); - - ui.rxconfig->saveSettings(currentFile); - ui.ryconfig->saveSettings(currentFile); - ui.rzconfig->saveSettings(currentFile); - ui.txconfig->saveSettings(currentFile); - ui.tyconfig->saveSettings(currentFile); - ui.tzconfig->saveSettings(currentFile); - - ui.txconfig_alt->saveSettings(currentFile); - ui.tyconfig_alt->saveSettings(currentFile); - ui.tzconfig_alt->saveSettings(currentFile); - ui.rxconfig_alt->saveSettings(currentFile); - ui.ryconfig_alt->saveSettings(currentFile); - ui.rzconfig_alt->saveSettings(currentFile); - - QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) - - iniFile.beginGroup("Tracking"); - - iniFile.setValue("rx_alt", ui.rx_altp->checkState() != Qt::Unchecked); - iniFile.setValue("ry_alt", ui.ry_altp->checkState() != Qt::Unchecked); - iniFile.setValue("rz_alt", ui.rz_altp->checkState() != Qt::Unchecked); - iniFile.setValue("tx_alt", ui.tx_altp->checkState() != Qt::Unchecked); - iniFile.setValue("ty_alt", ui.ty_altp->checkState() != Qt::Unchecked); - iniFile.setValue("tz_alt", ui.tz_altp->checkState() != Qt::Unchecked); - - QDoubleSpinBox* widgets2[] = { - ui.pos_tx, - ui.pos_ty, - ui.pos_tz, - ui.pos_tx, - ui.pos_ry, - ui.pos_rz - }; - - const char* names2[] = { - "zero_tx", - "zero_ty", - "zero_tz", - "zero_rx", - "zero_ry", - "zero_rz" - }; - - for (int i = 0; i < 6; i++) - iniFile.setValue(names2[i], widgets2[i]->value()); - - iniFile.endGroup(); - - settingsDirty = false; - - // - // Send a message to the main program, to update the Settings (for the tracker) - // - mainApp->updateSettings(); -} - void FaceTrackNoIR::shortcutRecentered() { if (tracker) diff --git a/facetracknoir/facetracknoir.h b/facetracknoir/facetracknoir.h index ee4e9132..ab0b8bc5 100644 --- a/facetracknoir/facetracknoir.h +++ b/facetracknoir/facetracknoir.h @@ -56,7 +56,6 @@ #include "ui_facetracknoir.h" #include "ui_ftnoir_keyboardshortcuts.h" -#include "ui_ftnoir_curves.h" #include "ftnoir_protocol_base/ftnoir_protocol_base.h" #include "ftnoir_tracker_base/ftnoir_tracker_base.h" @@ -64,6 +63,7 @@ #include "global-settings.h" #include "tracker.h" +#include "facetracknoir/curve-config.h" class Tracker; // pre-define class to avoid circular includes class FaceTrackNoIR; @@ -161,27 +161,27 @@ private: bool looping; - private slots: - //file menu - void open(); - void save(); - void saveAs(); - void exit(); +private slots: + //file menu + void open(); + void save(); + void saveAs(); + void exit(); // void setIcon(int index); - void profileSelected(int index); - void protocolSelected(int index); - void filterSelected(int index); - void trackingSourceSelected(int index); + void profileSelected(int index); + void protocolSelected(int index); + void filterSelected(int index); + void trackingSourceSelected(int index); - void showVideoWidget(); - void showHeadPoseWidget(); - void showTrackerSettings(); - void showSecondTrackerSettings(); + void showVideoWidget(); + void showHeadPoseWidget(); + void showTrackerSettings(); + void showSecondTrackerSettings(); - void showServerControls(); - void showFilterControls(); - void showKeyboardShortcuts(); - void showCurveConfiguration(); + void showServerControls(); + void showFilterControls(); + void showKeyboardShortcuts(); + void showCurveConfiguration(); void setInvertAxis( Axis axis, int invert ); void setInvertYaw(int invert) { @@ -232,31 +232,6 @@ private slots: void doCancel(); }; -// Widget that has controls for Keyboard shortcuts. -class CurveConfigurationDialog: public QWidget -{ - Q_OBJECT -public: - - explicit CurveConfigurationDialog( FaceTrackNoIR *ftnoir, QWidget *parent=0, Qt::WindowFlags f=0 ); - virtual ~CurveConfigurationDialog(); - void showEvent ( QShowEvent * event ); - void loadSettings(); -private: - Ui::UICCurveConfigurationDialog ui; - void save(); - - /** helper **/ - bool settingsDirty; - FaceTrackNoIR *mainApp; - -private slots: - void doOK(); - void doCancel(); - void curveChanged( bool change ) { settingsDirty = true; } - void curveChanged( int change ) { settingsDirty = true; } -}; - extern QList global_key_sequences; #if defined(__WIN32) || defined(_WIN32) class KeybindingWorkerDummy { -- cgit v1.2.3 From f5a465e829ce817e8b0fdaf2d240a34f37ca1c35 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 14 Sep 2013 17:59:21 +0200 Subject: Move keyboard shortcuts to a new file Windows build could be interminently broken. Will resolve in following commits. --- facetracknoir/facetracknoir.cpp | 106 +--------------------------------------- facetracknoir/facetracknoir.h | 80 ------------------------------ facetracknoir/shortcuts.cpp | 102 ++++++++++++++++++++++++++++++++++++++ facetracknoir/shortcuts.h | 89 +++++++++++++++++++++++++++++++++ 4 files changed, 193 insertions(+), 184 deletions(-) create mode 100644 facetracknoir/shortcuts.cpp create mode 100644 facetracknoir/shortcuts.h (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index 313673c6..2d5fe4a0 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -22,12 +22,14 @@ * with this program; if not, see . * *********************************************************************************/ #include "facetracknoir.h" +#include "shortcuts.h" #include "tracker.h" #include #include #if defined(__WIN32) || defined(_WIN32) # include +# include #endif #if defined(__APPLE__) @@ -40,110 +42,6 @@ #include -#if defined(__WIN32) || defined(_WIN32) -#undef DIRECTINPUT_VERSION -#define DIRECTINPUT_VERSION 0x0800 -#include -#include - -KeybindingWorkerDummy::~KeybindingWorkerDummy() { - if (dinkeyboard) { - dinkeyboard->Unacquire(); - dinkeyboard->Release(); - } - if (din) - din->Release(); -} - -KeybindingWorkerDummy::KeybindingWorkerDummy(FaceTrackNoIR& w, Key keyCenter) -: kCenter(keyCenter), window(w), should_quit(true), din(0), dinkeyboard(0) -{ - if (DirectInput8Create(GetModuleHandle(NULL), DIRECTINPUT_VERSION, IID_IDirectInput8, (void**)&din, NULL) != DI_OK) { - qDebug() << "setup DirectInput8 Creation failed!" << GetLastError(); - return; - } - if (din->CreateDevice(GUID_SysKeyboard, &dinkeyboard, NULL) != DI_OK) { - din->Release(); - din = 0; - qDebug() << "setup CreateDevice function failed!" << GetLastError(); - return; - } - if (dinkeyboard->SetDataFormat(&c_dfDIKeyboard) != DI_OK) { - qDebug() << "setup SetDataFormat function failed!" << GetLastError(); - dinkeyboard->Release(); - dinkeyboard = 0; - din->Release(); - din = 0; - return; - } - - if (dinkeyboard->SetCooperativeLevel(window.winId(), DISCL_NONEXCLUSIVE | DISCL_BACKGROUND) != DI_OK) { - dinkeyboard->Release(); - din->Release(); - din = 0; - dinkeyboard = 0; - qDebug() << "setup SetCooperativeLevel function failed!" << GetLastError(); - return; - } - if (dinkeyboard->Acquire() != DI_OK) - { - dinkeyboard->Release(); - din->Release(); - din = 0; - dinkeyboard = 0; - qDebug() << "setup dinkeyboard Acquire failed!" << GetLastError(); - return; - } - should_quit = false; -} - -#define PROCESS_KEY(k, s) \ - if (isKeyPressed(&k, keystate) && (!k.ever_pressed ? (k.timer.start(), k.ever_pressed = true) : k.timer.restart() > 100)) \ - window.s(); - -static bool isKeyPressed( const Key *key, const BYTE *keystate ) { - bool shift; - bool ctrl; - bool alt; - - if (keystate[key->keycode] & 0x80) { - shift = ( (keystate[DIK_LSHIFT] & 0x80) || (keystate[DIK_RSHIFT] & 0x80) ); - ctrl = ( (keystate[DIK_LCONTROL] & 0x80) || (keystate[DIK_RCONTROL] & 0x80) ); - alt = ( (keystate[DIK_LALT] & 0x80) || (keystate[DIK_RALT] & 0x80) ); - - // - // If one of the modifiers is needed and not pressed, return false. - // - if (key->shift && !shift) return false; - if (key->ctrl && !ctrl) return false; - if (key->alt && !alt) return false; - - // - // All is well! - // - return true; - } - return false; -} - -void KeybindingWorkerDummy::run() { - BYTE keystate[256]; - while (!should_quit) - { - if (dinkeyboard->GetDeviceState(256, (LPVOID)keystate) != DI_OK) { - qDebug() << "Tracker::run GetDeviceState function failed!" << GetLastError(); - Sleep(25); - continue; - } - - PROCESS_KEY(kCenter, shortcutRecentered); - - Sleep(25); - } -} -#else -#endif - #ifdef _MSC_VER # define LIB_PREFIX "" #else diff --git a/facetracknoir/facetracknoir.h b/facetracknoir/facetracknoir.h index ab0b8bc5..b1a1cb42 100644 --- a/facetracknoir/facetracknoir.h +++ b/facetracknoir/facetracknoir.h @@ -53,9 +53,7 @@ #include #include - #include "ui_facetracknoir.h" -#include "ui_ftnoir_keyboardshortcuts.h" #include "ftnoir_protocol_base/ftnoir_protocol_base.h" #include "ftnoir_tracker_base/ftnoir_tracker_base.h" @@ -70,28 +68,6 @@ class FaceTrackNoIR; class KeybindingWorker; -#if defined(__WIN32) || defined(_WIN32) -extern QList global_windows_key_sequences; -#undef DIRECTINPUT_VERSION -#define DIRECTINPUT_VERSION 0x0800 -#include -struct Key { - BYTE keycode; - bool shift; - bool ctrl; - bool alt; - bool ever_pressed; - QElapsedTimer timer; -public: - Key() : keycode(0), shift(false), ctrl(false), alt(false), ever_pressed(false) - { - } -}; -#else -typedef unsigned char BYTE; -struct Key { int foo; }; -#endif - class FaceTrackNoIR : public QMainWindow, IDynamicLibraryProvider { Q_OBJECT @@ -209,60 +185,4 @@ private slots: }; -class KeyboardShortcutDialog: public QWidget -{ - Q_OBJECT -public: - - explicit KeyboardShortcutDialog( FaceTrackNoIR *ftnoir, QWidget *parent=0, Qt::WindowFlags f=0 ); - virtual ~KeyboardShortcutDialog(); - void showEvent ( QShowEvent * event ); - -private: - Ui::UICKeyboardShortcutDialog ui; - void loadSettings(); - void save(); - - /** helper **/ - bool settingsDirty; - FaceTrackNoIR *mainApp; - -private slots: - void doOK(); - void doCancel(); -}; - -extern QList global_key_sequences; -#if defined(__WIN32) || defined(_WIN32) -class KeybindingWorkerDummy { -private: - LPDIRECTINPUT8 din; - LPDIRECTINPUTDEVICE8 dinkeyboard; - Key kCenter; - FaceTrackNoIR& window; -public: - volatile bool should_quit; - ~KeybindingWorkerDummy(); - KeybindingWorkerDummy(FaceTrackNoIR& w, Key keyCenter); - void run(); -}; -#else -class KeybindingWorkerDummy { -public: - KeybindingWorkerDummy(FaceTrackNoIR& w, Key keyCenter); - void run() {} -}; -#endif - -class KeybindingWorker : public QThread, public KeybindingWorkerDummy { - Q_OBJECT -public: - KeybindingWorker(FaceTrackNoIR& w, Key keyCenter) : KeybindingWorkerDummy(w, keyCenter) - { - } - void run() { - KeybindingWorkerDummy::run(); - } -}; - #endif // FaceTrackNoIR_H diff --git a/facetracknoir/shortcuts.cpp b/facetracknoir/shortcuts.cpp new file mode 100644 index 00000000..1a80c8dc --- /dev/null +++ b/facetracknoir/shortcuts.cpp @@ -0,0 +1,102 @@ +#if defined(__WIN32) || defined(_WIN32) +#include "facetracknoir/facetracknoir.h" +#include "facetracknoir/shortcut-dialog.h" +#include + +KeybindingWorkerDummy::~KeybindingWorkerDummy() { + if (dinkeyboard) { + dinkeyboard->Unacquire(); + dinkeyboard->Release(); + } + if (din) + din->Release(); +} + +KeybindingWorkerDummy::KeybindingWorkerDummy(FaceTrackNoIR& w, Key keyCenter) +: kCenter(keyCenter), window(w), should_quit(true), din(0), dinkeyboard(0) +{ + if (DirectInput8Create(GetModuleHandle(NULL), DIRECTINPUT_VERSION, IID_IDirectInput8, (void**)&din, NULL) != DI_OK) { + qDebug() << "setup DirectInput8 Creation failed!" << GetLastError(); + return; + } + if (din->CreateDevice(GUID_SysKeyboard, &dinkeyboard, NULL) != DI_OK) { + din->Release(); + din = 0; + qDebug() << "setup CreateDevice function failed!" << GetLastError(); + return; + } + if (dinkeyboard->SetDataFormat(&c_dfDIKeyboard) != DI_OK) { + qDebug() << "setup SetDataFormat function failed!" << GetLastError(); + dinkeyboard->Release(); + dinkeyboard = 0; + din->Release(); + din = 0; + return; + } + + if (dinkeyboard->SetCooperativeLevel(window.winId(), DISCL_NONEXCLUSIVE | DISCL_BACKGROUND) != DI_OK) { + dinkeyboard->Release(); + din->Release(); + din = 0; + dinkeyboard = 0; + qDebug() << "setup SetCooperativeLevel function failed!" << GetLastError(); + return; + } + if (dinkeyboard->Acquire() != DI_OK) + { + dinkeyboard->Release(); + din->Release(); + din = 0; + dinkeyboard = 0; + qDebug() << "setup dinkeyboard Acquire failed!" << GetLastError(); + return; + } + should_quit = false; +} + +#define PROCESS_KEY(k, s) \ + if (isKeyPressed(&k, keystate) && (!k.ever_pressed ? (k.timer.start(), k.ever_pressed = true) : k.timer.restart() > 100)) \ + window.s(); + +static bool isKeyPressed( const Key *key, const BYTE *keystate ) { + bool shift; + bool ctrl; + bool alt; + + if (keystate[key->keycode] & 0x80) { + shift = ( (keystate[DIK_LSHIFT] & 0x80) || (keystate[DIK_RSHIFT] & 0x80) ); + ctrl = ( (keystate[DIK_LCONTROL] & 0x80) || (keystate[DIK_RCONTROL] & 0x80) ); + alt = ( (keystate[DIK_LALT] & 0x80) || (keystate[DIK_RALT] & 0x80) ); + + // + // If one of the modifiers is needed and not pressed, return false. + // + if (key->shift && !shift) return false; + if (key->ctrl && !ctrl) return false; + if (key->alt && !alt) return false; + + // + // All is well! + // + return true; + } + return false; +} + +void KeybindingWorkerDummy::run() { + BYTE keystate[256]; + while (!should_quit) + { + if (dinkeyboard->GetDeviceState(256, (LPVOID)keystate) != DI_OK) { + qDebug() << "Tracker::run GetDeviceState function failed!" << GetLastError(); + Sleep(25); + continue; + } + + PROCESS_KEY(kCenter, shortcutRecentered); + + Sleep(25); + } +} +#else +#endif diff --git a/facetracknoir/shortcuts.h b/facetracknoir/shortcuts.h new file mode 100644 index 00000000..9f2fd5f6 --- /dev/null +++ b/facetracknoir/shortcuts.h @@ -0,0 +1,89 @@ +#pragma once +#include +#include +#include +#include "ui_ftnoir_keyboardshortcuts.h" + +class FaceTrackNoIR; + +class KeyboardShortcutDialog: public QWidget +{ + Q_OBJECT +public: + + explicit KeyboardShortcutDialog( FaceTrackNoIR *ftnoir, QWidget *parent=0, Qt::WindowFlags f=0 ); + virtual ~KeyboardShortcutDialog(); + void showEvent ( QShowEvent * event ); + +private: + Ui::UICKeyboardShortcutDialog ui; + void loadSettings(); + void save(); + + bool settingsDirty; + FaceTrackNoIR *mainApp; + +private slots: + void doOK(); + void doCancel(); +}; + +extern QList global_key_sequences; + +#if defined(__WIN32) || defined(_WIN32) +extern QList global_windows_key_sequences; +# undef DIRECTINPUT_VERSION +# define DIRECTINPUT_VERSION 0x0800 +# include +# undef DIRECTINPUT_VERSION +# define DIRECTINPUT_VERSION 0x0800 +# include + +struct Key { + BYTE keycode; + bool shift; + bool ctrl; + bool alt; + bool ever_pressed; + QElapsedTimer timer; +public: + Key() : keycode(0), shift(false), ctrl(false), alt(false), ever_pressed(false) + { + } +}; +#else +typedef unsigned char BYTE; +struct Key { int foo; }; +#endif + +#if defined(__WIN32) || defined(_WIN32) +class KeybindingWorkerImpl { +private: + LPDIRECTINPUT8 din; + LPDIRECTINPUTDEVICE8 dinkeyboard; + Key kCenter; + FaceTrackNoIR& window; +public: + volatile bool should_quit; + ~KeybindingWorkerImpl(); + KeybindingWorkerImpl(FaceTrackNoIR& w, Key keyCenter); + void run(); +}; +#else +class KeybindingWorkerImpl { +public: + KeybindingWorkerImpl(FaceTrackNoIR& w, Key keyCenter); + void run() {} +}; +#endif + +class KeybindingWorker : public QThread, public KeybindingWorkerImpl { + Q_OBJECT +public: + KeybindingWorker(FaceTrackNoIR& w, Key keyCenter) : KeybindingWorkerImpl(w, keyCenter) + { + } + void run() { + KeybindingWorkerImpl::run(); + } +}; -- cgit v1.2.3 From 3ae661f563d916ba779e26880f470d50a94ed83b Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 14 Sep 2013 18:10:56 +0200 Subject: Cleanup the main class's file some more. Windows still broken. --- facetracknoir/facetracknoir.cpp | 159 +--------------------------------------- facetracknoir/shortcuts.cpp | 134 ++++++++++++++++++++++++++++++++- facetracknoir/shortcuts.h | 4 + 3 files changed, 138 insertions(+), 159 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index 2d5fe4a0..087de81c 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -965,11 +965,6 @@ void FaceTrackNoIR::createIconGroupBox() void FaceTrackNoIR::protocolSelected(int index) { settingsDirty = true; - ui.btnShowServerControls->setEnabled ( true ); - - //setWindowIcon(QIcon(":/images/FaceTrackNoIR.png")); - //breaks with transparency -sh - //ui.btnShowServerControls->setIcon(icon);] } // @@ -977,8 +972,7 @@ void FaceTrackNoIR::protocolSelected(int index) // void FaceTrackNoIR::trackingSourceSelected(int index) { - settingsDirty = true; - ui.btnShowEngineControls->setEnabled ( true ); + settingsDirty = true; } // @@ -998,7 +992,7 @@ void FaceTrackNoIR::profileSelected(int index) // // Save the name of the INI-file in the Registry. // - settings.setValue ("SettingsFile", pathInfo.absolutePath() + "/" + iniFileList.value(ui.iconcomboProfile->currentIndex(), "")); + settings.setValue ("SettingsFile", pathInfo.absolutePath() + "/" + iniFileList.value(index, "")); loadSettings(); } @@ -1008,101 +1002,6 @@ void FaceTrackNoIR::profileSelected(int index) void FaceTrackNoIR::filterSelected(int index) { settingsDirty = true; - - //QSettings settings("opentrack"); // 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) - - ui.btnShowFilterControls->setEnabled ( true ); -} - -//**************************************************************************************************// -//**************************************************************************************************// -// -// Constructor for Keyboard-shortcuts-dialog -// -KeyboardShortcutDialog::KeyboardShortcutDialog( FaceTrackNoIR *ftnoir, QWidget *parent, Qt::WindowFlags f ) : -QWidget( parent , f) -{ - ui.setupUi( this ); - - QPoint offsetpos(100, 100); - this->move(parent->pos() + offsetpos); - - mainApp = ftnoir; // Preserve a pointer to FTNoIR - - // Connect Qt signals to member-functions - connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); - connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); - - // Clear the Lists with key-descriptions and keycodes and build the Lists - // The strings will all be added to the ListBoxes for each Shortkey - // - - // Add strings to the Listboxes. - // - - for ( int i = 0; i < global_key_sequences.size(); i++) { - ui.cbxCenterKey->addItem(global_key_sequences.at(i)); - } - - // Load the settings from the current .INI-file - loadSettings(); -} - -// -// Destructor for server-dialog -// -KeyboardShortcutDialog::~KeyboardShortcutDialog() { - qDebug() << "~KeyboardShortcutDialog() says: started"; -} - -// -// OK clicked on server-dialog -// -void KeyboardShortcutDialog::doOK() { - save(); - this->close(); - mainApp->bindKeyboardShortcuts(); -} - -// override show event -void KeyboardShortcutDialog::showEvent ( QShowEvent * event ) { - loadSettings(); -} - -// -// Cancel clicked on server-dialog -// -void KeyboardShortcutDialog::doCancel() { - // - // Ask if changed Settings should be saved - // - if (settingsDirty) { - int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard ); - - qDebug() << "doCancel says: answer =" << ret; - - switch (ret) { - case QMessageBox::Save: - save(); - this->close(); - break; - case QMessageBox::Discard: - this->close(); - break; - case QMessageBox::Cancel: - // Cancel was clicked - break; - default: - // should never be reached - break; - } - } - else { - this->close(); - } } void FaceTrackNoIR::bindKeyboardShortcuts() @@ -1163,60 +1062,6 @@ void FaceTrackNoIR::bindKeyboardShortcuts() } } -// -// Load the current Settings from the currently 'active' INI-file. -// -void KeyboardShortcutDialog::loadSettings() { - qDebug() << "loadSettings says: Starting "; - QSettings settings("opentrack"); // 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; - - iniFile.beginGroup ( "KB_Shortcuts" ); - - ui.chkCenterShift->setChecked (iniFile.value ( "Shift_Center", 0 ).toBool()); - ui.chkCenterCtrl->setChecked (iniFile.value ( "Ctrl_Center", 0 ).toBool()); - ui.chkCenterAlt->setChecked (iniFile.value ( "Alt_Center", 0 ).toBool()); - - ui.cbxCenterKey->setCurrentIndex(iniFile.value("Key_index_Center", 0).toInt()); - - iniFile.endGroup (); - - settingsDirty = false; - -} - -// -// Save the current Settings to the currently 'active' INI-file. -// -void KeyboardShortcutDialog::save() { - - qDebug() << "save() says: started"; - - QSettings settings("opentrack"); // 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) - - iniFile.beginGroup ( "KB_Shortcuts" ); - iniFile.setValue ( "Key_index_Center", ui.cbxCenterKey->currentIndex() ); - iniFile.setValue ( "Shift_Center", ui.chkCenterShift->isChecked() ); - iniFile.setValue ( "Ctrl_Center", ui.chkCenterCtrl->isChecked() ); - iniFile.setValue ( "Alt_Center", ui.chkCenterAlt->isChecked() ); - - iniFile.endGroup (); - - settingsDirty = false; - - // - // Send a message to the main program, to update the Settings (for the tracker) - // - mainApp->updateSettings(); -} - void FaceTrackNoIR::shortcutRecentered() { if (tracker) diff --git a/facetracknoir/shortcuts.cpp b/facetracknoir/shortcuts.cpp index 1a80c8dc..001edf80 100644 --- a/facetracknoir/shortcuts.cpp +++ b/facetracknoir/shortcuts.cpp @@ -1,6 +1,136 @@ -#if defined(__WIN32) || defined(_WIN32) #include "facetracknoir/facetracknoir.h" -#include "facetracknoir/shortcut-dialog.h" +#include "facetracknoir/shortcuts.h" + +KeyboardShortcutDialog::KeyboardShortcutDialog( FaceTrackNoIR *ftnoir, QWidget *parent, Qt::WindowFlags f ) : +QWidget( parent , f) +{ + ui.setupUi( this ); + + QPoint offsetpos(100, 100); + this->move(parent->pos() + offsetpos); + + mainApp = ftnoir; // Preserve a pointer to FTNoIR + + // Connect Qt signals to member-functions + connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); + connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); + + for ( int i = 0; i < global_key_sequences.size(); i++) { + ui.cbxCenterKey->addItem(global_key_sequences.at(i)); + } + + loadSettings(); +} + +// +// Destructor for server-dialog +// +KeyboardShortcutDialog::~KeyboardShortcutDialog() { + qDebug() << "~KeyboardShortcutDialog() says: started"; +} + +// +// OK clicked on server-dialog +// +void KeyboardShortcutDialog::doOK() { + save(); + this->close(); + mainApp->bindKeyboardShortcuts(); +} + +// override show event +void KeyboardShortcutDialog::showEvent ( QShowEvent * event ) { + loadSettings(); +} + +// +// Cancel clicked on server-dialog +// +void KeyboardShortcutDialog::doCancel() { + // + // Ask if changed Settings should be saved + // + if (settingsDirty) { + int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard ); + + qDebug() << "doCancel says: answer =" << ret; + + switch (ret) { + case QMessageBox::Save: + save(); + this->close(); + break; + case QMessageBox::Discard: + this->close(); + break; + case QMessageBox::Cancel: + // Cancel was clicked + break; + default: + // should never be reached + break; + } + } + else { + this->close(); + } +} + +// +// Load the current Settings from the currently 'active' INI-file. +// +void KeyboardShortcutDialog::loadSettings() { + qDebug() << "loadSettings says: Starting "; + QSettings settings("opentrack"); // 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; + + iniFile.beginGroup ( "KB_Shortcuts" ); + + ui.chkCenterShift->setChecked (iniFile.value ( "Shift_Center", 0 ).toBool()); + ui.chkCenterCtrl->setChecked (iniFile.value ( "Ctrl_Center", 0 ).toBool()); + ui.chkCenterAlt->setChecked (iniFile.value ( "Alt_Center", 0 ).toBool()); + + ui.cbxCenterKey->setCurrentIndex(iniFile.value("Key_index_Center", 0).toInt()); + + iniFile.endGroup (); + + settingsDirty = false; + +} + +// +// Save the current Settings to the currently 'active' INI-file. +// +void KeyboardShortcutDialog::save() { + + qDebug() << "save() says: started"; + + QSettings settings("opentrack"); // 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) + + iniFile.beginGroup ( "KB_Shortcuts" ); + iniFile.setValue ( "Key_index_Center", ui.cbxCenterKey->currentIndex() ); + iniFile.setValue ( "Shift_Center", ui.chkCenterShift->isChecked() ); + iniFile.setValue ( "Ctrl_Center", ui.chkCenterCtrl->isChecked() ); + iniFile.setValue ( "Alt_Center", ui.chkCenterAlt->isChecked() ); + + iniFile.endGroup (); + + settingsDirty = false; + + // + // Send a message to the main program, to update the Settings (for the tracker) + // + mainApp->updateSettings(); +} + +#if defined(__WIN32) || defined(_WIN32) #include KeybindingWorkerDummy::~KeybindingWorkerDummy() { diff --git a/facetracknoir/shortcuts.h b/facetracknoir/shortcuts.h index 9f2fd5f6..a254b2bb 100644 --- a/facetracknoir/shortcuts.h +++ b/facetracknoir/shortcuts.h @@ -2,6 +2,10 @@ #include #include #include +#include +#include +#include +#include #include "ui_ftnoir_keyboardshortcuts.h" class FaceTrackNoIR; -- cgit v1.2.3 From fc83b218cb5297071ce154f60c815588bbbeb769 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 14 Sep 2013 18:12:56 +0200 Subject: Remove unused functions --- facetracknoir/facetracknoir.cpp | 32 -------------------------------- facetracknoir/facetracknoir.h | 7 ------- 2 files changed, 39 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index 087de81c..16691c5d 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -139,14 +139,10 @@ void FaceTrackNoIR::setupFaceTrackNoIR() { //Load the tracker-settings, from the INI-file loadSettings(); - connect(ui.iconcomboProtocol, SIGNAL(currentIndexChanged(int)), this, SLOT(protocolSelected(int))); connect(ui.iconcomboProfile, SIGNAL(currentIndexChanged(int)), this, SLOT(profileSelected(int))); - connect(ui.iconcomboTrackerSource, SIGNAL(currentIndexChanged(int)), this, SLOT(trackingSourceSelected(int))); - connect(ui.iconcomboFilter, SIGNAL(currentIndexChanged(int)), this, SLOT(filterSelected(int))); //Setup the timer for showing the headpose. connect(&timUpdateHeadPose, SIGNAL(timeout()), this, SLOT(showHeadPose())); - settingsDirty = false; } /** destructor stops the engine and quits the faceapi **/ @@ -309,8 +305,6 @@ void FaceTrackNoIR::save() { iniFile.setValue ( "DLL", filter == NULL ? "" : filter->filename); } iniFile.endGroup (); - - settingsDirty = false; } // @@ -486,7 +480,6 @@ void FaceTrackNoIR::loadSettings() { ((CurveConfigurationDialog*)_curve_config)->loadSettings(); - settingsDirty = false; looping = false; } @@ -713,7 +706,6 @@ void FaceTrackNoIR::stopTracker( ) { void FaceTrackNoIR::setInvertAxis(Axis axis, int invert ) { if (tracker) tracker->setInvertAxis (axis, (invert != 0)?true:false ); - settingsDirty = true; } /** Show the headpose in the widget (triggered by timer) **/ @@ -959,22 +951,6 @@ void FaceTrackNoIR::createIconGroupBox() connect(ui.cbxSecondTrackerSource, SIGNAL(currentIndexChanged(int)), this, SLOT(trackingSourceSelected(int))); } -// -// Handle changes of the Protocol selection -// -void FaceTrackNoIR::protocolSelected(int index) -{ - settingsDirty = true; -} - -// -// Handle changes of the Tracking Source selection -// -void FaceTrackNoIR::trackingSourceSelected(int index) -{ - settingsDirty = true; -} - // // Handle changes of the Profile selection // @@ -996,14 +972,6 @@ void FaceTrackNoIR::profileSelected(int index) loadSettings(); } -// -// Handle changes of the Filter selection -// -void FaceTrackNoIR::filterSelected(int index) -{ - settingsDirty = true; -} - void FaceTrackNoIR::bindKeyboardShortcuts() { QSettings settings("opentrack"); // Registry settings (in HK_USER) diff --git a/facetracknoir/facetracknoir.h b/facetracknoir/facetracknoir.h index b1a1cb42..ba9538f6 100644 --- a/facetracknoir/facetracknoir.h +++ b/facetracknoir/facetracknoir.h @@ -122,10 +122,6 @@ private: QWidget *_curve_config; void createIconGroupBox(); -// void createMessageGroupBox(); - - /** helper **/ - bool settingsDirty; void GetCameraNameDX(); void loadSettings(); @@ -145,9 +141,6 @@ private slots: void exit(); // void setIcon(int index); void profileSelected(int index); - void protocolSelected(int index); - void filterSelected(int index); - void trackingSourceSelected(int index); void showVideoWidget(); void showHeadPoseWidget(); -- cgit v1.2.3 From 6370fd2457fb0ecff239a645fa78dbd97f2102b8 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 14 Sep 2013 18:19:00 +0200 Subject: Open-code stuff that has no place outside ctor --- facetracknoir/facetracknoir.cpp | 202 +++++++++++++++++++--------------------- 1 file changed, 94 insertions(+), 108 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index 16691c5d..508c616c 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -48,6 +48,43 @@ # define LIB_PREFIX "lib" #endif +static bool get_metadata(DynamicLibrary* lib, QString& longName, QIcon& icon) +{ + Metadata* meta; + if (!lib->Metadata || ((meta = lib->Metadata()), !meta)) + { + delete lib; + return false; + } + meta->getFullName(&longName); + meta->getIcon(&icon); + delete meta; + return true; +} + +static void fill_combobox(const QString& filter, QList& list, QComboBox* cbx, QComboBox* cbx2) +{ + QDir settingsDir( QCoreApplication::applicationDirPath() ); + QStringList filenames = settingsDir.entryList( QStringList() << (LIB_PREFIX + filter + SONAME), QDir::Files, QDir::Name ); + for ( int i = 0; i < filenames.size(); i++) { + QIcon icon; + QString longName; + QString str = filenames.at(i); + DynamicLibrary* lib = new DynamicLibrary(str); + qDebug() << "Loading" << str; + std::cout.flush(); + if (!get_metadata(lib, longName, icon)) + { + delete lib; + continue; + } + list.push_back(lib); + cbx->addItem(icon, longName); + if (cbx2) + cbx2->addItem(icon, longName); + } +} + // // Setup the Main Dialog // @@ -75,7 +112,63 @@ FaceTrackNoIR::FaceTrackNoIR(QWidget *parent, Qt::WFlags flags) : tracker = 0; - setupFaceTrackNoIR(); + // this is needed for Wine plugin subprocess + QDir::setCurrent(QCoreApplication::applicationDirPath()); + + // if we simply place a global variable with THeadPoseData, + // it gets initialized and pulls in QSettings before + // main() starts. program can and will crash. + + ui.headPoseWidget->show(); + ui.video_frame->hide(); + + // menu objects will be connected with the functions in FaceTrackNoIR class + connect(ui.btnLoad, SIGNAL(clicked()), this, SLOT(open())); + connect(ui.btnSave, SIGNAL(clicked()), this, SLOT(save())); + connect(ui.btnSaveAs, SIGNAL(clicked()), this, SLOT(saveAs())); + + connect(ui.btnEditCurves, SIGNAL(clicked()), this, SLOT(showCurveConfiguration())); + connect(ui.btnShortcuts, SIGNAL(clicked()), this, SLOT(showKeyboardShortcuts())); + connect(ui.btnShowEngineControls, SIGNAL(clicked()), this, SLOT(showTrackerSettings())); + connect(ui.btnShowSecondTrackerSettings, SIGNAL(clicked()), this, SLOT(showSecondTrackerSettings())); + connect(ui.btnShowServerControls, SIGNAL(clicked()), this, SLOT(showServerControls())); + connect(ui.btnShowFilterControls, SIGNAL(clicked()), this, SLOT(showFilterControls())); + + // Connect checkboxes + connect(ui.chkInvertYaw, SIGNAL(stateChanged(int)), this, SLOT(setInvertYaw(int))); + connect(ui.chkInvertRoll, SIGNAL(stateChanged(int)), this, SLOT(setInvertRoll(int))); + connect(ui.chkInvertPitch, SIGNAL(stateChanged(int)), this, SLOT(setInvertPitch(int))); + connect(ui.chkInvertX, SIGNAL(stateChanged(int)), this, SLOT(setInvertX(int))); + connect(ui.chkInvertY, SIGNAL(stateChanged(int)), this, SLOT(setInvertY(int))); + connect(ui.chkInvertZ, SIGNAL(stateChanged(int)), this, SLOT(setInvertZ(int))); + + // button methods connect with methods in this class + connect(ui.btnStartTracker, SIGNAL(clicked()), this, SLOT(startTracker())); + connect(ui.btnStopTracker, SIGNAL(clicked()), this, SLOT(stopTracker())); + + //read the camera-name, using DirectShow + GetCameraNameDX(); + + ui.cbxSecondTrackerSource->addItem(QIcon(), "None"); + dlopen_filters.push_back((DynamicLibrary*) NULL); + ui.iconcomboFilter->addItem(QIcon(), "None"); + + fill_combobox("opentrack-proto-*.", dlopen_protocols, ui.iconcomboProtocol, NULL); + fill_combobox("opentrack-tracker-*.", dlopen_trackers, ui.iconcomboTrackerSource, ui.cbxSecondTrackerSource); + fill_combobox("opentrack-filter-*.", dlopen_filters, ui.iconcomboFilter, NULL); + + connect(ui.iconcomboProtocol, SIGNAL(currentIndexChanged(int)), this, SLOT(protocolSelected(int))); + connect(ui.iconcomboTrackerSource, SIGNAL(currentIndexChanged(int)), this, SLOT(trackingSourceSelected(int))); + connect(ui.iconcomboFilter, SIGNAL(currentIndexChanged(int)), this, SLOT(filterSelected(int))); + connect(ui.cbxSecondTrackerSource, SIGNAL(currentIndexChanged(int)), this, SLOT(trackingSourceSelected(int))); + + connect(ui.iconcomboProfile, SIGNAL(currentIndexChanged(int)), this, SLOT(profileSelected(int))); + + //Setup the timer for showing the headpose. + connect(&timUpdateHeadPose, SIGNAL(timeout()), this, SLOT(showHeadPose())); + + //Load the tracker-settings, from the INI-file + loadSettings(); //Q_INIT_RESOURCE(PoseWidget); @@ -94,57 +187,6 @@ FaceTrackNoIR::FaceTrackNoIR(QWidget *parent, Qt::WFlags flags) : ui.lcdNumOutputRotZ->setVisible(false); } -/** sets up all objects and connections to buttons */ -void FaceTrackNoIR::setupFaceTrackNoIR() { - // this is needed for Wine plugin subprocess - QDir::setCurrent(QCoreApplication::applicationDirPath()); - - // if we simply place a global variable with THeadPoseData, - // it gets initialized and pulls in QSettings before - // main() starts. program can and will crash. - - ui.headPoseWidget->show(); - ui.video_frame->hide(); - - // menu objects will be connected with the functions in FaceTrackNoIR class - connect(ui.btnLoad, SIGNAL(clicked()), this, SLOT(open())); - connect(ui.btnSave, SIGNAL(clicked()), this, SLOT(save())); - connect(ui.btnSaveAs, SIGNAL(clicked()), this, SLOT(saveAs())); - - connect(ui.btnEditCurves, SIGNAL(clicked()), this, SLOT(showCurveConfiguration())); - connect(ui.btnShortcuts, SIGNAL(clicked()), this, SLOT(showKeyboardShortcuts())); - connect(ui.btnShowEngineControls, SIGNAL(clicked()), this, SLOT(showTrackerSettings())); - connect(ui.btnShowSecondTrackerSettings, SIGNAL(clicked()), this, SLOT(showSecondTrackerSettings())); - connect(ui.btnShowServerControls, SIGNAL(clicked()), this, SLOT(showServerControls())); - connect(ui.btnShowFilterControls, SIGNAL(clicked()), this, SLOT(showFilterControls())); - - // Connect checkboxes - connect(ui.chkInvertYaw, SIGNAL(stateChanged(int)), this, SLOT(setInvertYaw(int))); - connect(ui.chkInvertRoll, SIGNAL(stateChanged(int)), this, SLOT(setInvertRoll(int))); - connect(ui.chkInvertPitch, SIGNAL(stateChanged(int)), this, SLOT(setInvertPitch(int))); - connect(ui.chkInvertX, SIGNAL(stateChanged(int)), this, SLOT(setInvertX(int))); - connect(ui.chkInvertY, SIGNAL(stateChanged(int)), this, SLOT(setInvertY(int))); - connect(ui.chkInvertZ, SIGNAL(stateChanged(int)), this, SLOT(setInvertZ(int))); - - // button methods connect with methods in this class - connect(ui.btnStartTracker, SIGNAL(clicked()), this, SLOT(startTracker())); - connect(ui.btnStopTracker, SIGNAL(clicked()), this, SLOT(stopTracker())); - - //read the camera-name, using DirectShow - GetCameraNameDX(); - - //Create the system-tray and connect the events for that. - createIconGroupBox(); - - //Load the tracker-settings, from the INI-file - loadSettings(); - - connect(ui.iconcomboProfile, SIGNAL(currentIndexChanged(int)), this, SLOT(profileSelected(int))); - - //Setup the timer for showing the headpose. - connect(&timUpdateHeadPose, SIGNAL(timeout()), this, SLOT(showHeadPose())); -} - /** destructor stops the engine and quits the faceapi **/ FaceTrackNoIR::~FaceTrackNoIR() { @@ -895,62 +937,6 @@ void FaceTrackNoIR::exit() { QCoreApplication::exit(0); } -static bool get_metadata(DynamicLibrary* lib, QString& longName, QIcon& icon) -{ - Metadata* meta; - if (!lib->Metadata || ((meta = lib->Metadata()), !meta)) - { - delete lib; - return false; - } - meta->getFullName(&longName); - meta->getIcon(&icon); - delete meta; - return true; -} - -static void fill_combobox(const QString& filter, QList& list, QComboBox* cbx, QComboBox* cbx2) -{ - QDir settingsDir( QCoreApplication::applicationDirPath() ); - QStringList filenames = settingsDir.entryList( QStringList() << (LIB_PREFIX + filter + SONAME), QDir::Files, QDir::Name ); - for ( int i = 0; i < filenames.size(); i++) { - QIcon icon; - QString longName; - QString str = filenames.at(i); - DynamicLibrary* lib = new DynamicLibrary(str); - qDebug() << "Loading" << str; - std::cout.flush(); - if (!get_metadata(lib, longName, icon)) - { - delete lib; - continue; - } - list.push_back(lib); - cbx->addItem(icon, longName); - if (cbx2) - cbx2->addItem(icon, longName); - } -} - -// -// Setup the icons for the comboBoxes -// -void FaceTrackNoIR::createIconGroupBox() -{ - ui.cbxSecondTrackerSource->addItem(QIcon(), "None"); - dlopen_filters.push_back((DynamicLibrary*) NULL); - ui.iconcomboFilter->addItem(QIcon(), "None"); - - fill_combobox("opentrack-proto-*.", dlopen_protocols, ui.iconcomboProtocol, NULL); - fill_combobox("opentrack-tracker-*.", dlopen_trackers, ui.iconcomboTrackerSource, ui.cbxSecondTrackerSource); - fill_combobox("opentrack-filter-*.", dlopen_filters, ui.iconcomboFilter, NULL); - - connect(ui.iconcomboProtocol, SIGNAL(currentIndexChanged(int)), this, SLOT(protocolSelected(int))); - connect(ui.iconcomboTrackerSource, SIGNAL(currentIndexChanged(int)), this, SLOT(trackingSourceSelected(int))); - connect(ui.iconcomboFilter, SIGNAL(currentIndexChanged(int)), this, SLOT(filterSelected(int))); - connect(ui.cbxSecondTrackerSource, SIGNAL(currentIndexChanged(int)), this, SLOT(trackingSourceSelected(int))); -} - // // Handle changes of the Profile selection // -- cgit v1.2.3 From fd15fb1341e68fe15c8ff17c42cb67a665463134 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 14 Sep 2013 18:20:55 +0200 Subject: Remove useless comment --- facetracknoir/curve-config.cpp | 5 ----- 1 file changed, 5 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/curve-config.cpp b/facetracknoir/curve-config.cpp index 05b2e065..68303b44 100644 --- a/facetracknoir/curve-config.cpp +++ b/facetracknoir/curve-config.cpp @@ -1,11 +1,6 @@ #include "facetracknoir/facetracknoir.h" #include "facetracknoir/curve-config.h" #include -//**************************************************************************************************// -//**************************************************************************************************// -// -// Constructor for Curve-configuration-dialog -// CurveConfigurationDialog::CurveConfigurationDialog( FaceTrackNoIR *ftnoir, QWidget *parent, Qt::WindowFlags f ) : QWidget( parent , f) { -- cgit v1.2.3 From 8b409a50481d64383910bb9ddccc8d962705f017 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 14 Sep 2013 18:24:35 +0200 Subject: Absolutely no need to update tracker here --- facetracknoir/shortcuts.cpp | 5 ----- 1 file changed, 5 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/shortcuts.cpp b/facetracknoir/shortcuts.cpp index 001edf80..1dff7c60 100644 --- a/facetracknoir/shortcuts.cpp +++ b/facetracknoir/shortcuts.cpp @@ -123,11 +123,6 @@ void KeyboardShortcutDialog::save() { iniFile.endGroup (); settingsDirty = false; - - // - // Send a message to the main program, to update the Settings (for the tracker) - // - mainApp->updateSettings(); } #if defined(__WIN32) || defined(_WIN32) -- cgit v1.2.3 From 349ed6430b02b1b92fe5aa60a9b5daf2b29ae381 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 14 Sep 2013 18:24:52 +0200 Subject: Rename for clarity --- facetracknoir/curve-config.cpp | 2 +- facetracknoir/facetracknoir.cpp | 2 +- facetracknoir/facetracknoir.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/curve-config.cpp b/facetracknoir/curve-config.cpp index 68303b44..ba734111 100644 --- a/facetracknoir/curve-config.cpp +++ b/facetracknoir/curve-config.cpp @@ -239,5 +239,5 @@ void CurveConfigurationDialog::save() { // // Send a message to the main program, to update the Settings (for the tracker) // - mainApp->updateSettings(); + mainApp->update_tracker_settings(); } diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index 508c616c..84daff52 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -200,7 +200,7 @@ FaceTrackNoIR::~FaceTrackNoIR() { // // Update the Settings, after a value has changed. This way, the Tracker does not have to re-start. // -void FaceTrackNoIR::updateSettings() { +void FaceTrackNoIR::update_tracker_settings() { if ( tracker != NULL ) { tracker->loadSettings(); } diff --git a/facetracknoir/facetracknoir.h b/facetracknoir/facetracknoir.h index ba9538f6..763b5dad 100644 --- a/facetracknoir/facetracknoir.h +++ b/facetracknoir/facetracknoir.h @@ -76,7 +76,7 @@ public: FaceTrackNoIR(QWidget *parent = 0, Qt::WFlags flags = 0); ~FaceTrackNoIR(); - void updateSettings(); // Update the settings (let Tracker read INI-file). + void update_tracker_settings(); // Update the settings (let Tracker read INI-file). QFrame *get_video_widget(); // Get a pointer to the video-widget, to use in the DLL Tracker *tracker; -- cgit v1.2.3 From b7b54c64a94f9e42661ba80841e14d3f84549086 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 14 Sep 2013 18:26:29 +0200 Subject: Refresh splines only once --- facetracknoir/facetracknoir.cpp | 6 ------ 1 file changed, 6 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index 84daff52..0dca8183 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -509,12 +509,6 @@ void FaceTrackNoIR::loadSettings() { } } - for (int i = 0; i < 6; i++) - { - axis(i).curve.loadSettings(iniFile); - axis(i).curveAlt.loadSettings(iniFile); - } - if (!_curve_config) { _curve_config = new CurveConfigurationDialog( this, this, Qt::Dialog ); -- cgit v1.2.3 From 924620c03eb640fd11ecceabc867a0d30a4d504b Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 14 Sep 2013 18:29:05 +0200 Subject: Open-code always-constant params --- facetracknoir/curve-config.cpp | 4 ++-- facetracknoir/curve-config.h | 2 +- facetracknoir/facetracknoir.cpp | 6 +++--- facetracknoir/shortcuts.cpp | 4 ++-- facetracknoir/shortcuts.h | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/curve-config.cpp b/facetracknoir/curve-config.cpp index ba734111..a4dd03ae 100644 --- a/facetracknoir/curve-config.cpp +++ b/facetracknoir/curve-config.cpp @@ -1,8 +1,8 @@ #include "facetracknoir/facetracknoir.h" #include "facetracknoir/curve-config.h" #include -CurveConfigurationDialog::CurveConfigurationDialog( FaceTrackNoIR *ftnoir, QWidget *parent, Qt::WindowFlags f ) : -QWidget( parent , f) +CurveConfigurationDialog::CurveConfigurationDialog(FaceTrackNoIR *ftnoir, QWidget *parent) : +QWidget( parent, Qt::Dialog ) { ui.setupUi( this ); diff --git a/facetracknoir/curve-config.h b/facetracknoir/curve-config.h index e783dd33..1fcddc4e 100644 --- a/facetracknoir/curve-config.h +++ b/facetracknoir/curve-config.h @@ -9,7 +9,7 @@ class CurveConfigurationDialog: public QWidget Q_OBJECT public: - explicit CurveConfigurationDialog( FaceTrackNoIR *ftnoir, QWidget *parent=0, Qt::WindowFlags f=0 ); + explicit CurveConfigurationDialog( FaceTrackNoIR *ftnoir, QWidget *parent ); virtual ~CurveConfigurationDialog(); void showEvent ( QShowEvent * event ); void loadSettings(); diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index 0dca8183..60e2e124 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -511,7 +511,7 @@ void FaceTrackNoIR::loadSettings() { if (!_curve_config) { - _curve_config = new CurveConfigurationDialog( this, this, Qt::Dialog ); + _curve_config = new CurveConfigurationDialog( this, this ); } ((CurveConfigurationDialog*)_curve_config)->loadSettings(); @@ -900,7 +900,7 @@ void FaceTrackNoIR::showKeyboardShortcuts() { // Create if new if (!_keyboard_shortcuts) { - _keyboard_shortcuts = new KeyboardShortcutDialog( this, this, Qt::Dialog ); + _keyboard_shortcuts = new KeyboardShortcutDialog( this, this ); } // Show if already created @@ -916,7 +916,7 @@ void FaceTrackNoIR::showCurveConfiguration() { // Create if new if (!_curve_config) { - _curve_config = new CurveConfigurationDialog( this, this, Qt::Dialog ); + _curve_config = new CurveConfigurationDialog( this, this ); } // Show if already created diff --git a/facetracknoir/shortcuts.cpp b/facetracknoir/shortcuts.cpp index 1dff7c60..57f64998 100644 --- a/facetracknoir/shortcuts.cpp +++ b/facetracknoir/shortcuts.cpp @@ -1,8 +1,8 @@ #include "facetracknoir/facetracknoir.h" #include "facetracknoir/shortcuts.h" -KeyboardShortcutDialog::KeyboardShortcutDialog( FaceTrackNoIR *ftnoir, QWidget *parent, Qt::WindowFlags f ) : -QWidget( parent , f) +KeyboardShortcutDialog::KeyboardShortcutDialog( FaceTrackNoIR *ftnoir, QWidget *parent ) + : QWidget( parent, Qt::Dialog) { ui.setupUi( this ); diff --git a/facetracknoir/shortcuts.h b/facetracknoir/shortcuts.h index a254b2bb..15256b6c 100644 --- a/facetracknoir/shortcuts.h +++ b/facetracknoir/shortcuts.h @@ -15,7 +15,7 @@ class KeyboardShortcutDialog: public QWidget Q_OBJECT public: - explicit KeyboardShortcutDialog( FaceTrackNoIR *ftnoir, QWidget *parent=0, Qt::WindowFlags f=0 ); + explicit KeyboardShortcutDialog( FaceTrackNoIR *ftnoir, QWidget *parent ); virtual ~KeyboardShortcutDialog(); void showEvent ( QShowEvent * event ); -- cgit v1.2.3 From ba960bad6766cc8315c62b460ed4f2c88274a629 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 14 Sep 2013 18:33:19 +0200 Subject: Unbreak Windows partially --- facetracknoir/shortcuts.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/shortcuts.cpp b/facetracknoir/shortcuts.cpp index 57f64998..c2778806 100644 --- a/facetracknoir/shortcuts.cpp +++ b/facetracknoir/shortcuts.cpp @@ -128,7 +128,7 @@ void KeyboardShortcutDialog::save() { #if defined(__WIN32) || defined(_WIN32) #include -KeybindingWorkerDummy::~KeybindingWorkerDummy() { +KeybindingWorkerImpl::~KeybindingWorkerImpl() { if (dinkeyboard) { dinkeyboard->Unacquire(); dinkeyboard->Release(); @@ -137,7 +137,7 @@ KeybindingWorkerDummy::~KeybindingWorkerDummy() { din->Release(); } -KeybindingWorkerDummy::KeybindingWorkerDummy(FaceTrackNoIR& w, Key keyCenter) +KeybindingWorkerImpl::KeybindingWorkerImpl(FaceTrackNoIR& w, Key keyCenter) : kCenter(keyCenter), window(w), should_quit(true), din(0), dinkeyboard(0) { if (DirectInput8Create(GetModuleHandle(NULL), DIRECTINPUT_VERSION, IID_IDirectInput8, (void**)&din, NULL) != DI_OK) { @@ -208,7 +208,7 @@ static bool isKeyPressed( const Key *key, const BYTE *keystate ) { return false; } -void KeybindingWorkerDummy::run() { +void KeybindingWorkerImpl::run() { BYTE keystate[256]; while (!should_quit) { -- cgit v1.2.3 From 7bb0bdcd09d2dbe2bd0132fc9433a8c0091da18d Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 14 Sep 2013 18:33:45 +0200 Subject: Reduce macro scope --- facetracknoir/shortcuts.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/shortcuts.cpp b/facetracknoir/shortcuts.cpp index c2778806..cf4b81f8 100644 --- a/facetracknoir/shortcuts.cpp +++ b/facetracknoir/shortcuts.cpp @@ -179,10 +179,6 @@ KeybindingWorkerImpl::KeybindingWorkerImpl(FaceTrackNoIR& w, Key keyCenter) should_quit = false; } -#define PROCESS_KEY(k, s) \ - if (isKeyPressed(&k, keystate) && (!k.ever_pressed ? (k.timer.start(), k.ever_pressed = true) : k.timer.restart() > 100)) \ - window.s(); - static bool isKeyPressed( const Key *key, const BYTE *keystate ) { bool shift; bool ctrl; @@ -208,6 +204,10 @@ static bool isKeyPressed( const Key *key, const BYTE *keystate ) { return false; } +#define PROCESS_KEY(k, s) \ + if (isKeyPressed(&k, keystate) && (!k.ever_pressed ? (k.timer.start(), k.ever_pressed = true) : k.timer.restart() > 100)) \ + window.s(); + void KeybindingWorkerImpl::run() { BYTE keystate[256]; while (!should_quit) @@ -223,5 +223,6 @@ void KeybindingWorkerImpl::run() { Sleep(25); } } + #else #endif -- cgit v1.2.3 From 38303ae6a79fc8dea560a2d2813fe1ea360e401d Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 14 Sep 2013 18:48:16 +0200 Subject: Recent braino resulted in double free in error path --- facetracknoir/facetracknoir.cpp | 3 --- 1 file changed, 3 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index 60e2e124..85607329 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -52,10 +52,7 @@ static bool get_metadata(DynamicLibrary* lib, QString& longName, QIcon& icon) { Metadata* meta; if (!lib->Metadata || ((meta = lib->Metadata()), !meta)) - { - delete lib; return false; - } meta->getFullName(&longName); meta->getIcon(&icon); delete meta; -- cgit v1.2.3 From ec1c2b16379d657db92c90e25b9e01393267b596 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 14 Sep 2013 18:51:32 +0200 Subject: Clean up preprocessor mingw-isms No functional changes. --- compat/compat.cpp | 2 +- compat/compat.h | 6 +++--- facetracknoir/facetracknoir.cpp | 17 ++++++++--------- facetracknoir/facetracknoir.h | 4 ++-- facetracknoir/global-settings.cpp | 6 +++--- facetracknoir/global-settings.h | 6 +++--- facetracknoir/global-shortcuts.cpp | 2 +- facetracknoir/shortcuts.cpp | 2 +- facetracknoir/shortcuts.h | 4 ++-- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 4 ++-- ftnoir_tracker_ht/ftnoir_tracker_ht.cpp | 6 +++--- 11 files changed, 29 insertions(+), 30 deletions(-) (limited to 'facetracknoir') diff --git a/compat/compat.cpp b/compat/compat.cpp index 8eedc845..d8aac9bc 100644 --- a/compat/compat.cpp +++ b/compat/compat.cpp @@ -7,7 +7,7 @@ #define IN_FTNOIR_COMPAT #include "compat.h" -#if defined(_WIN32) || defined(__WIN32) +#if defined(_WIN32) PortableLockedShm::PortableLockedShm(const char* shmName, const char* mutexName, int mapSize) { diff --git a/compat/compat.h b/compat/compat.h index 7692b38a..6a95f167 100644 --- a/compat/compat.h +++ b/compat/compat.h @@ -6,7 +6,7 @@ */ #pragma once -#if defined(_WIN32) || defined(__WIN32) +#if defined(_WIN32) #include #else #include @@ -19,7 +19,7 @@ #include #endif -#if defined(IN_FTNOIR_COMPAT) && (defined(_WIN32) || defined(__WIN32)) +#if defined(IN_FTNOIR_COMPAT) && defined(_WIN32) # define COMPAT_EXPORT __declspec(dllexport) #else # define COMPAT_EXPORT @@ -33,7 +33,7 @@ public: void unlock(); void* mem; private: -#if defined(_WIN32) || defined(__WIN32) +#if defined(_WIN32) HANDLE hMutex, hMapFile; #else int fd, size; diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index 85607329..6ff1759b 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -27,14 +27,14 @@ #include #include -#if defined(__WIN32) || defined(_WIN32) +#if defined(_WIN32) # include # include #endif #if defined(__APPLE__) # define SONAME "dylib" -#elif defined(_WIN32) || defined(__WIN32) +#elif defined(_WIN32) # define SONAME "dll" #else # define SONAME "so" @@ -86,7 +86,7 @@ static void fill_combobox(const QString& filter, QList& list, Q // Setup the Main Dialog // FaceTrackNoIR::FaceTrackNoIR(QWidget *parent, Qt::WFlags flags) : - #if defined(__WIN32) || defined(_WIN32) + #if defined(_WIN32) keybindingWorker(NULL), #else keyCenter(0), @@ -544,7 +544,7 @@ void FaceTrackNoIR::startTracker( ) { return; } -#if defined(_WIN32) || defined(__WIN32) +#if defined(_WIN32) keybindingWorker = new KeybindingWorker(*this, keyCenter); keybindingWorker->start(); #endif @@ -657,7 +657,7 @@ void FaceTrackNoIR::startTracker( ) { /** stop tracking the face **/ void FaceTrackNoIR::stopTracker( ) { ui.game_name->setText("Not connected"); -#if defined(_WIN32) || defined(__WIN32) +#if defined(_WIN32) if (keybindingWorker) { keybindingWorker->should_quit = true; @@ -958,7 +958,7 @@ void FaceTrackNoIR::bindKeyboardShortcuts() iniFile.beginGroup ( "KB_Shortcuts" ); int idxCenter = iniFile.value("Key_index_Center", 0).toInt(); -#if !defined(_WIN32) && !defined(__WIN32) +#if !defined(_WIN32) if (keyCenter) { delete keyCenter; keyCenter = NULL; @@ -979,7 +979,6 @@ void FaceTrackNoIR::bindKeyboardShortcuts() connect(keyCenter, SIGNAL(activated()), this, SLOT(shortcutRecentered())); } } - #else keyCenter.keycode = 0; keyCenter.shift = keyCenter.alt = keyCenter.ctrl = 0; @@ -993,7 +992,7 @@ void FaceTrackNoIR::bindKeyboardShortcuts() if (tracker) /* running already */ { -#if defined(_WIN32) || defined(__WIN32) +#if defined(_WIN32) if (keybindingWorker) { keybindingWorker->should_quit = true; @@ -1011,7 +1010,7 @@ void FaceTrackNoIR::shortcutRecentered() { if (tracker) { -#if defined(__WIN32) || defined(_WIN32) +#if defined(_WIN32) MessageBeep(MB_OK); #else QApplication::beep(); diff --git a/facetracknoir/facetracknoir.h b/facetracknoir/facetracknoir.h index 763b5dad..8f83a851 100644 --- a/facetracknoir/facetracknoir.h +++ b/facetracknoir/facetracknoir.h @@ -44,7 +44,7 @@ #include #include #include -#if !defined(_WIN32) && !defined(__WIN32) +#if !defined(_WIN32) # include #else # include @@ -97,7 +97,7 @@ public: return *pose.axes[idx]; } -#if defined(_WIN32) || defined(__WIN32) +#if defined(_WIN32) Key keyCenter; KeybindingWorker* keybindingWorker; #else diff --git a/facetracknoir/global-settings.cpp b/facetracknoir/global-settings.cpp index f605b591..4a655171 100644 --- a/facetracknoir/global-settings.cpp +++ b/facetracknoir/global-settings.cpp @@ -1,6 +1,6 @@ #include "global-settings.h" -#if !(defined(__WIN32) || defined(_WIN32)) +#if !(defined(_WIN32)) # include #endif @@ -92,7 +92,7 @@ DynamicLibrary::DynamicLibrary(const QString& filename) { this->filename = filename; QString fullPath = QCoreApplication::applicationDirPath() + "/" + this->filename; -#if defined(__WIN32) || defined(_WIN32) +#if defined(_WIN32) handle = new QLibrary(fullPath); Dialog = (SETTINGS_FUNCTION) handle->resolve(MAYBE_STDCALL_UNDERSCORE "GetDialog" CALLING_CONVENTION_SUFFIX_VOID_FUNCTION); Constructor = (NULLARY_DYNAMIC_FUNCTION) handle->resolve(MAYBE_STDCALL_UNDERSCORE "GetConstructor" CALLING_CONVENTION_SUFFIX_VOID_FUNCTION); @@ -128,7 +128,7 @@ DynamicLibrary::DynamicLibrary(const QString& filename) DynamicLibrary::~DynamicLibrary() { -#if defined(__WIN32) || defined(_WIN32) +#if defined(_WIN32) handle->unload(); #else if (handle) diff --git a/facetracknoir/global-settings.h b/facetracknoir/global-settings.h index 29a8da62..b2a54e20 100644 --- a/facetracknoir/global-settings.h +++ b/facetracknoir/global-settings.h @@ -1,6 +1,6 @@ #pragma once -#if defined(_WIN32) || defined(__WIN32) +#if defined(_WIN32) # define CALLING_CONVENTION_SUFFIX_VOID_FUNCTION "@0" # ifdef _MSC_VER # define MAYBE_STDCALL_UNDERSCORE "_" @@ -21,7 +21,7 @@ #include "ftnoir_filter_base/ftnoir_filter_base.h" #include "ftnoir_protocol_base/ftnoir_protocol_base.h" -#if defined(_WIN32) || defined(__WIN32) +#if defined(_WIN32) # define CALLING_CONVENTION __stdcall #else # define CALLING_CONVENTION @@ -57,7 +57,7 @@ public: METADATA_FUNCTION Metadata; QString filename; private: -#if defined(_WIN32) || defined(__WIN32) +#if defined(_WIN32) QLibrary* handle; #else void* handle; diff --git a/facetracknoir/global-shortcuts.cpp b/facetracknoir/global-shortcuts.cpp index 286200c0..8666333c 100644 --- a/facetracknoir/global-shortcuts.cpp +++ b/facetracknoir/global-shortcuts.cpp @@ -1,6 +1,6 @@ #include "facetracknoir/facetracknoir.h" -#if defined(__WIN32) || defined(_WIN32) +#if defined(_WIN32) #include #include #include diff --git a/facetracknoir/shortcuts.cpp b/facetracknoir/shortcuts.cpp index cf4b81f8..cdb2c3b7 100644 --- a/facetracknoir/shortcuts.cpp +++ b/facetracknoir/shortcuts.cpp @@ -125,7 +125,7 @@ void KeyboardShortcutDialog::save() { settingsDirty = false; } -#if defined(__WIN32) || defined(_WIN32) +#if defined(_WIN32) #include KeybindingWorkerImpl::~KeybindingWorkerImpl() { diff --git a/facetracknoir/shortcuts.h b/facetracknoir/shortcuts.h index 15256b6c..685c78b6 100644 --- a/facetracknoir/shortcuts.h +++ b/facetracknoir/shortcuts.h @@ -34,7 +34,7 @@ private slots: extern QList global_key_sequences; -#if defined(__WIN32) || defined(_WIN32) +#if defined(_WIN32) extern QList global_windows_key_sequences; # undef DIRECTINPUT_VERSION # define DIRECTINPUT_VERSION 0x0800 @@ -60,7 +60,7 @@ typedef unsigned char BYTE; struct Key { int foo; }; #endif -#if defined(__WIN32) || defined(_WIN32) +#if defined(_WIN32) class KeybindingWorkerImpl { private: LPDIRECTINPUT8 din; diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index dcd91994..3f5960ef 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -17,7 +17,7 @@ #include #include -#if defined(_WIN32) || defined(__WIN32) +#if defined(_WIN32) #include #else #include @@ -26,7 +26,7 @@ // delicious copypasta static QList get_camera_names(void) { QList ret; -#if defined(_WIN32) || defined(__WIN32) +#if defined(_WIN32) // Create the System Device Enumerator. HRESULT hr; ICreateDevEnum *pSysDevEnum = NULL; diff --git a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp index 45c62f55..9be50efa 100644 --- a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp +++ b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp @@ -7,7 +7,7 @@ #include "facetracknoir/global-settings.h" #include -#if defined(_WIN32) || defined(__WIN32) +#if defined(_WIN32) #include #else #include @@ -16,7 +16,7 @@ // delicious copypasta static QList get_camera_names(void) { QList ret; -#if defined(_WIN32) || defined(__WIN32) +#if defined(_WIN32) // Create the System Device Enumerator. HRESULT hr; ICreateDevEnum *pSysDevEnum = NULL; @@ -175,7 +175,7 @@ void Tracker::StartTracker(QFrame* videoframe) shm->pause = shm->terminate = shm->running = false; shm->timer = 0; subprocess.setWorkingDirectory(QCoreApplication::applicationDirPath() + "/tracker-ht"); -#if defined(_WIN32) || defined(__WIN32) +#if defined(_WIN32) subprocess.start("\"" + QCoreApplication::applicationDirPath() + "/tracker-ht/headtracker-ftnoir" + "\""); #else subprocess.start(QCoreApplication::applicationDirPath() + "/tracker-ht/headtracker-ftnoir"); -- cgit v1.2.3 From 27c639d49f48632950204b54761944cbc15c777b Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 14 Sep 2013 19:10:10 +0200 Subject: Don't duplicate event handlers for every config reload --- facetracknoir/curve-config.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/curve-config.cpp b/facetracknoir/curve-config.cpp index a4dd03ae..5421c670 100644 --- a/facetracknoir/curve-config.cpp +++ b/facetracknoir/curve-config.cpp @@ -167,9 +167,9 @@ void CurveConfigurationDialog::loadSettings() { alt_configs[i]->setConfig(&mainApp->axis(i).curveAlt, currentFile); configs[i]->loadSettings(currentFile); alt_configs[i]->loadSettings(currentFile); - connect(configs[i], SIGNAL(CurveChanged(bool)), this, SLOT(curveChanged(bool))); - connect(alt_configs[i], SIGNAL(CurveChanged(bool)), this, SLOT(curveChanged(bool))); - connect(checkboxes[i], SIGNAL(stateChanged(int)), this, SLOT(curveChanged(int))); + connect(configs[i], SIGNAL(CurveChanged(bool)), this, SLOT(curveChanged(bool)), Qt::UniqueConnection); + connect(alt_configs[i], SIGNAL(CurveChanged(bool)), this, SLOT(curveChanged(bool)), Qt::UniqueConnection); + connect(checkboxes[i], SIGNAL(stateChanged(int)), this, SLOT(curveChanged(int)), Qt::UniqueConnection); } settingsDirty = false; -- cgit v1.2.3 From 2516f604e6d6728a994d607230ff22550019634c Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 14 Sep 2013 19:23:57 +0200 Subject: Remove outdated signal connections --- facetracknoir/facetracknoir.cpp | 5 ----- 1 file changed, 5 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index 6ff1759b..534f18c8 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -154,11 +154,6 @@ FaceTrackNoIR::FaceTrackNoIR(QWidget *parent, Qt::WFlags flags) : fill_combobox("opentrack-tracker-*.", dlopen_trackers, ui.iconcomboTrackerSource, ui.cbxSecondTrackerSource); fill_combobox("opentrack-filter-*.", dlopen_filters, ui.iconcomboFilter, NULL); - connect(ui.iconcomboProtocol, SIGNAL(currentIndexChanged(int)), this, SLOT(protocolSelected(int))); - connect(ui.iconcomboTrackerSource, SIGNAL(currentIndexChanged(int)), this, SLOT(trackingSourceSelected(int))); - connect(ui.iconcomboFilter, SIGNAL(currentIndexChanged(int)), this, SLOT(filterSelected(int))); - connect(ui.cbxSecondTrackerSource, SIGNAL(currentIndexChanged(int)), this, SLOT(trackingSourceSelected(int))); - connect(ui.iconcomboProfile, SIGNAL(currentIndexChanged(int)), this, SLOT(profileSelected(int))); //Setup the timer for showing the headpose. -- cgit v1.2.3 From 98a70e0e80e82f8bb0205d106c745cfa545e21a0 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 14 Sep 2013 19:30:08 +0200 Subject: Init X11 threads on Q_OS_UNIX --- CMakeLists.txt | 2 ++ facetracknoir/main.cpp | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'facetracknoir') diff --git a/CMakeLists.txt b/CMakeLists.txt index 8c7b1389..6e5b6978 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -492,6 +492,8 @@ endif() add_executable(opentrack ${opentrack-win32-executable} ${opentrack-bin-c} ${opentrack-bin-moc} ${opentrack-bin-uih} ${opentrack-bin-rcc}) if(WIN32) target_link_libraries(opentrack "${CMAKE_SOURCE_DIR}/dinput/dinput8.lib" "${CMAKE_SOURCE_DIR}/dinput/dxguid.lib" "${CMAKE_SOURCE_DIR}/dinput/strmiids.lib" winmm) + else() + target_link_libraries(opentrack X11) endif() if(MSVC) SET_TARGET_PROPERTIES(opentrack PROPERTIES LINK_FLAGS "/ENTRY:mainCRTStartup") diff --git a/facetracknoir/main.cpp b/facetracknoir/main.cpp index bc0f973b..4dc96603 100644 --- a/facetracknoir/main.cpp +++ b/facetracknoir/main.cpp @@ -30,13 +30,17 @@ #include #if defined(_WIN32) -#include +# include //#pragma comment(linker, "/SUBSYSTEM:console /ENTRY:mainCRTStartup") +#elif defined(Q_OS_UNIX) +#include #endif int main(int argc, char** argv) { #if defined(_WIN32) (void) timeBeginPeriod(1); +#elif defined(Q_OS_UNIX) + XInitThreads(); #endif QApplication app(argc, argv); QFont font; -- cgit v1.2.3 From b85584d51cd028ef9f2cad5aee021b32915b7752 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 14 Sep 2013 19:33:27 +0200 Subject: Actually check for X11, not Unix --- facetracknoir/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'facetracknoir') diff --git a/facetracknoir/main.cpp b/facetracknoir/main.cpp index 4dc96603..d487de57 100644 --- a/facetracknoir/main.cpp +++ b/facetracknoir/main.cpp @@ -39,7 +39,7 @@ int main(int argc, char** argv) { #if defined(_WIN32) (void) timeBeginPeriod(1); -#elif defined(Q_OS_UNIX) +#elif defined(Q_WS_X11) XInitThreads(); #endif QApplication app(argc, argv); -- cgit v1.2.3 From c34777d460d41a485f2e2900bd2954490b82ac1b Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 14 Sep 2013 21:41:10 +0200 Subject: filter API: Remove implementation detail. Sprinkle const --- facetracknoir/tracker.cpp | 3 +-- ftnoir_filter_accela/ftnoir_filter_accela.cpp | 5 ++--- ftnoir_filter_accela/ftnoir_filter_accela.h | 3 ++- ftnoir_filter_base/ftnoir_filter_base.h | 2 +- ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp | 5 ++--- ftnoir_filter_ewma2/ftnoir_filter_ewma2.h | 7 +++---- 6 files changed, 11 insertions(+), 14 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/tracker.cpp b/facetracknoir/tracker.cpp index cdf28d40..5acf7dea 100644 --- a/facetracknoir/tracker.cpp +++ b/facetracknoir/tracker.cpp @@ -56,7 +56,6 @@ static void get_curve(double pos, double& out, THeadPoseDOF& axis) { /** QThread run method @override **/ void Tracker::run() { - T6DOF current_camera; // Used for filtering T6DOF target_camera; T6DOF new_camera; @@ -135,7 +134,7 @@ void Tracker::run() { if (Libraries->pFilter) { for (int i = 0; i < 6; i++) last_post_filter[i] = gameoutput_camera.axes[i]; - Libraries->pFilter->FilterHeadPoseData(current_camera.axes, target_camera.axes, new_camera.axes, last_post_filter); + Libraries->pFilter->FilterHeadPoseData(target_camera.axes, new_camera.axes, last_post_filter); } else { new_camera = target_camera; diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.cpp b/ftnoir_filter_accela/ftnoir_filter_accela.cpp index ee7289a4..e0b80034 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela.cpp @@ -51,10 +51,9 @@ static double parabola(const double a, const double x) return a1 * x * x; } -void FTNoIR_Filter::FilterHeadPoseData(double *current_camera_position, - double *target_camera_position, +void FTNoIR_Filter::FilterHeadPoseData(const double *target_camera_position, double *new_camera_position, - double *last_post_filter_values) + const double *last_post_filter_values) { if (first_run) { diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.h b/ftnoir_filter_accela/ftnoir_filter_accela.h index 333ab08d..55e413aa 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.h +++ b/ftnoir_filter_accela/ftnoir_filter_accela.h @@ -46,7 +46,7 @@ class FTNOIR_FILTER_BASE_EXPORT FTNoIR_Filter : public IFilter public: FTNoIR_Filter(); ~FTNoIR_Filter(); - void FilterHeadPoseData(double *current_camera_position, double *target_camera_position, double *new_camera_position, double *last_post_filter_values); + void FilterHeadPoseData(const double *target_camera_position, double *new_camera_position, const double *last_post_filter_values); void Initialize() { first_run = true; } @@ -56,6 +56,7 @@ private: void loadSettings(); bool first_run; double rotation_alpha, translation_alpha, zoom_factor; + double current_camera_position[6]; }; //******************************************************************************************************* diff --git a/ftnoir_filter_base/ftnoir_filter_base.h b/ftnoir_filter_base/ftnoir_filter_base.h index 49454a7e..b8b5017d 100644 --- a/ftnoir_filter_base/ftnoir_filter_base.h +++ b/ftnoir_filter_base/ftnoir_filter_base.h @@ -26,7 +26,7 @@ struct IFilter { virtual ~IFilter() {} - virtual void FilterHeadPoseData(double *current_camera_position, double *target_camera_position, double *new_camera_position, double *last_post_filter) = 0; + virtual void FilterHeadPoseData(const double *target_camera_position, double *new_camera_position, const double *last_post_filter) = 0; virtual void Initialize() = 0; }; diff --git a/ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp b/ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp index bb9fd4c9..6904dd92 100644 --- a/ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp +++ b/ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp @@ -79,10 +79,9 @@ void FTNoIR_Filter::loadSettings() { iniFile.endGroup (); } -void FTNoIR_Filter::FilterHeadPoseData(double *current_camera_position, - double *target_camera_position, +void FTNoIR_Filter::FilterHeadPoseData(const double *target_camera_position, double *new_camera_position, - double *last_post_filter) + const double *last_post_filter) { double delta; double new_alpha; diff --git a/ftnoir_filter_ewma2/ftnoir_filter_ewma2.h b/ftnoir_filter_ewma2/ftnoir_filter_ewma2.h index 91f32816..4f9cdba3 100644 --- a/ftnoir_filter_ewma2/ftnoir_filter_ewma2.h +++ b/ftnoir_filter_ewma2/ftnoir_filter_ewma2.h @@ -44,10 +44,9 @@ public: ~FTNoIR_Filter(); void Initialize() {} - void FilterHeadPoseData(double *current_camera_position, - double *target_camera_position, + void FilterHeadPoseData(const double *target_camera_position, double *new_camera_position, - double *last_post_filter); + const double *last_post_filter); void receiveSettings(double smin, double smax, double sexpt); private: @@ -61,7 +60,7 @@ private: double kMinSmoothing; double kMaxSmoothing; double kSmoothingScaleCurve; - + double current_camera_position[6]; QMutex mutex; }; -- cgit v1.2.3 From 94c0368c1a008d089ab780ffcea4f8aa24a0ee35 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 14 Sep 2013 23:46:24 +0200 Subject: Unbreak Windows build --- facetracknoir/facetracknoir.h | 1 + freetrackclient/freetrackclient.cpp | 18 +++++++----------- 2 files changed, 8 insertions(+), 11 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.h b/facetracknoir/facetracknoir.h index 8f83a851..b4ea2912 100644 --- a/facetracknoir/facetracknoir.h +++ b/facetracknoir/facetracknoir.h @@ -62,6 +62,7 @@ #include "global-settings.h" #include "tracker.h" #include "facetracknoir/curve-config.h" +#include "facetracknoir/shortcuts.h" class Tracker; // pre-define class to avoid circular includes class FaceTrackNoIR; diff --git a/freetrackclient/freetrackclient.cpp b/freetrackclient/freetrackclient.cpp index 52aa6190..0f8ced65 100644 --- a/freetrackclient/freetrackclient.cpp +++ b/freetrackclient/freetrackclient.cpp @@ -34,7 +34,7 @@ #include #include -#include "ftnoir_protocol_ft\fttypes.h" +#include "ftnoir_protocol_ft/fttypes.h" // // Functions to create/open the file-mapping @@ -58,8 +58,8 @@ static FILE *debug_stream = fopen("c:\\FreeTrackClient.log", "a"); static HANDLE hFTMemMap = 0; static FTMemMap *pMemData = 0; static HANDLE hFTMutex = 0; -static char* dllVersion = "1.0.0.0"; -static char* dllProvider = "FreeTrack"; +static const char* dllVersion = "1.0.0.0"; +static const char* dllProvider = "FreeTrack"; static unsigned short gameid = 0; @@ -92,13 +92,13 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) /****************************************************************** * FTGetData (FreeTrackClient.1) */ + #pragma comment(linker, "/export:FTGetData@4=FTGetData") FT_EXPORT(bool) FTGetData(PFreetrackData data) { - static int frame = 0; static int prevDataID = 0; static int dlyTrackingOff = 0; - static int tracking = 0; + // dbg_report("NP_GetData called."); if (FTCreateMapping() == false) return false; @@ -117,7 +117,6 @@ FT_EXPORT(bool) FTGetData(PFreetrackData data) dlyTrackingOff++; if (dlyTrackingOff > 20) { dlyTrackingOff = 100; - tracking = false; } } prevDataID = pMemData->data.DataID; @@ -161,7 +160,7 @@ FT_EXPORT(void) FTReportName( int name ) * FTGetDllVersion (FreeTrackClient.3) */ #pragma comment(linker, "/export:FTGetDllVersion@0=FTGetDllVersion") -extern "C" __declspec( dllexport ) char* FTGetDllVersion(void) +extern "C" __declspec( dllexport ) const char* FTGetDllVersion(void) { dbg_report("FTGetDllVersion request.\n"); @@ -172,7 +171,7 @@ extern "C" __declspec( dllexport ) char* FTGetDllVersion(void) * FTProvider (FreeTrackClient.4) */ #pragma comment(linker, "/export:FTProvider@0=FTProvider") -extern "C" __declspec( dllexport ) char* FTProvider(void) +extern "C" __declspec( dllexport ) const char* FTProvider(void) { dbg_report("FTProvider request.\n"); @@ -186,8 +185,6 @@ extern "C" __declspec( dllexport ) char* FTProvider(void) // bool FTCreateMapping() { - bool bMappingExists = false; - // // Memory-mapping already exists! // @@ -211,7 +208,6 @@ bool FTCreateMapping() if ( ( hFTMemMap != 0 ) && ( GetLastError() == ERROR_ALREADY_EXISTS ) ) { dbg_report("FTCreateMapping: Mapping already exists.\n"); - bMappingExists = true; // So the server was (probably) already started! CloseHandle( hFTMemMap ); hFTMemMap = 0; } -- cgit v1.2.3 From e1cf876626aad4cbed2db96f30867c8e11af340e Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 15 Sep 2013 03:44:46 +0200 Subject: Fix MSVC build. Also, minor reformat --- CMakeLists.txt | 8 +- facetracknoir/curve-config.h | 1 - facetracknoir/facetracknoir.cpp | 2 +- facetracknoir/facetracknoir.h | 104 ++++++++++----------- facetracknoir/tracker.h | 15 --- ftnoir_filter_accela/ftnoir_filter_accela.h | 5 +- ftnoir_filter_base/ftnoir_filter_base_global.h | 2 +- ftnoir_protocol_base/ftnoir_protocol_base_global.h | 2 +- ftnoir_tracker_base/ftnoir_tracker_base.h | 6 -- ftnoir_tracker_base/ftnoir_tracker_base_global.h | 2 +- ftnoir_tracker_base/ftnoir_tracker_types.h | 5 - qfunctionconfigurator/functionconfig.cpp | 5 + qfunctionconfigurator/functionconfig.h | 11 +-- qfunctionconfigurator/qfunctionconfigurator.h | 2 + 14 files changed, 66 insertions(+), 104 deletions(-) (limited to 'facetracknoir') diff --git a/CMakeLists.txt b/CMakeLists.txt index 25d3a809..f906d0a2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,8 +28,6 @@ if(NOT SDK_FACEAPI_ONLY) find_package(OpenCV) find_package(Qt4 COMPONENTS QtCore QtGui QtDesigner QtXml QtNetwork REQUIRED) - add_definitions(-DFTNOIR_FILTER_BASE_LIB -DFTNOIR_TRACKER_BASE_LIB -DFTNOIR_PROTOCOL_BASE_LIB) - if(NOT WIN32) if(NOT QXT_QXTGUI_LIB_RELEASE) find_package(Qxt COMPONENTS QxtGui REQUIRED) @@ -297,7 +295,6 @@ endif() SET (CMAKE_MODULE_LINKER_FLAGS ${CMAKE_MODULE_LINKER_FLAGS_INIT} -rdynamic CACHE STRING "Flags used by the linker during the creation of modules.") endif() - add_library(opentrack-compat SHARED ${opentrack-compat-c}) if(NOT WIN32) target_link_libraries(opentrack-compat rt) @@ -314,8 +311,8 @@ endif() add_library(opentrack-pose-widget SHARED ${opentrack-pose-widget-c} ${opentrack-pose-widget-moc} ${opentrack-pose-widget-rcc}) target_link_libraries(opentrack-pose-widget ${MY_QT_LIBS}) - add_library(opentrack-spline-widget SHARED ${opentrack-spline-widget-c} ${opentrack-spline-widget-moc} ${MY_QT_LIBS} ${QT_QTDESIGNER_LIBRARY_RELEASE}) - target_link_libraries(opentrack-spline-widget ${MY_QT_LIBS}) + add_library(opentrack-spline-widget SHARED ${opentrack-spline-widget-c} ${opentrack-spline-widget-moc}) + target_link_libraries(opentrack-spline-widget ${MY_QT_LIBS} ${QT_QTDESIGNER_LIBRARY_RELEASE}) add_library(opentrack-filter-accela SHARED ${opentrack-filter-accela-c} ${opentrack-filter-accela-moc} ${opentrack-filter-accela-uih} ${opentrack-filter-accela-rcc}) target_link_libraries(opentrack-filter-accela ${MY_QT_LIBS}) @@ -508,6 +505,7 @@ endif() if(NOT WIN32) target_link_libraries(opentrack dl) endif() + set_target_properties(opentrack PROPERTIES COMPILE_FLAGS -DOPENTRACK_MAIN) endif() # make install diff --git a/facetracknoir/curve-config.h b/facetracknoir/curve-config.h index 1fcddc4e..d02f1587 100644 --- a/facetracknoir/curve-config.h +++ b/facetracknoir/curve-config.h @@ -8,7 +8,6 @@ class CurveConfigurationDialog: public QWidget { Q_OBJECT public: - explicit CurveConfigurationDialog( FaceTrackNoIR *ftnoir, QWidget *parent ); virtual ~CurveConfigurationDialog(); void showEvent ( QShowEvent * event ); diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index 534f18c8..17dded92 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -24,7 +24,7 @@ #include "facetracknoir.h" #include "shortcuts.h" #include "tracker.h" -#include +#include "curve-config.h" #include #if defined(_WIN32) diff --git a/facetracknoir/facetracknoir.h b/facetracknoir/facetracknoir.h index b4ea2912..2aa6614f 100644 --- a/facetracknoir/facetracknoir.h +++ b/facetracknoir/facetracknoir.h @@ -25,13 +25,6 @@ #ifndef FaceTrackNoIR_H #define FaceTrackNoIR_H -#undef FTNOIR_PROTOCOL_BASE_LIB -#undef FTNOIR_TRACKER_BASE_LIB -#undef FTNOIR_FILTER_BASE_LIB -#define FTNOIR_PROTOCOL_BASE_EXPORT Q_DECL_IMPORT -#define FTNOIR_TRACKER_BASE_EXPORT Q_DECL_IMPORT -#define FTNOIR_FILTER_BASE_EXPORT Q_DECL_IMPORT - #include #include #include @@ -55,15 +48,14 @@ #include "ui_facetracknoir.h" -#include "ftnoir_protocol_base/ftnoir_protocol_base.h" -#include "ftnoir_tracker_base/ftnoir_tracker_base.h" -#include "ftnoir_filter_base/ftnoir_filter_base.h" - #include "global-settings.h" #include "tracker.h" -#include "facetracknoir/curve-config.h" #include "facetracknoir/shortcuts.h" +#include "ftnoir_protocol_base/ftnoir_protocol_base.h" +#include "ftnoir_tracker_base/ftnoir_tracker_base.h" +#include "ftnoir_filter_base/ftnoir_filter_base.h" + class Tracker; // pre-define class to avoid circular includes class FaceTrackNoIR; @@ -105,7 +97,7 @@ public: QxtGlobalShortcut* keyCenter; #endif public slots: - void shortcutRecentered(); + void shortcutRecentered(); private: HeadPoseData pose; @@ -133,50 +125,50 @@ private: QList dlopen_protocols; bool looping; - + private slots: - //file menu - void open(); - void save(); - void saveAs(); - void exit(); -// void setIcon(int index); - void profileSelected(int index); - - void showVideoWidget(); - void showHeadPoseWidget(); - void showTrackerSettings(); - void showSecondTrackerSettings(); - - void showServerControls(); - void showFilterControls(); - void showKeyboardShortcuts(); - void showCurveConfiguration(); - - void setInvertAxis( Axis axis, int invert ); - void setInvertYaw(int invert) { - setInvertAxis(Yaw, invert); - } - void setInvertPitch(int invert) { - setInvertAxis(Pitch, invert); - } - void setInvertRoll(int invert) { - setInvertAxis(Roll, invert); - } - void setInvertX(int invert) { - setInvertAxis(TX, invert); - } - void setInvertY(int invert) { - setInvertAxis(TY, invert); - } - void setInvertZ(int invert) { - setInvertAxis(TZ, invert); - } - void showHeadPose(); - - void startTracker(); - void stopTracker(); - + //file menu + void open(); + void save(); + void saveAs(); + void exit(); + // void setIcon(int index); + void profileSelected(int index); + + void showVideoWidget(); + void showHeadPoseWidget(); + void showTrackerSettings(); + void showSecondTrackerSettings(); + + void showServerControls(); + void showFilterControls(); + void showKeyboardShortcuts(); + void showCurveConfiguration(); + + void setInvertAxis( Axis axis, int invert ); + void setInvertYaw(int invert) { + setInvertAxis(Yaw, invert); + } + void setInvertPitch(int invert) { + setInvertAxis(Pitch, invert); + } + void setInvertRoll(int invert) { + setInvertAxis(Roll, invert); + } + void setInvertX(int invert) { + setInvertAxis(TX, invert); + } + void setInvertY(int invert) { + setInvertAxis(TY, invert); + } + void setInvertZ(int invert) { + setInvertAxis(TZ, invert); + } + void showHeadPose(); + + void startTracker(); + void stopTracker(); + }; #endif // FaceTrackNoIR_H diff --git a/facetracknoir/tracker.h b/facetracknoir/tracker.h index 0476eec4..31489d87 100644 --- a/facetracknoir/tracker.h +++ b/facetracknoir/tracker.h @@ -35,22 +35,7 @@ #include "global-settings.h" #include -//#define DIRECTINPUT_VERSION 0x0800 -//#include -#undef FTNOIR_PROTOCOL_BASE_LIB -#undef FTNOIR_TRACKER_BASE_LIB -#undef FTNOIR_FILTER_BASE_LIB -#undef FTNOIR_PROTOCOL_BASE_EXPORT -#undef FTNOIR_TRACKER_BASE_EXPORT -#undef FTNOIR_FILTER_BASE_EXPORT -#define FTNOIR_PROTOCOL_BASE_EXPORT Q_DECL_IMPORT -#define FTNOIR_TRACKER_BASE_EXPORT Q_DECL_IMPORT -#define FTNOIR_FILTER_BASE_EXPORT Q_DECL_IMPORT - #include -#include "ftnoir_tracker_base/ftnoir_tracker_base.h" -#include "ftnoir_protocol_base/ftnoir_protocol_base.h" -#include "ftnoir_filter_base/ftnoir_filter_base.h" #include "tracker_types.h" class FaceTrackNoIR; // pre-define parent-class to avoid circular includes diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.h b/ftnoir_filter_accela/ftnoir_filter_accela.h index 82766293..effb06c2 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.h +++ b/ftnoir_filter_accela/ftnoir_filter_accela.h @@ -26,9 +26,6 @@ #ifndef INCLUDED_FTN_FILTER_H #define INCLUDED_FTN_FILTER_H -#undef FTNOIR_TRACKER_BASE_LIB -#define FTNOIR_TRACKER_BASE_EXPORT Q_DECL_IMPORT - #include "ftnoir_filter_base/ftnoir_filter_base.h" #include "ui_ftnoir_accela_filtercontrols.h" #include "facetracknoir/global-settings.h" @@ -36,7 +33,7 @@ #define ACCELA_SMOOTHING_ROTATION 60.0 #define ACCELA_SMOOTHING_TRANSLATION 40.0 -#define ACCELA_ZOOM_SLOWNESS 35 +#define ACCELA_ZOOM_SLOWNESS 35 //******************************************************************************************************* // FaceTrackNoIR Filter class. diff --git a/ftnoir_filter_base/ftnoir_filter_base_global.h b/ftnoir_filter_base/ftnoir_filter_base_global.h index 02733ace..ce112411 100644 --- a/ftnoir_filter_base/ftnoir_filter_base_global.h +++ b/ftnoir_filter_base/ftnoir_filter_base_global.h @@ -3,7 +3,7 @@ #include -#ifdef FTNOIR_FILTER_BASE_LIB +#ifndef OPENTRACK_MAIN # define FTNOIR_FILTER_BASE_EXPORT Q_DECL_EXPORT #else # define FTNOIR_FILTER_BASE_EXPORT Q_DECL_IMPORT diff --git a/ftnoir_protocol_base/ftnoir_protocol_base_global.h b/ftnoir_protocol_base/ftnoir_protocol_base_global.h index 9f66d67a..bed874c4 100644 --- a/ftnoir_protocol_base/ftnoir_protocol_base_global.h +++ b/ftnoir_protocol_base/ftnoir_protocol_base_global.h @@ -3,7 +3,7 @@ #include -#ifdef FTNOIR_PROTOCOL_BASE_LIB +#ifndef OPENTRACK_MAIN # define FTNOIR_PROTOCOL_BASE_EXPORT Q_DECL_EXPORT #else # define FTNOIR_PROTOCOL_BASE_EXPORT Q_DECL_IMPORT diff --git a/ftnoir_tracker_base/ftnoir_tracker_base.h b/ftnoir_tracker_base/ftnoir_tracker_base.h index 4d968e59..39db6bb6 100644 --- a/ftnoir_tracker_base/ftnoir_tracker_base.h +++ b/ftnoir_tracker_base/ftnoir_tracker_base.h @@ -22,12 +22,6 @@ * with this program; if not, see . * * This class implements a tracker-base * *********************************************************************************/ -/* - Modifications (last one on top): - 20122109 - C14: Replaced Release with virtual destructor - 20120009 - WVR: Removed AutoClosePtr (seemed like it didn't work OK) - 20110415 - WVR: Added overloaded operator - and -= -*/ #ifndef FTNOIR_TRACKER_BASE_H #define FTNOIR_TRACKER_BASE_H diff --git a/ftnoir_tracker_base/ftnoir_tracker_base_global.h b/ftnoir_tracker_base/ftnoir_tracker_base_global.h index af9899c5..30fb95e9 100644 --- a/ftnoir_tracker_base/ftnoir_tracker_base_global.h +++ b/ftnoir_tracker_base/ftnoir_tracker_base_global.h @@ -3,7 +3,7 @@ #include -#ifdef FTNOIR_TRACKER_BASE_LIB +#ifndef OPENTRACK_MAIN # define FTNOIR_TRACKER_BASE_EXPORT Q_DECL_EXPORT #else # define FTNOIR_TRACKER_BASE_EXPORT Q_DECL_IMPORT diff --git a/ftnoir_tracker_base/ftnoir_tracker_types.h b/ftnoir_tracker_base/ftnoir_tracker_types.h index 591728a6..74612371 100644 --- a/ftnoir_tracker_base/ftnoir_tracker_types.h +++ b/ftnoir_tracker_base/ftnoir_tracker_types.h @@ -22,11 +22,6 @@ * with this program; if not, see . * * This class implements a tracker-base * *********************************************************************************/ -/* - Modifications (last one on top): - 20120924 - C14: Moved T6DOF to separate file (not pulic interface) - 20110415 - WVR: Added overloaded operator - and -= -*/ #ifndef FTNOIR_TRACKER_TYPES_H #define FTNOIR_TRACKER_TYPES_H diff --git a/qfunctionconfigurator/functionconfig.cpp b/qfunctionconfigurator/functionconfig.cpp index af350143..5dab2b52 100644 --- a/qfunctionconfigurator/functionconfig.cpp +++ b/qfunctionconfigurator/functionconfig.cpp @@ -39,6 +39,11 @@ FunctionConfig::FunctionConfig(QString title, int intMaxInput, int intMaxOutput) reload(); } +void FunctionConfig::setTrackingActive(bool blnActive) +{ + _tracking_active = blnActive; +} + FunctionConfig::FunctionConfig() : _tracking_active(false), _max_Input(0), diff --git a/qfunctionconfigurator/functionconfig.h b/qfunctionconfigurator/functionconfig.h index 21e9e43e..f1310a8c 100644 --- a/qfunctionconfigurator/functionconfig.h +++ b/qfunctionconfigurator/functionconfig.h @@ -6,6 +6,8 @@ * notice appear in all copies. */ +#pragma once + #include #include #include @@ -13,9 +15,6 @@ #include #include "ftnoir_tracker_base/ftnoir_tracker_base.h" -#ifndef FUNCTION_CONFIG_H -#define FUNCTION_CONFIG_H - #define MEMOIZE_PRECISION 500 class FTNOIR_TRACKER_BASE_EXPORT FunctionConfig { @@ -69,10 +68,6 @@ public: void saveSettings(QSettings& settings); void loadSettings(QSettings& settings); - void setTrackingActive(bool blnActive) { - _tracking_active = blnActive; - } + void setTrackingActive(bool blnActive); QString getTitle() { return _title; } }; - -#endif diff --git a/qfunctionconfigurator/qfunctionconfigurator.h b/qfunctionconfigurator/qfunctionconfigurator.h index 7260de1f..c9290722 100644 --- a/qfunctionconfigurator/qfunctionconfigurator.h +++ b/qfunctionconfigurator/qfunctionconfigurator.h @@ -50,9 +50,11 @@ // The Function is coded in a separate Class and can exists, without the Widget. When the widget is displayed (therefore 'created'), the Function can be attached to the // Widget and the Widget used to change the Function. // + class FTNOIR_TRACKER_BASE_EXPORT QFunctionConfigurator : public QWidget { Q_OBJECT + Q_PROPERTY(int maxInputEGU READ maxInputEGU WRITE setmaxInputEGU) Q_PROPERTY(int maxOutputEGU READ maxOutputEGU WRITE setmaxOutputEGU) Q_PROPERTY(int pixPerEGU_Input READ pixPerEGU_Input WRITE setpixPerEGU_Input) -- cgit v1.2.3 From d15a1c158d8c1ae589f18a0443defc5726190a40 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 15 Sep 2013 04:05:18 +0200 Subject: Only use mm timers during tracking --- facetracknoir/main.cpp | 4 +--- facetracknoir/tracker.cpp | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 5 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/main.cpp b/facetracknoir/main.cpp index d487de57..fbf28678 100644 --- a/facetracknoir/main.cpp +++ b/facetracknoir/main.cpp @@ -37,9 +37,7 @@ #endif int main(int argc, char** argv) { -#if defined(_WIN32) - (void) timeBeginPeriod(1); -#elif defined(Q_WS_X11) +#if defined(Q_WS_X11) XInitThreads(); #endif QApplication app(argc, argv); diff --git a/facetracknoir/tracker.cpp b/facetracknoir/tracker.cpp index 981be4b7..cff2e765 100644 --- a/facetracknoir/tracker.cpp +++ b/facetracknoir/tracker.cpp @@ -24,6 +24,10 @@ #include "tracker.h" #include "facetracknoir.h" +#if defined(_WIN32) +# include +#endif + /** constructor **/ Tracker::Tracker( FaceTrackNoIR *parent ) : should_quit(false), @@ -69,7 +73,11 @@ void Tracker::run() { double newpose[6]; double last_post_filter[6]; - forever +#if defined(_WIN32) + (void) timeBeginPeriod(1); +#endif + + for (;;) { if (should_quit) break; @@ -157,6 +165,9 @@ void Tracker::run() { //for lower cpu load msleep(8); } +#if defined(_WIN32) + (void) timeEndPeriod(1); +#endif for (int i = 0; i < 6; i++) { @@ -192,7 +203,7 @@ void Tracker::loadSettings() { qDebug() << "Tracker::loadSettings says: Starting "; QSettings settings("opentrack"); // Registry settings (in HK_USER) - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); + QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) iniFile.beginGroup("Tracking"); -- cgit v1.2.3 From 7b0ce8034456271ab0ea15da9b60fe9b94d75dc0 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 15 Sep 2013 04:32:44 +0200 Subject: Don't use tracker.cpp indirection for updating zeroing --- facetracknoir/curve-config.cpp | 8 +++----- facetracknoir/facetracknoir.cpp | 9 --------- facetracknoir/facetracknoir.h | 2 -- facetracknoir/tracker.cpp | 30 ------------------------------ facetracknoir/tracker.h | 1 - 5 files changed, 3 insertions(+), 47 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/curve-config.cpp b/facetracknoir/curve-config.cpp index 5421c670..1bb40078 100644 --- a/facetracknoir/curve-config.cpp +++ b/facetracknoir/curve-config.cpp @@ -230,14 +230,12 @@ void CurveConfigurationDialog::save() { }; for (int i = 0; i < 6; i++) + { iniFile.setValue(names2[i], widgets2[i]->value()); + mainApp->axis(i).zero = widgets2[i]->value(); + } iniFile.endGroup(); settingsDirty = false; - - // - // Send a message to the main program, to update the Settings (for the tracker) - // - mainApp->update_tracker_settings(); } diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index 17dded92..d9569ccc 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -189,15 +189,6 @@ FaceTrackNoIR::~FaceTrackNoIR() { save(); } -// -// Update the Settings, after a value has changed. This way, the Tracker does not have to re-start. -// -void FaceTrackNoIR::update_tracker_settings() { - if ( tracker != NULL ) { - tracker->loadSettings(); - } -} - // // Get a pointer to the video-widget, to use in the DLL // diff --git a/facetracknoir/facetracknoir.h b/facetracknoir/facetracknoir.h index 2aa6614f..16f42727 100644 --- a/facetracknoir/facetracknoir.h +++ b/facetracknoir/facetracknoir.h @@ -69,8 +69,6 @@ public: FaceTrackNoIR(QWidget *parent = 0, Qt::WFlags flags = 0); ~FaceTrackNoIR(); - void update_tracker_settings(); // Update the settings (let Tracker read INI-file). - QFrame *get_video_widget(); // Get a pointer to the video-widget, to use in the DLL Tracker *tracker; void bindKeyboardShortcuts(); diff --git a/facetracknoir/tracker.cpp b/facetracknoir/tracker.cpp index cff2e765..4304d939 100644 --- a/facetracknoir/tracker.cpp +++ b/facetracknoir/tracker.cpp @@ -36,7 +36,6 @@ Tracker::Tracker( FaceTrackNoIR *parent ) : // Retieve the pointer to the parent mainApp = parent; // Load the settings from the INI-file - loadSettings(); } Tracker::~Tracker() @@ -196,33 +195,4 @@ void Tracker::getOutputHeadPose( double *data ) { data[i] = output_camera.axes[i]; } -// -// Load the current Settings from the currently 'active' INI-file. -// -void Tracker::loadSettings() { - qDebug() << "Tracker::loadSettings says: Starting "; - QSettings settings("opentrack"); // 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) - - iniFile.beginGroup("Tracking"); - - qDebug() << "loadSettings says: iniFile = " << currentFile; - - const char* names2[] = { - "zero_tx", - "zero_ty", - "zero_tz", - "zero_rx", - "zero_ry", - "zero_rz" - }; - - for (int i = 0; i < 6; i++) - mainApp->axis(i).zero = iniFile.value(names2[i], 0).toDouble(); - - iniFile.endGroup(); -} - void Tracker::setInvertAxis(Axis axis, bool invert) { mainApp->axis(axis).invert = invert?-1.0f:1.0f; } diff --git a/facetracknoir/tracker.h b/facetracknoir/tracker.h index 31489d87..c831df61 100644 --- a/facetracknoir/tracker.h +++ b/facetracknoir/tracker.h @@ -99,7 +99,6 @@ protected: public: Tracker( FaceTrackNoIR *parent ); ~Tracker(); - void loadSettings(); // Load settings from the INI-file void setInvertAxis(Axis axis, bool invert); -- cgit v1.2.3 From 0efacbc3d776079b48ea09c010798e71de155cb5 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 15 Sep 2013 05:02:09 +0200 Subject: Bump version --- facetracknoir/facetracknoir.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index d9569ccc..394ad8a6 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -401,7 +401,7 @@ void FaceTrackNoIR::loadSettings() { // Put the filename in the window-title. // QFileInfo pathInfo ( currentFile ); - setWindowTitle ( "opentrack (1.8 alpha) - " + pathInfo.fileName() ); + setWindowTitle ( "opentrack 2.0a1 - " + pathInfo.fileName() ); // // Get a List of all the INI-files in the (currently active) Settings-folder. -- cgit v1.2.3 From 490f3ddb79018d13182fc17bb92943bbe427643d Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 15 Sep 2013 15:00:56 +0200 Subject: New PT from Patrick Ruoff adapted to Linux --- CMakeLists.txt | 2 + FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui | 4 +- FTNoIR_Tracker_PT/boost-compat.h | 6 ++ FTNoIR_Tracker_PT/camera.cpp | 135 ++++++++++++++++++++----- FTNoIR_Tracker_PT/camera.h | 96 +++++++++--------- FTNoIR_Tracker_PT/frame_observer.cpp | 4 +- FTNoIR_Tracker_PT/frame_observer.h | 8 +- FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp | 56 ++++++++-- FTNoIR_Tracker_PT/ftnoir_tracker_pt.h | 33 +++++- FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.cpp | 15 ++- FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.h | 6 +- FTNoIR_Tracker_PT/ftnoir_tracker_pt_dll.cpp | 10 +- FTNoIR_Tracker_PT/ftnoir_tracker_pt_dll.h | 18 +++- FTNoIR_Tracker_PT/point_extractor.cpp | 2 +- FTNoIR_Tracker_PT/point_extractor.h | 1 + FTNoIR_Tracker_PT/point_tracker.cpp | 31 +++++- FTNoIR_Tracker_PT/point_tracker.h | 6 +- FTNoIR_Tracker_PT/timer.cpp | 4 +- FTNoIR_Tracker_PT/video_widget.cpp | 58 ++++++++--- FTNoIR_Tracker_PT/video_widget.h | 47 ++++++++- facetracknoir/rotation.h | 18 ++-- facetracknoir/tracker_types.cpp | 12 +-- 22 files changed, 422 insertions(+), 150 deletions(-) create mode 100644 FTNoIR_Tracker_PT/boost-compat.h (limited to 'facetracknoir') diff --git a/CMakeLists.txt b/CMakeLists.txt index 0669fb74..6c5bed0f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,6 +7,8 @@ SET(CMAKE_SKIP_INSTALL_RPATH FALSE) SET(CMAKE_SKIP_RPATH FALSE) SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}") +add_definitions(-DOPENTRACK_API) + if(WIN32) SET(SDK_FACEAPI_ONLY FALSE CACHE BOOL "FaceAPI only (MSVC 2005)") endif() diff --git a/FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui b/FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui index 7bb7eb50..1495249a 100644 --- a/FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui +++ b/FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui @@ -9,8 +9,8 @@ 0 0 - 395 - 552 + 458 + 590 diff --git a/FTNoIR_Tracker_PT/boost-compat.h b/FTNoIR_Tracker_PT/boost-compat.h new file mode 100644 index 00000000..aea5e1a2 --- /dev/null +++ b/FTNoIR_Tracker_PT/boost-compat.h @@ -0,0 +1,6 @@ +#pragma once +#include +#define shared_ptr auto_ptr +namespace boost { + using std::auto_ptr; +}; diff --git a/FTNoIR_Tracker_PT/camera.cpp b/FTNoIR_Tracker_PT/camera.cpp index 21a910c1..a372373d 100644 --- a/FTNoIR_Tracker_PT/camera.cpp +++ b/FTNoIR_Tracker_PT/camera.cpp @@ -10,6 +10,69 @@ using namespace cv; +#if defined(OPENTRACK_API) && (defined(__unix) || defined(__linux)) +#include +#endif + +#ifdef OPENTRACK_API +void get_camera_device_names(std::vector& device_names) { +# if defined(_WIN32) + // Create the System Device Enumerator. + HRESULT hr; + ICreateDevEnum *pSysDevEnum = NULL; + hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER, IID_ICreateDevEnum, (void **)&pSysDevEnum); + if (FAILED(hr)) + { + return ret; + } + // Obtain a class enumerator for the video compressor category. + IEnumMoniker *pEnumCat = NULL; + hr = pSysDevEnum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory, &pEnumCat, 0); + + if (hr == S_OK) { + // Enumerate the monikers. + IMoniker *pMoniker = NULL; + ULONG cFetched; + while (pEnumCat->Next(1, &pMoniker, &cFetched) == S_OK) { + IPropertyBag *pPropBag; + hr = pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void **)&pPropBag); + if (SUCCEEDED(hr)) { + // To retrieve the filter's friendly name, do the following: + VARIANT varName; + VariantInit(&varName); + hr = pPropBag->Read(L"FriendlyName", &varName, 0); + if (SUCCEEDED(hr)) + { + device_names.push_back(std::string(reinterpret_cast(varName.bstrVal))); + } + VariantClear(&varName); + + ////// To create an instance of the filter, do the following: + ////IBaseFilter *pFilter; + ////hr = pMoniker->BindToObject(NULL, NULL, IID_IBaseFilter, + //// (void**)&pFilter); + // Now add the filter to the graph. + //Remember to release pFilter later. + pPropBag->Release(); + } + pMoniker->Release(); + } + pEnumCat->Release(); + } + pSysDevEnum->Release(); +# else + for (int i = 0; i < 16; i++) { + char buf[128]; + sprintf(buf, "/dev/video%d", i); + if (access(buf, R_OK | W_OK) == 0) { + device_names.push_back(std::string(buf)); + } else { + continue; + } + } +# endif +} +#else // ---------------------------------------------------------------------------- void get_camera_device_names(std::vector& device_names) { @@ -22,6 +85,7 @@ void get_camera_device_names(std::vector& device_names) device_names.push_back(device_name); } } +#endif // ---------------------------------------------------------------------------- void Camera::set_device_index(int index) @@ -81,43 +145,49 @@ bool Camera::get_frame(float dt, cv::Mat* frame) } // ---------------------------------------------------------------------------- -/* +#ifdef OPENTRACK_API void CVCamera::start() { - cap = cvCreateCameraCapture(desired_index); + cap = new VideoCapture(desired_index); // extract camera info - if (cap) + if (cap->isOpened()) { active = true; active_index = desired_index; - cam_info.res_x = cvGetCaptureProperty(cap, CV_CAP_PROP_FRAME_WIDTH); - cam_info.res_y = cvGetCaptureProperty(cap, CV_CAP_PROP_FRAME_HEIGHT); + cam_info.res_x = cap->get(CV_CAP_PROP_FRAME_WIDTH); + cam_info.res_y = cap->get(CV_CAP_PROP_FRAME_HEIGHT); } + else { + delete cap; + cap = NULL; + } } void CVCamera::stop() { - if (cap) cvReleaseCapture(&cap); + if (cap) + { + cap->release(); + delete cap; + } active = false; } bool CVCamera::_get_frame(Mat* frame) { - if (cap && cvGrabFrame(cap) != 0) + if (cap) { - // retrieve frame - IplImage* _img = cvRetrieveFrame(cap, 0); - if(_img) - { - if(_img->origin == IPL_ORIGIN_TL) - *frame = Mat(_img); - else - { - Mat temp(_img); - flip(temp, *frame, 0); - } - return true; - } + Mat img; + /* + * XXX some Windows webcams fail to decode first + * frames and then some every once in a while + * -sh + */ + while (!cap->read(img))\ + ;; + + *frame = img; + return true; } return false; } @@ -134,21 +204,30 @@ void CVCamera::_set_f() void CVCamera::_set_fps() { - if (cap) cvSetCaptureProperty(cap, CV_CAP_PROP_FPS, cam_desired.fps); + if (cap) cap->set(CV_CAP_PROP_FPS, cam_desired.fps); } void CVCamera::_set_res() { if (cap) { - cvSetCaptureProperty(cap, CV_CAP_PROP_FRAME_WIDTH, cam_desired.res_x); - cvSetCaptureProperty(cap, CV_CAP_PROP_FRAME_HEIGHT, cam_desired.res_y); - cam_info.res_x = cvGetCaptureProperty(cap, CV_CAP_PROP_FRAME_WIDTH); - cam_info.res_y = cvGetCaptureProperty(cap, CV_CAP_PROP_FRAME_HEIGHT); + cap->set(CV_CAP_PROP_FRAME_WIDTH, cam_desired.res_x); + cap->set(CV_CAP_PROP_FRAME_HEIGHT, cam_desired.res_y); + cam_info.res_x = cap->get(CV_CAP_PROP_FRAME_WIDTH); + cam_info.res_y = cap->get(CV_CAP_PROP_FRAME_HEIGHT); } } -*/ +void CVCamera::_set_device_index() +{ + if (cap) + { + cap->release(); + delete cap; + } + cap = new VideoCapture(desired_index); +} +#else // ---------------------------------------------------------------------------- VICamera::VICamera() : frame_buffer(NULL) { @@ -234,7 +313,7 @@ void VICamera::_set_res() { if (active) restart(); } - +#endif // ---------------------------------------------------------------------------- Mat FrameRotation::rotate_frame(Mat frame) @@ -260,4 +339,4 @@ Mat FrameRotation::rotate_frame(Mat frame) default: return frame; } -} \ No newline at end of file +} diff --git a/FTNoIR_Tracker_PT/camera.h b/FTNoIR_Tracker_PT/camera.h index c0876d0a..d1a8104c 100644 --- a/FTNoIR_Tracker_PT/camera.h +++ b/FTNoIR_Tracker_PT/camera.h @@ -9,8 +9,13 @@ #define CAMERA_H #include -#include "videoInput/videoInput.h" -#include +#ifndef OPENTRACK_API +# include +#else +# include "FTNoIR_Tracker_PT/boost-compat.h" +# include +# include +#endif #include // ---------------------------------------------------------------------------- @@ -33,50 +38,50 @@ struct CamInfo class Camera { public: - Camera() : dt_valid(0), dt_mean(0), desired_index(0), active_index(-1), active(false) {} - virtual ~Camera() {} + Camera() : dt_valid(0), dt_mean(0), desired_index(0), active_index(-1), active(false) {} + virtual ~Camera() {} - // start/stop capturing - virtual void start() = 0; - virtual void stop() = 0; - void restart() { stop(); start(); } + // start/stop capturing + virtual void start() = 0; + virtual void stop() = 0; + void restart() { stop(); start(); } - // calls corresponding template methods and reinitializes frame rate calculation - void set_device_index(int index); - void set_f(float f); - void set_fps(int fps); - void set_res(int x_res, int y_res); + // calls corresponding template methods and reinitializes frame rate calculation + void set_device_index(int index); + void set_f(float f); + void set_fps(int fps); + void set_res(int x_res, int y_res); - // gets a frame from the camera, dt: time since last call in seconds - bool get_frame(float dt, cv::Mat* frame); + // gets a frame from the camera, dt: time since last call in seconds + bool get_frame(float dt, cv::Mat* frame); - // WARNING: returned references are valid as long as object - const CamInfo& get_info() const { return cam_info; } - const CamInfo& get_desired() const { return cam_desired; } + // WARNING: returned references are valid as long as object + const CamInfo& get_info() const { return cam_info; } + const CamInfo& get_desired() const { return cam_desired; } protected: - // get a frame from the camera - virtual bool _get_frame(cv::Mat* frame) = 0; - - // update the camera using cam_desired, write res and f to cam_info if successful - virtual void _set_device_index() = 0; - virtual void _set_f() = 0; - virtual void _set_fps() = 0; - virtual void _set_res() = 0; - - bool active; - int desired_index; - int active_index; - CamInfo cam_info; - CamInfo cam_desired; - float dt_valid; - float dt_mean; + // get a frame from the camera + virtual bool _get_frame(cv::Mat* frame) = 0; + + // update the camera using cam_desired, write res and f to cam_info if successful + virtual void _set_device_index() = 0; + virtual void _set_f() = 0; + virtual void _set_fps() = 0; + virtual void _set_res() = 0; + + bool active; + int desired_index; + int active_index; + CamInfo cam_info; + CamInfo cam_desired; + float dt_valid; + float dt_mean; }; // ---------------------------------------------------------------------------- // camera based on OpenCV's videoCapture -/* +#ifdef OPENTRACK_API class CVCamera : public Camera { public: @@ -92,11 +97,11 @@ protected: virtual void _set_f(); virtual void _set_fps(); virtual void _set_res(); + virtual void _set_device_index(); - CvCapture* cap; + cv::VideoCapture* cap; }; -*/ - +#else // ---------------------------------------------------------------------------- // Camera based on the videoInput library class VICamera : public Camera @@ -119,19 +124,20 @@ protected: cv::Mat new_frame; unsigned char* frame_buffer; }; +#endif +enum RotationType +{ + CLOCKWISE = -1, + ZERO = 0, + COUNTER_CLOCKWISE = 1 +}; // ---------------------------------------------------------------------------- class FrameRotation { public: - typedef enum Rotation - { - CLOCKWISE = -1, - ZERO = 0, - COUNTER_CLOCKWISE = 1 - }; - Rotation rotation; + RotationType rotation; cv::Mat rotate_frame(cv::Mat frame); }; diff --git a/FTNoIR_Tracker_PT/frame_observer.cpp b/FTNoIR_Tracker_PT/frame_observer.cpp index 7e4bb3e3..281f3d57 100644 --- a/FTNoIR_Tracker_PT/frame_observer.cpp +++ b/FTNoIR_Tracker_PT/frame_observer.cpp @@ -11,8 +11,8 @@ FrameProvider::~FrameProvider() { QMutexLocker lock(&observer_mutex); - for (auto iter=frame_observers.begin(); iter!=frame_observers.end(); ++iter) + for (std::set::iterator iter=frame_observers.begin(); iter!=frame_observers.end(); ++iter) { (*iter)->on_frame_provider_destroy(); } -} \ No newline at end of file +} diff --git a/FTNoIR_Tracker_PT/frame_observer.h b/FTNoIR_Tracker_PT/frame_observer.h index 4afbd72c..585a6ee7 100644 --- a/FTNoIR_Tracker_PT/frame_observer.h +++ b/FTNoIR_Tracker_PT/frame_observer.h @@ -10,7 +10,11 @@ #include #include -#include +#ifndef OPENTRACK_API +# include +#else +# include "FTNoIR_Tracker_PT/boost-compat.h" +#endif #include //----------------------------------------------------------------------------- @@ -69,4 +73,4 @@ private: FrameObserver(const FrameObserver&); }; -#endif //FRAME_OBSERVER_H \ No newline at end of file +#endif //FRAME_OBSERVER_H diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp index 88a3fc8d..d4741101 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp @@ -12,6 +12,10 @@ #include #include +#ifdef OPENTRACK_API +# define VideoWidget VideoWidget2 +#endif + using namespace std; using namespace cv; using namespace boost; @@ -92,6 +96,9 @@ void Tracker::run() const std::vector& points = point_extractor.extract_points(frame, dt, has_observers()); tracking_valid = point_tracker.track(points, camera.get_info().f, dt); frame_count++; +#ifdef OPENTRACK_API + video_widget->update_image(frame); +#endif } #ifdef PT_PERF_LOG log_stream<<"dt: "<(settings.cam_roll); + frame_rotation.rotation = static_cast(settings.cam_roll); point_extractor.threshold_val = settings.threshold; point_extractor.min_size = settings.min_point_size; - point_extractor.max_size = settings.max_point_size; - point_tracker.point_model = boost::shared_ptr(new PointModel(settings.M01, settings.M02)); - point_tracker.dynamic_pose_resolution = settings.dyn_pose_res; + point_extractor.max_size = settings.max_point_size; +#ifdef OPENTRACK_API + point_tracker.point_model.reset(new PointModel(settings.M01, settings.M02)); +#else + point_tracker.point_model = boost::shared_ptr(new PointModel(settings.M01, settings.M02)); +#endif + point_tracker.dynamic_pose_resolution = settings.dyn_pose_res; sleep_time = settings.sleep_time; point_tracker.dt_reset = settings.reset_time / 1000.0; show_video_widget = settings.video_widget; @@ -181,7 +192,6 @@ void Tracker::update_show_video_widget() { const int VIDEO_FRAME_WIDTH = 252; const int VIDEO_FRAME_HEIGHT = 189; - video_widget = new VideoWidget(video_frame, this); QHBoxLayout* video_layout = new QHBoxLayout(); video_layout->setContentsMargins(0, 0, 0, 0); @@ -208,15 +218,28 @@ void Tracker::refreshVideo() if (video_widget) video_widget->update_frame_and_points(); } +#ifdef OPENTRACK_API +void Tracker::StartTracker(QFrame *parent_window) +#else void Tracker::StartTracker(HWND parent_window) +#endif { +#ifdef OPENTRACK_API + Initialize(parent_window); +#endif reset_command(PAUSE); } +#ifndef OPENTRACK_API void Tracker::StopTracker(bool exit) { set_command(PAUSE); } +#endif + +#ifdef OPENTRACK_API +#define THeadPoseData double +#endif bool Tracker::GiveHeadPoseData(THeadPoseData *data) { @@ -228,14 +251,20 @@ bool Tracker::GiveHeadPoseData(THeadPoseData *data) FrameTrafo X_CM = point_tracker.get_pose(); FrameTrafo X_MH(Matx33f::eye(), t_MH); FrameTrafo X_GH = R_GC * X_CM * X_MH; - Matx33f R = X_GH.R * X_GH_0.R.t(); + Matx33f R = X_GH.R * X_GH_0.R.t(); Vec3f t = X_GH.t - X_GH_0.t; +#ifndef OPENTRACK_API // get translation(s) if (bEnableX) data->x = t[0] / 10.0; // convert to cm if (bEnableY) data->y = t[1] / 10.0; if (bEnableZ) data->z = t[2] / 10.0; - +#else + // get translation(s) + if (bEnableX) data[TX] = t[0] / 10.0; // convert to cm + if (bEnableY) data[TY] = t[1] / 10.0; + if (bEnableZ) data[TZ] = t[2] / 10.0; +#endif // translate rotation matrix from opengl (G) to roll-pitch-yaw (E) frame // -z -> x, y -> z, x -> -y Matx33f R_EG( 0, 0,-1, @@ -249,17 +278,26 @@ bool Tracker::GiveHeadPoseData(THeadPoseData *data) alpha = atan2( R(1,0), R(0,0)); gamma = atan2( R(2,1), R(2,2)); +#ifndef OPENTRACK_API if (bEnableYaw) data->yaw = rad2deg * alpha; if (bEnablePitch) data->pitch = - rad2deg * beta; // FTNoIR expects a minus here if (bEnableRoll) data->roll = rad2deg * gamma; +#else + if (bEnableYaw) data[Yaw] = rad2deg * alpha; + if (bEnablePitch) data[Pitch] = - rad2deg * beta; // FTNoIR expects a minus here + if (bEnableRoll) data[Roll] = rad2deg * gamma; +#endif } return true; } //----------------------------------------------------------------------------- +#ifdef OPENTRACK_API +extern "C" FTNOIR_TRACKER_BASE_EXPORT ITracker* CALLING_CONVENTION GetConstructor() +#else #pragma comment(linker, "/export:GetTracker=_GetTracker@0") - FTNOIR_TRACKER_BASE_EXPORT ITrackerPtr __stdcall GetTracker() +#endif { return new Tracker; -} \ No newline at end of file +} diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h index 6eef945a..867378d1 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h @@ -8,7 +8,12 @@ #ifndef FTNOIR_TRACKER_PT_H #define FTNOIR_TRACKER_PT_H -#include "..\ftnoir_tracker_base\ftnoir_tracker_base.h" +#ifdef OPENTRACK_API +# include "ftnoir_tracker_base/ftnoir_tracker_base.h" +# include "facetracknoir/global-settings.h" +#else +# include "..\ftnoir_tracker_base\ftnoir_tracker_base.h" +#endif #include "ftnoir_tracker_pt_settings.h" #include "frame_observer.h" #include "camera.h" @@ -19,9 +24,14 @@ #include #include +#include #include #include -#include +#ifndef OPENTRACK_API +# include +#else +# include "FTNoIR_Tracker_PT/boost-compat.h" +#endif #include //----------------------------------------------------------------------------- @@ -34,10 +44,16 @@ public: // --- ITracker interface --- virtual void Initialize(QFrame *videoframe); +#ifdef OPENTRACK_API + virtual void StartTracker(QFrame* parent_window); + virtual void WaitForExit() {} + virtual bool GiveHeadPoseData(double* data); +#else virtual void StartTracker(HWND parent_window); - virtual void StopTracker(bool exit); - virtual bool GiveHeadPoseData(THeadPoseData *data); - virtual void refreshVideo(); + virtual void StopTracker(bool exit); + virtual bool GiveHeadPoseData(THeadPoseData *data); +#endif + virtual void refreshVideo(); void apply(const TrackerSettings& settings); void center(); @@ -66,7 +82,12 @@ protected: int sleep_time; // --- tracking chain --- +#ifdef OPENTRACK_API +#define VideoWidget VideoWidget2 + CVCamera camera; +#else VICamera camera; +#endif FrameRotation frame_rotation; PointExtractor point_extractor; PointTracker point_tracker; @@ -96,4 +117,6 @@ protected: Timer time; }; +#undef VideoWidget + #endif // FTNOIR_TRACKER_PT_H diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.cpp b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.cpp index c99f4d67..fe995163 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.cpp +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.cpp @@ -10,7 +10,11 @@ #include #include #include -#include +#ifndef OPENTRACK_API +# include +#else +# include "FTNoIR_Tracker_PT/boost-compat.h" +#endif #include using namespace std; @@ -39,7 +43,7 @@ TrackerDialog::TrackerDialog() vector device_names; get_camera_device_names(device_names); - for (auto iter = device_names.begin(); iter != device_names.end(); ++iter) + for (vector::iterator iter = device_names.begin(); iter != device_names.end(); ++iter) { ui.camdevice_combo->addItem(iter->c_str()); } @@ -398,9 +402,12 @@ void TrackerDialog::unRegisterTracker() } //----------------------------------------------------------------------------- +#ifdef OPENTRACK_API +extern "C" FTNOIR_TRACKER_BASE_EXPORT ITrackerDialog* CALLING_CONVENTION GetDialog( ) +#else #pragma comment(linker, "/export:GetTrackerDialog=_GetTrackerDialog@0") - FTNOIR_TRACKER_BASE_EXPORT ITrackerDialogPtr __stdcall GetTrackerDialog( ) +#endif { return new TrackerDialog; -} \ No newline at end of file +} diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.h b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.h index bf0a90f2..14df7ede 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.h +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.h @@ -8,7 +8,11 @@ #ifndef FTNOIR_TRACKER_PT_DIALOG_H #define FTNOIR_TRACKER_PT_DIALOG_H +#ifdef OPENTRACK_API +#include "ftnoir_tracker_base/ftnoir_tracker_base.h" +#else #include "..\ftnoir_tracker_base\ftnoir_tracker_base.h" +#endif #include "ftnoir_tracker_pt_settings.h" #include "ftnoir_tracker_pt.h" #include "trans_calib.h" @@ -113,4 +117,4 @@ protected: Ui::UICPTClientControls ui; }; -#endif //FTNOIR_TRACKER_PT_DIALOG_H \ No newline at end of file +#endif //FTNOIR_TRACKER_PT_DIALOG_H diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dll.cpp b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dll.cpp index 3a73f679..be1705c0 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dll.cpp +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dll.cpp @@ -6,7 +6,6 @@ */ #include "ftnoir_tracker_pt_dll.h" - #include //----------------------------------------------------------------------------- @@ -31,10 +30,13 @@ void TrackerDll::getIcon(QIcon *icon) } -//----------------------------------------------------------------------------- -#pragma comment(linker, "/export:GetTrackerDll=_GetTrackerDll@0") - +#ifdef OPENTRACK_API +# include "facetracknoir/global-settings.h" +extern "C" FTNOIR_TRACKER_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata() +#else +# pragma comment(linker, "/export:GetTrackerDll=_GetTrackerDll@0") FTNOIR_TRACKER_BASE_EXPORT ITrackerDllPtr __stdcall GetTrackerDll() +#endif { return new TrackerDll; } diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dll.h b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dll.h index 15ad63aa..18283837 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dll.h +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dll.h @@ -5,15 +5,27 @@ * copyright notice and this permission notice appear in all copies. */ -#include "..\ftnoir_tracker_base\ftnoir_tracker_base.h" +#if defined(OPENTRACK_API) +# include "ftnoir_tracker_base/ftnoir_tracker_base.h" +# include "facetracknoir/global-settings.h" +#else +# include "../ftnoir_tracker_base/ftnoir_tracker_base.h" +#endif //----------------------------------------------------------------------------- -class TrackerDll : public ITrackerDll +class TrackerDll : +#if defined(OPENTRACK_API) + public Metadata +#else + public ITrackerDll +#endif { // ITrackerDll interface +#ifndef OPENTRACK_API void Initialize() {} +#endif void getFullName(QString *strToBeFilled); void getShortName(QString *strToBeFilled); void getDescription(QString *strToBeFilled); void getIcon(QIcon *icon); -}; \ No newline at end of file +}; diff --git a/FTNoIR_Tracker_PT/point_extractor.cpp b/FTNoIR_Tracker_PT/point_extractor.cpp index 76a152a7..261de60f 100644 --- a/FTNoIR_Tracker_PT/point_extractor.cpp +++ b/FTNoIR_Tracker_PT/point_extractor.cpp @@ -22,7 +22,7 @@ const vector& PointExtractor::extract_points(Mat frame, float dt, bool dr // convert to grayscale Mat frame_gray; - cvtColor(frame, frame_gray, CV_RGB2GRAY); + cvtColor(frame, frame_gray, CV_RGB2GRAY); // convert to binary Mat frame_bin; diff --git a/FTNoIR_Tracker_PT/point_extractor.h b/FTNoIR_Tracker_PT/point_extractor.h index b142d2bb..c62d34f9 100644 --- a/FTNoIR_Tracker_PT/point_extractor.h +++ b/FTNoIR_Tracker_PT/point_extractor.h @@ -9,6 +9,7 @@ #define POINTEXTRACTOR_H #include +#include // ---------------------------------------------------------------------------- // Extracts points from an opencv image diff --git a/FTNoIR_Tracker_PT/point_tracker.cpp b/FTNoIR_Tracker_PT/point_tracker.cpp index acde9154..8b508897 100644 --- a/FTNoIR_Tracker_PT/point_tracker.cpp +++ b/FTNoIR_Tracker_PT/point_tracker.cpp @@ -69,6 +69,13 @@ PointModel::PointModel(Vec3f M01, Vec3f M02) get_d_order(points, d_order); } +#ifdef OPENTRACK_API +static bool d_vals_sort(const pair a, const pair b) +{ + return a.first < b.first; +} +#endif + void PointModel::get_d_order(const std::vector& points, int d_order[]) const { // get sort indices with respect to d scalar product @@ -77,10 +84,17 @@ void PointModel::get_d_order(const std::vector& points, int d_order[] d_vals.push_back(pair(d.dot(points[i]), i)); struct - { - bool operator()(const pair& a, const pair& b) { return a.first < b.first; } - } comp; - sort(d_vals.begin(), d_vals.end(), comp); + { + bool operator()(const pair& a, const pair& b) { return a.first < b.first; } + } comp; + std::sort(d_vals.begin(), + d_vals.end(), +#ifdef OPENTRACK_API + d_vals_sort +#else + comp +#endif + ); for (int i = 0; i& points, float f, float dt) reset(); } + bool no_model = +#ifdef OPENTRACK_API + point_model.get() == NULL; +#else + !point_model; +#endif + // if there is a pointtracking problem, reset the velocities - if (!point_model || points.size() != PointModel::N_POINTS) + if (no_model || points.size() != PointModel::N_POINTS) { //qDebug()<<"Wrong number of points!"; reset_velocities(); diff --git a/FTNoIR_Tracker_PT/point_tracker.h b/FTNoIR_Tracker_PT/point_tracker.h index f52e9dd7..11034100 100644 --- a/FTNoIR_Tracker_PT/point_tracker.h +++ b/FTNoIR_Tracker_PT/point_tracker.h @@ -9,7 +9,11 @@ #define POINTTRACKER_H #include -#include +#ifndef OPENTRACK_API +# include +#else +# include "FTNoIR_Tracker_PT/boost-compat.h" +#endif #include // ---------------------------------------------------------------------------- diff --git a/FTNoIR_Tracker_PT/timer.cpp b/FTNoIR_Tracker_PT/timer.cpp index 363b5b09..ed7606e5 100644 --- a/FTNoIR_Tracker_PT/timer.cpp +++ b/FTNoIR_Tracker_PT/timer.cpp @@ -55,7 +55,7 @@ double Timer::elapsed() startTime = startCount.QuadPart * (1e3 / frequency.QuadPart); endTime = endCount.QuadPart * (1e3 / frequency.QuadPart); #else - if(!stopped) + if(running) gettimeofday(&endCount, NULL); startTime = (startCount.tv_sec * 1e3) + startCount.tv_usec; @@ -63,4 +63,4 @@ double Timer::elapsed() #endif return endTime - startTime; -} \ No newline at end of file +} diff --git a/FTNoIR_Tracker_PT/video_widget.cpp b/FTNoIR_Tracker_PT/video_widget.cpp index 236faaf7..0d31620f 100644 --- a/FTNoIR_Tracker_PT/video_widget.cpp +++ b/FTNoIR_Tracker_PT/video_widget.cpp @@ -14,8 +14,10 @@ using namespace cv; using namespace std; +#ifndef OPENTRACK_API using namespace boost; - +#endif +#ifndef OPENTRACK_API // ---------------------------------------------------------------------------- void VideoWidget::initializeGL() { @@ -100,20 +102,44 @@ void VideoWidget::update_frame_and_points() updateGL(); } +#else +void VideoWidget2::update_image(const cv::Mat& frame) +{ + QMutexLocker foo(&mtx); + QImage qframe = QImage(frame.cols, frame.rows, QImage::Format_RGB888); + uchar* data = qframe.bits(); + const int pitch = qframe.bytesPerLine(); + for (int y = 0; y < frame.rows; y++) + for (int x = 0; x < frame.cols; x++) + { + const int pos = 3 * (y*frame.cols + x); + data[y * pitch + x * 3 + 0] = frame.data[pos + 2]; + data[y * pitch + x * 3 + 1] = frame.data[pos + 1]; + data[y * pitch + x * 3 + 2] = frame.data[pos + 0]; + } + qframe = qframe.scaled(size(), Qt::IgnoreAspectRatio, Qt::FastTransformation); + pixmap = QPixmap::fromImage(qframe); +} +#endif + // ---------------------------------------------------------------------------- -VideoWidgetDialog::VideoWidgetDialog(QWidget *parent, FrameProvider* provider) - : QDialog(parent), - video_widget(NULL) +VideoWidgetDialog::VideoWidgetDialog(QWidget *parent, FrameProvider* provider) + : QDialog(parent), + video_widget(NULL) { - const int VIDEO_FRAME_WIDTH = 640; - const int VIDEO_FRAME_HEIGHT = 480; - - video_widget = new VideoWidget(this, provider); - - QHBoxLayout* layout = new QHBoxLayout(); - layout->setContentsMargins(0, 0, 0, 0); - layout->addWidget(video_widget); - if (this->layout()) delete this->layout(); - setLayout(layout); - resize(VIDEO_FRAME_WIDTH, VIDEO_FRAME_HEIGHT); -} \ No newline at end of file + const int VIDEO_FRAME_WIDTH = 640; + const int VIDEO_FRAME_HEIGHT = 480; + +#ifdef OPENTRACK_API + video_widget = new VideoWidget2(this, provider); +#else + video_widget = new VideoWidget(this, provider); +#endif + + QHBoxLayout* layout = new QHBoxLayout(); + layout->setContentsMargins(0, 0, 0, 0); + layout->addWidget(video_widget); + if (this->layout()) delete this->layout(); + setLayout(layout); + resize(VIDEO_FRAME_WIDTH, VIDEO_FRAME_HEIGHT); +} diff --git a/FTNoIR_Tracker_PT/video_widget.h b/FTNoIR_Tracker_PT/video_widget.h index dd5fb642..3164dacc 100644 --- a/FTNoIR_Tracker_PT/video_widget.h +++ b/FTNoIR_Tracker_PT/video_widget.h @@ -10,12 +10,23 @@ #include "frame_observer.h" -#include #include #include #include -#include +#ifndef OPENTRACK_API +# include +# include +#else +# include "FTNoIR_Tracker_PT/boost-compat.h" +# if defined(_WIN32) +# include +# endif +#endif +#include +#include +#include +#ifndef OPENTRACK_API // ---------------------------------------------------------------------------- // OpenGL based widget to display an OpenCV image with some points on top class VideoWidget : public QGLWidget, public FrameObserver @@ -23,7 +34,7 @@ class VideoWidget : public QGLWidget, public FrameObserver Q_OBJECT public: - VideoWidget(QWidget *parent, FrameProvider* provider) : QGLWidget(parent), FrameObserver(provider) {} + VideoWidget(QWidget *parent, FrameProvider* provider) : QGLWidget(parent), FrameObserver(provider) {} virtual void initializeGL(); virtual void resizeGL(int w, int h); @@ -40,19 +51,45 @@ private: boost::shared_ptr< std::vector > points; }; +#else +/* Qt moc likes to skip over preprocessor directives -sh */ +class VideoWidget2 : public QWidget, public FrameObserver +{ + Q_OBJECT + +public: + VideoWidget2(QWidget *parent, FrameProvider* provider) : QWidget(parent), /* to avoid linker errors */ FrameObserver(provider) { + connect(&timer, SIGNAL(timeout()), this, SLOT(update())); + timer.start(45); + } + void update_image(const cv::Mat &frame); + void update_frame_and_points() {} +protected slots: + void paintEvent( QPaintEvent* e ) { + QMutexLocker foo(&mtx); + QPainter painter(this); + painter.drawPixmap(e->rect(), pixmap, e->rect()); + } +private: + QMutex mtx; + QPixmap pixmap; + QTimer timer; +}; +#endif // ---------------------------------------------------------------------------- // A VideoWidget embedded in a dialog frame class VideoWidgetDialog : public QDialog { + Q_OBJECT public: VideoWidgetDialog(QWidget *parent, FrameProvider* provider); virtual ~VideoWidgetDialog() {} - VideoWidget* get_video_widget() { return video_widget; } + VideoWidget2* get_video_widget() { return video_widget; } private: - VideoWidget* video_widget; + VideoWidget2* video_widget; }; #endif // VIDEOWIDGET_H diff --git a/facetracknoir/rotation.h b/facetracknoir/rotation.h index e97ec0f0..747a23f9 100644 --- a/facetracknoir/rotation.h +++ b/facetracknoir/rotation.h @@ -9,15 +9,15 @@ #define ROTATION_H #include // ---------------------------------------------------------------------------- -class Rotation { +class RotationType { public: - Rotation() : a(1.0),b(0.0),c(0.0),d(0.0) {} - Rotation(double yaw, double pitch, double roll) { fromEuler(yaw, pitch, roll); } - Rotation(double a, double b, double c, double d) : a(a),b(b),c(c),d(d) {} + RotationType() : a(1.0),b(0.0),c(0.0),d(0.0) {} + RotationType(double yaw, double pitch, double roll) { fromEuler(yaw, pitch, roll); } + RotationType(double a, double b, double c, double d) : a(a),b(b),c(c),d(d) {} - Rotation inv(){ // inverse - return Rotation(a,-b,-c, -d); + RotationType inv(){ // inverse + return RotationType(a,-b,-c, -d); } @@ -46,10 +46,10 @@ public: yaw = atan2(2.0*(a*d + b*c), 1.0 - 2.0*(c*c + d*d)); } - const Rotation operator*(const Rotation& B) + const RotationType operator*(const RotationType& B) { - const Rotation& A = *this; - return Rotation(A.a*B.a - A.b*B.b - A.c*B.c - A.d*B.d, // quaternion multiplication + const RotationType& A = *this; + return RotationType(A.a*B.a - A.b*B.b - A.c*B.c - A.d*B.d, // quaternion multiplication A.a*B.b + A.b*B.a + A.c*B.d - A.d*B.c, A.a*B.c - A.b*B.d + A.c*B.a + A.d*B.b, A.a*B.d + A.b*B.c - A.c*B.b + A.d*B.a); diff --git a/facetracknoir/tracker_types.cpp b/facetracknoir/tracker_types.cpp index da246722..dec4ff81 100644 --- a/facetracknoir/tracker_types.cpp +++ b/facetracknoir/tracker_types.cpp @@ -7,9 +7,9 @@ T6DOF operator-(const T6DOF& A, const T6DOF& B) { - Rotation R_A(A.axes[Yaw]*D2R, A.axes[Pitch]*D2R, A.axes[Roll]*D2R); - Rotation R_B(B.axes[Yaw]*D2R, B.axes[Pitch]*D2R, B.axes[Roll]*D2R); - Rotation R_C = R_A * R_B.inv(); + RotationType R_A(A.axes[Yaw]*D2R, A.axes[Pitch]*D2R, A.axes[Roll]*D2R); + RotationType R_B(B.axes[Yaw]*D2R, B.axes[Pitch]*D2R, B.axes[Roll]*D2R); + RotationType R_C = R_A * R_B.inv(); T6DOF C; R_C.toEuler(C.axes[Yaw], C.axes[Pitch], C.axes[Roll]); @@ -26,9 +26,9 @@ T6DOF operator-(const T6DOF& A, const T6DOF& B) T6DOF operator+(const T6DOF& A, const T6DOF& B) { - Rotation R_A(A.axes[Yaw]*D2R, A.axes[Pitch]*D2R, A.axes[Roll]*D2R); - Rotation R_B(B.axes[Yaw]*D2R, B.axes[Pitch]*D2R, B.axes[Roll]*D2R); - Rotation R_C = R_A * R_B; + RotationType R_A(A.axes[Yaw]*D2R, A.axes[Pitch]*D2R, A.axes[Roll]*D2R); + RotationType R_B(B.axes[Yaw]*D2R, B.axes[Pitch]*D2R, B.axes[Roll]*D2R); + RotationType R_C = R_A * R_B; T6DOF C; R_C.toEuler(C.axes[Yaw], C.axes[Pitch], C.axes[Roll]); -- cgit v1.2.3 From fc906d93916d04c81ae712e52045ed56c2788adc Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 15 Sep 2013 20:00:57 +0200 Subject: Simplify tracker API No need to have a separate finalization function, can just as well sleep in the destructor. --- FTNoIR_Tracker_PT/ftnoir_tracker_pt.h | 1 - facetracknoir/global-settings.cpp | 7 ------- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 2 ++ ftnoir_tracker_aruco/ftnoir_tracker_aruco.h | 7 ------- ftnoir_tracker_base/ftnoir_tracker_base.h | 2 -- ftnoir_tracker_ht/ftnoir_tracker_ht.cpp | 4 ++++ ftnoir_tracker_ht/ftnoir_tracker_ht.h | 10 ---------- ftnoir_tracker_udp/ftnoir_tracker_udp.cpp | 2 ++ ftnoir_tracker_udp/ftnoir_tracker_udp.h | 5 ----- 9 files changed, 8 insertions(+), 32 deletions(-) (limited to 'facetracknoir') diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h index 867378d1..7dcfc8bb 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h @@ -46,7 +46,6 @@ public: virtual void Initialize(QFrame *videoframe); #ifdef OPENTRACK_API virtual void StartTracker(QFrame* parent_window); - virtual void WaitForExit() {} virtual bool GiveHeadPoseData(double* data); #else virtual void StartTracker(HWND parent_window); diff --git a/facetracknoir/global-settings.cpp b/facetracknoir/global-settings.cpp index 4a655171..aa334463 100644 --- a/facetracknoir/global-settings.cpp +++ b/facetracknoir/global-settings.cpp @@ -8,13 +8,6 @@ SelectedLibraries* Libraries = NULL; SelectedLibraries::~SelectedLibraries() { - if (pTracker) { - pTracker->WaitForExit(); - } - if (pSecondTracker) { - pSecondTracker->WaitForExit(); - } - if (pTracker) { delete pTracker; pTracker = NULL; diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index e40c92d2..b781f390 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -137,6 +137,8 @@ Tracker::Tracker() Tracker::~Tracker() { + stop = true; + wait(); if (layout) delete layout; if (videoWidget) diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h index 7f21f020..98aba2cf 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h @@ -27,13 +27,6 @@ public: void StartTracker(QFrame* frame); bool GiveHeadPoseData(double *data); bool enableTX, enableTY, enableTZ, enableRX, enableRY, enableRZ; - bool NeedsTimeToFinish() { - return true; - } - void WaitForExit() { - stop = true; - wait(); - } void run(); private: QMutex mtx; diff --git a/ftnoir_tracker_base/ftnoir_tracker_base.h b/ftnoir_tracker_base/ftnoir_tracker_base.h index 39db6bb6..b84ce05d 100644 --- a/ftnoir_tracker_base/ftnoir_tracker_base.h +++ b/ftnoir_tracker_base/ftnoir_tracker_base.h @@ -51,8 +51,6 @@ struct ITracker virtual ~ITracker() {} virtual void StartTracker( QFrame* frame ) = 0; virtual bool GiveHeadPoseData(double *data) = 0; - - virtual void WaitForExit() = 0; virtual void NotifyCenter() {} }; diff --git a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp index 2ca5a3de..27817a0c 100644 --- a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp +++ b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp @@ -149,6 +149,10 @@ Tracker::Tracker() : lck_shm(HT_SHM_NAME, HT_MUTEX_NAME, sizeof(ht_shm_t)), fres Tracker::~Tracker() { + if (shm) { + shm->terminate = true; + subprocess.waitForFinished(5000); + } subprocess.kill(); if (shm) shm->terminate = true; diff --git a/ftnoir_tracker_ht/ftnoir_tracker_ht.h b/ftnoir_tracker_ht/ftnoir_tracker_ht.h index fcdea140..5b8eb508 100644 --- a/ftnoir_tracker_ht/ftnoir_tracker_ht.h +++ b/ftnoir_tracker_ht/ftnoir_tracker_ht.h @@ -27,16 +27,6 @@ public: bool GiveHeadPoseData(double *data); bool enableTX, enableTY, enableTZ, enableRX, enableRY, enableRZ; ht_shm_t* shm; - bool NeedsTimeToFinish() { - return true; - } - void WaitForExit() { - if (shm) { - shm->terminate = true; - subprocess.waitForFinished(5000); - } - subprocess.kill(); - } private: QTimer timer; PortableLockedShm lck_shm; diff --git a/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp b/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp index e71d13bb..d67fb636 100644 --- a/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp +++ b/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp @@ -45,6 +45,8 @@ FTNoIR_Tracker::FTNoIR_Tracker() FTNoIR_Tracker::~FTNoIR_Tracker() { + should_quit = true; + wait(); if (inSocket) { inSocket->close(); delete inSocket; diff --git a/ftnoir_tracker_udp/ftnoir_tracker_udp.h b/ftnoir_tracker_udp/ftnoir_tracker_udp.h index 76fcacf2..e5ea7ff3 100644 --- a/ftnoir_tracker_udp/ftnoir_tracker_udp.h +++ b/ftnoir_tracker_udp/ftnoir_tracker_udp.h @@ -19,11 +19,6 @@ public: bool GiveHeadPoseData(double *data); void loadSettings(); volatile bool should_quit; - void WaitForExit() { - should_quit = true; - wait(); - } - protected: void run(); // qthread override run method -- cgit v1.2.3 From 61b7881fc31eaba7d6a2d7a7e9496a0f16b5f002 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 17 Sep 2013 01:21:05 +0200 Subject: Rename axes in dialog to commonly used terms --- facetracknoir/ftnoir_curves.ui | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/ftnoir_curves.ui b/facetracknoir/ftnoir_curves.ui index 9dc79326..bbdce4e2 100644 --- a/facetracknoir/ftnoir_curves.ui +++ b/facetracknoir/ftnoir_curves.ui @@ -81,7 +81,7 @@ color: rgb(255, 255, 255); - rx + Yaw @@ -165,7 +165,7 @@ color: rgb(255, 255, 255); - ry + Pitch @@ -255,7 +255,7 @@ color: rgb(255, 255, 255); - rz + Roll @@ -345,7 +345,7 @@ color: rgb(255, 255, 255); - tx + X @@ -435,7 +435,7 @@ color: rgb(255, 255, 255); - ty + Y @@ -525,7 +525,7 @@ color: rgb(255, 255, 255); - tz + Z -- cgit v1.2.3 From d0f805f9943db3a14c0eed5ebb503000e5c9ea88 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 17 Sep 2013 17:33:47 +0200 Subject: Sprinkle some volatile These data members are accessed without a lock. --- facetracknoir/tracker.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/tracker.h b/facetracknoir/tracker.h index c831df61..89f54bd5 100644 --- a/facetracknoir/tracker.h +++ b/facetracknoir/tracker.h @@ -77,12 +77,12 @@ public: altp = iniFile.value(secondary).toBool(); iniFile.endGroup(); } - double headPos; // Current position (from faceTracker, radials or meters) - float invert; // Invert measured value (= 1.0f or -1.0f) + volatile double headPos; // Current position (from faceTracker, radials or meters) + volatile float invert; // Invert measured value (= 1.0f or -1.0f) FunctionConfig curve; // Function to translate input -> output FunctionConfig curveAlt; - bool altp; - double zero; + volatile bool altp; + volatile double zero; }; class Tracker : public QThread { -- cgit v1.2.3 From f8edb5c556f970f5fc9be8919e054e0d973e9dcc Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 17 Sep 2013 17:41:54 +0200 Subject: main ui: appease GNU CC -Wreorder --- facetracknoir/facetracknoir.cpp | 6 +++--- facetracknoir/tracker.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index 394ad8a6..dc3bd15b 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -86,18 +86,18 @@ static void fill_combobox(const QString& filter, QList& list, Q // Setup the Main Dialog // FaceTrackNoIR::FaceTrackNoIR(QWidget *parent, Qt::WFlags flags) : + QMainWindow(parent, flags), #if defined(_WIN32) keybindingWorker(NULL), #else keyCenter(0), #endif - QMainWindow(parent, flags), + timUpdateHeadPose(this), pTrackerDialog(NULL), pSecondTrackerDialog(NULL), pProtocolDialog(NULL), pFilterDialog(NULL), - looping(false), - timUpdateHeadPose(this) + looping(false) { ui.setupUi(this); diff --git a/facetracknoir/tracker.h b/facetracknoir/tracker.h index 89f54bd5..885fc1e2 100644 --- a/facetracknoir/tracker.h +++ b/facetracknoir/tracker.h @@ -61,10 +61,10 @@ public: int maxOutput1, int maxInput2, int maxOutput2) : - curve(primary, maxInput1, maxOutput1), - curveAlt(secondary, maxInput2, maxOutput2), headPos(0), invert(1), + curve(primary, maxInput1, maxOutput1), + curveAlt(secondary, maxInput2, maxOutput2), zero(0) { QSettings settings("opentrack"); // Registry settings (in HK_USER) -- cgit v1.2.3 From 982bc5ef759e2d35341216c89ef1c1fd5d49babd Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 17 Sep 2013 18:18:26 +0200 Subject: main: -Wall clean --- facetracknoir/shortcuts.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'facetracknoir') diff --git a/facetracknoir/shortcuts.cpp b/facetracknoir/shortcuts.cpp index cdb2c3b7..152fe565 100644 --- a/facetracknoir/shortcuts.cpp +++ b/facetracknoir/shortcuts.cpp @@ -138,7 +138,7 @@ KeybindingWorkerImpl::~KeybindingWorkerImpl() { } KeybindingWorkerImpl::KeybindingWorkerImpl(FaceTrackNoIR& w, Key keyCenter) -: kCenter(keyCenter), window(w), should_quit(true), din(0), dinkeyboard(0) +: din(0), dinkeyboard(0), kCenter(keyCenter), window(w), should_quit(true) { if (DirectInput8Create(GetModuleHandle(NULL), DIRECTINPUT_VERSION, IID_IDirectInput8, (void**)&din, NULL) != DI_OK) { qDebug() << "setup DirectInput8 Creation failed!" << GetLastError(); -- cgit v1.2.3 From 088a7524206f40b8385b7da8f0377b72942f0dbd Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 17 Sep 2013 19:04:54 +0200 Subject: Check .ini access rights on Linux --- facetracknoir/facetracknoir.cpp | 15 ++++++++++++++- facetracknoir/facetracknoir.h | 1 + 2 files changed, 15 insertions(+), 1 deletion(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index dc3bd15b..fa1b7ea6 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -48,6 +48,10 @@ # define LIB_PREFIX "lib" #endif +#if defined(__unix) || defined(__linux) +# include +#endif + static bool get_metadata(DynamicLibrary* lib, QString& longName, QIcon& icon) { Metadata* meta; @@ -288,7 +292,6 @@ void FaceTrackNoIR::open() { // Save the current Settings to the currently 'active' INI-file. // void FaceTrackNoIR::save() { - QSettings settings("opentrack"); // Registry settings (in HK_USER) QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); @@ -330,6 +333,16 @@ void FaceTrackNoIR::save() { iniFile.setValue ( "DLL", filter == NULL ? "" : filter->filename); } iniFile.endGroup (); + +#if defined(__unix) || defined(__linux) + QByteArray bytes = currentFile.toUtf8(); + const char* filename_as_asciiz = bytes.constData(); + + if (access(filename_as_asciiz, R_OK | W_OK)) + { + QMessageBox::warning(this, "Something went wrong", "Check permissions and ownership for your .ini file!", QMessageBox::Ok, QMessageBox::NoButton); + } +#endif } // diff --git a/facetracknoir/facetracknoir.h b/facetracknoir/facetracknoir.h index 16f42727..b7c164ff 100644 --- a/facetracknoir/facetracknoir.h +++ b/facetracknoir/facetracknoir.h @@ -37,6 +37,7 @@ #include #include #include +#include #if !defined(_WIN32) # include #else -- cgit v1.2.3 From ec37d5b6834e45b2c90a2919fa9023dee5c0237c Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 17 Sep 2013 19:08:41 +0200 Subject: main: Use proper locale for asciiz conversion --- facetracknoir/facetracknoir.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index fa1b7ea6..1b09a681 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -335,7 +335,7 @@ void FaceTrackNoIR::save() { iniFile.endGroup (); #if defined(__unix) || defined(__linux) - QByteArray bytes = currentFile.toUtf8(); + QByteArray bytes = QFile::encodeName(currentFile); const char* filename_as_asciiz = bytes.constData(); if (access(filename_as_asciiz, R_OK | W_OK)) -- cgit v1.2.3 From 5d22b1379f161ae2e367ed24cba2d2e774d06865 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 17 Sep 2013 19:16:48 +0200 Subject: ui: Enable antialiasing --- facetracknoir/main.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'facetracknoir') diff --git a/facetracknoir/main.cpp b/facetracknoir/main.cpp index fbf28678..a015eeeb 100644 --- a/facetracknoir/main.cpp +++ b/facetracknoir/main.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #if defined(_WIN32) # include @@ -35,6 +36,7 @@ #elif defined(Q_OS_UNIX) #include #endif + int main(int argc, char** argv) { #if defined(Q_WS_X11) @@ -44,6 +46,7 @@ int main(int argc, char** argv) QFont font; font.setFamily(font.defaultFamily()); font.setPointSize(9); + font.setStyleStrategy(QFont::PreferAntialias); app.setFont(font); FaceTrackNoIR w; // -- cgit v1.2.3 From 6f7bff0e7465b2af3247f606db714e7fe4650a42 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 17 Sep 2013 19:20:08 +0200 Subject: Remove asinine comment --- facetracknoir/main.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/main.cpp b/facetracknoir/main.cpp index a015eeeb..25da2961 100644 --- a/facetracknoir/main.cpp +++ b/facetracknoir/main.cpp @@ -49,9 +49,7 @@ int main(int argc, char** argv) font.setStyleStrategy(QFont::PreferAntialias); app.setFont(font); FaceTrackNoIR w; - // - // Create the Main Window and DeskTop and Exec! - // + QDesktopWidget desktop; w.move(desktop.screenGeometry().width()/2-w.width()/2, 100); w.show(); -- cgit v1.2.3 From 1843e0bbb533a8fd438c31f6dc292dba9065be43 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 17 Sep 2013 19:24:06 +0200 Subject: main: Enable X11 threads the idiomatic way --- CMakeLists.txt | 2 -- facetracknoir/main.cpp | 11 +++++------ 2 files changed, 5 insertions(+), 8 deletions(-) (limited to 'facetracknoir') diff --git a/CMakeLists.txt b/CMakeLists.txt index a0207df4..bc734e43 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -536,8 +536,6 @@ endif() winmm uuid ) - else() - target_link_libraries(opentrack X11) endif() if(MSVC) SET_TARGET_PROPERTIES(opentrack PROPERTIES LINK_FLAGS "/ENTRY:mainCRTStartup") diff --git a/facetracknoir/main.cpp b/facetracknoir/main.cpp index 25da2961..78ea9aea 100644 --- a/facetracknoir/main.cpp +++ b/facetracknoir/main.cpp @@ -33,24 +33,23 @@ #if defined(_WIN32) # include //#pragma comment(linker, "/SUBSYSTEM:console /ENTRY:mainCRTStartup") -#elif defined(Q_OS_UNIX) -#include #endif int main(int argc, char** argv) { -#if defined(Q_WS_X11) - XInitThreads(); -#endif + QApplication::setAttribute(Qt::AA_X11InitThreads, true); + QApplication app(argc, argv); + QFont font; font.setFamily(font.defaultFamily()); font.setPointSize(9); font.setStyleStrategy(QFont::PreferAntialias); app.setFont(font); - FaceTrackNoIR w; + FaceTrackNoIR w; QDesktopWidget desktop; + w.move(desktop.screenGeometry().width()/2-w.width()/2, 100); w.show(); qApp->exec(); -- cgit v1.2.3 From edb9c9865b0526b8da9efe4369182387c632efb7 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 17 Sep 2013 19:26:58 +0200 Subject: ui: Don't override default font family since Admc@ complains so much --- facetracknoir/main.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'facetracknoir') diff --git a/facetracknoir/main.cpp b/facetracknoir/main.cpp index 78ea9aea..1a9f8a3c 100644 --- a/facetracknoir/main.cpp +++ b/facetracknoir/main.cpp @@ -40,12 +40,14 @@ int main(int argc, char** argv) QApplication::setAttribute(Qt::AA_X11InitThreads, true); QApplication app(argc, argv); +#if 0 QFont font; font.setFamily(font.defaultFamily()); font.setPointSize(9); font.setStyleStrategy(QFont::PreferAntialias); app.setFont(font); +#endif FaceTrackNoIR w; QDesktopWidget desktop; -- cgit v1.2.3 From 9ada3fad5dcd0885aa9a0f27d71b0ce01c017bcd Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 17 Sep 2013 19:29:03 +0200 Subject: main: use app instance, not some qt singleton --- facetracknoir/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'facetracknoir') diff --git a/facetracknoir/main.cpp b/facetracknoir/main.cpp index 1a9f8a3c..9dc0749f 100644 --- a/facetracknoir/main.cpp +++ b/facetracknoir/main.cpp @@ -54,7 +54,7 @@ int main(int argc, char** argv) w.move(desktop.screenGeometry().width()/2-w.width()/2, 100); w.show(); - qApp->exec(); + app.exec(); return 0; } -- cgit v1.2.3 From d83c606639fd1a092b026cb3264e427957532741 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 18 Sep 2013 16:38:28 +0200 Subject: main: bump version --- facetracknoir/facetracknoir.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index 1b09a681..9e81912e 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -414,7 +414,7 @@ void FaceTrackNoIR::loadSettings() { // Put the filename in the window-title. // QFileInfo pathInfo ( currentFile ); - setWindowTitle ( "opentrack 2.0a1 - " + pathInfo.fileName() ); + setWindowTitle ( "opentrack 2.0a2 - " + pathInfo.fileName() ); // // Get a List of all the INI-files in the (currently active) Settings-folder. -- cgit v1.2.3 From ccfcf1f770919822126f5e49f2a21ffb63b128fe Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 19 Sep 2013 17:43:40 +0200 Subject: ui: clean up ::showHeadPose() --- facetracknoir/facetracknoir.cpp | 50 +++++++++++++---------------------------- 1 file changed, 15 insertions(+), 35 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index 9e81912e..ea7718b7 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -744,33 +744,17 @@ void FaceTrackNoIR::setInvertAxis(Axis axis, int invert ) { void FaceTrackNoIR::showHeadPose() { double newdata[6]; - ui.lblX->setVisible(true); - ui.lblY->setVisible(true); - ui.lblZ->setVisible(true); - ui.lblRotX->setVisible(true); - ui.lblRotY->setVisible(true); - ui.lblRotZ->setVisible(true); - - ui.lcdNumOutputPosX->setVisible(true); - ui.lcdNumOutputPosY->setVisible(true); - ui.lcdNumOutputPosZ->setVisible(true); - ui.lcdNumOutputRotX->setVisible(true); - ui.lcdNumOutputRotY->setVisible(true); - ui.lcdNumOutputRotZ->setVisible(true); - - // - // Get the pose and also display it. - // Updating the pose from within the Tracker-class caused crashes... - // + const QString format("%1"); + tracker->getHeadPose(newdata); - ui.lcdNumX->display(QString("%1").arg(newdata[TX], 0, 'f', 1)); - ui.lcdNumY->display(QString("%1").arg(newdata[TY], 0, 'f', 1)); - ui.lcdNumZ->display(QString("%1").arg(newdata[TZ], 0, 'f', 1)); + ui.lcdNumX->display(format.arg(newdata[TX], 0, 'f', 1)); + ui.lcdNumY->display(format.arg(newdata[TY], 0, 'f', 1)); + ui.lcdNumZ->display(format.arg(newdata[TZ], 0, 'f', 1)); - ui.lcdNumRotX->display(QString("%1").arg(newdata[Yaw], 0, 'f', 1)); - ui.lcdNumRotY->display(QString("%1").arg(newdata[Pitch], 0, 'f', 1)); - ui.lcdNumRotZ->display(QString("%1").arg(newdata[Roll], 0, 'f', 1)); + ui.lcdNumRotX->display(format.arg(newdata[Yaw], 0, 'f', 1)); + ui.lcdNumRotY->display(format.arg(newdata[Pitch], 0, 'f', 1)); + ui.lcdNumRotZ->display(format.arg(newdata[Roll], 0, 'f', 1)); // // Get the output-pose and also display it. @@ -779,24 +763,20 @@ void FaceTrackNoIR::showHeadPose() { ui.pose_display->rotateBy(newdata[Yaw], newdata[Roll], newdata[Pitch]); - ui.lcdNumOutputPosX->display(QString("%1").arg(newdata[TX], 0, 'f', 1)); - ui.lcdNumOutputPosY->display(QString("%1").arg(newdata[TY], 0, 'f', 1)); - ui.lcdNumOutputPosZ->display(QString("%1").arg(newdata[TZ], 0, 'f', 1)); - + ui.lcdNumOutputPosX->display(format.arg(newdata[TX], 0, 'f', 1)); + ui.lcdNumOutputPosY->display(format.arg(newdata[TY], 0, 'f', 1)); + ui.lcdNumOutputPosZ->display(format.arg(newdata[TZ], 0, 'f', 1)); - ui.lcdNumOutputRotX->display(QString("%1").arg(newdata[Yaw], 0, 'f', 1)); - ui.lcdNumOutputRotY->display(QString("%1").arg(newdata[Pitch], 0, 'f', 1)); - ui.lcdNumOutputRotZ->display(QString("%1").arg(newdata[Roll], 0, 'f', 1)); + ui.lcdNumOutputRotX->display(format.arg(newdata[Yaw], 0, 'f', 1)); + ui.lcdNumOutputRotY->display(format.arg(newdata[Pitch], 0, 'f', 1)); + ui.lcdNumOutputRotZ->display(format.arg(newdata[Roll], 0, 'f', 1)); - // - // Update the curves in the curve-configurator. This shows the ball with the red lines. - // if (_curve_config) { _curve_config->update(); } if (Libraries->pProtocol) { - QString name = Libraries->pProtocol->getGameName(); + const QString name = Libraries->pProtocol->getGameName(); ui.game_name->setText(name); } } -- cgit v1.2.3 From 6f5b8f65704c0c8e2426305e2006ce73074a47d5 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 19 Sep 2013 17:44:50 +0200 Subject: ui: cleanup unused functions --- facetracknoir/facetracknoir.cpp | 16 ---------------- facetracknoir/facetracknoir.h | 2 -- 2 files changed, 18 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index ea7718b7..aa92987c 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -781,22 +781,6 @@ void FaceTrackNoIR::showHeadPose() { } } -/** toggles Video Widget **/ -void FaceTrackNoIR::showVideoWidget() { - if(ui.video_frame->isHidden()) - ui.video_frame->show(); - else - ui.video_frame->hide(); -} - -/** toggles Video Widget **/ -void FaceTrackNoIR::showHeadPoseWidget() { - if(ui.headPoseWidget->isHidden()) - ui.headPoseWidget->show(); - else - ui.headPoseWidget->hide(); -} - /** toggles Engine Controls Dialog **/ void FaceTrackNoIR::showTrackerSettings() { if (pTrackerDialog) { diff --git a/facetracknoir/facetracknoir.h b/facetracknoir/facetracknoir.h index b7c164ff..b9c7168b 100644 --- a/facetracknoir/facetracknoir.h +++ b/facetracknoir/facetracknoir.h @@ -134,8 +134,6 @@ private slots: // void setIcon(int index); void profileSelected(int index); - void showVideoWidget(); - void showHeadPoseWidget(); void showTrackerSettings(); void showSecondTrackerSettings(); -- cgit v1.2.3 From 4e4ec1db06ad848544123d6a22a595f8fb4dc14e Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 19 Sep 2013 17:49:57 +0200 Subject: hpp: remove unused function, PT dropped support --- facetracknoir/tracker.cpp | 6 ------ ftnoir_tracker_base/ftnoir_tracker_base.h | 1 - 2 files changed, 7 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/tracker.cpp b/facetracknoir/tracker.cpp index 4304d939..ab62590b 100644 --- a/facetracknoir/tracker.cpp +++ b/facetracknoir/tracker.cpp @@ -117,12 +117,6 @@ void Tracker::run() { Tracker::do_center = false; - if (Libraries->pTracker) - Libraries->pTracker->NotifyCenter(); - - if (Libraries->pSecondTracker) - Libraries->pSecondTracker->NotifyCenter(); - if (Libraries->pFilter) Libraries->pFilter->Initialize(); } diff --git a/ftnoir_tracker_base/ftnoir_tracker_base.h b/ftnoir_tracker_base/ftnoir_tracker_base.h index b84ce05d..cd603225 100644 --- a/ftnoir_tracker_base/ftnoir_tracker_base.h +++ b/ftnoir_tracker_base/ftnoir_tracker_base.h @@ -51,7 +51,6 @@ struct ITracker virtual ~ITracker() {} virtual void StartTracker( QFrame* frame ) = 0; virtual bool GiveHeadPoseData(double *data) = 0; - virtual void NotifyCenter() {} }; typedef ITracker* ITrackerPtr; -- cgit v1.2.3 From 2a3dc6a351d4fcd04e50a957b23e638ffa4bea46 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 19 Sep 2013 18:04:09 +0200 Subject: shortcuts: use win32 headers properly --- facetracknoir/global-shortcuts.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/global-shortcuts.cpp b/facetracknoir/global-shortcuts.cpp index 8666333c..e96530ae 100644 --- a/facetracknoir/global-shortcuts.cpp +++ b/facetracknoir/global-shortcuts.cpp @@ -2,8 +2,9 @@ #if defined(_WIN32) #include -#include -#include +#define DIRECTINPUT_VERSION 0x800 +#include + QList global_windows_key_sequences = QList() << 0 -- cgit v1.2.3 From 65229f5ad8ce2c8e999b0cf181c11383b0a9effb Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 19 Sep 2013 18:08:04 +0200 Subject: don't redefine dinput version that much --- facetracknoir/global-shortcuts.cpp | 8 +++++--- facetracknoir/shortcuts.h | 2 -- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/global-shortcuts.cpp b/facetracknoir/global-shortcuts.cpp index e96530ae..1c10b160 100644 --- a/facetracknoir/global-shortcuts.cpp +++ b/facetracknoir/global-shortcuts.cpp @@ -1,9 +1,11 @@ #include "facetracknoir/facetracknoir.h" #if defined(_WIN32) -#include -#define DIRECTINPUT_VERSION 0x800 -#include +# ifndef DIRECTINPUT_VERSION +# define DIRECTINPUT_VERSION 0x800 +# endif +# include +# include QList global_windows_key_sequences = QList() diff --git a/facetracknoir/shortcuts.h b/facetracknoir/shortcuts.h index 685c78b6..05c36520 100644 --- a/facetracknoir/shortcuts.h +++ b/facetracknoir/shortcuts.h @@ -39,8 +39,6 @@ extern QList global_windows_key_sequences; # undef DIRECTINPUT_VERSION # define DIRECTINPUT_VERSION 0x0800 # include -# undef DIRECTINPUT_VERSION -# define DIRECTINPUT_VERSION 0x0800 # include struct Key { -- cgit v1.2.3 From 7d95cb69ead5e427b900184021de73b65a58f982 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 19 Sep 2013 18:16:44 +0200 Subject: clean up implicit conversions float -> double --- facetracknoir/tracker.cpp | 2 +- ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/tracker.cpp b/facetracknoir/tracker.cpp index ab62590b..b965140b 100644 --- a/facetracknoir/tracker.cpp +++ b/facetracknoir/tracker.cpp @@ -189,4 +189,4 @@ void Tracker::getOutputHeadPose( double *data ) { data[i] = output_camera.axes[i]; } -void Tracker::setInvertAxis(Axis axis, bool invert) { mainApp->axis(axis).invert = invert?-1.0f:1.0f; } +void Tracker::setInvertAxis(Axis axis, bool invert) { mainApp->axis(axis).invert = invert? -1.0 : 1.0; } diff --git a/ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp b/ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp index f50c60d1..69d18d9b 100644 --- a/ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp +++ b/ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp @@ -64,7 +64,7 @@ void FTNoIR_Filter::loadSettings() { qDebug() << "FTNoIR_Filter::loadSettings says: Starting "; QSettings settings("opentrack"); // Registry settings (in HK_USER) - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); + QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) qDebug() << "FTNoIR_Filter::loadSettings says: iniFile = " << currentFile; @@ -108,7 +108,7 @@ void FTNoIR_Filter::FilterHeadPoseData(const double *target_camera_position, // Calculate the new alpha from the normalized delta. new_alpha=1.0/(kMinSmoothing+((1.0-pow(delta,kSmoothingScaleCurve))*(kMaxSmoothing-kMinSmoothing))); // Update the smoothed alpha. - alpha[i]=(alpha_smoothing*new_alpha)+((1.0f-alpha_smoothing)*alpha[i]); + alpha[i]=(alpha_smoothing*new_alpha)+((1.0-alpha_smoothing)*alpha[i]); } // Use the same (largest) smoothed alpha for each channel @@ -120,7 +120,7 @@ void FTNoIR_Filter::FilterHeadPoseData(const double *target_camera_position, // Calculate the new camera position. for (int i=0;i<6;i++) { - new_camera_position[i]=(largest_alpha*target_camera_position[i])+((1.0f-largest_alpha)*current_camera_position[i]); + new_camera_position[i]=(largest_alpha*target_camera_position[i])+((1.0-largest_alpha)*current_camera_position[i]); //new_camera_position[i]=(alpha[i]*target_camera_position[i])+((1.0f-alpha[i])*current_camera_position[i]); } -- cgit v1.2.3 From b9759403d7e22544975da8ba164cb9323e1b66a6 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 8 Oct 2013 18:26:18 +0200 Subject: Temporary fix for bad label size on Linux In particular, KDE with QtCurve and default DPI was broken, rendering labels unreadable. We'll use proper layouts in Qt5, when the switch finally happens... Signed-off-by: Stanislaw Halik --- facetracknoir/facetracknoir.ui | 186 ++++++++++++++--------------------------- 1 file changed, 64 insertions(+), 122 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.ui b/facetracknoir/facetracknoir.ui index fca13902..851fb6a2 100644 --- a/facetracknoir/facetracknoir.ui +++ b/facetracknoir/facetracknoir.ui @@ -10,7 +10,7 @@ 0 0 - 874 + 880 380 @@ -22,13 +22,13 @@ - 874 + 880 380 - 874 + 880 380 @@ -165,7 +165,7 @@ QGroupBox { 250 0 - 671 + 738 431 @@ -477,77 +477,19 @@ background:none; 320 70 - 221 - 121 + 231 + 101 Axis inversion - - - - 169 - 24 - 30 - 16 - - - - - 0 - 0 - - - - - 30 - 16777215 - - - - color:#ccc; -background:none; - - - Invert - - - - - - 72 - 24 - 30 - 16 - - - - - 0 - 0 - - - - - 30 - 16777215 - - - - color:#ccc; -background:none; - - - Invert - - - 108 - 52 - 25 + 130 + 29 + 41 16 @@ -577,21 +519,21 @@ background:none; - 10 - 71 - 25 + 20 + 50 + 61 16 - 25 + 40 0 - 150 + 65536 16777215 @@ -609,8 +551,8 @@ background:none; - 72 - 71 + 90 + 50 16 16 @@ -625,9 +567,9 @@ background:none; - 108 - 71 - 25 + 130 + 48 + 41 16 @@ -657,9 +599,9 @@ background:none; - 108 - 90 - 25 + 130 + 67 + 41 16 @@ -689,8 +631,8 @@ background:none; - 169 - 90 + 192 + 67 16 16 @@ -705,8 +647,8 @@ background:none; - 169 - 71 + 192 + 48 16 16 @@ -721,8 +663,8 @@ background:none; - 72 - 90 + 90 + 69 16 16 @@ -737,8 +679,8 @@ background:none; - 169 - 52 + 192 + 29 16 16 @@ -753,21 +695,21 @@ background:none; - 10 - 52 - 25 + 20 + 31 + 61 16 - 25 + 40 0 - 150 + 65536 16777215 @@ -785,8 +727,8 @@ background:none; - 72 - 52 + 90 + 31 16 16 @@ -801,21 +743,21 @@ background:none; - 10 - 90 - 25 + 20 + 69 + 61 16 - 25 + 40 0 - 150 + 65536 16777215 @@ -1098,20 +1040,20 @@ background:none; 230 201 - 200 + 180 80 - 200 - 70 + 180 + 80 - 200 - 80 + 180 + 65536 @@ -1125,7 +1067,7 @@ background:none; 10 20 - 180 + 161 22 @@ -1147,7 +1089,7 @@ background:none; 10 50 - 180 + 161 23 @@ -1234,13 +1176,13 @@ background:none; 230 289 200 - 80 + 61 200 - 80 + 0 @@ -1299,7 +1241,7 @@ background:none; 440 288 - 181 + 171 38 @@ -1311,7 +1253,7 @@ background:none; - 54 + 64 38 @@ -1346,13 +1288,13 @@ background:none; 440 332 - 181 + 171 38 - 54 + 64 38 @@ -1893,7 +1835,7 @@ color:white; 9 20 - 16 + 31 16 @@ -1909,7 +1851,7 @@ color:white; 10 40 - 16 + 31 16 @@ -1925,7 +1867,7 @@ color:white; 10 59 - 16 + 31 16 @@ -1940,8 +1882,8 @@ color:white; 69 - 59 - 20 + 60 + 51 16 @@ -1956,8 +1898,8 @@ color:white; 71 - 20 - 20 + 21 + 51 16 @@ -1972,8 +1914,8 @@ color:white; 69 - 40 - 25 + 41 + 51 16 -- cgit v1.2.3 From f5c9765f76141840e411159933098c6f4bad7f33 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 8 Oct 2013 19:29:54 +0200 Subject: correct fgfs protocol bitrot Signed-off-by: Stanislaw Halik --- facetracknoir/clientfiles/FlightGear/Linux/usage.txt | 6 ++++++ ftnoir_protocol_fg/fgtypes.h | 2 +- ftnoir_protocol_fg/ftnoir_fgcontrols.ui | 4 ++-- ftnoir_protocol_fg/ftnoir_protocol_fg.cpp | 12 +++++------- ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp | 2 +- ftnoir_protocol_ftn/ftnoir_protocol_ftn.cpp | 2 +- 6 files changed, 16 insertions(+), 12 deletions(-) create mode 100644 facetracknoir/clientfiles/FlightGear/Linux/usage.txt (limited to 'facetracknoir') diff --git a/facetracknoir/clientfiles/FlightGear/Linux/usage.txt b/facetracknoir/clientfiles/FlightGear/Linux/usage.txt new file mode 100644 index 00000000..14c77ad0 --- /dev/null +++ b/facetracknoir/clientfiles/FlightGear/Linux/usage.txt @@ -0,0 +1,6 @@ +fgfs --generic=socket,in,25,localhost,5542,udp,headtracker ~/opt/fgdata/Nasal/headtracker.xml + +Adjust paths as necessary. + +cheers, +-sh 20131008 diff --git a/ftnoir_protocol_fg/fgtypes.h b/ftnoir_protocol_fg/fgtypes.h index 0f29be3d..049de318 100644 --- a/ftnoir_protocol_fg/fgtypes.h +++ b/ftnoir_protocol_fg/fgtypes.h @@ -17,7 +17,7 @@ // // x,y,z position in metres, heading, pitch and roll in degrees... // -#pragma pack(push, 2) +#pragma pack(push, 1) struct TFlightGearData { double x, y, z, h, p, r; int status; diff --git a/ftnoir_protocol_fg/ftnoir_fgcontrols.ui b/ftnoir_protocol_fg/ftnoir_fgcontrols.ui index 51b5693c..fd0df6b0 100644 --- a/ftnoir_protocol_fg/ftnoir_fgcontrols.ui +++ b/ftnoir_protocol_fg/ftnoir_fgcontrols.ui @@ -9,8 +9,8 @@ 0 0 - 486 - 210 + 518 + 208 diff --git a/ftnoir_protocol_fg/ftnoir_protocol_fg.cpp b/ftnoir_protocol_fg/ftnoir_protocol_fg.cpp index dc76d193..643f9dd5 100644 --- a/ftnoir_protocol_fg/ftnoir_protocol_fg.cpp +++ b/ftnoir_protocol_fg/ftnoir_protocol_fg.cpp @@ -74,7 +74,7 @@ void FTNoIR_Protocol::loadSettings() { QString destAddr = iniFile.value ( "IP-1", 192 ).toString() + "." + iniFile.value ( "IP-2", 168 ).toString() + "." + iniFile.value ( "IP-3", 2 ).toString() + "." + iniFile.value ( "IP-4", 1 ).toString(); destIP = QHostAddress( destAddr ); } - destPort = iniFile.value ( "PortNumber", 5550 ).toInt(); + destPort = iniFile.value ( "PortNumber", 5542 ).toInt(); iniFile.endGroup (); @@ -91,10 +91,10 @@ quint16 senderPort; // // Copy the Raw measurements directly to the client. // - FlightData.x = headpose[TX]; - FlightData.y = headpose[Pitch]; - FlightData.z = headpose[TZ]; - FlightData.p = headpose[TY]; + FlightData.x = headpose[TX] * 1e-2; + FlightData.y = headpose[TY] * 1e-2; + FlightData.z = headpose[TZ] * 1e-2; + FlightData.p = headpose[Pitch]; FlightData.h = headpose[Yaw]; FlightData.r = headpose[Roll]; FlightData.status = fg_cmd; @@ -129,11 +129,9 @@ quint16 senderPort; #ifndef SEND_ASCII_DATA //! [1] -// no_bytes = outSocket->writeDatagram((const char *) &FlightData, sizeof( FlightData ), QHostAddress::LocalHost, 5550); if (outSocket != 0) { no_bytes = outSocket->writeDatagram((const char *) &FlightData, sizeof( FlightData ), destIP, destPort); if ( no_bytes > 0) { - // qDebug() << "FGServer::writePendingDatagrams says: bytes send =" << no_bytes << sizeof( double ); } else { qDebug() << "FGServer::writePendingDatagrams says: nothing sent!"; diff --git a/ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp b/ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp index b670bdd3..f479ce76 100644 --- a/ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp +++ b/ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp @@ -147,7 +147,7 @@ void FGControls::loadSettings() { ui.spinIPThirdNibble->setValue( iniFile.value ( "IP-3", 2 ).toInt() ); ui.spinIPFourthNibble->setValue( iniFile.value ( "IP-4", 1 ).toInt() ); - ui.spinPortNumber->setValue( iniFile.value ( "PortNumber", 5550 ).toInt() ); + ui.spinPortNumber->setValue( iniFile.value ( "PortNumber", 5542 ).toInt() ); iniFile.endGroup (); chkLocalPCOnlyChanged(); diff --git a/ftnoir_protocol_ftn/ftnoir_protocol_ftn.cpp b/ftnoir_protocol_ftn/ftnoir_protocol_ftn.cpp index d29c80c9..3d04dfd0 100644 --- a/ftnoir_protocol_ftn/ftnoir_protocol_ftn.cpp +++ b/ftnoir_protocol_ftn/ftnoir_protocol_ftn.cpp @@ -58,7 +58,7 @@ void FTNoIR_Protocol::loadSettings() { QString destAddr = iniFile.value ( "IP-1", 192 ).toString() + "." + iniFile.value ( "IP-2", 168 ).toString() + "." + iniFile.value ( "IP-3", 2 ).toString() + "." + iniFile.value ( "IP-4", 1 ).toString(); destIP = QHostAddress( destAddr ); - destPort = iniFile.value ( "PortNumber", 5550 ).toInt(); + destPort = iniFile.value ( "PortNumber", 5550 ).toInt(); iniFile.endGroup (); } -- cgit v1.2.3 From d2ee21b36506009aa8faa6ac66d842c339d06dbe Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 8 Oct 2013 21:40:50 +0200 Subject: actually fix FG this time Signed-off-by: Stanislaw Halik --- .../clientfiles/FlightGear/Linux/usage.txt | 4 +- .../clientfiles/FlightGear/Nasal/headtracker.xml | 83 ------------ .../FlightGear/Protocol/headtracker.xml | 27 +--- ftnoir_protocol_fg/fgtypes.h | 2 +- ftnoir_protocol_fg/ftnoir_protocol_fg.cpp | 143 ++------------------- ftnoir_protocol_fg/ftnoir_protocol_fg.h | 12 +- 6 files changed, 21 insertions(+), 250 deletions(-) delete mode 100644 facetracknoir/clientfiles/FlightGear/Nasal/headtracker.xml (limited to 'facetracknoir') diff --git a/facetracknoir/clientfiles/FlightGear/Linux/usage.txt b/facetracknoir/clientfiles/FlightGear/Linux/usage.txt index 14c77ad0..48cee837 100644 --- a/facetracknoir/clientfiles/FlightGear/Linux/usage.txt +++ b/facetracknoir/clientfiles/FlightGear/Linux/usage.txt @@ -1,4 +1,6 @@ -fgfs --generic=socket,in,25,localhost,5542,udp,headtracker ~/opt/fgdata/Nasal/headtracker.xml +Copy Protocol/headtracker.xml to fgdata/Protocol/headtracker.xml + +$ fgfs --generic=socket,in,25,localhost,5542,udp,headtracker Adjust paths as necessary. diff --git a/facetracknoir/clientfiles/FlightGear/Nasal/headtracker.xml b/facetracknoir/clientfiles/FlightGear/Nasal/headtracker.xml deleted file mode 100644 index d8bd1d0a..00000000 --- a/facetracknoir/clientfiles/FlightGear/Nasal/headtracker.xml +++ /dev/null @@ -1,83 +0,0 @@ - - - - - - - - - - - - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - - - diff --git a/facetracknoir/clientfiles/FlightGear/Protocol/headtracker.xml b/facetracknoir/clientfiles/FlightGear/Protocol/headtracker.xml index cd1d0dad..8c14119a 100644 --- a/facetracknoir/clientfiles/FlightGear/Protocol/headtracker.xml +++ b/facetracknoir/clientfiles/FlightGear/Protocol/headtracker.xml @@ -11,57 +11,44 @@ x double - /sim/headtracker/x-m + /sim/current-view/x-offset-m y double - /sim/headtracker/y-m + /sim/current-view/y-offset-m z double - /sim/headtracker/z-m + /sim/current-view/z-offset-m heading double - /sim/headtracker/heading-deg + /sim/current-view/heading-offset-deg pitch double - /sim/headtracker/pitch-deg + /sim/current-view/pitch-offset-deg roll double - /sim/headtracker/roll-deg + /sim/current-view/roll-offset-deg status int - /sim/headtracker/status + /sim/current-view/headtracker-debug-status - - - true - none - host - 4 - - - control - int - /sim/headtracker/control - - diff --git a/ftnoir_protocol_fg/fgtypes.h b/ftnoir_protocol_fg/fgtypes.h index 049de318..0f29be3d 100644 --- a/ftnoir_protocol_fg/fgtypes.h +++ b/ftnoir_protocol_fg/fgtypes.h @@ -17,7 +17,7 @@ // // x,y,z position in metres, heading, pitch and roll in degrees... // -#pragma pack(push, 1) +#pragma pack(push, 2) struct TFlightGearData { double x, y, z, h, p, r; int status; diff --git a/ftnoir_protocol_fg/ftnoir_protocol_fg.cpp b/ftnoir_protocol_fg/ftnoir_protocol_fg.cpp index 643f9dd5..5aa3487e 100644 --- a/ftnoir_protocol_fg/ftnoir_protocol_fg.cpp +++ b/ftnoir_protocol_fg/ftnoir_protocol_fg.cpp @@ -31,33 +31,16 @@ #include // For Todd and Arda Kutlu -//#define SEND_ASCII_DATA -//#define LOG_OUTPUT -/** constructor **/ FTNoIR_Protocol::FTNoIR_Protocol() { - blnConnectionActive = false; - loadSettings(); + loadSettings(); } -/** destructor **/ FTNoIR_Protocol::~FTNoIR_Protocol() { - if (inSocket != 0) { - inSocket->close(); - delete inSocket; - } - - if (outSocket != 0) { - outSocket->close(); - delete outSocket; - } } -// -// Load the current Settings from the currently 'active' INI-file. -// void FTNoIR_Protocol::loadSettings() { QSettings settings("opentrack"); // Registry settings (in HK_USER) @@ -68,7 +51,7 @@ void FTNoIR_Protocol::loadSettings() { bool blnLocalPC = iniFile.value ( "LocalPCOnly", 1 ).toBool(); if (blnLocalPC) { - destIP = QHostAddress::LocalHost; + destIP = QHostAddress::LocalHost; } else { QString destAddr = iniFile.value ( "IP-1", 192 ).toString() + "." + iniFile.value ( "IP-2", 168 ).toString() + "." + iniFile.value ( "IP-3", 2 ).toString() + "." + iniFile.value ( "IP-4", 1 ).toString(); @@ -80,87 +63,19 @@ void FTNoIR_Protocol::loadSettings() { } -// -// Update Headpose in Game. -// void FTNoIR_Protocol::sendHeadposeToGame( double *headpose, double *rawheadpose ) { -int no_bytes; -QHostAddress sender; -quint16 senderPort; + int no_bytes; + QHostAddress sender; + quint16 senderPort; - // - // Copy the Raw measurements directly to the client. - // FlightData.x = headpose[TX] * 1e-2; FlightData.y = headpose[TY] * 1e-2; FlightData.z = headpose[TZ] * 1e-2; FlightData.p = headpose[Pitch]; FlightData.h = headpose[Yaw]; FlightData.r = headpose[Roll]; - FlightData.status = fg_cmd; - - // - // Try to send an UDP-message to the FlightGear - // - -#ifdef SEND_ASCII_DATA - sprintf_s(data, "%.2f %.2f %.2f %.2f %.2f %.2f\n\0", FlightData.x, FlightData.y, FlightData.z, FlightData.p, FlightData.h, FlightData.r); - - if (outSocket != 0) { - no_bytes = outSocket->writeDatagram((const char *) &data, strlen( data ), destIP, destPort); - if ( no_bytes > 0) { - qDebug() << "FGServer::writePendingDatagrams says: bytes send =" << data; - } - else { - qDebug() << "FGServer::writePendingDatagrams says: nothing sent!"; - } - } - -#endif - - #ifdef LOG_OUTPUT - // Use this for some debug-output to file... - QFile datafile(QCoreApplication::applicationDirPath() + "\\FG_output.txt"); - if (datafile.open(QFile::WriteOnly | QFile::Append)) { - QTextStream out(&datafile); - out << "output:\t" << FlightData.x << "\t" << FlightData.y << "\t" << FlightData.z << "\t" << FlightData.p << "\t" << FlightData.h << "\t" << FlightData.r << '\n'; - } - #endif - - #ifndef SEND_ASCII_DATA - //! [1] - if (outSocket != 0) { - no_bytes = outSocket->writeDatagram((const char *) &FlightData, sizeof( FlightData ), destIP, destPort); - if ( no_bytes > 0) { - } - else { - qDebug() << "FGServer::writePendingDatagrams says: nothing sent!"; - } - } - #endif - - // - // FlightGear keeps sending data, so we must read that here. - // - if (inSocket != 0) { - while (inSocket->hasPendingDatagrams()) { - - QByteArray datagram; - datagram.resize(inSocket->pendingDatagramSize()); - - inSocket->readDatagram( (char * ) &cmd, sizeof(cmd), &sender, &senderPort); - - fg_cmd = cmd; // Let's just accept that command for now... - if ( cmd > 0 ) { - qDebug() << "FGServer::sendHeadposeToGame hasPendingDatagrams, cmd = " << cmd; -// headTracker->handleGameCommand ( cmd ); // Send it upstream, for the Tracker to handle - } - - if (!blnConnectionActive) { - blnConnectionActive = true; - } - } - } + FlightData.status = 1; + (void) outSocket.writeDatagram(reinterpret_cast(&FlightData), sizeof(FlightData), destIP, static_cast(destPort)); } // @@ -169,51 +84,9 @@ quint16 senderPort; // bool FTNoIR_Protocol::checkServerInstallationOK() { - // Init. the data - FlightData.x = 0.0f; - FlightData.y = 0.0f; - FlightData.z = 0.0f; - FlightData.h = 0.0f; - FlightData.p = 0.0f; - FlightData.r = 0.0f; - FlightData.status = 0; - fg_cmd = 1; - - inSocket = 0; - outSocket = 0; - - // - // Create UDP-sockets. - // - if (inSocket == 0) { - qDebug() << "FGServer::sendHeadposeToGame creating insocket"; - inSocket = new QUdpSocket(); - - // Connect the inSocket to the port, to receive messages - if (!inSocket->bind(QHostAddress::Any, destPort+1)) { - QMessageBox::warning(0,"FaceTrackNoIR Error", "Unable to bind UDP-port",QMessageBox::Ok,QMessageBox::NoButton); - delete inSocket; - inSocket = 0; - return false; - } - } - - if (outSocket == 0) { - outSocket = new QUdpSocket(); - } - - return true; + return outSocket.bind(QHostAddress::Any, 0, QUdpSocket::ShareAddress | QUdpSocket::ReuseAddressHint); } -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Protocol object. - -// Export both decorated and undecorated names. -// GetProtocol - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetProtocol@0 - Common name decoration for __stdcall functions in C language. -//#pragma comment(linker, "/export:GetProtocol=_GetProtocol@0") - extern "C" FTNOIR_PROTOCOL_BASE_EXPORT IProtocol* CALLING_CONVENTION GetConstructor() { return new FTNoIR_Protocol; diff --git a/ftnoir_protocol_fg/ftnoir_protocol_fg.h b/ftnoir_protocol_fg/ftnoir_protocol_fg.h index 40a83384..f399904b 100644 --- a/ftnoir_protocol_fg/ftnoir_protocol_fg.h +++ b/ftnoir_protocol_fg/ftnoir_protocol_fg.h @@ -36,7 +36,6 @@ #include #include #include -#include #include "facetracknoir/global-settings.h" #define FT_PROGRAMID "FT_ProgramID" @@ -52,15 +51,8 @@ public: return "FlightGear"; } private: - - bool blnConnectionActive; - - // Tracker *headTracker; // For upstream messages... - TFlightGearData FlightData; - QUdpSocket *inSocket; // Receive from FligthGear - QUdpSocket *outSocket; // Send to FligthGear - qint32 cmd; - qint32 fg_cmd; // Command from FlightGear + TFlightGearData FlightData; + QUdpSocket outSocket; // Send to FligthGear QHostAddress destIP; // Destination IP-address int destPort; // Destination port-number void loadSettings(); -- cgit v1.2.3 From 41014a32a3597784f29e9718cb5e665511549e1c Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 8 Oct 2013 21:41:45 +0200 Subject: update readme and other cruft Signed-off-by: Stanislaw Halik --- .../clientfiles/FlightGear/Linux/usage.txt | 8 ------- facetracknoir/clientfiles/FlightGear/readme.txt | 27 +++++++--------------- .../clientfiles/FlightGear/win32/start_fg.bat | 1 - 3 files changed, 8 insertions(+), 28 deletions(-) delete mode 100644 facetracknoir/clientfiles/FlightGear/Linux/usage.txt delete mode 100644 facetracknoir/clientfiles/FlightGear/win32/start_fg.bat (limited to 'facetracknoir') diff --git a/facetracknoir/clientfiles/FlightGear/Linux/usage.txt b/facetracknoir/clientfiles/FlightGear/Linux/usage.txt deleted file mode 100644 index 48cee837..00000000 --- a/facetracknoir/clientfiles/FlightGear/Linux/usage.txt +++ /dev/null @@ -1,8 +0,0 @@ -Copy Protocol/headtracker.xml to fgdata/Protocol/headtracker.xml - -$ fgfs --generic=socket,in,25,localhost,5542,udp,headtracker - -Adjust paths as necessary. - -cheers, --sh 20131008 diff --git a/facetracknoir/clientfiles/FlightGear/readme.txt b/facetracknoir/clientfiles/FlightGear/readme.txt index 75cbbcd2..0b3d9dfe 100644 --- a/facetracknoir/clientfiles/FlightGear/readme.txt +++ b/facetracknoir/clientfiles/FlightGear/readme.txt @@ -1,19 +1,8 @@ -FaceTrackNoIR for FlightGear. - -FaceTrackNoIR was made compatible with FlightGear with the help of Melchior Franz, who initially made a Linux headtracker. FaceTrackNoIR sends UDP-packets to FlightGear which contain 6DOF-data. The script and protocol provided by Melchior take care of receiving the data and moving 'the head' in-game. - -To make the FlightGear script work, copy the files in the subfolders to the corresponding folders in the FlightGear installation folder. Start FlightGear with the batch-file 'start_fg.bat'. - - -Please let us know if you like the program, if you have ideas for improvements or any questions you might have. - - - -The FaceTrackNoIR team: - -Wim Vriend -Ron Hendriks - - - -Disclaimer: For usage of 3rd party software like FlightGear, the FaceTrackNoIR team is not responsible. Use it at your own risk. \ No newline at end of file +Copy Protocol/headtracker.xml to fgdata/Protocol/headtracker.xml + +$ fgfs --generic=socket,in,25,localhost,5542,udp,headtracker + +Adjust paths as necessary. + +cheers, +-sh 20131008 diff --git a/facetracknoir/clientfiles/FlightGear/win32/start_fg.bat b/facetracknoir/clientfiles/FlightGear/win32/start_fg.bat deleted file mode 100644 index cd9829b5..00000000 --- a/facetracknoir/clientfiles/FlightGear/win32/start_fg.bat +++ /dev/null @@ -1 +0,0 @@ -fgfs --generic=socket,in,25,localhost,5550,udp,headtracker --generic=socket,out,10,localhost,5551,udp,headtracker --prop:browser=/sim/headtracker "c:\Program Files\FlightGear\data\Nasal\headtracker.xml" \ No newline at end of file -- cgit v1.2.3 From cdd9a365e08e6fdd0d44199c39d990a46df563e0 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 9 Oct 2013 00:08:27 +0200 Subject: fix: Reset the view zero pos on start Signed-off-by: Stanislaw Halik --- facetracknoir/curve-config.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'facetracknoir') diff --git a/facetracknoir/curve-config.cpp b/facetracknoir/curve-config.cpp index 1bb40078..36caa5c0 100644 --- a/facetracknoir/curve-config.cpp +++ b/facetracknoir/curve-config.cpp @@ -161,6 +161,15 @@ void CurveConfigurationDialog::loadSettings() { ui.tz_altp }; + QDoubleSpinBox* widgets3[] = { + ui.pos_tx, + ui.pos_ty, + ui.pos_tz, + ui.pos_tx, + ui.pos_ry, + ui.pos_rz + }; + for (int i = 0; i < 6; i++) { configs[i]->setConfig(&mainApp->axis(i).curve, currentFile); @@ -170,6 +179,7 @@ void CurveConfigurationDialog::loadSettings() { connect(configs[i], SIGNAL(CurveChanged(bool)), this, SLOT(curveChanged(bool)), Qt::UniqueConnection); connect(alt_configs[i], SIGNAL(CurveChanged(bool)), this, SLOT(curveChanged(bool)), Qt::UniqueConnection); connect(checkboxes[i], SIGNAL(stateChanged(int)), this, SLOT(curveChanged(int)), Qt::UniqueConnection); + mainApp->axis(i).zero = widgets3[i]->value(); } settingsDirty = false; -- cgit v1.2.3 From 1118434acb347988658370112c0e2e10aba6eec4 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 9 Oct 2013 18:09:51 +0200 Subject: fix widget positioning Signed-off-by: Stanislaw Halik --- facetracknoir/facetracknoir.ui | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.ui b/facetracknoir/facetracknoir.ui index 851fb6a2..5c573a0b 100644 --- a/facetracknoir/facetracknoir.ui +++ b/facetracknoir/facetracknoir.ui @@ -484,6 +484,9 @@ background:none; Axis inversion + + Qt::AlignCenter + @@ -797,6 +800,9 @@ background:none; Profile + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + @@ -924,6 +930,9 @@ background:none; Game protocol + + Qt::AlignCenter + @@ -991,7 +1000,10 @@ background:none; - Tracker Source(1st = Master) + Tracker Source + + + Qt::AlignCenter @@ -1062,6 +1074,9 @@ background:none; Filter + + Qt::AlignCenter + @@ -1126,7 +1141,10 @@ background:none; - Tracker Source (2nd) + Tracker Source #2 + + + Qt::AlignCenter @@ -1194,6 +1212,9 @@ background:none; GO! + + Qt::AlignCenter + -- cgit v1.2.3 From 51b0e2bf53eb74b3041a98908ba32aaeaf4ed253 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 9 Oct 2013 18:12:02 +0200 Subject: use native background color in spline dialog Signed-off-by: Stanislaw Halik --- facetracknoir/ftnoir_curves.ui | 54 ++++--------------------- qfunctionconfigurator/qfunctionconfigurator.cpp | 14 ++----- qfunctionconfigurator/qfunctionconfigurator.h | 12 ------ 3 files changed, 10 insertions(+), 70 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/ftnoir_curves.ui b/facetracknoir/ftnoir_curves.ui index bbdce4e2..83b514b5 100644 --- a/facetracknoir/ftnoir_curves.ui +++ b/facetracknoir/ftnoir_curves.ui @@ -6,8 +6,8 @@ 0 0 - 1050 - 667 + 1042 + 659 @@ -24,49 +24,9 @@ false - background-color: rgb(240, 240, 240); -/* -QWidget#widgetTop { -background-color: #595959; -border-bottom: 1px solid #000; -} -*/ + -/* Make text in message boxes selectable. */ -QMessageBox { -/* LinksAccessibleByMouse | TextSelectableByMouse */ -messagebox-text-interaction-flags: 5; -} -/* Make the entire row selected in item views. */ -QAbstractItemView { -show-decoration-selected: 1; -} - -/* Nice WindowsXP-style password character for password line edits. */ -QLineEdit[echoMode="2"] { -lineedit-password-character: 9679; -} - -/* Customize tooltips. */ -QToolTip { -background-color: rgb(170, 255, 127); -opacity: 200; -} - -/* Customize push buttons and comboboxes. Our read-only combobox -is very similar to a push button, so they share the same border image. */ - -QPushButton { -min-width: 4em; -} - -QPushButton:disabled { -color: rgb(128, 128, 128); -} - -QGroupBox { -color: rgb(255, 255, 255); -} + @@ -156,9 +116,9 @@ color: rgb(255, 255, 255); - 240 - 240 - 240 + 255 + 255 + 255 diff --git a/qfunctionconfigurator/qfunctionconfigurator.cpp b/qfunctionconfigurator/qfunctionconfigurator.cpp index 0bd9aad0..802c0a1d 100644 --- a/qfunctionconfigurator/qfunctionconfigurator.cpp +++ b/qfunctionconfigurator/qfunctionconfigurator.cpp @@ -140,15 +140,14 @@ void QFunctionConfigurator::drawBackground(const QRectF &fullRect) QRect scale; _background = QPixmap(fullRect.width(), fullRect.height()); + QColor bgColor = palette().color(QPalette::Normal, QPalette::Background); QPainter painter(&_background); - - painter.save(); + painter.fillRect(fullRect, bgColor); painter.setRenderHint(QPainter::Antialiasing); - painter.fillRect(fullRect, colBackground); QColor bg_color(112, 154, 209); painter.fillRect(range, bg_color); - QFont font("ComicSans", 4); + QFont font; font.setPointSize(8); painter.setFont(font); @@ -200,8 +199,6 @@ void QFunctionConfigurator::drawBackground(const QRectF &fullRect) pen.setColor( Qt::black ); drawLine(&painter, range.topLeft() - QPointF(2,0), range.bottomLeft() - QPointF(2,0), pen); drawLine(&painter, range.bottomLeft(), range.bottomRight(), pen); - - painter.restore(); } @@ -628,11 +625,6 @@ void QFunctionConfigurator::setColorBezier(QColor color) colBezier = color; update(); } -void QFunctionConfigurator::setColorBackground(QColor color) -{ - colBackground = color; - update(); -} void QFunctionConfigurator::setInputEGU(QString egu) { diff --git a/qfunctionconfigurator/qfunctionconfigurator.h b/qfunctionconfigurator/qfunctionconfigurator.h index 6669f92e..07eeeae3 100644 --- a/qfunctionconfigurator/qfunctionconfigurator.h +++ b/qfunctionconfigurator/qfunctionconfigurator.h @@ -63,7 +63,6 @@ class FTNOIR_TRACKER_BASE_EXPORT QFunctionConfigurator : public QWidget Q_PROPERTY(int gridDistEGU_Output READ gridDistEGU_Output WRITE setgridDistEGU_Output) Q_PROPERTY(QColor colorBezier READ colorBezier WRITE setColorBezier) - Q_PROPERTY(QColor colorBackground READ colorBackground WRITE setColorBackground) Q_PROPERTY(QString stringInputEGU READ stringInputEGU WRITE setInputEGU) Q_PROPERTY(QString stringOutputEGU READ stringOutputEGU WRITE setOutputEGU) Q_PROPERTY(QString stringCaption READ stringCaption WRITE setCaption) @@ -94,27 +93,18 @@ class FTNOIR_TRACKER_BASE_EXPORT QFunctionConfigurator : public QWidget return gDistEGU_Output; } - // Return the current color to Designer QColor colorBezier() const { return colBezier; } - // Return the current color to Designer - QColor colorBackground() const - { - return colBackground; - } - // Return the current string to Designer QString stringInputEGU() const { return strInputEGU; } - // Return the current string to Designer QString stringOutputEGU() const { return strOutputEGU; } - // Return the current string to Designer QString stringCaption() const { return strCaption; @@ -140,7 +130,6 @@ public slots: void setgridDistEGU_Output(int); void setColorBezier(QColor); - void setColorBackground(QColor); void setInputEGU(QString); void setOutputEGU(QString); void setCaption(QString); @@ -179,7 +168,6 @@ private: int gDistEGU_Output; // Distance of the grid, in EGU of Output QColor colBezier; // Color of Bezier curve - QColor colBackground; // Color of widget background QString strInputEGU; // Engineering Units input (vertical axis) QString strOutputEGU; // Engineering Units output (horizontal axis) QString strCaption; // Caption of the graph -- cgit v1.2.3 From c5512a6b685924f8ef71a776ae4cb441a6d77055 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 9 Oct 2013 18:13:11 +0200 Subject: tag 2.0a3 --- facetracknoir/facetracknoir.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index aa92987c..2ccb2bb7 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -414,7 +414,7 @@ void FaceTrackNoIR::loadSettings() { // Put the filename in the window-title. // QFileInfo pathInfo ( currentFile ); - setWindowTitle ( "opentrack 2.0a2 - " + pathInfo.fileName() ); + setWindowTitle ( "opentrack 2.0a3 - " + pathInfo.fileName() ); // // Get a List of all the INI-files in the (currently active) Settings-folder. -- cgit v1.2.3 From c5051c176421282c8f5c3cd937711fbf01c59be8 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 12 Oct 2013 16:13:34 +0200 Subject: add Crapple macam latest cvs snapshot Works with 32-bit apps, provided that quicktime is supported Signed-off-by: Stanislaw Halik --- .../clientfiles/macosx/macam-cvs-build-2009-09-25.zip | Bin 0 -> 3560122 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 facetracknoir/clientfiles/macosx/macam-cvs-build-2009-09-25.zip (limited to 'facetracknoir') diff --git a/facetracknoir/clientfiles/macosx/macam-cvs-build-2009-09-25.zip b/facetracknoir/clientfiles/macosx/macam-cvs-build-2009-09-25.zip new file mode 100644 index 00000000..79816779 Binary files /dev/null and b/facetracknoir/clientfiles/macosx/macam-cvs-build-2009-09-25.zip differ -- cgit v1.2.3 From 864910a1fb753629d2852a91ffae4ebba374358c Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 15 Oct 2013 08:52:25 +0200 Subject: fix trackers for qt5 Assorted changes: - make filenames unique, since automoc made a boo-boo - adjust include paths, "QtGui" -> "" - use std::shared_ptr in c++11 mode (thanks Patrick!) - make class names unique, automoc sucks, but saves typing - add a dummy class in one file since moronic automoc thinks every target contains Q_OBJECTS!!! --- FTNoIR_Tracker_PT/boost-compat.h | 3 +- FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp | 6 +- FTNoIR_Tracker_PT/ftnoir_tracker_pt.h | 9 +- FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.h | 2 +- FTNoIR_Tracker_PT/pt_video_widget.cpp | 52 ++++++++ FTNoIR_Tracker_PT/pt_video_widget.h | 64 ++++++++++ FTNoIR_Tracker_PT/video_widget.cpp | 145 ----------------------- FTNoIR_Tracker_PT/video_widget.h | 95 --------------- compat/qt-bug-appeasement.cpp | 1 + facetracknoir/qt-moc.h | 10 ++ ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp | 1 + ftnoir_tracker_aruco/ar_video_widget.cpp | 30 +++++ ftnoir_tracker_aruco/ar_video_widget.h | 39 ++++++ ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 2 +- ftnoir_tracker_aruco/ftnoir_tracker_aruco.h | 5 +- ftnoir_tracker_aruco/video_widget.cpp | 30 ----- ftnoir_tracker_aruco/video_widget.h | 39 ------ ftnoir_tracker_ht/ftnoir_tracker_ht.cpp | 2 +- ftnoir_tracker_ht/ftnoir_tracker_ht.h | 4 +- ftnoir_tracker_ht/ht_video_widget.cpp | 30 +++++ ftnoir_tracker_ht/ht_video_widget.h | 39 ++++++ ftnoir_tracker_ht/video_widget.cpp | 30 ----- ftnoir_tracker_ht/video_widget.h | 39 ------ 23 files changed, 280 insertions(+), 397 deletions(-) create mode 100644 FTNoIR_Tracker_PT/pt_video_widget.cpp create mode 100644 FTNoIR_Tracker_PT/pt_video_widget.h delete mode 100644 FTNoIR_Tracker_PT/video_widget.cpp delete mode 100644 FTNoIR_Tracker_PT/video_widget.h create mode 100644 compat/qt-bug-appeasement.cpp create mode 100644 facetracknoir/qt-moc.h create mode 100644 ftnoir_tracker_aruco/ar_video_widget.cpp create mode 100644 ftnoir_tracker_aruco/ar_video_widget.h delete mode 100644 ftnoir_tracker_aruco/video_widget.cpp delete mode 100644 ftnoir_tracker_aruco/video_widget.h create mode 100644 ftnoir_tracker_ht/ht_video_widget.cpp create mode 100644 ftnoir_tracker_ht/ht_video_widget.h delete mode 100644 ftnoir_tracker_ht/video_widget.cpp delete mode 100644 ftnoir_tracker_ht/video_widget.h (limited to 'facetracknoir') diff --git a/FTNoIR_Tracker_PT/boost-compat.h b/FTNoIR_Tracker_PT/boost-compat.h index aea5e1a2..b5be237a 100644 --- a/FTNoIR_Tracker_PT/boost-compat.h +++ b/FTNoIR_Tracker_PT/boost-compat.h @@ -1,6 +1,5 @@ #pragma once #include -#define shared_ptr auto_ptr namespace boost { - using std::auto_ptr; + using std::shared_ptr; }; diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp index d4741101..745d98e9 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp @@ -12,10 +12,6 @@ #include #include -#ifdef OPENTRACK_API -# define VideoWidget VideoWidget2 -#endif - using namespace std; using namespace cv; using namespace boost; @@ -192,7 +188,7 @@ void Tracker::update_show_video_widget() { const int VIDEO_FRAME_WIDTH = 252; const int VIDEO_FRAME_HEIGHT = 189; - video_widget = new VideoWidget(video_frame, this); + video_widget = new PTVideoWidget(video_frame, this); QHBoxLayout* video_layout = new QHBoxLayout(); video_layout->setContentsMargins(0, 0, 0, 0); video_layout->addWidget(video_widget); diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h index 7dcfc8bb..2430f5f0 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h @@ -11,15 +11,13 @@ #ifdef OPENTRACK_API # include "ftnoir_tracker_base/ftnoir_tracker_base.h" # include "facetracknoir/global-settings.h" -#else -# include "..\ftnoir_tracker_base\ftnoir_tracker_base.h" #endif #include "ftnoir_tracker_pt_settings.h" #include "frame_observer.h" #include "camera.h" #include "point_extractor.h" #include "point_tracker.h" -#include "video_widget.h" +#include "pt_video_widget.h" #include "timer.h" #include @@ -82,7 +80,6 @@ protected: // --- tracking chain --- #ifdef OPENTRACK_API -#define VideoWidget VideoWidget2 CVCamera camera; #else VICamera camera; @@ -101,7 +98,9 @@ protected: void update_show_video_widget(); bool show_video_widget; - VideoWidget* video_widget; +#ifdef OPENTRACK_API + PTVideoWidget* video_widget; +#endif QFrame* video_frame; // --- misc --- diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.h b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.h index 14df7ede..3e1af50a 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.h +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.h @@ -16,7 +16,7 @@ #include "ftnoir_tracker_pt_settings.h" #include "ftnoir_tracker_pt.h" #include "trans_calib.h" -#include "video_widget.h" +#include "pt_video_widget.h" #include "ui_FTNoIR_PT_Controls.h" #include diff --git a/FTNoIR_Tracker_PT/pt_video_widget.cpp b/FTNoIR_Tracker_PT/pt_video_widget.cpp new file mode 100644 index 00000000..03c42fc7 --- /dev/null +++ b/FTNoIR_Tracker_PT/pt_video_widget.cpp @@ -0,0 +1,52 @@ +/* Copyright (c) 2012 Patrick Ruoff + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * 20130312, WVR: Add 7 lines to resizeGL after resize_frame. This should lower CPU-load. + */ + +#include "pt_video_widget.h" + +#include +#include + +using namespace cv; +using namespace std; + +void PTVideoWidget::update_image(const cv::Mat& frame) +{ + QMutexLocker foo(&mtx); + QImage qframe = QImage(frame.cols, frame.rows, QImage::Format_RGB888); + uchar* data = qframe.bits(); + const int pitch = qframe.bytesPerLine(); + for (int y = 0; y < frame.rows; y++) + for (int x = 0; x < frame.cols; x++) + { + const int pos = 3 * (y*frame.cols + x); + data[y * pitch + x * 3 + 0] = frame.data[pos + 2]; + data[y * pitch + x * 3 + 1] = frame.data[pos + 1]; + data[y * pitch + x * 3 + 2] = frame.data[pos + 0]; + } + qframe = qframe.scaled(size(), Qt::IgnoreAspectRatio, Qt::FastTransformation); + pixmap = QPixmap::fromImage(qframe); +} + +// ---------------------------------------------------------------------------- +VideoWidgetDialog::VideoWidgetDialog(QWidget *parent, FrameProvider* provider) + : QDialog(parent), + video_widget(NULL) +{ + const int VIDEO_FRAME_WIDTH = 640; + const int VIDEO_FRAME_HEIGHT = 480; + + video_widget = new PTVideoWidget(this, provider); + + QHBoxLayout* layout = new QHBoxLayout(); + layout->setContentsMargins(0, 0, 0, 0); + layout->addWidget(video_widget); + if (this->layout()) delete this->layout(); + setLayout(layout); + resize(VIDEO_FRAME_WIDTH, VIDEO_FRAME_HEIGHT); +} diff --git a/FTNoIR_Tracker_PT/pt_video_widget.h b/FTNoIR_Tracker_PT/pt_video_widget.h new file mode 100644 index 00000000..e67e6d57 --- /dev/null +++ b/FTNoIR_Tracker_PT/pt_video_widget.h @@ -0,0 +1,64 @@ +/* Copyright (c) 2012 Patrick Ruoff + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + */ + +#pragma once + +#include "frame_observer.h" +#include +#include +#include +#include +#ifndef OPENTRACK_API +# include +# include +#else +# include "FTNoIR_Tracker_PT/boost-compat.h" +# if defined(_WIN32) +# include +# endif +#endif +#include +#include +#include + +class PTVideoWidget : public QWidget, public FrameObserver +{ + Q_OBJECT + +public: + PTVideoWidget(QWidget *parent, FrameProvider* provider) : QWidget(parent), /* to avoid linker errors */ FrameObserver(provider) { + connect(&timer, SIGNAL(timeout()), this, SLOT(update())); + timer.start(45); + } + void update_image(const cv::Mat &frame); + void update_frame_and_points() {} +protected slots: + void paintEvent( QPaintEvent* e ) { + QMutexLocker foo(&mtx); + QPainter painter(this); + painter.drawPixmap(e->rect(), pixmap, e->rect()); + } +private: + QMutex mtx; + QPixmap pixmap; + QTimer timer; +}; + +// ---------------------------------------------------------------------------- +// A VideoWidget embedded in a dialog frame +class VideoWidgetDialog : public QDialog +{ + Q_OBJECT +public: + VideoWidgetDialog(QWidget *parent, FrameProvider* provider); + virtual ~VideoWidgetDialog() {} + + PTVideoWidget* get_video_widget() { return video_widget; } + +private: + PTVideoWidget* video_widget; +}; diff --git a/FTNoIR_Tracker_PT/video_widget.cpp b/FTNoIR_Tracker_PT/video_widget.cpp deleted file mode 100644 index 0d31620f..00000000 --- a/FTNoIR_Tracker_PT/video_widget.cpp +++ /dev/null @@ -1,145 +0,0 @@ -/* Copyright (c) 2012 Patrick Ruoff - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * 20130312, WVR: Add 7 lines to resizeGL after resize_frame. This should lower CPU-load. - */ - -#include "video_widget.h" - -#include -#include - -using namespace cv; -using namespace std; -#ifndef OPENTRACK_API -using namespace boost; -#endif -#ifndef OPENTRACK_API -// ---------------------------------------------------------------------------- -void VideoWidget::initializeGL() -{ - glClearColor(0.0, 0.0, 0.0, 0.0); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); -} - -void VideoWidget::resizeGL(int w, int h) -{ - // setup 1 to 1 projection - glViewport(0, 0, w, h); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glOrtho(0, w, 0, h, -1, 1); - resize_frame(); - glDisable(GL_DEPTH_TEST); - glBegin(GL_QUADS); - glVertex2f(0,0); - glVertex2f(1,0); - glVertex2f(1,1); - glVertex2f(0,1); - glEnd(); -} - -void VideoWidget::paintGL() -{ - glClear(GL_COLOR_BUFFER_BIT); - if (!resized_qframe.isNull()) - { - glDrawPixels(resized_qframe.width(), resized_qframe.height(), GL_RGBA, GL_UNSIGNED_BYTE, resized_qframe.bits()); - - const int crosshair_radius = 10; - const int crosshair_thickness = 1; - - if (points) - { - glColor3f(1.0, 0.0, 0.0); - glLineWidth(crosshair_thickness); - int x,y; - for (vector::iterator iter = points->begin(); - iter != points->end(); - ++iter) - { - x = (*iter)[0] * resized_qframe.width() + resized_qframe.width()/2.0 + 0.5; - y = (*iter)[1] * resized_qframe.width() + resized_qframe.height()/2.0 + 0.5; - - glBegin(GL_LINES); - glVertex2i(x-crosshair_radius, y); - glVertex2i(x+crosshair_radius, y); - glEnd(); - glBegin(GL_LINES); - glVertex2i(x, y-crosshair_radius); - glVertex2i(x, y+crosshair_radius); - glEnd(); - } - } - } - glFlush(); -} - - -void VideoWidget::resize_frame() -{ - if (!qframe.isNull()) - resized_qframe = qframe.scaled(this->size(), Qt::KeepAspectRatio); -} - - -void VideoWidget::update_frame_and_points() -{ - if (!get_frame_and_points(frame, points)) return; - - // convert to QImage - if (frame.channels() == 3) - qframe = QImage((const unsigned char*)(frame.data), frame.cols, frame.rows, frame.step, QImage::Format_RGB888).rgbSwapped(); - else if (frame.channels() == 1) - qframe = QImage((const unsigned char*)(frame.data), frame.cols, frame.rows, frame.step, QImage::Format_Indexed8); - qframe = QGLWidget::convertToGLFormat(qframe); - - resize_frame(); - updateGL(); -} - -#else -void VideoWidget2::update_image(const cv::Mat& frame) -{ - QMutexLocker foo(&mtx); - QImage qframe = QImage(frame.cols, frame.rows, QImage::Format_RGB888); - uchar* data = qframe.bits(); - const int pitch = qframe.bytesPerLine(); - for (int y = 0; y < frame.rows; y++) - for (int x = 0; x < frame.cols; x++) - { - const int pos = 3 * (y*frame.cols + x); - data[y * pitch + x * 3 + 0] = frame.data[pos + 2]; - data[y * pitch + x * 3 + 1] = frame.data[pos + 1]; - data[y * pitch + x * 3 + 2] = frame.data[pos + 0]; - } - qframe = qframe.scaled(size(), Qt::IgnoreAspectRatio, Qt::FastTransformation); - pixmap = QPixmap::fromImage(qframe); -} -#endif - -// ---------------------------------------------------------------------------- -VideoWidgetDialog::VideoWidgetDialog(QWidget *parent, FrameProvider* provider) - : QDialog(parent), - video_widget(NULL) -{ - const int VIDEO_FRAME_WIDTH = 640; - const int VIDEO_FRAME_HEIGHT = 480; - -#ifdef OPENTRACK_API - video_widget = new VideoWidget2(this, provider); -#else - video_widget = new VideoWidget(this, provider); -#endif - - QHBoxLayout* layout = new QHBoxLayout(); - layout->setContentsMargins(0, 0, 0, 0); - layout->addWidget(video_widget); - if (this->layout()) delete this->layout(); - setLayout(layout); - resize(VIDEO_FRAME_WIDTH, VIDEO_FRAME_HEIGHT); -} diff --git a/FTNoIR_Tracker_PT/video_widget.h b/FTNoIR_Tracker_PT/video_widget.h deleted file mode 100644 index 3164dacc..00000000 --- a/FTNoIR_Tracker_PT/video_widget.h +++ /dev/null @@ -1,95 +0,0 @@ -/* Copyright (c) 2012 Patrick Ruoff - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - */ - -#ifndef VIDEOWIDGET_H -#define VIDEOWIDGET_H - -#include "frame_observer.h" - -#include -#include -#include -#ifndef OPENTRACK_API -# include -# include -#else -# include "FTNoIR_Tracker_PT/boost-compat.h" -# if defined(_WIN32) -# include -# endif -#endif -#include -#include -#include - -#ifndef OPENTRACK_API -// ---------------------------------------------------------------------------- -// OpenGL based widget to display an OpenCV image with some points on top -class VideoWidget : public QGLWidget, public FrameObserver -{ - Q_OBJECT - -public: - VideoWidget(QWidget *parent, FrameProvider* provider) : QGLWidget(parent), FrameObserver(provider) {} - - virtual void initializeGL(); - virtual void resizeGL(int w, int h); - virtual void paintGL(); - - void update_frame_and_points(); - -private: - void resize_frame(); - - cv::Mat frame; - QImage qframe; - QImage resized_qframe; - - boost::shared_ptr< std::vector > points; -}; -#else -/* Qt moc likes to skip over preprocessor directives -sh */ -class VideoWidget2 : public QWidget, public FrameObserver -{ - Q_OBJECT - -public: - VideoWidget2(QWidget *parent, FrameProvider* provider) : QWidget(parent), /* to avoid linker errors */ FrameObserver(provider) { - connect(&timer, SIGNAL(timeout()), this, SLOT(update())); - timer.start(45); - } - void update_image(const cv::Mat &frame); - void update_frame_and_points() {} -protected slots: - void paintEvent( QPaintEvent* e ) { - QMutexLocker foo(&mtx); - QPainter painter(this); - painter.drawPixmap(e->rect(), pixmap, e->rect()); - } -private: - QMutex mtx; - QPixmap pixmap; - QTimer timer; -}; -#endif - -// ---------------------------------------------------------------------------- -// A VideoWidget embedded in a dialog frame -class VideoWidgetDialog : public QDialog -{ - Q_OBJECT -public: - VideoWidgetDialog(QWidget *parent, FrameProvider* provider); - virtual ~VideoWidgetDialog() {} - - VideoWidget2* get_video_widget() { return video_widget; } - -private: - VideoWidget2* video_widget; -}; - -#endif // VIDEOWIDGET_H diff --git a/compat/qt-bug-appeasement.cpp b/compat/qt-bug-appeasement.cpp new file mode 100644 index 00000000..9a86ac0a --- /dev/null +++ b/compat/qt-bug-appeasement.cpp @@ -0,0 +1 @@ +#include "facetracknoir/qt-moc.h" diff --git a/facetracknoir/qt-moc.h b/facetracknoir/qt-moc.h new file mode 100644 index 00000000..467370f9 --- /dev/null +++ b/facetracknoir/qt-moc.h @@ -0,0 +1,10 @@ +#include + +// this file exists only such that cmake qt automoc is appeased + +class AutomocMe { + Q_OBJECT +private: + virtual void foo() = 0; + AutomocMe() = delete; +}; diff --git a/ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp b/ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp index f479ce76..cefc9bf8 100644 --- a/ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp +++ b/ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp @@ -26,6 +26,7 @@ * It is based on the (Linux) example made by Melchior FRANZ. * ********************************************************************************/ #include "ftnoir_protocol_fg.h" +#include #include #include "facetracknoir/global-settings.h" diff --git a/ftnoir_tracker_aruco/ar_video_widget.cpp b/ftnoir_tracker_aruco/ar_video_widget.cpp new file mode 100644 index 00000000..6a4572a0 --- /dev/null +++ b/ftnoir_tracker_aruco/ar_video_widget.cpp @@ -0,0 +1,30 @@ +/* Copyright (c) 2012 Patrick Ruoff + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + */ + +#include "ar_video_widget.h" + +#include + +using namespace std; + +void ArucoVideoWidget::update_image(unsigned char *frame, int width, int height) +{ + QMutexLocker foo(&mtx); + QImage qframe = QImage(width, height, QImage::Format_RGB888); + uchar* data = qframe.bits(); + const int pitch = qframe.bytesPerLine(); + for (int y = 0; y < height; y++) + for (int x = 0; x < width; x++) + { + const int pos = 3 * (y*width + x); + data[y * pitch + x * 3 + 0] = frame[pos + 2]; + data[y * pitch + x * 3 + 1] = frame[pos + 1]; + data[y * pitch + x * 3 + 2] = frame[pos + 0]; + } + qframe = qframe.scaled(size(), Qt::IgnoreAspectRatio, Qt::FastTransformation); + pixmap = QPixmap::fromImage(qframe); +} diff --git a/ftnoir_tracker_aruco/ar_video_widget.h b/ftnoir_tracker_aruco/ar_video_widget.h new file mode 100644 index 00000000..dd0c16ac --- /dev/null +++ b/ftnoir_tracker_aruco/ar_video_widget.h @@ -0,0 +1,39 @@ +/* Copyright (c) 2012 Patrick Ruoff + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + */ + +#ifndef VIDEOWIDGET_H +#define VIDEOWIDGET_H + +#include +#include +#include +#include +#include +#include +#include + +// ---------------------------------------------------------------------------- +class ArucoVideoWidget : public QWidget +{ + Q_OBJECT + +public: + ArucoVideoWidget(QWidget *parent) : QWidget(parent), mtx() { + } + void update_image(unsigned char* frame, int width, int height); +protected slots: + void paintEvent( QPaintEvent* e ) { + QMutexLocker foo(&mtx); + QPainter painter(this); + painter.drawPixmap(e->rect(), pixmap, e->rect()); + } +private: + QMutex mtx; + QPixmap pixmap; +}; + +#endif // VIDEOWIDGET_H diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index 8025e956..c735b479 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -148,7 +148,7 @@ Tracker::~Tracker() void Tracker::StartTracker(QFrame* videoframe) { videoframe->show(); - videoWidget = new VideoWidget(videoframe); + videoWidget = new ArucoVideoWidget(videoframe); QHBoxLayout* layout = new QHBoxLayout(); layout->setContentsMargins(0, 0, 0, 0); layout->addWidget(videoWidget); diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h index 98aba2cf..ddbdd179 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h @@ -10,12 +10,13 @@ #include "ftnoir_tracker_base/ftnoir_tracker_base.h" #include "ui_aruco-trackercontrols.h" -#include "video_widget.h" +#include "ar_video_widget.h" #include #include #include #include #include +#include #include class Tracker : public QThread, public ITracker @@ -31,7 +32,7 @@ public: private: QMutex mtx; QTimer timer; - VideoWidget* videoWidget; + ArucoVideoWidget* videoWidget; QHBoxLayout* layout; volatile bool fresh, stop; float fov; diff --git a/ftnoir_tracker_aruco/video_widget.cpp b/ftnoir_tracker_aruco/video_widget.cpp deleted file mode 100644 index 84cba6a3..00000000 --- a/ftnoir_tracker_aruco/video_widget.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/* Copyright (c) 2012 Patrick Ruoff - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - */ - -#include "video_widget.h" - -#include - -using namespace std; - -void VideoWidget::update_image(unsigned char *frame, int width, int height) -{ - QMutexLocker foo(&mtx); - QImage qframe = QImage(width, height, QImage::Format_RGB888); - uchar* data = qframe.bits(); - const int pitch = qframe.bytesPerLine(); - for (int y = 0; y < height; y++) - for (int x = 0; x < width; x++) - { - const int pos = 3 * (y*width + x); - data[y * pitch + x * 3 + 0] = frame[pos + 2]; - data[y * pitch + x * 3 + 1] = frame[pos + 1]; - data[y * pitch + x * 3 + 2] = frame[pos + 0]; - } - qframe = qframe.scaled(size(), Qt::IgnoreAspectRatio, Qt::FastTransformation); - pixmap = QPixmap::fromImage(qframe); -} diff --git a/ftnoir_tracker_aruco/video_widget.h b/ftnoir_tracker_aruco/video_widget.h deleted file mode 100644 index 87b6278a..00000000 --- a/ftnoir_tracker_aruco/video_widget.h +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright (c) 2012 Patrick Ruoff - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - */ - -#ifndef VIDEOWIDGET_H -#define VIDEOWIDGET_H - -#include -#include -#include -#include -#include -#include -#include - -// ---------------------------------------------------------------------------- -class VideoWidget : public QWidget -{ - Q_OBJECT - -public: - VideoWidget(QWidget *parent) : QWidget(parent), mtx() { - } - void update_image(unsigned char* frame, int width, int height); -protected slots: - void paintEvent( QPaintEvent* e ) { - QMutexLocker foo(&mtx); - QPainter painter(this); - painter.drawPixmap(e->rect(), pixmap, e->rect()); - } -private: - QMutex mtx; - QPixmap pixmap; -}; - -#endif // VIDEOWIDGET_H diff --git a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp index 27817a0c..b4fd03f6 100644 --- a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp +++ b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp @@ -165,7 +165,7 @@ Tracker::~Tracker() void Tracker::StartTracker(QFrame* videoframe) { videoframe->show(); - videoWidget = new VideoWidget(videoframe); + videoWidget = new HTVideoWidget(videoframe); QHBoxLayout* layout = new QHBoxLayout(); layout->setContentsMargins(0, 0, 0, 0); layout->addWidget(videoWidget); diff --git a/ftnoir_tracker_ht/ftnoir_tracker_ht.h b/ftnoir_tracker_ht/ftnoir_tracker_ht.h index 5b8eb508..96607411 100644 --- a/ftnoir_tracker_ht/ftnoir_tracker_ht.h +++ b/ftnoir_tracker_ht/ftnoir_tracker_ht.h @@ -12,7 +12,7 @@ #include "ftnoir_tracker_base/ftnoir_tracker_base.h" #include "headtracker-ftnoir.h" #include "ui_ht-trackercontrols.h" -#include "video_widget.h" +#include "ht_video_widget.h" #include "compat/compat.h" #include #include @@ -31,7 +31,7 @@ private: QTimer timer; PortableLockedShm lck_shm; QProcess subprocess; - VideoWidget* videoWidget; + HTVideoWidget* videoWidget; QHBoxLayout* layout; volatile bool fresh; private slots: diff --git a/ftnoir_tracker_ht/ht_video_widget.cpp b/ftnoir_tracker_ht/ht_video_widget.cpp new file mode 100644 index 00000000..4d7d66a2 --- /dev/null +++ b/ftnoir_tracker_ht/ht_video_widget.cpp @@ -0,0 +1,30 @@ +/* Copyright (c) 2012 Patrick Ruoff + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + */ + +#include "ht_video_widget.h" + +#include + +using namespace std; + +void HTVideoWidget::update_image(unsigned char *frame, int width, int height) +{ + QMutexLocker foo(&mtx); + QImage qframe = QImage(width, height, QImage::Format_RGB888); + uchar* data = qframe.bits(); + const int pitch = qframe.bytesPerLine(); + for (int y = 0; y < height; y++) + for (int x = 0; x < width; x++) + { + const int pos = 3 * (y*width + x); + data[y * pitch + x * 3 + 0] = frame[pos + 2]; + data[y * pitch + x * 3 + 1] = frame[pos + 1]; + data[y * pitch + x * 3 + 2] = frame[pos + 0]; + } + qframe = qframe.scaled(size(), Qt::IgnoreAspectRatio, Qt::FastTransformation); + pixmap = QPixmap::fromImage(qframe); +} diff --git a/ftnoir_tracker_ht/ht_video_widget.h b/ftnoir_tracker_ht/ht_video_widget.h new file mode 100644 index 00000000..b1182d8b --- /dev/null +++ b/ftnoir_tracker_ht/ht_video_widget.h @@ -0,0 +1,39 @@ +/* Copyright (c) 2012 Patrick Ruoff + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + */ + +#ifndef VIDEOWIDGET_H +#define VIDEOWIDGET_H + +#include +#include +#include +#include +#include +#include +#include + +// ---------------------------------------------------------------------------- +class HTVideoWidget : public QWidget +{ + Q_OBJECT + +public: + HTVideoWidget(QWidget *parent) : QWidget(parent), mtx() { + } + void update_image(unsigned char* frame, int width, int height); +protected slots: + void paintEvent( QPaintEvent* e ) { + QMutexLocker foo(&mtx); + QPainter painter(this); + painter.drawPixmap(e->rect(), pixmap, e->rect()); + } +private: + QMutex mtx; + QPixmap pixmap; +}; + +#endif // VIDEOWIDGET_H diff --git a/ftnoir_tracker_ht/video_widget.cpp b/ftnoir_tracker_ht/video_widget.cpp deleted file mode 100644 index 84cba6a3..00000000 --- a/ftnoir_tracker_ht/video_widget.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/* Copyright (c) 2012 Patrick Ruoff - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - */ - -#include "video_widget.h" - -#include - -using namespace std; - -void VideoWidget::update_image(unsigned char *frame, int width, int height) -{ - QMutexLocker foo(&mtx); - QImage qframe = QImage(width, height, QImage::Format_RGB888); - uchar* data = qframe.bits(); - const int pitch = qframe.bytesPerLine(); - for (int y = 0; y < height; y++) - for (int x = 0; x < width; x++) - { - const int pos = 3 * (y*width + x); - data[y * pitch + x * 3 + 0] = frame[pos + 2]; - data[y * pitch + x * 3 + 1] = frame[pos + 1]; - data[y * pitch + x * 3 + 2] = frame[pos + 0]; - } - qframe = qframe.scaled(size(), Qt::IgnoreAspectRatio, Qt::FastTransformation); - pixmap = QPixmap::fromImage(qframe); -} diff --git a/ftnoir_tracker_ht/video_widget.h b/ftnoir_tracker_ht/video_widget.h deleted file mode 100644 index 87b6278a..00000000 --- a/ftnoir_tracker_ht/video_widget.h +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright (c) 2012 Patrick Ruoff - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - */ - -#ifndef VIDEOWIDGET_H -#define VIDEOWIDGET_H - -#include -#include -#include -#include -#include -#include -#include - -// ---------------------------------------------------------------------------- -class VideoWidget : public QWidget -{ - Q_OBJECT - -public: - VideoWidget(QWidget *parent) : QWidget(parent), mtx() { - } - void update_image(unsigned char* frame, int width, int height); -protected slots: - void paintEvent( QPaintEvent* e ) { - QMutexLocker foo(&mtx); - QPainter painter(this); - painter.drawPixmap(e->rect(), pixmap, e->rect()); - } -private: - QMutex mtx; - QPixmap pixmap; -}; - -#endif // VIDEOWIDGET_H -- cgit v1.2.3 From 685f782fd54fcedde2a94d7960e31fe4e4f8f6c5 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 15 Oct 2013 08:53:13 +0200 Subject: fix includes Signed-off-by: Stanislaw Halik --- facetracknoir/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'facetracknoir') diff --git a/facetracknoir/main.cpp b/facetracknoir/main.cpp index 9dc0749f..5a52c034 100644 --- a/facetracknoir/main.cpp +++ b/facetracknoir/main.cpp @@ -24,7 +24,7 @@ #include "facetracknoir.h" #include "tracker.h" -#include +#include #include #include #include -- cgit v1.2.3 From e384433c993ee062d6d4c1b1e0224dd870a6455f Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 15 Oct 2013 08:53:43 +0200 Subject: correct some obsolete stuff Signed-off-by: Stanislaw Halik --- facetracknoir/facetracknoir.cpp | 4 +-- facetracknoir/facetracknoir.h | 6 ++-- facetracknoir/facetracknoir.ui | 40 +++++++++++++++------------ ftnoir_protocol_base/ftnoir_protocol_base.h | 4 +-- ftnoir_tracker_base/ftnoir_tracker_base.h | 4 +-- qfunctionconfigurator/qfunctionconfigurator.h | 1 - 6 files changed, 32 insertions(+), 27 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index 2ccb2bb7..eb24b320 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -89,7 +89,7 @@ static void fill_combobox(const QString& filter, QList& list, Q // // Setup the Main Dialog // -FaceTrackNoIR::FaceTrackNoIR(QWidget *parent, Qt::WFlags flags) : +FaceTrackNoIR::FaceTrackNoIR(QWidget *parent, Qt::WindowFlags flags) : QMainWindow(parent, flags), #if defined(_WIN32) keybindingWorker(NULL), @@ -938,7 +938,7 @@ void FaceTrackNoIR::bindKeyboardShortcuts() seq = "Alt+" + seq; if (iniFile.value("Ctrl_Center", false).toBool()) seq = "Ctrl+" + seq; - keyCenter = new QxtGlobalShortcut(QKeySequence(seq)); + keyCenter = new QxtGlobalShortcut(QKeySequence(seq), this); connect(keyCenter, SIGNAL(activated()), this, SLOT(shortcutRecentered())); } } diff --git a/facetracknoir/facetracknoir.h b/facetracknoir/facetracknoir.h index b9c7168b..6c087c43 100644 --- a/facetracknoir/facetracknoir.h +++ b/facetracknoir/facetracknoir.h @@ -25,7 +25,7 @@ #ifndef FaceTrackNoIR_H #define FaceTrackNoIR_H -#include +#include #include #include #include @@ -39,7 +39,7 @@ #include #include #if !defined(_WIN32) -# include +# include "qxt-mini/QxtGlobalShortcut" #else # include #endif @@ -67,7 +67,7 @@ class FaceTrackNoIR : public QMainWindow, IDynamicLibraryProvider Q_OBJECT public: - FaceTrackNoIR(QWidget *parent = 0, Qt::WFlags flags = 0); + FaceTrackNoIR(QWidget *parent = 0, Qt::WindowFlags flags = 0); ~FaceTrackNoIR(); QFrame *get_video_widget(); // Get a pointer to the video-widget, to use in the DLL diff --git a/facetracknoir/facetracknoir.ui b/facetracknoir/facetracknoir.ui index 5c573a0b..5568db26 100644 --- a/facetracknoir/facetracknoir.ui +++ b/facetracknoir/facetracknoir.ui @@ -1480,8 +1480,8 @@ background:none; QFrame::NoFrame - - 6 + + 2 @@ -1496,8 +1496,8 @@ background:none; QFrame::NoFrame - - 6 + + 2 @@ -1546,6 +1546,9 @@ color:white; QFrame::NoFrame + + 2 + @@ -1576,6 +1579,9 @@ border:none; QFrame::NoFrame + + 2 + @@ -1640,8 +1646,8 @@ color:white; QFrame::NoFrame - - 6 + + 2 @@ -1656,8 +1662,8 @@ color:white; QFrame::NoFrame - - 5 + + 2 @@ -1704,8 +1710,8 @@ color:white; QFrame::Raised - - 5 + + 1 QLCDNumber::Flat @@ -1732,8 +1738,8 @@ color:white; QFrame::Raised - - 5 + + 1 QLCDNumber::Flat @@ -1760,8 +1766,8 @@ color:white; QFrame::Raised - - 5 + + 1 QLCDNumber::Flat @@ -1788,7 +1794,7 @@ color:white; QFrame::Raised - + 5 @@ -1816,7 +1822,7 @@ color:white; QFrame::Raised - + 5 @@ -1844,7 +1850,7 @@ color:white; QFrame::Raised - + 5 diff --git a/ftnoir_protocol_base/ftnoir_protocol_base.h b/ftnoir_protocol_base/ftnoir_protocol_base.h index d20e01b5..79f0800c 100644 --- a/ftnoir_protocol_base/ftnoir_protocol_base.h +++ b/ftnoir_protocol_base/ftnoir_protocol_base.h @@ -34,8 +34,8 @@ #include "ftnoir_protocol_base_global.h" #include "ftnoir_tracker_base/ftnoir_tracker_types.h" -#include -#include +#include +#include struct IProtocol { diff --git a/ftnoir_tracker_base/ftnoir_tracker_base.h b/ftnoir_tracker_base/ftnoir_tracker_base.h index cd603225..edbe7379 100644 --- a/ftnoir_tracker_base/ftnoir_tracker_base.h +++ b/ftnoir_tracker_base/ftnoir_tracker_base.h @@ -27,8 +27,8 @@ #include "ftnoir_tracker_base_global.h" #include "ftnoir_tracker_types.h" -#include -#include +#include +#include #include #include #include diff --git a/qfunctionconfigurator/qfunctionconfigurator.h b/qfunctionconfigurator/qfunctionconfigurator.h index 8460751a..fa72fb72 100644 --- a/qfunctionconfigurator/qfunctionconfigurator.h +++ b/qfunctionconfigurator/qfunctionconfigurator.h @@ -9,7 +9,6 @@ #include #include -#include #include #include #include "qfunctionconfigurator/functionconfig.h" -- cgit v1.2.3 From ce768725d5947dff30d51aa510df8c0869dffcfe Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 15 Oct 2013 09:14:55 +0200 Subject: Fix lcdnum style, has to be flat, not sunken --- facetracknoir/facetracknoir.ui | 102 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 99 insertions(+), 3 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.ui b/facetracknoir/facetracknoir.ui index 5568db26..0578e2f6 100644 --- a/facetracknoir/facetracknoir.ui +++ b/facetracknoir/facetracknoir.ui @@ -1274,7 +1274,7 @@ background:none; - 64 + 62 38 @@ -1315,7 +1315,7 @@ background:none; - 64 + 62 38 @@ -1462,8 +1462,15 @@ background:none; 0 + + * { + text-color: white; + color: white; +} + + - Raw Input + Raw data true @@ -1480,9 +1487,21 @@ background:none; QFrame::NoFrame + + 0 + + + 0 + + + true + 2 + + QLCDNumber::Flat + @@ -1496,9 +1515,21 @@ background:none; QFrame::NoFrame + + 0 + + + 0 + + + true + 2 + + QLCDNumber::Flat + @@ -1546,9 +1577,21 @@ color:white; QFrame::NoFrame + + 0 + + + 0 + + + true + 2 + + QLCDNumber::Flat + @@ -1579,9 +1622,21 @@ border:none; QFrame::NoFrame + + 0 + + + 0 + + + true + 2 + + QLCDNumber::Flat + @@ -1646,9 +1701,21 @@ color:white; QFrame::NoFrame + + 0 + + + 0 + + + true + 2 + + QLCDNumber::Flat + @@ -1659,14 +1726,43 @@ color:white; 21 + + color: white; +text-color: white; + QFrame::NoFrame + + 0 + + + 0 + + + true + 2 + + QLCDNumber::Flat + + groupBox + lcdNumZ + lcdNumY + label_8 + label_9 + lcdNumRotY + label_4 + lcdNumRotX + label_7 + lcdNumRotZ + lcdNumX + label_5 + label_6 -- cgit v1.2.3 From e58fb06ebc274a684712a7cb80028f3d2ec7757b Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 15 Oct 2013 12:02:29 +0200 Subject: fix MSVC 2010 build somewhat (?) --- facetracknoir/qt-moc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'facetracknoir') diff --git a/facetracknoir/qt-moc.h b/facetracknoir/qt-moc.h index 467370f9..6f6033b2 100644 --- a/facetracknoir/qt-moc.h +++ b/facetracknoir/qt-moc.h @@ -6,5 +6,5 @@ class AutomocMe { Q_OBJECT private: virtual void foo() = 0; - AutomocMe() = delete; + AutomocMe() {} }; -- cgit v1.2.3 From 6f3dedb2791efd26f17d332d00650aceb49c31f7 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 15 Oct 2013 13:22:20 +0200 Subject: use cast to fix qt5 breakage --- facetracknoir/shortcuts.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'facetracknoir') diff --git a/facetracknoir/shortcuts.cpp b/facetracknoir/shortcuts.cpp index 152fe565..43c1019d 100644 --- a/facetracknoir/shortcuts.cpp +++ b/facetracknoir/shortcuts.cpp @@ -159,7 +159,7 @@ KeybindingWorkerImpl::KeybindingWorkerImpl(FaceTrackNoIR& w, Key keyCenter) return; } - if (dinkeyboard->SetCooperativeLevel(window.winId(), DISCL_NONEXCLUSIVE | DISCL_BACKGROUND) != DI_OK) { + if (dinkeyboard->SetCooperativeLevel((HWND) window.winId(), DISCL_NONEXCLUSIVE | DISCL_BACKGROUND) != DI_OK) { dinkeyboard->Release(); din->Release(); din = 0; -- cgit v1.2.3 From bb710c8d207337d4d0cc2a6657e954bbc2823e7f Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 16 Oct 2013 18:30:59 +0200 Subject: initial implementation To-be-reviewed-by: mm0zct --- facetracknoir/facetracknoir.cpp | 15 +- facetracknoir/facetracknoir.h | 3 + facetracknoir/ftnoir_keyboardshortcuts.ui | 305 ++++++++++++++++++------------ facetracknoir/shortcuts.cpp | 103 ++++++++-- facetracknoir/shortcuts.h | 7 +- facetracknoir/tracker.cpp | 8 +- facetracknoir/tracker.h | 1 + 7 files changed, 283 insertions(+), 159 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index eb24b320..dddcd4e4 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -95,6 +95,7 @@ FaceTrackNoIR::FaceTrackNoIR(QWidget *parent, Qt::WindowFlags flags) : keybindingWorker(NULL), #else keyCenter(0), + keyToggle(0), #endif timUpdateHeadPose(this), pTrackerDialog(NULL), @@ -973,12 +974,18 @@ void FaceTrackNoIR::shortcutRecentered() { if (tracker) { -#if defined(_WIN32) - MessageBeep(MB_OK); -#else QApplication::beep(); -#endif qDebug() << "Center"; tracker->do_center = true; } } + +void FaceTrackNoIR::shortcutToggled() +{ + if (tracker) + { + QApplication::beep(); + qDebug() << "Toggle"; + tracker->enabled = !tracker->enabled; + } +} diff --git a/facetracknoir/facetracknoir.h b/facetracknoir/facetracknoir.h index 6c087c43..8f510d78 100644 --- a/facetracknoir/facetracknoir.h +++ b/facetracknoir/facetracknoir.h @@ -91,12 +91,15 @@ public: #if defined(_WIN32) Key keyCenter; + Key keyToggle; KeybindingWorker* keybindingWorker; #else QxtGlobalShortcut* keyCenter; + QxtGlobalShortcut* keyToggle; #endif public slots: void shortcutRecentered(); + void shortcutToggled(); private: HeadPoseData pose; diff --git a/facetracknoir/ftnoir_keyboardshortcuts.ui b/facetracknoir/ftnoir_keyboardshortcuts.ui index e70b7536..66ab004f 100644 --- a/facetracknoir/ftnoir_keyboardshortcuts.ui +++ b/facetracknoir/ftnoir_keyboardshortcuts.ui @@ -6,10 +6,16 @@ 0 0 - 289 - 81 + 337 + 122 + + + 0 + 0 + + FaceTrackNoIR Keyboard and Mouse shortcuts @@ -26,8 +32,8 @@ - 180 - 50 + 120 + 90 100 23 @@ -57,8 +63,8 @@ - 74 - 50 + 230 + 90 100 23 @@ -85,131 +91,178 @@ OK - - - - 179 - 19 - 101 - 20 - - - - - 90 - 0 - - - - Select Number - - - QComboBox::InsertAlphabetically - - - - - - 210 - 0 - 46 - 16 - - - - - 0 - 0 - - - - Keyboard - - - Qt::AlignCenter - - - false - - - - - - 141 - 21 - 36 - 17 - - - - - 50 - 16777215 - - - - Alt - - - + 5 - 23 - 33 - 16 - - - - - 0 - 0 - - - - Center - - - false - - - - - - 95 - 21 - 40 - 17 - - - - - 50 - 16777215 - - - - Ctrl - - - - - - 44 - 21 - 45 - 17 + 0 + 321 + 75 - - - 50 - 16777215 - - - - Shift - + + + + + + 0 + 0 + + + + Keyboard + + + Qt::AlignCenter + + + false + + + + + + + + 0 + 0 + + + + Center + + + false + + + + + + + + 50 + 16777215 + + + + Shift + + + + + + + + 50 + 16777215 + + + + Ctrl + + + + + + + + 50 + 16777215 + + + + Alt + + + + + + + + 90 + 0 + + + + Select Number + + + QComboBox::InsertAlphabetically + + + + + + + + 0 + 0 + + + + Toggle + + + false + + + + + + + + 50 + 16777215 + + + + Shift + + + + + + + + 50 + 16777215 + + + + Ctrl + + + + + + + + 50 + 16777215 + + + + Alt + + + + + + + + 90 + 0 + + + + Select Number + + + QComboBox::InsertAlphabetically + + + + diff --git a/facetracknoir/shortcuts.cpp b/facetracknoir/shortcuts.cpp index 43c1019d..aae70bac 100644 --- a/facetracknoir/shortcuts.cpp +++ b/facetracknoir/shortcuts.cpp @@ -17,6 +17,7 @@ KeyboardShortcutDialog::KeyboardShortcutDialog( FaceTrackNoIR *ftnoir, QWidget * for ( int i = 0; i < global_key_sequences.size(); i++) { ui.cbxCenterKey->addItem(global_key_sequences.at(i)); + ui.cbxToggleKey->addItem(global_key_sequences.at(i)); } loadSettings(); @@ -38,7 +39,6 @@ void KeyboardShortcutDialog::doOK() { mainApp->bindKeyboardShortcuts(); } -// override show event void KeyboardShortcutDialog::showEvent ( QShowEvent * event ) { loadSettings(); } @@ -76,11 +76,7 @@ void KeyboardShortcutDialog::doCancel() { } } -// -// Load the current Settings from the currently 'active' INI-file. -// void KeyboardShortcutDialog::loadSettings() { - qDebug() << "loadSettings says: Starting "; QSettings settings("opentrack"); // Registry settings (in HK_USER) QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); @@ -90,24 +86,82 @@ void KeyboardShortcutDialog::loadSettings() { iniFile.beginGroup ( "KB_Shortcuts" ); - ui.chkCenterShift->setChecked (iniFile.value ( "Shift_Center", 0 ).toBool()); - ui.chkCenterCtrl->setChecked (iniFile.value ( "Ctrl_Center", 0 ).toBool()); - ui.chkCenterAlt->setChecked (iniFile.value ( "Alt_Center", 0 ).toBool()); + const char* names[] = { + "Center", "Togggle" + }; + + QComboBox* checkboxen[] = { + ui.cbxCenterKey, + ui.cbxToggleKey + }; + + QCheckBox* boxen[2][3] = { + { + ui.chkCenterShift, + ui.chkCenterCtrl, + ui.chkCenterAlt + }, + { + ui.chkToggleShift, + ui.chkToggleCtrl, + ui.chkToggleAlt + } + }; + + const char* modnames[] = { + "Shift", "Ctrl", "Alt" + }; + + const char* keynames[] = { + "Center", "Toggle" + }; - ui.cbxCenterKey->setCurrentIndex(iniFile.value("Key_index_Center", 0).toInt()); + const int KEY_COUNT = 2; + const int MODIFIERS = 3; + + for (int i = 0; i < KEY_COUNT; i++) + { + for (int m = 0; i < MODIFIERS; i++) + { + boxen[i][m]->setChecked (iniFile.value ( modnames[m] + QString("_") + QString(keynames[i]), 0 ).toBool()); + } + checkboxen[i]->setCurrentIndex(iniFile.value("Key_index_" + QString(names[i]), 0).toInt()); + } iniFile.endGroup (); settingsDirty = false; - } -// -// Save the current Settings to the currently 'active' INI-file. -// void KeyboardShortcutDialog::save() { + const char* keynames[] = { + "Center", "Toggle" + }; + + QComboBox* checkboxen[] = { + ui.cbxCenterKey, + ui.cbxToggleKey + }; + + const char* modnames[] = { + "Shift", "Ctrl", "Alt" + }; + + QCheckBox* boxen[2][3] = { + { + ui.chkCenterShift, + ui.chkCenterCtrl, + ui.chkCenterAlt + }, + { + ui.chkToggleShift, + ui.chkToggleCtrl, + ui.chkToggleAlt + } + }; - qDebug() << "save() says: started"; + const int MODIFIERS = 3; + const int KEY_COUNT = 2; QSettings settings("opentrack"); // Registry settings (in HK_USER) @@ -115,12 +169,18 @@ void KeyboardShortcutDialog::save() { QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) iniFile.beginGroup ( "KB_Shortcuts" ); - iniFile.setValue ( "Key_index_Center", ui.cbxCenterKey->currentIndex() ); - iniFile.setValue ( "Shift_Center", ui.chkCenterShift->isChecked() ); - iniFile.setValue ( "Ctrl_Center", ui.chkCenterCtrl->isChecked() ); - iniFile.setValue ( "Alt_Center", ui.chkCenterAlt->isChecked() ); - iniFile.endGroup (); + for (int i = 0; i < KEY_COUNT; i++) + { + iniFile.setValue ( "Key_index_" + QString(keynames[i]), + checkboxen[i]->currentIndex() ); + for (int m = 0; i < MODIFIERS; i++) + { + iniFile.setValue(modnames[m] + QString("_") + keynames[i], !!boxen[i][m]->isChecked()); + } + } + + iniFile.endGroup(); settingsDirty = false; } @@ -137,8 +197,8 @@ KeybindingWorkerImpl::~KeybindingWorkerImpl() { din->Release(); } -KeybindingWorkerImpl::KeybindingWorkerImpl(FaceTrackNoIR& w, Key keyCenter) -: din(0), dinkeyboard(0), kCenter(keyCenter), window(w), should_quit(true) +KeybindingWorkerImpl::KeybindingWorkerImpl(FaceTrackNoIR& w, Key keyCenter, Key keyToggle) +: din(0), dinkeyboard(0), kCenter(keyCenter), ktoggle(keyTogle), window(w), should_quit(true) { if (DirectInput8Create(GetModuleHandle(NULL), DIRECTINPUT_VERSION, IID_IDirectInput8, (void**)&din, NULL) != DI_OK) { qDebug() << "setup DirectInput8 Creation failed!" << GetLastError(); @@ -219,6 +279,7 @@ void KeybindingWorkerImpl::run() { } PROCESS_KEY(kCenter, shortcutRecentered); + PROCESS_KEY(kToggle, shortcutToggled); Sleep(25); } diff --git a/facetracknoir/shortcuts.h b/facetracknoir/shortcuts.h index 05c36520..9fd83af3 100644 --- a/facetracknoir/shortcuts.h +++ b/facetracknoir/shortcuts.h @@ -64,17 +64,18 @@ private: LPDIRECTINPUT8 din; LPDIRECTINPUTDEVICE8 dinkeyboard; Key kCenter; + Key kToggle; FaceTrackNoIR& window; public: volatile bool should_quit; ~KeybindingWorkerImpl(); - KeybindingWorkerImpl(FaceTrackNoIR& w, Key keyCenter); + KeybindingWorkerImpl(FaceTrackNoIR& w, Key keyCenter, Key keyToggle); void run(); }; #else class KeybindingWorkerImpl { public: - KeybindingWorkerImpl(FaceTrackNoIR& w, Key keyCenter); + KeybindingWorkerImpl(FaceTrackNoIR& w, Key keyCenter, Key keyToggle); void run() {} }; #endif @@ -82,7 +83,7 @@ public: class KeybindingWorker : public QThread, public KeybindingWorkerImpl { Q_OBJECT public: - KeybindingWorker(FaceTrackNoIR& w, Key keyCenter) : KeybindingWorkerImpl(w, keyCenter) + KeybindingWorker(FaceTrackNoIR& w, Key keyCenter, Key keyToggle) : KeybindingWorkerImpl(w, keyCenter, keyToggle) { } void run() { diff --git a/facetracknoir/tracker.cpp b/facetracknoir/tracker.cpp index b965140b..d1218098 100644 --- a/facetracknoir/tracker.cpp +++ b/facetracknoir/tracker.cpp @@ -31,7 +31,8 @@ /** constructor **/ Tracker::Tracker( FaceTrackNoIR *parent ) : should_quit(false), - do_center(false) + do_center(false), + enabled(true) { // Retieve the pointer to the parent mainApp = parent; @@ -145,17 +146,14 @@ void Tracker::run() { get_curve(new_camera.axes[i], output_camera.axes[i], mainApp->axis(i)); } - // // Send the headpose to the game - // - if (Libraries->pProtocol) { + if (Libraries->pProtocol && enabled) { gameoutput_camera = output_camera; Libraries->pProtocol->sendHeadposeToGame( gameoutput_camera.axes, newpose ); // degrees & centimeters } } } - //for lower cpu load msleep(8); } #if defined(_WIN32) diff --git a/facetracknoir/tracker.h b/facetracknoir/tracker.h index 885fc1e2..28f8dc99 100644 --- a/facetracknoir/tracker.h +++ b/facetracknoir/tracker.h @@ -108,6 +108,7 @@ public: volatile bool should_quit; // following are now protected by hTrackMutex volatile bool do_center; // Center head-position, using the shortkey + volatile bool enabled; T6DOF output_camera; }; -- cgit v1.2.3 From 0bdfd9d5a8738a442710be06ae5619ff40462f06 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 16 Oct 2013 19:04:11 +0200 Subject: fix typo Signed-off-by: Stanislaw Halik --- facetracknoir/shortcuts.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'facetracknoir') diff --git a/facetracknoir/shortcuts.cpp b/facetracknoir/shortcuts.cpp index aae70bac..4256e932 100644 --- a/facetracknoir/shortcuts.cpp +++ b/facetracknoir/shortcuts.cpp @@ -87,7 +87,7 @@ void KeyboardShortcutDialog::loadSettings() { iniFile.beginGroup ( "KB_Shortcuts" ); const char* names[] = { - "Center", "Togggle" + "Center", "Toggle" }; QComboBox* checkboxen[] = { -- cgit v1.2.3 From 861265697c04897ed63c6a5760d8f379dcd354af Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 16 Oct 2013 20:56:46 +0200 Subject: while here, clean up -Wall -Wextra -pedantic Signed-off-by: Stanislaw Halik --- facetracknoir/curve-config.cpp | 2 +- facetracknoir/curve-config.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/curve-config.cpp b/facetracknoir/curve-config.cpp index 36caa5c0..117e5803 100644 --- a/facetracknoir/curve-config.cpp +++ b/facetracknoir/curve-config.cpp @@ -35,7 +35,7 @@ void CurveConfigurationDialog::doOK() { } // override show event -void CurveConfigurationDialog::showEvent ( QShowEvent * event ) { +void CurveConfigurationDialog::showEvent ( QShowEvent * ) { loadSettings(); } diff --git a/facetracknoir/curve-config.h b/facetracknoir/curve-config.h index d02f1587..a9073840 100644 --- a/facetracknoir/curve-config.h +++ b/facetracknoir/curve-config.h @@ -22,6 +22,6 @@ private: private slots: void doOK(); void doCancel(); - void curveChanged( bool change ) { settingsDirty = true; } - void curveChanged( int change ) { settingsDirty = true; } + void curveChanged( bool ) { settingsDirty = true; } + void curveChanged( int ) { settingsDirty = true; } }; -- cgit v1.2.3 From dfb30c9b033f980aaa702a8b7594f3e5113ad843 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 16 Oct 2013 20:56:55 +0200 Subject: fix wrong colors Signed-off-by: Stanislaw Halik --- facetracknoir/ftnoir_keyboardshortcuts.ui | 43 ++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/ftnoir_keyboardshortcuts.ui b/facetracknoir/ftnoir_keyboardshortcuts.ui index 66ab004f..0bbd42ff 100644 --- a/facetracknoir/ftnoir_keyboardshortcuts.ui +++ b/facetracknoir/ftnoir_keyboardshortcuts.ui @@ -6,8 +6,8 @@ 0 0 - 337 - 122 + 335 + 120 @@ -16,6 +16,43 @@ 0 + + + + + + + 255 + 255 + 255 + + + + + + + + + 255 + 255 + 255 + + + + + + + + + 141 + 143 + 145 + + + + + + FaceTrackNoIR Keyboard and Mouse shortcuts @@ -91,7 +128,7 @@ OK - + 5 -- cgit v1.2.3 From 3240f3d4f1f7e084dcb4bb2c4dbda563ce62aa6e Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 16 Oct 2013 20:57:03 +0200 Subject: while here, remove dead code Signed-off-by: Stanislaw Halik --- facetracknoir/main.cpp | 9 --------- 1 file changed, 9 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/main.cpp b/facetracknoir/main.cpp index 5a52c034..cf7ff6fb 100644 --- a/facetracknoir/main.cpp +++ b/facetracknoir/main.cpp @@ -28,7 +28,6 @@ #include #include #include -#include #if defined(_WIN32) # include @@ -40,14 +39,6 @@ int main(int argc, char** argv) QApplication::setAttribute(Qt::AA_X11InitThreads, true); QApplication app(argc, argv); -#if 0 - - QFont font; - font.setFamily(font.defaultFamily()); - font.setPointSize(9); - font.setStyleStrategy(QFont::PreferAntialias); - app.setFont(font); -#endif FaceTrackNoIR w; QDesktopWidget desktop; -- cgit v1.2.3 From ee1bc50aea27ab75bd50b62f393f6f51cdc3aa53 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 16 Oct 2013 20:57:19 +0200 Subject: remove dead code Signed-off-by: Stanislaw Halik --- facetracknoir/shortcuts.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'facetracknoir') diff --git a/facetracknoir/shortcuts.h b/facetracknoir/shortcuts.h index 9fd83af3..a98211a8 100644 --- a/facetracknoir/shortcuts.h +++ b/facetracknoir/shortcuts.h @@ -17,7 +17,7 @@ public: explicit KeyboardShortcutDialog( FaceTrackNoIR *ftnoir, QWidget *parent ); virtual ~KeyboardShortcutDialog(); - void showEvent ( QShowEvent * event ); + void showEvent (QShowEvent *); private: Ui::UICKeyboardShortcutDialog ui; -- cgit v1.2.3 From df7969c687a0e6a5e6cbed8cabaf11c51058d35a Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 16 Oct 2013 20:57:35 +0200 Subject: don't even display headpose when off Signed-off-by: Stanislaw Halik --- facetracknoir/tracker.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/tracker.cpp b/facetracknoir/tracker.cpp index d1218098..53b3ffd3 100644 --- a/facetracknoir/tracker.cpp +++ b/facetracknoir/tracker.cpp @@ -122,7 +122,7 @@ void Tracker::run() { Libraries->pFilter->Initialize(); } - if (confid) { + if (confid && enabled) { // get values for (int i = 0; i < 6; i++) target_camera.axes[i] = mainApp->axis(i).headPos; @@ -147,7 +147,7 @@ void Tracker::run() { } // Send the headpose to the game - if (Libraries->pProtocol && enabled) { + if (Libraries->pProtocol) { gameoutput_camera = output_camera; Libraries->pProtocol->sendHeadposeToGame( gameoutput_camera.axes, newpose ); // degrees & centimeters } -- cgit v1.2.3 From 015547df5de7dcfaa60bfa6f8ac30b1f9c91385a Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 16 Oct 2013 20:57:56 +0200 Subject: fix the damn mess Signed-off-by: Stanislaw Halik --- facetracknoir/facetracknoir.cpp | 119 ++++++++++-------- facetracknoir/facetracknoir.h | 10 +- facetracknoir/facetracknoir.ui | 270 +--------------------------------------- facetracknoir/shortcuts.cpp | 19 ++- 4 files changed, 86 insertions(+), 332 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index dddcd4e4..af630bea 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -91,12 +91,12 @@ static void fill_combobox(const QString& filter, QList& list, Q // FaceTrackNoIR::FaceTrackNoIR(QWidget *parent, Qt::WindowFlags flags) : QMainWindow(parent, flags), - #if defined(_WIN32) - keybindingWorker(NULL), - #else - keyCenter(0), - keyToggle(0), - #endif +#if defined(_WIN32) + keybindingWorker(NULL), +#else + keyCenter(this), + keyToggle(this), +#endif timUpdateHeadPose(this), pTrackerDialog(NULL), pSecondTrackerDialog(NULL), @@ -182,6 +182,9 @@ FaceTrackNoIR::FaceTrackNoIR(QWidget *parent, Qt::WindowFlags flags) : ui.lcdNumOutputRotX->setVisible(false); ui.lcdNumOutputRotY->setVisible(false); ui.lcdNumOutputRotZ->setVisible(false); + + connect(&keyCenter, SIGNAL(activated()), this, SLOT(shortcutRecentered())); + connect(&keyToggle, SIGNAL(activated()), this, SLOT(shortcutToggled())); } /** destructor stops the engine and quits the faceapi **/ @@ -545,7 +548,7 @@ void FaceTrackNoIR::startTracker( ) { } #if defined(_WIN32) - keybindingWorker = new KeybindingWorker(*this, keyCenter); + keybindingWorker = new KeybindingWorker(*this, &keyCenter, &keyToggle); keybindingWorker->start(); #endif @@ -913,79 +916,97 @@ void FaceTrackNoIR::profileSelected(int index) loadSettings(); } -void FaceTrackNoIR::bindKeyboardShortcuts() -{ - QSettings settings("opentrack"); // 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) - iniFile.beginGroup ( "KB_Shortcuts" ); - int idxCenter = iniFile.value("Key_index_Center", 0).toInt(); - #if !defined(_WIN32) - if (keyCenter) { - delete keyCenter; - keyCenter = NULL; - } - - if (idxCenter > 0) +void FaceTrackNoIR::bind_keyboard_shortcut(QxtGlobalShortcut& key, const QString label, QSettings& iniFile) +{ + const int idx = iniFile.value("Key_index_" + label, 0).toInt(); + key.setShortcut(QKeySequence::fromString("")); + key.setDisabled(); + QString seq(global_key_sequences.value(idx, "")); + if (idx > 0) { - QString seq(global_key_sequences.value(idxCenter, "")); if (!seq.isEmpty()) { - if (iniFile.value("Shift_Center", false).toBool()) + if (iniFile.value(QString("Shift_%1").arg(label), false).toBool()) seq = "Shift+" + seq; - if (iniFile.value("Alt_Center", false).toBool()) + if (iniFile.value(QString("Alt_%1").arg(label), false).toBool()) seq = "Alt+" + seq; - if (iniFile.value("Ctrl_Center", false).toBool()) + if (iniFile.value(QString("Ctrl_%1").arg(label), false).toBool()) seq = "Ctrl+" + seq; - keyCenter = new QxtGlobalShortcut(QKeySequence(seq), this); - connect(keyCenter, SIGNAL(activated()), this, SLOT(shortcutRecentered())); + key.setShortcut(QKeySequence::fromString(seq, QKeySequence::NativeText)); + key.setEnabled(); } } +} #else - keyCenter.keycode = 0; - keyCenter.shift = keyCenter.alt = keyCenter.ctrl = 0; - if (idxCenter > 0 && idxCenter < global_windows_key_sequences.size()) - keyCenter.keycode = global_windows_key_sequences[idxCenter]; - keyCenter.shift = iniFile.value("Shift_Center", false).toBool(); - keyCenter.alt = iniFile.value("Alt_Center", false).toBool(); - keyCenter.ctrl = iniFile.value("Ctrl_Center", false).toBool(); +static void bind_keyboard_shotcut(Key& key, const QString label, QSettings& iniFile) +{ + const int idx = iniFile.value("Key_index_" + label, 0).toInt(); + if (idx > 0) + { + key.keycode = 0; + key.shift = key.alt = key.ctrl = 0; + if (idx < global_windows_key_sequences.size()) + key.keycode = global_windows_key_sequences[idx]; + key.shift = iniFile.value(QString("Shift_").arg(label), false).toBool(); + key.alt = iniFile.value(QString("Alt_").arg(label), false).toBool(); + key.ctrl = iniFile.value(QString("Ctrl_").arg(label), false).toBool(); + } +} #endif - iniFile.endGroup (); + +void FaceTrackNoIR::bindKeyboardShortcuts() +{ + QSettings settings("opentrack"); // 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) + iniFile.beginGroup ( "KB_Shortcuts" ); +#if !defined(_WIN32) + bind_keyboard_shortcut(keyCenter, "Center", iniFile); + bind_keyboard_shortcut(keyToggle, "Toggle", iniFile); +#else + bind_keyboard_shortcut(&keyCenter, "Center", iniFile)); + bind_keyboard_shortcut(&keyToggle, "Toggle", iniFile)); +#endif + iniFile.endGroup (); + if (tracker) /* running already */ { #if defined(_WIN32) - if (keybindingWorker) - { - keybindingWorker->should_quit = true; - keybindingWorker->wait(); - delete keybindingWorker; - keybindingWorker = NULL; - } - keybindingWorker = new KeybindingWorker(*this, keyCenter); - keybindingWorker->start(); + if (keybindingWorker) + { + keybindingWorker->should_quit = true; + keybindingWorker->wait(); + delete keybindingWorker; + keybindingWorker = NULL; + } + const int idx_center = iniFile.value("Key_index_Center", 0).toInt(); + const int idx_toggle = iniFile.value("Key_index_Toggle", 0).toInt(); + keybindingWorker = new KeybindingWorker(*this, keyCenter, keyToggle); + keybindingWorker->start(); #endif } } void FaceTrackNoIR::shortcutRecentered() { + QApplication::beep(); + + qDebug() << "Center"; if (tracker) { - QApplication::beep(); - qDebug() << "Center"; tracker->do_center = true; } } void FaceTrackNoIR::shortcutToggled() { + QApplication::beep(); + qDebug() << "Toggle"; if (tracker) { - QApplication::beep(); - qDebug() << "Toggle"; tracker->enabled = !tracker->enabled; } } diff --git a/facetracknoir/facetracknoir.h b/facetracknoir/facetracknoir.h index 8f510d78..bfeb2d38 100644 --- a/facetracknoir/facetracknoir.h +++ b/facetracknoir/facetracknoir.h @@ -94,8 +94,8 @@ public: Key keyToggle; KeybindingWorker* keybindingWorker; #else - QxtGlobalShortcut* keyCenter; - QxtGlobalShortcut* keyToggle; + QxtGlobalShortcut keyCenter; + QxtGlobalShortcut keyToggle; #endif public slots: void shortcutRecentered(); @@ -112,7 +112,6 @@ private: IProtocolDialog* pProtocolDialog; // Pointer to Protocol dialog instance (in DLL) IFilterDialog* pFilterDialog; // Pointer to Filter dialog instance (in DLL) - /** Widget variables **/ QWidget *_keyboard_shortcuts; QWidget *_curve_config; @@ -120,12 +119,15 @@ private: void GetCameraNameDX(); void loadSettings(); - void setupFaceTrackNoIR(); QList dlopen_filters; QList dlopen_trackers; QList dlopen_protocols; +#ifndef _WIN32 + void bind_keyboard_shortcut(QxtGlobalShortcut& key, const QString label, QSettings& iniFile); +#endif + bool looping; private slots: diff --git a/facetracknoir/facetracknoir.ui b/facetracknoir/facetracknoir.ui index 0578e2f6..2f35e29b 100644 --- a/facetracknoir/facetracknoir.ui +++ b/facetracknoir/facetracknoir.ui @@ -181,259 +181,6 @@ QGroupBox { 419 - - - - - - - 0 - 0 - 0 - - - - - - - 89 - 89 - 89 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 89 - 89 - 89 - - - - - - - 89 - 89 - 89 - - - - - - - 192 - 192 - 192 - - - - - - - 0 - 0 - 0 - - - - - - - 72 - 72 - 72 - - - - - - - - - 0 - 0 - 0 - - - - - - - 89 - 89 - 89 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 89 - 89 - 89 - - - - - - - 89 - 89 - 89 - - - - - - - 192 - 192 - 192 - - - - - - - 0 - 0 - 0 - - - - - - - 72 - 72 - 72 - - - - - - - - - 0 - 0 - 0 - - - - - - - 89 - 89 - 89 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 89 - 89 - 89 - - - - - - - 89 - 89 - 89 - - - - - - - 192 - 192 - 192 - - - - - - - 0 - 0 - 0 - - - - - - - 72 - 72 - 72 - - - - - - false @@ -1464,7 +1211,6 @@ background:none; * { - text-color: white; color: white; } @@ -1727,8 +1473,7 @@ color:white; - color: white; -text-color: white; + color: white; QFrame::NoFrame @@ -1750,19 +1495,6 @@ text-color: white; - groupBox - lcdNumZ - lcdNumY - label_8 - label_9 - lcdNumRotY - label_4 - lcdNumRotX - label_7 - lcdNumRotZ - lcdNumX - label_5 - label_6 diff --git a/facetracknoir/shortcuts.cpp b/facetracknoir/shortcuts.cpp index 4256e932..1cd967e0 100644 --- a/facetracknoir/shortcuts.cpp +++ b/facetracknoir/shortcuts.cpp @@ -39,7 +39,7 @@ void KeyboardShortcutDialog::doOK() { mainApp->bindKeyboardShortcuts(); } -void KeyboardShortcutDialog::showEvent ( QShowEvent * event ) { +void KeyboardShortcutDialog::showEvent ( QShowEvent * ) { loadSettings(); } @@ -90,7 +90,7 @@ void KeyboardShortcutDialog::loadSettings() { "Center", "Toggle" }; - QComboBox* checkboxen[] = { + QComboBox* comboboxen[] = { ui.cbxCenterKey, ui.cbxToggleKey }; @@ -121,11 +121,11 @@ void KeyboardShortcutDialog::loadSettings() { for (int i = 0; i < KEY_COUNT; i++) { - for (int m = 0; i < MODIFIERS; i++) + for (int m = 0; m < MODIFIERS; m++) { - boxen[i][m]->setChecked (iniFile.value ( modnames[m] + QString("_") + QString(keynames[i]), 0 ).toBool()); + boxen[i][m]->setChecked (iniFile.value ( QString("%1_%2").arg(modnames[m], keynames[i]), 0).toBool()); } - checkboxen[i]->setCurrentIndex(iniFile.value("Key_index_" + QString(names[i]), 0).toInt()); + comboboxen[i]->setCurrentIndex(iniFile.value(QString("Key_index_%1").arg(names[i]), 0).toInt()); } iniFile.endGroup (); @@ -138,7 +138,7 @@ void KeyboardShortcutDialog::save() { "Center", "Toggle" }; - QComboBox* checkboxen[] = { + QComboBox* comboboxen[] = { ui.cbxCenterKey, ui.cbxToggleKey }; @@ -172,12 +172,11 @@ void KeyboardShortcutDialog::save() { for (int i = 0; i < KEY_COUNT; i++) { - iniFile.setValue ( "Key_index_" + QString(keynames[i]), - checkboxen[i]->currentIndex() ); - for (int m = 0; i < MODIFIERS; i++) + for (int m = 0; m < MODIFIERS; m++) { - iniFile.setValue(modnames[m] + QString("_") + keynames[i], !!boxen[i][m]->isChecked()); + iniFile.setValue(QString("%1_%2").arg(modnames[m], keynames[i]), boxen[i][m]->isChecked()); } + iniFile.setValue(QString("Key_index_%1").arg(keynames[i]), comboboxen[i]->currentIndex()); } iniFile.endGroup(); -- cgit v1.2.3 From fdcc4a6034ad0afffd68f0d6df9766c6c5a08495 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 16 Oct 2013 21:18:30 +0200 Subject: fix win32 typos Signed-off-by: Stanislaw Halik --- facetracknoir/facetracknoir.cpp | 10 ++++++---- facetracknoir/shortcuts.cpp | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index af630bea..f5358329 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -183,8 +183,10 @@ FaceTrackNoIR::FaceTrackNoIR(QWidget *parent, Qt::WindowFlags flags) : ui.lcdNumOutputRotY->setVisible(false); ui.lcdNumOutputRotZ->setVisible(false); +#ifndef _WIN32 connect(&keyCenter, SIGNAL(activated()), this, SLOT(shortcutRecentered())); connect(&keyToggle, SIGNAL(activated()), this, SLOT(shortcutToggled())); +#endif } /** destructor stops the engine and quits the faceapi **/ @@ -548,7 +550,7 @@ void FaceTrackNoIR::startTracker( ) { } #if defined(_WIN32) - keybindingWorker = new KeybindingWorker(*this, &keyCenter, &keyToggle); + keybindingWorker = new KeybindingWorker(*this, keyCenter, keyToggle); keybindingWorker->start(); #endif @@ -939,7 +941,7 @@ void FaceTrackNoIR::bind_keyboard_shortcut(QxtGlobalShortcut& key, const QString } } #else -static void bind_keyboard_shotcut(Key& key, const QString label, QSettings& iniFile) +static void bind_keyboard_shortcut(Key& key, const QString label, QSettings& iniFile) { const int idx = iniFile.value("Key_index_" + label, 0).toInt(); if (idx > 0) @@ -967,8 +969,8 @@ void FaceTrackNoIR::bindKeyboardShortcuts() bind_keyboard_shortcut(keyCenter, "Center", iniFile); bind_keyboard_shortcut(keyToggle, "Toggle", iniFile); #else - bind_keyboard_shortcut(&keyCenter, "Center", iniFile)); - bind_keyboard_shortcut(&keyToggle, "Toggle", iniFile)); + bind_keyboard_shortcut(keyCenter, "Center", iniFile); + bind_keyboard_shortcut(keyToggle, "Toggle", iniFile); #endif iniFile.endGroup (); diff --git a/facetracknoir/shortcuts.cpp b/facetracknoir/shortcuts.cpp index 1cd967e0..09663a0f 100644 --- a/facetracknoir/shortcuts.cpp +++ b/facetracknoir/shortcuts.cpp @@ -197,7 +197,7 @@ KeybindingWorkerImpl::~KeybindingWorkerImpl() { } KeybindingWorkerImpl::KeybindingWorkerImpl(FaceTrackNoIR& w, Key keyCenter, Key keyToggle) -: din(0), dinkeyboard(0), kCenter(keyCenter), ktoggle(keyTogle), window(w), should_quit(true) +: din(0), dinkeyboard(0), kCenter(keyCenter), kToggle(keyToggle), window(w), should_quit(true) { if (DirectInput8Create(GetModuleHandle(NULL), DIRECTINPUT_VERSION, IID_IDirectInput8, (void**)&din, NULL) != DI_OK) { qDebug() << "setup DirectInput8 Creation failed!" << GetLastError(); -- cgit v1.2.3 From 3342d36cfb22b22f812a2f8b306c4d9cb9e48cae Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 16 Oct 2013 21:22:09 +0200 Subject: fix more win32 typos --- facetracknoir/facetracknoir.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index f5358329..197e9fa6 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -950,9 +950,9 @@ static void bind_keyboard_shortcut(Key& key, const QString label, QSettings& ini key.shift = key.alt = key.ctrl = 0; if (idx < global_windows_key_sequences.size()) key.keycode = global_windows_key_sequences[idx]; - key.shift = iniFile.value(QString("Shift_").arg(label), false).toBool(); - key.alt = iniFile.value(QString("Alt_").arg(label), false).toBool(); - key.ctrl = iniFile.value(QString("Ctrl_").arg(label), false).toBool(); + key.shift = iniFile.value(QString("Shift_%1").arg(label), false).toBool(); + key.alt = iniFile.value(QString("Alt_%1").arg(label), false).toBool(); + key.ctrl = iniFile.value(QString("Ctrl_%1").arg(label), false).toBool(); } } #endif -- cgit v1.2.3 From 1a77ab96501324a7417c970bec753e1304931267 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 16 Oct 2013 23:28:42 +0200 Subject: remove custom styles. use default Qt styles. This is a major user-facing change. Signed-off-by: Stanislaw Halik --- facetracknoir/facetracknoir.ui | 590 ++++++++++++++---------------- facetracknoir/ftnoir_keyboardshortcuts.ui | 37 -- 2 files changed, 274 insertions(+), 353 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.ui b/facetracknoir/facetracknoir.ui index 2f35e29b..e17fa30b 100644 --- a/facetracknoir/facetracknoir.ui +++ b/facetracknoir/facetracknoir.ui @@ -39,96 +39,12 @@ FaceTrackNoIR - + :/images/facetracknoir.png:/images/facetracknoir.png - - /* Customize any plain widget that is a child of a QMainWindow. */ -QMainWindow > .QWidget { - background-color: rgb(100, 100, 100); -} - -/* Set the selection colors for all widgets. */ -QWidget { - selection-color: black; - selection-background-color: Silver; - color: black; -} - -/* Specials for individual widget(s) */ -QWidget#widget { -/* background-color: #484848;*/ - background-color: #595959; - border-left: 1px solid #000; -} - -/* Specials for individual widget(s) */ -QWidget#widget4logo { - background-color: #000000; -} - -/* Specials for individual widget(s) */ -QWidget#headPoseWidget { - background-color: #595959; -} - -QWidget#widget4video { -/* background-color: #595959;*/ -} - -QWidget#Leftwidget { - background-color: ; -} - -QWidget#widgetTop { - background-color: #595959; - border-bottom: 1px solid #000; -} - -/* Make text in message boxes selectable. */ -QMessageBox { - /* LinksAccessibleByMouse | TextSelectableByMouse */ - messagebox-text-interaction-flags: 5; -} - -/* Make the entire row selected in item views. */ -QAbstractItemView { - show-decoration-selected: 1; -} - -/* Nice WindowsXP-style password character for password line edits. */ -QLineEdit[echoMode="2"] { - lineedit-password-character: 9679; -} - -/* Customize tooltips. */ -QToolTip { - background-color: rgb(170, 255, 127); - opacity: 200; -} - -/* Customize push buttons and comboboxes. Our read-only combobox - is very similar to a push button, so they share the same border image. */ - -QPushButton { - min-width: 4em; -} - -QCheckBox { - background:none; -} - -QPushButton:disabled { - color: rgb(128, 128, 128); -} - -QGroupBox { - color: rgb(255, 255, 255); -} - @@ -211,10 +127,6 @@ QGroupBox { 30 - - color:#ccc; -background:none; - @@ -234,6 +146,12 @@ background:none; Qt::AlignCenter + + false + + + false + @@ -258,10 +176,6 @@ background:none; Qt::RightToLeft - - color:#ccc; -background:none; - X @@ -290,10 +204,6 @@ background:none; Qt::RightToLeft - - color:#ccc; -background:none; - Pitch @@ -338,10 +248,6 @@ background:none; Qt::RightToLeft - - color:#ccc; -background:none; - Y @@ -370,10 +276,6 @@ background:none; Qt::RightToLeft - - color:#ccc; -background:none; - Z @@ -466,10 +368,6 @@ background:none; Qt::RightToLeft - - color:#ccc; -background:none; - Yaw @@ -514,10 +412,6 @@ background:none; Qt::RightToLeft - - color:#ccc; -background:none; - Roll @@ -548,7 +442,7 @@ background:none; Profile - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + Qt::AlignCenter @@ -642,10 +536,6 @@ background:none; 16 - - color:#ccc; -background:none; - Not connected @@ -747,7 +637,7 @@ background:none; - Tracker Source + Main tracker Qt::AlignCenter @@ -888,7 +778,7 @@ background:none; - Tracker Source #2 + Auxiliary tracker Qt::AlignCenter @@ -1209,12 +1099,6 @@ background:none; 0 - - * { - color: white; -} - - Raw data @@ -1222,14 +1106,20 @@ background:none; true + + true + - 150 + 160 60 - 71 + 81 21 + + false + QFrame::NoFrame @@ -1240,24 +1130,33 @@ background:none; 0 - true + false + + + 7 - 2 + 7 QLCDNumber::Flat + + true + - 150 + 160 20 - 71 + 81 21 + + false + QFrame::NoFrame @@ -1268,10 +1167,13 @@ background:none; 0 - true + false + + + 7 - 2 + 7 QLCDNumber::Flat @@ -1286,10 +1188,6 @@ background:none; 16 - - border:none; -color:white - X @@ -1303,23 +1201,25 @@ color:white 16 - - border:none; -color:white; - Y + + true + - 30 + 40 60 - 61 + 71 21 + + false + QFrame::NoFrame @@ -1330,10 +1230,13 @@ color:white; 0 - true + false + + + 7 - 2 + 7 QLCDNumber::Flat @@ -1348,23 +1251,25 @@ color:white; 16 - - color:white; -border:none; - Z + + true + - 30 + 40 40 - 61 + 71 21 + + false + QFrame::NoFrame @@ -1375,10 +1280,13 @@ border:none; 0 - true + false + + + 7 - 2 + 7 QLCDNumber::Flat @@ -1387,16 +1295,12 @@ border:none; - 108 + 120 58 31 20 - - border:none; -color:white; - roll @@ -1404,16 +1308,12 @@ color:white; - 109 + 121 38 31 20 - - color:white; -border:none; - pitch @@ -1421,29 +1321,31 @@ border:none; - 108 + 120 18 31 20 - - border:none; -color:white; - yaw + + true + - 150 + 160 40 - 71 + 81 21 + + false + QFrame::NoFrame @@ -1454,26 +1356,32 @@ color:white; 0 - true + false + + + 7 - 2 + 7 QLCDNumber::Flat + + true + - 30 + 40 20 - 61 + 71 21 - - color: white; + + false QFrame::NoFrame @@ -1485,10 +1393,13 @@ color:white; 0 - true + false + + + 7 - 2 + 7 QLCDNumber::Flat @@ -1517,110 +1428,162 @@ color:white; 90 - + + + true + - 101 - 19 - 50 + 21 + 21 + 51 21 false - - color: rgb(0, 255, 0); - QFrame::NoFrame - QFrame::Raised + QFrame::Plain - + 1 + + false + + + 5 + + + 5 + QLCDNumber::Flat - + - 101 - 37 - 50 - 21 + 5 + 21 + 31 + 16 - - false - - - color: rgb(0, 255, 0); + + X - - QFrame::NoFrame + + + + true - - QFrame::Raised + + + 5 + 41 + 31 + 16 + - - 1 + + false - - QLCDNumber::Flat + + Y - + + + true + - 101 - 55 - 50 - 21 + 5 + 61 + 31 + 16 false - - color: rgb(0, 255, 0); + + Z - - QFrame::NoFrame + + + + + 69 + 61 + 51 + 16 + - - QFrame::Raised + + roll - - 1 + + + + + 71 + 21 + 51 + 16 + - - QLCDNumber::Flat + + yaw - + - 17 - 19 - 50 + 69 + 41 + 51 + 16 + + + + pitch + + + + + true + + + + 21 + 41 + 51 21 false - - color: rgb(0, 255, 0); - QFrame::NoFrame - QFrame::Raised + QFrame::Plain + + + 1 + + + false + + + 5 5 @@ -1629,26 +1592,35 @@ color:white; QLCDNumber::Flat - + + + true + - 17 - 37 - 50 + 21 + 61 + 51 21 false - - color: rgb(0, 255, 0); - QFrame::NoFrame - QFrame::Raised + QFrame::Plain + + + 1 + + + false + + + 5 5 @@ -1657,26 +1629,35 @@ color:white; QLCDNumber::Flat - + + + true + - 17 - 55 - 50 + 102 + 61 + 61 21 false - - color: rgb(0, 255, 0); - QFrame::NoFrame - QFrame::Raised + QFrame::Plain + + + 1 + + + false + + + 5 5 @@ -1685,100 +1666,78 @@ color:white; QLCDNumber::Flat - + + + true + - 9 - 20 - 31 - 16 + 102 + 21 + 61 + 21 - - color: rgb(0, 255, 0); + + false - - X + + QFrame::NoFrame - - - - - 10 - 40 - 31 - 16 - + + QFrame::Plain - - color: rgb(0, 255, 0); + + 1 - - Y + + false - - - - - 10 - 59 - 31 - 16 - + + 5 - - color: rgb(0, 255, 0); + + 5 - - Z + + QLCDNumber::Flat - + + + true + - 69 - 60 - 51 - 16 + 102 + 41 + 61 + 21 - - color: rgb(0, 255, 0); + + false - - roll + + QFrame::NoFrame - - - - - 71 - 21 - 51 - 16 - + + QFrame::Plain - - color: rgb(0, 255, 0); + + 1 - - yaw + + false - - - - - 69 - 41 - 51 - 16 - + + 5 - - color: rgb(0, 255, 0); + + 5 - - pitch + + QLCDNumber::Flat @@ -1822,7 +1781,6 @@ color:white; iconcomboProtocol - diff --git a/facetracknoir/ftnoir_keyboardshortcuts.ui b/facetracknoir/ftnoir_keyboardshortcuts.ui index 0bbd42ff..a189b680 100644 --- a/facetracknoir/ftnoir_keyboardshortcuts.ui +++ b/facetracknoir/ftnoir_keyboardshortcuts.ui @@ -16,43 +16,6 @@ 0 - - - - - - - 255 - 255 - 255 - - - - - - - - - 255 - 255 - 255 - - - - - - - - - 141 - 143 - 145 - - - - - - FaceTrackNoIR Keyboard and Mouse shortcuts -- cgit v1.2.3 From 6f757249bb9f3dc7b5f1a0fb892bc52a462c3f0a Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 16 Oct 2013 23:29:51 +0200 Subject: ui tweaks: lcd float display, linux camera path Signed-off-by: Stanislaw Halik --- facetracknoir/facetracknoir.cpp | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index 197e9fa6..0e7e25ec 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -264,6 +264,15 @@ void FaceTrackNoIR::GetCameraNameDX() { pEnumCat->Release(); } pSysDevEnum->Release(); +#else + for (int i = 0; i < 16; i++) { + char buf[128]; + sprintf(buf, "/dev/video%d", i); + if (access(buf, R_OK | W_OK) == 0) { + ui.cameraName->setText(QString(buf)); + break; + } + } #endif } @@ -753,14 +762,14 @@ void FaceTrackNoIR::showHeadPose() { const QString format("%1"); tracker->getHeadPose(newdata); - ui.lcdNumX->display(format.arg(newdata[TX], 0, 'f', 1)); - ui.lcdNumY->display(format.arg(newdata[TY], 0, 'f', 1)); - ui.lcdNumZ->display(format.arg(newdata[TZ], 0, 'f', 1)); + ui.lcdNumX->display(newdata[TX]); + ui.lcdNumY->display(newdata[TY]); + ui.lcdNumZ->display(newdata[TZ]); - ui.lcdNumRotX->display(format.arg(newdata[Yaw], 0, 'f', 1)); - ui.lcdNumRotY->display(format.arg(newdata[Pitch], 0, 'f', 1)); - ui.lcdNumRotZ->display(format.arg(newdata[Roll], 0, 'f', 1)); + ui.lcdNumRotX->display(newdata[Yaw]); + ui.lcdNumRotY->display(newdata[Pitch]); + ui.lcdNumRotZ->display(newdata[Roll]); // // Get the output-pose and also display it. @@ -769,13 +778,13 @@ void FaceTrackNoIR::showHeadPose() { ui.pose_display->rotateBy(newdata[Yaw], newdata[Roll], newdata[Pitch]); - ui.lcdNumOutputPosX->display(format.arg(newdata[TX], 0, 'f', 1)); - ui.lcdNumOutputPosY->display(format.arg(newdata[TY], 0, 'f', 1)); - ui.lcdNumOutputPosZ->display(format.arg(newdata[TZ], 0, 'f', 1)); + ui.lcdNumOutputPosX->display(newdata[TX]); + ui.lcdNumOutputPosY->display(newdata[TY]); + ui.lcdNumOutputPosZ->display(newdata[TZ]); - ui.lcdNumOutputRotX->display(format.arg(newdata[Yaw], 0, 'f', 1)); - ui.lcdNumOutputRotY->display(format.arg(newdata[Pitch], 0, 'f', 1)); - ui.lcdNumOutputRotZ->display(format.arg(newdata[Roll], 0, 'f', 1)); + ui.lcdNumOutputRotX->display(newdata[Yaw]); + ui.lcdNumOutputRotY->display(newdata[Pitch]); + ui.lcdNumOutputRotZ->display(newdata[Roll]); if (_curve_config) { _curve_config->update(); -- cgit v1.2.3 From da46cf18a2c7ad56c53e9c02014f75c818d39ea3 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 16 Oct 2013 23:30:47 +0200 Subject: change protocol ABI: sprinkle const. ABI BREAKAGE! Signed-off-by: Stanislaw Halik --- facetracknoir/tracker.cpp | 2 +- ftnoir_protocol_base/ftnoir_protocol_base.h | 2 +- ftnoir_protocol_fg/ftnoir_protocol_fg.cpp | 6 +----- ftnoir_protocol_fg/ftnoir_protocol_fg.h | 2 +- ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp | 2 +- ftnoir_protocol_ftn/ftnoir_protocol_ftn.cpp | 2 +- ftnoir_protocol_ftn/ftnoir_protocol_ftn.h | 6 +++--- ftnoir_protocol_ftn/ftnoir_protocol_ftn_dialog.cpp | 2 +- ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.cpp | 2 +- ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.h | 4 ++-- ftnoir_protocol_wine/ftnoir_protocol_wine.cpp | 2 +- ftnoir_protocol_wine/ftnoir_protocol_wine.h | 8 ++++---- 12 files changed, 18 insertions(+), 22 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/tracker.cpp b/facetracknoir/tracker.cpp index 53b3ffd3..25b42ece 100644 --- a/facetracknoir/tracker.cpp +++ b/facetracknoir/tracker.cpp @@ -149,7 +149,7 @@ void Tracker::run() { // Send the headpose to the game if (Libraries->pProtocol) { gameoutput_camera = output_camera; - Libraries->pProtocol->sendHeadposeToGame( gameoutput_camera.axes, newpose ); // degrees & centimeters + Libraries->pProtocol->sendHeadposeToGame( gameoutput_camera.axes ); // degrees & centimeters } } } diff --git a/ftnoir_protocol_base/ftnoir_protocol_base.h b/ftnoir_protocol_base/ftnoir_protocol_base.h index 79f0800c..5db49f01 100644 --- a/ftnoir_protocol_base/ftnoir_protocol_base.h +++ b/ftnoir_protocol_base/ftnoir_protocol_base.h @@ -41,7 +41,7 @@ struct IProtocol { virtual ~IProtocol() {} virtual bool checkServerInstallationOK() = 0; - virtual void sendHeadposeToGame( double *headpose, double *rawheadpose ) = 0; + virtual void sendHeadposeToGame( const double* headpose ) = 0; virtual QString getGameName() = 0; }; diff --git a/ftnoir_protocol_fg/ftnoir_protocol_fg.cpp b/ftnoir_protocol_fg/ftnoir_protocol_fg.cpp index 5aa3487e..08e7370b 100644 --- a/ftnoir_protocol_fg/ftnoir_protocol_fg.cpp +++ b/ftnoir_protocol_fg/ftnoir_protocol_fg.cpp @@ -63,11 +63,7 @@ void FTNoIR_Protocol::loadSettings() { } -void FTNoIR_Protocol::sendHeadposeToGame( double *headpose, double *rawheadpose ) { - int no_bytes; - QHostAddress sender; - quint16 senderPort; - +void FTNoIR_Protocol::sendHeadposeToGame(const double* headpose) { FlightData.x = headpose[TX] * 1e-2; FlightData.y = headpose[TY] * 1e-2; FlightData.z = headpose[TZ] * 1e-2; diff --git a/ftnoir_protocol_fg/ftnoir_protocol_fg.h b/ftnoir_protocol_fg/ftnoir_protocol_fg.h index f399904b..43d1b05a 100644 --- a/ftnoir_protocol_fg/ftnoir_protocol_fg.h +++ b/ftnoir_protocol_fg/ftnoir_protocol_fg.h @@ -46,7 +46,7 @@ public: FTNoIR_Protocol(); ~FTNoIR_Protocol(); bool checkServerInstallationOK(); - void sendHeadposeToGame( double *headpose, double *rawheadpose ); + void sendHeadposeToGame(const double *headpose); QString getGameName() { return "FlightGear"; } diff --git a/ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp b/ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp index cefc9bf8..45123540 100644 --- a/ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp +++ b/ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp @@ -91,7 +91,7 @@ void FGControls::doOK() { } // override show event -void FGControls::showEvent ( QShowEvent * event ) { +void FGControls::showEvent ( QShowEvent * ) { loadSettings(); } diff --git a/ftnoir_protocol_ftn/ftnoir_protocol_ftn.cpp b/ftnoir_protocol_ftn/ftnoir_protocol_ftn.cpp index 3d04dfd0..80cbfa0a 100644 --- a/ftnoir_protocol_ftn/ftnoir_protocol_ftn.cpp +++ b/ftnoir_protocol_ftn/ftnoir_protocol_ftn.cpp @@ -66,7 +66,7 @@ void FTNoIR_Protocol::loadSettings() { // // Update Headpose in Game. // -void FTNoIR_Protocol::sendHeadposeToGame(double *headpose, double *rawheadpose ) { +void FTNoIR_Protocol::sendHeadposeToGame(const double *headpose) { int no_bytes; double test_data[6]; // diff --git a/ftnoir_protocol_ftn/ftnoir_protocol_ftn.h b/ftnoir_protocol_ftn/ftnoir_protocol_ftn.h index 4c1c34cd..4e814ddf 100644 --- a/ftnoir_protocol_ftn/ftnoir_protocol_ftn.h +++ b/ftnoir_protocol_ftn/ftnoir_protocol_ftn.h @@ -45,7 +45,7 @@ public: FTNoIR_Protocol(); ~FTNoIR_Protocol(); bool checkServerInstallationOK(); - void sendHeadposeToGame( double *headpose, double *rawheadpose ); + void sendHeadposeToGame(const double *headpose); QString getGameName() { return "UDP Tracker"; } @@ -65,9 +65,9 @@ public: explicit FTNControls(); virtual ~FTNControls(); - void showEvent ( QShowEvent * event ); + void showEvent (QShowEvent *); void Initialize(QWidget *parent); - void registerProtocol(IProtocol *protocol) {} + void registerProtocol(IProtocol *) {} void unRegisterProtocol() {} private: diff --git a/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dialog.cpp b/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dialog.cpp index 0b61fd48..3b4e851c 100644 --- a/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dialog.cpp +++ b/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dialog.cpp @@ -84,7 +84,7 @@ void FTNControls::doOK() { } // override show event -void FTNControls::showEvent ( QShowEvent * event ) { +void FTNControls::showEvent ( QShowEvent * ) { loadSettings(); } diff --git a/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.cpp b/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.cpp index fc01552e..70fde395 100644 --- a/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.cpp +++ b/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.cpp @@ -70,7 +70,7 @@ FTNoIR_Protocol::~FTNoIR_Protocol() libevdev_free(dev); } -void FTNoIR_Protocol::sendHeadposeToGame( double *headpose, double *rawheadpose ) { +void FTNoIR_Protocol::sendHeadposeToGame(const double* headpose) { static const int axes[] = { /* translation goes first */ ABS_X, ABS_Y, ABS_Z, ABS_RX, ABS_RY, ABS_RZ diff --git a/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.h b/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.h index e753269e..3c6f591c 100644 --- a/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.h +++ b/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.h @@ -25,7 +25,7 @@ public: bool checkServerInstallationOK() { return dev != NULL; } - void sendHeadposeToGame( double *headpose, double *rawheadpose ); + void sendHeadposeToGame(const double *headpose); QString getGameName() { return "Virtual joystick for Linux"; } @@ -45,7 +45,7 @@ public: void showEvent ( QShowEvent *) {} void Initialize(QWidget *); - void registerProtocol(IProtocol *l) {} + void registerProtocol(IProtocol *) {} void unRegisterProtocol() {} private: diff --git a/ftnoir_protocol_wine/ftnoir_protocol_wine.cpp b/ftnoir_protocol_wine/ftnoir_protocol_wine.cpp index 698c2236..c5d0754f 100644 --- a/ftnoir_protocol_wine/ftnoir_protocol_wine.cpp +++ b/ftnoir_protocol_wine/ftnoir_protocol_wine.cpp @@ -25,7 +25,7 @@ FTNoIR_Protocol::~FTNoIR_Protocol() shm_unlink("/" WINE_SHM_NAME); } -void FTNoIR_Protocol::sendHeadposeToGame( double *headpose, double *rawheadpose ) { +void FTNoIR_Protocol::sendHeadposeToGame( const double *headpose ) { if (shm) { lck_shm.lock(); diff --git a/ftnoir_protocol_wine/ftnoir_protocol_wine.h b/ftnoir_protocol_wine/ftnoir_protocol_wine.h index 300501ad..01bfc93d 100644 --- a/ftnoir_protocol_wine/ftnoir_protocol_wine.h +++ b/ftnoir_protocol_wine/ftnoir_protocol_wine.h @@ -51,7 +51,7 @@ public: ~FTNoIR_Protocol(); bool checkServerInstallationOK(); - void sendHeadposeToGame(double* headpose, double* rawheadpose ); + void sendHeadposeToGame(const double* headpose); QString getGameName() { QMutexLocker foo(&game_name_mutex); return connected_game; @@ -72,9 +72,9 @@ class FTControls: public QWidget, public IProtocolDialog public: FTControls(); - void showEvent ( QShowEvent * event ) {show();} - void Initialize(QWidget *parent) {show();} - void registerProtocol(IProtocol *protocol) {} + void showEvent ( QShowEvent * ) {show();} + void Initialize(QWidget *) {show();} + void registerProtocol(IProtocol *) {} void unRegisterProtocol() {} private: -- cgit v1.2.3 From d3ea7c225cf583e2ee243279ee9135ea49b3fecb Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 17 Oct 2013 01:18:25 +0200 Subject: regen Signed-off-by: Stanislaw Halik --- facetracknoir/facetracknoir.ui | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.ui b/facetracknoir/facetracknoir.ui index e17fa30b..39087c2c 100644 --- a/facetracknoir/facetracknoir.ui +++ b/facetracknoir/facetracknoir.ui @@ -39,7 +39,7 @@ FaceTrackNoIR - + :/images/facetracknoir.png:/images/facetracknoir.png @@ -1781,6 +1781,7 @@ iconcomboProtocol + -- cgit v1.2.3 From 250ba4c465088f2ed03be8b967683fea1b5bd28e Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 17 Oct 2013 01:18:30 +0200 Subject: fix size Signed-off-by: Stanislaw Halik --- facetracknoir/ftnoir_curves.ui | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/ftnoir_curves.ui b/facetracknoir/ftnoir_curves.ui index 83b514b5..46a1892c 100644 --- a/facetracknoir/ftnoir_curves.ui +++ b/facetracknoir/ftnoir_curves.ui @@ -6,10 +6,16 @@ 0 0 - 1042 - 659 + 980 + 655 + + + 0 + 0 + + FaceTrackNoIR tracking curves @@ -20,13 +26,8 @@ Qt::LeftToRight - - false - - - - + -- cgit v1.2.3 From 383c832723691506351b02b5ccac7e9cd26f4583 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 17 Oct 2013 03:15:43 +0200 Subject: fix UI after changes Signed-off-by: Stanislaw Halik --- facetracknoir/facetracknoir.cpp | 9 +- facetracknoir/facetracknoir.h | 2 +- facetracknoir/facetracknoir.ui | 3099 +++++++++++++++++++-------------------- 3 files changed, 1487 insertions(+), 1623 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index 0e7e25ec..bec35522 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -121,9 +121,6 @@ FaceTrackNoIR::FaceTrackNoIR(QWidget *parent, Qt::WindowFlags flags) : // it gets initialized and pulls in QSettings before // main() starts. program can and will crash. - ui.headPoseWidget->show(); - ui.video_frame->hide(); - // menu objects will be connected with the functions in FaceTrackNoIR class connect(ui.btnLoad, SIGNAL(clicked()), this, SLOT(open())); connect(ui.btnSave, SIGNAL(clicked()), this, SLOT(save())); @@ -202,8 +199,8 @@ FaceTrackNoIR::~FaceTrackNoIR() { // // Get a pointer to the video-widget, to use in the DLL // -QFrame *FaceTrackNoIR::get_video_widget() { - return ui.video_frame; +QFrame* FaceTrackNoIR::get_video_widget() { + return ui.video_frame; } /** read the name of the first video-capturing device at start up **/ @@ -630,7 +627,7 @@ void FaceTrackNoIR::startTracker( ) { tracker->start(); - ui.headPoseWidget->show(); + ui.video_frame->show(); // ui.btnStartTracker->setEnabled ( false ); diff --git a/facetracknoir/facetracknoir.h b/facetracknoir/facetracknoir.h index bfeb2d38..c5b2dc01 100644 --- a/facetracknoir/facetracknoir.h +++ b/facetracknoir/facetracknoir.h @@ -103,7 +103,7 @@ public slots: private: HeadPoseData pose; - Ui::FaceTrackNoIRClass ui; + Ui::OpentrackUI ui; QTimer timUpdateHeadPose; // Timer to display headpose QStringList iniFileList; // List of INI-files, that are present in the Settings folder diff --git a/facetracknoir/facetracknoir.ui b/facetracknoir/facetracknoir.ui index 39087c2c..cc5891bf 100644 --- a/facetracknoir/facetracknoir.ui +++ b/facetracknoir/facetracknoir.ui @@ -1,8 +1,8 @@ WVR - FaceTrackNoIRClass - + OpentrackUI + Qt::NonModal @@ -10,33 +10,33 @@ 0 0 - 880 - 380 + 788 + 554 - + 0 0 - 880 - 380 + 0 + 0 - 880 - 380 + 65536 + 65536 Qt::DefaultContextMenu - FaceTrackNoIR + opentrack @@ -59,1695 +59,1426 @@ - + 0 0 - 874 - 380 + 0 + 0 + + + + + 65535 + 65535 - - - true - + - 250 - 0 - 738 - 431 + 5 + 170 + 320 + 240 - + 0 0 - 400 - 419 + 250 + 187 - - false - - - + + + 65536 + 65536 + - - + + 0 - - - - 20 - 10 - 400 - 25 - - - - - 400 - 25 - - - - - 600 - 30 - - - - - - - - - - 320 - 70 - 231 - 101 - - - - Axis inversion - - - Qt::AlignCenter - - - false - - - false - - - - - 130 - 29 - 41 - 16 - - - - - 25 - 0 - - - - - 150 - 16777215 - - - - Qt::RightToLeft - - - X - - - - - - 20 - 50 - 61 - 16 - - - - - 40 - 0 - - - - - 65536 - 16777215 - - - - Qt::RightToLeft - - - Pitch - - - - - - 90 - 50 - 16 - 16 - - - - background:none; - - - - - - - - - 130 - 48 - 41 - 16 - - - - - 25 - 0 - - - - - 150 - 16777215 - - - - Qt::RightToLeft - - - Y - - - - - - 130 - 67 - 41 - 16 - - - - - 25 - 0 - - - - - 150 - 16777215 - - - - Qt::RightToLeft - - - Z - - - - - - 192 - 67 - 16 - 16 - - - - background:none; - - - - - - - - - 192 - 48 - 16 - 16 - - - - background:none; - - - - - - - - - 90 - 69 - 16 - 16 - - - - background:none; - - - - - - - - - 192 - 29 - 16 - 16 - - - - background:none; - - - - - - - - - 20 - 31 - 61 - 16 - - - - - 40 - 0 - - - - - 65536 - 16777215 - - - - Qt::RightToLeft - - - Yaw - - - - - - 90 - 31 - 16 - 16 - - - - background:none; - - - - - - - - - 20 - 69 - 61 - 16 - - - - - 40 - 0 - - - - - 65536 - 16777215 - - - - Qt::RightToLeft - - - Roll - - - - - - - 20 - 70 - 271 - 120 - - - - - 206 - 120 - - - - - 65535 - 65535 - - - - Profile - - - Qt::AlignCenter - - - - - 10 - 20 - 251 - 22 - - - - - - - -1 - - - 10 - - - - - true - - - - 10 - 80 - 251 - 23 - - - - Save the INI-file under another name - - - - - - Save As ... - - - - - - 10 - 50 - 111 - 23 - - - - Load an INI-file from a folder - - - - - - Load - - - - - true - - - - 130 - 50 - 131 - 23 - - - - Save the current INI-file - - - - - - Save - - - - - - - 20 - 40 - 411 - 16 - - - - Not connected - - - - - - 440 - 201 - 180 - 80 - - - - - 180 - 80 - - - - - 180 - 80 - - - - - - - Game protocol - - - Qt::AlignCenter - - - - - 10 - 20 - 161 - 22 - - - - - - - -1 - - - 7 - - - - - true - - - - 10 - 50 - 161 - 23 - - - - Change game protocol settings - - - - - - Settings - - - - - - - 20 - 201 - 200 - 80 - - - - - 200 - 80 - - - - - 200 - 80 - - - - - - - Main tracker - - - Qt::AlignCenter - - - - - 10 - 20 - 180 - 22 - - - - - - - -1 - - - 42 - - - - - true - - - - 10 - 50 - 180 - 23 - - - - Change tracker settings - - - - - - Settings - - - - - - - 230 - 201 - 180 - 80 - - - - - 180 - 80 - - - - - 180 - 65536 - - - - - - - Filter - - - Qt::AlignCenter - - - - - 10 - 20 - 161 - 22 - - - - - - - -1 - - - 7 - - - - - true - - - - 10 - 50 - 161 - 23 - - - - Change game protocol settings - - - - - - Settings - - - - - - - 20 - 289 - 200 - 80 - - - - - 200 - 80 - - - - - 200 - 80 - - - - Auxiliary tracker - - - Qt::AlignCenter - - - - true - - - - 10 - 50 - 180 - 23 - - - - Change tracker settings - - - - - - Settings - - - - - - 10 - 20 - 180 - 22 - - - - - - - -1 - - - 42 - - - - - - - 230 - 289 - 200 - 61 - - - - - 200 - 0 - - - - - 16777215 - 80 - - - - GO! - - - Qt::AlignCenter - - - - - 10 - 30 - 81 - 21 - - - - Start the Tracker - - - - - - Start - - - - - false - - - - 100 - 30 - 81 - 21 - - - - Stop the Tracker - - - - - - Stop - - - - + - 440 - 288 - 171 - 38 + 0 + -10 + 320 + 240 - + 0 0 - 62 - 38 - - - - - 200 - 16777215 - - - - PointingHandCursor - - - Edit the Keyboard and mouse shortcuts - - - Shortcuts - - - - :/uielements/tools.png:/uielements/tools.png - - - - 24 - 24 - - - - - - - 440 - 332 - 171 - 38 - - - - - 62 - 38 + 0 + 0 - 200 - 16777215 - - - - PointingHandCursor - - - Edit the Curve settings - - - Qt::LeftToRight - - - background:none; - - - Curves - - - - :/uielements/curves.png:/uielements/curves.png - - - - 120 - 24 + 65536 + 65536 - + - 0 - 89 - 250 - 187 + 120 + 40 + 203 + 97 - - - 0 - 0 - - - 250 - 187 + 0 + 0 - 250 - 187 + 65536 + 65536 - - QFrame::NoFrame + + - - QFrame::Plain + + Qt::AlignJustify|Qt::AlignVCenter - - 0 + + false - - - - 0 - 0 - 250 - 187 - - - - - 0 - 0 - - - - - 250 - 187 - - - - - 250 - 187 - - - + + + + + true + + + + 65536 + 65536 + + + + false + + + Y + + + + + + + true + + + + 65536 + 65536 + + + + false + + + QFrame::NoFrame + + + QFrame::Plain + + + 1 + + + false + + + 5 + + + QLCDNumber::Filled + + + + + + + true + + + + 65536 + 65536 + + + + false + + + QFrame::NoFrame + + + QFrame::Plain + + + 1 + + + false + + + 5 + + + QLCDNumber::Filled + + + + + + + true + + + + 65536 + 65536 + + + + false + + + QFrame::NoFrame + + + QFrame::Plain + + + 1 + + + false + + + 5 + + + QLCDNumber::Filled + + + + + + + true + + + + 65536 + 65536 + + + + false + + + Z + + + + + + + + 65536 + 65536 + + + + pitch + + + + + + + true + + + + 65536 + 65536 + + + + false + + + QFrame::NoFrame + + + QFrame::Plain + + + 1 + + + false + + + 5 + + + QLCDNumber::Filled + + + + + + + + 65536 + 65536 + + + + X + + + + + + + + 65536 + 65536 + + + + roll + + + + + + + true + + + + 65536 + 65536 + + + + false + + + QFrame::NoFrame + + + QFrame::Plain + + + 1 + + + false + + + 5 + + + QLCDNumber::Filled + + + + + + + true + + + + 65536 + 65536 + + + + false + + + QFrame::NoFrame + + + QFrame::Plain + + + 1 + + + false + + + 5 + + + QLCDNumber::Filled + + + + + + + + 65536 + 65536 + + + + yaw + + + + - + - 0 - 275 - 261 - 141 + 10 + 40 + 90 + 100 + + + 0 + 0 + + 0 - 100 + 0 - 16777215 - 160 + 65536 + 65536 - - - - - - - 10 - 12 - 231 - 169 - - - - - 0 - 0 - - - - - 0 - 0 - - - - Raw data - - - true - - - - true - - - - 160 - 60 - 81 - 21 - - - - false - - - QFrame::NoFrame - - - 0 - - - 0 - - - false - - - 7 - - - 7 - - - QLCDNumber::Flat - - - - - true - - - - 160 - 20 - 81 - 21 - - - - false - - - QFrame::NoFrame - - - 0 - - - 0 - - - false - - - 7 - - - 7 - - - QLCDNumber::Flat - - - - - - 10 - 20 - 21 - 16 - - - - X - - - - - - 10 - 40 - 21 - 16 - - - - Y - - - - - true - - - - 40 - 60 - 71 - 21 - - - - false - - - QFrame::NoFrame - - - 0 - - - 0 - - - false - - - 7 - - - 7 - - - QLCDNumber::Flat - - - - - - 10 - 60 - 21 - 16 - - - - Z - - - - - true - - - - 40 - 40 - 71 - 21 - - - - false - - - QFrame::NoFrame - - - 0 - - - 0 - - - false - - - 7 - - - 7 - - - QLCDNumber::Flat - - - - - - 120 - 58 - 31 - 20 - - - - roll - - - - - - 121 - 38 - 31 - 20 - - - - pitch - - - - - - 120 - 18 - 31 - 20 - - - - yaw - - - - - true - - - - 160 - 40 - 81 - 21 - - - - false - - - QFrame::NoFrame - - - 0 - - - 0 - - - false - - - 7 - - - 7 - - - QLCDNumber::Flat - - - - - true - - - - 40 - 20 - 71 - 21 - - - - false - - - QFrame::NoFrame - - - 0 - - - 0 - - - false - - - 7 - - - 7 - - - QLCDNumber::Flat - - - - + - 90 - 0 - 160 - 90 + 350 + 370 + 191 + 80 - 160 - 90 + 180 + 80 - 16777215 - 90 + 65536 + 65536 - - - true - - - - 21 - 21 - 51 - 21 - - - - false - - - QFrame::NoFrame - - - QFrame::Plain - - - 1 - - - false - - - 5 - - - 5 - - - QLCDNumber::Flat - - - - - - 5 - 21 - 31 - 16 - - - - X - - - - - true - - - - 5 - 41 - 31 - 16 - - - - false - - - Y - - - - - true - - - - 5 - 61 - 31 - 16 - - - - false - - - Z - - - - - - 69 - 61 - 51 - 16 - - - - roll - - - - - - 71 - 21 - 51 - 16 - - - - yaw - - - - - - 69 - 41 - 51 - 16 - - - - pitch - - - - - true - - - - 21 - 41 - 51 - 21 - - - - false - - - QFrame::NoFrame - - - QFrame::Plain - - - 1 - - - false - - - 5 - - - 5 - - - QLCDNumber::Flat - - - - - true - - - - 21 - 61 - 51 - 21 - - - - false - - - QFrame::NoFrame - - - QFrame::Plain - - - 1 - - - false - - - 5 - - - 5 - - - QLCDNumber::Flat - - - - - true - - - - 102 - 61 - 61 - 21 - - - - false - - - QFrame::NoFrame - - - QFrame::Plain - - - 1 - - - false - - - 5 - - - 5 - - - QLCDNumber::Flat - - - - - true - - - - 102 - 21 - 61 - 21 - - - - false - - - QFrame::NoFrame - - - QFrame::Plain - - - 1 - - - false - - - 5 - - - 5 - - - QLCDNumber::Flat - - - - - true - - - - 102 - 41 - 61 - 21 - - - - false - - - QFrame::NoFrame - - - QFrame::Plain - - - 1 - - - false - - - 5 - - - 5 - - - QLCDNumber::Flat - - + + + + + Game protocol + + + Qt::AlignCenter + + + false + + + false + + + + QLayout::SetDefaultConstraint + + + 6 + + + + + + 65536 + 65536 + + + + + + + -1 + + + 7 + + + + + + + true + + + + 65536 + 65536 + + + + Change game protocol settings + + + + + + Settings + + + + - + - 0 - 0 - 90 - 90 + 580 + 470 + 171 + 38 + + + + + 62 + 38 + + + + + 65536 + 65536 + + + + PointingHandCursor + + + Edit the Curve settings + + + Qt::LeftToRight + + + background:none; + + + Curves + + + + :/uielements/curves.png:/uielements/curves.png + + + + 120 + 24 + + + + + + + 350 + 36 + 371 + 20 + + + + + 65536 + 65536 + + + + Not connected + + + + + + 350 + 262 + 191 + 91 + + + + + 180 + 80 + + + + + 65536 + 65536 + + + + + + + Filter + + + Qt::AlignCenter + + + false + + + false + + + + QLayout::SetDefaultConstraint + + + + + + 65536 + 65536 + + + + + + + -1 + + + 7 + + + + + + + true + + + + 65536 + 65536 + + + + Change game protocol settings + + + + + + Settings + + + + + + + + + 350 + 70 + 191 + 83 + + + + + 0 + 0 + + + + + 65536 + 65536 + + + + + + + Main tracker + + + Qt::AlignCenter + + + false + + + false + + + + QLayout::SetDefaultConstraint + + + + + + 65536 + 65536 + + + + + + + -1 + + + 42 + + + + + + + true + + + + 65536 + 65536 + + + + Change tracker settings + + + + + + Settings + + + + + + + + + 20 + 420 + 321 + 131 + + + + + 0 + 0 + + + + + 0 + 0 + + + + + 65536 + 65536 + + + + Raw data + + + false + + + + 6 + + + + + + 65536 + 65536 + + + + TX + + + + + + + true + + + + 65536 + 65536 + + + + false + + + QFrame::NoFrame + + + 0 + + + 0 + + + false + + + 5 + + + QLCDNumber::Flat + + + + + + + + 65536 + 65536 + + + + yaw + + + + + + + true + + + + 65536 + 65536 + + + + false + + + QFrame::NoFrame + + + 0 + + + 0 + + + false + + + 5 + + + QLCDNumber::Flat + + + + + + + + 65536 + 65536 + + + + TX + + + + + + + true + + + + 65536 + 65536 + + + + false + + + QFrame::NoFrame + + + 0 + + + 0 + + + false + + + 5 + + + QLCDNumber::Flat + + + + + + + + 65536 + 65536 + + + + pitch + + + + + + + true + + + + 65536 + 65536 + + + + false + + + QFrame::NoFrame + + + 0 + + + 0 + + + false + + + 5 + + + QLCDNumber::Flat + + + + + + + + 65536 + 65536 + + + + TX + + + + + + + true + + + + 65536 + 65536 + + + + false + + + QFrame::NoFrame + + + 0 + + + 0 + + + false + + + 5 + + + QLCDNumber::Flat + + + + + + + + 65536 + 65536 + + + + roll + + + + + + + true + + + + 65536 + 65536 + + + + false + + + QFrame::NoFrame + + + 0 + + + 0 + + + false + + + 5 + + + QLCDNumber::Flat + + + + + + + + + 350 + 10 + 371 + 25 + + + + + 0 + 0 + + + + + 65536 + 65536 + + + + + + + + + + 600 + 240 + 124 + 117 + + + + + 65536 + 65536 + + + + + true + + + + Axis inversion + + + Qt::AlignCenter + + + false + + + false + + + + QLayout::SetMinAndMaxSize + + + 6 + + + + + + 65536 + 65536 + + + + Qt::RightToLeft + + + background:none; + + + Yaw + + + + + + + + 65536 + 65536 + + + + Qt::RightToLeft + + + background:none; + + + TX + + + + + + + + 65536 + 65536 + + + + Qt::RightToLeft + + + false + + + background:none; + + + Pitch + + + + + + + + 65536 + 65536 + + + + Qt::RightToLeft + + + background:none; + + + TY + + + + + + + + 65536 + 65536 + + + + Qt::RightToLeft + + + background:none; + + + Roll + + + + + + + + 65536 + 65536 + + + + Qt::RightToLeft + + + background:none; + + + TZ + + + + + + + + + 350 + 180 + 191 + 83 + + + + + 0 + 0 + + + + + 65536 + 65536 + + + + Auxiliary tracker + + + Qt::AlignCenter + + + false + + + false + + + + QLayout::SetDefaultConstraint + + + + + + 65536 + 65536 + + + + + + + -1 + + + 42 + + + + + + + true + + + + 65536 + 65536 + + + + Change tracker settings + + + + + + Settings + + + + + + + + + 350 + 470 + 190 + 65 + + + + + 0 + 0 + + + + + 65536 + 65536 + + + + GO! + + + Qt::AlignCenter + + + + QLayout::SetMinimumSize + + + 6 + + + + + + 65536 + 65536 + + + + Start the Tracker + + + + + + Start + + + + + + + false + + + + 65536 + 65536 + + + + Stop the Tracker + + + + + + Stop + + + + + + + + + 580 + 420 + 171 + 38 @@ -1756,12 +1487,155 @@ 0 + + + 62 + 38 + + + + + 65536 + 65536 + + + + PointingHandCursor + + + Edit the Keyboard and mouse shortcuts + + + Shortcuts + + + + :/uielements/tools.png:/uielements/tools.png + + + + 24 + 24 + + + + + + + 550 + 60 + 231 + 123 + + 0 0 + + + 65536 + 65536 + + + + Profile + + + Qt::AlignCenter + + + + QLayout::SetDefaultConstraint + + + 6 + + + + + + 65536 + 65536 + + + + + + + -1 + + + 10 + + + + + + + + 65536 + 65536 + + + + Load an INI-file from a folder + + + + + + Load + + + + + + + true + + + + 65536 + 65536 + + + + Save the current INI-file + + + + + + Save + + + + + + + true + + + + 65536 + 65536 + + + + Save the INI-file under another name + + + + + + Save As ... + + + + @@ -1773,13 +1647,6 @@
glwidget.h
- - iconcomboTrackerSource - btnStartTracker - btnStopTracker - btnShowEngineControls - iconcomboProtocol - -- cgit v1.2.3 From 8f23371ba8e894f5301cdccdce5e49e86a0222f8 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 17 Oct 2013 20:15:21 +0200 Subject: hardcode colors, since qt tabpage is somewhat 'special' Signed-off-by: Stanislaw Halik --- facetracknoir/curve-config.cpp | 6 +- facetracknoir/curve-config.h | 1 + facetracknoir/facetracknoir.cpp | 1 + facetracknoir/ftnoir_curves.ui | 1693 +++++++++++------------ qfunctionconfigurator/qfunctionconfigurator.cpp | 4 +- 5 files changed, 841 insertions(+), 864 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/curve-config.cpp b/facetracknoir/curve-config.cpp index 117e5803..50aa8acf 100644 --- a/facetracknoir/curve-config.cpp +++ b/facetracknoir/curve-config.cpp @@ -2,15 +2,13 @@ #include "facetracknoir/curve-config.h" #include CurveConfigurationDialog::CurveConfigurationDialog(FaceTrackNoIR *ftnoir, QWidget *parent) : -QWidget( parent, Qt::Dialog ) + QWidget( parent, Qt::Dialog ), mainApp(ftnoir) { ui.setupUi( this ); - QPoint offsetpos(120, 30); + QPoint offsetpos(120, 30); this->move(parent->pos() + offsetpos); - mainApp = ftnoir; // Preserve a pointer to FTNoIR - // Connect Qt signals to member-functions connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); diff --git a/facetracknoir/curve-config.h b/facetracknoir/curve-config.h index a9073840..d2acf371 100644 --- a/facetracknoir/curve-config.h +++ b/facetracknoir/curve-config.h @@ -1,5 +1,6 @@ #pragma once #include +#include #include "ui_ftnoir_curves.h" class FaceTrackNoIR; diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index bec35522..b5ccfdff 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -105,6 +105,7 @@ FaceTrackNoIR::FaceTrackNoIR(QWidget *parent, Qt::WindowFlags flags) : looping(false) { ui.setupUi(this); + setFixedSize(size()); // // Initialize Widget handles, to prevent memory-access errors. diff --git a/facetracknoir/ftnoir_curves.ui b/facetracknoir/ftnoir_curves.ui index 46a1892c..d9198a76 100644 --- a/facetracknoir/ftnoir_curves.ui +++ b/facetracknoir/ftnoir_curves.ui @@ -6,7 +6,7 @@ 0 0 - 980 + 970 655
@@ -27,847 +27,841 @@ Qt::LeftToRight
- + background-color: #ccc; - - - - - - - - - - 0 - - - - Yaw - - - - - 0 - 0 - 921 - 240 - - - - 180 - - - 180 - - - 5 - - - - 255 - 0 - 0 - - - - - 240 - 240 - 240 - - - - - - - 0 - 280 - 166 - 21 - - - - Use alternative - - - - - - 0 - 340 - 921 - 240 - - - - 180 - - - 180 - - - 5 - - - - 255 - 0 - 0 - - - - - 255 - 255 - 255 - - - - - - - Pitch - - - - - 0 - 0 - 595 - 240 - - - - 90 - - - 90 - - - 10 - - - 2 - - - - 0 - 255 - 0 - - - - - 240 - 240 - 240 - - - - - - - 0 - 280 - 199 - 21 - - - - Use alternative - - - - - - 0 - 340 - 1013 - 240 - - - - 90 - - - 90 - - - 10 - - - 2 - - - - 0 - 255 - 0 - - - - - 240 - 240 - 240 - - - - - - - Roll - - - - - 0 - 0 - 595 - 240 - - - - 180 - - - 180 - - - 5 - - - 1 - - - - 0 - 0 - 255 - - - - - 240 - 240 - 240 - - - - - - - 0 - 280 - 271 - 21 - - - - Use alternative - - - - - - 0 - 340 - 595 - 240 - - - - 180 - - - 180 - - - 5 - - - 1 - - - - 0 - 0 - 255 - - - - - 240 - 240 - 240 - - - - - - - X - - - - - 0 - 0 - 555 - 270 - - - - 100 - - - 100 - - - 7 - - - 2 - - - - 255 - 0 - 255 - - - - - 240 - 240 - 240 - - - - - - - 0 - 280 - 228 - 21 - - - - Use alternative - - - - - - 0 - 310 - 555 - 160 - - - - 100 - - - 100 - - - 7 - - - 2 - - - - 255 - 0 - 255 - - - - - 240 - 240 - 240 - - - - - - - Y - - - - - 0 - 0 - 555 - 160 - - - - 100 - - - 100 - - - 7 - - - 2 - - - - 255 - 255 - 0 - - - - - 240 - 240 - 240 - - - - - - - 0 - 280 - 229 - 21 - - - - Use alternative - - - - - - 0 - 310 - 555 - 160 - - - - 100 - - - 100 - - - 7 - - - 2 - - - - 255 - 255 - 0 - - - - - 240 - 240 - 240 - - - - - - - Z - - - - - 0 - 0 - 555 - 160 - - - - 100 - - - 100 - - - 7 - - - 2 - - - - 0 - 255 - 255 - - - - - 240 - 240 - 240 - - - - - - - 0 - 280 - 263 - 21 - - - - Use alternative - - - - - - 0 - 310 - 555 - 160 - - - - 100 - - - 100 - - - 7 - - - 2 - - - - 0 - 255 - 255 - - - - - 240 - 240 - 240 - - - - - - - Positions - - - - - 10 - 44 - 35 - 16 - - - - RY - - - - - - 10 - 10 - 34 - 20 - - - - RX - - - - - - 9 - 75 - 33 - 16 - - - - RZ - - - - - - 50 - 10 - 131 - 22 - - - - deg. - - - 3 - - - -180.000000000000000 - - - 180.000000000000000 - - - - - - 50 - 40 - 131 - 22 - - - - deg. - - - 3 - - - -180.000000000000000 - - - 180.000000000000000 - - - - - - 49 - 71 - 131 - 22 - - - - deg. - - - 3 - - - -180.000000000000000 - - - 180.000000000000000 - - - - - - 209 - 10 - 32 - 20 - - - - TX - - - - - - 249 - 10 - 152 - 22 - - - - cm - - - 3 - - - -100.000000000000000 - - - 100.000000000000000 - - - - - - 249 - 40 - 152 - 22 - - - - cm - - - 3 - - - -100.000000000000000 - - - 100.000000000000000 - - - - - - 248 - 71 - 154 - 22 - - - - cm - - - 3 - - - -100.000000000000000 - - - 100.000000000000000 - - - - - - 209 - 44 - 32 - 16 - - - - TY - - - - - - 208 - 75 - 35 - 16 - - - - TZ - - - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - QLayout::SetDefaultConstraint - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 100 - 16777215 - - - - OK - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 100 - 16777215 - - - - Cancel - - - - - - - - + + + + 810 + 625 + 72 + 24 + + + + + 0 + 0 + + + + + 0 + 0 + + + + + 100 + 16777215 + + + + + + + OK + + + + + + 886 + 625 + 69 + 24 + + + + + 0 + 0 + + + + + 0 + 0 + + + + + 100 + 16777215 + + + + Cancel + + + + + + 0 + 0 + 984 + 621 + + + + background-color: #ccc; + + + QTabWidget::North + + + 0 + + + + Yaw + + + + + 0 + 0 + 921 + 240 + + + + 180 + + + 180 + + + 5 + + + + 255 + 0 + 0 + + + + + 240 + 240 + 240 + + + + + + + 10 + 260 + 166 + 21 + + + + Use alternative + + + + + + 0 + 300 + 975 + 275 + + + + 180 + + + 180 + + + 5 + + + + 255 + 0 + 0 + + + + + 255 + 255 + 255 + + + + + + + Pitch + + + + + 0 + 0 + 595 + 240 + + + + 90 + + + 90 + + + 10 + + + 2 + + + + 0 + 255 + 0 + + + + + 240 + 240 + 240 + + + + + + + 10 + 260 + 199 + 21 + + + + Use alternative + + + + + + 0 + 300 + 1013 + 240 + + + + 90 + + + 90 + + + 10 + + + 2 + + + + 0 + 255 + 0 + + + + + 240 + 240 + 240 + + + + + + + Roll + + + + + 0 + 0 + 595 + 240 + + + + 180 + + + 180 + + + 5 + + + 1 + + + + 0 + 0 + 255 + + + + + 240 + 240 + 240 + + + + + + + 10 + 260 + 271 + 21 + + + + Use alternative + + + + + + 0 + 300 + 595 + 240 + + + + 180 + + + 180 + + + 5 + + + 1 + + + + 0 + 0 + 255 + + + + + 240 + 240 + 240 + + + + + + + X + + + + + 0 + 0 + 555 + 160 + + + + 100 + + + 100 + + + 7 + + + 2 + + + + 255 + 0 + 255 + + + + + 240 + 240 + 240 + + + + + + + 10 + 270 + 228 + 21 + + + + Use alternative + + + + + + 0 + 300 + 555 + 160 + + + + 100 + + + 100 + + + 7 + + + 2 + + + + 255 + 0 + 255 + + + + + 240 + 240 + 240 + + + + + + + Y + + + + + 0 + 0 + 555 + 160 + + + + 100 + + + 100 + + + 7 + + + 2 + + + + 255 + 255 + 0 + + + + + 240 + 240 + 240 + + + + + + + 10 + 270 + 229 + 21 + + + + Use alternative + + + + + + 0 + 300 + 555 + 160 + + + + 100 + + + 100 + + + 7 + + + 2 + + + + 255 + 255 + 0 + + + + + 240 + 240 + 240 + + + + + + + Z + + + + + 0 + 0 + 555 + 160 + + + + 100 + + + 100 + + + 7 + + + 2 + + + + 0 + 255 + 255 + + + + + 240 + 240 + 240 + + + + + + + 10 + 270 + 263 + 21 + + + + Use alternative + + + + + + 0 + 300 + 555 + 160 + + + + 100 + + + 100 + + + 7 + + + 2 + + + + 0 + 255 + 255 + + + + + 240 + 240 + 240 + + + + + + + Defaults + + + + + 10 + 44 + 35 + 16 + + + + RY + + + + + + 10 + 10 + 34 + 20 + + + + RX + + + + + + 9 + 75 + 33 + 16 + + + + RZ + + + + + + 50 + 10 + 131 + 22 + + + + deg. + + + 3 + + + -180.000000000000000 + + + 180.000000000000000 + + + + + + 50 + 40 + 131 + 22 + + + + deg. + + + 3 + + + -180.000000000000000 + + + 180.000000000000000 + + + + + + 49 + 71 + 131 + 22 + + + + deg. + + + 3 + + + -180.000000000000000 + + + 180.000000000000000 + + + + + + 209 + 10 + 32 + 20 + + + + TX + + + + + + 249 + 10 + 152 + 22 + + + + cm + + + 3 + + + -100.000000000000000 + + + 100.000000000000000 + + + + + + 249 + 40 + 152 + 22 + + + + cm + + + 3 + + + -100.000000000000000 + + + 100.000000000000000 + + + + + + 248 + 71 + 154 + 22 + + + + cm + + + 3 + + + -100.000000000000000 + + + 100.000000000000000 + + + + + + 209 + 44 + 32 + 16 + + + + TY + + + + + + 208 + 75 + 35 + 16 + + + + TZ + + + +
@@ -878,23 +872,6 @@ - - - 10 - - - 10 - - - false - - - false - - - true - - startEngineClicked() stopEngineClicked() diff --git a/qfunctionconfigurator/qfunctionconfigurator.cpp b/qfunctionconfigurator/qfunctionconfigurator.cpp index a068a53c..6bacf294 100644 --- a/qfunctionconfigurator/qfunctionconfigurator.cpp +++ b/qfunctionconfigurator/qfunctionconfigurator.cpp @@ -20,6 +20,7 @@ #include #include #include +#include static const int pointSize = 5; @@ -111,9 +112,8 @@ void QFunctionConfigurator::drawBackground(const QRectF &fullRect) int i; QRect scale; _background = QPixmap(fullRect.width(), fullRect.height()); - auto bgColor = palette().button(); QPainter painter(&_background); - painter.fillRect(fullRect, bgColor); + painter.fillRect(fullRect, QColor::fromRgb(204, 204, 204)); painter.setRenderHint(QPainter::Antialiasing); QColor bg_color(112, 154, 209); painter.fillRect(range, bg_color); -- cgit v1.2.3 From d37cbece940357105480c0991a70ee8394939301 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 17 Oct 2013 20:34:39 +0200 Subject: get rid of QFC artifacts Signed-off-by: Stanislaw Halik --- facetracknoir/ftnoir_curves.ui | 2 +- .../broken/qfunctionconfiguratorplugin.cpp | 7 ------- qfunctionconfigurator/qfunctionconfigurator.cpp | 24 +++++++++++----------- qfunctionconfigurator/qfunctionconfigurator.h | 2 +- 4 files changed, 14 insertions(+), 21 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/ftnoir_curves.ui b/facetracknoir/ftnoir_curves.ui index d9198a76..d0c1b2cd 100644 --- a/facetracknoir/ftnoir_curves.ui +++ b/facetracknoir/ftnoir_curves.ui @@ -168,7 +168,7 @@ 0 300 975 - 275 + 206 diff --git a/qfunctionconfigurator/broken/qfunctionconfiguratorplugin.cpp b/qfunctionconfigurator/broken/qfunctionconfiguratorplugin.cpp index 9bed2c9e..1a9da10a 100644 --- a/qfunctionconfigurator/broken/qfunctionconfiguratorplugin.cpp +++ b/qfunctionconfigurator/broken/qfunctionconfiguratorplugin.cpp @@ -82,13 +82,6 @@ QString QFunctionConfiguratorPlugin::domXml() const " 0\n" " \n" " \n" - " \n" - " \n" - " 192\n" - " 192\n" - " 192\n" - " \n" - " \n" " \n" " Input Yaw (degr.)\n" " \n" diff --git a/qfunctionconfigurator/qfunctionconfigurator.cpp b/qfunctionconfigurator/qfunctionconfigurator.cpp index 6bacf294..0b4df033 100644 --- a/qfunctionconfigurator/qfunctionconfigurator.cpp +++ b/qfunctionconfigurator/qfunctionconfigurator.cpp @@ -43,7 +43,6 @@ QFunctionConfigurator::QFunctionConfigurator(QWidget *parent) // This will require the Curve-Dialog to be higher (which was the reason it was reversed in the first place..) range = QRectF(40, 20, MaxInput * pPerEGU_Input, MaxOutput * pPerEGU_Output); - setMouseTracking(true); movingPoint = -1; // Index of that same point // @@ -107,13 +106,13 @@ void QFunctionConfigurator::saveSettings(QString settingsFile) { // Draw the Background for the graph, the gridlines and the gridpoints. // The static objects are drawn on a Pixmap, so it does not have to be repeated every paintEvent. Hope this speeds things up... // -void QFunctionConfigurator::drawBackground(const QRectF &fullRect) +void QFunctionConfigurator::drawBackground() { int i; QRect scale; - _background = QPixmap(fullRect.width(), fullRect.height()); + _background = QPixmap(width(), height()); QPainter painter(&_background); - painter.fillRect(fullRect, QColor::fromRgb(204, 204, 204)); + painter.fillRect(rect(), QColor::fromRgb(204, 204, 204)); painter.setRenderHint(QPainter::Antialiasing); QColor bg_color(112, 154, 209); painter.fillRect(range, bg_color); @@ -236,11 +235,10 @@ int i; QPainter p(this); p.setRenderHint(QPainter::Antialiasing); - p.setClipRect(e->rect()); if (_draw_background) { - drawBackground(e->rect()); // Draw the static parts on a Pixmap - p.drawPixmap(0, 0, _background); // Paint the background + drawBackground(); // Draw the static parts on a Pixmap + p.drawPixmap(e->rect(), _background); // Paint the background _draw_background = false; } @@ -248,14 +246,13 @@ int i; drawFunction(); // Draw the Function on a Pixmap _draw_function = false; } - p.drawPixmap(0, 0, _function); // Always draw the background and the function - - QPen pen(Qt::white, 1, Qt::SolidLine); + p.drawPixmap(e->rect(), _function); // Always draw the background and the function // // Draw the Points, that make up the Curve // if (_config) { + QPen pen(Qt::white, 1, Qt::SolidLine); QList points = _config->getPoints(); // // When moving, also draw a sketched version of the Function. @@ -304,12 +301,13 @@ int i; // // Draw the delimiters // +#if 0 pen.setWidth(1); pen.setColor( Qt::white ); pen.setStyle( Qt::SolidLine ); drawLine(&p, QPoint(lastPoint.x(), range.top()), QPoint(lastPoint.x(), range.bottom()), pen); drawLine(&p, QPoint(range.left(), lastPoint.y()), QPoint(range.right(), lastPoint.y()), pen); - +#endif //QTimer::singleShot(50, this, SLOT(update())); } @@ -360,6 +358,7 @@ void QFunctionConfigurator::mousePressEvent(QMouseEvent *e) bTouchingPoint = true; movingPoint = i; timer.restart(); + setMouseTracking(true); break; } } @@ -400,9 +399,9 @@ void QFunctionConfigurator::mousePressEvent(QMouseEvent *e) emit CurveChanged( true ); } movingPoint = -1; + setMouseTracking(false); } } - _draw_function = _draw_background = true; update(); } @@ -459,6 +458,7 @@ void QFunctionConfigurator::mouseReleaseEvent(QMouseEvent *e) QList points = _config->getPoints(); if (e->button() == Qt::LeftButton) { + setMouseTracking(false); timer.invalidate(); //qDebug()<<"releasing"; if (movingPoint >= 0 && movingPoint < points.size()) { diff --git a/qfunctionconfigurator/qfunctionconfigurator.h b/qfunctionconfigurator/qfunctionconfigurator.h index 1ac919fe..35f06a0d 100644 --- a/qfunctionconfigurator/qfunctionconfigurator.h +++ b/qfunctionconfigurator/qfunctionconfigurator.h @@ -112,7 +112,7 @@ protected slots: void mouseReleaseEvent(QMouseEvent *e); protected: - void drawBackground(const QRectF &); + void drawBackground(); void drawFunction(); void drawPoint(QPainter *painter, const QPointF &pt, QColor colBG ); void drawLine(QPainter *painter, const QPointF &start, const QPointF &end, QPen pen); -- cgit v1.2.3 From 7404dada6bade3c07fdd2ccf0740ecd11f05e655 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 19 Oct 2013 16:38:42 +0200 Subject: Fix copy-paste UI error Signed-off-by: Stanislaw Halik Reported-by: mm0zct --- facetracknoir/facetracknoir.ui | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.ui b/facetracknoir/facetracknoir.ui index cc5891bf..5bda6067 100644 --- a/facetracknoir/facetracknoir.ui +++ b/facetracknoir/facetracknoir.ui @@ -951,7 +951,7 @@ - TX + TY
@@ -1045,7 +1045,7 @@ - TX + TZ
-- cgit v1.2.3 From d90cbf7c0ad8a530e6dca3fc03189ef648159d0d Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 19 Oct 2013 17:11:21 +0200 Subject: play nice with valgrind Signed-off-by: Stanislaw Halik --- facetracknoir/facetracknoir.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index b5ccfdff..8786ed38 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -195,6 +195,8 @@ FaceTrackNoIR::~FaceTrackNoIR() { // stopTracker(); save(); + if (Libraries) + delete Libraries; } // -- cgit v1.2.3 From 02765c2920a647826c68ccad8adee496c00ff239 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 19 Oct 2013 17:16:35 +0200 Subject: play nicer with vg Signed-off-by: Stanislaw Halik --- facetracknoir/tracker.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'facetracknoir') diff --git a/facetracknoir/tracker.h b/facetracknoir/tracker.h index 28f8dc99..5f5ab1dc 100644 --- a/facetracknoir/tracker.h +++ b/facetracknoir/tracker.h @@ -125,6 +125,13 @@ public: axes[Pitch] = new THeadPoseDOF("ry", "ry_alt", 90, 90, 90, 90); axes[Roll] = new THeadPoseDOF("rz", "rz_alt", 180, 180, 180, 180); } + ~HeadPoseData() + { + for (int i = 0; i < 6; i++) + { + delete[] axes[i]; + } + } }; #endif -- cgit v1.2.3 From 4461b2971abb43a8f93989e6adf61c01f91fa973 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 19 Oct 2013 17:26:17 +0200 Subject: bah, stupido (valgrind) Signed-off-by: Stanislaw Halik --- facetracknoir/tracker.h | 2 +- qfunctionconfigurator/functionconfig.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/tracker.h b/facetracknoir/tracker.h index 5f5ab1dc..24a22c16 100644 --- a/facetracknoir/tracker.h +++ b/facetracknoir/tracker.h @@ -129,7 +129,7 @@ public: { for (int i = 0; i < 6; i++) { - delete[] axes[i]; + delete axes[i]; } } }; diff --git a/qfunctionconfigurator/functionconfig.h b/qfunctionconfigurator/functionconfig.h index b6257df2..4f48096a 100644 --- a/qfunctionconfigurator/functionconfig.h +++ b/qfunctionconfigurator/functionconfig.h @@ -37,7 +37,7 @@ public: // FunctionConfig(); FunctionConfig(QString title, int intMaxInput, int intMaxOutput); - virtual ~FunctionConfig(); + ~FunctionConfig(); float getValue(float x); bool getLastPoint(QPointF& point); // Get the last Point that was requested. -- cgit v1.2.3 From a664af379749f01e13600fad2850273f39db898f Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 19 Oct 2013 19:39:06 +0200 Subject: cleanup headpose timer Signed-off-by: Stanislaw Halik --- facetracknoir/facetracknoir.cpp | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index 8786ed38..569f0f3f 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -651,21 +651,7 @@ void FaceTrackNoIR::startTracker( ) { // // Start the timer to update the head-pose (digits and 'man in black') // - timUpdateHeadPose.start(40); - - ui.lblX->setVisible(true); - ui.lblY->setVisible(true); - ui.lblZ->setVisible(true); - ui.lblRotX->setVisible(true); - ui.lblRotY->setVisible(true); - ui.lblRotZ->setVisible(true); - - ui.lcdNumOutputPosX->setVisible(true); - ui.lcdNumOutputPosY->setVisible(true); - ui.lcdNumOutputPosZ->setVisible(true); - ui.lcdNumOutputRotX->setVisible(true); - ui.lcdNumOutputRotY->setVisible(true); - ui.lcdNumOutputRotZ->setVisible(true); + timUpdateHeadPose.start(50); } /** stop tracking the face **/ @@ -759,8 +745,6 @@ void FaceTrackNoIR::setInvertAxis(Axis axis, int invert ) { void FaceTrackNoIR::showHeadPose() { double newdata[6]; - const QString format("%1"); - tracker->getHeadPose(newdata); ui.lcdNumX->display(newdata[TX]); ui.lcdNumY->display(newdata[TY]); -- cgit v1.2.3 From 8c55d5fc650d49245fa94408eaaa12cf40f27849 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 20 Oct 2013 16:43:50 +0200 Subject: cleanup old cruft Signed-off-by: Stanislaw Halik --- facetracknoir/facetracknoir.cpp | 29 ----------------------------- 1 file changed, 29 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index 569f0f3f..e53f414a 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -167,20 +167,6 @@ FaceTrackNoIR::FaceTrackNoIR(QWidget *parent, Qt::WindowFlags flags) : //Q_INIT_RESOURCE(PoseWidget); - ui.lblX->setVisible(false); - ui.lblY->setVisible(false); - ui.lblZ->setVisible(false); - ui.lblRotX->setVisible(false); - ui.lblRotY->setVisible(false); - ui.lblRotZ->setVisible(false); - - ui.lcdNumOutputPosX->setVisible(false); - ui.lcdNumOutputPosY->setVisible(false); - ui.lcdNumOutputPosZ->setVisible(false); - ui.lcdNumOutputRotX->setVisible(false); - ui.lcdNumOutputRotY->setVisible(false); - ui.lcdNumOutputRotZ->setVisible(false); - #ifndef _WIN32 connect(&keyCenter, SIGNAL(activated()), this, SLOT(shortcutRecentered())); connect(&keyToggle, SIGNAL(activated()), this, SLOT(shortcutToggled())); @@ -672,21 +658,6 @@ void FaceTrackNoIR::stopTracker( ) { timUpdateHeadPose.stop(); ui.pose_display->rotateBy(0, 0, 0); - ui.lblX->setVisible(false); - ui.lblY->setVisible(false); - ui.lblZ->setVisible(false); - ui.lblRotX->setVisible(false); - ui.lblRotY->setVisible(false); - ui.lblRotZ->setVisible(false); - - ui.lcdNumOutputPosX->setVisible(false); - ui.lcdNumOutputPosY->setVisible(false); - ui.lcdNumOutputPosZ->setVisible(false); - ui.lcdNumOutputRotX->setVisible(false); - ui.lcdNumOutputRotY->setVisible(false); - ui.lcdNumOutputRotZ->setVisible(false); - - // // UnRegister the Tracker instance with the Tracker Dialog (if open) // if (pTrackerDialog) { -- cgit v1.2.3 From ac6d76a7c6a7ff924684609a73ac54d95fa5c9b1 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 20 Oct 2013 16:50:06 +0200 Subject: in preparation for a4 Waiting for mm0zct's okay Signed-off-by: Stanislaw Halik --- facetracknoir/facetracknoir.cpp | 2 +- installer/opentrack-installer.iss | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index e53f414a..1d531229 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -415,7 +415,7 @@ void FaceTrackNoIR::loadSettings() { // Put the filename in the window-title. // QFileInfo pathInfo ( currentFile ); - setWindowTitle ( "opentrack 2.0a3 - " + pathInfo.fileName() ); + setWindowTitle ( "opentrack 2.0a4 - " + pathInfo.fileName() ); // // Get a List of all the INI-files in the (currently active) Settings-folder. diff --git a/installer/opentrack-installer.iss b/installer/opentrack-installer.iss index dc6e624b..5ff42ea5 100644 --- a/installer/opentrack-installer.iss +++ b/installer/opentrack-installer.iss @@ -2,7 +2,7 @@ ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! #define MyAppName "opentrack" -#define MyAppVersion "2.0a3" +#define MyAppVersion "2.0a4" #define MyAppPublisher "opentrack" #define MyAppURL "http://github.com/opentrack/opentrack" #define MyAppExeName "opentrack.exe" -- cgit v1.2.3 From adfe6cfe1e1fb3d580248788d8f1b239ddd41f7f Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 20 Oct 2013 20:34:29 +0200 Subject: add kbd shortcut for quitting the software Signed-off-by: Stanislaw Halik --- facetracknoir/facetracknoir.cpp | 6 +++++- facetracknoir/facetracknoir.h | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index 1d531229..48bca959 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -102,7 +102,8 @@ FaceTrackNoIR::FaceTrackNoIR(QWidget *parent, Qt::WindowFlags flags) : pSecondTrackerDialog(NULL), pProtocolDialog(NULL), pFilterDialog(NULL), - looping(false) + looping(false), + kbd_quit(QKeySequence("Ctrl+Q"), this) { ui.setupUi(this); setFixedSize(size()); @@ -171,6 +172,9 @@ FaceTrackNoIR::FaceTrackNoIR(QWidget *parent, Qt::WindowFlags flags) : connect(&keyCenter, SIGNAL(activated()), this, SLOT(shortcutRecentered())); connect(&keyToggle, SIGNAL(activated()), this, SLOT(shortcutToggled())); #endif + + connect(&kbd_quit, SIGNAL(activated()), this, SLOT(exit())); + kbd_quit.setEnabled(true); } /** destructor stops the engine and quits the faceapi **/ diff --git a/facetracknoir/facetracknoir.h b/facetracknoir/facetracknoir.h index c5b2dc01..491274c8 100644 --- a/facetracknoir/facetracknoir.h +++ b/facetracknoir/facetracknoir.h @@ -38,6 +38,7 @@ #include #include #include +#include #if !defined(_WIN32) # include "qxt-mini/QxtGlobalShortcut" #else @@ -123,6 +124,7 @@ private: QList dlopen_filters; QList dlopen_trackers; QList dlopen_protocols; + QShortcut kbd_quit; #ifndef _WIN32 void bind_keyboard_shortcut(QxtGlobalShortcut& key, const QString label, QSettings& iniFile); -- cgit v1.2.3 From 732644b87e4fbc999170d13f6cda179113d3940b Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 20 Oct 2013 20:34:45 +0200 Subject: needless fun with main for layout Signed-off-by: Stanislaw Halik --- facetracknoir/facetracknoir.ui | 1325 +++++++++++++++++++++++----------------- 1 file changed, 772 insertions(+), 553 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.ui b/facetracknoir/facetracknoir.ui index 5bda6067..7ef41537 100644 --- a/facetracknoir/facetracknoir.ui +++ b/facetracknoir/facetracknoir.ui @@ -142,7 +142,7 @@ 120 - 40 + 60 203 97 @@ -163,33 +163,29 @@ - Qt::AlignJustify|Qt::AlignVCenter + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - false + true - - - - true - - - - 65536 - 65536 - - - - false - - - Y - - - - - + + QLayout::SetMaximumSize + + + 2 + + + 2 + + + 2 + + + 6 + + + true @@ -214,16 +210,19 @@ false + + 5 + 5 - QLCDNumber::Filled + QLCDNumber::Flat - - + + true @@ -248,16 +247,45 @@ false + + 5 + 5 - QLCDNumber::Filled + QLCDNumber::Flat - - + + + + + 65536 + 65536 + + + + roll + + + + + + + + 65536 + 65536 + + + + pitch + + + + + true @@ -282,16 +310,19 @@ false + + 5 + 5 - QLCDNumber::Filled + QLCDNumber::Flat - - + + true @@ -304,21 +335,26 @@ false - - Z + + QFrame::NoFrame - - - - - - - 65536 - 65536 - + + QFrame::Plain - - pitch + + 1 + + + false + + + 5 + + + 5 + + + QLCDNumber::Flat @@ -348,11 +384,14 @@ false + + 5 + 5 - QLCDNumber::Filled + QLCDNumber::Flat @@ -364,21 +403,37 @@ 65536 + + + 9 + + X - - + + + + true + 65536 65536 + + + 9 + + + + false + - roll + Y @@ -408,16 +463,19 @@ false + + 5 + 5 - QLCDNumber::Filled + QLCDNumber::Flat - - + + true @@ -427,26 +485,16 @@ 65536 - - false - - - QFrame::NoFrame - - - QFrame::Plain - - - 1 + + + 9 + - + false - - 5 - - - QLCDNumber::Filled + + Z @@ -468,9 +516,9 @@ - 10 - 40 - 90 + 20 + 50 + 81 100 @@ -499,7 +547,7 @@ 350 370 191 - 80 + 91 @@ -524,7 +572,7 @@ Qt::AlignCenter - false + true false @@ -583,7 +631,7 @@ 580 - 470 + 460 171 38 @@ -621,7 +669,7 @@ - 120 + 98 24 @@ -629,9 +677,9 @@ - 350 + 130 36 - 371 + 651 20 @@ -649,7 +697,7 @@ 350 - 262 + 270 191 91 @@ -676,7 +724,7 @@ Qt::AlignCenter - false + true false @@ -732,9 +780,9 @@ 350 - 70 + 60 191 - 83 + 91 @@ -759,7 +807,7 @@ Qt::AlignCenter - false + true false @@ -811,21 +859,15 @@
- + - 20 - 420 - 321 - 131 + 130 + 10 + 651 + 25 - - - 0 - 0 - - 0 @@ -838,266 +880,226 @@ 65536 + + + + + + + + 600 + 240 + 124 + 117 + + + + + 65536 + 65536 + + + + + true + + - Raw data + Axis inversion + + + Qt::AlignCenter + true + + false - + + + QLayout::SetMinAndMaxSize + 6 - + 65536 65536 + + Qt::RightToLeft + + + background:none; + - TX + Yaw - - - true - + 65536 65536 - - false - - - QFrame::NoFrame - - - 0 - - - 0 - - - false + + Qt::RightToLeft - - 5 + + background:none; - - QLCDNumber::Flat + + TX - - + + 65536 65536 - - yaw - - - - - - - true - - - - 65536 - 65536 - + + Qt::RightToLeft false - - QFrame::NoFrame - - - 0 - - - 0 - - - false - - - 5 - - - QLCDNumber::Flat - - - - - - - - 65536 - 65536 - + + background:none; - TY + Pitch - - - true - + 65536 65536 - - false - - - QFrame::NoFrame - - - 0 - - - 0 - - - false - - - 5 - - - QLCDNumber::Flat + + Qt::RightToLeft - - - - - - - 65536 - 65536 - + + background:none; - pitch + TY - - - - true - + + 65536 65536 - - false - - - QFrame::NoFrame - - - 0 - - - 0 - - - false - - - 5 - - - QLCDNumber::Flat + + Qt::RightToLeft - - - - - - - 65536 - 65536 - + + background:none; - TZ + Roll - - - true - + 65536 65536 - - false - - - QFrame::NoFrame - - - 0 - - - 0 - - - false + + Qt::RightToLeft - - 5 + + background:none; - - QLCDNumber::Flat + + TZ - - + + + + + + 350 + 160 + 191 + 91 + + + + + 0 + 0 + + + + + 65536 + 65536 + + + + Auxiliary tracker + + + Qt::AlignCenter + + + true + + + false + + + + QLayout::SetDefaultConstraint + + + 65536 65536 - - roll + + + + + -1 + + + 42 - - + + true @@ -1107,38 +1109,26 @@ 65536 - - false - - - QFrame::NoFrame - - - 0 - - - 0 - - - false + + Change tracker settings - - 5 + + - - QLCDNumber::Flat + + Settings - + 350 - 10 - 371 - 25 + 470 + 190 + 65 @@ -1153,274 +1143,14 @@ 65536 - - + + GO! - - - - - 600 - 240 - 124 - 117 - - - - - 65536 - 65536 - - - - - true - - - - Axis inversion - - - Qt::AlignCenter - - - false - - - false - - - - QLayout::SetMinAndMaxSize - - - 6 - - - - - - 65536 - 65536 - - - - Qt::RightToLeft - - - background:none; - - - Yaw - - - - - - - - 65536 - 65536 - - - - Qt::RightToLeft - - - background:none; - - - TX - - - - - - - - 65536 - 65536 - - - - Qt::RightToLeft - - - false - - - background:none; - - - Pitch - - - - - - - - 65536 - 65536 - - - - Qt::RightToLeft - - - background:none; - - - TY - - - - - - - - 65536 - 65536 - - - - Qt::RightToLeft - - - background:none; - - - Roll - - - - - - - - 65536 - 65536 - - - - Qt::RightToLeft - - - background:none; - - - TZ - - - - - - - - - 350 - 180 - 191 - 83 - - - - - 0 - 0 - - - - - 65536 - 65536 - - - - Auxiliary tracker - - - Qt::AlignCenter + + Qt::AlignCenter - false - - - false - - - - QLayout::SetDefaultConstraint - - - - - - 65536 - 65536 - - - - - - - -1 - - - 42 - - - - - - - true - - - - 65536 - 65536 - - - - Change tracker settings - - - - - - Settings - - - - - - - - - 350 - 470 - 190 - 65 - - - - - 0 - 0 - - - - - 65536 - 65536 - - - - GO! - - - Qt::AlignCenter + true @@ -1476,7 +1206,7 @@ 580 - 420 + 410 171 38 @@ -1506,7 +1236,7 @@ Edit the Keyboard and mouse shortcuts - Shortcuts + Keys @@ -1514,7 +1244,7 @@ - 24 + 98 24 @@ -1546,6 +1276,9 @@ Qt::AlignCenter + + true + QLayout::SetDefaultConstraint @@ -1637,6 +1370,492 @@ + + + + 30 + 420 + 131 + 111 + + + + Raw translation + + + Qt::AlignBottom|Qt::AlignHCenter + + + true + + + + QLayout::SetMaximumSize + + + QFormLayout::FieldsStayAtSizeHint + + + QFormLayout::DontWrapRows + + + Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft + + + Qt::AlignBottom|Qt::AlignHCenter + + + 6 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + 65536 + 65536 + + + + TX + + + + + + + true + + + + 0 + 0 + + + + + 65536 + 65536 + + + + + 12 + + + + false + + + QFrame::NoFrame + + + 0 + + + 0 + + + false + + + 4 + + + QLCDNumber::Flat + + + + + + + + 0 + 0 + + + + + 65536 + 65536 + + + + TY + + + + + + + true + + + + 0 + 0 + + + + + 65536 + 65536 + + + + + 12 + + + + false + + + QFrame::NoFrame + + + 0 + + + 0 + + + false + + + 4 + + + QLCDNumber::Flat + + + + + + + + 0 + 0 + + + + + 65536 + 65536 + + + + TZ + + + + + + + true + + + + 0 + 0 + + + + + 65536 + 65536 + + + + + 12 + + + + false + + + QFrame::NoFrame + + + 0 + + + 0 + + + false + + + 4 + + + QLCDNumber::Flat + + + + + + + + + 190 + 420 + 131 + 111 + + + + Raw rotation + + + Qt::AlignBottom|Qt::AlignHCenter + + + true + + + + QLayout::SetMaximumSize + + + QFormLayout::FieldsStayAtSizeHint + + + QFormLayout::DontWrapRows + + + Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft + + + Qt::AlignBottom|Qt::AlignHCenter + + + 6 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + 65536 + 65536 + + + + yaw + + + + + + + true + + + + 0 + 0 + + + + + 65536 + 65536 + + + + + 12 + + + + false + + + QFrame::NoFrame + + + 0 + + + 0 + + + false + + + 4 + + + QLCDNumber::Flat + + + + + + + + 0 + 0 + + + + + 65536 + 65536 + + + + pitch + + + + + + + true + + + + 0 + 0 + + + + + 65536 + 65536 + + + + + 12 + + + + false + + + QFrame::NoFrame + + + 0 + + + 0 + + + false + + + 4 + + + QLCDNumber::Flat + + + + + + + + 0 + 0 + + + + + 65536 + 65536 + + + + roll + + + + + + + true + + + + 0 + 0 + + + + + 65536 + 65536 + + + + + 12 + + + + false + + + QFrame::NoFrame + + + 0 + + + 0 + + + false + + + 4 + + + QLCDNumber::Flat + + + + + lcdNumRotZ + label_8 + label_7 + lcdNumRotY + lcdNumRotX + label_9 + -- cgit v1.2.3 From 49bc9a8550a8ab1fd037da31260bb38d80b6da15 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 21 Oct 2013 23:57:17 +0200 Subject: bump version --- facetracknoir/facetracknoir.cpp | 2 +- installer/opentrack-installer.iss | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index 1d531229..c1d4bc85 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -415,7 +415,7 @@ void FaceTrackNoIR::loadSettings() { // Put the filename in the window-title. // QFileInfo pathInfo ( currentFile ); - setWindowTitle ( "opentrack 2.0a4 - " + pathInfo.fileName() ); + setWindowTitle ( "opentrack 2.0a5 - " + pathInfo.fileName() ); // // Get a List of all the INI-files in the (currently active) Settings-folder. diff --git a/installer/opentrack-installer.iss b/installer/opentrack-installer.iss index 60d9963b..47bafe7a 100644 --- a/installer/opentrack-installer.iss +++ b/installer/opentrack-installer.iss @@ -2,7 +2,7 @@ ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! #define MyAppName "opentrack" -#define MyAppVersion "2.0a4" +#define MyAppVersion "2.0a5" #define MyAppPublisher "opentrack" #define MyAppURL "http://github.com/opentrack/opentrack" #define MyAppExeName "opentrack.exe" -- cgit v1.2.3 From 3752c7723cadf203c822879bd29ced20225d6bf4 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 22 Oct 2013 02:31:43 +0200 Subject: bump --- facetracknoir/facetracknoir.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index afc46625..f8a1f1f0 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -419,7 +419,7 @@ void FaceTrackNoIR::loadSettings() { // Put the filename in the window-title. // QFileInfo pathInfo ( currentFile ); - setWindowTitle ( "opentrack 2.0a5 - " + pathInfo.fileName() ); + setWindowTitle ( "opentrack 2.0a6 - " + pathInfo.fileName() ); // // Get a List of all the INI-files in the (currently active) Settings-folder. -- cgit v1.2.3 From 062cb6be8cf1da609475c128bb5815d7df082f29 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 22 Oct 2013 02:54:51 +0200 Subject: centralize version tracking Signed-off-by: Stanislaw Halik --- facetracknoir/facetracknoir.cpp | 3 ++- installer/opentrack-installer.iss | 3 ++- opentrack-version.h | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 opentrack-version.h (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index f8a1f1f0..f2bb5439 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -25,6 +25,7 @@ #include "shortcuts.h" #include "tracker.h" #include "curve-config.h" +#include "opentrack-version.h" #include #if defined(_WIN32) @@ -419,7 +420,7 @@ void FaceTrackNoIR::loadSettings() { // Put the filename in the window-title. // QFileInfo pathInfo ( currentFile ); - setWindowTitle ( "opentrack 2.0a6 - " + pathInfo.fileName() ); + setWindowTitle ( ("opentrack " OPENTRACK_VERSION) + pathInfo.fileName() ); // // Get a List of all the INI-files in the (currently active) Settings-folder. diff --git a/installer/opentrack-installer.iss b/installer/opentrack-installer.iss index f7b2c272..30669ee5 100644 --- a/installer/opentrack-installer.iss +++ b/installer/opentrack-installer.iss @@ -1,8 +1,9 @@ ; Script generated by the Inno Setup Script Wizard. ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! +#include "../opentrack-version.h" #define MyAppName "opentrack" -#define MyAppVersion "2.0a6" +#define MyAppVersion OPENTRACK_VERSION #define MyAppPublisher "opentrack" #define MyAppURL "http://github.com/opentrack/opentrack" #define MyAppExeName "opentrack.exe" diff --git a/opentrack-version.h b/opentrack-version.h new file mode 100644 index 00000000..4a60f25e --- /dev/null +++ b/opentrack-version.h @@ -0,0 +1 @@ +#define OPENTRACK_VERSION "2.0a6" -- cgit v1.2.3 From 2ffbf6801bd11caf3321cc9004460b3e5c035db3 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 22 Oct 2013 03:00:14 +0200 Subject: take spacing and expect vectors Signed-off-by: Stanislaw Halik --- facetracknoir/facetracknoir.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index f2bb5439..5b6ed347 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -420,7 +420,7 @@ void FaceTrackNoIR::loadSettings() { // Put the filename in the window-title. // QFileInfo pathInfo ( currentFile ); - setWindowTitle ( ("opentrack " OPENTRACK_VERSION) + pathInfo.fileName() ); + setWindowTitle ( ("opentrack " OPENTRACK_VERSION " ") + pathInfo.fileName() ); // // Get a List of all the INI-files in the (currently active) Settings-folder. -- cgit v1.2.3 From 41dc5c9bd5ea9ea5adfe26fa8779892b086e82ea Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 23 Oct 2013 13:09:56 +0200 Subject: main: use RTTI to set dialog fixed size Signed-off-by: Stanislaw Halik --- facetracknoir/facetracknoir.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index 5b6ed347..0a47e661 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -768,6 +768,8 @@ void FaceTrackNoIR::showTrackerSettings() { if (lib) { pTrackerDialog = (ITrackerDialog*) lib->Dialog(); if (pTrackerDialog) { + auto foo = dynamic_cast(pTrackerDialog); + foo->setFixedSize(foo->size()); if (Libraries && Libraries->pTracker) pTrackerDialog->registerTracker(Libraries->pTracker); pTrackerDialog->Initialize(this); @@ -787,6 +789,8 @@ void FaceTrackNoIR::showSecondTrackerSettings() { if (lib) { pSecondTrackerDialog = (ITrackerDialog*) lib->Dialog(); if (pSecondTrackerDialog) { + auto foo = dynamic_cast(pSecondTrackerDialog); + foo->setFixedSize(foo->size()); if (Libraries && Libraries->pSecondTracker) pSecondTrackerDialog->registerTracker(Libraries->pSecondTracker); pSecondTrackerDialog->Initialize(this); @@ -806,6 +810,8 @@ void FaceTrackNoIR::showServerControls() { if (lib && lib->Dialog) { pProtocolDialog = (IProtocolDialog*) lib->Dialog(); if (pProtocolDialog) { + auto foo = dynamic_cast(pProtocolDialog); + foo->setFixedSize(foo->size()); pProtocolDialog->Initialize(this); } } @@ -823,6 +829,8 @@ void FaceTrackNoIR::showFilterControls() { if (lib && lib->Dialog) { pFilterDialog = (IFilterDialog*) lib->Dialog(); if (pFilterDialog) { + auto foo = dynamic_cast(pFilterDialog); + foo->setFixedSize(foo->size()); pFilterDialog->Initialize(this); if (Libraries && Libraries->pFilter) pFilterDialog->registerFilter(Libraries->pFilter); -- cgit v1.2.3 From f64549bf043e1331b6c9d1226619f337e5fd8e0c Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 23 Oct 2013 16:08:26 +0200 Subject: don't qualify self-class Signed-off-by: Stanislaw Halik --- facetracknoir/tracker.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'facetracknoir') diff --git a/facetracknoir/tracker.cpp b/facetracknoir/tracker.cpp index 25b42ece..38b70199 100644 --- a/facetracknoir/tracker.cpp +++ b/facetracknoir/tracker.cpp @@ -116,7 +116,7 @@ void Tracker::run() { for (int i = 0; i < 6; i++) offset_camera.axes[i] = mainApp->axis(i).headPos; - Tracker::do_center = false; + do_center = false; if (Libraries->pFilter) Libraries->pFilter->Initialize(); -- cgit v1.2.3 From 60519897a43be9aba177f6a0f542851510322c8e Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 23 Oct 2013 19:10:35 +0200 Subject: Integrate Google Breakpad for crash dumps Signed-off-by: Stanislaw Halik --- CMakeLists.txt | 15 +++++++++++++++ facetracknoir/main.cpp | 19 ++++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) (limited to 'facetracknoir') diff --git a/CMakeLists.txt b/CMakeLists.txt index 2f8daadb..cffe88cd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,6 +25,16 @@ if(CMAKE_COMPILER_IS_GNUCXX) add_definitions(-std=c++11) endif() +if(WIN32) + set(SDK_GOOGLE_BREAKPAD "" CACHE PATH "google-breakpad for crash reporting") +endif() + +if(SDK_GOOGLE_BREAKPAD) + add_definitions(-DOPENTRACK_BREAKPAD) + include_directories("${SDK_GOOGLE_BREAKPAD}/src/client/windows/handler") + include_directories("${SDK_GOOGLE_BREAKPAD}/src/") +endif() + if(UNIX) set(SDK_ENABLE_LIBEVDEV FALSE CACHE BOOL "libevdev virtual joystick protocol support (probably Linux only)") endif() @@ -579,6 +589,11 @@ endif() if(NOT WIN32) target_link_libraries(opentrack dl) endif() + if(SDK_GOOGLE_BREAKPAD AND MSVC) + target_link_libraries(opentrack "${SDK_GOOGLE_BREAKPAD}/src/client/windows/Release/lib/crash_generation_client.lib" + "${SDK_GOOGLE_BREAKPAD}/src/client/windows/Release/lib/exception_handler.lib" + "${SDK_GOOGLE_BREAKPAD}/src/client/windows/Release/lib/common.lib") + endif() set_target_properties(opentrack PROPERTIES COMPILE_FLAGS -DOPENTRACK_MAIN) endif() diff --git a/facetracknoir/main.cpp b/facetracknoir/main.cpp index cf7ff6fb..0c8e5c11 100644 --- a/facetracknoir/main.cpp +++ b/facetracknoir/main.cpp @@ -31,12 +31,29 @@ #if defined(_WIN32) # include -//#pragma comment(linker, "/SUBSYSTEM:console /ENTRY:mainCRTStartup") +# ifdef OPENTRACK_BREAKPAD +# include +using namespace google_breakpad; +bool dumpCallback(const wchar_t* dump_path, + const wchar_t* minidump_id, + void* context, + EXCEPTION_POINTERS* exinfo, + MDRawAssertionInfo* assertion, + bool succeeded) +{ + return succeeded; +} + +# endif #endif int main(int argc, char** argv) { QApplication::setAttribute(Qt::AA_X11InitThreads, true); + +#ifdef OPENTRACK_BREAKPAD + auto handler = new ExceptionHandler(L".", nullptr, dumpCallback, nullptr, -1); +#endif QApplication app(argc, argv); -- cgit v1.2.3 From 18e2eb1ad59db93f575bf9199d9f361c05161e70 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 23 Oct 2013 19:48:06 +0200 Subject: integrate Git version in the titlebar Signed-off-by: Stanislaw Halik --- CMakeLists.txt | 24 ++++-- cmake/GetGitRevisionDescription.cmake | 123 +++++++++++++++++++++++++++++++ cmake/GetGitRevisionDescription.cmake.in | 38 ++++++++++ facetracknoir/facetracknoir.cpp | 2 +- facetracknoir/facetracknoir.h | 3 + facetracknoir/main.cpp | 4 + opentrack-version.h | 4 +- 7 files changed, 190 insertions(+), 8 deletions(-) create mode 100644 cmake/GetGitRevisionDescription.cmake create mode 100644 cmake/GetGitRevisionDescription.cmake.in (limited to 'facetracknoir') diff --git a/CMakeLists.txt b/CMakeLists.txt index d374f0ae..7a1cb8b6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,12 @@ project(opentrack) cmake_minimum_required(VERSION 2.8) set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${CMAKE_SOURCE_DIR}/cmake/") +include(GetGitRevisionDescription) +find_package(Git QUIET) +if(GIT_FOUND) + git_describe(OPENTRACK__COMMIT --tags --always) +endif() + SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) SET(CMAKE_SKIP_INSTALL_RPATH FALSE) @@ -25,11 +31,11 @@ if(CMAKE_COMPILER_IS_GNUCXX) add_definitions(-std=c++11) endif() -if(WIN32 AND MSVC) +if(WIN32) set(SDK_GOOGLE_BREAKPAD "" CACHE PATH "google-breakpad for crash reporting") endif() -if(SDK_GOOGLE_BREAKPAD AND MSVC) +if(SDK_GOOGLE_BREAKPAD AND WIN32) add_definitions(-DOPENTRACK_BREAKPAD) include_directories("${SDK_GOOGLE_BREAKPAD}/src/client/windows/handler") include_directories("${SDK_GOOGLE_BREAKPAD}/src/") @@ -566,6 +572,7 @@ endif() target_link_libraries(opentrack-qxt-mini ${MY_QT_LIBS}) endif() add_executable(opentrack ${opentrack-win32-executable} ${opentrack-bin-c} ${opentrack-bin-moc} ${opentrack-bin-uih} ${opentrack-bin-rcc}) + set_target_properties(opentrack PROPERTIES COMPILE_DEFINITIONS OPENTRACK_VERSION=\"${OPENTRACK__COMMIT}\") if(UNIX) target_link_libraries(opentrack opentrack-qxt-mini) endif() @@ -589,10 +596,15 @@ endif() if(NOT WIN32) target_link_libraries(opentrack dl) endif() - if(SDK_GOOGLE_BREAKPAD AND MSVC) - target_link_libraries(opentrack "${SDK_GOOGLE_BREAKPAD}/src/client/windows/Release/lib/crash_generation_client.lib" - "${SDK_GOOGLE_BREAKPAD}/src/client/windows/Release/lib/exception_handler.lib" - "${SDK_GOOGLE_BREAKPAD}/src/client/windows/Release/lib/common.lib") + if(SDK_GOOGLE_BREAKPAD) + if(MSVC) + target_link_libraries(opentrack "${SDK_GOOGLE_BREAKPAD}/src/client/windows/Release/lib/crash_generation_client.lib" + "${SDK_GOOGLE_BREAKPAD}/src/client/windows/Release/lib/exception_handler.lib" + "${SDK_GOOGLE_BREAKPAD}/src/client/windows/Release/lib/common.lib") + else() + target_link_libraries(opentrack "${SDK_GOOGLE_BREAKPAD}/lib/libbreakpad_client.a" + "${SDK_GOOGLE_BREAKPAD}/lib/libbreakpad.a") + endif() endif() set_target_properties(opentrack PROPERTIES COMPILE_FLAGS -DOPENTRACK_MAIN) endif() diff --git a/cmake/GetGitRevisionDescription.cmake b/cmake/GetGitRevisionDescription.cmake new file mode 100644 index 00000000..e16d8c37 --- /dev/null +++ b/cmake/GetGitRevisionDescription.cmake @@ -0,0 +1,123 @@ +# - Returns a version string from Git +# +# These functions force a re-configure on each git commit so that you can +# trust the values of the variables in your build system. +# +# get_git_head_revision( [ ...]) +# +# Returns the refspec and sha hash of the current head revision +# +# git_describe( [ ...]) +# +# Returns the results of git describe on the source tree, and adjusting +# the output so that it tests false if an error occurs. +# +# git_get_exact_tag( [ ...]) +# +# Returns the results of git describe --exact-match on the source tree, +# and adjusting the output so that it tests false if there was no exact +# matching tag. +# +# Requires CMake 2.6 or newer (uses the 'function' command) +# +# Original Author: +# 2009-2010 Ryan Pavlik +# http://academic.cleardefinition.com +# Iowa State University HCI Graduate Program/VRAC +# +# Copyright Iowa State University 2009-2010. +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +if(__get_git_revision_description) + return() +endif() +set(__get_git_revision_description YES) + +# We must run the following at "include" time, not at function call time, +# to find the path to this module rather than the path to a calling list file +get_filename_component(_gitdescmoddir ${CMAKE_CURRENT_LIST_FILE} PATH) + +function(get_git_head_revision _refspecvar _hashvar) + set(GIT_PARENT_DIR "${CMAKE_SOURCE_DIR}") + set(GIT_DIR "${GIT_PARENT_DIR}/.git") + while(NOT EXISTS "${GIT_DIR}") # .git dir not found, search parent directories + set(GIT_PREVIOUS_PARENT "${GIT_PARENT_DIR}") + get_filename_component(GIT_PARENT_DIR ${GIT_PARENT_DIR} PATH) + if(GIT_PARENT_DIR STREQUAL GIT_PREVIOUS_PARENT) + # We have reached the root directory, we are not in git + set(${_refspecvar} "GITDIR-NOTFOUND" PARENT_SCOPE) + set(${_hashvar} "GITDIR-NOTFOUND" PARENT_SCOPE) + return() + endif() + set(GIT_DIR "${GIT_PARENT_DIR}/.git") + endwhile() + set(GIT_DATA "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/git-data") + if(NOT EXISTS "${GIT_DATA}") + file(MAKE_DIRECTORY "${GIT_DATA}") + endif() + + if(NOT EXISTS "${GIT_DIR}/HEAD") + return() + endif() + set(HEAD_FILE "${GIT_DATA}/HEAD") + configure_file("${GIT_DIR}/HEAD" "${HEAD_FILE}" COPYONLY) + + configure_file("${_gitdescmoddir}/GetGitRevisionDescription.cmake.in" + "${GIT_DATA}/grabRef.cmake" + @ONLY) + include("${GIT_DATA}/grabRef.cmake") + + set(${_refspecvar} "${HEAD_REF}" PARENT_SCOPE) + set(${_hashvar} "${HEAD_HASH}" PARENT_SCOPE) +endfunction() + +function(git_describe _var) + if(NOT GIT_FOUND) + find_package(Git QUIET) + endif() + get_git_head_revision(refspec hash) + if(NOT GIT_FOUND) + set(${_var} "GIT-NOTFOUND" PARENT_SCOPE) + return() + endif() + if(NOT hash) + set(${_var} "HEAD-HASH-NOTFOUND" PARENT_SCOPE) + return() + endif() + + # TODO sanitize + #if((${ARGN}" MATCHES "&&") OR + # (ARGN MATCHES "||") OR + # (ARGN MATCHES "\\;")) + # message("Please report the following error to the project!") + # message(FATAL_ERROR "Looks like someone's doing something nefarious with git_describe! Passed arguments ${ARGN}") + #endif() + + #message(STATUS "Arguments to execute_process: ${ARGN}") + + execute_process(COMMAND + "${GIT_EXECUTABLE}" + describe + ${hash} + ${ARGN} + WORKING_DIRECTORY + "${CMAKE_SOURCE_DIR}" + RESULT_VARIABLE + res + OUTPUT_VARIABLE + out + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + if(NOT res EQUAL 0) + set(out "${out}-${res}-NOTFOUND") + endif() + + set(${_var} "${out}" PARENT_SCOPE) +endfunction() + +function(git_get_exact_tag _var) + git_describe(out ${ARGN}) + set(${_var} "${out}" PARENT_SCOPE) +endfunction() diff --git a/cmake/GetGitRevisionDescription.cmake.in b/cmake/GetGitRevisionDescription.cmake.in new file mode 100644 index 00000000..888ce13a --- /dev/null +++ b/cmake/GetGitRevisionDescription.cmake.in @@ -0,0 +1,38 @@ +# +# Internal file for GetGitRevisionDescription.cmake +# +# Requires CMake 2.6 or newer (uses the 'function' command) +# +# Original Author: +# 2009-2010 Ryan Pavlik +# http://academic.cleardefinition.com +# Iowa State University HCI Graduate Program/VRAC +# +# Copyright Iowa State University 2009-2010. +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +set(HEAD_HASH) + +file(READ "@HEAD_FILE@" HEAD_CONTENTS LIMIT 1024) + +string(STRIP "${HEAD_CONTENTS}" HEAD_CONTENTS) +if(HEAD_CONTENTS MATCHES "ref") + # named branch + string(REPLACE "ref: " "" HEAD_REF "${HEAD_CONTENTS}") + if(EXISTS "@GIT_DIR@/${HEAD_REF}") + configure_file("@GIT_DIR@/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY) + elseif(EXISTS "@GIT_DIR@/logs/${HEAD_REF}") + configure_file("@GIT_DIR@/logs/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY) + set(HEAD_HASH "${HEAD_REF}") + endif() +else() + # detached HEAD + configure_file("@GIT_DIR@/HEAD" "@GIT_DATA@/head-ref" COPYONLY) +endif() + +if(NOT HEAD_HASH) + file(READ "@GIT_DATA@/head-ref" HEAD_HASH LIMIT 1024) + string(STRIP "${HEAD_HASH}" HEAD_HASH) +endif() diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index 0a47e661..4884001e 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -420,7 +420,7 @@ void FaceTrackNoIR::loadSettings() { // Put the filename in the window-title. // QFileInfo pathInfo ( currentFile ); - setWindowTitle ( ("opentrack " OPENTRACK_VERSION " ") + pathInfo.fileName() ); + setWindowTitle(QString( OPENTRACK_VERSION " :: ") + pathInfo.fileName()); // // Get a List of all the INI-files in the (currently active) Settings-folder. diff --git a/facetracknoir/facetracknoir.h b/facetracknoir/facetracknoir.h index 491274c8..499bdf3f 100644 --- a/facetracknoir/facetracknoir.h +++ b/facetracknoir/facetracknoir.h @@ -58,6 +58,8 @@ #include "ftnoir_tracker_base/ftnoir_tracker_base.h" #include "ftnoir_filter_base/ftnoir_filter_base.h" +#include "opentrack-version.h" + class Tracker; // pre-define class to avoid circular includes class FaceTrackNoIR; @@ -68,6 +70,7 @@ class FaceTrackNoIR : public QMainWindow, IDynamicLibraryProvider Q_OBJECT public: + volatile const char* __opentrack_version__ = "$OPENTRACK_VERSION=" OPENTRACK_VERSION "$"; FaceTrackNoIR(QWidget *parent = 0, Qt::WindowFlags flags = 0); ~FaceTrackNoIR(); diff --git a/facetracknoir/main.cpp b/facetracknoir/main.cpp index 0c8e5c11..5ba7e3b2 100644 --- a/facetracknoir/main.cpp +++ b/facetracknoir/main.cpp @@ -41,6 +41,10 @@ bool dumpCallback(const wchar_t* dump_path, MDRawAssertionInfo* assertion, bool succeeded) { + MessageBoxA(GetDesktopWindow(), + "Generating crash dump!\r\n" + "Please send the .dmp file to to help us improve the code.", + "opentrack crashed :("); return succeeded; } diff --git a/opentrack-version.h b/opentrack-version.h index 4a60f25e..1b941000 100644 --- a/opentrack-version.h +++ b/opentrack-version.h @@ -1 +1,3 @@ -#define OPENTRACK_VERSION "2.0a6" +#ifndef OPENTRACK_VERSION +# define OPENTRACK_VERSION "Mourns-For-Trees" +#endif -- cgit v1.2.3 From 76a5947369612e737bedd86faf215a910abaead7 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 23 Oct 2013 19:50:21 +0200 Subject: Fix MSVC brain damage --- facetracknoir/facetracknoir.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.h b/facetracknoir/facetracknoir.h index 499bdf3f..7c7b7a87 100644 --- a/facetracknoir/facetracknoir.h +++ b/facetracknoir/facetracknoir.h @@ -70,7 +70,10 @@ class FaceTrackNoIR : public QMainWindow, IDynamicLibraryProvider Q_OBJECT public: - volatile const char* __opentrack_version__ = "$OPENTRACK_VERSION=" OPENTRACK_VERSION "$"; +#ifndef _MSC_VER + volatile +#endif + const char* __opentrack_version__ = "$OPENTRACK_VERSION=" OPENTRACK_VERSION "$"; FaceTrackNoIR(QWidget *parent = 0, Qt::WindowFlags flags = 0); ~FaceTrackNoIR(); -- cgit v1.2.3 From 8feff247dca2f9711d9d6a380df73ab45154536c Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 23 Oct 2013 19:53:43 +0200 Subject: Really fix the build this time --- facetracknoir/facetracknoir.cpp | 1 + facetracknoir/facetracknoir.h | 5 +---- 2 files changed, 2 insertions(+), 4 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index 4884001e..c8e2fae5 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -91,6 +91,7 @@ static void fill_combobox(const QString& filter, QList& list, Q // Setup the Main Dialog // FaceTrackNoIR::FaceTrackNoIR(QWidget *parent, Qt::WindowFlags flags) : + __opentrack_version__(OPENTRACK_VERSION), QMainWindow(parent, flags), #if defined(_WIN32) keybindingWorker(NULL), diff --git a/facetracknoir/facetracknoir.h b/facetracknoir/facetracknoir.h index 7c7b7a87..a199635d 100644 --- a/facetracknoir/facetracknoir.h +++ b/facetracknoir/facetracknoir.h @@ -70,10 +70,7 @@ class FaceTrackNoIR : public QMainWindow, IDynamicLibraryProvider Q_OBJECT public: -#ifndef _MSC_VER - volatile -#endif - const char* __opentrack_version__ = "$OPENTRACK_VERSION=" OPENTRACK_VERSION "$"; + volatile const char* __opentrack_version__; FaceTrackNoIR(QWidget *parent = 0, Qt::WindowFlags flags = 0); ~FaceTrackNoIR(); -- cgit v1.2.3 From 691c1193809fd1d217bab184d12902c2740f5740 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 23 Oct 2013 19:55:46 +0200 Subject: Fix MSVC build, sorry for commit flood --- facetracknoir/main.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'facetracknoir') diff --git a/facetracknoir/main.cpp b/facetracknoir/main.cpp index 5ba7e3b2..8cc97a38 100644 --- a/facetracknoir/main.cpp +++ b/facetracknoir/main.cpp @@ -44,7 +44,8 @@ bool dumpCallback(const wchar_t* dump_path, MessageBoxA(GetDesktopWindow(), "Generating crash dump!\r\n" "Please send the .dmp file to to help us improve the code.", - "opentrack crashed :("); + "opentrack crashed :(", + MB_OK | MB_ICONERROR); return succeeded; } -- cgit v1.2.3 From 941b72e0124d4a242b3a01b648be29fecbf8b928 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 24 Oct 2013 17:37:08 +0200 Subject: fix build --- facetracknoir/qt-moc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'facetracknoir') diff --git a/facetracknoir/qt-moc.h b/facetracknoir/qt-moc.h index 6f6033b2..8ccfffe8 100644 --- a/facetracknoir/qt-moc.h +++ b/facetracknoir/qt-moc.h @@ -2,7 +2,7 @@ // this file exists only such that cmake qt automoc is appeased -class AutomocMe { +class AutomocMe : public QObject { Q_OBJECT private: virtual void foo() = 0; -- cgit v1.2.3 From 542c5e475f151ba7f531e3128a3bcead247a317c Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 24 Oct 2013 20:14:10 +0200 Subject: main: ignore confid errors Signed-off-by: Stanislaw Halik --- facetracknoir/tracker.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/tracker.cpp b/facetracknoir/tracker.cpp index 38b70199..c0fe4eef 100644 --- a/facetracknoir/tracker.cpp +++ b/facetracknoir/tracker.cpp @@ -70,7 +70,7 @@ void Tracker::run() { bool bTracker1Confid = false; bool bTracker2Confid = false; - double newpose[6]; + double newpose[6] = {0}; double last_post_filter[6]; #if defined(_WIN32) @@ -82,9 +82,6 @@ void Tracker::run() { if (should_quit) break; - for (int i = 0; i < 6; i++) - newpose[i] = 0; - // // The second tracker serves as 'secondary'. So if an axis is written by the second tracker it CAN be overwritten by the Primary tracker. // This is enforced by the sequence below. -- cgit v1.2.3 From e248b039d1110dddc5c3ee13172b75a818f6d265 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 24 Oct 2013 20:36:09 +0200 Subject: ignore confid values wrt submitting pose to game Signed-off-by: Stanislaw Halik --- facetracknoir/tracker.cpp | 83 ++++++++++++++++++----------------------------- 1 file changed, 31 insertions(+), 52 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/tracker.cpp b/facetracknoir/tracker.cpp index c0fe4eef..980415c8 100644 --- a/facetracknoir/tracker.cpp +++ b/facetracknoir/tracker.cpp @@ -35,8 +35,8 @@ Tracker::Tracker( FaceTrackNoIR *parent ) : enabled(true) { // Retieve the pointer to the parent - mainApp = parent; - // Load the settings from the INI-file + mainApp = parent; + // Load the settings from the INI-file } Tracker::~Tracker() @@ -60,12 +60,7 @@ static void get_curve(double pos, double& out, THeadPoseDOF& axis) { /** QThread run method @override **/ void Tracker::run() { - T6DOF target_camera; - T6DOF new_camera; - - /** Direct Input variables **/ - T6DOF offset_camera; - T6DOF gameoutput_camera; + T6DOF offset_camera, new_camera, gameoutput_camera, target_camera, target_camera2; bool bTracker1Confid = false; bool bTracker2Confid = false; @@ -78,14 +73,10 @@ void Tracker::run() { #endif for (;;) - { + { if (should_quit) break; - // - // The second tracker serves as 'secondary'. So if an axis is written by the second tracker it CAN be overwritten by the Primary tracker. - // This is enforced by the sequence below. - // if (Libraries->pSecondTracker) { bTracker2Confid = Libraries->pSecondTracker->GiveHeadPoseData(newpose); } @@ -97,57 +88,45 @@ void Tracker::run() { { QMutexLocker foo(&mtx); const bool confid = bTracker1Confid || bTracker2Confid; - + if ( confid ) { for (int i = 0; i < 6; i++) mainApp->axis(i).headPos = newpose[i]; } - - // - // If Center is pressed, copy the current values to the offsets. - // + if (do_center) { - // - // Only copy valid values - // for (int i = 0; i < 6; i++) - offset_camera.axes[i] = mainApp->axis(i).headPos; - + offset_camera.axes[i] = target_camera.axes[i]; + do_center = false; - + if (Libraries->pFilter) Libraries->pFilter->Initialize(); } - - if (confid && enabled) { - // get values + + if (enabled && confid) + { for (int i = 0; i < 6; i++) target_camera.axes[i] = mainApp->axis(i).headPos; - - // do the centering - target_camera = target_camera - offset_camera; - - // - // Use advanced filtering, when a filter was selected. - // - if (Libraries->pFilter) { - for (int i = 0; i < 6; i++) - last_post_filter[i] = gameoutput_camera.axes[i]; - Libraries->pFilter->FilterHeadPoseData(target_camera.axes, new_camera.axes, last_post_filter); - } - else { - new_camera = target_camera; - } - - for (int i = 0; i < 6; i++) { - get_curve(new_camera.axes[i], output_camera.axes[i], mainApp->axis(i)); - } - - // Send the headpose to the game - if (Libraries->pProtocol) { - gameoutput_camera = output_camera; - Libraries->pProtocol->sendHeadposeToGame( gameoutput_camera.axes ); // degrees & centimeters - } + + target_camera2 = target_camera - offset_camera; + } + + if (Libraries->pFilter) { + for (int i = 0; i < 6; i++) + last_post_filter[i] = gameoutput_camera.axes[i]; + Libraries->pFilter->FilterHeadPoseData(target_camera2.axes, new_camera.axes, last_post_filter); + } else { + new_camera = target_camera2; + } + + for (int i = 0; i < 6; i++) { + get_curve(new_camera.axes[i], output_camera.axes[i], mainApp->axis(i)); + } + + if (Libraries->pProtocol) { + gameoutput_camera = output_camera; + Libraries->pProtocol->sendHeadposeToGame( gameoutput_camera.axes ); // degrees & centimeters } } -- cgit v1.2.3 From ab1394534a8439eea139d6d3fe85e211a7d19e2a Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 25 Oct 2013 05:37:40 +0200 Subject: remove trivial comments, references to sm faceapi Signed-off-by: Stanislaw Halik --- facetracknoir/facetracknoir.cpp | 190 +++------------------------------------- 1 file changed, 13 insertions(+), 177 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index c8e2fae5..8028d0ca 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -87,9 +87,6 @@ static void fill_combobox(const QString& filter, QList& list, Q } } -// -// Setup the Main Dialog -// FaceTrackNoIR::FaceTrackNoIR(QWidget *parent, Qt::WindowFlags flags) : __opentrack_version__(OPENTRACK_VERSION), QMainWindow(parent, flags), @@ -110,22 +107,13 @@ FaceTrackNoIR::FaceTrackNoIR(QWidget *parent, Qt::WindowFlags flags) : ui.setupUi(this); setFixedSize(size()); - // - // Initialize Widget handles, to prevent memory-access errors. - // _keyboard_shortcuts = 0; _curve_config = 0; tracker = 0; - // this is needed for Wine plugin subprocess QDir::setCurrent(QCoreApplication::applicationDirPath()); - // if we simply place a global variable with THeadPoseData, - // it gets initialized and pulls in QSettings before - // main() starts. program can and will crash. - - // menu objects will be connected with the functions in FaceTrackNoIR class connect(ui.btnLoad, SIGNAL(clicked()), this, SLOT(open())); connect(ui.btnSave, SIGNAL(clicked()), this, SLOT(save())); connect(ui.btnSaveAs, SIGNAL(clicked()), this, SLOT(saveAs())); @@ -137,7 +125,6 @@ FaceTrackNoIR::FaceTrackNoIR(QWidget *parent, Qt::WindowFlags flags) : connect(ui.btnShowServerControls, SIGNAL(clicked()), this, SLOT(showServerControls())); connect(ui.btnShowFilterControls, SIGNAL(clicked()), this, SLOT(showFilterControls())); - // Connect checkboxes connect(ui.chkInvertYaw, SIGNAL(stateChanged(int)), this, SLOT(setInvertYaw(int))); connect(ui.chkInvertRoll, SIGNAL(stateChanged(int)), this, SLOT(setInvertRoll(int))); connect(ui.chkInvertPitch, SIGNAL(stateChanged(int)), this, SLOT(setInvertPitch(int))); @@ -145,11 +132,9 @@ FaceTrackNoIR::FaceTrackNoIR(QWidget *parent, Qt::WindowFlags flags) : connect(ui.chkInvertY, SIGNAL(stateChanged(int)), this, SLOT(setInvertY(int))); connect(ui.chkInvertZ, SIGNAL(stateChanged(int)), this, SLOT(setInvertZ(int))); - // button methods connect with methods in this class connect(ui.btnStartTracker, SIGNAL(clicked()), this, SLOT(startTracker())); connect(ui.btnStopTracker, SIGNAL(clicked()), this, SLOT(stopTracker())); - //read the camera-name, using DirectShow GetCameraNameDX(); ui.cbxSecondTrackerSource->addItem(QIcon(), "None"); @@ -161,15 +146,10 @@ FaceTrackNoIR::FaceTrackNoIR(QWidget *parent, Qt::WindowFlags flags) : fill_combobox("opentrack-filter-*.", dlopen_filters, ui.iconcomboFilter, NULL); connect(ui.iconcomboProfile, SIGNAL(currentIndexChanged(int)), this, SLOT(profileSelected(int))); - - //Setup the timer for showing the headpose. connect(&timUpdateHeadPose, SIGNAL(timeout()), this, SLOT(showHeadPose())); - //Load the tracker-settings, from the INI-file loadSettings(); - //Q_INIT_RESOURCE(PoseWidget); - #ifndef _WIN32 connect(&keyCenter, SIGNAL(activated()), this, SLOT(shortcutRecentered())); connect(&keyToggle, SIGNAL(activated()), this, SLOT(shortcutToggled())); @@ -179,27 +159,18 @@ FaceTrackNoIR::FaceTrackNoIR(QWidget *parent, Qt::WindowFlags flags) : kbd_quit.setEnabled(true); } -/** destructor stops the engine and quits the faceapi **/ FaceTrackNoIR::~FaceTrackNoIR() { - // - // Stop the tracker, by simulating a button-push - // stopTracker(); save(); if (Libraries) delete Libraries; } -// -// Get a pointer to the video-widget, to use in the DLL -// QFrame* FaceTrackNoIR::get_video_widget() { return ui.video_frame; } -/** read the name of the first video-capturing device at start up **/ -/** FaceAPI can only use this first one... **/ void FaceTrackNoIR::GetCameraNameDX() { #if defined(_WIN32) ui.cameraName->setText("No video-capturing device was found in your system: check if it's connected!"); @@ -223,32 +194,23 @@ void FaceTrackNoIR::GetCameraNameDX() { if (hr == S_OK) { qDebug() << "GetWDM says: CreateClassEnumerator succeeded!"; - // Enumerate the monikers. IMoniker *pMoniker = NULL; ULONG cFetched; if (pEnumCat->Next(1, &pMoniker, &cFetched) == S_OK) { IPropertyBag *pPropBag; hr = pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void **)&pPropBag); if (SUCCEEDED(hr)) { - // To retrieve the filter's friendly name, do the following: VARIANT varName; VariantInit(&varName); hr = pPropBag->Read(L"FriendlyName", &varName, 0); if (SUCCEEDED(hr)) { - // Display the name in your UI somehow. QString str((QChar*)varName.bstrVal, wcslen(varName.bstrVal)); qDebug() << "GetWDM says: Moniker found:" << str; ui.cameraName->setText(str); } VariantClear(&varName); - ////// To create an instance of the filter, do the following: - ////IBaseFilter *pFilter; - ////hr = pMoniker->BindToObject(NULL, NULL, IID_IBaseFilter, - //// (void**)&pFilter); - // Now add the filter to the graph. - //Remember to release pFilter later. pPropBag->Release(); } pMoniker->Release(); @@ -268,10 +230,6 @@ void FaceTrackNoIR::GetCameraNameDX() { #endif } -// -// Open an INI-file with the QFileDialog -// If succesfull, the settings in it will be read -// void FaceTrackNoIR::open() { QFileDialog dialog(this); dialog.setFileMode(QFileDialog::ExistingFile); @@ -283,26 +241,20 @@ void FaceTrackNoIR::open() { tr("Settings file (*.ini);;All Files (*)"), NULL); - // - // If a file was selected, save it's name and read it's contents. - // if (! fileName.isEmpty() ) { { - QSettings settings("opentrack"); // Registry settings (in HK_USER) + QSettings settings("opentrack"); settings.setValue ("SettingsFile", QFileInfo(fileName).absoluteFilePath()); } loadSettings(); } } -// -// Save the current Settings to the currently 'active' INI-file. -// void FaceTrackNoIR::save() { - QSettings settings("opentrack"); // Registry settings (in HK_USER) + QSettings settings("opentrack"); QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); - QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) + QSettings iniFile( currentFile, QSettings::IniFormat ); iniFile.beginGroup ( "Tracking" ); iniFile.setValue ( "invertYaw", ui.chkInvertYaw->isChecked() ); @@ -331,9 +283,6 @@ void FaceTrackNoIR::save() { } iniFile.endGroup (); - // - // Save the name of the filter in the INI-file. - // iniFile.beginGroup ( "Filter" ); { DynamicLibrary* filter = dlopen_filters.value( ui.iconcomboFilter->currentIndex(), (DynamicLibrary*) NULL); @@ -352,89 +301,54 @@ void FaceTrackNoIR::save() { #endif } -// -// Get the new name of the INI-file and save the settings to it. -// -// The user may choose to overwrite an existing file. This will be deleted, before copying the current file to it. -// void FaceTrackNoIR::saveAs() { - // - // Get the current filename of the INI-file. - // - QSettings settings("opentrack"); // Registry settings (in HK_USER) + QSettings settings("opentrack"); QString oldFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); - // - // Get the new filename of the INI-file. - // QString fileName = QFileDialog::getSaveFileName(this, tr("Save file"), oldFile, // QCoreApplication::applicationDirPath() + "/settings", tr("Settings file (*.ini);;All Files (*)")); if (!fileName.isEmpty()) { - // - // Remove the file, if it already exists. - // QFileInfo newFileInfo ( fileName ); if ((newFileInfo.exists()) && (oldFile != fileName)) { QFile newFileFile ( fileName ); newFileFile.remove(); } - // - // Copy the current INI-file to the new name. - // QFileInfo oldFileInfo ( oldFile ); if (oldFileInfo.exists()) { QFile oldFileFile ( oldFile ); oldFileFile.copy( fileName ); } - // - // Write the new name to the Registry and save the other INI-values. - // settings.setValue ("SettingsFile", fileName); save(); - // - // Reload the settings, to get the GUI right again... - // loadSettings(); } } -// -// Load the current Settings from the currently 'active' INI-file. -// void FaceTrackNoIR::loadSettings() { looping = true; qDebug() << "loadSettings says: Starting "; - QSettings settings("opentrack"); // Registry settings (in HK_USER) + QSettings settings("opentrack"); QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); qDebug() << "Config file now" << currentFile; - QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) + QSettings iniFile( currentFile, QSettings::IniFormat ); - // - // Put the filename in the window-title. - // QFileInfo pathInfo ( currentFile ); setWindowTitle(QString( OPENTRACK_VERSION " :: ") + pathInfo.fileName()); - // - // Get a List of all the INI-files in the (currently active) Settings-folder. - // QDir settingsDir( pathInfo.dir() ); QStringList filters; filters << "*.ini"; iniFileList.clear(); iniFileList = settingsDir.entryList( filters, QDir::Files, QDir::Name ); - // - // Add strings to the Listbox. - // ui.iconcomboProfile->clear(); for ( int i = 0; i < iniFileList.size(); i++) { ui.iconcomboProfile->addItem(QIcon(":/images/settings16.png"), iniFileList.at(i)); @@ -455,16 +369,10 @@ void FaceTrackNoIR::loadSettings() { ui.chkInvertZ->setChecked (iniFile.value ( "invertZ", 0 ).toBool()); iniFile.endGroup (); - // Read the currently selected Protocol from the INI-file. - // If the setting "DLL" isn't found (pre-1.7 version of INI), then the setting 'Selection' is evaluated. - // iniFile.beginGroup ( "GameProtocol" ); QString selectedProtocolName = iniFile.value ( "DLL", "" ).toString(); iniFile.endGroup (); - // - // Find the Index of the DLL and set the selection. - // for ( int i = 0; i < dlopen_protocols.size(); i++) { if (dlopen_protocols.at(i)->filename.compare( selectedProtocolName, Qt::CaseInsensitive ) == 0) { ui.iconcomboProtocol->setCurrentIndex( i ); @@ -472,10 +380,6 @@ void FaceTrackNoIR::loadSettings() { } } - // - // Read the currently selected Tracker from the INI-file. - // If the setting "DLL" isn't found (pre-1.7 version), then the setting 'Selection' is evaluated. - // iniFile.beginGroup ( "TrackerSource" ); QString selectedTrackerName = iniFile.value ( "DLL", "" ).toString(); qDebug() << "loadSettings says: selectedTrackerName = " << selectedTrackerName; @@ -493,17 +397,11 @@ void FaceTrackNoIR::loadSettings() { } } - // - // Read the currently selected Filter from the INI-file. - // iniFile.beginGroup ( "Filter" ); QString selectedFilterName = iniFile.value ( "DLL", "" ).toString(); qDebug() << "createIconGroupBox says: selectedFilterName = " << selectedFilterName; iniFile.endGroup (); - // - // Find the Index of the DLL and set the selection. - // for ( int i = 0; i < dlopen_filters.size(); i++) { DynamicLibrary* foo = dlopen_filters.at(i); if (foo && foo->filename.compare( selectedFilterName, Qt::CaseInsensitive ) == 0) { @@ -522,23 +420,15 @@ void FaceTrackNoIR::loadSettings() { looping = false; } -/** start tracking the face **/ void FaceTrackNoIR::startTracker( ) { bindKeyboardShortcuts(); - // - // Disable buttons - // ui.iconcomboProfile->setEnabled ( false ); ui.btnLoad->setEnabled ( false ); ui.btnSave->setEnabled ( false ); ui.btnSaveAs->setEnabled ( false ); ui.btnShowFilterControls->setEnabled ( true ); - // - // Create the Tracker and setup - // - if (Libraries) delete Libraries; Libraries = new SelectedLibraries(this); @@ -560,9 +450,9 @@ void FaceTrackNoIR::startTracker( ) { delete tracker; } - QSettings settings("opentrack"); // Registry settings (in HK_USER) + QSettings settings("opentrack"); QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); - QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) + QSettings iniFile( currentFile, QSettings::IniFormat ); for (int i = 0; i < 6; i++) { @@ -599,10 +489,6 @@ void FaceTrackNoIR::startTracker( ) { tracker = new Tracker ( this ); - // - // Setup the Tracker and send the settings. - // This is necessary, because the events are only triggered 'on change' - // tracker->setInvertAxis(Yaw, ui.chkInvertYaw->isChecked() ); tracker->setInvertAxis(Pitch, ui.chkInvertPitch->isChecked() ); tracker->setInvertAxis(Roll, ui.chkInvertRoll->isChecked() ); @@ -610,9 +496,6 @@ void FaceTrackNoIR::startTracker( ) { tracker->setInvertAxis(TY, ui.chkInvertY->isChecked() ); tracker->setInvertAxis(TZ, ui.chkInvertZ->isChecked() ); - // - // Register the Tracker instance with the Tracker Dialog (if open) - // if (pTrackerDialog && Libraries->pTracker) { pTrackerDialog->registerTracker( Libraries->pTracker ); } @@ -624,29 +507,20 @@ void FaceTrackNoIR::startTracker( ) { ui.video_frame->show(); - // ui.btnStartTracker->setEnabled ( false ); ui.btnStopTracker->setEnabled ( true ); - // Enable/disable Protocol-server Settings ui.iconcomboTrackerSource->setEnabled ( false ); ui.cbxSecondTrackerSource->setEnabled ( false ); ui.iconcomboProtocol->setEnabled ( false ); ui.btnShowServerControls->setEnabled ( false ); ui.iconcomboFilter->setEnabled ( false ); - // - // Update the camera-name, FaceAPI can only use the 1st one found! - // GetCameraNameDX(); - // - // Start the timer to update the head-pose (digits and 'man in black') - // timUpdateHeadPose.start(50); } -/** stop tracking the face **/ void FaceTrackNoIR::stopTracker( ) { ui.game_name->setText("Not connected"); #if defined(_WIN32) @@ -658,14 +532,9 @@ void FaceTrackNoIR::stopTracker( ) { keybindingWorker = NULL; } #endif - // - // Stop displaying the head-pose. - // timUpdateHeadPose.stop(); ui.pose_display->rotateBy(0, 0, 0); - // UnRegister the Tracker instance with the Tracker Dialog (if open) - // if (pTrackerDialog) { pTrackerDialog->unRegisterTracker(); } @@ -675,9 +544,6 @@ void FaceTrackNoIR::stopTracker( ) { if (pFilterDialog) pFilterDialog->unregisterFilter(); - // - // Delete the tracker (after stopping things and all). - // if ( tracker ) { qDebug() << "Done with tracking"; tracker->should_quit = true; @@ -694,17 +560,14 @@ void FaceTrackNoIR::stopTracker( ) { } ui.btnStartTracker->setEnabled ( true ); ui.btnStopTracker->setEnabled ( false ); -// ui.btnShowEngineControls->setEnabled ( false ); ui.iconcomboProtocol->setEnabled ( true ); ui.iconcomboTrackerSource->setEnabled ( true ); ui.cbxSecondTrackerSource->setEnabled ( true ); ui.iconcomboFilter->setEnabled ( true ); - // Enable/disable Protocol-server Settings ui.btnShowServerControls->setEnabled ( true ); ui.video_frame->hide(); - // ui.iconcomboProfile->setEnabled ( true ); ui.btnLoad->setEnabled ( true ); ui.btnSave->setEnabled ( true ); @@ -712,13 +575,11 @@ void FaceTrackNoIR::stopTracker( ) { ui.btnShowFilterControls->setEnabled ( true ); } -/** set the invert from the checkbox **/ void FaceTrackNoIR::setInvertAxis(Axis axis, int invert ) { if (tracker) tracker->setInvertAxis (axis, (invert != 0)?true:false ); } -/** Show the headpose in the widget (triggered by timer) **/ void FaceTrackNoIR::showHeadPose() { double newdata[6]; @@ -732,9 +593,6 @@ void FaceTrackNoIR::showHeadPose() { ui.lcdNumRotY->display(newdata[Pitch]); ui.lcdNumRotZ->display(newdata[Roll]); - // - // Get the output-pose and also display it. - // tracker->getOutputHeadPose(newdata); ui.pose_display->rotateBy(newdata[Yaw], newdata[Roll], newdata[Pitch]); @@ -778,7 +636,6 @@ void FaceTrackNoIR::showTrackerSettings() { } } -// Show the Settings dialog for the secondary Tracker void FaceTrackNoIR::showSecondTrackerSettings() { if (pSecondTrackerDialog) { delete pSecondTrackerDialog; @@ -799,7 +656,6 @@ void FaceTrackNoIR::showSecondTrackerSettings() { } } -/** toggles Server Controls Dialog **/ void FaceTrackNoIR::showServerControls() { if (pProtocolDialog) { delete pProtocolDialog; @@ -818,7 +674,6 @@ void FaceTrackNoIR::showServerControls() { } } -/** toggles Filter Controls Dialog **/ void FaceTrackNoIR::showFilterControls() { if (pFilterDialog) { delete pFilterDialog; @@ -838,60 +693,41 @@ void FaceTrackNoIR::showFilterControls() { } } } -/** toggles Keyboard Shortcut Dialog **/ void FaceTrackNoIR::showKeyboardShortcuts() { - // Create if new if (!_keyboard_shortcuts) { _keyboard_shortcuts = new KeyboardShortcutDialog( this, this ); } - // Show if already created - if (_keyboard_shortcuts) { - _keyboard_shortcuts->show(); - _keyboard_shortcuts->raise(); - } + _keyboard_shortcuts->show(); + _keyboard_shortcuts->raise(); } - -/** toggles Curve Configuration Dialog **/ void FaceTrackNoIR::showCurveConfiguration() { - // Create if new if (!_curve_config) { _curve_config = new CurveConfigurationDialog( this, this ); } - // Show if already created if (_curve_config) { _curve_config->show(); _curve_config->raise(); } } -/** exit application **/ void FaceTrackNoIR::exit() { QCoreApplication::exit(0); } -// -// Handle changes of the Profile selection -// void FaceTrackNoIR::profileSelected(int index) { if (looping) return; - // - // Read the current INI-file setting, to get the folder in which it's located... - // - QSettings settings("opentrack"); // Registry settings (in HK_USER) + QSettings settings("opentrack"); QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); QFileInfo pathInfo ( currentFile ); - // - // Save the name of the INI-file in the Registry. - // settings.setValue ("SettingsFile", pathInfo.absolutePath() + "/" + iniFileList.value(index, "")); loadSettings(); } @@ -937,10 +773,10 @@ static void bind_keyboard_shortcut(Key& key, const QString label, QSettings& ini void FaceTrackNoIR::bindKeyboardShortcuts() { - QSettings settings("opentrack"); // Registry settings (in HK_USER) + QSettings settings("opentrack"); QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); - QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) + QSettings iniFile( currentFile, QSettings::IniFormat ); iniFile.beginGroup ( "KB_Shortcuts" ); #if !defined(_WIN32) -- cgit v1.2.3 From 06687f9777fc7fa4e2bca2b2471af596ab658e9f Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 25 Oct 2013 14:08:15 +0200 Subject: sprinkle const Signed-off-by: Stanislaw Halik --- facetracknoir/rotation.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/rotation.h b/facetracknoir/rotation.h index 747a23f9..22f35abb 100644 --- a/facetracknoir/rotation.h +++ b/facetracknoir/rotation.h @@ -39,14 +39,14 @@ public: d = cos_phi*cos_the*sin_psi - sin_phi*sin_the*cos_psi; } - void toEuler(double& yaw, double& pitch, double& roll) + void toEuler(double& yaw, double& pitch, double& roll) const { roll = atan2(2.0*(a*b + c*d), 1.0 - 2.0*(b*b + c*c)); pitch = asin(2.0*(a*c - b*d)); yaw = atan2(2.0*(a*d + b*c), 1.0 - 2.0*(c*c + d*d)); } - const RotationType operator*(const RotationType& B) + const RotationType operator*(const RotationType& B) const { const RotationType& A = *this; return RotationType(A.a*B.a - A.b*B.b - A.c*B.c - A.d*B.d, // quaternion multiplication -- cgit v1.2.3 From 3831edae9a45d65f6636767d6f6c53378e036b06 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 25 Oct 2013 14:08:56 +0200 Subject: add translation compensation Signed-off-by: Stanislaw Halik --- facetracknoir/curve-config.cpp | 12 ++++++++++++ facetracknoir/facetracknoir.cpp | 3 +++ facetracknoir/ftnoir_curves.ui | 25 ++++++++++++++++++++++--- facetracknoir/tracker.cpp | 41 +++++++++++++++++++++++++++++++++++++++-- facetracknoir/tracker.h | 1 + 5 files changed, 77 insertions(+), 5 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/curve-config.cpp b/facetracknoir/curve-config.cpp index 50aa8acf..6da1730d 100644 --- a/facetracknoir/curve-config.cpp +++ b/facetracknoir/curve-config.cpp @@ -1,6 +1,7 @@ #include "facetracknoir/facetracknoir.h" #include "facetracknoir/curve-config.h" #include +#include CurveConfigurationDialog::CurveConfigurationDialog(FaceTrackNoIR *ftnoir, QWidget *parent) : QWidget( parent, Qt::Dialog ), mainApp(ftnoir) { @@ -93,6 +94,8 @@ void CurveConfigurationDialog::loadSettings() { iniFile.beginGroup("Tracking"); + ui.checkBox->setChecked(iniFile.value("compensation", true).toBool()); + for (int i = 0; i < 6; i++) mainApp->axis(i).altp = iniFile.value(names[i], false).toBool(); @@ -179,6 +182,8 @@ void CurveConfigurationDialog::loadSettings() { connect(checkboxes[i], SIGNAL(stateChanged(int)), this, SLOT(curveChanged(int)), Qt::UniqueConnection); mainApp->axis(i).zero = widgets3[i]->value(); } + + connect(ui.checkBox, SIGNAL(stateChanged(int)), this, SLOT(curveChanged(int))); settingsDirty = false; } @@ -212,6 +217,13 @@ void CurveConfigurationDialog::save() { iniFile.beginGroup("Tracking"); + bool compensate = true; + + iniFile.setValue("compensation", compensate = (bool) !!ui.checkBox->isChecked()); + + if (mainApp->tracker) + mainApp->tracker->compensate = compensate; + iniFile.setValue("rx_alt", ui.rx_altp->checkState() != Qt::Unchecked); iniFile.setValue("ry_alt", ui.ry_altp->checkState() != Qt::Unchecked); iniFile.setValue("rz_alt", ui.rz_altp->checkState() != Qt::Unchecked); diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index 8028d0ca..73daca70 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -257,6 +257,7 @@ void FaceTrackNoIR::save() { QSettings iniFile( currentFile, QSettings::IniFormat ); iniFile.beginGroup ( "Tracking" ); + iniFile.setValue ( "invertYaw", ui.chkInvertYaw->isChecked() ); iniFile.setValue ( "invertPitch", ui.chkInvertPitch->isChecked() ); iniFile.setValue ( "invertRoll", ui.chkInvertRoll->isChecked() ); @@ -489,6 +490,8 @@ void FaceTrackNoIR::startTracker( ) { tracker = new Tracker ( this ); + tracker->compensate = iniFile.value("compensate", true).toBool(); + tracker->setInvertAxis(Yaw, ui.chkInvertYaw->isChecked() ); tracker->setInvertAxis(Pitch, ui.chkInvertPitch->isChecked() ); tracker->setInvertAxis(Roll, ui.chkInvertRoll->isChecked() ); diff --git a/facetracknoir/ftnoir_curves.ui b/facetracknoir/ftnoir_curves.ui index d0c1b2cd..0c269c70 100644 --- a/facetracknoir/ftnoir_curves.ui +++ b/facetracknoir/ftnoir_curves.ui @@ -99,7 +99,7 @@ 0 0 - 984 + 971 621 @@ -110,7 +110,7 @@ QTabWidget::North - 0 + 6 @@ -648,7 +648,7 @@ - Defaults + Options @@ -860,6 +860,25 @@ TZ + + + + 10 + 100 + 192 + 21 + + + + + 0 + 0 + + + + Translation compensation + +
diff --git a/facetracknoir/tracker.cpp b/facetracknoir/tracker.cpp index 980415c8..ac9de5cb 100644 --- a/facetracknoir/tracker.cpp +++ b/facetracknoir/tracker.cpp @@ -23,16 +23,18 @@ *********************************************************************************/ #include "tracker.h" #include "facetracknoir.h" +#include +#include #if defined(_WIN32) # include #endif -/** constructor **/ Tracker::Tracker( FaceTrackNoIR *parent ) : should_quit(false), do_center(false), - enabled(true) + enabled(true), + compensate(true) { // Retieve the pointer to the parent mainApp = parent; @@ -124,6 +126,41 @@ void Tracker::run() { get_curve(new_camera.axes[i], output_camera.axes[i], mainApp->axis(i)); } + if (compensate) + { + const auto H = output_camera.axes[Yaw] * M_PI / 180; + const auto P = output_camera.axes[Pitch] * M_PI / 180; + const auto B = output_camera.axes[Roll] * M_PI / 180; + + const auto cosH = cos(H); + const auto sinH = sin(H); + const auto cosP = cos(P); + const auto sinP = sin(P); + const auto cosB = cos(B); + const auto sinB = sin(B); + + double foo[] = { + cosH * cosB - sinH * sinP * sinB, + - sinB * cosP, + sinH * cosB + cosH * sinP * sinB, + cosH * sinB + sinH * sinP * cosB, + cosB * cosP, + sinB * sinH - cosH * sinP * cosB, + - sinH * cosP, + - sinP, + cosH * cosP, + }; + + cv::Mat rmat(3, 3, CV_64F, foo); + cv::Mat tvec(3, 1, CV_64F, output_camera.axes); + cv::Mat ret = rmat * tvec; + + cv::Mat junk1(3, 3, CV_64FC1), junk2(3, 3, CV_64FC1); + + for (int i = 0; i < 3; i++) + output_camera.axes[i] = ret.at(i); + } + if (Libraries->pProtocol) { gameoutput_camera = output_camera; Libraries->pProtocol->sendHeadposeToGame( gameoutput_camera.axes ); // degrees & centimeters diff --git a/facetracknoir/tracker.h b/facetracknoir/tracker.h index 24a22c16..a7951ceb 100644 --- a/facetracknoir/tracker.h +++ b/facetracknoir/tracker.h @@ -109,6 +109,7 @@ public: // following are now protected by hTrackMutex volatile bool do_center; // Center head-position, using the shortkey volatile bool enabled; + volatile bool compensate; T6DOF output_camera; }; -- cgit v1.2.3 From 5f8f39873d8f1caddc6eca9ccc765e37176012c1 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 25 Oct 2013 14:10:53 +0200 Subject: double polling interval for rift, hydra Signed-off-by: Stanislaw Halik --- facetracknoir/tracker.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'facetracknoir') diff --git a/facetracknoir/tracker.cpp b/facetracknoir/tracker.cpp index ac9de5cb..107c2c95 100644 --- a/facetracknoir/tracker.cpp +++ b/facetracknoir/tracker.cpp @@ -167,7 +167,7 @@ void Tracker::run() { } } - msleep(8); + msleep(4); } #if defined(_WIN32) (void) timeEndPeriod(1); -- cgit v1.2.3 From 2558cd7659e33297003adffa17c5771320bca2bf Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 25 Oct 2013 15:04:33 +0200 Subject: fix dangerous (i.e. leaky) braino Signed-off-by: Stanislaw Halik --- facetracknoir/curve-config.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/curve-config.cpp b/facetracknoir/curve-config.cpp index 6da1730d..5622e076 100644 --- a/facetracknoir/curve-config.cpp +++ b/facetracknoir/curve-config.cpp @@ -13,6 +13,7 @@ CurveConfigurationDialog::CurveConfigurationDialog(FaceTrackNoIR *ftnoir, QWidge // Connect Qt signals to member-functions connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); + connect(ui.checkBox, SIGNAL(stateChanged(int)), this, SLOT(curveChanged(int))); // Load the settings from the current .INI-file loadSettings(); @@ -182,8 +183,6 @@ void CurveConfigurationDialog::loadSettings() { connect(checkboxes[i], SIGNAL(stateChanged(int)), this, SLOT(curveChanged(int)), Qt::UniqueConnection); mainApp->axis(i).zero = widgets3[i]->value(); } - - connect(ui.checkBox, SIGNAL(stateChanged(int)), this, SLOT(curveChanged(int))); settingsDirty = false; } -- cgit v1.2.3 From da211b0012045548eab180ff769c6da4b942ba10 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 25 Oct 2013 15:27:59 +0200 Subject: use qbuttonbox in curve config Signed-off-by: Stanislaw Halik --- facetracknoir/curve-config.cpp | 4 +-- facetracknoir/ftnoir_curves.ui | 78 +++++++----------------------------------- 2 files changed, 15 insertions(+), 67 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/curve-config.cpp b/facetracknoir/curve-config.cpp index 5622e076..d06e1f6c 100644 --- a/facetracknoir/curve-config.cpp +++ b/facetracknoir/curve-config.cpp @@ -11,8 +11,8 @@ CurveConfigurationDialog::CurveConfigurationDialog(FaceTrackNoIR *ftnoir, QWidge this->move(parent->pos() + offsetpos); // Connect Qt signals to member-functions - connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); - connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); + connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); + connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); connect(ui.checkBox, SIGNAL(stateChanged(int)), this, SLOT(curveChanged(int))); // Load the settings from the current .INI-file diff --git a/facetracknoir/ftnoir_curves.ui b/facetracknoir/ftnoir_curves.ui index 0c269c70..77399a68 100644 --- a/facetracknoir/ftnoir_curves.ui +++ b/facetracknoir/ftnoir_curves.ui @@ -29,71 +29,6 @@ background-color: #ccc; - - - - 810 - 625 - 72 - 24 - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 100 - 16777215 - - - - - - - OK - - - - - - 886 - 625 - 69 - 24 - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 100 - 16777215 - - - - Cancel - - @@ -881,6 +816,19 @@
+ + + + 800 + 630 + 164 + 25 + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + +
-- cgit v1.2.3 From 674c969c3cf60e0285dbeb8e237bbd43dfe112e8 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 25 Oct 2013 16:57:09 +0200 Subject: improve main ui lcd scaling Signed-off-by: Stanislaw Halik --- facetracknoir/facetracknoir.ui | 250 +++++++++++++++++++++-------------------- 1 file changed, 126 insertions(+), 124 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.ui b/facetracknoir/facetracknoir.ui index 7ef41537..09c77626 100644 --- a/facetracknoir/facetracknoir.ui +++ b/facetracknoir/facetracknoir.ui @@ -39,7 +39,7 @@ opentrack - + :/images/facetracknoir.png:/images/facetracknoir.png @@ -141,10 +141,10 @@ - 120 - 60 - 203 - 97 + 110 + 50 + 229 + 121 @@ -170,22 +170,16 @@ - QLayout::SetMaximumSize - - - 2 - - - 2 + QLayout::SetMinimumSize - - 2 + + 10 - - 6 + + 0 - - + + true @@ -198,31 +192,13 @@ false - - QFrame::NoFrame - - - QFrame::Plain - - - 1 - - - false - - - 5 - - - 5 - - - QLCDNumber::Flat + + TZ - - + + true @@ -232,6 +208,11 @@ 65536 + + + 13 + + false @@ -258,21 +239,8 @@ - - - - - 65536 - 65536 - - - - roll - - - - - + + 65536 @@ -280,12 +248,12 @@ - pitch + TX - - + + true @@ -295,6 +263,11 @@ 65536 + + + 13 + + false @@ -321,8 +294,21 @@
- - + + + + + 65536 + 65536 + + + + yaw + + + + + true @@ -332,6 +318,11 @@ 65536 + + + 13 + + false @@ -358,8 +349,8 @@ - - + + true @@ -369,6 +360,11 @@ 65536 + + + 13 + + false @@ -395,21 +391,16 @@ - - + + 65536 65536 - - - 9 - - - X + roll @@ -424,21 +415,29 @@ 65536 - - - 9 - - false - Y + TY - - + + + + + 65536 + 65536 + + + + pitch + + + + + true @@ -448,6 +447,11 @@ 65536 + + + 13 + + false @@ -474,8 +478,8 @@ - - + + true @@ -487,27 +491,32 @@ - 9 + 13 false - - Z + + QFrame::NoFrame - - - - - - - 65536 - 65536 - + + QFrame::Plain - - yaw + + 1 + + + false + + + 5 + + + 5 + + + QLCDNumber::Flat @@ -678,11 +687,17 @@ 130 - 36 + 30 651 20 + + + 0 + 0 + + 65536 @@ -863,11 +878,17 @@ 130 - 10 + 0 651 25 + + + 0 + 0 + + 0 @@ -1373,10 +1394,10 @@ - 30 + 10 420 - 131 - 111 + 141 + 106 @@ -1402,18 +1423,9 @@ Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft - Qt::AlignBottom|Qt::AlignHCenter + Qt::AlignHCenter|Qt::AlignTop - - 6 - - - 0 - - - 0 - - + 0 @@ -1613,9 +1625,9 @@ - 190 + 160 420 - 131 + 161 111 @@ -1642,18 +1654,9 @@ Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft - Qt::AlignBottom|Qt::AlignHCenter - - - 6 - - - 0 - - - 0 + Qt::AlignHCenter|Qt::AlignTop - + 0 @@ -1867,7 +1870,6 @@ - -- cgit v1.2.3 From 3c665bbb21722d281de05c024db1c2eca85a9c63 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 25 Oct 2013 16:58:51 +0200 Subject: make groupboxen in main ui non-flat Signed-off-by: Stanislaw Halik --- facetracknoir/facetracknoir.ui | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.ui b/facetracknoir/facetracknoir.ui index 09c77626..d134e54c 100644 --- a/facetracknoir/facetracknoir.ui +++ b/facetracknoir/facetracknoir.ui @@ -578,10 +578,10 @@ Game protocol - Qt::AlignCenter + Qt::AlignHCenter|Qt::AlignTop - true + false false @@ -736,10 +736,10 @@ Filter - Qt::AlignCenter + Qt::AlignHCenter|Qt::AlignTop - true + false false @@ -819,10 +819,10 @@ Main tracker - Qt::AlignCenter + Qt::AlignHCenter|Qt::AlignTop - true + false false @@ -1088,10 +1088,10 @@ Auxiliary tracker - Qt::AlignCenter + Qt::AlignHCenter|Qt::AlignTop - true + false false @@ -1168,10 +1168,10 @@ GO! - Qt::AlignCenter + Qt::AlignHCenter|Qt::AlignTop - true + false @@ -1295,10 +1295,10 @@ Profile - Qt::AlignCenter + Qt::AlignHCenter|Qt::AlignTop - true + false @@ -1407,7 +1407,7 @@ Qt::AlignBottom|Qt::AlignHCenter - true + false @@ -1638,7 +1638,7 @@ Qt::AlignBottom|Qt::AlignHCenter - true + false -- cgit v1.2.3 From ce6c3a8b4df5d753c66fc6afd9a78bacfee8d937 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 26 Oct 2013 18:35:42 +0200 Subject: Project Evil: don't reset view on mutex timeout Reported-by: Tomasz Listwan Tested-by: Tomasz Listwan --- bin/NPClient.dll | Bin 39417 -> 51139 bytes bin/NPClient64.dll | Bin 42054 -> 21161 bytes facetracknoir/tracker.cpp | 2 +- 3 files changed, 1 insertion(+), 1 deletion(-) mode change 100644 => 100755 bin/NPClient.dll mode change 100644 => 100755 bin/NPClient64.dll (limited to 'facetracknoir') diff --git a/bin/NPClient.dll b/bin/NPClient.dll old mode 100644 new mode 100755 index 2469db3c..5000c898 Binary files a/bin/NPClient.dll and b/bin/NPClient.dll differ diff --git a/bin/NPClient64.dll b/bin/NPClient64.dll old mode 100644 new mode 100755 index 37bc6207..34da48c6 Binary files a/bin/NPClient64.dll and b/bin/NPClient64.dll differ diff --git a/facetracknoir/tracker.cpp b/facetracknoir/tracker.cpp index 107c2c95..01c16312 100644 --- a/facetracknoir/tracker.cpp +++ b/facetracknoir/tracker.cpp @@ -167,7 +167,7 @@ void Tracker::run() { } } - msleep(4); + msleep(15); } #if defined(_WIN32) (void) timeEndPeriod(1); -- cgit v1.2.3 From 881bd1ae68eb11ae5621789be7aee6677bf4f447 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 26 Oct 2013 21:10:51 +0200 Subject: force font DPI again, it breaks in qt5 with resolution changes Signed-off-by: Stanislaw Halik --- facetracknoir/facetracknoir.cpp | 4 ++-- facetracknoir/facetracknoir.h | 2 +- facetracknoir/main.cpp | 8 ++++++-- 3 files changed, 9 insertions(+), 5 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index 73daca70..7036e633 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -87,9 +87,9 @@ static void fill_combobox(const QString& filter, QList& list, Q } } -FaceTrackNoIR::FaceTrackNoIR(QWidget *parent, Qt::WindowFlags flags) : +FaceTrackNoIR::FaceTrackNoIR(QWidget *parent) : __opentrack_version__(OPENTRACK_VERSION), - QMainWindow(parent, flags), + QMainWindow(parent), #if defined(_WIN32) keybindingWorker(NULL), #else diff --git a/facetracknoir/facetracknoir.h b/facetracknoir/facetracknoir.h index a199635d..6547023b 100644 --- a/facetracknoir/facetracknoir.h +++ b/facetracknoir/facetracknoir.h @@ -71,7 +71,7 @@ class FaceTrackNoIR : public QMainWindow, IDynamicLibraryProvider public: volatile const char* __opentrack_version__; - FaceTrackNoIR(QWidget *parent = 0, Qt::WindowFlags flags = 0); + FaceTrackNoIR(QWidget *parent = 0); ~FaceTrackNoIR(); QFrame *get_video_widget(); // Get a pointer to the video-widget, to use in the DLL diff --git a/facetracknoir/main.cpp b/facetracknoir/main.cpp index 8cc97a38..d7b94506 100644 --- a/facetracknoir/main.cpp +++ b/facetracknoir/main.cpp @@ -55,14 +55,18 @@ bool dumpCallback(const wchar_t* dump_path, int main(int argc, char** argv) { QApplication::setAttribute(Qt::AA_X11InitThreads, true); - #ifdef OPENTRACK_BREAKPAD auto handler = new ExceptionHandler(L".", nullptr, dumpCallback, nullptr, -1); #endif QApplication app(argc, argv); - FaceTrackNoIR w; + QFont font; + font.setFamily(font.defaultFamily()); + font.setPointSize(10); + font.setPixelSize(10*4/3); + w.setFont(font); + app.setFont(font); QDesktopWidget desktop; w.move(desktop.screenGeometry().width()/2-w.width()/2, 100); -- cgit v1.2.3 From dc322bc02965565c13fdc9b14093d6b936abe833 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 26 Oct 2013 21:47:29 +0200 Subject: Force font DPI right way --- facetracknoir/main.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/main.cpp b/facetracknoir/main.cpp index d7b94506..36bccfad 100644 --- a/facetracknoir/main.cpp +++ b/facetracknoir/main.cpp @@ -54,20 +54,19 @@ bool dumpCallback(const wchar_t* dump_path, int main(int argc, char** argv) { - QApplication::setAttribute(Qt::AA_X11InitThreads, true); #ifdef OPENTRACK_BREAKPAD auto handler = new ExceptionHandler(L".", nullptr, dumpCallback, nullptr, -1); #endif QApplication app(argc, argv); - FaceTrackNoIR w; QFont font; font.setFamily(font.defaultFamily()); font.setPointSize(10); font.setPixelSize(10*4/3); - w.setFont(font); - app.setFont(font); - QDesktopWidget desktop; + QApplication::setFont(font); + QApplication::setAttribute(Qt::AA_X11InitThreads, true); + FaceTrackNoIR w; + QDesktopWidget desktop; w.move(desktop.screenGeometry().width()/2-w.width()/2, 100); w.show(); -- cgit v1.2.3 From 48e785f62b5f9aef17c7b8b06f5c7beaf74cdf68 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 26 Oct 2013 21:49:32 +0200 Subject: Set x11 threads as soon as possible --- facetracknoir/main.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/main.cpp b/facetracknoir/main.cpp index 36bccfad..58357f42 100644 --- a/facetracknoir/main.cpp +++ b/facetracknoir/main.cpp @@ -57,14 +57,13 @@ int main(int argc, char** argv) #ifdef OPENTRACK_BREAKPAD auto handler = new ExceptionHandler(L".", nullptr, dumpCallback, nullptr, -1); #endif - + QApplication::setAttribute(Qt::AA_X11InitThreads, true); QApplication app(argc, argv); QFont font; font.setFamily(font.defaultFamily()); font.setPointSize(10); font.setPixelSize(10*4/3); QApplication::setFont(font); - QApplication::setAttribute(Qt::AA_X11InitThreads, true); FaceTrackNoIR w; QDesktopWidget desktop; -- cgit v1.2.3 From 5e92ff0786555cc613d2d05421679abfd98fad94 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 26 Oct 2013 23:19:48 +0200 Subject: set font harder (probably meaningless) Signed-off-by: Stanislaw Halik --- facetracknoir/main.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'facetracknoir') diff --git a/facetracknoir/main.cpp b/facetracknoir/main.cpp index 58357f42..08439c8a 100644 --- a/facetracknoir/main.cpp +++ b/facetracknoir/main.cpp @@ -64,6 +64,7 @@ int main(int argc, char** argv) font.setPointSize(10); font.setPixelSize(10*4/3); QApplication::setFont(font); + qApp->setFont(font); FaceTrackNoIR w; QDesktopWidget desktop; -- cgit v1.2.3 From 5f643fa61aa4b5701de758010531ae227c6a202c Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 26 Oct 2013 23:25:26 +0200 Subject: set global dpi for curve config Signed-off-by: Stanislaw Halik --- facetracknoir/curve-config.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'facetracknoir') diff --git a/facetracknoir/curve-config.cpp b/facetracknoir/curve-config.cpp index d06e1f6c..65470339 100644 --- a/facetracknoir/curve-config.cpp +++ b/facetracknoir/curve-config.cpp @@ -6,6 +6,7 @@ CurveConfigurationDialog::CurveConfigurationDialog(FaceTrackNoIR *ftnoir, QWidge QWidget( parent, Qt::Dialog ), mainApp(ftnoir) { ui.setupUi( this ); + setFont(qApp->font()); QPoint offsetpos(120, 30); this->move(parent->pos() + offsetpos); -- cgit v1.2.3 From c929cc7e4bd312f62f1c0ebcb8f72fe52cf0c8c7 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 27 Oct 2013 02:54:21 +0200 Subject: ui: regen --- facetracknoir/facetracknoir.ui | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.ui b/facetracknoir/facetracknoir.ui index d134e54c..896c4294 100644 --- a/facetracknoir/facetracknoir.ui +++ b/facetracknoir/facetracknoir.ui @@ -39,7 +39,7 @@ opentrack - + :/images/facetracknoir.png:/images/facetracknoir.png @@ -1870,6 +1870,7 @@ + -- cgit v1.2.3 From 532f3ee81709d3e1127437fce5dd32db5c835674 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 27 Oct 2013 02:54:47 +0200 Subject: remove dpi scale forcing --- facetracknoir/main.cpp | 6 ------ 1 file changed, 6 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/main.cpp b/facetracknoir/main.cpp index 08439c8a..e059090d 100644 --- a/facetracknoir/main.cpp +++ b/facetracknoir/main.cpp @@ -59,12 +59,6 @@ int main(int argc, char** argv) #endif QApplication::setAttribute(Qt::AA_X11InitThreads, true); QApplication app(argc, argv); - QFont font; - font.setFamily(font.defaultFamily()); - font.setPointSize(10); - font.setPixelSize(10*4/3); - QApplication::setFont(font); - qApp->setFont(font); FaceTrackNoIR w; QDesktopWidget desktop; -- cgit v1.2.3 From e7e8fd1c8b115dc9c2393fde29733eb301d4342c Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 27 Oct 2013 10:28:18 +0100 Subject: main: improve pose compensation Signed-off-by: Stanislaw Halik --- facetracknoir/tracker.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/tracker.cpp b/facetracknoir/tracker.cpp index 01c16312..83f60356 100644 --- a/facetracknoir/tracker.cpp +++ b/facetracknoir/tracker.cpp @@ -128,9 +128,14 @@ void Tracker::run() { if (compensate) { - const auto H = output_camera.axes[Yaw] * M_PI / 180; - const auto P = output_camera.axes[Pitch] * M_PI / 180; - const auto B = output_camera.axes[Roll] * M_PI / 180; + const double yi = mainApp->axis(Yaw).invert; + const double pi = mainApp->axis(Pitch).invert; + const double ri = mainApp->axis(Roll).invert; + output_camera.axes[Yaw] += atan2(target_camera2.axes[TX] * yi, target_camera2.axes[TZ]); + output_camera.axes[Pitch] += atan2(target_camera2.axes[TY] * pi, target_camera2.axes[TZ]); + const auto H = output_camera.axes[Yaw] * M_PI / 180 * yi; + const auto P = output_camera.axes[Pitch] * M_PI / 180 * pi; + const auto B = output_camera.axes[Roll] * M_PI / 180 * ri; const auto cosH = cos(H); const auto sinH = sin(H); -- cgit v1.2.3 From bc4e25f2cc8f7763ca42c892adaad9325fdc25b3 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 27 Oct 2013 11:11:02 +0100 Subject: compensation v2: don't rotate on pure translation --- facetracknoir/tracker.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/tracker.cpp b/facetracknoir/tracker.cpp index 83f60356..43db732e 100644 --- a/facetracknoir/tracker.cpp +++ b/facetracknoir/tracker.cpp @@ -131,8 +131,6 @@ void Tracker::run() { const double yi = mainApp->axis(Yaw).invert; const double pi = mainApp->axis(Pitch).invert; const double ri = mainApp->axis(Roll).invert; - output_camera.axes[Yaw] += atan2(target_camera2.axes[TX] * yi, target_camera2.axes[TZ]); - output_camera.axes[Pitch] += atan2(target_camera2.axes[TY] * pi, target_camera2.axes[TZ]); const auto H = output_camera.axes[Yaw] * M_PI / 180 * yi; const auto P = output_camera.axes[Pitch] * M_PI / 180 * pi; const auto B = output_camera.axes[Roll] * M_PI / 180 * ri; @@ -164,6 +162,9 @@ void Tracker::run() { for (int i = 0; i < 3; i++) output_camera.axes[i] = ret.at(i); + + output_camera.axes[Yaw] += atan2(output_camera.axes[TZ], output_camera.axes[TX]) * yi; + output_camera.axes[Pitch] -= atan2(output_camera.axes[TZ], output_camera.axes[TY]) * pi; } if (Libraries->pProtocol) { -- cgit v1.2.3 From bc21e1b961dc3a7a7d4790e5eb8cc85150a67e44 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 27 Oct 2013 11:21:16 +0100 Subject: remove unused vars Signed-off-by: Stanislaw Halik --- facetracknoir/tracker.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/tracker.cpp b/facetracknoir/tracker.cpp index 43db732e..ce9af054 100644 --- a/facetracknoir/tracker.cpp +++ b/facetracknoir/tracker.cpp @@ -158,8 +158,6 @@ void Tracker::run() { cv::Mat tvec(3, 1, CV_64F, output_camera.axes); cv::Mat ret = rmat * tvec; - cv::Mat junk1(3, 3, CV_64FC1), junk2(3, 3, CV_64FC1); - for (int i = 0; i < 3; i++) output_camera.axes[i] = ret.at(i); -- cgit v1.2.3 From e0a3d094c8b2aafca810f812a00110719215be58 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 27 Oct 2013 11:43:31 +0100 Subject: curves: group sensibly, as to avoid user confusion Signed-off-by: Stanislaw Halik --- facetracknoir/ftnoir_curves.ui | 1536 +++++++++++++++++++--------------------- 1 file changed, 739 insertions(+), 797 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/ftnoir_curves.ui b/facetracknoir/ftnoir_curves.ui index 77399a68..22403f66 100644 --- a/facetracknoir/ftnoir_curves.ui +++ b/facetracknoir/ftnoir_curves.ui @@ -29,806 +29,748 @@ background-color: #ccc; - - - - 0 - 0 - 971 - 621 - - - - background-color: #ccc; - - - QTabWidget::North - - - 6 - - - - Yaw - - - - - 0 - 0 - 921 - 240 - - - - 180 - - - 180 - - - 5 - - - - 255 - 0 - 0 - - - - - 240 - 240 - 240 - - - - - - - 10 - 260 - 166 - 21 - - - - Use alternative - - - - - - 0 - 300 - 975 - 206 - - - - 180 - - - 180 - - - 5 - - - - 255 - 0 - 0 - - - - - 255 - 255 - 255 - - - - - - - Pitch - - - - - 0 - 0 - 595 - 240 - - - - 90 - - - 90 - - - 10 - - - 2 - - - - 0 - 255 - 0 - - - - - 240 - 240 - 240 - - - - - - - 10 - 260 - 199 - 21 - - - - Use alternative - - - - - - 0 - 300 - 1013 - 240 - - - - 90 - - - 90 - - - 10 - - - 2 - - - - 0 - 255 - 0 - - - - - 240 - 240 - 240 - - - - - - - Roll - - - - - 0 - 0 - 595 - 240 - - - - 180 - - - 180 - - - 5 - - - 1 - - - - 0 - 0 - 255 - - - - - 240 - 240 - 240 - - - - - - - 10 - 260 - 271 - 21 - - - - Use alternative - - - - - - 0 - 300 - 595 - 240 - - - - 180 - - - 180 - - - 5 - - - 1 - - - - 0 - 0 - 255 - - - - - 240 - 240 - 240 - - - - - - - X - - - - - 0 - 0 - 555 - 160 - - - - 100 - - - 100 - - - 7 - - - 2 - - - - 255 - 0 - 255 - - - - - 240 - 240 - 240 - - - - - - - 10 - 270 - 228 - 21 - - - - Use alternative - - - - - - 0 - 300 - 555 - 160 - - - - 100 - - - 100 - - - 7 - - - 2 - - - - 255 - 0 - 255 - - - - - 240 - 240 - 240 - - - - - - - Y - - - - - 0 - 0 - 555 - 160 - - - - 100 - - - 100 - - - 7 - - - 2 - - - - 255 - 255 - 0 - - - - - 240 - 240 - 240 - - - - - - - 10 - 270 - 229 - 21 - - - - Use alternative - + + + + + background-color: #ccc; + + + QTabWidget::North + + + 6 + + + + Yaw + + + + + 0 + 0 + 921 + 240 + + + + 180 + + + 180 + + + 5 + + + + 255 + 0 + 0 + + + + + 240 + 240 + 240 + + + + + + + 10 + 260 + 166 + 21 + + + + Use alternative + + + + + + 0 + 300 + 975 + 206 + + + + 180 + + + 180 + + + 5 + + + + 255 + 0 + 0 + + + + + 255 + 255 + 255 + + + + + + + Pitch + + + + + 0 + 0 + 595 + 240 + + + + 90 + + + 90 + + + 10 + + + 2 + + + + 0 + 255 + 0 + + + + + 240 + 240 + 240 + + + + + + + 10 + 260 + 199 + 21 + + + + Use alternative + + + + + + 0 + 300 + 1013 + 240 + + + + 90 + + + 90 + + + 10 + + + 2 + + + + 0 + 255 + 0 + + + + + 240 + 240 + 240 + + + + + + + Roll + + + + + 0 + 0 + 595 + 240 + + + + 180 + + + 180 + + + 5 + + + 1 + + + + 0 + 0 + 255 + + + + + 240 + 240 + 240 + + + + + + + 10 + 260 + 271 + 21 + + + + Use alternative + + + + + + 0 + 300 + 595 + 240 + + + + 180 + + + 180 + + + 5 + + + 1 + + + + 0 + 0 + 255 + + + + + 240 + 240 + 240 + + + + + + + X + + + + + 0 + 0 + 555 + 160 + + + + 100 + + + 100 + + + 7 + + + 2 + + + + 255 + 0 + 255 + + + + + 240 + 240 + 240 + + + + + + + 10 + 270 + 228 + 21 + + + + Use alternative + + + + + + 0 + 300 + 555 + 160 + + + + 100 + + + 100 + + + 7 + + + 2 + + + + 255 + 0 + 255 + + + + + 240 + 240 + 240 + + + + + + + Y + + + + + 0 + 0 + 555 + 160 + + + + 100 + + + 100 + + + 7 + + + 2 + + + + 255 + 255 + 0 + + + + + 240 + 240 + 240 + + + + + + + 10 + 270 + 229 + 21 + + + + Use alternative + + + + + + 0 + 300 + 555 + 160 + + + + 100 + + + 100 + + + 7 + + + 2 + + + + 255 + 255 + 0 + + + + + 240 + 240 + 240 + + + + + + + Z + + + + + 0 + 0 + 555 + 160 + + + + 100 + + + 100 + + + 7 + + + 2 + + + + 0 + 255 + 255 + + + + + 240 + 240 + 240 + + + + + + + 10 + 270 + 263 + 21 + + + + Use alternative + + + + + + 0 + 300 + 555 + 160 + + + + 100 + + + 100 + + + 7 + + + 2 + + + + 0 + 255 + 255 + + + + + 240 + 240 + 240 + + + + + + + Options + + + + + 310 + 10 + 192 + 21 + + + + + 0 + 0 + + + + Translation compensation + + + + + + 0 + 10 + 306 + 114 + + + + Center pose + + + Qt::AlignCenter + + + true + + + false + + + + + + RX + + + + + + + deg. + + + 3 + + + -180.000000000000000 + + + 180.000000000000000 + + + + + + + TX + + + + + + + cm + + + 3 + + + -100.000000000000000 + + + 100.000000000000000 + + + + + + + RY + + + + + + + deg. + + + 3 + + + -180.000000000000000 + + + 180.000000000000000 + + + + + + + TY + + + + + + + cm + + + 3 + + + -100.000000000000000 + + + 100.000000000000000 + + + + + + + RZ + + + + + + + deg. + + + 3 + + + -180.000000000000000 + + + 180.000000000000000 + + + + + + + TZ + + + + + + + cm + + + 3 + + + -100.000000000000000 + + + 100.000000000000000 + + + + + + - - - - 0 - 300 - 555 - 160 - - - - 100 - - - 100 - - - 7 - - - 2 - - - - 255 - 255 - 0 - - - - - 240 - 240 - 240 - - - - - - - Z - - - - - 0 - 0 - 555 - 160 - - - - 100 - - - 100 - - - 7 - - - 2 - - - - 0 - 255 - 255 - - - - - 240 - 240 - 240 - - - - - - - 10 - 270 - 263 - 21 - - - - Use alternative - - - - - - 0 - 300 - 555 - 160 - - - - 100 - - - 100 - - - 7 - - - 2 - - - - 0 - 255 - 255 - - - - - 240 - 240 - 240 - - - - - - - Options - - - - - 10 - 44 - 35 - 16 - - - - RY - - - - - - 10 - 10 - 34 - 20 - - - - RX - - - - - - 9 - 75 - 33 - 16 - - - - RZ - - - - - - 50 - 10 - 131 - 22 - - - - deg. - - - 3 - - - -180.000000000000000 - - - 180.000000000000000 - - - - - - 50 - 40 - 131 - 22 - - - - deg. - - - 3 - - - -180.000000000000000 - - - 180.000000000000000 - - - - - - 49 - 71 - 131 - 22 - - - - deg. - - - 3 - - - -180.000000000000000 - - - 180.000000000000000 - - - - - - 209 - 10 - 32 - 20 - - - - TX - - - - - - 249 - 10 - 152 - 22 - - - - cm - - - 3 - - - -100.000000000000000 - - - 100.000000000000000 - - - - - - 249 - 40 - 152 - 22 - - - - cm - - - 3 - - - -100.000000000000000 - - - 100.000000000000000 - - - - - - 248 - 71 - 154 - 22 - - - - cm - - - 3 - - - -100.000000000000000 - - - 100.000000000000000 - - - - - - 209 - 44 - 32 - 16 - - - - TY - - - - - - 208 - 75 - 35 - 16 - - - - TZ - - - - - - 10 - 100 - 192 - 21 - - - - - 0 - 0 - - - - Translation compensation + + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - 800 - 630 - 164 - 25 - - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - + + -- cgit v1.2.3 From 4b2a9abcd44292f6f2b9f119f68c39e27cd536a5 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 27 Oct 2013 11:44:42 +0100 Subject: rename alt curves, as to avoid user confusion Signed-off-by: Stanislaw Halik --- facetracknoir/ftnoir_curves.ui | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/ftnoir_curves.ui b/facetracknoir/ftnoir_curves.ui index 22403f66..2b843303 100644 --- a/facetracknoir/ftnoir_curves.ui +++ b/facetracknoir/ftnoir_curves.ui @@ -88,7 +88,7 @@ - Use alternative + Asymmetric curves below
@@ -175,7 +175,7 @@ - Use alternative + Asymmetric curves below @@ -265,7 +265,7 @@ - Use alternative + Asymmetric curves below @@ -355,7 +355,7 @@ - Use alternative + Asymmetric curves below @@ -445,7 +445,7 @@ - Use alternative + Asymmetric curves below @@ -535,7 +535,7 @@ - Use alternative + Asymmetric curves below -- cgit v1.2.3 From b0769de5dfd0e01039dbadcf4b0469e77175fd4f Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 28 Oct 2013 04:55:27 +0100 Subject: remove broken scaling code Signed-off-by: Stanislaw Halik --- facetracknoir/tracker.cpp | 3 --- 1 file changed, 3 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/tracker.cpp b/facetracknoir/tracker.cpp index ce9af054..50c7ad9d 100644 --- a/facetracknoir/tracker.cpp +++ b/facetracknoir/tracker.cpp @@ -160,9 +160,6 @@ void Tracker::run() { for (int i = 0; i < 3; i++) output_camera.axes[i] = ret.at(i); - - output_camera.axes[Yaw] += atan2(output_camera.axes[TZ], output_camera.axes[TX]) * yi; - output_camera.axes[Pitch] -= atan2(output_camera.axes[TZ], output_camera.axes[TY]) * pi; } if (Libraries->pProtocol) { -- cgit v1.2.3 From 9df6326873b84899433bc324de647f18f1bbca5c Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 29 Oct 2013 00:10:07 +0100 Subject: conditionalize breakpad for MSVC only, broken on mingw Signed-off-by: Stanislaw Halik --- facetracknoir/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/main.cpp b/facetracknoir/main.cpp index e059090d..e643bcd3 100644 --- a/facetracknoir/main.cpp +++ b/facetracknoir/main.cpp @@ -29,7 +29,7 @@ #include #include -#if defined(_WIN32) +#if defined(_WIN32) && defined(_MSC_VER) # include # ifdef OPENTRACK_BREAKPAD # include @@ -54,7 +54,7 @@ bool dumpCallback(const wchar_t* dump_path, int main(int argc, char** argv) { -#ifdef OPENTRACK_BREAKPAD +#if defined(OPENTRACK_BREAKPAD) && defined(_MSC_VER) auto handler = new ExceptionHandler(L".", nullptr, dumpCallback, nullptr, -1); #endif QApplication::setAttribute(Qt::AA_X11InitThreads, true); -- cgit v1.2.3 From 17615205b06eaf8bffb6bacd4f79696d856117a4 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 29 Oct 2013 00:12:20 +0100 Subject: fix compensation Signed-off-by: Stanislaw Halik --- facetracknoir/tracker.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/tracker.cpp b/facetracknoir/tracker.cpp index 50c7ad9d..e86e095d 100644 --- a/facetracknoir/tracker.cpp +++ b/facetracknoir/tracker.cpp @@ -128,9 +128,9 @@ void Tracker::run() { if (compensate) { - const double yi = mainApp->axis(Yaw).invert; - const double pi = mainApp->axis(Pitch).invert; - const double ri = mainApp->axis(Roll).invert; + const double yi = mainApp->axis(Yaw).invert * mainApp->axis(TX).invert; + const double pi = mainApp->axis(Pitch).invert * mainApp->axis(TY).invert; + const double ri = mainApp->axis(Roll).invert * mainApp->axis(TZ).invert; const auto H = output_camera.axes[Yaw] * M_PI / 180 * yi; const auto P = output_camera.axes[Pitch] * M_PI / 180 * pi; const auto B = output_camera.axes[Roll] * M_PI / 180 * ri; -- cgit v1.2.3 From 9ce886603f443b145890ad688879bad4d14c52f2 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 29 Oct 2013 00:28:02 +0100 Subject: hopefully fix compensation for good Signed-off-by: Stanislaw Halik --- facetracknoir/tracker.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/tracker.cpp b/facetracknoir/tracker.cpp index e86e095d..eb6348ca 100644 --- a/facetracknoir/tracker.cpp +++ b/facetracknoir/tracker.cpp @@ -128,12 +128,9 @@ void Tracker::run() { if (compensate) { - const double yi = mainApp->axis(Yaw).invert * mainApp->axis(TX).invert; - const double pi = mainApp->axis(Pitch).invert * mainApp->axis(TY).invert; - const double ri = mainApp->axis(Roll).invert * mainApp->axis(TZ).invert; - const auto H = output_camera.axes[Yaw] * M_PI / 180 * yi; - const auto P = output_camera.axes[Pitch] * M_PI / 180 * pi; - const auto B = output_camera.axes[Roll] * M_PI / 180 * ri; + const auto H = output_camera.axes[Yaw] * M_PI / 180; + const auto P = output_camera.axes[Pitch] * M_PI / 180; + const auto B = output_camera.axes[Roll] * M_PI / 180; const auto cosH = cos(H); const auto sinH = sin(H); -- cgit v1.2.3 From 78e7b38162d525923feb13c6b609ecf1a75847a9 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 29 Oct 2013 07:31:46 +0100 Subject: move variable decls into inner scope Signed-off-by: Stanislaw Halik --- facetracknoir/tracker.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/tracker.cpp b/facetracknoir/tracker.cpp index eb6348ca..a91d9f58 100644 --- a/facetracknoir/tracker.cpp +++ b/facetracknoir/tracker.cpp @@ -62,18 +62,18 @@ static void get_curve(double pos, double& out, THeadPoseDOF& axis) { /** QThread run method @override **/ void Tracker::run() { - T6DOF offset_camera, new_camera, gameoutput_camera, target_camera, target_camera2; - + T6DOF offset_camera, gameoutput_camera; + bool bTracker1Confid = false; bool bTracker2Confid = false; - + double newpose[6] = {0}; double last_post_filter[6]; - + #if defined(_WIN32) (void) timeBeginPeriod(1); #endif - + for (;;) { if (should_quit) @@ -88,6 +88,7 @@ void Tracker::run() { } { + T6DOF target_camera; QMutexLocker foo(&mtx); const bool confid = bTracker1Confid || bTracker2Confid; @@ -106,6 +107,8 @@ void Tracker::run() { Libraries->pFilter->Initialize(); } + T6DOF target_camera2, new_camera; + if (enabled && confid) { for (int i = 0; i < 6; i++) @@ -164,7 +167,7 @@ void Tracker::run() { Libraries->pProtocol->sendHeadposeToGame( gameoutput_camera.axes ); // degrees & centimeters } } - + msleep(15); } #if defined(_WIN32) -- cgit v1.2.3 From bcfa72d0d2a3355e152267b5a17fa593df93e9c0 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 29 Oct 2013 07:40:38 +0100 Subject: remove existing copyright notice, file has been completely rewritten Signed-off-by: Stanislaw Halik --- facetracknoir/tracker.h | 38 +++++++------------------------------- 1 file changed, 7 insertions(+), 31 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/tracker.h b/facetracknoir/tracker.h index a7951ceb..c0ec0cf1 100644 --- a/facetracknoir/tracker.h +++ b/facetracknoir/tracker.h @@ -1,25 +1,3 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of the some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2010 - 2012 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -*********************************************************************************/ #ifndef __TRACKER_H__ #define __TRACKER_H__ @@ -67,7 +45,7 @@ public: curveAlt(secondary, maxInput2, maxOutput2), zero(0) { - QSettings settings("opentrack"); // Registry settings (in HK_USER) + QSettings settings("opentrack"); QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); QSettings iniFile( currentFile, QSettings::IniFormat ); curve.loadSettings(iniFile); @@ -77,9 +55,9 @@ public: altp = iniFile.value(secondary).toBool(); iniFile.endGroup(); } - volatile double headPos; // Current position (from faceTracker, radials or meters) - volatile float invert; // Invert measured value (= 1.0f or -1.0f) - FunctionConfig curve; // Function to translate input -> output + volatile double headPos; + volatile float invert; + FunctionConfig curve; FunctionConfig curveAlt; volatile bool altp; volatile double zero; @@ -93,7 +71,6 @@ private: QMutex mtx; protected: - // qthread override run method void run(); public: @@ -102,12 +79,11 @@ public: void setInvertAxis(Axis axis, bool invert); - void getHeadPose(double *data); // Return the current headpose data - void getOutputHeadPose(double *data); // Return the current (processed) headpose data + void getHeadPose(double *data); + void getOutputHeadPose(double *data); volatile bool should_quit; - // following are now protected by hTrackMutex - volatile bool do_center; // Center head-position, using the shortkey + volatile bool do_center; volatile bool enabled; volatile bool compensate; -- cgit v1.2.3 From d1d72f35a4b6371244674e06f4dd3fc3fc2ea2aa Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 29 Oct 2013 07:40:48 +0100 Subject: remove rewritten code copyright notice Signed-off-by: Stanislaw Halik --- facetracknoir/tracker.cpp | 45 +++++++++++++-------------------------------- 1 file changed, 13 insertions(+), 32 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/tracker.cpp b/facetracknoir/tracker.cpp index a91d9f58..c1b7b3af 100644 --- a/facetracknoir/tracker.cpp +++ b/facetracknoir/tracker.cpp @@ -1,26 +1,15 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of the some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2012 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage: http://facetracknoir.sourceforge.net/home/default.htm * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -*********************************************************************************/ +/* Copyright (c) 2012-2013 Stanislaw Halik + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + */ + +/* + * this file appeared originally in facetracknoir, was rewritten completely + * following opentrack fork. + */ + #include "tracker.h" #include "facetracknoir.h" #include @@ -36,9 +25,7 @@ Tracker::Tracker( FaceTrackNoIR *parent ) : enabled(true), compensate(true) { - // Retieve the pointer to the parent mainApp = parent; - // Load the settings from the INI-file } Tracker::~Tracker() @@ -68,7 +55,7 @@ void Tracker::run() { bool bTracker2Confid = false; double newpose[6] = {0}; - double last_post_filter[6]; + double last_post_filter[6] ; #if defined(_WIN32) (void) timeBeginPeriod(1); @@ -181,9 +168,6 @@ void Tracker::run() { } } -// -// Get the raw headpose, so it can be displayed. -// void Tracker::getHeadPose( double *data ) { QMutexLocker foo(&mtx); for (int i = 0; i < 6; i++) @@ -192,9 +176,6 @@ void Tracker::getHeadPose( double *data ) { } } -// -// Get the output-headpose, so it can be displayed. -// void Tracker::getOutputHeadPose( double *data ) { QMutexLocker foo(&mtx); for (int i = 0; i < 6; i++) -- cgit v1.2.3 From 8b906eea4f5c36aa1ac3273de8daf83dbdd3f768 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 29 Oct 2013 07:41:10 +0100 Subject: remove captain obvious comment Signed-off-by: Stanislaw Halik --- facetracknoir/tracker.h | 3 --- 1 file changed, 3 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/tracker.h b/facetracknoir/tracker.h index c0ec0cf1..7b15cee7 100644 --- a/facetracknoir/tracker.h +++ b/facetracknoir/tracker.h @@ -18,9 +18,6 @@ class FaceTrackNoIR; // pre-define parent-class to avoid circular includes -// -// Structure to hold all variables concerning one of 6 DOF's -// class THeadPoseDOF { private: THeadPoseDOF(const THeadPoseDOF &) {} -- cgit v1.2.3 From fda36e3ec5a1c613a9c960868a2cca1463f63e25 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 29 Oct 2013 07:47:16 +0100 Subject: remove assignment operator Signed-off-by: Stanislaw Halik --- facetracknoir/tracker.h | 1 + 1 file changed, 1 insertion(+) (limited to 'facetracknoir') diff --git a/facetracknoir/tracker.h b/facetracknoir/tracker.h index 7b15cee7..1094c61b 100644 --- a/facetracknoir/tracker.h +++ b/facetracknoir/tracker.h @@ -21,6 +21,7 @@ class FaceTrackNoIR; // pre-define parent-class to avoid circular includes class THeadPoseDOF { private: THeadPoseDOF(const THeadPoseDOF &) {} + THeadPoseDOF& operator=(const THeadPoseDOF&) { return *this; } public: THeadPoseDOF() : headPos(0), -- cgit v1.2.3 From a5c8a7ed8edf60688b4c732d22db1c9a38c7c262 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 29 Oct 2013 07:50:00 +0100 Subject: remove third-party copyright notice Signed-off-by: Stanislaw Halik --- facetracknoir/tracker_types.h | 22 ---------------------- 1 file changed, 22 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/tracker_types.h b/facetracknoir/tracker_types.h index 54d1841e..a367371e 100644 --- a/facetracknoir/tracker_types.h +++ b/facetracknoir/tracker_types.h @@ -1,25 +1,3 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of the some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2010 - 2012 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -*********************************************************************************/ #ifndef __TRACKER_TYPES_H__ #define __TRACKER_TYPES_H__ -- cgit v1.2.3 From ee4b6e0f322cb781b146e38314afd2edbcb4e86c Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 29 Oct 2013 08:07:14 +0100 Subject: move var into ifdef'd portion --- facetracknoir/global-settings.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'facetracknoir') diff --git a/facetracknoir/global-settings.cpp b/facetracknoir/global-settings.cpp index aa334463..b198f327 100644 --- a/facetracknoir/global-settings.cpp +++ b/facetracknoir/global-settings.cpp @@ -84,8 +84,8 @@ SelectedLibraries::SelectedLibraries(IDynamicLibraryProvider* mainApp) : DynamicLibrary::DynamicLibrary(const QString& filename) { this->filename = filename; - QString fullPath = QCoreApplication::applicationDirPath() + "/" + this->filename; #if defined(_WIN32) + QString fullPath = QCoreApplication::applicationDirPath() + "/" + this->filename; handle = new QLibrary(fullPath); Dialog = (SETTINGS_FUNCTION) handle->resolve(MAYBE_STDCALL_UNDERSCORE "GetDialog" CALLING_CONVENTION_SUFFIX_VOID_FUNCTION); Constructor = (NULLARY_DYNAMIC_FUNCTION) handle->resolve(MAYBE_STDCALL_UNDERSCORE "GetConstructor" CALLING_CONVENTION_SUFFIX_VOID_FUNCTION); -- cgit v1.2.3 From f2669a28ec620144c5d4f2aa6f7a69c2668e433e Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 30 Oct 2013 17:35:29 +0100 Subject: pass warns Signed-off-by: Stanislaw Halik --- facetracknoir/facetracknoir.cpp | 5 ++--- facetracknoir/facetracknoir.h | 1 - 2 files changed, 2 insertions(+), 4 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index 7036e633..81f618b7 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -88,7 +88,6 @@ static void fill_combobox(const QString& filter, QList& list, Q } FaceTrackNoIR::FaceTrackNoIR(QWidget *parent) : - __opentrack_version__(OPENTRACK_VERSION), QMainWindow(parent), #if defined(_WIN32) keybindingWorker(NULL), @@ -101,8 +100,8 @@ FaceTrackNoIR::FaceTrackNoIR(QWidget *parent) : pSecondTrackerDialog(NULL), pProtocolDialog(NULL), pFilterDialog(NULL), - looping(false), - kbd_quit(QKeySequence("Ctrl+Q"), this) + kbd_quit(QKeySequence("Ctrl+Q"), this), + looping(false) { ui.setupUi(this); setFixedSize(size()); diff --git a/facetracknoir/facetracknoir.h b/facetracknoir/facetracknoir.h index 6547023b..385409ac 100644 --- a/facetracknoir/facetracknoir.h +++ b/facetracknoir/facetracknoir.h @@ -70,7 +70,6 @@ class FaceTrackNoIR : public QMainWindow, IDynamicLibraryProvider Q_OBJECT public: - volatile const char* __opentrack_version__; FaceTrackNoIR(QWidget *parent = 0); ~FaceTrackNoIR(); -- cgit v1.2.3 From 95f7e4c5b9608c550d008c662dc41fa049a6b725 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 30 Oct 2013 18:24:51 +0100 Subject: clean up the visibility mess in a messiest way possible Signed-off-by: Stanislaw Halik --- CMakeLists.txt | 13 ++++++++----- facetracknoir/global-settings.cpp | 12 ++++++++++++ facetracknoir/global-settings.h | 15 +++++++++++++++ opentrack-api/context.cpp | 15 +++++++++++---- opentrack-api/opentrack-guts.h | 24 +++++++++++++----------- opentrack-api/opentrack.h | 7 ++++++- 6 files changed, 65 insertions(+), 21 deletions(-) (limited to 'facetracknoir') diff --git a/CMakeLists.txt b/CMakeLists.txt index 239cafb5..1aafaa16 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -154,8 +154,8 @@ else() endif() # main app -file(GLOB opentrack-lib-c "opentrack-api/*.cpp") -file(GLOB opentrack-lib-h "opentrack-api/*.h") +file(GLOB opentrack-lib-c "opentrack-api/*.cpp" "facetracknoir/global-settings.cpp") +file(GLOB opentrack-lib-h "opentrack-api/*.h" "facetracknoir/global-settings.h") file(GLOB opentrack-bin-c "facetracknoir/*.cpp" "facetracknoir/*.rc") file(GLOB opentrack-bin-h "facetracknoir/*.h") @@ -614,9 +614,12 @@ configure_file("${CMAKE_SOURCE_DIR}/opentrack-version.h" "${CMAKE_BINARY_DIR}/op add_library(opentrack-api SHARED ${opentrack-lib-c} ${opentrack-lib-h} ${opentrack-lib-moc}) target_link_libraries(opentrack-api ${MY_QT_LIBS}) -if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) - SET_TARGET_PROPERTIES(opentrack-api - PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/opentrack-api/gnuc-version-script.txt") +if(CMAKE_COMPILER_IS_GNUCXX) + SET_TARGET_PROPERTIES(opentrack-api PROPERTIES + LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/opentrack-api/gnuc-version-script.txt" + COMPILE_FLAGS "-fvisibility=protected -fvisibility-inlines-hidden" + COMPILE_DEFINITIONS IN_OPENTRACK_API + ) endif() set_target_properties(opentrack PROPERTIES COMPILE_DEFINITIONS OPENTRACK_VERSION=\"${OPENTRACK__COMMIT}\") diff --git a/facetracknoir/global-settings.cpp b/facetracknoir/global-settings.cpp index b198f327..42646742 100644 --- a/facetracknoir/global-settings.cpp +++ b/facetracknoir/global-settings.cpp @@ -4,6 +4,12 @@ # include #endif +#ifdef IN_OPENTRACK_API +# ifdef __GNUC__ +# pragma GCC visibility push(protected) +# endif +#endif + SelectedLibraries* Libraries = NULL; SelectedLibraries::~SelectedLibraries() @@ -128,3 +134,9 @@ DynamicLibrary::~DynamicLibrary() (void) dlclose(handle); #endif } + +#ifdef IN_OPENTRACK_API +# ifdef __GNUC__ +# pragma GCC visibility pop +# endif +#endif diff --git a/facetracknoir/global-settings.h b/facetracknoir/global-settings.h index b2a54e20..ea36abac 100644 --- a/facetracknoir/global-settings.h +++ b/facetracknoir/global-settings.h @@ -12,6 +12,14 @@ # define MAYBE_STDCALL_UNDERSCORE "" #endif +#include + +#ifdef IN_OPENTRACK_API +# ifdef __GNUC__ +# pragma GCC visibility push(protected) +# endif +#endif + #include #include #include @@ -83,3 +91,10 @@ public: virtual DynamicLibrary* current_filter() = 0; virtual QFrame* get_video_widget() = 0; }; + + +#ifdef IN_OPENTRACK_API +# ifdef __GNUC__ +# pragma GCC visibility pop +# endif +#endif diff --git a/opentrack-api/context.cpp b/opentrack-api/context.cpp index 100acf5c..1fdf6713 100644 --- a/opentrack-api/context.cpp +++ b/opentrack-api/context.cpp @@ -17,7 +17,10 @@ # define LIB_PREFIX "lib" #endif -// shamelessly copied from core +#ifdef __GNUC__ +# pragma GCC visibility push(protected) +#endif + static Metadata* get_metadata(DynamicLibrary* lib, QString& longName, QIcon& icon) { Metadata* meta; @@ -89,20 +92,24 @@ opentrack_ctx::~opentrack_ctx() extern "C" { -const char** OPENTRACK_EXPORT opentrack_enum_trackers(opentrack ctx) +const char** opentrack_enum_trackers(opentrack ctx) { return const_cast(ctx->list); } -opentrack OPENTRACK_EXPORT opentrack_make_ctx(const char *dir) +opentrack opentrack_make_ctx(const char *dir) { QDir d(dir); return new opentrack_ctx(d); } -void OPENTRACK_EXPORT opentrack_finalize_ctx(opentrack foo) +void opentrack_finalize_ctx(opentrack foo) { delete foo; } } + +#ifdef __GNUC__ +# pragma GCC visibility pop +#endif diff --git a/opentrack-api/opentrack-guts.h b/opentrack-api/opentrack-guts.h index 3f8806cc..01463cfc 100644 --- a/opentrack-api/opentrack-guts.h +++ b/opentrack-api/opentrack-guts.h @@ -1,8 +1,9 @@ #pragma once -#include "ftnoir_tracker_base/ftnoir_tracker_base.h" -#include "facetracknoir/global-settings.h" -#include +#ifdef __GNUC__ +# pragma GCC visibility push(protected) +#endif + #include #include #include @@ -10,16 +11,13 @@ #include #include #include - -#ifdef __GNUC__ -# define OPENTRACK_HIDDEN __attribute__((visibility ("hidden"))) -#else -# define OPENTRACK_HIDDEN -#endif +#include +#include "ftnoir_tracker_base/ftnoir_tracker_base.h" +#include "facetracknoir/global-settings.h" typedef ITracker* opentrack_tracker; -class OPENTRACK_HIDDEN opentrack_meta { +class opentrack_meta { public: Metadata* meta; QString path; @@ -35,7 +33,7 @@ public: } }; -typedef class OPENTRACK_HIDDEN opentrack_ctx { +typedef class opentrack_ctx { public: QDir dir; char** list; @@ -44,3 +42,7 @@ public: opentrack_ctx(QDir& dir); ~opentrack_ctx(); } *opentrack; + +#ifdef __GNUC__ +# pragma GCC visibility pop +#endif diff --git a/opentrack-api/opentrack.h b/opentrack-api/opentrack.h index 8d28b5b8..1c8fcee5 100644 --- a/opentrack-api/opentrack.h +++ b/opentrack-api/opentrack.h @@ -15,7 +15,11 @@ typedef opentrack_opaque_tracker* opentrack_tracker; # ifdef _WIN32 # define OPENTRACK_EXPORT __declspec(dllexport) # else -# define OPENTRACK_EXPORT +# ifdef __GNUC__ +# define OPENTRACK_EXPORT __attribute__((visibility ("default"))) +# else +# define OPENTRACK_EXPORT +# endif # endif #else # ifdef _WIN32 @@ -55,3 +59,4 @@ void opentrack_finalize_tracker(opentrack_tracker tracker); #ifdef __cplusplus } #endif + -- cgit v1.2.3 From 9bd8a9d352f4f3c2d42ed50d93df8191d89ffb9d Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 30 Oct 2013 18:37:42 +0100 Subject: main: pass warns on mingw --- facetracknoir/facetracknoir.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index 81f618b7..1e83110c 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -800,8 +800,6 @@ void FaceTrackNoIR::bindKeyboardShortcuts() delete keybindingWorker; keybindingWorker = NULL; } - const int idx_center = iniFile.value("Key_index_Center", 0).toInt(); - const int idx_toggle = iniFile.value("Key_index_Toggle", 0).toInt(); keybindingWorker = new KeybindingWorker(*this, keyCenter, keyToggle); keybindingWorker->start(); #endif -- cgit v1.2.3 From 5eb570d1608e2071c0d01412925ac43768770624 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 30 Oct 2013 18:40:06 +0100 Subject: end this foolishness, a linker script is more than enough Signed-off-by: Stanislaw Halik --- facetracknoir/global-settings.cpp | 12 ------------ facetracknoir/global-settings.h | 13 ------------- opentrack-api/context.cpp | 7 ------- opentrack-api/opentrack-guts.h | 8 -------- 4 files changed, 40 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/global-settings.cpp b/facetracknoir/global-settings.cpp index 42646742..b198f327 100644 --- a/facetracknoir/global-settings.cpp +++ b/facetracknoir/global-settings.cpp @@ -4,12 +4,6 @@ # include #endif -#ifdef IN_OPENTRACK_API -# ifdef __GNUC__ -# pragma GCC visibility push(protected) -# endif -#endif - SelectedLibraries* Libraries = NULL; SelectedLibraries::~SelectedLibraries() @@ -134,9 +128,3 @@ DynamicLibrary::~DynamicLibrary() (void) dlclose(handle); #endif } - -#ifdef IN_OPENTRACK_API -# ifdef __GNUC__ -# pragma GCC visibility pop -# endif -#endif diff --git a/facetracknoir/global-settings.h b/facetracknoir/global-settings.h index ea36abac..3e24bf74 100644 --- a/facetracknoir/global-settings.h +++ b/facetracknoir/global-settings.h @@ -14,12 +14,6 @@ #include -#ifdef IN_OPENTRACK_API -# ifdef __GNUC__ -# pragma GCC visibility push(protected) -# endif -#endif - #include #include #include @@ -91,10 +85,3 @@ public: virtual DynamicLibrary* current_filter() = 0; virtual QFrame* get_video_widget() = 0; }; - - -#ifdef IN_OPENTRACK_API -# ifdef __GNUC__ -# pragma GCC visibility pop -# endif -#endif diff --git a/opentrack-api/context.cpp b/opentrack-api/context.cpp index 1fdf6713..003377ce 100644 --- a/opentrack-api/context.cpp +++ b/opentrack-api/context.cpp @@ -17,10 +17,6 @@ # define LIB_PREFIX "lib" #endif -#ifdef __GNUC__ -# pragma GCC visibility push(protected) -#endif - static Metadata* get_metadata(DynamicLibrary* lib, QString& longName, QIcon& icon) { Metadata* meta; @@ -110,6 +106,3 @@ void opentrack_finalize_ctx(opentrack foo) } -#ifdef __GNUC__ -# pragma GCC visibility pop -#endif diff --git a/opentrack-api/opentrack-guts.h b/opentrack-api/opentrack-guts.h index 01463cfc..b9c3878b 100644 --- a/opentrack-api/opentrack-guts.h +++ b/opentrack-api/opentrack-guts.h @@ -1,9 +1,5 @@ #pragma once -#ifdef __GNUC__ -# pragma GCC visibility push(protected) -#endif - #include #include #include @@ -42,7 +38,3 @@ public: opentrack_ctx(QDir& dir); ~opentrack_ctx(); } *opentrack; - -#ifdef __GNUC__ -# pragma GCC visibility pop -#endif -- cgit v1.2.3 From 949d013c0a0fa51f8a2b55719c1ab2b4fcbbbcd8 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 30 Oct 2013 21:10:19 +0100 Subject: fix recentering Signed-off-by: Stanislaw Halik --- facetracknoir/tracker.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/tracker.cpp b/facetracknoir/tracker.cpp index c1b7b3af..adfff34c 100644 --- a/facetracknoir/tracker.cpp +++ b/facetracknoir/tracker.cpp @@ -49,7 +49,7 @@ static void get_curve(double pos, double& out, THeadPoseDOF& axis) { /** QThread run method @override **/ void Tracker::run() { - T6DOF offset_camera, gameoutput_camera; + T6DOF offset_camera, gameoutput_camera, target_camera; bool bTracker1Confid = false; bool bTracker2Confid = false; @@ -75,7 +75,6 @@ void Tracker::run() { } { - T6DOF target_camera; QMutexLocker foo(&mtx); const bool confid = bTracker1Confid || bTracker2Confid; -- cgit v1.2.3 From 067b88814f4fdfe0b0be1d86a01f081d2b61c8a1 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 31 Oct 2013 07:45:46 +0100 Subject: add credit to original author Signed-off-by: Stanislaw Halik --- facetracknoir/tracker.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'facetracknoir') diff --git a/facetracknoir/tracker.cpp b/facetracknoir/tracker.cpp index adfff34c..b4e73e08 100644 --- a/facetracknoir/tracker.cpp +++ b/facetracknoir/tracker.cpp @@ -8,6 +8,8 @@ /* * this file appeared originally in facetracknoir, was rewritten completely * following opentrack fork. + * + * originally written by Wim Vriend. */ #include "tracker.h" -- cgit v1.2.3 From 6e1aa998ea5d2f54c704fdbaad1008bb2472825e Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 3 Nov 2013 14:08:11 +0100 Subject: "fix" crapintosh build --- CMakeLists.txt | 32 ++++++++++++++++++++++++++------ FTNoIR_Tracker_PT/camera.cpp | 2 +- facetracknoir/facetracknoir.cpp | 2 +- qxt-mini/qxtglobalshortcut.cpp | 12 ++++++------ qxt-mini/qxtglobalshortcut_p.h | 10 ++++++---- 5 files changed, 40 insertions(+), 18 deletions(-) (limited to 'facetracknoir') diff --git a/CMakeLists.txt b/CMakeLists.txt index c1cc757e..952584e4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -327,7 +327,7 @@ if(SDK_XPLANE) LIBRARY_OUTPUT_NAME "opentrack.xpl" PREFIX "" SUFFIX "") endif() - if(UNIX) + if(UNIX AND NOT APPLE) target_link_libraries(opentrack-xplane-plugin rt) endif() endif() @@ -345,7 +345,7 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) endif() add_library(opentrack-compat SHARED ${opentrack-compat-c} ${opentrack-compat-h}) -if(NOT WIN32) +if(NOT WIN32 AND NOT APPLE) target_link_libraries(opentrack-compat rt) endif() @@ -354,7 +354,12 @@ endif() if(WIN32) set(my-qt-deps ws2_32) endif() -SET(MY_QT_LIBS ${Qt5Widgets_LIBRARIES} ${Qt5Gui_LIBRARIES} ${Qt5Network_LIBRARIES} ${Qt5Xml_LIBRARIES} ${Qt5Core_LIBRARIES} ${my-qt-deps}) +if(APPLE) + link_directories(${CMAKE_INSTALL_PREFIX}) + SET(MY_QT_LIBS QtWidgets QtGui QtNetwork QtXml QtCore) +else() + SET(MY_QT_LIBS ${Qt5Widgets_LIBRARIES} ${Qt5Gui_LIBRARIES} ${Qt5Network_LIBRARIES} ${Qt5Xml_LIBRARIES} ${Qt5Core_LIBRARIES} ${my-qt-deps}) +endif() add_library(opentrack-csv SHARED ${opentrack-csv-c} ${opentrack-csv-h}) target_link_libraries(opentrack-csv ${MY_QT_LIBS}) @@ -550,7 +555,11 @@ if(SDK_RIFT) if(WIN32) target_link_libraries(opentrack-tracker-rift "${SDK_RIFT}/libLibOVR.a" winmm.lib setupapi.lib) else() - target_link_libraries(opentrack-tracker-rift "${SDK_RIFT}/libLibOVR.a" udev Xinerama) + if (NOT APPLE) + target_link_libraries(opentrack-tracker-rift "${SDK_RIFT}/libLibOVR.a" udev Xinerama) + else() # crapintosh + target_link_libraries(opentrack-tracker-rift "${SDK_RIFT}/libLibOVR.a") + endif() endif() endif() if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) @@ -560,6 +569,10 @@ if(SDK_RIFT) COMPILE_FLAGS "-fno-strict-aliasing" ) endif() + if(APPLE) + SET_TARGET_PROPERTIES(opentrack-tracker-rift + PROPERTIES LINK_FLAGS "-framework CoreFoundation -framework CoreGraphics -framework IOKit -framework Quartz") + endif() endif() if(SDK_HYDRA) @@ -604,16 +617,23 @@ if(WIN32 AND NOT SDK_CONSOLE_DEBUG) else() set(opentrack-win32-executable "") endif() -if(UNIX) +if(UNIX OR APPLE) add_library(opentrack-qxt-mini SHARED ${qxt-mini-c}) SET_TARGET_PROPERTIES(opentrack-qxt-mini PROPERTIES COMPILE_FLAGS "-DBUILD_QXT_CORE=42 -DBUILD_QXT_WIDGETS=42 -DBUILD_QXT_GUI=42") - target_link_libraries(opentrack-qxt-mini ${MY_QT_LIBS} X11) + target_link_libraries(opentrack-qxt-mini ${MY_QT_LIBS}) + if(NOT APPLE) + target_link_libraries(opentrack-qxt-mini X11) + endif() endif() add_executable(opentrack ${opentrack-win32-executable} ${opentrack-bin-c} ${opentrack-bin-h} ${opentrack-bin-moc} ${opentrack-bin-uih} ${opentrack-bin-rcc}) set_target_properties(opentrack PROPERTIES COMPILE_DEFINITIONS OPENTRACK_VERSION=\"${OPENTRACK__COMMIT}\") set(OPENTRACK_COMMIT_VERSION \"${OPENTRACK__COMMIT}\") configure_file("${CMAKE_SOURCE_DIR}/opentrack-version.h" "${CMAKE_BINARY_DIR}/opentrack-version.h" @ONLY NEWLINE_STYLE UNIX) +if(APPLE) + SET_TARGET_PROPERTIES(opentrack-qxt-mini PROPERTIES LINK_FLAGS "-framework Carbon -framework CoreFoundation") +endif() + add_library(opentrack-api SHARED ${opentrack-lib-c} ${opentrack-lib-h} ${opentrack-lib-moc}) target_link_libraries(opentrack-api ${MY_QT_LIBS}) if(CMAKE_COMPILER_IS_GNUCXX) diff --git a/FTNoIR_Tracker_PT/camera.cpp b/FTNoIR_Tracker_PT/camera.cpp index e5ecdc99..b4d2509f 100644 --- a/FTNoIR_Tracker_PT/camera.cpp +++ b/FTNoIR_Tracker_PT/camera.cpp @@ -11,7 +11,7 @@ using namespace cv; -#if defined(OPENTRACK_API) && (defined(__unix) || defined(__linux)) +#if defined(OPENTRACK_API) && (defined(__unix) || defined(__linux) || defined(__APPLE__)) #include #endif diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index 1e83110c..ef470c7a 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -49,7 +49,7 @@ # define LIB_PREFIX "lib" #endif -#if defined(__unix) || defined(__linux) +#if defined(__unix) || defined(__linux) || defined(__APPLE__) # include #endif diff --git a/qxt-mini/qxtglobalshortcut.cpp b/qxt-mini/qxtglobalshortcut.cpp index 72548d6f..44b9f917 100644 --- a/qxt-mini/qxtglobalshortcut.cpp +++ b/qxt-mini/qxtglobalshortcut.cpp @@ -33,17 +33,17 @@ #include #include -#ifndef Q_WS_MAC +#ifndef Q_OS_MAC int QxtGlobalShortcutPrivate::ref = 0; # if QT_VERSION < QT_VERSION_CHECK(5,0,0) QAbstractEventDispatcher::EventFilter QxtGlobalShortcutPrivate::prevEventFilter = 0; # endif -#endif // Q_WS_MAC +#endif // Q_OS_MAC QHash, QxtGlobalShortcut*> QxtGlobalShortcutPrivate::shortcuts; QxtGlobalShortcutPrivate::QxtGlobalShortcutPrivate() : enabled(true), key(Qt::Key(0)), mods(Qt::NoModifier) { -#ifndef Q_WS_MAC +#ifndef Q_OS_MAC if (ref == 0) { # if QT_VERSION < QT_VERSION_CHECK(5,0,0) prevEventFilter = QAbstractEventDispatcher::instance()->setEventFilter(eventFilter); @@ -52,12 +52,12 @@ QxtGlobalShortcutPrivate::QxtGlobalShortcutPrivate() : enabled(true), key(Qt::Ke #endif } ++ref; -#endif // Q_WS_MAC +#endif // Q_OS_MAC } QxtGlobalShortcutPrivate::~QxtGlobalShortcutPrivate() { -#ifndef Q_WS_MAC +#ifndef Q_OS_MAC --ref; if (ref == 0) { QAbstractEventDispatcher *ed = QAbstractEventDispatcher::instance(); @@ -69,7 +69,7 @@ QxtGlobalShortcutPrivate::~QxtGlobalShortcutPrivate() # endif } } -#endif // Q_WS_MAC +#endif // Q_OS_MAC } bool QxtGlobalShortcutPrivate::setShortcut(const QKeySequence& shortcut) diff --git a/qxt-mini/qxtglobalshortcut_p.h b/qxt-mini/qxtglobalshortcut_p.h index 1a788852..0d88b354 100644 --- a/qxt-mini/qxtglobalshortcut_p.h +++ b/qxt-mini/qxtglobalshortcut_p.h @@ -59,14 +59,16 @@ public: bool unsetShortcut(); static bool error; -#ifndef Q_WS_MAC +#ifndef Q_OS_DARWIN static int ref; -#if QT_VERSION < QT_VERSION_CHECK(5,0,0) +# if QT_VERSION < QT_VERSION_CHECK(5,0,0) static QAbstractEventDispatcher::EventFilter prevEventFilter; static bool eventFilter(void* message); -#else +# else virtual bool nativeEventFilter(const QByteArray & eventType, void * message, long * result); -#endif // QT_VERSION < QT_VERSION_CHECK(5,0,0) +# endif // QT_VERSION < QT_VERSION_CHECK(5,0,0) +# else + virtual bool nativeEventFilter(const QByteArray & eventType, void * message, long * result) {} #endif // Q_WS_MAC static void activateShortcut(quint32 nativeKey, quint32 nativeMods); -- cgit v1.2.3 From bbaefce3a90b3c45f23e494f76ed15fa9a00d5e8 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 3 Nov 2013 21:34:49 +0100 Subject: fix apple build --- CMakeLists.txt | 31 ++++++++++++++++++++++--------- compat/compat.cpp | 19 ++++++------------- compat/compat.h | 3 ++- facetracknoir/main.cpp | 6 ++++++ ftnoir_tracker_ht/ftnoir_tracker_ht.cpp | 18 +++++++++--------- 5 files changed, 45 insertions(+), 32 deletions(-) (limited to 'facetracknoir') diff --git a/CMakeLists.txt b/CMakeLists.txt index d17279c2..242d200d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,7 +9,7 @@ if(GIT_FOUND) endif() SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) -SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) +set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) SET(CMAKE_SKIP_INSTALL_RPATH FALSE) SET(CMAKE_SKIP_RPATH FALSE) SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}") @@ -23,8 +23,12 @@ if(MSVC) add_definitions(-DNOMINMAX) endif() -if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - add_definitions(-std=c++11) +if(NOT APPLE) + if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + add_definitions(-std=c++11) + endif() +else() + set(CMAKE_CXX_FLAGS " -std=c++11 ${CMAKE_CXX_FLAGS}") endif() if(CMAKE_COMPILER_IS_GNUCXX) @@ -92,7 +96,7 @@ endif() find_package(OpenCV REQUIRED) find_package(Qt5 REQUIRED COMPONENTS Core Xml Network Widgets Gui QUIET) - cmake_policy(SET CMP0020 NEW) + cmake_policy(SET CMP0020 NEW) include_directories(${Qt5Core_INCLUDE_DIRS} ${Qt5Xml_INCLUDE_DIRS} ${Qt5Gui_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS} ${Qt5Network_INCLUDE_DIRS}) add_definitions(${Qt5Core_DEFINITIONS} ${Qt5Xml_DEFINITIONS} ${Qt5Gui_DEFINITIONS} ${Qt5Widgets_DEFINITIONS} ${Qt5Network_DEFINITIONS}) @@ -328,9 +332,9 @@ if(SDK_XPLANE) PREFIX "" SUFFIX "") endif() if(APPLE) - SET_TARGET_PROPERTIES(opentrack-xplane-plugin - COMPILE_FLAGS "-DAPL -DXPLM210 -framework XPLM -framework XPWidgets" - LINK_FLAGS "-framework XPLM -framework XPWidgets") + SET_TARGET_PROPERTIES(opentrack-xplane-plugin PROPERTIES + COMPILE_FLAGS "-iframework ${SDK_XPLANE}/Libraries/Mac/ -DAPL -DXPLM210 -framework XPLM -framework XPWidgets" + LINK_FLAGS "-F${SDK_XPLANE}/Libraries/Mac/ -framework XPLM -framework XPWidgets") endif() if(UNIX AND NOT APPLE) target_link_libraries(opentrack-xplane-plugin rt) @@ -360,7 +364,12 @@ if(WIN32) set(my-qt-deps ws2_32) endif() -SET(MY_QT_LIBS ${Qt5Widgets_LIBRARIES} ${Qt5Gui_LIBRARIES} ${Qt5Network_LIBRARIES} ${Qt5Xml_LIBRARIES} ${Qt5Core_LIBRARIES} ${my-qt-deps}) +if(APPLE) + link_directories(${CMAKE_INSTALL_PREFIX}) + set(MY_QT_LIBS Qt5Widgets Qt5Gui Qt5Network Qt5Xml Qt5Core ${my-qt-deps}) +else() + SET(MY_QT_LIBS ${Qt5Widgets_LIBRARIES} ${Qt5Gui_LIBRARIES} ${Qt5Network_LIBRARIES} ${Qt5Xml_LIBRARIES} ${Qt5Core_LIBRARIES} ${my-qt-deps}) +endif() add_library(opentrack-csv SHARED ${opentrack-csv-c} ${opentrack-csv-h}) target_link_libraries(opentrack-csv ${MY_QT_LIBS}) @@ -470,6 +479,10 @@ if(NOT WIN32 AND SDK_WINE_PREFIX) PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt") endif() if(NOT SDK_WINE_NO_WRAPPER) + set(my-rt -lrt) + if(APPLE) + set(my-rt) + endif() add_custom_command( OUTPUT opentrack-wrapper-wine.exe.so DEPENDS "${CMAKE_SOURCE_DIR}/ftnoir_protocol_wine/opentrack-wrapper-wine-main.cxx" @@ -480,7 +493,7 @@ if(NOT WIN32 AND SDK_WINE_PREFIX) "${CMAKE_SOURCE_DIR}/ftnoir_protocol_wine/opentrack-wrapper-wine-main.cxx" "${CMAKE_SOURCE_DIR}/ftnoir_protocol_wine/opentrack-wrapper-wine-posix.cxx" "${CMAKE_SOURCE_DIR}/ftnoir_protocol_wine/opentrack-wrapper-wine-windows.cxx" - -lrt) + ${my-rt}) add_custom_target(wine-wrapper ALL DEPENDS opentrack-wrapper-wine.exe.so) add_dependencies(wine-wrapper opentrack-compat opentrack-proto-wine) endif() diff --git a/compat/compat.cpp b/compat/compat.cpp index bcdbd17f..7b695617 100644 --- a/compat/compat.cpp +++ b/compat/compat.cpp @@ -6,8 +6,7 @@ */ #define IN_FTNOIR_COMPAT #include "compat.h" -#include -#include +#include #if defined(_WIN32) @@ -48,17 +47,11 @@ void PortableLockedShm::unlock() #else PortableLockedShm::PortableLockedShm(const char *shmName, const char* /*mutexName*/, int mapSize) : size(mapSize) { - std::string filename; - filename.append("/"); - filename.append(shmName); - //(void) shm_unlink(shm_filename); - - fd = shm_open(filename.c_str(), O_RDWR | O_CREAT, 0600); - if (ftruncate(fd, mapSize) == 0) { ;; } - else { - fprintf(stderr, "oh, bother, ftruncate: %s\n", strerror(errno)); - //mem = (void*) -1; - } + char filename[512] = {0}; + strcpy(filename, "/"); + strcat(filename, shmName); + fd = shm_open(filename, O_RDWR | O_CREAT, 0600); + (void) ftruncate(fd, mapSize); mem = mmap(NULL, mapSize, PROT_READ|PROT_WRITE, MAP_SHARED, fd, (off_t)0); } diff --git a/compat/compat.h b/compat/compat.h index 8c307b14..60395830 100644 --- a/compat/compat.h +++ b/compat/compat.h @@ -7,7 +7,8 @@ #pragma once #if defined(_WIN32) -#include +#include +#include #else #include #include diff --git a/facetracknoir/main.cpp b/facetracknoir/main.cpp index e643bcd3..23703ef3 100644 --- a/facetracknoir/main.cpp +++ b/facetracknoir/main.cpp @@ -28,6 +28,8 @@ #include #include #include +#include +#include #if defined(_WIN32) && defined(_MSC_VER) # include @@ -59,6 +61,10 @@ int main(int argc, char** argv) #endif QApplication::setAttribute(Qt::AA_X11InitThreads, true); QApplication app(argc, argv); +#ifdef __APPLE__ + QDir dir(QCoreApplication::applicationDirPath()); + QCoreApplication::setLibraryPaths(QStringList(dir.absolutePath())); +#endif FaceTrackNoIR w; QDesktopWidget desktop; diff --git a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp index db0ef6d6..77eede52 100644 --- a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp +++ b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp @@ -62,7 +62,7 @@ static QList get_camera_names(void) { pEnumCat->Release(); } pSysDevEnum->Release(); -#else +#elsif !defined(__APPLE__) for (int i = 0; i < 16; i++) { char buf[128]; sprintf(buf, "/dev/video%d", i); @@ -281,15 +281,15 @@ TrackerControls::TrackerControls() { ui.setupUi(this); setAttribute(Qt::WA_NativeWindow, true); - connect(ui.cameraName, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.cameraFPS, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged(int))); + connect(ui.cameraName, SIGNAL(valueChanged(int)), this, SLOT(settingChanged(int))); + connect(ui.cameraFPS, SIGNAL(valueChanged(int)), this, SLOT(settingChanged(int))); connect(ui.cameraFOV, SIGNAL(valueChanged(double)), this, SLOT(settingChanged(double))); - connect(ui.rx, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.ry, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.rz, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.tx, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.ty, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.tz, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); + connect(ui.rx, SIGNAL(valueChanged(int)), this, SLOT(settingChanged(int))); + connect(ui.ry, SIGNAL(valueChanged(int)), this, SLOT(settingChanged(int))); + connect(ui.rz, SIGNAL(valueChanged(int)), this, SLOT(settingChanged(int))); + connect(ui.tx, SIGNAL(valueChanged(int)), this, SLOT(settingChanged(int))); + connect(ui.ty, SIGNAL(valueChanged(int)), this, SLOT(settingChanged(int))); + connect(ui.tz, SIGNAL(valueChanged(int)), this, SLOT(settingChanged(int))); connect(ui.buttonCancel, SIGNAL(clicked()), this, SLOT(doCancel())); connect(ui.buttonOK, SIGNAL(clicked()), this, SLOT(doOK())); //connect(ui.buttonSettings, SIGNAL(clicked()), this, SLOT(cameraSettings())); -- cgit v1.2.3 From eaa69914338be6df77e101ba374a8a184655a7a6 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 3 Nov 2013 21:35:35 +0100 Subject: fix dyld Signed-off-by: Stanislaw Halik --- facetracknoir/global-settings.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'facetracknoir') diff --git a/facetracknoir/global-settings.cpp b/facetracknoir/global-settings.cpp index b198f327..316859c5 100644 --- a/facetracknoir/global-settings.cpp +++ b/facetracknoir/global-settings.cpp @@ -95,6 +95,8 @@ DynamicLibrary::DynamicLibrary(const QString& filename) handle = dlopen(latin1.constData(), RTLD_NOW | # ifdef __linux RTLD_DEEPBIND +# elif defined(__APPLE__) + RTLD_LOCAL # else 0 # endif -- cgit v1.2.3 From c4654c992ec2cad51d28b0b8e81c2e5e7e604c8b Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 3 Nov 2013 21:56:12 +0100 Subject: fix dyld harder --- facetracknoir/global-settings.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'facetracknoir') diff --git a/facetracknoir/global-settings.cpp b/facetracknoir/global-settings.cpp index 316859c5..3b627860 100644 --- a/facetracknoir/global-settings.cpp +++ b/facetracknoir/global-settings.cpp @@ -96,7 +96,7 @@ DynamicLibrary::DynamicLibrary(const QString& filename) # ifdef __linux RTLD_DEEPBIND # elif defined(__APPLE__) - RTLD_LOCAL + RTLD_LOCAL|RTLD_FIRST|RTLD_NOW # else 0 # endif -- cgit v1.2.3 From 66a84f555958a47dbaff4c3fb6898f02122b5006 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 5 Nov 2013 09:21:31 +0100 Subject: possibly really fix the crash on macosx Signed-off-by: Stanislaw Halik --- facetracknoir/facetracknoir.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.h b/facetracknoir/facetracknoir.h index 385409ac..72ccebd8 100644 --- a/facetracknoir/facetracknoir.h +++ b/facetracknoir/facetracknoir.h @@ -132,7 +132,7 @@ private: void bind_keyboard_shortcut(QxtGlobalShortcut& key, const QString label, QSettings& iniFile); #endif - bool looping; + volatile bool looping; private slots: //file menu -- cgit v1.2.3 From 8aec2c52ec39e2f2e350acc8d09899821404951b Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 5 Nov 2013 09:28:47 +0100 Subject: get rid of dubious cast Signed-off-by: Stanislaw Halik --- facetracknoir/facetracknoir.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index ef470c7a..fc4aac51 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -410,12 +410,17 @@ void FaceTrackNoIR::loadSettings() { } } + CurveConfigurationDialog* ccd = nullptr; + if (!_curve_config) { - _curve_config = new CurveConfigurationDialog( this, this ); + ccd = new CurveConfigurationDialog( this, this ); + _curve_config = ccd; + } else { + ccd = dynamic_cast(_curve_config); } - ((CurveConfigurationDialog*)_curve_config)->loadSettings(); + ccd->loadSettings(); looping = false; } -- cgit v1.2.3 From 37ea681b9f89f864b74c1930550f65e9c70bffce Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 5 Nov 2013 09:29:52 +0100 Subject: don't needlessly initialize Signed-off-by: Stanislaw Halik --- facetracknoir/facetracknoir.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index fc4aac51..844305e9 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -410,7 +410,7 @@ void FaceTrackNoIR::loadSettings() { } } - CurveConfigurationDialog* ccd = nullptr; + CurveConfigurationDialog* ccd; if (!_curve_config) { -- cgit v1.2.3 From b6c2ce4f26a31fd521f56994fb64963b30b77cd5 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 5 Nov 2013 09:40:19 +0100 Subject: shotgun debugging continues Signed-off-by: Stanislaw Halik --- facetracknoir/facetracknoir.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index 844305e9..55a0f4cb 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -332,6 +332,8 @@ void FaceTrackNoIR::saveAs() } void FaceTrackNoIR::loadSettings() { + if (looping) + return; looping = true; qDebug() << "loadSettings says: Starting "; QSettings settings("opentrack"); -- cgit v1.2.3 From 2937ae5a8780b4d82178c3762294bb1c3eb4c95c Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 10 Nov 2013 22:11:19 +0100 Subject: hopefully fix qxt/qt eating letter keys Signed-off-by: Stanislaw Halik --- facetracknoir/facetracknoir.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index 55a0f4cb..1227f6a0 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -758,7 +758,7 @@ void FaceTrackNoIR::bind_keyboard_shortcut(QxtGlobalShortcut& key, const QString seq = "Alt+" + seq; if (iniFile.value(QString("Ctrl_%1").arg(label), false).toBool()) seq = "Ctrl+" + seq; - key.setShortcut(QKeySequence::fromString(seq, QKeySequence::NativeText)); + key.setShortcut(QKeySequence::fromString(seq)); key.setEnabled(); } } -- cgit v1.2.3 From 0d75fa2f92e41dce578aef99579f21bd3f6d20fa Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 22 Nov 2013 15:22:29 +0100 Subject: disable unreferenced shortcuts --- facetracknoir/facetracknoir.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index 1227f6a0..b000b304 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -758,9 +758,11 @@ void FaceTrackNoIR::bind_keyboard_shortcut(QxtGlobalShortcut& key, const QString seq = "Alt+" + seq; if (iniFile.value(QString("Ctrl_%1").arg(label), false).toBool()) seq = "Ctrl+" + seq; - key.setShortcut(QKeySequence::fromString(seq)); + key.setShortcut(QKeySequence::fromString(seq, QKeySequence::PortableText)); key.setEnabled(); - } + } else { + key.setDisabled(); + } } } #else -- cgit v1.2.3 From db246232e898e9c4b351e80cede0dbea271ca8b8 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 22 Nov 2013 15:22:52 +0100 Subject: don't bind shortcuts unless tracker running --- facetracknoir/shortcuts.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'facetracknoir') diff --git a/facetracknoir/shortcuts.cpp b/facetracknoir/shortcuts.cpp index 09663a0f..6a972aa3 100644 --- a/facetracknoir/shortcuts.cpp +++ b/facetracknoir/shortcuts.cpp @@ -36,7 +36,8 @@ KeyboardShortcutDialog::~KeyboardShortcutDialog() { void KeyboardShortcutDialog::doOK() { save(); this->close(); - mainApp->bindKeyboardShortcuts(); + if (mainApp->tracker) + mainApp->bindKeyboardShortcuts(); } void KeyboardShortcutDialog::showEvent ( QShowEvent * ) { -- cgit v1.2.3 From bc1af5cbeb776b62db89a51dd8b34fa3f31c998c Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 24 Nov 2013 02:20:01 +0100 Subject: fix ini key name for compensation Signed-off-by: Stanislaw Halik --- facetracknoir/curve-config.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/curve-config.cpp b/facetracknoir/curve-config.cpp index 65470339..ca9e0d19 100644 --- a/facetracknoir/curve-config.cpp +++ b/facetracknoir/curve-config.cpp @@ -96,7 +96,7 @@ void CurveConfigurationDialog::loadSettings() { iniFile.beginGroup("Tracking"); - ui.checkBox->setChecked(iniFile.value("compensation", true).toBool()); + ui.checkBox->setChecked(iniFile.value("compensate", true).toBool()); for (int i = 0; i < 6; i++) mainApp->axis(i).altp = iniFile.value(names[i], false).toBool(); @@ -219,7 +219,7 @@ void CurveConfigurationDialog::save() { bool compensate = true; - iniFile.setValue("compensation", compensate = (bool) !!ui.checkBox->isChecked()); + iniFile.setValue("compensate", compensate = (bool) !!ui.checkBox->isChecked()); if (mainApp->tracker) mainApp->tracker->compensate = compensate; -- cgit v1.2.3 From a8750aae7ed86edd9f28f39f09f4650d9fe00666 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 24 Nov 2013 02:25:57 +0100 Subject: fix qsettings group mismatch Signed-off-by: Stanislaw Halik --- facetracknoir/facetracknoir.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index b000b304..1f3ae3a2 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -492,12 +492,12 @@ void FaceTrackNoIR::startTracker( ) { axis(i).invert = iniFile.value(invert_names[i], false).toBool() ? 1 : -1; } - iniFile.endGroup(); - - tracker = new Tracker ( this ); + tracker = new Tracker ( this ); tracker->compensate = iniFile.value("compensate", true).toBool(); + iniFile.endGroup(); + tracker->setInvertAxis(Yaw, ui.chkInvertYaw->isChecked() ); tracker->setInvertAxis(Pitch, ui.chkInvertPitch->isChecked() ); tracker->setInvertAxis(Roll, ui.chkInvertRoll->isChecked() ); -- cgit v1.2.3 From 60a79a5b244dbe9cc51fb5ee6fe784ccb374e917 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 24 Nov 2013 06:07:25 +0100 Subject: decruft main --- facetracknoir/main.cpp | 4 ---- 1 file changed, 4 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/main.cpp b/facetracknoir/main.cpp index 23703ef3..5ba3fcd5 100644 --- a/facetracknoir/main.cpp +++ b/facetracknoir/main.cpp @@ -61,10 +61,6 @@ int main(int argc, char** argv) #endif QApplication::setAttribute(Qt::AA_X11InitThreads, true); QApplication app(argc, argv); -#ifdef __APPLE__ - QDir dir(QCoreApplication::applicationDirPath()); - QCoreApplication::setLibraryPaths(QStringList(dir.absolutePath())); -#endif FaceTrackNoIR w; QDesktopWidget desktop; -- cgit v1.2.3 From c972f37886e3db405f30b713b96a3dedf72675b6 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 26 Nov 2013 19:42:35 +0100 Subject: add virtual override safety while preserving M$VC brain damage --- facetracknoir/global-settings.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'facetracknoir') diff --git a/facetracknoir/global-settings.h b/facetracknoir/global-settings.h index 3e24bf74..6b04b73b 100644 --- a/facetracknoir/global-settings.h +++ b/facetracknoir/global-settings.h @@ -12,6 +12,12 @@ # define MAYBE_STDCALL_UNDERSCORE "" #endif +#ifdef _MSC_VER +# define virt_override +#else +# define virt_override override +#endif + #include #include -- cgit v1.2.3 From 324f47f0740dda04cc37674d817b1bfcd1a7ec48 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 26 Nov 2013 19:43:01 +0100 Subject: use tracker-declared Hz --- facetracknoir/tracker.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'facetracknoir') diff --git a/facetracknoir/tracker.cpp b/facetracknoir/tracker.cpp index b4e73e08..6c48b17a 100644 --- a/facetracknoir/tracker.cpp +++ b/facetracknoir/tracker.cpp @@ -16,6 +16,7 @@ #include "facetracknoir.h" #include #include +#include #if defined(_WIN32) # include @@ -59,6 +60,16 @@ void Tracker::run() { double newpose[6] = {0}; double last_post_filter[6] ; + int sleep_ms = 15; + + if (Libraries->pTracker) + sleep_ms = std::min(sleep_ms, 1000 / Libraries->pTracker->preferredHz()); + + if (Libraries->pSecondTracker) + sleep_ms = std::min(sleep_ms, 1000 / Libraries->pSecondTracker->preferredHz()); + + qDebug() << "tracker Hz:" << 1000 / sleep_ms; + #if defined(_WIN32) (void) timeBeginPeriod(1); #endif @@ -156,7 +167,7 @@ void Tracker::run() { } } - msleep(15); + msleep(sleep_ms); } #if defined(_WIN32) (void) timeEndPeriod(1); -- cgit v1.2.3 From 5f17327c0d9d5bd2da69139a324434d461519403 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 27 Nov 2013 01:33:53 +0100 Subject: initial import of hatire by Furax49 Signed-off-by: Stanislaw Halik --- CMakeLists.txt | 16 +- facetracknoir/clientfiles/HAT_100/HAT_100.ino | 389 +++++++ facetracknoir/clientfiles/HAT_100/README | 35 + ftnoir_tracker_hatire/ftnoir_arduino_type.h | 31 + ftnoir_tracker_hatire/ftnoir_hat.qrc | 6 + ftnoir_tracker_hatire/ftnoir_hatcontrols.ui | 1066 ++++++++++++++++++++ ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp | 304 ++++++ ftnoir_tracker_hatire/ftnoir_tracker_hat.h | 102 ++ ftnoir_tracker_hatire/ftnoir_tracker_hat.rc | 61 ++ .../ftnoir_tracker_hat_dialog.cpp | 299 ++++++ ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.h | 78 ++ ftnoir_tracker_hatire/ftnoir_tracker_hat_dll.cpp | 79 ++ .../ftnoir_tracker_hat_settings.cpp | 102 ++ .../ftnoir_tracker_hat_settings.h | 44 + ftnoir_tracker_hatire/images/hat.ico | Bin 0 -> 1150 bytes ftnoir_tracker_hatire/images/hat_logo.png | Bin 0 -> 15210 bytes 16 files changed, 2611 insertions(+), 1 deletion(-) create mode 100644 facetracknoir/clientfiles/HAT_100/HAT_100.ino create mode 100644 facetracknoir/clientfiles/HAT_100/README create mode 100644 ftnoir_tracker_hatire/ftnoir_arduino_type.h create mode 100644 ftnoir_tracker_hatire/ftnoir_hat.qrc create mode 100644 ftnoir_tracker_hatire/ftnoir_hatcontrols.ui create mode 100644 ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp create mode 100644 ftnoir_tracker_hatire/ftnoir_tracker_hat.h create mode 100644 ftnoir_tracker_hatire/ftnoir_tracker_hat.rc create mode 100644 ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.cpp create mode 100644 ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.h create mode 100644 ftnoir_tracker_hatire/ftnoir_tracker_hat_dll.cpp create mode 100644 ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.cpp create mode 100644 ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.h create mode 100644 ftnoir_tracker_hatire/images/hat.ico create mode 100644 ftnoir_tracker_hatire/images/hat_logo.png (limited to 'facetracknoir') diff --git a/CMakeLists.txt b/CMakeLists.txt index 12c4cee0..307aeac4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -96,7 +96,7 @@ if(MINGW) endif() find_package(OpenCV REQUIRED) - find_package(Qt5 REQUIRED COMPONENTS Core Xml Network Widgets Gui QUIET) + find_package(Qt5 REQUIRED COMPONENTS Core Xml Network Widgets Gui SerialPort QUIET) cmake_policy(SET CMP0020 NEW) include_directories(${Qt5Core_INCLUDE_DIRS} ${Qt5Xml_INCLUDE_DIRS} ${Qt5Gui_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS} ${Qt5Network_INCLUDE_DIRS}) add_definitions(${Qt5Core_DEFINITIONS} ${Qt5Xml_DEFINITIONS} ${Qt5Gui_DEFINITIONS} ${Qt5Widgets_DEFINITIONS} ${Qt5Network_DEFINITIONS}) @@ -308,6 +308,13 @@ file(GLOB opentrack-tracker-hydra-rc "ftnoir_tracker_hydra/*.qrc") QT5_WRAP_UI(opentrack-tracker-hydra-uih ${opentrack-tracker-hydra-ui}) QT5_ADD_RESOURCES(opentrack-tracker-hydra-rcc ${opentrack-tracker-hydra-rc}) +file(GLOB opentrack-tracker-hatire-c "ftnoir_tracker_hatire/*.cpp") +file(GLOB opentrack-tracker-hatire-h "ftnoir_tracker_hatire/*.h") +file(GLOB opentrack-tracker-hatire-ui "ftnoir_tracker_hatire/*.ui") +file(GLOB opentrack-tracker-hatire-rc "ftnoir_tracker_hatire/*.qrc") +QT5_WRAP_UI(opentrack-tracker-hatire-uih ${opentrack-tracker-hatire-ui}) +QT5_ADD_RESOURCES(opentrack-tracker-hatire-rcc ${opentrack-tracker-hatire-rc}) + file(GLOB opentrack-csv-c "ftnoir_csv/*.cpp") # compat lib for POSIX/win32 @@ -524,6 +531,13 @@ if(SDK_ARUCO_LIBPATH) endif() endif() +add_library(opentrack-tracker-hatire SHARED ${opentrack-tracker-hatire-c} ${opentrack-tracker-hatire-h} ${opentrack-tracker-hatire-moc} ${opentrack-tracker-hatire-uih} ${opentrack-tracker-hatire-rcc}) +target_link_libraries(opentrack-tracker-hatire ${MY_QT_LIBS} Qt5SerialPort) +if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) + SET_TARGET_PROPERTIES(opentrack-tracker-hatire + PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt") +endif() + if(WIN32) target_link_libraries(opentrack-tracker-ht "${CMAKE_SOURCE_DIR}/dinput/dxguid.lib" diff --git a/facetracknoir/clientfiles/HAT_100/HAT_100.ino b/facetracknoir/clientfiles/HAT_100/HAT_100.ino new file mode 100644 index 00000000..f8644ffe --- /dev/null +++ b/facetracknoir/clientfiles/HAT_100/HAT_100.ino @@ -0,0 +1,389 @@ +// Arduino sketch for MPU6050 on NanoWII using DMP MotionApps v4.1 +// HAT 14/04/2013 by FuraX49 +// +// Head Arduino Tracker for FaceTrackNoIR +// http://facetracknoir.sourceforge.net/home/default.htm +// I2C device class (I2Cdev) +// https://github.com/jrowberg/i2cdevlib + + +#include +#include +#include "I2Cdev.h" +#include "MPU6050_9Axis_MotionApps41.h" + + +MPU6050 mpu; + + +typedef struct { + int16_t Begin ; // 2 Debut + uint16_t Cpt ; // 2 Compteur trame or Code info or error + float gyro[3]; // 12 [Y, P, R] gyro + float acc[3]; // 12 [x, y, z] Acc + int16_t End ; // 2 Fin +} _hatire; + +typedef struct { + int16_t Begin ; // 2 Debut + uint16_t Code ; // 2 Code info + char Msg[24]; // 24 Message + int16_t End ; // 2 Fin +} _msginfo; + +typedef struct +{ + byte rate; + double gyro_offset[3] ; + double acc_offset[3] ; +} _eprom_save; + + +// MPU control/status vars +bool dmpReady = false; // set true if DMP init was successful +bool dmpLoaded = false; // set true if DMP loaded successfuly +uint8_t mpuIntStatus; // holds actual interrupt status byte from MPU +uint8_t devStatus; // return status after each device operation (0 = success, !0 = error) +uint16_t packetSize; // expected DMP packet size (default is 42 bytes) +uint16_t fifoCount; // count of all bytes currently in FIFO +uint8_t fifoBuffer[64]; // FIFO storage buffer + +char Commande; +char Version[] = "HAT V 1.00"; + +// orientation/motion vars +Quaternion q; // [w, x, y, z] quaternion container +VectorInt16 aa; // [x, y, z] accel sensor measurements +VectorFloat gravity; // [x, y, z] gravity vector + +float Rad2Deg = (180/M_PI) ; + +// trame for message +_hatire hatire; +_msginfo msginfo; +_eprom_save eprom_save; + + +bool AskCalibrate = false; // set true when calibrating is ask +int CptCal = 0; +const int NbCal = 5; + + + + +// ================================================================ +// === INTERRUPT DETECTION ROUTINE === +// ================================================================ +volatile bool mpuInterrupt = false; // indicates whether MPU interrupt pin has gone high + +void dmpDataReady() { + mpuInterrupt = true; +} + +// ================================================================ +// === PRINT SERIAL FORMATTE === +// ================================================================ +void PrintCodeSerial(uint16_t code,char Msg[24],bool EOL ) { + msginfo.Code=code; + memset(msginfo.Msg,0x00,24); + strcpy(msginfo.Msg,Msg); + if (EOL) msginfo.Msg[23]=0x0A; + // Send HATIRE message to PC + Serial.write((byte*)&msginfo,30); +} + + +// ================================================================ +// === INITIAL SETUP === +// ================================================================ + +void setup() { + // join I2C bus (I2Cdev library doesn't do this automatically) + Wire.begin(); + + // initialize serial communication + while (!Serial); // wait for Leonardo enumeration, others continue immediately + + Serial.begin(115200); + PrintCodeSerial(2000,Version,true); + + hatire.Begin=0xAAAA; + hatire.Cpt=0; + hatire.End=0x5555; + + msginfo.Begin=0xAAAA; + msginfo.Code=0; + msginfo.End=0x5555; + + // initialize device + PrintCodeSerial(3001,"Initializing I2C",true); + mpu.initialize(); + + // verify connection + PrintCodeSerial(3002,"Testing connections",true); + + if (mpu.testConnection()){ + PrintCodeSerial(3003,"MPU6050 connection OK",true); + } else { + PrintCodeSerial(9007,"MPU6050 ERRROR CNX",true); + } + + while (Serial.available() && Serial.read()); // empty buffer + + // load and configure the DMP + PrintCodeSerial(3004,"Initializing DMP...",true); + devStatus = mpu.dmpInitialize(); + + // make sure it worked (returns 0 if so) + if (devStatus == 0) { + dmpLoaded=true; + + // Read Epprom saved params + PrintCodeSerial(3005,"Reading saved params...",true); + ReadParams(); + + // turn on the DMP, now that it's ready + PrintCodeSerial(3006,"Enabling DMP...",true); + mpu.setDMPEnabled(true); + + // enable Arduino interrupt detection + PrintCodeSerial(3007,"Enabling interrupt",true); + attachInterrupt(0, dmpDataReady, RISING); + mpuIntStatus = mpu.getIntStatus(); + + // set our DMP Ready flag so the main loop() function knows it's okay to use it + PrintCodeSerial(5000,"HAT BEGIN",true); + dmpReady = true; + // get expected DMP packet size for later comparison + packetSize = mpu.dmpGetFIFOPacketSize(); + // Empty FIFO + fifoCount = mpu.getFIFOCount(); + while (fifoCount > packetSize) { + fifoCount = mpu.getFIFOCount(); + mpu.getFIFOBytes(fifoBuffer, fifoCount); + } + } + else { + // ERROR! + // 1 = initial memory load failed + // 2 = DMP configuration updates failed + // (if it's going to break, usually the code will be 1) + dmpLoaded=false; + PrintCodeSerial(9000+devStatus,"DMP Initialization failed",true); + } +} + + +// ================================================================ +// === RAZ OFFSET === +// ================================================================ +void razoffset() { + eprom_save.gyro_offset[0] = 0; + eprom_save.gyro_offset[1] = 0; + eprom_save.gyro_offset[2] = 0; + eprom_save.acc_offset[0] = 0; + eprom_save.acc_offset[1] = 0; + eprom_save.acc_offset[2] = 0; +} + + +// ================================================================ +// === SAVE PARAMS === +// ================================================================ +void SaveParams() { + eeprom_write_block((const void*)&eprom_save, (void*) 0, sizeof(eprom_save)); +} + + + +// ================================================================ +// === READ PARAMS === +// ================================================================ +void ReadParams() { + eeprom_read_block( (void*)&eprom_save, (void*) 0, sizeof(eprom_save)); +} + + +// ================================================================ +// === Serial Command === +// ================================================================ +void serialEvent(){ + Commande = (char)Serial.read(); + switch (Commande) { + case 'S': + PrintCodeSerial(5001,"HAT START",true); + if (dmpLoaded==true) { + mpu.resetFIFO(); + hatire.Cpt=0; + attachInterrupt(0, dmpDataReady, RISING); + mpu.setDMPEnabled(true); + dmpReady = true; + } + else { + PrintCodeSerial(9011,"Error DMP not loaded",true); + } + break; + + case 's': + PrintCodeSerial(5002,"HAT STOP",true); + if (dmpReady==true) { + mpu.setDMPEnabled(false); + detachInterrupt(0); + dmpReady = false; + } + break; + + case 'R': + PrintCodeSerial(5003,"HAT RESET",true); + if (dmpLoaded==true) { + mpu.setDMPEnabled(false); + detachInterrupt(0); + mpu.resetFIFO(); + hatire.Cpt=0; + dmpReady = false; + setup(); + } + else { + PrintCodeSerial(9011,"Error DMP not loaded",true); + } + break; + + + case 'C': + CptCal=0; + razoffset(); + AskCalibrate=true; + break; + + case 'V': + PrintCodeSerial(2000,Version,true); + break; + + case 'I': + Serial.println(); + Serial.print("Version : \t"); + Serial.println(Version); + Serial.println("Gyroscopes offsets"); + for (int i=0; i <= 2; i++) { + Serial.print(i); + Serial.print(" : "); + Serial.print(eprom_save.gyro_offset[i]); + Serial.println(); + } + Serial.println("Accelerometers offsets"); + for (int i=0; i <= 2; i++) { + Serial.print(i); + Serial.print(" : "); + Serial.print(eprom_save.acc_offset[i]); + Serial.println(); + } + break; + + + default: + break; + } +} + + +// ================================================================ +// === MAIN PROGRAM LOOP === +// ================================================================ +void loop() { + // Leonardo BUG (simul Serial Event) + if(Serial.available() > 0) serialEvent(); + + + // if programming failed, don't try to do anything + if (dmpReady) { + + + while (!mpuInterrupt && fifoCount < packetSize) ; + + // reset interrupt flag and get INT_STATUS byte + mpuInterrupt = false; + mpuIntStatus = mpu.getIntStatus(); + + // get current FIFO count + fifoCount = mpu.getFIFOCount(); + + // check for overflow (this should never happen unless our code is too inefficient) + if ((mpuIntStatus & 0x10) || fifoCount == 1024) { + // reset so we can continue cleanly + mpu.resetFIFO(); + PrintCodeSerial(9010,"Overflow FIFO DMP",true); + hatire.Cpt=0; + + // otherwise, check for DMP data ready interrupt (this should happen frequently) + } + else if (mpuIntStatus & 0x02) { + // wait for correct available data length, should be a VERY short wait + while (fifoCount < packetSize) fifoCount = mpu.getFIFOCount(); + + // read a packet from FIFO + mpu.getFIFOBytes(fifoBuffer, packetSize); + + // track FIFO count here in case there is > 1 packet available + // (this lets us immediately read more without waiting for an interrupt) + fifoCount -= packetSize; + + // Get Euler angles in degrees + mpu.dmpGetQuaternion(&q, fifoBuffer); + mpu.dmpGetGravity(&gravity, &q); + mpu.dmpGetYawPitchRoll(hatire.gyro, &q, &gravity); + + // Get real acceleration, adjusted to remove gravity + // not used in this script + // mpu.dmpGetAccel(&aa, fifoBuffer); + // mpu.dmpGetLinearAccel(&hatire.acc, &aa, &gravity); + + // Calibration sur X mesures + if (AskCalibrate) { + if ( CptCal>=NbCal) { + CptCal=0; + eprom_save.gyro_offset[0] = eprom_save.gyro_offset[0] / NbCal ; + eprom_save.gyro_offset[1] = eprom_save.gyro_offset[1] / NbCal ; + eprom_save.gyro_offset[2] = eprom_save.gyro_offset[2] / NbCal ; + AskCalibrate=false; + SaveParams(); + } + else { + eprom_save.gyro_offset[0] += (float) hatire.gyro[0]; + eprom_save.gyro_offset[1] += (float) hatire.gyro[1]; + eprom_save.gyro_offset[2] += (float) hatire.gyro[2]; + + CptCal++; + } + } + + + // Conversion angles Euler en +-180 Degr�es + for (int i=0; i <= 2; i++) { + hatire.gyro[i]= (hatire.gyro[i] - eprom_save.gyro_offset[i] ) * Rad2Deg; + if (hatire.gyro[i]>180) { + hatire.gyro[i] = hatire.gyro[i] - 360; + } + } + + if (AskCalibrate) { + hatire.gyro[0] = 0; + hatire.gyro[1] = 0; + hatire.gyro[2] = 0; + hatire.acc[0]= 0; + hatire.acc[1] = 0; + hatire.acc[2] = 0; + } + + // Send Trame to HATIRE PC + Serial.write((byte*)&hatire,30); + + hatire.Cpt++; + if (hatire.Cpt>999) { + hatire.Cpt=0; + } + } + } + delay(1); +} + + diff --git a/facetracknoir/clientfiles/HAT_100/README b/facetracknoir/clientfiles/HAT_100/README new file mode 100644 index 00000000..1e4f2926 --- /dev/null +++ b/facetracknoir/clientfiles/HAT_100/README @@ -0,0 +1,35 @@ + Frame exchange protocol fixed size of 30 bytes like this : + + typedef struct { + int16_t Begin ; // 2 Debut + uint16_t Cpt ; // 2 Compteur trame or Code + float gyro[3]; // 12 [Y, P, R] gyro + float acc[3]; // 12 [x, y, z] Acc + int16_t End ; // 2 Fin +} _hatire; +_hat hat; + + +void setup() { + Serial.begin(115200); + // header frame + hatire.Begin=0xAAAA; + // Frame Number or Error code + hat.Cpt=0; + // footer frame + hat.End=0x5555; +} + + + void loop() { + mpu.dmpGetYawPitchRoll(hatire.gyro); + mpu.dmpAccXYZ(hatire.acc); + // Send Trame to HATIRE PC + Serial.write((byte*)&hatire,30); + hatire.Cpt++; + if (hatire.Cpt>999) { + hatire.Cpt=0; + } + delay(1); +} + diff --git a/ftnoir_tracker_hatire/ftnoir_arduino_type.h b/ftnoir_tracker_hatire/ftnoir_arduino_type.h new file mode 100644 index 00000000..4d19043b --- /dev/null +++ b/ftnoir_tracker_hatire/ftnoir_arduino_type.h @@ -0,0 +1,31 @@ +#ifndef FTNOIR_TARDUINO_TYPE_H +#define FTNOIR_TARDUINO_TYPE_H + +// Arduino trame structure +#pragma pack(push,2) +struct TArduinoData +{ + quint16 Begin; // Header trame 0xAAAA; + quint16 Code; // 0->999 Num Trame >=2000 Info >=3000 Init >=5000 Start Command >=9000 Error + float Gyro[3]; + float Acc[3]; + quint16 End; // End trame 0x5555; +} ; +#pragma pack(pop) + + +inline QDataStream & operator >> ( QDataStream& in, TArduinoData& out ) +{ + in.setByteOrder(QDataStream::LittleEndian ); + in.setFloatingPointPrecision(QDataStream::SinglePrecision ); + + in >> (quint16)out.Begin >> (quint16)out.Code + >> (float)out.Gyro[0] >> (float)out.Gyro[1] >> (float)out.Gyro[2] + >> (float)out.Acc[0] >> (float)out.Acc[1] >> (float)out.Acc[2] + >> (quint16)out.End; + return in; +} + + + +#endif \ No newline at end of file diff --git a/ftnoir_tracker_hatire/ftnoir_hat.qrc b/ftnoir_tracker_hatire/ftnoir_hat.qrc new file mode 100644 index 00000000..4c606f92 --- /dev/null +++ b/ftnoir_tracker_hatire/ftnoir_hat.qrc @@ -0,0 +1,6 @@ + + + images/hat.ico + images/hat_logo.png + + diff --git a/ftnoir_tracker_hatire/ftnoir_hatcontrols.ui b/ftnoir_tracker_hatire/ftnoir_hatcontrols.ui new file mode 100644 index 00000000..86f9e48a --- /dev/null +++ b/ftnoir_tracker_hatire/ftnoir_hatcontrols.ui @@ -0,0 +1,1066 @@ + + + UIHATControls + + + + 0 + 0 + 370 + 520 + + + + + 370 + 520 + + + + + 370 + 520 + + + + Qt::NoContextMenu + + + Head Arduino Tracker settings FaceTrackNoIR + + + + images/hat.icoimages/hat.ico + + + 1.000000000000000 + + + Qt::LeftToRight + + + false + + + + + 0 + 480 + 361 + 27 + + + + + + + + 0 + 0 + + + + + 80 + 25 + + + + + 80 + 25 + + + + OK + + + + + + + + 80 + 25 + + + + + 80 + 25 + + + + Save + + + + + + + + 0 + 0 + + + + + 80 + 25 + + + + + 80 + 25 + + + + Cancel + + + + + + + + + 0 + 0 + 360 + 470 + + + + + 360 + 470 + + + + + 360 + 470 + + + + 0 + + + true + + + + + :/images/hat.ico:/images/hat.ico + + + General + + + + + 10 + 350 + 331 + 91 + + + + Information + + + + + 10 + 20 + 311 + 51 + + + + + QFormLayout::AllNonFixedFieldsGrow + + + 10 + + + 10 + + + 0 + + + 0 + + + 0 + + + + + + 31 + 0 + + + + + 60 + 13 + + + + Trame per seconde + + + tps : + + + + + + + + 60 + 16777215 + + + + Status : + + + + + + + + 170 + 0 + + + + + 60 + 16777215 + + + + + + + + + + + + 31 + 0 + + + + + 60 + 13 + + + + 00 + + + + + + + + + + 10 + 130 + 331 + 211 + + + + + 0 + 106 + + + + Axis Configuration + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + 10 + 20 + 311 + 181 + + + + + QLayout::SetMinAndMaxSize + + + 0 + + + 0 + + + 6 + + + + + + 20 + 16777215 + + + + Enable Axis + + + Qt::LeftToRight + + + + + + + + + + + 20 + 16777215 + + + + Enable Axis + + + Qt::LeftToRight + + + + + + + + + + + + + Associate Axis + + + + RotX + + + + + RotY + + + + + RotZ + + + + + + + + Yaw: + + + + + + + Associate Axis + + + + RotX + + + + + RotY + + + + + RotZ + + + + + + + + Associate Axis + + + + RotX + + + + + RotY + + + + + RotZ + + + + + + + + + 20 + 16777215 + + + + Enable Axis + + + Qt::LeftToRight + + + + + + + + + + Pitch: + + + + + + + Roll: + + + + + + + + 20 + 16777215 + + + + Invert Axis + + + Qt::LeftToRight + + + + + + + + + + + + + + 20 + 16777215 + + + + Invert Axis + + + Qt::LeftToRight + + + + + + + + + + + + + + 20 + 16777215 + + + + Invert Axis + + + Qt::LeftToRight + + + + + + + + + + + + + Enable + + + + + + + Axis + + + + + + + Invert + + + + + + + X: + + + + + + + + 20 + 16777215 + + + + Enable Axis + + + Qt::LeftToRight + + + + + + + + + + Associate Axis + + + + X + + + + + Y + + + + + Z + + + + + + + + + 20 + 16777215 + + + + Invert Axis + + + Qt::LeftToRight + + + + + + + + + + + + + Y: + + + + + + + + 20 + 16777215 + + + + Enable Axis + + + Qt::LeftToRight + + + + + + + + + + Associate Axis + + + + X + + + + + Y + + + + + Z + + + + + + + + + 20 + 16777215 + + + + Invert Axis + + + Qt::LeftToRight + + + + + + + + + + + + + Z: + + + + + + + + 20 + 16777215 + + + + Enable Axis + + + Qt::LeftToRight + + + + + + + + + + Associate Axis + + + + X + + + + + Y + + + + + Z + + + + + + + + + 20 + 16777215 + + + + Invert Axis + + + Qt::LeftToRight + + + + + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 16 + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 16 + + + + + + + + + + + 10 + 90 + 331 + 31 + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 13 + 16 + + + + + + + + + 80 + 20 + + + + Center + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 13 + 16 + + + + + + + + + 80 + 20 + + + + Reset + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 13 + 16 + + + + + + + + + + 10 + 10 + 331 + 31 + + + + + + + + 60 + 16777215 + + + + Serial Port : + + + + + + + + 100 + 16777215 + + + + false + + + QComboBox::AdjustToMinimumContentsLength + + + 0 + + + + + + + Qt::Horizontal + + + QSizePolicy::Minimum + + + + 40 + 20 + + + + + + + + + + 10 + 50 + 331 + 31 + + + + + 7 + + + + + Choose the Serial Com port where is connected ARDUINO. + + + true + + + + + + + + + About + + + + + 10 + 20 + 111 + 111 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">FTNoIR HAT Plugin<br />Version 1.0</span></p> +<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">by FuraX49</span></p> +<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://hatire.sourceforge.net/"><span style=" font-weight:600; text-decoration: underline; color:#0000ff;">Manual (external)</span></a></p></body></html> + + + true + + + + + + 200 + 20 + 128 + 128 + + + + + + + :/images/hat_logo.png + + + + + + 10 + 190 + 331 + 251 + + + + true + + + 800 + + + + + + 10 + 160 + 241 + 20 + + + + + + + 260 + 160 + 75 + 23 + + + + Send + + + + + + + btnCancel + + + + + + + startEngineClicked() + stopEngineClicked() + cameraSettingsClicked() + + diff --git a/ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp b/ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp new file mode 100644 index 00000000..e961a10f --- /dev/null +++ b/ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp @@ -0,0 +1,304 @@ +/******************************************************************************** +* FaceTrackNoIR This program is a private project of some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2012 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage: http://facetracknoir.sourceforge.net/home/default.htm * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +********************************************************************************/ + + +#include "ftnoir_tracker_hat.h" +#include +#include +#include + +FTNoIR_Tracker::FTNoIR_Tracker() +{ + SerialPort = NULL; + waitTimeout = 1000; + TrackerSettings settings; + settings.load_ini(); + applysettings(settings); + + + // Create events + m_StopThread = CreateEvent(0, TRUE, FALSE, 0); + m_WaitThread = CreateEvent(0, TRUE, FALSE, 0); + + ListErrInf = new QList(); + + // prepare & reserve QByteArray + datagram.reserve(30); +} + +FTNoIR_Tracker::~FTNoIR_Tracker() +{ + // Trigger thread to stop + ::SetEvent(m_StopThread); + + // Wait until thread finished + if (isRunning()) { + ::WaitForSingleObject(m_WaitThread, INFINITE); + } + + // Close handles + ::CloseHandle(m_StopThread); + ::CloseHandle(m_WaitThread); + + if (SerialPort!=NULL) { + if (SerialPort->isOpen() ) { + SerialPort->putChar('s'); //Send STOP to Arduino + SerialPort->close(); + } + delete SerialPort; + SerialPort=NULL; + } + +} + +//send CENTER to Arduino +void FTNoIR_Tracker::notifyCenter() { + if (SerialPort!=NULL) { + if (SerialPort->isOpen() ) { + SerialPort->putChar('C'); + } + } +} + + + +//send CENTER to Arduino +void FTNoIR_Tracker::center() { + if (SerialPort!=NULL) { + if (SerialPort->isOpen() ) { + SerialPort->putChar('C'); + } + } +} + +//send RESET to Arduino +void FTNoIR_Tracker::reset() { + if (SerialPort!=NULL) { + if (SerialPort->isOpen() ) { + SerialPort->putChar('R'); + } + } +} + +//send command to Arduino +void FTNoIR_Tracker::sendcmd(QString* cmd) { + QReadLocker locker(&rwlock); + QByteArray bytes; + if (SerialPort!=NULL) { + if (SerialPort->isOpen() ) { + bytes.append(cmd->toAscii()); + SerialPort->write(bytes); + } + } +} + +// return FPS and last status +void FTNoIR_Tracker::get_info(QString* info, int* tps ){ + QReadLocker locker(&rwlock); + *tps=HAT.Code; + if (ListErrInf->size()>0) { + *info=ListErrInf->takeFirst(); + } else { + *info= QString(); + } +} + + +/** QThread run @override **/ +void FTNoIR_Tracker::run() { + // + // Read the data that was received. + // + forever { + + // Check event for stop thread + if(::WaitForSingleObject(m_StopThread, 0) == WAIT_OBJECT_0) + { + // Set event + ::SetEvent(m_WaitThread); + qDebug() << "FTNoIR_Tracker::run() terminated run()"; + return; + } + if (SerialPort->bytesAvailable()>=30) { + QWriteLocker locker(&rwlock); + datagram.clear(); + datagram=SerialPort->read(30); + QDataStream datastream(datagram); + datastream>>ArduinoData; + + if (ArduinoData.Begin==0xAAAA && ArduinoData.End==0x5555 ) { + if (ArduinoData.Code <= 1000) { + HAT=ArduinoData; + } else { + ListErrInf->push_back(QString::fromAscii(datagram.mid(4,24),24)) ; + } + } else { + SerialPort->read(1); + } + } + //for lower cpu load + usleep(10000); + } +} + +void FTNoIR_Tracker::Initialize( QFrame *videoframe ) +{ + qDebug() << "FTNoIR_Tracker::Initialize says: Starting "; + + // + // Create SerialPort if they don't exist already. + // They must be created here, because they must be in the new thread (FTNoIR_Tracker::run()) + // + + if (SerialPort == NULL) { + qDebug() << "FTNoIR_Tracker::Initialize() Open SerialPort"; + SerialPort = new QextSerialPort(sSerialPortName); + if (SerialPort->open(QIODevice::ReadWrite | QIODevice::Unbuffered ) == true) { + SerialPort->flush(); + SerialPort->setBaudRate(BAUD115200); + SerialPort->setParity(PAR_NONE); + SerialPort->setDataBits(DATA_8); + SerialPort->setStopBits(STOP_1); + SerialPort->setFlowControl(FLOW_OFF); + SerialPort->setTimeout(waitTimeout); + SerialPort->setQueryMode(QextSerialPort::EventDriven); //Polling + // Send START to arduino + SerialPort->putChar('S'); + } + else { + QMessageBox::warning(0,"FaceTrackNoIR Error", "Unable to open SerialPort",QMessageBox::Ok,QMessageBox::NoButton); + delete SerialPort; + SerialPort = NULL; + } + } + return; +} + +void FTNoIR_Tracker::StartTracker( HWND parent_window ) +{ + start( QThread::TimeCriticalPriority ); + return; +} + +void FTNoIR_Tracker::StopTracker( bool exit ) +{ + // + // OK, the thread is not stopped, doing this. That might be dangerous anyway... + // + if (exit || !exit) return; + return; +} + +// +// Return 6DOF info +// +bool FTNoIR_Tracker::GiveHeadPoseData(THeadPoseData *data) +{ + QReadLocker locker(&rwlock); + data->frame_number = HAT.Code; + + if (bEnableYaw) { + if (bInvertYaw ) data->yaw = HAT.Gyro[iYawAxe] * -1.0f; + else data->yaw = HAT.Gyro[iYawAxe]; + } + + if (bEnablePitch) { + if (bInvertPitch)data->pitch = HAT.Gyro[iPitchAxe] * -1.0f; + else data->pitch = HAT.Gyro[iPitchAxe]; + } + + if (bEnableRoll) { + if (bInvertRoll) data->roll = HAT.Gyro[iRollAxe] * -1.0f; + else data->roll = HAT.Gyro[iRollAxe]; + } + + if (bEnableX) { + if (bInvertX) data->x = HAT.Acc[iXAxe]* -1.0f; + else data->x = HAT.Acc[iXAxe]; + } + + if (bEnableY) { + if (bInvertY) data->y = HAT.Acc[iYAxe]* -1.0f; + else data->y = HAT.Acc[iYAxe]; + } + + if (bEnableZ) { + if (bInvertZ) data->z = HAT.Acc[iZAxe]* -1.0f; + else data->z = HAT.Acc[iZAxe]; + } + + return true; +} + + + +// +// Apply modification Settings +// +void FTNoIR_Tracker::applysettings(const TrackerSettings& settings){ + qDebug()<<"Tracker:: Applying settings"; + + QReadLocker locker(&rwlock); + sSerialPortName= settings.SerialPortName; + + bEnableRoll = settings.EnableRoll; + bEnablePitch = settings.EnablePitch; + bEnableYaw = settings.EnableYaw; + bEnableX = settings.EnableX; + bEnableY = settings.EnableY; + bEnableZ = settings.EnableZ; + + bInvertRoll = settings.InvertRoll; + bInvertPitch = settings.InvertPitch; + bInvertYaw = settings.InvertYaw; + bInvertX = settings.InvertX; + bInvertY = settings.InvertY; + bInvertZ = settings.InvertZ; + + + iRollAxe= settings.RollAxe; + iPitchAxe= settings.PitchAxe; + iYawAxe= settings.YawAxe; + iXAxe= settings.XAxe; + iYAxe= settings.YAxe; + iZAxe= settings.ZAxe; +} + + + + +//////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Tracker object. + +// Export both decorated and undecorated names. +// GetTracker - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetTracker@0 - Common name decoration for __stdcall functions in C language. +#pragma comment(linker, "/export:GetTracker=_GetTracker@0") + +FTNOIR_TRACKER_BASE_EXPORT ITrackerPtr __stdcall GetTracker() +{ + return new FTNoIR_Tracker; +} diff --git a/ftnoir_tracker_hatire/ftnoir_tracker_hat.h b/ftnoir_tracker_hatire/ftnoir_tracker_hat.h new file mode 100644 index 00000000..54e67f48 --- /dev/null +++ b/ftnoir_tracker_hatire/ftnoir_tracker_hat.h @@ -0,0 +1,102 @@ +#ifndef FTNOIR_TRACKER_HAT_H +#define FTNOIR_TRACKER_HAT_H + +#include "..\ftnoir_tracker_base\ftnoir_tracker_base.h" +#include "ftnoir_tracker_hat_settings.h" +#include "ftnoir_arduino_type.h" + +#include +#include +#include +#include +#include +#include +#include "Windows.h" +#include "math.h" + +class QextSerialPort; +class QExtSerialEnumerator; + +class FTNoIR_Tracker : public ITracker, QThread +{ + +public: + FTNoIR_Tracker(); + ~FTNoIR_Tracker(); + + void Initialize( QFrame *videoframe ); + void StartTracker( HWND parent_window ); + void StopTracker( bool exit ); + bool GiveHeadPoseData(THeadPoseData *data); + + void applysettings(const TrackerSettings& settings); + void notifyCenter(); + void center(); + void reset(); + void sendcmd(QString* cmd); + void get_info(QString* info , int* tps ); + +protected: + void run(); // qthread override run method + + +private: + // Handles to neatly terminate thread... + HANDLE m_StopThread; + HANDLE m_WaitThread; + + TArduinoData ArduinoData, HAT ; // Trame from Arduino + QByteArray datagram; + QextSerialPort *SerialPort; + QReadWriteLock rwlock; + QList* ListErrInf ; + int waitTimeout; + QString sSerialPortName; // Port serial name + bool bEnableRoll; + bool bEnablePitch; + bool bEnableYaw; + bool bEnableX; + bool bEnableY; + bool bEnableZ; + + bool bInvertRoll; + bool bInvertPitch; + bool bInvertYaw; + bool bInvertX; + bool bInvertY; + bool bInvertZ; + + + int iRollAxe; + int iPitchAxe; + int iYawAxe; + int iXAxe; + int iYAxe; + int iZAxe; + +}; + + +//******************************************************************************************************* +// FaceTrackNoIR Tracker DLL. Functions used to get general info on the Tracker +//******************************************************************************************************* +class FTNoIR_TrackerDll : public ITrackerDll +{ +public: + FTNoIR_TrackerDll(); + ~FTNoIR_TrackerDll(); + + void Initialize(); + + void getFullName(QString *strToBeFilled); + void getShortName(QString *strToBeFilled); + void getDescription(QString *strToBeFilled); + void getIcon(QIcon *icon); + +private: + QString trackerFullName; // Trackers' name and description + QString trackerShortName; + QString trackerDescription; +}; + +#endif // FTNOIR_TRACKER_HAT_H \ No newline at end of file diff --git a/ftnoir_tracker_hatire/ftnoir_tracker_hat.rc b/ftnoir_tracker_hatire/ftnoir_tracker_hat.rc new file mode 100644 index 00000000..62e0a613 --- /dev/null +++ b/ftnoir_tracker_hatire/ftnoir_tracker_hat.rc @@ -0,0 +1,61 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +//#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +LANGUAGE 9, 1 +#pragma code_page(1252) + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.cpp b/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.cpp new file mode 100644 index 00000000..b889341f --- /dev/null +++ b/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.cpp @@ -0,0 +1,299 @@ +/******************************************************************************** +* FaceTrackNoIR This program is a private project of some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2012 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage: http://facetracknoir.sourceforge.net/home/default.htm * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +********************************************************************************/ +#include "ftnoir_tracker_hat.h" +#include "ftnoir_tracker_hat_dialog.h" + +#include +#include + +//******************************************************************************************************* +// FaceTrackNoIR Client Settings-dialog. +//******************************************************************************************************* + +// +// Constructor for server-settings-dialog +// +TrackerControls::TrackerControls() : settingsDirty(false), theTracker(NULL), timer(this), +QWidget() +{ + + settingsDirty= false; + theTracker = NULL; + ui.setupUi( this ); + pre_trame = 0; + settings.load_ini(); + + // make SerialPort list + foreach (QextPortInfo PortInfo , QextSerialEnumerator::getPorts() ) { + ui.cbSerialPort->addItem(PortInfo.portName); + } + // Stop if no SerialPort dispo + if (ui.cbSerialPort->count()<1) { + QMessageBox::critical(this,"FaceTrackNoIR Error", "No SerialPort avaible"); + } else { + + int indxport =ui.cbSerialPort->findText(settings.SerialPortName,Qt::MatchExactly ); + if (indxport!=-1) { + ui.cbSerialPort->setCurrentIndex(indxport); + } else { + QMessageBox::warning(this,"FaceTrackNoIR Error", "Selected SerialPort modified"); + ui.cbSerialPort-> setCurrentIndex(indxport); + } + } + + ui.chkEnableRoll->setChecked(settings.EnableRoll); + ui.chkEnablePitch->setChecked(settings.EnablePitch); + ui.chkEnableYaw->setChecked(settings.EnableYaw); + ui.chkEnableX->setChecked(settings.EnableX); + ui.chkEnableY->setChecked(settings.EnableY); + ui.chkEnableZ->setChecked(settings.EnableZ); + + ui.chkInvertRoll->setChecked(settings.InvertRoll); + ui.chkInvertPitch->setChecked(settings.InvertPitch); + ui.chkInvertYaw->setChecked(settings.InvertYaw); + ui.chkInvertX->setChecked(settings.InvertX); + ui.chkInvertY->setChecked(settings.InvertY); + ui.chkInvertZ->setChecked(settings.InvertZ); + + + ui.cb_roll->setCurrentIndex(settings.RollAxe); + ui.cb_pitch->setCurrentIndex(settings.PitchAxe); + ui.cb_yaw->setCurrentIndex(settings.YawAxe); + ui.cb_x->setCurrentIndex(settings.XAxe); + ui.cb_y->setCurrentIndex(settings.YAxe); + ui.cb_z->setCurrentIndex(settings.ZAxe); + + + // Connect Qt signals to member-functions + connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); + connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); + connect(ui.btnSave, SIGNAL(clicked()), this, SLOT(doSave())); + + + connect(ui.cbSerialPort, SIGNAL(currentIndexChanged(QString)), this,SLOT(set_mod_port(QString)) ); + + connect( ui.chkEnableRoll,SIGNAL(toggled(bool)), this,SLOT(set_ena_roll(bool)) ); + connect( ui.chkEnablePitch,SIGNAL(toggled(bool)), this,SLOT(set_ena_pitch(bool)) ); + connect( ui.chkEnableYaw,SIGNAL(toggled(bool)), this,SLOT(set_ena_yaw(bool)) ); + connect( ui.chkEnableX,SIGNAL(toggled(bool)), this,SLOT(set_ena_x(bool)) ); + connect( ui.chkEnableY,SIGNAL(toggled(bool)), this,SLOT(set_ena_y(bool)) ); + connect( ui.chkEnableZ,SIGNAL(toggled(bool)), this,SLOT(set_ena_z(bool)) ); + + connect( ui.chkInvertRoll,SIGNAL(toggled(bool)), this,SLOT(set_inv_roll(bool)) ); + connect( ui.chkInvertPitch,SIGNAL(toggled(bool)), this,SLOT(set_inv_pitch(bool)) ); + connect( ui.chkInvertYaw,SIGNAL(toggled(bool)), this,SLOT(set_inv_yaw(bool)) ); + connect( ui.chkInvertX,SIGNAL(toggled(bool)), this,SLOT(set_inv_x(bool)) ); + connect( ui.chkInvertY,SIGNAL(toggled(bool)), this,SLOT(set_inv_y(bool)) ); + connect( ui.chkInvertZ,SIGNAL(toggled(bool)), this,SLOT(set_inv_z(bool)) ); + + + connect(ui.cb_roll, SIGNAL(currentIndexChanged(int)), this,SLOT(set_rot_roll(int))); + connect(ui.cb_pitch, SIGNAL(currentIndexChanged(int)),this,SLOT(set_rot_pitch(int))); + connect(ui.cb_yaw, SIGNAL(currentIndexChanged(int)), this,SLOT(set_rot_yaw(int))); + connect(ui.cb_x, SIGNAL(currentIndexChanged(int)), this,SLOT(set_acc_x(int))); + connect(ui.cb_y, SIGNAL(currentIndexChanged(int)), this,SLOT(set_acc_y(int))); + connect(ui.cb_z, SIGNAL(currentIndexChanged(int)), this,SLOT(set_acc_z(int))); + + connect(ui.btnReset, SIGNAL(clicked()), this, SLOT(doReset())); + connect(ui.btnCenter, SIGNAL(clicked()), this, SLOT(doCenter())); + connect(ui.btnSend, SIGNAL(clicked()), this, SLOT(doSend())); + + connect(&timer,SIGNAL(timeout()), this,SLOT(poll_tracker_info())); +} + +// +// Destructor for server-dialog +// +TrackerControls::~TrackerControls() { + delete this; +} + + +// +// Initialize tracker-client-dialog +// +void TrackerControls::Initialize(QWidget *parent) { + QPoint offsetpos(100, 100); + if (parent) { + this->move(parent->pos() + offsetpos); + } + show(); +} + + +// +// Apply online settings to tracker +// +void TrackerControls::settings_changed() +{ + settingsDirty = true; + if (theTracker) theTracker->applysettings(settings); +} + + +// +// Center asked to ARDUINO +// +void TrackerControls::doCenter() { + if (theTracker) theTracker->center(); +} + +// +// Reset asked to ARDUINO +// +void TrackerControls::doReset() { + if (theTracker) theTracker->reset(); +} + + +// +// Send command to ARDUINO +// +void TrackerControls::doSend() { + if (theTracker) { + if (!ui.lineSend->text().isEmpty()) { + QString cmd; + cmd=ui.lineSend->text(); + theTracker->sendcmd(&cmd); + ui.lineSend->clear(); + } + } +} + + +// +// Display FPS and Status of Arduino. +// +void TrackerControls::poll_tracker_info() +{ + if (theTracker) + { + QString info; + int num_trame; + int nb_trame; + + theTracker->get_info(&info,&num_trame); + if ( !info.isNull()) { + ui.lab_vstatus->setText(info); + ui.pteINFO->moveCursor(QTextCursor::End); + ui.pteINFO->insertPlainText(info); + } + + + if (pre_tramesetText(QString::number(nb_trame*(1000/timer.interval()))); + + pre_trame=num_trame; + } + +} + + +void TrackerControls::doSave() { + settingsDirty=false; + settings.save_ini(); +} + + +// +// OK clicked on server-dialog +// +void TrackerControls::doOK() { + settingsDirty=false; + settings.save_ini(); + this->close(); +} + +// +// Cancel clicked on server-dialog +// +void TrackerControls::doCancel() { + // + // Ask if changed Settings should be saved + // + if (settingsDirty) { + int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard ); + + // qDebug() << "doCancel says: answer =" << ret; + + switch (ret) { + case QMessageBox::Save: + settings.save_ini(); + close(); + break; + case QMessageBox::Discard: + close(); + break; + case QMessageBox::Cancel: + // Cancel was clicked + break; + default: + // should never be reached + break; + } + } + else { + close(); + } +} + + +void TrackerControls::registerTracker(ITracker *tracker) { +// theTracker = (FTNoIR_Tracker *) tracker; + theTracker = static_cast(tracker); + if (isVisible() && settingsDirty) theTracker->applysettings(settings); + ui.cbSerialPort->setEnabled(false); + timer.start(250); + ui.lab_vstatus->setText("HAT START"); +} + + +void TrackerControls::unRegisterTracker() { + theTracker = NULL; + ui.cbSerialPort->setEnabled(true); + timer.stop(); + ui.lab_vstatus->setText("HAT STOPPED"); + ui.lab_vtps->setText(""); +} + + + + +//////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Tracker-settings dialog object. + +// Export both decorated and undecorated names. +// GetTrackerDialog - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetTrackerDialog@0 - Common name decoration for __stdcall functions in C language. +#pragma comment(linker, "/export:GetTrackerDialog=_GetTrackerDialog@0") + +FTNOIR_TRACKER_BASE_EXPORT ITrackerDialogPtr __stdcall GetTrackerDialog( ) +{ + return new TrackerControls; +} diff --git a/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.h b/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.h new file mode 100644 index 00000000..c463f361 --- /dev/null +++ b/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.h @@ -0,0 +1,78 @@ +#ifndef FTNOIR_TRACKER_HAT_DIALOG_H +#define FTNOIR_TRACKER_HAT_DIALOG_H + +#include "..\ftnoir_tracker_base\ftnoir_tracker_base.h" +#include "ftnoir_tracker_hat_settings.h" +#include "ftnoir_tracker_hat.h" +#include "ui_ftnoir_hatcontrols.h" + +#include +#include + +// Widget that has controls for FTNoIR protocol client-settings. +class TrackerControls: public QWidget, Ui::UIHATControls, public ITrackerDialog +{ + Q_OBJECT + +public: + explicit TrackerControls(); + virtual ~TrackerControls(); + + void Initialize(QWidget *parent); + void registerTracker(ITracker *tracker); + void unRegisterTracker() ; + +private: + Ui::UIHATControls ui; + int pre_trame; + FTNoIR_Tracker *theTracker; + +protected slots: + + /* + void set_mod_port(int val) { settings.SerialPortName = ui.cbSerialPort->itemText(val); + QMessageBox::warning(this,"FaceTrackNoIR Error", settings.SerialPortName); + settings_changed(); } +*/ + void set_mod_port(const QString & val) { settings.SerialPortName =val; + QMessageBox::warning(this,"FaceTrackNoIR Error", settings.SerialPortName); + settings_changed(); } + void set_ena_roll(bool val) { settings.EnableRoll = val; settings_changed(); } + void set_ena_pitch(bool val) { settings.EnablePitch = val; settings_changed(); } + void set_ena_yaw(bool val) { settings.EnableYaw = val; settings_changed(); } + void set_ena_x(bool val) { settings.EnableX = val; settings_changed(); } + void set_ena_y(bool val) { settings.EnableY = val; settings_changed(); } + void set_ena_z(bool val) { settings.EnableZ = val; settings_changed(); } + + void set_inv_roll(bool val) { settings.InvertRoll = val; settings_changed(); } + void set_inv_pitch(bool val) { settings.InvertPitch = val; settings_changed(); } + void set_inv_yaw(bool val) { settings.InvertYaw = val; settings_changed(); } + void set_inv_x(bool val) { settings.InvertX = val; settings_changed(); } + void set_inv_y(bool val) { settings.InvertY = val; settings_changed(); } + void set_inv_z(bool val) { settings.InvertZ = val; settings_changed(); } + + + void set_rot_roll(int val) { settings.RollAxe = val; settings_changed(); } + void set_rot_pitch(int val) { settings.PitchAxe = val; settings_changed(); } + void set_rot_yaw(int val) { settings.YawAxe = val; settings_changed(); } + void set_acc_x(int val) { settings.XAxe = val; settings_changed(); } + void set_acc_y(int val) { settings.YAxe = val; settings_changed(); } + void set_acc_z(int val) { settings.ZAxe = val; settings_changed(); } + + void doOK(); + void doCancel(); + void doSave(); + void doReset(); + void doCenter(); + void doSend(); + void poll_tracker_info(); + +protected: + bool settingsDirty; + void settings_changed(); + TrackerSettings settings; + QTimer timer; +}; + + +#endif //FTNOIR_TRACKER_HAT_DIALOG_H \ No newline at end of file diff --git a/ftnoir_tracker_hatire/ftnoir_tracker_hat_dll.cpp b/ftnoir_tracker_hatire/ftnoir_tracker_hat_dll.cpp new file mode 100644 index 00000000..246eb397 --- /dev/null +++ b/ftnoir_tracker_hatire/ftnoir_tracker_hat_dll.cpp @@ -0,0 +1,79 @@ +/******************************************************************************** +* FaceTrackNoIR This program is a private project of some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2012 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage: http://facetracknoir.sourceforge.net/home/default.htm * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +********************************************************************************/ + +#include "ftnoir_tracker_hat.h" +#include +#include + +FTNoIR_TrackerDll::FTNoIR_TrackerDll() { + //populate the description strings + trackerFullName = "Head Arduino Tracker"; + trackerShortName = "HAT"; + trackerDescription = "FaceTrackNoIR HAT"; +} + +FTNoIR_TrackerDll::~FTNoIR_TrackerDll() +{ + +} + +void FTNoIR_TrackerDll::Initialize() +{ + return; +} + +void FTNoIR_TrackerDll::getFullName(QString *strToBeFilled) +{ + *strToBeFilled = trackerFullName; +}; + +void FTNoIR_TrackerDll::getShortName(QString *strToBeFilled) +{ + *strToBeFilled = trackerShortName; +}; + +void FTNoIR_TrackerDll::getDescription(QString *strToBeFilled) +{ + *strToBeFilled = trackerDescription; +}; + +void FTNoIR_TrackerDll::getIcon(QIcon *icon) +{ + *icon = QIcon(":/images/hat.ico"); +}; + +//////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Tracker object. + +// Export both decorated and undecorated names. +// GetTrackerDll - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetTrackerDll@0 - Common name decoration for __stdcall functions in C language. +#pragma comment(linker, "/export:GetTrackerDll=_GetTrackerDll@0") + +FTNOIR_TRACKER_BASE_EXPORT ITrackerDllPtr __stdcall GetTrackerDll() +{ + return new FTNoIR_TrackerDll; +} diff --git a/ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.cpp b/ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.cpp new file mode 100644 index 00000000..f8b342cc --- /dev/null +++ b/ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.cpp @@ -0,0 +1,102 @@ +/******************************************************************************** +* FaceTrackNoIR This program is a private project of some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2012 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage: http://facetracknoir.sourceforge.net/home/default.htm * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +********************************************************************************/ +#include +#include + +#include "ftnoir_tracker_hat_settings.h" + +void TrackerSettings::load_ini() +{ + qDebug("TrackerSettings::load_ini()"); + 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) + + iniFile.beginGroup( "HAT" ); + + SerialPortName=iniFile.value ( "PortName" ).toString(); + + EnableRoll = iniFile.value( "EnableRoll", 1 ).toBool(); + EnablePitch = iniFile.value( "EnablePitch", 1 ).toBool(); + EnableYaw = iniFile.value( "EnableYaw", 1 ).toBool(); + EnableX = iniFile.value( "EnableX", 0 ).toBool(); + EnableY = iniFile.value( "EnableY", 0 ).toBool(); + EnableZ = iniFile.value( "EnableZ", 0 ).toBool(); + + + InvertRoll = iniFile.value( "InvertRoll", 1 ).toBool(); + InvertPitch = iniFile.value( "InvertPitch", 1 ).toBool(); + InvertYaw = iniFile.value( "InvertYaw", 1 ).toBool(); + InvertX = iniFile.value( "InvertX", 0 ).toBool(); + InvertY = iniFile.value( "InvertY", 0 ).toBool(); + InvertZ = iniFile.value( "InvertZ", 0 ).toBool(); + + + RollAxe=iniFile.value("RollAxe",1).toInt(); + PitchAxe=iniFile.value("PitchAxe",2).toInt(); + YawAxe=iniFile.value("YawAxe",0).toInt(); + XAxe=iniFile.value("XAxe",1).toInt(); + YAxe=iniFile.value("YAxe",2).toInt(); + ZAxe=iniFile.value("ZAxe",0).toInt(); + + iniFile.endGroup(); +} + + +void TrackerSettings::save_ini() const +{ + qDebug("TrackerSettings::save_ini()"); + + 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) + + iniFile.beginGroup ( "HAT" ); + + iniFile.setValue ( "PortName",SerialPortName ); + + iniFile.setValue( "EnableRoll", EnableRoll ); + iniFile.setValue( "EnablePitch", EnablePitch ); + iniFile.setValue( "EnableYaw", EnableYaw ); + iniFile.setValue( "EnableX", EnableX ); + iniFile.setValue( "EnableY", EnableY ); + iniFile.setValue( "EnableZ", EnableZ ); + + iniFile.setValue( "InvertRoll", InvertRoll ); + iniFile.setValue( "InvertPitch", InvertPitch ); + iniFile.setValue( "InvertYaw", InvertYaw ); + iniFile.setValue( "InvertX", InvertX ); + iniFile.setValue( "InvertY", InvertY ); + iniFile.setValue( "InvertZ", InvertZ ); + + iniFile.setValue ( "RollAxe", RollAxe ); + iniFile.setValue ( "PitchAxe", PitchAxe ); + iniFile.setValue ( "YawAxe",YawAxe ); + iniFile.setValue ( "XAxe", XAxe ); + iniFile.setValue ( "YAxe", YAxe ); + iniFile.setValue ( "ZAxe", ZAxe ); + + iniFile.endGroup(); +} diff --git a/ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.h b/ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.h new file mode 100644 index 00000000..a29fed6b --- /dev/null +++ b/ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.h @@ -0,0 +1,44 @@ +/* Copyright (c) 2012 Patrick Ruoff + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + */ + +#ifndef FTNOIR_TRACKER_HAT_SETTINGS_H +#define FTNOIR_TRACKER_HAT_SETTINGS_H + + +//----------------------------------------------------------------------------- +struct TrackerSettings +{ + + QString SerialPortName; + bool EnableRoll; + bool EnablePitch; + bool EnableYaw; + bool EnableX; + bool EnableY; + bool EnableZ; + + bool InvertRoll; + bool InvertPitch; + bool InvertYaw; + bool InvertX; + bool InvertY; + bool InvertZ; + + + int RollAxe; + int PitchAxe; + int YawAxe; + int XAxe; + int YAxe; + int ZAxe; + + void load_ini(); + void save_ini() const; +}; + + +#endif //FTNOIR_TRACKER_HAT_SETTINGS_H \ No newline at end of file diff --git a/ftnoir_tracker_hatire/images/hat.ico b/ftnoir_tracker_hatire/images/hat.ico new file mode 100644 index 00000000..d8f5aac4 Binary files /dev/null and b/ftnoir_tracker_hatire/images/hat.ico differ diff --git a/ftnoir_tracker_hatire/images/hat_logo.png b/ftnoir_tracker_hatire/images/hat_logo.png new file mode 100644 index 00000000..c3a92b1b Binary files /dev/null and b/ftnoir_tracker_hatire/images/hat_logo.png differ -- cgit v1.2.3 From c30602927bcd0865d7581e3fea31e65a6a73d592 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 27 Nov 2013 17:27:15 +0100 Subject: merge from FreePIE: vjoy bugfix Signed-off-by: Stanislaw Halik --- facetracknoir/clientfiles/vjoy/VJoy.dll | Bin 0 -> 94208 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 facetracknoir/clientfiles/vjoy/VJoy.dll (limited to 'facetracknoir') diff --git a/facetracknoir/clientfiles/vjoy/VJoy.dll b/facetracknoir/clientfiles/vjoy/VJoy.dll new file mode 100644 index 00000000..e3446675 Binary files /dev/null and b/facetracknoir/clientfiles/vjoy/VJoy.dll differ -- cgit v1.2.3 From 386f3e87423c130d149f19a6fad10b7c51a80fe2 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 29 Nov 2013 10:31:20 +0100 Subject: don't install macam, doesn't work with qtkit --- .../clientfiles/macosx/macam-cvs-build-2009-09-25.zip | Bin 3560122 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 facetracknoir/clientfiles/macosx/macam-cvs-build-2009-09-25.zip (limited to 'facetracknoir') diff --git a/facetracknoir/clientfiles/macosx/macam-cvs-build-2009-09-25.zip b/facetracknoir/clientfiles/macosx/macam-cvs-build-2009-09-25.zip deleted file mode 100644 index 79816779..00000000 Binary files a/facetracknoir/clientfiles/macosx/macam-cvs-build-2009-09-25.zip and /dev/null differ -- cgit v1.2.3 From 6fa54a3c58518523da20794e47b5718f3db2ca73 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 30 Nov 2013 16:03:00 +0100 Subject: forgot to add linker script proper --- facetracknoir/mingw-version-script.txt | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 facetracknoir/mingw-version-script.txt (limited to 'facetracknoir') diff --git a/facetracknoir/mingw-version-script.txt b/facetracknoir/mingw-version-script.txt new file mode 100644 index 00000000..fe20ad37 --- /dev/null +++ b/facetracknoir/mingw-version-script.txt @@ -0,0 +1,8 @@ +{ + global: + GetDialog?0; + GetConstructor?0; + GetMetadata?0; + local: + *; +}; -- cgit v1.2.3 From 49b2ac5b1c96e47636664439ab260f1ea4239be1 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 1 Dec 2013 12:38:59 +0100 Subject: ui: fix tab order Signed-off-by: Stanislaw Halik --- facetracknoir/ftnoir_curves.ui | 23 +- facetracknoir/ftnoir_keyboardshortcuts.ui | 448 ++++++++++----------- .../ftnoir_accela_filtercontrols.ui | 16 + ftnoir_tracker_aruco/aruco-trackercontrols.ui | 415 ++++++++++--------- 4 files changed, 465 insertions(+), 437 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/ftnoir_curves.ui b/facetracknoir/ftnoir_curves.ui index 2b843303..213e8f9a 100644 --- a/facetracknoir/ftnoir_curves.ui +++ b/facetracknoir/ftnoir_curves.ui @@ -29,8 +29,8 @@ background-color: #ccc; - - + + background-color: #ccc; @@ -763,7 +763,7 @@ - + QDialogButtonBox::Cancel|QDialogButtonBox::Ok @@ -779,6 +779,23 @@
qfunctionconfigurator.h
+ + pos_rx + pos_ry + pos_rz + pos_tx + pos_ty + pos_tz + checkBox + tz_altp + ty_altp + tabWidget + ry_altp + buttonBox + rz_altp + rx_altp + tx_altp + diff --git a/facetracknoir/ftnoir_keyboardshortcuts.ui b/facetracknoir/ftnoir_keyboardshortcuts.ui index a189b680..565c0e77 100644 --- a/facetracknoir/ftnoir_keyboardshortcuts.ui +++ b/facetracknoir/ftnoir_keyboardshortcuts.ui @@ -29,241 +29,219 @@ false - - - - 120 - 90 - 100 - 23 - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - Cancel - - - - - - 230 - 90 - 100 - 23 - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - OK - - - - - - 5 - 0 - 321 - 75 - - - - - - - - 0 - 0 - - - - Keyboard - - - Qt::AlignCenter - - - false - - - - - - - - 0 - 0 - - - - Center - - - false - - - - - - - - 50 - 16777215 - - - - Shift - - - - - - - - 50 - 16777215 - - - - Ctrl - - - - - - - - 50 - 16777215 - - - - Alt - - - - - - - - 90 - 0 - - - - Select Number - - - QComboBox::InsertAlphabetically - - - - - - - - 0 - 0 - - - - Toggle - - - false - - - - - - - - 50 - 16777215 - - - - Shift - - - - - - - - 50 - 16777215 - - - - Ctrl - - - - - - - - 50 - 16777215 - - - - Alt - - - - - - - - 90 - 0 - - - - Select Number - - - QComboBox::InsertAlphabetically - - - - - + + + + + + 0 + 0 + + + + Keyboard + + + Qt::AlignCenter + + + false + + + + + + + + 0 + 0 + + + + Center + + + false + + + + + + + + 50 + 16777215 + + + + Shift + + + + + + + + 50 + 16777215 + + + + Ctrl + + + + + + + + 50 + 16777215 + + + + Alt + + + + + + + + 90 + 0 + + + + Select Number + + + QComboBox::InsertAlphabetically + + + + + + + + 0 + 0 + + + + Toggle + + + false + + + + + + + + 50 + 16777215 + + + + Shift + + + + + + + + 50 + 16777215 + + + + Ctrl + + + + + + + + 50 + 16777215 + + + + Alt + + + + + + + + 90 + 0 + + + + Select Number + + + QComboBox::InsertAlphabetically + + + + + + + + 0 + 0 + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + Cancel + + + + + + + + 0 + 0 + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + OK + + + +
diff --git a/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui b/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui index b4b12061..536cf328 100644 --- a/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui +++ b/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui @@ -715,6 +715,22 @@ background:none;
+ + rotation_alpha + translation_alpha + order_2nd + order_3rd + spinZoom + deadzone + expt + doubleSpinBox + doubleSpinBox_2 + doubleSpinBox_3 + doubleSpinBox_4 + doubleSpinBox_5 + doubleSpinBox_6 + buttonBox + diff --git a/ftnoir_tracker_aruco/aruco-trackercontrols.ui b/ftnoir_tracker_aruco/aruco-trackercontrols.ui index 8cf28057..d4b64c23 100644 --- a/ftnoir_tracker_aruco/aruco-trackercontrols.ui +++ b/ftnoir_tracker_aruco/aruco-trackercontrols.ui @@ -32,205 +32,6 @@ -1 - - - - - 0 - 0 - - - - <html><head/><body><p>The ARUCO Library has been developed by the Ava group of the Univeristy of Cordoba, Spain</p><p>Rafael Muñoz Salinas &lt;<a href="mailto:rmsalinas@uco.es"><span style=" text-decoration: underline; color:#0057ae;">rmsalinas@uco.es</span></a>&gt;</p><p>&lt;<a href="https://github.com/rmsalinas/aruco"><span style=" text-decoration: underline; color:#0057ae;">https://github.com/rmsalinas/aruco</span></a>&gt;</p></body></html> - - - Qt::RichText - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - true - - - 4 - - - true - - - Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse|Qt::TextBrowserInteraction|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse - - - - - - - - Default - - - - - 30 - - - - - 60 - - - - - 120 - - - - - - - - Camera name - - - - - - - - - - - - - 35.000000000000000 - - - 180.000000000000000 - - - 52.000000000000000 - - - - - - - Frames per second - - - - - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - Horizontal FOV - - - - - - - Resolution - - - - - - - - 640x480 - - - - - 320x240 - - - - - 320x200 - - - - - Default (not recommended!) - - - - - - - - Enable axes - - - - -1 - - - 6 - - - 0 - - - 6 - - - 0 - - - - - RX - - - - - - - TX - - - - - - - RY - - - - - - - TY - - - - - - - RZ - - - - - - - TZ - - - - - - @@ -323,8 +124,224 @@ + + + + Enable axes + + + + -1 + + + 6 + + + 0 + + + 6 + + + 0 + + + + + RX + + + + + + + TX + + + + + + + RY + + + + + + + TY + + + + + + + RZ + + + + + + + TZ + + + + + + + + + + Resolution + + + + + + + + Default + + + + + 30 + + + + + 60 + + + + + 120 + + + + + + + + Frames per second + + + + + + + + 640x480 + + + + + 320x240 + + + + + 320x200 + + + + + Default (not recommended!) + + + + + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + + + 0 + 0 + + + + <html><head/><body><p>The ARUCO Library has been developed by the Ava group of the Univeristy of Cordoba, Spain</p><p>Rafael Muñoz Salinas &lt;<a href="mailto:rmsalinas@uco.es"><span style=" text-decoration: underline; color:#0057ae;">rmsalinas@uco.es</span></a>&gt;</p><p>&lt;<a href="https://github.com/rmsalinas/aruco"><span style=" text-decoration: underline; color:#0057ae;">https://github.com/rmsalinas/aruco</span></a>&gt;</p></body></html> + + + Qt::RichText + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + true + + + 4 + + + true + + + Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse|Qt::TextBrowserInteraction|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + + + + + + + 35.000000000000000 + + + 180.000000000000000 + + + 52.000000000000000 + + + + + + + Camera name + + + + + + + Horizontal FOV + + +
+ + cameraFOV + cameraFPS + cameraName + resolution + cx + cy + cz + pitch_deg + rx + ry + rz + tx + ty + tz + buttonBox + -- cgit v1.2.3 From ec60dd12939505c48b9d4348c152d2371c4621d9 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 1 Dec 2013 13:14:45 +0100 Subject: ui: fix tab order Signed-off-by: Stanislaw Halik --- facetracknoir/ftnoir_curves.ui | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/ftnoir_curves.ui b/facetracknoir/ftnoir_curves.ui index 213e8f9a..69440a5b 100644 --- a/facetracknoir/ftnoir_curves.ui +++ b/facetracknoir/ftnoir_curves.ui @@ -783,18 +783,18 @@ pos_rx pos_ry pos_rz - pos_tx - pos_ty - pos_tz - checkBox - tz_altp + ry_altp + rz_altp + tx_altp ty_altp + tz_altp + checkBox tabWidget - ry_altp + pos_tx buttonBox - rz_altp + pos_ty rx_altp - tx_altp + pos_tz -- cgit v1.2.3 From 59f4f2326f3fd8941e0694a930270d07774ca651 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 4 Dec 2013 18:45:18 +0100 Subject: not doing mingw-w64 lto builds anymore --- facetracknoir/mingw-version-script.txt | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 facetracknoir/mingw-version-script.txt (limited to 'facetracknoir') diff --git a/facetracknoir/mingw-version-script.txt b/facetracknoir/mingw-version-script.txt deleted file mode 100644 index fe20ad37..00000000 --- a/facetracknoir/mingw-version-script.txt +++ /dev/null @@ -1,8 +0,0 @@ -{ - global: - GetDialog?0; - GetConstructor?0; - GetMetadata?0; - local: - *; -}; -- cgit v1.2.3 From 81e2c265c795d9eda41ebed6550e1f7954db9bc5 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 9 Dec 2013 00:53:26 +0100 Subject: move translation compensation to its own function Signed-off-by: Stanislaw Halik --- facetracknoir/tracker.cpp | 65 +++++++++++++++++++++++++---------------------- 1 file changed, 34 insertions(+), 31 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/tracker.cpp b/facetracknoir/tracker.cpp index 6c48b17a..b65ccde8 100644 --- a/facetracknoir/tracker.cpp +++ b/facetracknoir/tracker.cpp @@ -50,6 +50,39 @@ static void get_curve(double pos, double& out, THeadPoseDOF& axis) { out += axis.zero; } +static void t_compensate(double* input, double* output) +{ + const auto H = input[Yaw] * M_PI / 180; + const auto P = input[Pitch] * M_PI / 180; + const auto B = input[Roll] * M_PI / 180; + + const auto cosH = cos(H); + const auto sinH = sin(H); + const auto cosP = cos(P); + const auto sinP = sin(P); + const auto cosB = cos(B); + const auto sinB = sin(B); + + double foo[] = { + cosH * cosB - sinH * sinP * sinB, + - sinB * cosP, + sinH * cosB + cosH * sinP * sinB, + cosH * sinB + sinH * sinP * cosB, + cosB * cosP, + sinB * sinH - cosH * sinP * cosB, + - sinH * cosP, + - sinP, + cosH * cosP, + }; + + cv::Mat rmat(3, 3, CV_64F, foo); + const cv::Mat tvec(3, 1, CV_64F, input); + cv::Mat ret = rmat * tvec; + + for (int i = 0; i < 3; i++) + output[i] = ret.at(i); +} + /** QThread run method @override **/ void Tracker::run() { T6DOF offset_camera, gameoutput_camera, target_camera; @@ -129,37 +162,7 @@ void Tracker::run() { } if (compensate) - { - const auto H = output_camera.axes[Yaw] * M_PI / 180; - const auto P = output_camera.axes[Pitch] * M_PI / 180; - const auto B = output_camera.axes[Roll] * M_PI / 180; - - const auto cosH = cos(H); - const auto sinH = sin(H); - const auto cosP = cos(P); - const auto sinP = sin(P); - const auto cosB = cos(B); - const auto sinB = sin(B); - - double foo[] = { - cosH * cosB - sinH * sinP * sinB, - - sinB * cosP, - sinH * cosB + cosH * sinP * sinB, - cosH * sinB + sinH * sinP * cosB, - cosB * cosP, - sinB * sinH - cosH * sinP * cosB, - - sinH * cosP, - - sinP, - cosH * cosP, - }; - - cv::Mat rmat(3, 3, CV_64F, foo); - cv::Mat tvec(3, 1, CV_64F, output_camera.axes); - cv::Mat ret = rmat * tvec; - - for (int i = 0; i < 3; i++) - output_camera.axes[i] = ret.at(i); - } + t_compensate(output_camera.axes, output_camera.axes); if (Libraries->pProtocol) { gameoutput_camera = output_camera; -- cgit v1.2.3 From 1744c1cc6058e4508c912eac1e40a277fe4c4bfe Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 10 Dec 2013 03:25:39 +0100 Subject: don't jump around when repeatedly centering Signed-off-by: Stanislaw Halik --- facetracknoir/tracker.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'facetracknoir') diff --git a/facetracknoir/tracker.cpp b/facetracknoir/tracker.cpp index b65ccde8..9bf5fb2c 100644 --- a/facetracknoir/tracker.cpp +++ b/facetracknoir/tracker.cpp @@ -131,7 +131,7 @@ void Tracker::run() { if (do_center) { for (int i = 0; i < 6; i++) - offset_camera.axes[i] = target_camera.axes[i]; + offset_camera.axes[i] = mainApp->axis(i).headPos; do_center = false; -- cgit v1.2.3 From 474e4f75998ca0782f5212c7365d107790cab5c6 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 10 Dec 2013 03:27:41 +0100 Subject: move declarations closer to usage Signed-off-by: Stanislaw Halik --- facetracknoir/tracker.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/tracker.cpp b/facetracknoir/tracker.cpp index 9bf5fb2c..dfc5d230 100644 --- a/facetracknoir/tracker.cpp +++ b/facetracknoir/tracker.cpp @@ -85,7 +85,7 @@ static void t_compensate(double* input, double* output) /** QThread run method @override **/ void Tracker::run() { - T6DOF offset_camera, gameoutput_camera, target_camera; + T6DOF offset_camera; bool bTracker1Confid = false; bool bTracker2Confid = false; @@ -139,7 +139,7 @@ void Tracker::run() { Libraries->pFilter->Initialize(); } - T6DOF target_camera2, new_camera; + T6DOF target_camera, target_camera2, new_camera; if (enabled && confid) { @@ -149,6 +149,8 @@ void Tracker::run() { target_camera2 = target_camera - offset_camera; } + T6DOF gameoutput_camera; + if (Libraries->pFilter) { for (int i = 0; i < 6; i++) last_post_filter[i] = gameoutput_camera.axes[i]; -- cgit v1.2.3 From 893b79383a71f5ce8a34f756445c1494d049a283 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 10 Dec 2013 03:29:38 +0100 Subject: get rid of 'confid' --- facetracknoir/tracker.cpp | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/tracker.cpp b/facetracknoir/tracker.cpp index dfc5d230..371c10a6 100644 --- a/facetracknoir/tracker.cpp +++ b/facetracknoir/tracker.cpp @@ -87,9 +87,6 @@ static void t_compensate(double* input, double* output) void Tracker::run() { T6DOF offset_camera; - bool bTracker1Confid = false; - bool bTracker2Confid = false; - double newpose[6] = {0}; double last_post_filter[6] ; @@ -113,21 +110,18 @@ void Tracker::run() { break; if (Libraries->pSecondTracker) { - bTracker2Confid = Libraries->pSecondTracker->GiveHeadPoseData(newpose); + Libraries->pSecondTracker->GiveHeadPoseData(newpose); } if (Libraries->pTracker) { - bTracker1Confid = Libraries->pTracker->GiveHeadPoseData(newpose); + Libraries->pTracker->GiveHeadPoseData(newpose); } { QMutexLocker foo(&mtx); - const bool confid = bTracker1Confid || bTracker2Confid; - if ( confid ) { - for (int i = 0; i < 6; i++) - mainApp->axis(i).headPos = newpose[i]; - } + for (int i = 0; i < 6; i++) + mainApp->axis(i).headPos = newpose[i]; if (do_center) { for (int i = 0; i < 6; i++) -- cgit v1.2.3 From c1845054628c42017b838ceb7769a779dc1f1e08 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 10 Dec 2013 03:30:05 +0100 Subject: this declaration must have larger extent --- facetracknoir/tracker.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/tracker.cpp b/facetracknoir/tracker.cpp index 371c10a6..dfe71f28 100644 --- a/facetracknoir/tracker.cpp +++ b/facetracknoir/tracker.cpp @@ -85,7 +85,7 @@ static void t_compensate(double* input, double* output) /** QThread run method @override **/ void Tracker::run() { - T6DOF offset_camera; + T6DOF offset_camera, gameoutput_camera; double newpose[6] = {0}; double last_post_filter[6] ; @@ -135,7 +135,7 @@ void Tracker::run() { T6DOF target_camera, target_camera2, new_camera; - if (enabled && confid) + if (enabled) { for (int i = 0; i < 6; i++) target_camera.axes[i] = mainApp->axis(i).headPos; @@ -143,8 +143,6 @@ void Tracker::run() { target_camera2 = target_camera - offset_camera; } - T6DOF gameoutput_camera; - if (Libraries->pFilter) { for (int i = 0; i < 6; i++) last_post_filter[i] = gameoutput_camera.axes[i]; -- cgit v1.2.3 From 83997336c88f75cc183eb7ccdb7ae002be9b0fac Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 10 Dec 2013 03:45:27 +0100 Subject: get rid of "last_post_filter" Signed-off-by: Stanislaw Halik --- facetracknoir/tracker.cpp | 11 +- .../ftnoir_accela_filtercontrols.ui | 159 ++++++--------------- ftnoir_filter_accela/ftnoir_filter_accela.cpp | 11 +- ftnoir_filter_accela/ftnoir_filter_accela.h | 5 +- .../ftnoir_filter_accela_dialog.cpp | 4 - ftnoir_filter_base/ftnoir_filter_base.h | 2 +- ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp | 3 +- ftnoir_filter_ewma2/ftnoir_filter_ewma2.h | 2 +- ftnoir_filter_kalman/ftnoir_filter_kalman.h | 3 +- ftnoir_filter_kalman/kalman.cpp | 3 +- 10 files changed, 60 insertions(+), 143 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/tracker.cpp b/facetracknoir/tracker.cpp index dfe71f28..fbf90a66 100644 --- a/facetracknoir/tracker.cpp +++ b/facetracknoir/tracker.cpp @@ -85,11 +85,9 @@ static void t_compensate(double* input, double* output) /** QThread run method @override **/ void Tracker::run() { - T6DOF offset_camera, gameoutput_camera; + T6DOF offset_camera; double newpose[6] = {0}; - double last_post_filter[6] ; - int sleep_ms = 15; if (Libraries->pTracker) @@ -144,9 +142,7 @@ void Tracker::run() { } if (Libraries->pFilter) { - for (int i = 0; i < 6; i++) - last_post_filter[i] = gameoutput_camera.axes[i]; - Libraries->pFilter->FilterHeadPoseData(target_camera2.axes, new_camera.axes, last_post_filter); + Libraries->pFilter->FilterHeadPoseData(target_camera2.axes, new_camera.axes); } else { new_camera = target_camera2; } @@ -159,8 +155,7 @@ void Tracker::run() { t_compensate(output_camera.axes, output_camera.axes); if (Libraries->pProtocol) { - gameoutput_camera = output_camera; - Libraries->pProtocol->sendHeadposeToGame( gameoutput_camera.axes ); // degrees & centimeters + Libraries->pProtocol->sendHeadposeToGame( output_camera.axes ); // degrees & centimeters } } diff --git a/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui b/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui index b48496bf..fb6a9565 100644 --- a/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui +++ b/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui @@ -78,6 +78,9 @@ Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + QFormLayout::ExpandingFieldsGrow + @@ -160,76 +163,77 @@ - - + + + + Order #2 + + + + + - + 0 0 - - - 25 - 0 - + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - 150 - 16777215 - + + QAbstractSpinBox::CorrectToPreviousValue - - color:#0; -background:none; + + 4 + + + 0.100000000000000 + + 65535.000000000000000 + + + 1.000000000000000 + + + + + - Zoomed + Order #3 - - + + 0 0 - - - 20 - 22 - - - - background:none; - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - false + + QAbstractSpinBox::CorrectToPreviousValue - - % + + 4 - 0 + 0.100000000000000 - 200 - - - 1 + 65535.000000000000000 - 45 + 1.000000000000000 - + @@ -258,7 +262,7 @@ background:none; - + @@ -286,14 +290,14 @@ background:none; - + Exponent - + @@ -315,76 +319,6 @@ background:none; - - - - Order #2 - - - - - - - - 0 - 0 - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - QAbstractSpinBox::CorrectToPreviousValue - - - 4 - - - 0.100000000000000 - - - 65535.000000000000000 - - - 1.000000000000000 - - - - - - - - 0 - 0 - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - QAbstractSpinBox::CorrectToPreviousValue - - - 4 - - - 0.100000000000000 - - - 65535.000000000000000 - - - 1.000000000000000 - - - - - - - Order #3 - - -
@@ -720,7 +654,6 @@ background:none; translation_alpha order_2nd order_3rd - spinZoom deadzone expt doubleSpinBox diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.cpp b/ftnoir_filter_accela/ftnoir_filter_accela.cpp index a78a38c5..1046c268 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela.cpp @@ -31,7 +31,6 @@ void FTNoIR_Filter::loadSettings() { QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) iniFile.beginGroup ( "Accela" ); - zoom_factor = iniFile.value("zoom-slowness", ACCELA_ZOOM_SLOWNESS).toDouble(); rotation_alpha = iniFile.value("rotation-alpha", ACCELA_SMOOTHING_ROTATION).toDouble(); translation_alpha = iniFile.value("translation-alpha", ACCELA_SMOOTHING_TRANSLATION).toDouble(); second_order_alpha = iniFile.value("second-order-alpha", ACCELA_SECOND_ORDER_ALPHA).toDouble(); @@ -80,8 +79,7 @@ static inline T clamp(const T min, const T max, const T value) } void FTNoIR_Filter::FilterHeadPoseData(const double* target_camera_position, - double *new_camera_position, - const double* last_post_filter_values) + double *new_camera_position) { if (first_run) { @@ -136,11 +134,10 @@ void FTNoIR_Filter::FilterHeadPoseData(const double* target_camera_position, const double a = i >= 3 ? rotation_alpha : translation_alpha; const double a2 = a * second_order_alpha; const double a3 = a * third_order_alpha; - const double reduction = 1. / std::max(1., 1. + zoom_factor * -last_post_filter_values[TZ] / 1000); const double velocity = - parabola(a, vec * scaling[i], deadzone, expt) * reduction + - parabola(a2, vec2 * scaling[i], deadzone, expt) * reduction + - parabola(a3, vec3 * scaling[i], deadzone, expt) * reduction; + parabola(a, vec * scaling[i], deadzone, expt) + + parabola(a2, vec2 * scaling[i], deadzone, expt) + + parabola(a3, vec3 * scaling[i], deadzone, expt); const double result = last_output[0][i] + velocity; const bool done = sign > 0 ? result >= target_camera_position[i] : result <= target_camera_position[i]; new_camera_position[i] = done ? target_camera_position[i] : result; diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.h b/ftnoir_filter_accela/ftnoir_filter_accela.h index 0a550f0e..d91a5e42 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.h +++ b/ftnoir_filter_accela/ftnoir_filter_accela.h @@ -34,7 +34,6 @@ #define ACCELA_SMOOTHING_ROTATION 60.0 #define ACCELA_SMOOTHING_TRANSLATION 40.0 -#define ACCELA_ZOOM_SLOWNESS 0 #define ACCELA_SECOND_ORDER_ALPHA 100.0 #define ACCELA_THIRD_ORDER_ALPHA 180.0 @@ -46,7 +45,7 @@ class FTNoIR_Filter : public IFilter public: FTNoIR_Filter(); virtual ~FTNoIR_Filter(); - void FilterHeadPoseData(const double* target_camera_position, double *new_camera_position, const double* last_post_filter_values); + void FilterHeadPoseData(const double* target_camera_position, double *new_camera_position); void Initialize() { first_run = true; } @@ -55,7 +54,7 @@ private: QMutex mutex; void loadSettings(); bool first_run; - double rotation_alpha, translation_alpha, zoom_factor; + double rotation_alpha, translation_alpha; double second_order_alpha, third_order_alpha; double scaling[6]; double deadzone; diff --git a/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp b/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp index be6836c2..a14db280 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp @@ -47,8 +47,6 @@ FilterControls::FilterControls() : connect(ui.rotation_alpha, SIGNAL(valueChanged(double)), this, SLOT(settingChanged(double))); connect(ui.translation_alpha, SIGNAL(valueChanged(double)), this, SLOT(settingChanged(double))); - connect(ui.spinZoom, SIGNAL(valueChanged(int)), this, SLOT(settingChanged(int))); - QDoubleSpinBox* boxen[] = { ui.doubleSpinBox, ui.doubleSpinBox_2, @@ -157,7 +155,6 @@ void FilterControls::loadSettings() { //qDebug() << "FTNoIR_Filter::loadSettings2 says: size = " << NUM_OF(defScaleRotation); iniFile.beginGroup ( "Accela" ); - ui.spinZoom->setValue(iniFile.value("zoom-slowness", ACCELA_ZOOM_SLOWNESS).toInt()); ui.rotation_alpha->setValue(iniFile.value("rotation-alpha", ACCELA_SMOOTHING_ROTATION).toDouble()); ui.translation_alpha->setValue(iniFile.value("translation-alpha", ACCELA_SMOOTHING_TRANSLATION).toDouble()); ui.order_2nd->setValue(iniFile.value("second-order-alpha", ACCELA_SECOND_ORDER_ALPHA).toDouble()); @@ -210,7 +207,6 @@ void FilterControls::save() { iniFile.beginGroup ( "Accela" ); iniFile.setValue("rotation-alpha", ui.rotation_alpha->value()); iniFile.setValue("translation-alpha", ui.translation_alpha->value()); - iniFile.setValue("zoom-slowness", ui.spinZoom->value()); iniFile.setValue("deadzone", ui.deadzone->value()); iniFile.setValue("exponent", ui.expt->value()); iniFile.setValue("second-order-alpha", ui.order_2nd->value()); diff --git a/ftnoir_filter_base/ftnoir_filter_base.h b/ftnoir_filter_base/ftnoir_filter_base.h index 48a4a6b9..800e5deb 100644 --- a/ftnoir_filter_base/ftnoir_filter_base.h +++ b/ftnoir_filter_base/ftnoir_filter_base.h @@ -13,7 +13,7 @@ struct IFilter { virtual ~IFilter() = 0; - virtual void FilterHeadPoseData(const double *target_camera_position, double *new_camera_position, const double *last_post_filter) = 0; + virtual void FilterHeadPoseData(const double *target_camera_position, double *new_camera_position) = 0; virtual void Initialize() = 0; }; diff --git a/ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp b/ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp index 3b208ef2..5f66be96 100644 --- a/ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp +++ b/ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp @@ -80,8 +80,7 @@ void FTNoIR_Filter::loadSettings() { } void FTNoIR_Filter::FilterHeadPoseData(const double *target_camera_position, - double *new_camera_position, - const double *) + double *new_camera_position) { double delta; double new_alpha; diff --git a/ftnoir_filter_ewma2/ftnoir_filter_ewma2.h b/ftnoir_filter_ewma2/ftnoir_filter_ewma2.h index 7f2f21e6..86e4b65c 100644 --- a/ftnoir_filter_ewma2/ftnoir_filter_ewma2.h +++ b/ftnoir_filter_ewma2/ftnoir_filter_ewma2.h @@ -45,7 +45,7 @@ public: void Initialize() {} void FilterHeadPoseData(const double *target_camera_position, - double *new_camera_position, const double *); + double *new_camera_position); void receiveSettings(double smin, double smax, double sexpt); private: diff --git a/ftnoir_filter_kalman/ftnoir_filter_kalman.h b/ftnoir_filter_kalman/ftnoir_filter_kalman.h index 6c2cb6a9..da6df2b1 100644 --- a/ftnoir_filter_kalman/ftnoir_filter_kalman.h +++ b/ftnoir_filter_kalman/ftnoir_filter_kalman.h @@ -30,8 +30,7 @@ public: } void Initialize() virt_override; void FilterHeadPoseData(const double *target_camera_position, - double *new_camera_position, - const double *) virt_override; + double *new_camera_position) virt_override; cv::KalmanFilter kalman; double prev_position[6]; double prev2_filter_pos[6]; diff --git a/ftnoir_filter_kalman/kalman.cpp b/ftnoir_filter_kalman/kalman.cpp index 5ecd417c..629cfcc8 100644 --- a/ftnoir_filter_kalman/kalman.cpp +++ b/ftnoir_filter_kalman/kalman.cpp @@ -93,8 +93,7 @@ static inline T clamp(const T min, const T max, const T value) } void FTNoIR_Filter::FilterHeadPoseData(const double* target_camera_position, - double *new_camera_position, - const double *) + double *new_camera_position) { bool new_target = false; -- cgit v1.2.3 From 3bc46979c76cd13b10ba0215804962f1e3904c5c Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 10 Dec 2013 03:54:52 +0100 Subject: s/Give/Get/ --- FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp | 2 +- FTNoIR_Tracker_PT/ftnoir_tracker_pt.h | 4 ++-- facetracknoir/tracker.cpp | 4 ++-- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 2 +- ftnoir_tracker_aruco/ftnoir_tracker_aruco.h | 2 +- ftnoir_tracker_base/ftnoir_tracker_base.h | 2 +- ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp | 2 +- ftnoir_tracker_hatire/ftnoir_tracker_hat.h | 4 ++-- ftnoir_tracker_ht/ftnoir_tracker_ht.cpp | 2 +- ftnoir_tracker_ht/ftnoir_tracker_ht.h | 2 +- ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp | 2 +- ftnoir_tracker_hydra/ftnoir_tracker_hydra.h | 2 +- ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp | 2 +- ftnoir_tracker_joystick/ftnoir_tracker_joystick.h | 2 +- ftnoir_tracker_rift/ftnoir_tracker_rift.cpp | 2 +- ftnoir_tracker_rift/ftnoir_tracker_rift.h | 2 +- ftnoir_tracker_udp/ftnoir_tracker_udp.cpp | 2 +- ftnoir_tracker_udp/ftnoir_tracker_udp.h | 2 +- opentrack-api/trackers.cpp | 2 +- 19 files changed, 22 insertions(+), 22 deletions(-) (limited to 'facetracknoir') diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp index a6aaa29c..639053b7 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp @@ -233,7 +233,7 @@ void Tracker::StopTracker(bool exit) #define THeadPoseData double #endif -void Tracker::GiveHeadPoseData(THeadPoseData *data) +void Tracker::GetHeadPoseData(THeadPoseData *data) { { QMutexLocker lock(&mutex); diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h index 5c8d35d2..54edafb2 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h @@ -44,11 +44,11 @@ public: virtual void Initialize(QFrame *videoframe); #ifdef OPENTRACK_API virtual void StartTracker(QFrame* parent_window); - virtual void GiveHeadPoseData(double* data); + virtual void GetHeadPoseData(double* data); #else virtual void StartTracker(HWND parent_window); virtual void StopTracker(bool exit); - virtual bool GiveHeadPoseData(THeadPoseData *data); + virtual bool GetHeadPoseData(THeadPoseData *data); #endif virtual void refreshVideo(); diff --git a/facetracknoir/tracker.cpp b/facetracknoir/tracker.cpp index fbf90a66..8f8ad356 100644 --- a/facetracknoir/tracker.cpp +++ b/facetracknoir/tracker.cpp @@ -108,11 +108,11 @@ void Tracker::run() { break; if (Libraries->pSecondTracker) { - Libraries->pSecondTracker->GiveHeadPoseData(newpose); + Libraries->pSecondTracker->GetHeadPoseData(newpose); } if (Libraries->pTracker) { - Libraries->pTracker->GiveHeadPoseData(newpose); + Libraries->pTracker->GetHeadPoseData(newpose); } { diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index 11916df5..6d06d4a8 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -375,7 +375,7 @@ void Tracker::run() } } -void Tracker::GiveHeadPoseData(double *data) +void Tracker::GetHeadPoseData(double *data) { QMutexLocker lck(&mtx); diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h index 8a480d9f..be2ad3d7 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h @@ -26,7 +26,7 @@ public: Tracker(); virtual ~Tracker(); void StartTracker(QFrame* frame); - void GiveHeadPoseData(double *data); + void GetHeadPoseData(double *data); bool enableTX, enableTY, enableTZ, enableRX, enableRY, enableRZ; void run(); void load_settings(); diff --git a/ftnoir_tracker_base/ftnoir_tracker_base.h b/ftnoir_tracker_base/ftnoir_tracker_base.h index e6e770ed..16f76cf3 100644 --- a/ftnoir_tracker_base/ftnoir_tracker_base.h +++ b/ftnoir_tracker_base/ftnoir_tracker_base.h @@ -43,7 +43,7 @@ struct ITracker { virtual ~ITracker() = 0; virtual void StartTracker( QFrame* frame ) = 0; - virtual void GiveHeadPoseData(double *data) = 0; + virtual void GetHeadPoseData(double *data) = 0; virtual int preferredHz() { return 66; } }; diff --git a/ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp b/ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp index bcef6753..f902b207 100644 --- a/ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp +++ b/ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp @@ -323,7 +323,7 @@ void FTNoIR_Tracker::StartTracker(QFrame*) #define THeadPoseData double #endif -void FTNoIR_Tracker::GiveHeadPoseData(THeadPoseData *data) +void FTNoIR_Tracker::GetHeadPoseData(THeadPoseData *data) { QMutexLocker lck(&mutex); while (dataRead.length()>=30) { diff --git a/ftnoir_tracker_hatire/ftnoir_tracker_hat.h b/ftnoir_tracker_hatire/ftnoir_tracker_hat.h index 04c5fb61..ec1125b9 100644 --- a/ftnoir_tracker_hatire/ftnoir_tracker_hat.h +++ b/ftnoir_tracker_hatire/ftnoir_tracker_hat.h @@ -29,12 +29,12 @@ public: #ifdef OPENTRACK_API virtual void StartTracker(QFrame*); - virtual void GiveHeadPoseData(double* data); + virtual void GetHeadPoseData(double* data); #else void Initialize( QFrame *videoframe ); virtual void StartTracker(HWND parent_window); virtual void StopTracker(bool exit); - virtual bool GiveHeadPoseData(THeadPoseData *data); + virtual bool GetHeadPoseData(THeadPoseData *data); #endif void applysettings(const TrackerSettings& settings); void notifyCenter(); diff --git a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp index c3c12005..00dd9919 100644 --- a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp +++ b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp @@ -186,7 +186,7 @@ void Tracker::StartTracker(QFrame* videoframe) #endif } -void Tracker::GiveHeadPoseData(double *data) +void Tracker::GetHeadPoseData(double *data) { lck_shm.lock(); shm->timer = 0; diff --git a/ftnoir_tracker_ht/ftnoir_tracker_ht.h b/ftnoir_tracker_ht/ftnoir_tracker_ht.h index 475d5a6c..404dbf6e 100644 --- a/ftnoir_tracker_ht/ftnoir_tracker_ht.h +++ b/ftnoir_tracker_ht/ftnoir_tracker_ht.h @@ -23,7 +23,7 @@ public: Tracker(); virtual ~Tracker(); void StartTracker(QFrame* frame); - void GiveHeadPoseData(double *data); + void GetHeadPoseData(double *data); bool enableTX, enableTY, enableTZ, enableRX, enableRY, enableRZ; ht_shm_t* shm; private: diff --git a/ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp b/ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp index 11a3e0fb..31e3f319 100644 --- a/ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp +++ b/ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp @@ -66,7 +66,7 @@ void Hydra_Tracker::StartTracker(QFrame*) } -void Hydra_Tracker::GiveHeadPoseData(double *data) +void Hydra_Tracker::GetHeadPoseData(double *data) { sixenseSetActiveBase(0); diff --git a/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h b/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h index 6e40b710..240f0687 100644 --- a/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h +++ b/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h @@ -12,7 +12,7 @@ public: ~Hydra_Tracker(); void StartTracker(QFrame *) virt_override; - void GiveHeadPoseData(double *data) virt_override; + void GetHeadPoseData(double *data) virt_override; void loadSettings(); volatile bool should_quit; protected: diff --git a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp index 8f5ac162..5be6b3db 100644 --- a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp +++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp @@ -175,7 +175,7 @@ fail: qDebug() << "joy init failure"; } -void FTNoIR_Tracker::GiveHeadPoseData(double *data) +void FTNoIR_Tracker::GetHeadPoseData(double *data) { QMutexLocker foo(&mtx); DIJOYSTATE js = {0}; diff --git a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h index 809d8c73..9c856d85 100644 --- a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h +++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h @@ -42,7 +42,7 @@ public: ~FTNoIR_Tracker(); void StartTracker(QFrame *frame); - void GiveHeadPoseData(double *data); + void GetHeadPoseData(double *data); void loadSettings(); LPDIRECTINPUT8 g_pDI; LPDIRECTINPUTDEVICE8 g_pJoystick; diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp b/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp index c3b313ca..da44ea0c 100644 --- a/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp +++ b/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp @@ -68,7 +68,7 @@ void Rift_Tracker::StartTracker(QFrame*) } -void Rift_Tracker::GiveHeadPoseData(double *data) +void Rift_Tracker::GetHeadPoseData(double *data) { if (pSFusion != NULL && pSensor != NULL) { Quatf hmdOrient = pSFusion->GetOrientation(); diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift.h b/ftnoir_tracker_rift/ftnoir_tracker_rift.h index 33e6f5cd..3920c6ad 100644 --- a/ftnoir_tracker_rift/ftnoir_tracker_rift.h +++ b/ftnoir_tracker_rift/ftnoir_tracker_rift.h @@ -15,7 +15,7 @@ public: virtual ~Rift_Tracker() virt_override; void StartTracker(QFrame *) virt_override; - void GiveHeadPoseData(double *data) virt_override; + void GetHeadPoseData(double *data) virt_override; void loadSettings(); virtual int preferredHz() virt_override { return 250; } volatile bool should_quit; diff --git a/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp b/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp index d58341a6..e70bfdc7 100644 --- a/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp +++ b/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp @@ -110,7 +110,7 @@ void FTNoIR_Tracker::StartTracker(QFrame*) return; } -void FTNoIR_Tracker::GiveHeadPoseData(double *data) +void FTNoIR_Tracker::GetHeadPoseData(double *data) { mutex.lock(); if (bEnableX) { diff --git a/ftnoir_tracker_udp/ftnoir_tracker_udp.h b/ftnoir_tracker_udp/ftnoir_tracker_udp.h index 7b6c5328..c7e9decf 100644 --- a/ftnoir_tracker_udp/ftnoir_tracker_udp.h +++ b/ftnoir_tracker_udp/ftnoir_tracker_udp.h @@ -16,7 +16,7 @@ public: ~FTNoIR_Tracker(); void StartTracker(QFrame *); - void GiveHeadPoseData(double *data); + void GetHeadPoseData(double *data); void loadSettings(); volatile bool should_quit; protected: diff --git a/opentrack-api/trackers.cpp b/opentrack-api/trackers.cpp index 937f7084..5027ec1d 100644 --- a/opentrack-api/trackers.cpp +++ b/opentrack-api/trackers.cpp @@ -31,7 +31,7 @@ void OPENTRACK_EXPORT opentrack_tracker_start(opentrack self, opentrack_tracker void OPENTRACK_EXPORT opentrack_tracker_tick(opentrack_tracker tracker, double* headpose) { - tracker->GiveHeadPoseData(headpose); + tracker->GetHeadPoseData(headpose); QApplication::processEvents(0, 5); } -- cgit v1.2.3 From f767abd5a5c3f61727d949b230b12ed055d2ce62 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 10 Dec 2013 04:38:44 +0100 Subject: replace the forked project's logo with a cute octopus drawing Signed-off-by: Stanislaw Halik --- facetracknoir/images/facetracknoir.png | Bin 691 -> 26466 bytes ftnoir_posewidget/images/side1.png | Bin 9018 -> 26449 bytes ftnoir_posewidget/images/side6.png | Bin 4768 -> 26493 bytes 3 files changed, 0 insertions(+), 0 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/images/facetracknoir.png b/facetracknoir/images/facetracknoir.png index b57724e0..41b54524 100644 Binary files a/facetracknoir/images/facetracknoir.png and b/facetracknoir/images/facetracknoir.png differ diff --git a/ftnoir_posewidget/images/side1.png b/ftnoir_posewidget/images/side1.png index e0315b77..d7467943 100644 Binary files a/ftnoir_posewidget/images/side1.png and b/ftnoir_posewidget/images/side1.png differ diff --git a/ftnoir_posewidget/images/side6.png b/ftnoir_posewidget/images/side6.png index f4160001..eaa80d7e 100644 Binary files a/ftnoir_posewidget/images/side6.png and b/ftnoir_posewidget/images/side6.png differ -- cgit v1.2.3 From e917b2fd7b7cf57ef77e7c2a1252d8adae80d1fa Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 10 Dec 2013 04:42:39 +0100 Subject: re-add mingw version script Signed-off-by: Stanislaw Halik --- facetracknoir/mingw-version-script.txt | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 facetracknoir/mingw-version-script.txt (limited to 'facetracknoir') diff --git a/facetracknoir/mingw-version-script.txt b/facetracknoir/mingw-version-script.txt new file mode 100644 index 00000000..fe20ad37 --- /dev/null +++ b/facetracknoir/mingw-version-script.txt @@ -0,0 +1,8 @@ +{ + global: + GetDialog?0; + GetConstructor?0; + GetMetadata?0; + local: + *; +}; -- cgit v1.2.3 From 3fc21e23083bce507fc9832073297c9a861c3505 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 14 Dec 2013 17:45:05 +0100 Subject: allow for Z swapping for tcomp Signed-off-by: Stanislaw Halik --- facetracknoir/curve-config.cpp | 11 +++++-- facetracknoir/facetracknoir.cpp | 1 + facetracknoir/ftnoir_curves.ui | 66 +++++++++++++++++++++++++++++------------ facetracknoir/tracker.cpp | 12 ++++---- facetracknoir/tracker.h | 1 + 5 files changed, 64 insertions(+), 27 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/curve-config.cpp b/facetracknoir/curve-config.cpp index ca9e0d19..2e731892 100644 --- a/facetracknoir/curve-config.cpp +++ b/facetracknoir/curve-config.cpp @@ -96,6 +96,7 @@ void CurveConfigurationDialog::loadSettings() { iniFile.beginGroup("Tracking"); + ui.tcomp_rz->setChecked(iniFile.value("tcomp-rz", false).toBool()); ui.checkBox->setChecked(iniFile.value("compensate", true).toBool()); for (int i = 0; i < 6; i++) @@ -184,7 +185,7 @@ void CurveConfigurationDialog::loadSettings() { connect(checkboxes[i], SIGNAL(stateChanged(int)), this, SLOT(curveChanged(int)), Qt::UniqueConnection); mainApp->axis(i).zero = widgets3[i]->value(); } - + settingsDirty = false; } @@ -213,16 +214,20 @@ void CurveConfigurationDialog::save() { ui.ryconfig_alt->saveSettings(currentFile); ui.rzconfig_alt->saveSettings(currentFile); + bool tcomp_rz = false, compensate = true; + QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) iniFile.beginGroup("Tracking"); - bool compensate = true; - + iniFile.setValue("tcomp-rz", tcomp_rz = ui.tcomp_rz->checkState() != Qt::Unchecked); iniFile.setValue("compensate", compensate = (bool) !!ui.checkBox->isChecked()); if (mainApp->tracker) + { mainApp->tracker->compensate = compensate; + mainApp->tracker->tcomp_rz = tcomp_rz; + } iniFile.setValue("rx_alt", ui.rx_altp->checkState() != Qt::Unchecked); iniFile.setValue("ry_alt", ui.ry_altp->checkState() != Qt::Unchecked); diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index 1f3ae3a2..75ac737d 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -495,6 +495,7 @@ void FaceTrackNoIR::startTracker( ) { tracker = new Tracker ( this ); tracker->compensate = iniFile.value("compensate", true).toBool(); + tracker->tcomp_rz = iniFile.value("tcomp-rz", false).toBool(); iniFile.endGroup(); diff --git a/facetracknoir/ftnoir_curves.ui b/facetracknoir/ftnoir_curves.ui index 69440a5b..87c449ba 100644 --- a/facetracknoir/ftnoir_curves.ui +++ b/facetracknoir/ftnoir_curves.ui @@ -579,25 +579,6 @@ Options - - - - 310 - 10 - 192 - 21 - - - - - 0 - 0 - - - - Translation compensation - - @@ -760,6 +741,53 @@ + + + + 10 + 140 + 211 + 81 + + + + + + + Translation compensation + + + true + + + + + + + 0 + 0 + + + + + + + Enablement + + + + + + + + + + Reverse Z axis + + + + +
diff --git a/facetracknoir/tracker.cpp b/facetracknoir/tracker.cpp index 8f8ad356..0c5501d4 100644 --- a/facetracknoir/tracker.cpp +++ b/facetracknoir/tracker.cpp @@ -26,7 +26,8 @@ Tracker::Tracker( FaceTrackNoIR *parent ) : should_quit(false), do_center(false), enabled(true), - compensate(true) + compensate(true), + tcomp_rz(false) { mainApp = parent; } @@ -50,8 +51,9 @@ static void get_curve(double pos, double& out, THeadPoseDOF& axis) { out += axis.zero; } -static void t_compensate(double* input, double* output) +static void t_compensate(double* input, double* output, bool rz) { + double z = rz ? -1 : 1; const auto H = input[Yaw] * M_PI / 180; const auto P = input[Pitch] * M_PI / 180; const auto B = input[Roll] * M_PI / 180; @@ -60,8 +62,8 @@ static void t_compensate(double* input, double* output) const auto sinH = sin(H); const auto cosP = cos(P); const auto sinP = sin(P); - const auto cosB = cos(B); - const auto sinB = sin(B); + const auto cosB = cos(B * z); + const auto sinB = sin(B * z); double foo[] = { cosH * cosB - sinH * sinP * sinB, @@ -152,7 +154,7 @@ void Tracker::run() { } if (compensate) - t_compensate(output_camera.axes, output_camera.axes); + t_compensate(output_camera.axes, output_camera.axes, tcomp_rz); if (Libraries->pProtocol) { Libraries->pProtocol->sendHeadposeToGame( output_camera.axes ); // degrees & centimeters diff --git a/facetracknoir/tracker.h b/facetracknoir/tracker.h index 1094c61b..02824206 100644 --- a/facetracknoir/tracker.h +++ b/facetracknoir/tracker.h @@ -84,6 +84,7 @@ public: volatile bool do_center; volatile bool enabled; volatile bool compensate; + volatile bool tcomp_rz; T6DOF output_camera; }; -- cgit v1.2.3 From 0284b597bf018f34b92e78ea0711afb812208287 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 14 Dec 2013 19:18:57 +0100 Subject: don't compensate Z axis as an option Signed-off-by: Stanislaw Halik --- facetracknoir/ftnoir_curves.ui | 4 ++-- facetracknoir/tracker.cpp | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/ftnoir_curves.ui b/facetracknoir/ftnoir_curves.ui index 87c449ba..77df9a20 100644 --- a/facetracknoir/ftnoir_curves.ui +++ b/facetracknoir/ftnoir_curves.ui @@ -746,7 +746,7 @@ 10 140 - 211 + 291 81 @@ -782,7 +782,7 @@ - Reverse Z axis + Disable Z axis compensation diff --git a/facetracknoir/tracker.cpp b/facetracknoir/tracker.cpp index 0c5501d4..590d44bf 100644 --- a/facetracknoir/tracker.cpp +++ b/facetracknoir/tracker.cpp @@ -53,7 +53,6 @@ static void get_curve(double pos, double& out, THeadPoseDOF& axis) { static void t_compensate(double* input, double* output, bool rz) { - double z = rz ? -1 : 1; const auto H = input[Yaw] * M_PI / 180; const auto P = input[Pitch] * M_PI / 180; const auto B = input[Roll] * M_PI / 180; @@ -62,8 +61,8 @@ static void t_compensate(double* input, double* output, bool rz) const auto sinH = sin(H); const auto cosP = cos(P); const auto sinP = sin(P); - const auto cosB = cos(B * z); - const auto sinB = sin(B * z); + const auto cosB = cos(B); + const auto sinB = sin(B); double foo[] = { cosH * cosB - sinH * sinP * sinB, @@ -81,7 +80,9 @@ static void t_compensate(double* input, double* output, bool rz) const cv::Mat tvec(3, 1, CV_64F, input); cv::Mat ret = rmat * tvec; - for (int i = 0; i < 3; i++) + const int max = !rz ? 3 : 2; + + for (int i = 0; i < max; i++) output[i] = ret.at(i); } -- cgit v1.2.3 From a4fe36ce7b86fbc9527da067a14682b82ef62e7a Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 28 Dec 2013 00:38:55 +0100 Subject: major incompatible change: translation range in spline window --- facetracknoir/tracker.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/tracker.h b/facetracknoir/tracker.h index 02824206..987b5a24 100644 --- a/facetracknoir/tracker.h +++ b/facetracknoir/tracker.h @@ -94,9 +94,9 @@ public: THeadPoseDOF* axes[6]; HeadPoseData() { - axes[TX] = new THeadPoseDOF("tx","tx_alt", 100, 100, 100, 100); - axes[TY] = new THeadPoseDOF("ty","ty_alt", 100, 100, 100, 100); - axes[TZ] = new THeadPoseDOF("tz","tz_alt", 100, 100, 100, 100); + axes[TX] = new THeadPoseDOF("tx","tx_alt", 25, 100, 25, 100); + axes[TY] = new THeadPoseDOF("ty","ty_alt", 25, 100, 25, 100); + axes[TZ] = new THeadPoseDOF("tz","tz_alt", 25, 100, 25, 100); axes[Yaw] = new THeadPoseDOF("rx", "rx_alt", 180, 180, 180, 180); axes[Pitch] = new THeadPoseDOF("ry", "ry_alt", 90, 90, 90, 90); axes[Roll] = new THeadPoseDOF("rz", "rz_alt", 180, 180, 180, 180); -- cgit v1.2.3 From a7195519a25b715a5786383450a25f0420f7aeb5 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 30 Dec 2013 08:19:24 +0100 Subject: initial ng options impl, untested --- facetracknoir/options.hpp | 200 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 200 insertions(+) create mode 100644 facetracknoir/options.hpp (limited to 'facetracknoir') diff --git a/facetracknoir/options.hpp b/facetracknoir/options.hpp new file mode 100644 index 00000000..7db75941 --- /dev/null +++ b/facetracknoir/options.hpp @@ -0,0 +1,200 @@ +/* Copyright (c) 2013 Stanislaw Halik + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + */ + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace options { + template + inline T qcruft_to_t(const QVariant& t); + + template<> + inline int qcruft_to_t(const QVariant& t) + { + return t.toInt(); + } + + template<> + inline bool qcruft_to_t(const QVariant& t) + { + return t.toBool(); + } + + template<> + inline double qcruft_to_t(const QVariant& t) + { + return t.toDouble(); + } + + template<> + inline float qcruft_to_t(const QVariant& t) + { + return t.toFloat(); + } + + // snapshot of qsettings group at given time + class group { + private: + QMap map; + QString name; + public: + group(const QString& name, QSettings& s) : name(name) + { + s.beginGroup(name); + for (auto& k : s.childKeys()) + map[k] = s.value(k); + s.endGroup(); + } + static constexpr const char* org = "opentrack"; + void save() { + QSettings s(org); + s.beginGroup(name); + for (auto& k : map.keys()) + s.setValue(k, map[k]); + s.endGroup(); + } + template + T get(const QString& k) { + return qcruft_to_t(map.value(k)); + } + + void put(const QString& s, const QVariant& d) + { + map[s] = d; + } + }; + + class bundle { + private: + const QString group_name; + group saved; + group transient; + bundle(const bundle&) = delete; + bundle& operator=(const bundle&) = delete; + bool modified; + public: + bundle(const QString& group_name, QSettings& s) : + group_name(group_name), + saved(group_name, s), + transient(saved), + modified(false) + { + } + std::shared_ptr make(const QString& name, QSettings& s) { + assert(s.format() == QSettings::IniFormat); + return std::make_shared(name, s); + } + void store(QString& name, QVariant& datum) + { + modified = true; + transient.put(name, datum); + } + template + T get(QString& name) { + transient.get(name); + } + void save() + { + modified = false; + saved = transient; + transient.save(); + } + void revert() + { + modified = false; + transient = saved; + } + }; + + typedef std::shared_ptr pbundle; + + class QCruft : public QObject { + }; + + template + class value : public QCruft { + private: + const QString self_name; + pbundle b; + public: + value(const pbundle& b, const QString& name) : + self_name(name), + b(b) + { + } + operator T() { return b->get(self_name); } + T& operator=(const T& datum) { + b->store(self_name, datum); + emit valueChanged(datum); + return datum; + } + public slots: + void setValue(const T datum) { + this->operator =(datum); + } + signals: + void valueChanged(T datum); + }; + + template + inline void tie(value&, Q*); + + template<> + inline void tie(value& v, QComboBox* cb) + { + QObject::connect(cb, SIGNAL(currentIndexChanged(int)), &v, SLOT(setValue(int))); + QObject::connect(&v, SIGNAL(valueChanged(int)), &v, SLOT(setValue(int))); + } + + template<> + inline void tie(value& v, QComboBox* cb) + { + QObject::connect(cb, SIGNAL(currentTextChanged(QString)), &v, SLOT(setValue(QString))); + QObject::connect(&v, SIGNAL(valueChanged(QString)), &v, SLOT(setValue(QString))); + } + + template<> + inline void tie(value& v, QCheckBox* cb) + { + QObject::connect(cb, SIGNAL(toggled(bool)), &v, SLOT(setValue(bool))); + QObject::connect(&v, SIGNAL(valueChanged(bool)), cb, SLOT(setChecked(bool))); + } + + template<> + inline void tie(value& v, QDoubleSpinBox* dsb) + { + QObject::connect(dsb, SIGNAL(valueChanged(double)), &v, SLOT(setValue(double))); + QObject::connect(&v, SIGNAL(valueChanged(double)), dsb, SLOT(setValue(double))); + } + + template<> + inline void tie(value& v, QSpinBox* sb) + { + QObject::connect(sb, SIGNAL(valueChanged(int)), &v, SLOT(setValue(int))); + QObject::connect(&v, SIGNAL(valueChanged(int)), sb, SLOT(setValue(int))); + } + + template<> + inline void tie(value& v, QSlider* sl) + { + QObject::connect(sl, SIGNAL(valueChanged(int)), &v, SLOT(setValue(int))); + QObject::connect(&v, SIGNAL(valueChanged(int)), sl, SLOT(setValue(int))); + } +} -- cgit v1.2.3 From 40d5a72739ff9f650e05c3193a60a6bbcd2ea69c Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 30 Dec 2013 08:27:38 +0100 Subject: const correctness --- facetracknoir/options.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'facetracknoir') diff --git a/facetracknoir/options.hpp b/facetracknoir/options.hpp index 7db75941..ef3437ad 100644 --- a/facetracknoir/options.hpp +++ b/facetracknoir/options.hpp @@ -101,7 +101,7 @@ namespace options { assert(s.format() == QSettings::IniFormat); return std::make_shared(name, s); } - void store(QString& name, QVariant& datum) + void store(const QString& name, QVariant& datum) { modified = true; transient.put(name, datum); -- cgit v1.2.3 From 598a7ebfb4672ab96a5f0b8693cfab3d954ea6a6 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 30 Dec 2013 08:27:50 +0100 Subject: impl default value --- facetracknoir/options.hpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/options.hpp b/facetracknoir/options.hpp index ef3437ad..49367831 100644 --- a/facetracknoir/options.hpp +++ b/facetracknoir/options.hpp @@ -79,6 +79,10 @@ namespace options { { map[s] = d; } + bool contains(const QString& s) + { + return map.contains(s); + } }; class bundle { @@ -106,6 +110,10 @@ namespace options { modified = true; transient.put(name, datum); } + bool contains(const QString& name) + { + return transient.contains(name); + } template T get(QString& name) { transient.get(name); @@ -131,13 +139,18 @@ namespace options { template class value : public QCruft { private: - const QString self_name; + QString self_name; pbundle b; public: - value(const pbundle& b, const QString& name) : + value(const pbundle& b, const QString& name, T def) : self_name(name), b(b) { + if (!b->contains(name)) + { + QVariant cruft(def); + b->store(self_name, cruft); + } } operator T() { return b->get(self_name); } T& operator=(const T& datum) { -- cgit v1.2.3 From 6e16b672ac49db35d1d0365991de01831d29a0dc Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 30 Dec 2013 09:55:19 +0100 Subject: M-x valium-mode on Fix Qt's moronicity the hard way --- facetracknoir/options.hpp | 138 ++++++++++++++++++++++++++++------------------ 1 file changed, 83 insertions(+), 55 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/options.hpp b/facetracknoir/options.hpp index 49367831..16946e88 100644 --- a/facetracknoir/options.hpp +++ b/facetracknoir/options.hpp @@ -43,28 +43,31 @@ namespace options { return t.toDouble(); } - template<> - inline float qcruft_to_t(const QVariant& t) - { - return t.toFloat(); - } - // snapshot of qsettings group at given time class group { private: QMap map; QString name; public: - group(const QString& name, QSettings& s) : name(name) + group(const QString& name) : name(name) { - s.beginGroup(name); - for (auto& k : s.childKeys()) - map[k] = s.value(k); - s.endGroup(); + QSettings settings(group::org); + QString currentFile = + settings.value("SettingsFile", + QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); + QSettings iniFile(currentFile, QSettings::IniFormat); + iniFile.beginGroup(name); + for (auto& k : iniFile.childKeys()) + map[k] = iniFile.value(k); + iniFile.endGroup(); } static constexpr const char* org = "opentrack"; void save() { - QSettings s(org); + QSettings settings(group::org); + QString currentFile = + settings.value("SettingsFile", + QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); + QSettings s(currentFile, QSettings::IniFormat); s.beginGroup(name); for (auto& k : map.keys()) s.setValue(k, map[k]); @@ -85,27 +88,32 @@ namespace options { } }; - class bundle { + class impl_bundle { private: const QString group_name; group saved; group transient; - bundle(const bundle&) = delete; - bundle& operator=(const bundle&) = delete; + impl_bundle(const impl_bundle&) = delete; + impl_bundle& operator=(const impl_bundle&) = delete; bool modified; public: - bundle(const QString& group_name, QSettings& s) : + impl_bundle(const QString& group_name) : group_name(group_name), - saved(group_name, s), + saved(group_name), transient(saved), modified(false) { } - std::shared_ptr make(const QString& name, QSettings& s) { - assert(s.format() == QSettings::IniFormat); - return std::make_shared(name, s); + /* keep in mind doesn't fire signals */ + void reload() { + saved = group(group_name); + transient = saved; } - void store(const QString& name, QVariant& datum) + + std::shared_ptr make(const QString& name) { + return std::make_shared(name); + } + void store(const QString& name, const QVariant& datum) { modified = true; transient.put(name, datum); @@ -116,7 +124,7 @@ namespace options { } template T get(QString& name) { - transient.get(name); + return transient.get(name); } void save() { @@ -129,15 +137,32 @@ namespace options { modified = false; transient = saved; } + + bool modifiedp() const { return modified; } }; - typedef std::shared_ptr pbundle; + typedef std::shared_ptr pbundle; - class QCruft : public QObject { + class base_value : public QObject { + Q_OBJECT + public: + virtual QVariant operator=(const QVariant& datum) = 0; + public slots: +#define DEFINE_SLOT(t) void setValue(t datum) { this->operator=(datum); } + DEFINE_SLOT(double) + DEFINE_SLOT(int) + DEFINE_SLOT(QString) + DEFINE_SLOT(bool) + signals: +#define DEFINE_SIGNAL(t) void valueChanged(t); + DEFINE_SIGNAL(double) + DEFINE_SIGNAL(int) + DEFINE_SIGNAL(QString) + DEFINE_SIGNAL(bool) }; template - class value : public QCruft { + class value : public base_value { private: QString self_name; pbundle b; @@ -153,61 +178,64 @@ namespace options { } } operator T() { return b->get(self_name); } - T& operator=(const T& datum) { + QVariant operator=(const QVariant& datum) { b->store(self_name, datum); - emit valueChanged(datum); - return datum; - } - public slots: - void setValue(const T datum) { - this->operator =(datum); + switch (datum.type()) + { +#define BRANCH_ON(e, m) case QVariant::e: return valueChanged(datum.m()), datum + BRANCH_ON(Int, toInt); + BRANCH_ON(Double, toDouble); + BRANCH_ON(String, toString); + BRANCH_ON(Bool, toBool); + default: abort(); + } } - signals: - void valueChanged(T datum); }; template - inline void tie(value&, Q*); + inline void tie_setting(value&, Q*); template<> - inline void tie(value& v, QComboBox* cb) + inline void tie_setting(value& v, QComboBox* cb) { - QObject::connect(cb, SIGNAL(currentIndexChanged(int)), &v, SLOT(setValue(int))); - QObject::connect(&v, SIGNAL(valueChanged(int)), &v, SLOT(setValue(int))); + base_value::connect(cb, SIGNAL(currentIndexChanged(int)), &v, SLOT(setValue(int))); + base_value::connect(&v, SIGNAL(valueChanged(int)), cb, SLOT(setCurrentIndex(int))); + cb->setCurrentIndex(v); } template<> - inline void tie(value& v, QComboBox* cb) + inline void tie_setting(value& v, QCheckBox* cb) { - QObject::connect(cb, SIGNAL(currentTextChanged(QString)), &v, SLOT(setValue(QString))); - QObject::connect(&v, SIGNAL(valueChanged(QString)), &v, SLOT(setValue(QString))); + base_value::connect(cb, SIGNAL(toggled(bool)), &v, SLOT(setValue(bool))); + base_value::connect(&v, SIGNAL(valueChanged(bool)), cb, SLOT(setChecked(bool))); + cb->setChecked(v); } template<> - inline void tie(value& v, QCheckBox* cb) + inline void tie_setting(value& v, QDoubleSpinBox* dsb) { - QObject::connect(cb, SIGNAL(toggled(bool)), &v, SLOT(setValue(bool))); - QObject::connect(&v, SIGNAL(valueChanged(bool)), cb, SLOT(setChecked(bool))); + base_value::connect(dsb, SIGNAL(valueChanged(double)), &v, SLOT(setValue(double))); + base_value::connect(&v, SIGNAL(valueChanged(double)), dsb, SLOT(setValue(double))); + dsb->setValue(v); } template<> - inline void tie(value& v, QDoubleSpinBox* dsb) + inline void tie_setting(value& v, QSpinBox* sb) { - QObject::connect(dsb, SIGNAL(valueChanged(double)), &v, SLOT(setValue(double))); - QObject::connect(&v, SIGNAL(valueChanged(double)), dsb, SLOT(setValue(double))); + base_value::connect(sb, SIGNAL(valueChanged(int)), &v, SLOT(setValue(int))); + base_value::connect(&v, SIGNAL(valueChanged(int)), sb, SLOT(setValue(int))); + sb->setValue(v); } template<> - inline void tie(value& v, QSpinBox* sb) + inline void tie_setting(value& v, QSlider* sl) { - QObject::connect(sb, SIGNAL(valueChanged(int)), &v, SLOT(setValue(int))); - QObject::connect(&v, SIGNAL(valueChanged(int)), sb, SLOT(setValue(int))); + base_value::connect(sl, SIGNAL(valueChanged(int)), &v, SLOT(setValue(int))); + base_value::connect(&v, SIGNAL(valueChanged(int)), sl, SLOT(setValue(int))); + sl->setValue(v); } - template<> - inline void tie(value& v, QSlider* sl) - { - QObject::connect(sl, SIGNAL(valueChanged(int)), &v, SLOT(setValue(int))); - QObject::connect(&v, SIGNAL(valueChanged(int)), sl, SLOT(setValue(int))); + inline pbundle bundle(const QString& group) { + return std::make_shared(group); } } -- cgit v1.2.3 From eaeb86205a04a2159de3e55fb7105195962249db Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 30 Dec 2013 10:58:26 +0100 Subject: don't mark as dirty by accident --- facetracknoir/options.hpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/options.hpp b/facetracknoir/options.hpp index 16946e88..67c0958d 100644 --- a/facetracknoir/options.hpp +++ b/facetracknoir/options.hpp @@ -43,6 +43,12 @@ namespace options { return t.toDouble(); } + template<> + inline QVariant qcruft_to_t(const QVariant& t) + { + return t; + } + // snapshot of qsettings group at given time class group { private: @@ -115,8 +121,11 @@ namespace options { } void store(const QString& name, const QVariant& datum) { - modified = true; - transient.put(name, datum); + if (!transient.contains(name) || datum != transient.get(name)) + { + modified = true; + transient.put(name, datum); + } } bool contains(const QString& name) { -- cgit v1.2.3 From d93d2a4f373f79e86e855c43815edf26cc455e3d Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 30 Dec 2013 11:29:28 +0100 Subject: support QLineEdit --- facetracknoir/options.hpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'facetracknoir') diff --git a/facetracknoir/options.hpp b/facetracknoir/options.hpp index 67c0958d..c9a982bc 100644 --- a/facetracknoir/options.hpp +++ b/facetracknoir/options.hpp @@ -20,10 +20,11 @@ #include #include #include +#include namespace options { template - inline T qcruft_to_t(const QVariant& t); + inline T qcruft_to_t (const QVariant& t); template<> inline int qcruft_to_t(const QVariant& t) @@ -31,6 +32,12 @@ namespace options { return t.toInt(); } + template<> + inline QString qcruft_to_t(const QVariant& t) + { + return t.toString(); + } + template<> inline bool qcruft_to_t(const QVariant& t) { @@ -244,6 +251,14 @@ namespace options { sl->setValue(v); } + template<> + inline void tie_setting(value& v, QLineEdit* le) + { + base_value::connect(le, SIGNAL(textChanged(QString)), &v, SLOT(setValue(QString))); + base_value::connect(&v, SIGNAL(valueChanged(QString)),le, SLOT(setText(QString))); + le->setText(v); + } + inline pbundle bundle(const QString& group) { return std::make_shared(group); } -- cgit v1.2.3 From 76c48c14b4f5f5b22532016b5963e600fbebb610 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 30 Dec 2013 12:56:11 +0100 Subject: add option of tying combobox to its text value --- facetracknoir/options.hpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'facetracknoir') diff --git a/facetracknoir/options.hpp b/facetracknoir/options.hpp index c9a982bc..900f06c0 100644 --- a/facetracknoir/options.hpp +++ b/facetracknoir/options.hpp @@ -183,7 +183,7 @@ namespace options { QString self_name; pbundle b; public: - value(const pbundle& b, const QString& name, T def) : + value(pbundle& b, const QString& name, T def) : self_name(name), b(b) { @@ -219,6 +219,14 @@ namespace options { cb->setCurrentIndex(v); } + template<> + inline void tie_setting(value& v, QComboBox* cb) + { + base_value::connect(cb, SIGNAL(currentTextChanged(QString)), &v, SLOT(setValue(int))); + base_value::connect(&v, SIGNAL(valueChanged(QString)), cb, SLOT(setCurrentText(QString))); + cb->setCurrentText(v); + } + template<> inline void tie_setting(value& v, QCheckBox* cb) { -- cgit v1.2.3 From 904add389667ff9d97cde3930a881fae89c3fb50 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 31 Dec 2013 08:40:02 +0100 Subject: options: fix some bugs --- facetracknoir/options.hpp | 96 +++++++++++++++++++++++++++++++---------------- 1 file changed, 63 insertions(+), 33 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/options.hpp b/facetracknoir/options.hpp index 900f06c0..1305bd0a 100644 --- a/facetracknoir/options.hpp +++ b/facetracknoir/options.hpp @@ -7,11 +7,13 @@ #pragma once -#include +#include #include #include #include #include +#include +#include #include #include #include @@ -21,6 +23,13 @@ #include #include #include +#include + +#ifdef __GNUC__ +# define ov override +#else +# define ov +#endif namespace options { template @@ -101,8 +110,10 @@ namespace options { } }; - class impl_bundle { + class impl_bundle : public QObject { + Q_OBJECT private: + QMutex mtx; const QString group_name; group saved; group transient; @@ -111,6 +122,7 @@ namespace options { bool modified; public: impl_bundle(const QString& group_name) : + mtx(QMutex::Recursive), group_name(group_name), saved(group_name), transient(saved), @@ -119,8 +131,10 @@ namespace options { } /* keep in mind doesn't fire signals */ void reload() { + QMutexLocker l(&mtx); saved = group(group_name); transient = saved; + emit reloaded(); } std::shared_ptr make(const QString& name) { @@ -128,33 +142,46 @@ namespace options { } void store(const QString& name, const QVariant& datum) { + QMutexLocker l(&mtx); if (!transient.contains(name) || datum != transient.get(name)) { modified = true; transient.put(name, datum); + emit bundleChanged(); } } bool contains(const QString& name) { + QMutexLocker l(&mtx); return transient.contains(name); } template - T get(QString& name) { + T get(const QString& name) { + QMutexLocker l(&mtx); return transient.get(name); } void save() { + QMutexLocker l(&mtx); modified = false; saved = transient; transient.save(); } void revert() { + QMutexLocker l(&mtx); modified = false; transient = saved; + emit bundleChanged(); } - bool modifiedp() const { return modified; } + bool modifiedp() { + QMutexLocker l(&mtx); + return modified; + } + signals: + void bundleChanged(); + void reloaded(); }; typedef std::shared_ptr pbundle; @@ -162,7 +189,18 @@ namespace options { class base_value : public QObject { Q_OBJECT public: + base_value(pbundle b, const QString& name) : b(b), self_name(name) { + connect(b.get(), SIGNAL(reloaded()), this, SLOT(reread_value())); + } virtual QVariant operator=(const QVariant& datum) = 0; + protected: + pbundle b; + QString self_name; + public slots: + void reread_value() + { + this->operator=(b->get(self_name)); + } public slots: #define DEFINE_SLOT(t) void setValue(t datum) { this->operator=(datum); } DEFINE_SLOT(double) @@ -179,13 +217,11 @@ namespace options { template class value : public base_value { - private: - QString self_name; - pbundle b; + private: T def; public: - value(pbundle& b, const QString& name, T def) : - self_name(name), - b(b) + static constexpr const Qt::ConnectionType CONNTYPE = Qt::QueuedConnection; + value(pbundle b, const QString& name, T def) : + base_value(b, name), def(def) { if (!b->contains(name)) { @@ -196,15 +232,9 @@ namespace options { operator T() { return b->get(self_name); } QVariant operator=(const QVariant& datum) { b->store(self_name, datum); - switch (datum.type()) - { -#define BRANCH_ON(e, m) case QVariant::e: return valueChanged(datum.m()), datum - BRANCH_ON(Int, toInt); - BRANCH_ON(Double, toDouble); - BRANCH_ON(String, toString); - BRANCH_ON(Bool, toBool); - default: abort(); - } + auto foo = qcruft_to_t(datum); + emit valueChanged(foo); + return datum; } }; @@ -214,56 +244,56 @@ namespace options { template<> inline void tie_setting(value& v, QComboBox* cb) { - base_value::connect(cb, SIGNAL(currentIndexChanged(int)), &v, SLOT(setValue(int))); - base_value::connect(&v, SIGNAL(valueChanged(int)), cb, SLOT(setCurrentIndex(int))); + base_value::connect(cb, SIGNAL(currentIndexChanged(int)), &v, SLOT(setValue(int)), v.CONNTYPE); + base_value::connect(&v, SIGNAL(valueChanged(int)), cb, SLOT(setCurrentIndex(int)), v.CONNTYPE); cb->setCurrentIndex(v); } template<> inline void tie_setting(value& v, QComboBox* cb) { - base_value::connect(cb, SIGNAL(currentTextChanged(QString)), &v, SLOT(setValue(int))); - base_value::connect(&v, SIGNAL(valueChanged(QString)), cb, SLOT(setCurrentText(QString))); + base_value::connect(cb, SIGNAL(currentTextChanged(QString)), &v, SLOT(setValue(QString)), v.CONNTYPE); + base_value::connect(&v, SIGNAL(valueChanged(QString)), cb, SLOT(setCurrentText(QString)), v.CONNTYPE); cb->setCurrentText(v); } template<> inline void tie_setting(value& v, QCheckBox* cb) { - base_value::connect(cb, SIGNAL(toggled(bool)), &v, SLOT(setValue(bool))); - base_value::connect(&v, SIGNAL(valueChanged(bool)), cb, SLOT(setChecked(bool))); + base_value::connect(cb, SIGNAL(toggled(bool)), &v, SLOT(setValue(bool)), v.CONNTYPE); + base_value::connect(&v, SIGNAL(valueChanged(bool)), cb, SLOT(setChecked(bool)), v.CONNTYPE); cb->setChecked(v); } template<> inline void tie_setting(value& v, QDoubleSpinBox* dsb) { - base_value::connect(dsb, SIGNAL(valueChanged(double)), &v, SLOT(setValue(double))); - base_value::connect(&v, SIGNAL(valueChanged(double)), dsb, SLOT(setValue(double))); + base_value::connect(dsb, SIGNAL(valueChanged(double)), &v, SLOT(setValue(double)), v.CONNTYPE); + base_value::connect(&v, SIGNAL(valueChanged(double)), dsb, SLOT(setValue(double)), v.CONNTYPE); dsb->setValue(v); } template<> inline void tie_setting(value& v, QSpinBox* sb) { - base_value::connect(sb, SIGNAL(valueChanged(int)), &v, SLOT(setValue(int))); - base_value::connect(&v, SIGNAL(valueChanged(int)), sb, SLOT(setValue(int))); + base_value::connect(sb, SIGNAL(valueChanged(int)), &v, SLOT(setValue(int)), v.CONNTYPE); + base_value::connect(&v, SIGNAL(valueChanged(int)), sb, SLOT(setValue(int)), v.CONNTYPE); sb->setValue(v); } template<> inline void tie_setting(value& v, QSlider* sl) { - base_value::connect(sl, SIGNAL(valueChanged(int)), &v, SLOT(setValue(int))); - base_value::connect(&v, SIGNAL(valueChanged(int)), sl, SLOT(setValue(int))); + base_value::connect(sl, SIGNAL(valueChanged(int)), &v, SLOT(setValue(int)), v.CONNTYPE); + base_value::connect(&v, SIGNAL(valueChanged(int)), sl, SLOT(setValue(int)), v.CONNTYPE); sl->setValue(v); } template<> inline void tie_setting(value& v, QLineEdit* le) { - base_value::connect(le, SIGNAL(textChanged(QString)), &v, SLOT(setValue(QString))); - base_value::connect(&v, SIGNAL(valueChanged(QString)),le, SLOT(setText(QString))); + base_value::connect(le, SIGNAL(textChanged(QString)), &v, SLOT(setValue(QString)), v.CONNTYPE); + base_value::connect(&v, SIGNAL(valueChanged(QString)),le, SLOT(setText(QString)), v.CONNTYPE); le->setText(v); } -- cgit v1.2.3 From 54892e5f6a15c1ce0aba364039174eda3d1a6b8b Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 31 Dec 2013 08:40:27 +0100 Subject: main: use settings framework --- facetracknoir/curve-config.cpp | 161 +++--------- facetracknoir/facetracknoir.cpp | 397 ++++++++++-------------------- facetracknoir/facetracknoir.h | 38 +-- facetracknoir/ftnoir_curves.ui | 4 +- facetracknoir/ftnoir_keyboardshortcuts.ui | 53 +--- facetracknoir/main.cpp | 7 +- facetracknoir/shortcuts.cpp | 148 ++--------- facetracknoir/shortcuts.h | 9 +- facetracknoir/tracker.cpp | 25 +- facetracknoir/tracker.h | 51 ++-- 10 files changed, 224 insertions(+), 669 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/curve-config.cpp b/facetracknoir/curve-config.cpp index 2e731892..4b07a165 100644 --- a/facetracknoir/curve-config.cpp +++ b/facetracknoir/curve-config.cpp @@ -14,7 +14,23 @@ CurveConfigurationDialog::CurveConfigurationDialog(FaceTrackNoIR *ftnoir, QWidge // Connect Qt signals to member-functions connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); - connect(ui.checkBox, SIGNAL(stateChanged(int)), this, SLOT(curveChanged(int))); + + tie_setting(mainApp->s.a_x.altp, ui.tx_altp); + tie_setting(mainApp->s.a_y.altp, ui.ty_altp); + tie_setting(mainApp->s.a_z.altp, ui.tz_altp); + tie_setting(mainApp->s.a_yaw.altp, ui.rx_altp); + tie_setting(mainApp->s.a_pitch.altp, ui.ry_altp); + tie_setting(mainApp->s.a_roll.altp, ui.rz_altp); + + tie_setting(mainApp->s.tcomp_p, ui.tcomp_enable); + tie_setting(mainApp->s.tcomp_tz, ui.tcomp_rz); + + tie_setting(mainApp->s.a_x.zero, ui.pos_tx); + tie_setting(mainApp->s.a_y.zero, ui.pos_ty); + tie_setting(mainApp->s.a_z.zero, ui.pos_tz); + tie_setting(mainApp->s.a_yaw.zero, ui.pos_rx); + tie_setting(mainApp->s.a_pitch.zero, ui.pos_ry); + tie_setting(mainApp->s.a_roll.zero, ui.pos_rz); // Load the settings from the current .INI-file loadSettings(); @@ -47,7 +63,7 @@ void CurveConfigurationDialog::doCancel() { // // Ask if changed Settings should be saved // - if (settingsDirty) { + if (settingsDirty || mainApp->s.b->modifiedp()) { int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard ); qDebug() << "doCancel says: answer =" << ret; @@ -58,6 +74,7 @@ void CurveConfigurationDialog::doCancel() { this->close(); break; case QMessageBox::Discard: + mainApp->s.b->revert(); this->close(); break; case QMessageBox::Cancel: @@ -77,67 +94,6 @@ void CurveConfigurationDialog::doCancel() { // Load the current Settings from the currently 'active' INI-file. // void CurveConfigurationDialog::loadSettings() { - qDebug() << "CurveConfigurationDialog::loadSettings says: Starting "; - QSettings settings("opentrack"); // 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() << "CurveConfigurationDialog::loadSettings says: iniFile = " << currentFile; - - static const char* names[] = { - "tx_alt", - "ty_alt", - "tz_alt", - "rx_alt", - "ry_alt", - "rz_alt" - }; - - iniFile.beginGroup("Tracking"); - - ui.tcomp_rz->setChecked(iniFile.value("tcomp-rz", false).toBool()); - ui.checkBox->setChecked(iniFile.value("compensate", true).toBool()); - - for (int i = 0; i < 6; i++) - mainApp->axis(i).altp = iniFile.value(names[i], false).toBool(); - - QCheckBox* widgets[] = { - ui.tx_altp, - ui.ty_altp, - ui.tz_altp, - ui.rx_altp, - ui.ry_altp, - ui.rz_altp - }; - - for (int i = 0; i < 6; i++) - widgets[i]->setChecked(mainApp->axis(i).altp); - - QDoubleSpinBox* widgets2[] = { - ui.pos_tx, - ui.pos_ty, - ui.pos_tz, - ui.pos_tx, - ui.pos_ry, - ui.pos_rz - }; - - const char* names2[] = { - "zero_tx", - "zero_ty", - "zero_tz", - "zero_rx", - "zero_ry", - "zero_rz" - }; - - - for (int i = 0; i < 6; i++) - widgets2[i]->setValue(iniFile.value(names2[i], 0).toDouble()); - - iniFile.endGroup(); - QFunctionConfigurator* configs[6] = { ui.txconfig, ui.tyconfig, @@ -156,23 +112,10 @@ void CurveConfigurationDialog::loadSettings() { ui.rzconfig_alt }; - QCheckBox* checkboxes[6] = { - ui.rx_altp, - ui.ry_altp, - ui.rz_altp, - ui.tx_altp, - ui.ty_altp, - ui.tz_altp - }; - - QDoubleSpinBox* widgets3[] = { - ui.pos_tx, - ui.pos_ty, - ui.pos_tz, - ui.pos_tx, - ui.pos_ry, - ui.pos_rz - }; + QSettings settings("opentrack"); + QString currentFile = settings.value("SettingsFile", + QCoreApplication::applicationDirPath() + "/settings/default.ini" ) + .toString(); for (int i = 0; i < 6; i++) { @@ -182,8 +125,6 @@ void CurveConfigurationDialog::loadSettings() { alt_configs[i]->loadSettings(currentFile); connect(configs[i], SIGNAL(CurveChanged(bool)), this, SLOT(curveChanged(bool)), Qt::UniqueConnection); connect(alt_configs[i], SIGNAL(CurveChanged(bool)), this, SLOT(curveChanged(bool)), Qt::UniqueConnection); - connect(checkboxes[i], SIGNAL(stateChanged(int)), this, SLOT(curveChanged(int)), Qt::UniqueConnection); - mainApp->axis(i).zero = widgets3[i]->value(); } settingsDirty = false; @@ -196,9 +137,11 @@ void CurveConfigurationDialog::save() { qDebug() << "save() says: started"; - QSettings settings("opentrack"); // Registry settings (in HK_USER) - - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); + QSettings settings("opentrack"); + QString currentFile = + settings.value("SettingsFile", + QCoreApplication::applicationDirPath() + "/settings/default.ini" ) + .toString(); ui.rxconfig->saveSettings(currentFile); ui.ryconfig->saveSettings(currentFile); @@ -214,53 +157,5 @@ void CurveConfigurationDialog::save() { ui.ryconfig_alt->saveSettings(currentFile); ui.rzconfig_alt->saveSettings(currentFile); - bool tcomp_rz = false, compensate = true; - - QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) - - iniFile.beginGroup("Tracking"); - - iniFile.setValue("tcomp-rz", tcomp_rz = ui.tcomp_rz->checkState() != Qt::Unchecked); - iniFile.setValue("compensate", compensate = (bool) !!ui.checkBox->isChecked()); - - if (mainApp->tracker) - { - mainApp->tracker->compensate = compensate; - mainApp->tracker->tcomp_rz = tcomp_rz; - } - - iniFile.setValue("rx_alt", ui.rx_altp->checkState() != Qt::Unchecked); - iniFile.setValue("ry_alt", ui.ry_altp->checkState() != Qt::Unchecked); - iniFile.setValue("rz_alt", ui.rz_altp->checkState() != Qt::Unchecked); - iniFile.setValue("tx_alt", ui.tx_altp->checkState() != Qt::Unchecked); - iniFile.setValue("ty_alt", ui.ty_altp->checkState() != Qt::Unchecked); - iniFile.setValue("tz_alt", ui.tz_altp->checkState() != Qt::Unchecked); - - QDoubleSpinBox* widgets2[] = { - ui.pos_tx, - ui.pos_ty, - ui.pos_tz, - ui.pos_tx, - ui.pos_ry, - ui.pos_rz - }; - - const char* names2[] = { - "zero_tx", - "zero_ty", - "zero_tz", - "zero_rx", - "zero_ry", - "zero_rz" - }; - - for (int i = 0; i < 6; i++) - { - iniFile.setValue(names2[i], widgets2[i]->value()); - mainApp->axis(i).zero = widgets2[i]->value(); - } - - iniFile.endGroup(); - settingsDirty = false; } diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index 75ac737d..b98c6085 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -95,6 +95,9 @@ FaceTrackNoIR::FaceTrackNoIR(QWidget *parent) : keyCenter(this), keyToggle(this), #endif + b(bundle("opentrack-ui")), + s(b), + pose(std::vector{&s.a_x, &s.a_y, &s.a_z, &s.a_yaw, &s.a_pitch, &s.a_roll}), timUpdateHeadPose(this), pTrackerDialog(NULL), pSecondTrackerDialog(NULL), @@ -111,6 +114,16 @@ FaceTrackNoIR::FaceTrackNoIR(QWidget *parent) : tracker = 0; + CurveConfigurationDialog* ccd; + + if (!_curve_config) + { + ccd = new CurveConfigurationDialog( this, this ); + _curve_config = ccd; + } else { + ccd = dynamic_cast(_curve_config); + } + QDir::setCurrent(QCoreApplication::applicationDirPath()); connect(ui.btnLoad, SIGNAL(clicked()), this, SLOT(open())); @@ -124,18 +137,6 @@ FaceTrackNoIR::FaceTrackNoIR(QWidget *parent) : connect(ui.btnShowServerControls, SIGNAL(clicked()), this, SLOT(showServerControls())); connect(ui.btnShowFilterControls, SIGNAL(clicked()), this, SLOT(showFilterControls())); - connect(ui.chkInvertYaw, SIGNAL(stateChanged(int)), this, SLOT(setInvertYaw(int))); - connect(ui.chkInvertRoll, SIGNAL(stateChanged(int)), this, SLOT(setInvertRoll(int))); - connect(ui.chkInvertPitch, SIGNAL(stateChanged(int)), this, SLOT(setInvertPitch(int))); - connect(ui.chkInvertX, SIGNAL(stateChanged(int)), this, SLOT(setInvertX(int))); - connect(ui.chkInvertY, SIGNAL(stateChanged(int)), this, SLOT(setInvertY(int))); - connect(ui.chkInvertZ, SIGNAL(stateChanged(int)), this, SLOT(setInvertZ(int))); - - connect(ui.btnStartTracker, SIGNAL(clicked()), this, SLOT(startTracker())); - connect(ui.btnStopTracker, SIGNAL(clicked()), this, SLOT(stopTracker())); - - GetCameraNameDX(); - ui.cbxSecondTrackerSource->addItem(QIcon(), "None"); dlopen_filters.push_back((DynamicLibrary*) NULL); ui.iconcomboFilter->addItem(QIcon(), "None"); @@ -144,11 +145,25 @@ FaceTrackNoIR::FaceTrackNoIR(QWidget *parent) : fill_combobox("opentrack-tracker-*.", dlopen_trackers, ui.iconcomboTrackerSource, ui.cbxSecondTrackerSource); fill_combobox("opentrack-filter-*.", dlopen_filters, ui.iconcomboFilter, NULL); + tie_setting(s.a_yaw.invert, ui.chkInvertYaw); + tie_setting(s.a_pitch.invert, ui.chkInvertPitch); + tie_setting(s.a_roll.invert, ui.chkInvertRoll); + tie_setting(s.a_x.invert, ui.chkInvertX); + tie_setting(s.a_y.invert, ui.chkInvertY); + tie_setting(s.a_z.invert, ui.chkInvertZ); + tie_setting(s.tracker_dll, ui.iconcomboTrackerSource); + tie_setting(s.tracker2_dll, ui.cbxSecondTrackerSource); + tie_setting(s.protocol_dll, ui.iconcomboProtocol); + tie_setting(s.filter_dll, ui.iconcomboFilter); + + connect(ui.btnStartTracker, SIGNAL(clicked()), this, SLOT(startTracker())); + connect(ui.btnStopTracker, SIGNAL(clicked()), this, SLOT(stopTracker())); + + GetCameraNameDX(); + connect(ui.iconcomboProfile, SIGNAL(currentIndexChanged(int)), this, SLOT(profileSelected(int))); connect(&timUpdateHeadPose, SIGNAL(timeout()), this, SLOT(showHeadPose())); - loadSettings(); - #ifndef _WIN32 connect(&keyCenter, SIGNAL(activated()), this, SLOT(shortcutRecentered())); connect(&keyToggle, SIGNAL(activated()), this, SLOT(shortcutToggled())); @@ -156,6 +171,8 @@ FaceTrackNoIR::FaceTrackNoIR(QWidget *parent) : connect(&kbd_quit, SIGNAL(activated()), this, SLOT(exit())); kbd_quit.setEnabled(true); + + fill_profile_cbx(); } FaceTrackNoIR::~FaceTrackNoIR() { @@ -250,45 +267,14 @@ void FaceTrackNoIR::open() { } void FaceTrackNoIR::save() { - QSettings settings("opentrack"); + b->save(); - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); - QSettings iniFile( currentFile, QSettings::IniFormat ); - - iniFile.beginGroup ( "Tracking" ); - - iniFile.setValue ( "invertYaw", ui.chkInvertYaw->isChecked() ); - iniFile.setValue ( "invertPitch", ui.chkInvertPitch->isChecked() ); - iniFile.setValue ( "invertRoll", ui.chkInvertRoll->isChecked() ); - iniFile.setValue ( "invertX", ui.chkInvertX->isChecked() ); - iniFile.setValue ( "invertY", ui.chkInvertY->isChecked() ); - iniFile.setValue ( "invertZ", ui.chkInvertZ->isChecked() ); - iniFile.endGroup (); - - iniFile.beginGroup ( "GameProtocol" ); - { - DynamicLibrary* proto = dlopen_protocols.value( ui.iconcomboProtocol->currentIndex(), (DynamicLibrary*) NULL); - iniFile.setValue ( "DLL", proto == NULL ? "" : proto->filename); - } - iniFile.endGroup (); - - iniFile.beginGroup ( "TrackerSource" ); - { - DynamicLibrary* tracker = dlopen_trackers.value( ui.iconcomboTrackerSource->currentIndex(), (DynamicLibrary*) NULL); - iniFile.setValue ( "DLL", tracker == NULL ? "" : tracker->filename); - } - { - DynamicLibrary* tracker = dlopen_trackers.value( ui.cbxSecondTrackerSource->currentIndex() - 1, (DynamicLibrary*) NULL); - iniFile.setValue ( "2ndDLL", tracker == NULL ? "" : tracker->filename); - } - iniFile.endGroup (); + QSettings settings("opentrack"); - iniFile.beginGroup ( "Filter" ); - { - DynamicLibrary* filter = dlopen_filters.value( ui.iconcomboFilter->currentIndex(), (DynamicLibrary*) NULL); - iniFile.setValue ( "DLL", filter == NULL ? "" : filter->filename); - } - iniFile.endGroup (); + QString currentFile = + settings.value("SettingsFile", + QCoreApplication::applicationDirPath() + "/settings/default.ini") + .toString(); #if defined(__unix) || defined(__linux) QByteArray bytes = QFile::encodeName(currentFile); @@ -308,8 +294,7 @@ void FaceTrackNoIR::saveAs() QString fileName = QFileDialog::getSaveFileName(this, tr("Save file"), oldFile, -// QCoreApplication::applicationDirPath() + "/settings", - tr("Settings file (*.ini);;All Files (*)")); + tr("Settings file (*.ini);;All Files (*)")); if (!fileName.isEmpty()) { QFileInfo newFileInfo ( fileName ); @@ -325,117 +310,40 @@ void FaceTrackNoIR::saveAs() } settings.setValue ("SettingsFile", fileName); - save(); - - loadSettings(); - } + save(); + } } void FaceTrackNoIR::loadSettings() { - if (looping) - return; - looping = true; - qDebug() << "loadSettings says: Starting "; - QSettings settings("opentrack"); - - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); - qDebug() << "Config file now" << currentFile; - QSettings iniFile( currentFile, QSettings::IniFormat ); - - QFileInfo pathInfo ( currentFile ); - setWindowTitle(QString( OPENTRACK_VERSION " :: ") + pathInfo.fileName()); - - QDir settingsDir( pathInfo.dir() ); - QStringList filters; - filters << "*.ini"; - iniFileList.clear(); - iniFileList = settingsDir.entryList( filters, QDir::Files, QDir::Name ); - - ui.iconcomboProfile->clear(); - for ( int i = 0; i < iniFileList.size(); i++) { - ui.iconcomboProfile->addItem(QIcon(":/images/settings16.png"), iniFileList.at(i)); - if (iniFileList.at(i) == pathInfo.fileName()) { - ui.iconcomboProfile->setItemIcon(i, QIcon(":/images/settingsopen16.png")); - ui.iconcomboProfile->setCurrentIndex( i ); - } - } - - qDebug() << "loadSettings says: iniFile = " << currentFile; - - iniFile.beginGroup ( "Tracking" ); - ui.chkInvertYaw->setChecked (iniFile.value ( "invertYaw", 0 ).toBool()); - ui.chkInvertPitch->setChecked (iniFile.value ( "invertPitch", 0 ).toBool()); - ui.chkInvertRoll->setChecked (iniFile.value ( "invertRoll", 0 ).toBool()); - ui.chkInvertX->setChecked (iniFile.value ( "invertX", 0 ).toBool()); - ui.chkInvertY->setChecked (iniFile.value ( "invertY", 0 ).toBool()); - ui.chkInvertZ->setChecked (iniFile.value ( "invertZ", 0 ).toBool()); - iniFile.endGroup (); - - iniFile.beginGroup ( "GameProtocol" ); - QString selectedProtocolName = iniFile.value ( "DLL", "" ).toString(); - iniFile.endGroup (); - - for ( int i = 0; i < dlopen_protocols.size(); i++) { - if (dlopen_protocols.at(i)->filename.compare( selectedProtocolName, Qt::CaseInsensitive ) == 0) { - ui.iconcomboProtocol->setCurrentIndex( i ); - break; - } - } - - iniFile.beginGroup ( "TrackerSource" ); - QString selectedTrackerName = iniFile.value ( "DLL", "" ).toString(); - qDebug() << "loadSettings says: selectedTrackerName = " << selectedTrackerName; - QString secondTrackerName = iniFile.value ( "2ndDLL", "None" ).toString(); - qDebug() << "loadSettings says: secondTrackerName = " << secondTrackerName; - iniFile.endGroup (); - - for ( int i = 0; i < dlopen_trackers.size(); i++) { - DynamicLibrary* foo = dlopen_trackers.at(i); - if (foo && foo->filename.compare( selectedTrackerName, Qt::CaseInsensitive ) == 0) { - ui.iconcomboTrackerSource->setCurrentIndex( i ); - } - if (foo && foo->filename.compare( secondTrackerName, Qt::CaseInsensitive ) == 0) { - ui.cbxSecondTrackerSource->setCurrentIndex( i + 1 ); - } - } - - iniFile.beginGroup ( "Filter" ); - QString selectedFilterName = iniFile.value ( "DLL", "" ).toString(); - qDebug() << "createIconGroupBox says: selectedFilterName = " << selectedFilterName; - iniFile.endGroup (); - - for ( int i = 0; i < dlopen_filters.size(); i++) { - DynamicLibrary* foo = dlopen_filters.at(i); - if (foo && foo->filename.compare( selectedFilterName, Qt::CaseInsensitive ) == 0) { - ui.iconcomboFilter->setCurrentIndex( i ); - break; - } - } - - CurveConfigurationDialog* ccd; - - if (!_curve_config) - { - ccd = new CurveConfigurationDialog( this, this ); - _curve_config = ccd; - } else { - ccd = dynamic_cast(_curve_config); - } - - ccd->loadSettings(); + b->reload(); + (dynamic_cast(_curve_config))->loadSettings(); +} - looping = false; +void FaceTrackNoIR::updateButtonState(bool running) +{ + bool e = !running; + ui.iconcomboProfile->setEnabled ( e ); + ui.btnLoad->setEnabled ( e ); + ui.btnSaveAs->setEnabled ( e ); + ui.btnShowFilterControls->setEnabled ( e ); + ui.btnStartTracker->setEnabled ( e ); + ui.btnStopTracker->setEnabled ( running ); + + ui.iconcomboTrackerSource->setEnabled ( e ); + ui.cbxSecondTrackerSource->setEnabled ( e ); + ui.iconcomboProtocol->setEnabled ( e ); + ui.btnShowServerControls->setEnabled ( e ); + ui.iconcomboFilter->setEnabled ( e ); + + ui.btnStartTracker->setEnabled(e); + ui.btnStopTracker->setEnabled(running); } -void FaceTrackNoIR::startTracker( ) { +void FaceTrackNoIR::startTracker( ) { + b->save(); + loadSettings(); bindKeyboardShortcuts(); - ui.iconcomboProfile->setEnabled ( false ); - ui.btnLoad->setEnabled ( false ); - ui.btnSave->setEnabled ( false ); - ui.btnSaveAs->setEnabled ( false ); - ui.btnShowFilterControls->setEnabled ( true ); - if (Libraries) delete Libraries; Libraries = new SelectedLibraries(this); @@ -457,54 +365,19 @@ void FaceTrackNoIR::startTracker( ) { delete tracker; } - QSettings settings("opentrack"); - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); - QSettings iniFile( currentFile, QSettings::IniFormat ); - - for (int i = 0; i < 6; i++) { - axis(i).curve.loadSettings(iniFile); - axis(i).curveAlt.loadSettings(iniFile); - } + QSettings settings("opentrack"); + QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); + QSettings iniFile( currentFile, QSettings::IniFormat ); - static const char* names[] = { - "tx_alt", - "ty_alt", - "tz_alt", - "rx_alt", - "ry_alt", - "rz_alt", - }; - - static const char* invert_names[] = { - "invertX", - "invertY", - "invertZ", - "invertYaw", - "invertPitch", - "invertRoll" - }; - - iniFile.beginGroup("Tracking"); - - for (int i = 0; i < 6; i++) { - axis(i).altp = iniFile.value(names[i], false).toBool(); - axis(i).invert = iniFile.value(invert_names[i], false).toBool() ? 1 : -1; + for (int i = 0; i < 6; i++) + { + axis(i).curve.loadSettings(iniFile); + axis(i).curveAlt.loadSettings(iniFile); + } } - tracker = new Tracker ( this ); - - tracker->compensate = iniFile.value("compensate", true).toBool(); - tracker->tcomp_rz = iniFile.value("tcomp-rz", false).toBool(); - - iniFile.endGroup(); - - tracker->setInvertAxis(Yaw, ui.chkInvertYaw->isChecked() ); - tracker->setInvertAxis(Pitch, ui.chkInvertPitch->isChecked() ); - tracker->setInvertAxis(Roll, ui.chkInvertRoll->isChecked() ); - tracker->setInvertAxis(TX, ui.chkInvertX->isChecked() ); - tracker->setInvertAxis(TY, ui.chkInvertY->isChecked() ); - tracker->setInvertAxis(TZ, ui.chkInvertZ->isChecked() ); + tracker = new Tracker ( this, s ); if (pTrackerDialog && Libraries->pTracker) { pTrackerDialog->registerTracker( Libraries->pTracker ); @@ -517,21 +390,12 @@ void FaceTrackNoIR::startTracker( ) { ui.video_frame->show(); - ui.btnStartTracker->setEnabled ( false ); - ui.btnStopTracker->setEnabled ( true ); - - ui.iconcomboTrackerSource->setEnabled ( false ); - ui.cbxSecondTrackerSource->setEnabled ( false ); - ui.iconcomboProtocol->setEnabled ( false ); - ui.btnShowServerControls->setEnabled ( false ); - ui.iconcomboFilter->setEnabled ( false ); - - GetCameraNameDX(); - timUpdateHeadPose.start(50); + + updateButtonState(true); } -void FaceTrackNoIR::stopTracker( ) { +void FaceTrackNoIR::stopTracker( ) { ui.game_name->setText("Not connected"); #if defined(_WIN32) if (keybindingWorker) @@ -555,39 +419,16 @@ void FaceTrackNoIR::stopTracker( ) { pFilterDialog->unregisterFilter(); if ( tracker ) { - qDebug() << "Done with tracking"; tracker->should_quit = true; tracker->wait(); - - qDebug() << "stopTracker says: Deleting tracker!"; delete tracker; - qDebug() << "stopTracker says: Tracker deleted!"; tracker = 0; if (Libraries) { delete Libraries; Libraries = NULL; } } - ui.btnStartTracker->setEnabled ( true ); - ui.btnStopTracker->setEnabled ( false ); - ui.iconcomboProtocol->setEnabled ( true ); - ui.iconcomboTrackerSource->setEnabled ( true ); - ui.cbxSecondTrackerSource->setEnabled ( true ); - ui.iconcomboFilter->setEnabled ( true ); - - ui.btnShowServerControls->setEnabled ( true ); - ui.video_frame->hide(); - - ui.iconcomboProfile->setEnabled ( true ); - ui.btnLoad->setEnabled ( true ); - ui.btnSave->setEnabled ( true ); - ui.btnSaveAs->setEnabled ( true ); - ui.btnShowFilterControls->setEnabled ( true ); -} - -void FaceTrackNoIR::setInvertAxis(Axis axis, int invert ) { - if (tracker) - tracker->setInvertAxis (axis, (invert != 0)?true:false ); + updateButtonState(false); } void FaceTrackNoIR::showHeadPose() { @@ -625,7 +466,6 @@ void FaceTrackNoIR::showHeadPose() { } } -/** toggles Engine Controls Dialog **/ void FaceTrackNoIR::showTrackerSettings() { if (pTrackerDialog) { delete pTrackerDialog; @@ -641,7 +481,7 @@ void FaceTrackNoIR::showTrackerSettings() { foo->setFixedSize(foo->size()); if (Libraries && Libraries->pTracker) pTrackerDialog->registerTracker(Libraries->pTracker); - pTrackerDialog->Initialize(this); + dynamic_cast(pTrackerDialog)->show(); } } } @@ -661,7 +501,7 @@ void FaceTrackNoIR::showSecondTrackerSettings() { foo->setFixedSize(foo->size()); if (Libraries && Libraries->pSecondTracker) pSecondTrackerDialog->registerTracker(Libraries->pSecondTracker); - pSecondTrackerDialog->Initialize(this); + dynamic_cast(pSecondTrackerDialog)->show(); } } } @@ -679,7 +519,7 @@ void FaceTrackNoIR::showServerControls() { if (pProtocolDialog) { auto foo = dynamic_cast(pProtocolDialog); foo->setFixedSize(foo->size()); - pProtocolDialog->Initialize(this); + dynamic_cast(pProtocolDialog)->show(); } } } @@ -697,9 +537,9 @@ void FaceTrackNoIR::showFilterControls() { if (pFilterDialog) { auto foo = dynamic_cast(pFilterDialog); foo->setFixedSize(foo->size()); - pFilterDialog->Initialize(this); if (Libraries && Libraries->pFilter) pFilterDialog->registerFilter(Libraries->pFilter); + dynamic_cast(pFilterDialog)->show(); } } } @@ -730,34 +570,61 @@ void FaceTrackNoIR::exit() { QCoreApplication::exit(0); } -void FaceTrackNoIR::profileSelected(int index) +void FaceTrackNoIR::fill_profile_cbx() { if (looping) return; + looping = true; + QSettings settings("opentrack"); + QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); + qDebug() << "Config file now" << currentFile; + QFileInfo pathInfo ( currentFile ); + setWindowTitle(QString( OPENTRACK_VERSION " :: ") + pathInfo.fileName()); + QDir settingsDir( pathInfo.dir() ); + QStringList filters; + filters << "*.ini"; + auto iniFileList = settingsDir.entryList( filters, QDir::Files, QDir::Name ); + ui.iconcomboProfile->clear(); + for ( int i = 0; i < iniFileList.size(); i++) { + ui.iconcomboProfile->addItem(QIcon(":/images/settings16.png"), iniFileList.at(i)); + if (iniFileList.at(i) == pathInfo.fileName()) { + ui.iconcomboProfile->setItemIcon(i, QIcon(":/images/settingsopen16.png")); + ui.iconcomboProfile->setCurrentIndex( i ); + } + } + looping = false; +} + +void FaceTrackNoIR::profileSelected(int index) +{ QSettings settings("opentrack"); QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); QFileInfo pathInfo ( currentFile ); - - settings.setValue ("SettingsFile", pathInfo.absolutePath() + "/" + iniFileList.value(index, "")); + settings.setValue ("SettingsFile", pathInfo.absolutePath() + "/" + ui.iconcomboProfile->itemText(index)); loadSettings(); + if (looping) + return; + looping = true; + fill_profile_cbx(); + looping = false; } #if !defined(_WIN32) -void FaceTrackNoIR::bind_keyboard_shortcut(QxtGlobalShortcut& key, const QString label, QSettings& iniFile) +void FaceTrackNoIR::bind_keyboard_shortcut(QxtGlobalShortcut& key, key_opts& k) { - const int idx = iniFile.value("Key_index_" + label, 0).toInt(); key.setShortcut(QKeySequence::fromString("")); key.setDisabled(); - QString seq(global_key_sequences.value(idx, "")); + const int idx = k.key_index; if (idx > 0) { + QString seq(global_key_sequences.value(idx, "")); if (!seq.isEmpty()) { - if (iniFile.value(QString("Shift_%1").arg(label), false).toBool()) + if (k.shift) seq = "Shift+" + seq; - if (iniFile.value(QString("Alt_%1").arg(label), false).toBool()) + if (k.alt) seq = "Alt+" + seq; - if (iniFile.value(QString("Ctrl_%1").arg(label), false).toBool()) + if (k.ctrl) seq = "Ctrl+" + seq; key.setShortcut(QKeySequence::fromString(seq, QKeySequence::PortableText)); key.setEnabled(); @@ -767,39 +634,31 @@ void FaceTrackNoIR::bind_keyboard_shortcut(QxtGlobalShortcut& key, const QString } } #else -static void bind_keyboard_shortcut(Key& key, const QString label, QSettings& iniFile) +static void bind_keyboard_shortcut(Key& key, const key& k) { - const int idx = iniFile.value("Key_index_" + label, 0).toInt(); + const int idx = k.key_index; if (idx > 0) { key.keycode = 0; key.shift = key.alt = key.ctrl = 0; if (idx < global_windows_key_sequences.size()) key.keycode = global_windows_key_sequences[idx]; - key.shift = iniFile.value(QString("Shift_%1").arg(label), false).toBool(); - key.alt = iniFile.value(QString("Alt_%1").arg(label), false).toBool(); - key.ctrl = iniFile.value(QString("Ctrl_%1").arg(label), false).toBool(); + key.shift = k.shift; + key.alt = k.alt; + key.ctrl = k.ctrl; } } #endif void FaceTrackNoIR::bindKeyboardShortcuts() { - QSettings settings("opentrack"); - - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); - QSettings iniFile( currentFile, QSettings::IniFormat ); - iniFile.beginGroup ( "KB_Shortcuts" ); - #if !defined(_WIN32) - bind_keyboard_shortcut(keyCenter, "Center", iniFile); - bind_keyboard_shortcut(keyToggle, "Toggle", iniFile); + bind_keyboard_shortcut(keyCenter, s.center_key); + bind_keyboard_shortcut(keyToggle, s.toggle_key); #else - bind_keyboard_shortcut(keyCenter, "Center", iniFile); - bind_keyboard_shortcut(keyToggle, "Toggle", iniFile); + bind_keyboard_shortcut(keyCenter, s.center_key); + bind_keyboard_shortcut(keyToggle, s.toggle_key); #endif - iniFile.endGroup (); - if (tracker) /* running already */ { #if defined(_WIN32) @@ -822,9 +681,7 @@ void FaceTrackNoIR::shortcutRecentered() qDebug() << "Center"; if (tracker) - { tracker->do_center = true; - } } void FaceTrackNoIR::shortcutToggled() @@ -832,7 +689,5 @@ void FaceTrackNoIR::shortcutToggled() QApplication::beep(); qDebug() << "Toggle"; if (tracker) - { tracker->enabled = !tracker->enabled; - } } diff --git a/facetracknoir/facetracknoir.h b/facetracknoir/facetracknoir.h index 72ccebd8..b1279697 100644 --- a/facetracknoir/facetracknoir.h +++ b/facetracknoir/facetracknoir.h @@ -39,6 +39,7 @@ #include #include #include +#include #if !defined(_WIN32) # include "qxt-mini/QxtGlobalShortcut" #else @@ -50,6 +51,11 @@ #include "ui_facetracknoir.h" +#include "facetracknoir/options.hpp" +using namespace options; + +#include "facetracknoir/main-settings.hpp" + #include "global-settings.h" #include "tracker.h" #include "facetracknoir/shortcuts.h" @@ -100,6 +106,8 @@ public: QxtGlobalShortcut keyCenter; QxtGlobalShortcut keyToggle; #endif + pbundle b; + main_settings s; public slots: void shortcutRecentered(); void shortcutToggled(); @@ -108,7 +116,6 @@ private: HeadPoseData pose; Ui::OpentrackUI ui; QTimer timUpdateHeadPose; // Timer to display headpose - QStringList iniFileList; // List of INI-files, that are present in the Settings folder ITrackerDialog* pTrackerDialog; // Pointer to Tracker dialog instance (in DLL) ITrackerDialog* pSecondTrackerDialog; // Pointer to the second Tracker dialog instance (in DLL) @@ -122,6 +129,7 @@ private: void GetCameraNameDX(); void loadSettings(); + void updateButtonState(bool); QList dlopen_filters; QList dlopen_trackers; @@ -129,18 +137,18 @@ private: QShortcut kbd_quit; #ifndef _WIN32 - void bind_keyboard_shortcut(QxtGlobalShortcut& key, const QString label, QSettings& iniFile); + void bind_keyboard_shortcut(QxtGlobalShortcut&, key_opts& k); #endif - volatile bool looping; + bool looping; + + void fill_profile_cbx(); private slots: - //file menu void open(); void save(); void saveAs(); void exit(); - // void setIcon(int index); void profileSelected(int index); void showTrackerSettings(); @@ -151,30 +159,10 @@ private slots: void showKeyboardShortcuts(); void showCurveConfiguration(); - void setInvertAxis( Axis axis, int invert ); - void setInvertYaw(int invert) { - setInvertAxis(Yaw, invert); - } - void setInvertPitch(int invert) { - setInvertAxis(Pitch, invert); - } - void setInvertRoll(int invert) { - setInvertAxis(Roll, invert); - } - void setInvertX(int invert) { - setInvertAxis(TX, invert); - } - void setInvertY(int invert) { - setInvertAxis(TY, invert); - } - void setInvertZ(int invert) { - setInvertAxis(TZ, invert); - } void showHeadPose(); void startTracker(); void stopTracker(); - }; #endif // FaceTrackNoIR_H diff --git a/facetracknoir/ftnoir_curves.ui b/facetracknoir/ftnoir_curves.ui index 77df9a20..f96df044 100644 --- a/facetracknoir/ftnoir_curves.ui +++ b/facetracknoir/ftnoir_curves.ui @@ -761,7 +761,7 @@ - + 0 @@ -816,7 +816,7 @@ tx_altp ty_altp tz_altp - checkBox + tcomp_enable tabWidget pos_tx buttonBox diff --git a/facetracknoir/ftnoir_keyboardshortcuts.ui b/facetracknoir/ftnoir_keyboardshortcuts.ui index 565c0e77..1477d56d 100644 --- a/facetracknoir/ftnoir_keyboardshortcuts.ui +++ b/facetracknoir/ftnoir_keyboardshortcuts.ui @@ -6,8 +6,8 @@ 0 0 - 335 - 120 + 360 + 124 @@ -191,53 +191,10 @@ - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - Cancel - - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - OK + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok diff --git a/facetracknoir/main.cpp b/facetracknoir/main.cpp index 5ba3fcd5..3143a093 100644 --- a/facetracknoir/main.cpp +++ b/facetracknoir/main.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #if defined(_WIN32) && defined(_MSC_VER) # include @@ -61,11 +62,9 @@ int main(int argc, char** argv) #endif QApplication::setAttribute(Qt::AA_X11InitThreads, true); QApplication app(argc, argv); - FaceTrackNoIR w; - QDesktopWidget desktop; + auto w = std::make_shared(); - w.move(desktop.screenGeometry().width()/2-w.width()/2, 100); - w.show(); + w->show(); app.exec(); return 0; diff --git a/facetracknoir/shortcuts.cpp b/facetracknoir/shortcuts.cpp index 6a972aa3..2f117ea4 100644 --- a/facetracknoir/shortcuts.cpp +++ b/facetracknoir/shortcuts.cpp @@ -12,63 +12,55 @@ KeyboardShortcutDialog::KeyboardShortcutDialog( FaceTrackNoIR *ftnoir, QWidget * mainApp = ftnoir; // Preserve a pointer to FTNoIR // Connect Qt signals to member-functions - connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); - connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); + connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); + connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); for ( int i = 0; i < global_key_sequences.size(); i++) { ui.cbxCenterKey->addItem(global_key_sequences.at(i)); ui.cbxToggleKey->addItem(global_key_sequences.at(i)); } - loadSettings(); -} + tie_setting(mainApp->s.center_key.key_index, ui.cbxCenterKey); + tie_setting(mainApp->s.center_key.alt, ui.chkCenterAlt); + tie_setting(mainApp->s.center_key.shift, ui.chkCenterShift); + tie_setting(mainApp->s.center_key.ctrl, ui.chkCenterCtrl); -// -// Destructor for server-dialog -// -KeyboardShortcutDialog::~KeyboardShortcutDialog() { - qDebug() << "~KeyboardShortcutDialog() says: started"; + tie_setting(mainApp->s.toggle_key.key_index, ui.cbxToggleKey); + tie_setting(mainApp->s.toggle_key.alt, ui.chkToggleAlt); + tie_setting(mainApp->s.toggle_key.shift, ui.chkToggleShift); + tie_setting(mainApp->s.toggle_key.ctrl, ui.chkToggleCtrl); } // // OK clicked on server-dialog // void KeyboardShortcutDialog::doOK() { - save(); + mainApp->b->save(); this->close(); if (mainApp->tracker) mainApp->bindKeyboardShortcuts(); } -void KeyboardShortcutDialog::showEvent ( QShowEvent * ) { - loadSettings(); -} - -// -// Cancel clicked on server-dialog -// void KeyboardShortcutDialog::doCancel() { // // Ask if changed Settings should be saved // - if (settingsDirty) { - int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard ); + if (mainApp->b->modifiedp()) { + int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel); qDebug() << "doCancel says: answer =" << ret; switch (ret) { case QMessageBox::Save: - save(); + mainApp->b->save(); this->close(); break; case QMessageBox::Discard: - this->close(); + mainApp->b->revert(); + close(); break; case QMessageBox::Cancel: - // Cancel was clicked - break; default: - // should never be reached break; } } @@ -77,114 +69,6 @@ void KeyboardShortcutDialog::doCancel() { } } -void KeyboardShortcutDialog::loadSettings() { - QSettings settings("opentrack"); // 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; - - iniFile.beginGroup ( "KB_Shortcuts" ); - - const char* names[] = { - "Center", "Toggle" - }; - - QComboBox* comboboxen[] = { - ui.cbxCenterKey, - ui.cbxToggleKey - }; - - QCheckBox* boxen[2][3] = { - { - ui.chkCenterShift, - ui.chkCenterCtrl, - ui.chkCenterAlt - }, - { - ui.chkToggleShift, - ui.chkToggleCtrl, - ui.chkToggleAlt - } - }; - - const char* modnames[] = { - "Shift", "Ctrl", "Alt" - }; - - const char* keynames[] = { - "Center", "Toggle" - }; - - const int KEY_COUNT = 2; - const int MODIFIERS = 3; - - for (int i = 0; i < KEY_COUNT; i++) - { - for (int m = 0; m < MODIFIERS; m++) - { - boxen[i][m]->setChecked (iniFile.value ( QString("%1_%2").arg(modnames[m], keynames[i]), 0).toBool()); - } - comboboxen[i]->setCurrentIndex(iniFile.value(QString("Key_index_%1").arg(names[i]), 0).toInt()); - } - - iniFile.endGroup (); - - settingsDirty = false; -} - -void KeyboardShortcutDialog::save() { - const char* keynames[] = { - "Center", "Toggle" - }; - - QComboBox* comboboxen[] = { - ui.cbxCenterKey, - ui.cbxToggleKey - }; - - const char* modnames[] = { - "Shift", "Ctrl", "Alt" - }; - - QCheckBox* boxen[2][3] = { - { - ui.chkCenterShift, - ui.chkCenterCtrl, - ui.chkCenterAlt - }, - { - ui.chkToggleShift, - ui.chkToggleCtrl, - ui.chkToggleAlt - } - }; - - const int MODIFIERS = 3; - const int KEY_COUNT = 2; - - QSettings settings("opentrack"); // 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) - - iniFile.beginGroup ( "KB_Shortcuts" ); - - for (int i = 0; i < KEY_COUNT; i++) - { - for (int m = 0; m < MODIFIERS; m++) - { - iniFile.setValue(QString("%1_%2").arg(modnames[m], keynames[i]), boxen[i][m]->isChecked()); - } - iniFile.setValue(QString("Key_index_%1").arg(keynames[i]), comboboxen[i]->currentIndex()); - } - - iniFile.endGroup(); - - settingsDirty = false; -} - #if defined(_WIN32) #include diff --git a/facetracknoir/shortcuts.h b/facetracknoir/shortcuts.h index a98211a8..f8c34be7 100644 --- a/facetracknoir/shortcuts.h +++ b/facetracknoir/shortcuts.h @@ -15,16 +15,9 @@ class KeyboardShortcutDialog: public QWidget Q_OBJECT public: - explicit KeyboardShortcutDialog( FaceTrackNoIR *ftnoir, QWidget *parent ); - virtual ~KeyboardShortcutDialog(); - void showEvent (QShowEvent *); - + KeyboardShortcutDialog( FaceTrackNoIR *ftnoir, QWidget *parent ); private: Ui::UICKeyboardShortcutDialog ui; - void loadSettings(); - void save(); - - bool settingsDirty; FaceTrackNoIR *mainApp; private slots: diff --git a/facetracknoir/tracker.cpp b/facetracknoir/tracker.cpp index 590d44bf..ae4398ff 100644 --- a/facetracknoir/tracker.cpp +++ b/facetracknoir/tracker.cpp @@ -22,14 +22,13 @@ # include #endif -Tracker::Tracker( FaceTrackNoIR *parent ) : +Tracker::Tracker(FaceTrackNoIR *parent , main_settings& s) : + mainApp(parent), + s(s), should_quit(false), do_center(false), - enabled(true), - compensate(true), - tcomp_rz(false) + enabled(true) { - mainApp = parent; } Tracker::~Tracker() @@ -37,18 +36,18 @@ Tracker::~Tracker() } static void get_curve(double pos, double& out, THeadPoseDOF& axis) { - bool altp = (pos < 0) && axis.altp; + bool altp = (pos < 0) && axis.opts.altp; if (altp) { - out = axis.invert * axis.curveAlt.getValue(pos); + out = (axis.opts.invert ? -1 : 1) * axis.curveAlt.getValue(pos); axis.curve.setTrackingActive( false ); axis.curveAlt.setTrackingActive( true ); } else { - out = axis.invert * axis.curve.getValue(pos); + out = (axis.opts.invert ? -1 : 1) * axis.curve.getValue(pos); axis.curve.setTrackingActive( true ); axis.curveAlt.setTrackingActive( false ); } - out += axis.zero; + out += axis.opts.zero; } static void t_compensate(double* input, double* output, bool rz) @@ -131,7 +130,7 @@ void Tracker::run() { do_center = false; if (Libraries->pFilter) - Libraries->pFilter->Initialize(); + Libraries->pFilter->reset(); } T6DOF target_camera, target_camera2, new_camera; @@ -154,8 +153,8 @@ void Tracker::run() { get_curve(new_camera.axes[i], output_camera.axes[i], mainApp->axis(i)); } - if (compensate) - t_compensate(output_camera.axes, output_camera.axes, tcomp_rz); + if (mainApp->s.tcomp_p) + t_compensate(output_camera.axes, output_camera.axes, mainApp->s.tcomp_tz); if (Libraries->pProtocol) { Libraries->pProtocol->sendHeadposeToGame( output_camera.axes ); // degrees & centimeters @@ -188,5 +187,3 @@ void Tracker::getOutputHeadPose( double *data ) { for (int i = 0; i < 6; i++) data[i] = output_camera.axes[i]; } - -void Tracker::setInvertAxis(Axis axis, bool invert) { mainApp->axis(axis).invert = invert? -1.0 : 1.0; } diff --git a/facetracknoir/tracker.h b/facetracknoir/tracker.h index 987b5a24..b671ac7c 100644 --- a/facetracknoir/tracker.h +++ b/facetracknoir/tracker.h @@ -12,53 +12,43 @@ #include #include "global-settings.h" #include +#include #include #include "tracker_types.h" +#include "facetracknoir/main-settings.hpp" +#include "facetracknoir/options.hpp" +using namespace options; class FaceTrackNoIR; // pre-define parent-class to avoid circular includes class THeadPoseDOF { private: - THeadPoseDOF(const THeadPoseDOF &) {} - THeadPoseDOF& operator=(const THeadPoseDOF&) { return *this; } + THeadPoseDOF(const THeadPoseDOF &) = delete; + THeadPoseDOF& operator=(const THeadPoseDOF&) = delete; public: - THeadPoseDOF() : - headPos(0), - invert(0), - altp(false), - zero(0) - { - } - THeadPoseDOF(QString primary, QString secondary, int maxInput1, int maxOutput1, int maxInput2, - int maxOutput2) : + int maxOutput2, + axis_opts* opts) : headPos(0), - invert(1), curve(primary, maxInput1, maxOutput1), curveAlt(secondary, maxInput2, maxOutput2), - zero(0) + opts(*opts) { QSettings settings("opentrack"); QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); QSettings iniFile( currentFile, QSettings::IniFormat ); curve.loadSettings(iniFile); curveAlt.loadSettings(iniFile); - - iniFile.beginGroup("Tracking"); - altp = iniFile.value(secondary).toBool(); - iniFile.endGroup(); } volatile double headPos; - volatile float invert; FunctionConfig curve; FunctionConfig curveAlt; - volatile bool altp; - volatile double zero; + axis_opts& opts; }; class Tracker : public QThread { @@ -67,24 +57,21 @@ class Tracker : public QThread { private: FaceTrackNoIR *mainApp; QMutex mtx; + main_settings& s; protected: void run(); public: - Tracker( FaceTrackNoIR *parent ); + Tracker( FaceTrackNoIR *parent, main_settings& s); ~Tracker(); - void setInvertAxis(Axis axis, bool invert); - void getHeadPose(double *data); void getOutputHeadPose(double *data); volatile bool should_quit; volatile bool do_center; volatile bool enabled; - volatile bool compensate; - volatile bool tcomp_rz; T6DOF output_camera; }; @@ -92,14 +79,14 @@ public: class HeadPoseData { public: THeadPoseDOF* axes[6]; - HeadPoseData() + HeadPoseData(std::vector opts) { - axes[TX] = new THeadPoseDOF("tx","tx_alt", 25, 100, 25, 100); - axes[TY] = new THeadPoseDOF("ty","ty_alt", 25, 100, 25, 100); - axes[TZ] = new THeadPoseDOF("tz","tz_alt", 25, 100, 25, 100); - axes[Yaw] = new THeadPoseDOF("rx", "rx_alt", 180, 180, 180, 180); - axes[Pitch] = new THeadPoseDOF("ry", "ry_alt", 90, 90, 90, 90); - axes[Roll] = new THeadPoseDOF("rz", "rz_alt", 180, 180, 180, 180); + axes[TX] = new THeadPoseDOF("tx","tx_alt", 25, 100, 25, 100, opts[TX]); + axes[TY] = new THeadPoseDOF("ty","ty_alt", 25, 100, 25, 100, opts[TY]); + axes[TZ] = new THeadPoseDOF("tz","tz_alt", 25, 100, 25, 100, opts[TZ]); + axes[Yaw] = new THeadPoseDOF("rx", "rx_alt", 180, 180, 180, 180, opts[Yaw]); + axes[Pitch] = new THeadPoseDOF("ry", "ry_alt", 90, 90, 90, 90, opts[Pitch]); + axes[Roll] = new THeadPoseDOF("rz", "rz_alt", 180, 180, 180, 180, opts[Roll]); } ~HeadPoseData() { -- cgit v1.2.3 From d498588f59c5b33a30bd63cd5d7f55ef8d209ecd Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 31 Dec 2013 08:43:02 +0100 Subject: add forgotten settings file for main ui --- facetracknoir/main-settings.hpp | 56 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 facetracknoir/main-settings.hpp (limited to 'facetracknoir') diff --git a/facetracknoir/main-settings.hpp b/facetracknoir/main-settings.hpp new file mode 100644 index 00000000..05c75398 --- /dev/null +++ b/facetracknoir/main-settings.hpp @@ -0,0 +1,56 @@ +#pragma once + +#include +#include "facetracknoir/options.hpp" +using namespace options; + +struct key_opts { + value key_index; + value ctrl, alt, shift; + key_opts(pbundle b, const QString& name) : + key_index(b, QString("key-index-%1").arg(name), 0), + ctrl(b, QString("key-ctrl-%1").arg(name), 0), + alt(b, QString("key-alt-%1").arg(name), 0), + shift(b, QString("key-shift-%1").arg(name), 0) + {} +}; + +struct axis_opts { + value zero; + value invert, altp; + axis_opts(pbundle b, QString pfx) : + zero(b, n(pfx, "zero-pos"), 0), + invert(b, n(pfx, "invert-axis"), false), + altp(b, n(pfx, "alt-axis-sign"), false) + {} +private: + static inline QString n(QString pfx, QString name) { + return QString("%1-%2").arg(pfx, name); + } +}; + +struct main_settings { + pbundle b; + key_opts center_key; + key_opts toggle_key; + value tracker_dll, tracker2_dll, filter_dll, protocol_dll; + axis_opts a_x, a_y, a_z, a_yaw, a_pitch, a_roll; + value tcomp_p, tcomp_tz; + main_settings(pbundle b) : + b(b), + center_key(b, "center"), + toggle_key(b, "toggle"), + tracker_dll(b, "tracker-dll", ""), + tracker2_dll(b, "tracker2-dll", ""), + filter_dll(b, "filter-dll", ""), + protocol_dll(b, "protocol-dll", ""), + a_x(b, "x"), + a_y(b, "y"), + a_z(b, "z"), + a_yaw(b, "yaw"), + a_pitch(b, "pitch"), + a_roll(b, "roll"), + tcomp_p(b, "compensate-translation", true), + tcomp_tz(b, "compensate-translation-disable-z-axis", false) + {} +}; -- cgit v1.2.3 From f460f501d169df9e21825ebe31c9c21fb2692dfa Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 31 Dec 2013 12:40:10 +0100 Subject: rename --- facetracknoir/options.h | 303 ++++++++++++++++++++++++++++++++++++++++++++++ facetracknoir/options.hpp | 303 ---------------------------------------------- 2 files changed, 303 insertions(+), 303 deletions(-) create mode 100644 facetracknoir/options.h delete mode 100644 facetracknoir/options.hpp (limited to 'facetracknoir') diff --git a/facetracknoir/options.h b/facetracknoir/options.h new file mode 100644 index 00000000..1305bd0a --- /dev/null +++ b/facetracknoir/options.h @@ -0,0 +1,303 @@ +/* Copyright (c) 2013 Stanislaw Halik + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + */ + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef __GNUC__ +# define ov override +#else +# define ov +#endif + +namespace options { + template + inline T qcruft_to_t (const QVariant& t); + + template<> + inline int qcruft_to_t(const QVariant& t) + { + return t.toInt(); + } + + template<> + inline QString qcruft_to_t(const QVariant& t) + { + return t.toString(); + } + + template<> + inline bool qcruft_to_t(const QVariant& t) + { + return t.toBool(); + } + + template<> + inline double qcruft_to_t(const QVariant& t) + { + return t.toDouble(); + } + + template<> + inline QVariant qcruft_to_t(const QVariant& t) + { + return t; + } + + // snapshot of qsettings group at given time + class group { + private: + QMap map; + QString name; + public: + group(const QString& name) : name(name) + { + QSettings settings(group::org); + QString currentFile = + settings.value("SettingsFile", + QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); + QSettings iniFile(currentFile, QSettings::IniFormat); + iniFile.beginGroup(name); + for (auto& k : iniFile.childKeys()) + map[k] = iniFile.value(k); + iniFile.endGroup(); + } + static constexpr const char* org = "opentrack"; + void save() { + QSettings settings(group::org); + QString currentFile = + settings.value("SettingsFile", + QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); + QSettings s(currentFile, QSettings::IniFormat); + s.beginGroup(name); + for (auto& k : map.keys()) + s.setValue(k, map[k]); + s.endGroup(); + } + template + T get(const QString& k) { + return qcruft_to_t(map.value(k)); + } + + void put(const QString& s, const QVariant& d) + { + map[s] = d; + } + bool contains(const QString& s) + { + return map.contains(s); + } + }; + + class impl_bundle : public QObject { + Q_OBJECT + private: + QMutex mtx; + const QString group_name; + group saved; + group transient; + impl_bundle(const impl_bundle&) = delete; + impl_bundle& operator=(const impl_bundle&) = delete; + bool modified; + public: + impl_bundle(const QString& group_name) : + mtx(QMutex::Recursive), + group_name(group_name), + saved(group_name), + transient(saved), + modified(false) + { + } + /* keep in mind doesn't fire signals */ + void reload() { + QMutexLocker l(&mtx); + saved = group(group_name); + transient = saved; + emit reloaded(); + } + + std::shared_ptr make(const QString& name) { + return std::make_shared(name); + } + void store(const QString& name, const QVariant& datum) + { + QMutexLocker l(&mtx); + if (!transient.contains(name) || datum != transient.get(name)) + { + modified = true; + transient.put(name, datum); + emit bundleChanged(); + } + } + bool contains(const QString& name) + { + QMutexLocker l(&mtx); + return transient.contains(name); + } + template + T get(const QString& name) { + QMutexLocker l(&mtx); + return transient.get(name); + } + void save() + { + QMutexLocker l(&mtx); + modified = false; + saved = transient; + transient.save(); + } + void revert() + { + QMutexLocker l(&mtx); + modified = false; + transient = saved; + emit bundleChanged(); + } + + bool modifiedp() { + QMutexLocker l(&mtx); + return modified; + } + signals: + void bundleChanged(); + void reloaded(); + }; + + typedef std::shared_ptr pbundle; + + class base_value : public QObject { + Q_OBJECT + public: + base_value(pbundle b, const QString& name) : b(b), self_name(name) { + connect(b.get(), SIGNAL(reloaded()), this, SLOT(reread_value())); + } + virtual QVariant operator=(const QVariant& datum) = 0; + protected: + pbundle b; + QString self_name; + public slots: + void reread_value() + { + this->operator=(b->get(self_name)); + } + public slots: +#define DEFINE_SLOT(t) void setValue(t datum) { this->operator=(datum); } + DEFINE_SLOT(double) + DEFINE_SLOT(int) + DEFINE_SLOT(QString) + DEFINE_SLOT(bool) + signals: +#define DEFINE_SIGNAL(t) void valueChanged(t); + DEFINE_SIGNAL(double) + DEFINE_SIGNAL(int) + DEFINE_SIGNAL(QString) + DEFINE_SIGNAL(bool) + }; + + template + class value : public base_value { + private: T def; + public: + static constexpr const Qt::ConnectionType CONNTYPE = Qt::QueuedConnection; + value(pbundle b, const QString& name, T def) : + base_value(b, name), def(def) + { + if (!b->contains(name)) + { + QVariant cruft(def); + b->store(self_name, cruft); + } + } + operator T() { return b->get(self_name); } + QVariant operator=(const QVariant& datum) { + b->store(self_name, datum); + auto foo = qcruft_to_t(datum); + emit valueChanged(foo); + return datum; + } + }; + + template + inline void tie_setting(value&, Q*); + + template<> + inline void tie_setting(value& v, QComboBox* cb) + { + base_value::connect(cb, SIGNAL(currentIndexChanged(int)), &v, SLOT(setValue(int)), v.CONNTYPE); + base_value::connect(&v, SIGNAL(valueChanged(int)), cb, SLOT(setCurrentIndex(int)), v.CONNTYPE); + cb->setCurrentIndex(v); + } + + template<> + inline void tie_setting(value& v, QComboBox* cb) + { + base_value::connect(cb, SIGNAL(currentTextChanged(QString)), &v, SLOT(setValue(QString)), v.CONNTYPE); + base_value::connect(&v, SIGNAL(valueChanged(QString)), cb, SLOT(setCurrentText(QString)), v.CONNTYPE); + cb->setCurrentText(v); + } + + template<> + inline void tie_setting(value& v, QCheckBox* cb) + { + base_value::connect(cb, SIGNAL(toggled(bool)), &v, SLOT(setValue(bool)), v.CONNTYPE); + base_value::connect(&v, SIGNAL(valueChanged(bool)), cb, SLOT(setChecked(bool)), v.CONNTYPE); + cb->setChecked(v); + } + + template<> + inline void tie_setting(value& v, QDoubleSpinBox* dsb) + { + base_value::connect(dsb, SIGNAL(valueChanged(double)), &v, SLOT(setValue(double)), v.CONNTYPE); + base_value::connect(&v, SIGNAL(valueChanged(double)), dsb, SLOT(setValue(double)), v.CONNTYPE); + dsb->setValue(v); + } + + template<> + inline void tie_setting(value& v, QSpinBox* sb) + { + base_value::connect(sb, SIGNAL(valueChanged(int)), &v, SLOT(setValue(int)), v.CONNTYPE); + base_value::connect(&v, SIGNAL(valueChanged(int)), sb, SLOT(setValue(int)), v.CONNTYPE); + sb->setValue(v); + } + + template<> + inline void tie_setting(value& v, QSlider* sl) + { + base_value::connect(sl, SIGNAL(valueChanged(int)), &v, SLOT(setValue(int)), v.CONNTYPE); + base_value::connect(&v, SIGNAL(valueChanged(int)), sl, SLOT(setValue(int)), v.CONNTYPE); + sl->setValue(v); + } + + template<> + inline void tie_setting(value& v, QLineEdit* le) + { + base_value::connect(le, SIGNAL(textChanged(QString)), &v, SLOT(setValue(QString)), v.CONNTYPE); + base_value::connect(&v, SIGNAL(valueChanged(QString)),le, SLOT(setText(QString)), v.CONNTYPE); + le->setText(v); + } + + inline pbundle bundle(const QString& group) { + return std::make_shared(group); + } +} diff --git a/facetracknoir/options.hpp b/facetracknoir/options.hpp deleted file mode 100644 index 1305bd0a..00000000 --- a/facetracknoir/options.hpp +++ /dev/null @@ -1,303 +0,0 @@ -/* Copyright (c) 2013 Stanislaw Halik - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - */ - -#pragma once - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef __GNUC__ -# define ov override -#else -# define ov -#endif - -namespace options { - template - inline T qcruft_to_t (const QVariant& t); - - template<> - inline int qcruft_to_t(const QVariant& t) - { - return t.toInt(); - } - - template<> - inline QString qcruft_to_t(const QVariant& t) - { - return t.toString(); - } - - template<> - inline bool qcruft_to_t(const QVariant& t) - { - return t.toBool(); - } - - template<> - inline double qcruft_to_t(const QVariant& t) - { - return t.toDouble(); - } - - template<> - inline QVariant qcruft_to_t(const QVariant& t) - { - return t; - } - - // snapshot of qsettings group at given time - class group { - private: - QMap map; - QString name; - public: - group(const QString& name) : name(name) - { - QSettings settings(group::org); - QString currentFile = - settings.value("SettingsFile", - QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); - QSettings iniFile(currentFile, QSettings::IniFormat); - iniFile.beginGroup(name); - for (auto& k : iniFile.childKeys()) - map[k] = iniFile.value(k); - iniFile.endGroup(); - } - static constexpr const char* org = "opentrack"; - void save() { - QSettings settings(group::org); - QString currentFile = - settings.value("SettingsFile", - QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); - QSettings s(currentFile, QSettings::IniFormat); - s.beginGroup(name); - for (auto& k : map.keys()) - s.setValue(k, map[k]); - s.endGroup(); - } - template - T get(const QString& k) { - return qcruft_to_t(map.value(k)); - } - - void put(const QString& s, const QVariant& d) - { - map[s] = d; - } - bool contains(const QString& s) - { - return map.contains(s); - } - }; - - class impl_bundle : public QObject { - Q_OBJECT - private: - QMutex mtx; - const QString group_name; - group saved; - group transient; - impl_bundle(const impl_bundle&) = delete; - impl_bundle& operator=(const impl_bundle&) = delete; - bool modified; - public: - impl_bundle(const QString& group_name) : - mtx(QMutex::Recursive), - group_name(group_name), - saved(group_name), - transient(saved), - modified(false) - { - } - /* keep in mind doesn't fire signals */ - void reload() { - QMutexLocker l(&mtx); - saved = group(group_name); - transient = saved; - emit reloaded(); - } - - std::shared_ptr make(const QString& name) { - return std::make_shared(name); - } - void store(const QString& name, const QVariant& datum) - { - QMutexLocker l(&mtx); - if (!transient.contains(name) || datum != transient.get(name)) - { - modified = true; - transient.put(name, datum); - emit bundleChanged(); - } - } - bool contains(const QString& name) - { - QMutexLocker l(&mtx); - return transient.contains(name); - } - template - T get(const QString& name) { - QMutexLocker l(&mtx); - return transient.get(name); - } - void save() - { - QMutexLocker l(&mtx); - modified = false; - saved = transient; - transient.save(); - } - void revert() - { - QMutexLocker l(&mtx); - modified = false; - transient = saved; - emit bundleChanged(); - } - - bool modifiedp() { - QMutexLocker l(&mtx); - return modified; - } - signals: - void bundleChanged(); - void reloaded(); - }; - - typedef std::shared_ptr pbundle; - - class base_value : public QObject { - Q_OBJECT - public: - base_value(pbundle b, const QString& name) : b(b), self_name(name) { - connect(b.get(), SIGNAL(reloaded()), this, SLOT(reread_value())); - } - virtual QVariant operator=(const QVariant& datum) = 0; - protected: - pbundle b; - QString self_name; - public slots: - void reread_value() - { - this->operator=(b->get(self_name)); - } - public slots: -#define DEFINE_SLOT(t) void setValue(t datum) { this->operator=(datum); } - DEFINE_SLOT(double) - DEFINE_SLOT(int) - DEFINE_SLOT(QString) - DEFINE_SLOT(bool) - signals: -#define DEFINE_SIGNAL(t) void valueChanged(t); - DEFINE_SIGNAL(double) - DEFINE_SIGNAL(int) - DEFINE_SIGNAL(QString) - DEFINE_SIGNAL(bool) - }; - - template - class value : public base_value { - private: T def; - public: - static constexpr const Qt::ConnectionType CONNTYPE = Qt::QueuedConnection; - value(pbundle b, const QString& name, T def) : - base_value(b, name), def(def) - { - if (!b->contains(name)) - { - QVariant cruft(def); - b->store(self_name, cruft); - } - } - operator T() { return b->get(self_name); } - QVariant operator=(const QVariant& datum) { - b->store(self_name, datum); - auto foo = qcruft_to_t(datum); - emit valueChanged(foo); - return datum; - } - }; - - template - inline void tie_setting(value&, Q*); - - template<> - inline void tie_setting(value& v, QComboBox* cb) - { - base_value::connect(cb, SIGNAL(currentIndexChanged(int)), &v, SLOT(setValue(int)), v.CONNTYPE); - base_value::connect(&v, SIGNAL(valueChanged(int)), cb, SLOT(setCurrentIndex(int)), v.CONNTYPE); - cb->setCurrentIndex(v); - } - - template<> - inline void tie_setting(value& v, QComboBox* cb) - { - base_value::connect(cb, SIGNAL(currentTextChanged(QString)), &v, SLOT(setValue(QString)), v.CONNTYPE); - base_value::connect(&v, SIGNAL(valueChanged(QString)), cb, SLOT(setCurrentText(QString)), v.CONNTYPE); - cb->setCurrentText(v); - } - - template<> - inline void tie_setting(value& v, QCheckBox* cb) - { - base_value::connect(cb, SIGNAL(toggled(bool)), &v, SLOT(setValue(bool)), v.CONNTYPE); - base_value::connect(&v, SIGNAL(valueChanged(bool)), cb, SLOT(setChecked(bool)), v.CONNTYPE); - cb->setChecked(v); - } - - template<> - inline void tie_setting(value& v, QDoubleSpinBox* dsb) - { - base_value::connect(dsb, SIGNAL(valueChanged(double)), &v, SLOT(setValue(double)), v.CONNTYPE); - base_value::connect(&v, SIGNAL(valueChanged(double)), dsb, SLOT(setValue(double)), v.CONNTYPE); - dsb->setValue(v); - } - - template<> - inline void tie_setting(value& v, QSpinBox* sb) - { - base_value::connect(sb, SIGNAL(valueChanged(int)), &v, SLOT(setValue(int)), v.CONNTYPE); - base_value::connect(&v, SIGNAL(valueChanged(int)), sb, SLOT(setValue(int)), v.CONNTYPE); - sb->setValue(v); - } - - template<> - inline void tie_setting(value& v, QSlider* sl) - { - base_value::connect(sl, SIGNAL(valueChanged(int)), &v, SLOT(setValue(int)), v.CONNTYPE); - base_value::connect(&v, SIGNAL(valueChanged(int)), sl, SLOT(setValue(int)), v.CONNTYPE); - sl->setValue(v); - } - - template<> - inline void tie_setting(value& v, QLineEdit* le) - { - base_value::connect(le, SIGNAL(textChanged(QString)), &v, SLOT(setValue(QString)), v.CONNTYPE); - base_value::connect(&v, SIGNAL(valueChanged(QString)),le, SLOT(setText(QString)), v.CONNTYPE); - le->setText(v); - } - - inline pbundle bundle(const QString& group) { - return std::make_shared(group); - } -} -- cgit v1.2.3 From 85129ee6fcabee8821e301ae64fec81f12df788d Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 31 Dec 2013 12:40:55 +0100 Subject: fix doze --- facetracknoir/facetracknoir.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index b98c6085..2006f831 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -634,9 +634,9 @@ void FaceTrackNoIR::bind_keyboard_shortcut(QxtGlobalShortcut& key, key_opts& k) } } #else -static void bind_keyboard_shortcut(Key& key, const key& k) +static void bind_keyboard_shortcut(Key& key, key_opts& k) { - const int idx = k.key_index; + int idx = k.key_index; if (idx > 0) { key.keycode = 0; -- cgit v1.2.3 From 77412f01c387ffce47d42bcaad3cf26816591350 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 31 Dec 2013 12:41:12 +0100 Subject: finish rename --- FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.h | 2 +- facetracknoir/facetracknoir.h | 2 +- facetracknoir/main-settings.hpp | 2 +- facetracknoir/tracker.h | 2 +- ftnoir_filter_accela/ftnoir_filter_accela.h | 2 +- ftnoir_filter_ewma2/ftnoir_filter_ewma2.h | 2 +- ftnoir_filter_kalman/ftnoir_filter_kalman.h | 2 +- ftnoir_protocol_fg/ftnoir_protocol_fg.h | 2 +- ftnoir_tracker_aruco/ftnoir_tracker_aruco.h | 2 +- ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.h | 2 +- ftnoir_tracker_ht/ftnoir_tracker_ht.h | 2 +- ftnoir_tracker_hydra/ftnoir_tracker_hydra.h | 2 +- ftnoir_tracker_rift/ftnoir_tracker_rift.h | 2 +- 13 files changed, 13 insertions(+), 13 deletions(-) (limited to 'facetracknoir') diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.h b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.h index 8c590db2..a828ea48 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.h +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.h @@ -11,7 +11,7 @@ #include #include "point_tracker.h" -#include "facetracknoir/options.hpp" +#include "facetracknoir/options.h" using namespace options; struct settings diff --git a/facetracknoir/facetracknoir.h b/facetracknoir/facetracknoir.h index b1279697..53b83754 100644 --- a/facetracknoir/facetracknoir.h +++ b/facetracknoir/facetracknoir.h @@ -51,7 +51,7 @@ #include "ui_facetracknoir.h" -#include "facetracknoir/options.hpp" +#include "facetracknoir/options.h" using namespace options; #include "facetracknoir/main-settings.hpp" diff --git a/facetracknoir/main-settings.hpp b/facetracknoir/main-settings.hpp index 05c75398..c9b5ff66 100644 --- a/facetracknoir/main-settings.hpp +++ b/facetracknoir/main-settings.hpp @@ -1,7 +1,7 @@ #pragma once #include -#include "facetracknoir/options.hpp" +#include "facetracknoir/options.h" using namespace options; struct key_opts { diff --git a/facetracknoir/tracker.h b/facetracknoir/tracker.h index b671ac7c..404a8f24 100644 --- a/facetracknoir/tracker.h +++ b/facetracknoir/tracker.h @@ -17,7 +17,7 @@ #include #include "tracker_types.h" #include "facetracknoir/main-settings.hpp" -#include "facetracknoir/options.hpp" +#include "facetracknoir/options.h" using namespace options; class FaceTrackNoIR; // pre-define parent-class to avoid circular includes diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.h b/ftnoir_filter_accela/ftnoir_filter_accela.h index 1aaa039f..e8f077c3 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.h +++ b/ftnoir_filter_accela/ftnoir_filter_accela.h @@ -10,7 +10,7 @@ #define ACCELA_SECOND_ORDER_ALPHA 100.0 #define ACCELA_THIRD_ORDER_ALPHA 180.0 -#include "facetracknoir/options.hpp" +#include using namespace options; struct settings { diff --git a/ftnoir_filter_ewma2/ftnoir_filter_ewma2.h b/ftnoir_filter_ewma2/ftnoir_filter_ewma2.h index 6e9a7f9a..e50a4284 100644 --- a/ftnoir_filter_ewma2/ftnoir_filter_ewma2.h +++ b/ftnoir_filter_ewma2/ftnoir_filter_ewma2.h @@ -31,7 +31,7 @@ #include "ui_ftnoir_ewma_filtercontrols.h" #include #include -#include "facetracknoir/options.hpp" +#include "facetracknoir/options.h" using namespace options; struct settings { diff --git a/ftnoir_filter_kalman/ftnoir_filter_kalman.h b/ftnoir_filter_kalman/ftnoir_filter_kalman.h index 8f5bcd8b..25f0a0ad 100644 --- a/ftnoir_filter_kalman/ftnoir_filter_kalman.h +++ b/ftnoir_filter_kalman/ftnoir_filter_kalman.h @@ -21,7 +21,7 @@ #include #include #include -#include "facetracknoir/options.hpp" +#include "facetracknoir/options.h" using namespace options; class FTNOIR_FILTER_BASE_EXPORT FTNoIR_Filter : public IFilter diff --git a/ftnoir_protocol_fg/ftnoir_protocol_fg.h b/ftnoir_protocol_fg/ftnoir_protocol_fg.h index 13aaeab4..dca1f245 100644 --- a/ftnoir_protocol_fg/ftnoir_protocol_fg.h +++ b/ftnoir_protocol_fg/ftnoir_protocol_fg.h @@ -33,7 +33,7 @@ #include #include #include "facetracknoir/global-settings.h" -#include "facetracknoir/options.hpp" +#include "facetracknoir/options.h" using namespace options; struct settings { diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h index 23598f4d..2ff40c77 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h @@ -18,7 +18,7 @@ #include #include #include -#include "facetracknoir/options.hpp" +#include "facetracknoir/options.h" using namespace options; struct settings { diff --git a/ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.h b/ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.h index 8739394f..4c0fcb8d 100644 --- a/ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.h +++ b/ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.h @@ -8,7 +8,7 @@ #pragma once #include -#include "facetracknoir/options.hpp" +#include "facetracknoir/options.h" #include using namespace options; diff --git a/ftnoir_tracker_ht/ftnoir_tracker_ht.h b/ftnoir_tracker_ht/ftnoir_tracker_ht.h index b3c89136..583249dc 100644 --- a/ftnoir_tracker_ht/ftnoir_tracker_ht.h +++ b/ftnoir_tracker_ht/ftnoir_tracker_ht.h @@ -15,7 +15,7 @@ #include "ht_video_widget.h" #include "compat/compat.h" #include -#include "facetracknoir/options.hpp" +#include "facetracknoir/options.h" using namespace options; struct settings { diff --git a/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h b/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h index 8d91dfbb..e569efab 100644 --- a/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h +++ b/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h @@ -5,7 +5,7 @@ #include #include #include "facetracknoir/global-settings.h" -#include "facetracknoir/options.hpp" +#include "facetracknoir/options.h" using namespace options; struct settings { diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift.h b/ftnoir_tracker_rift/ftnoir_tracker_rift.h index b1f96bf2..dd673308 100644 --- a/ftnoir_tracker_rift/ftnoir_tracker_rift.h +++ b/ftnoir_tracker_rift/ftnoir_tracker_rift.h @@ -8,7 +8,7 @@ #include "facetracknoir/global-settings.h" #include "OVR.h" #include -#include "facetracknoir/options.hpp" +#include "facetracknoir/options.h" using namespace options; struct settings { -- cgit v1.2.3 From ef92acc3d03d46818317118655bac8574dfb9340 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 31 Dec 2013 13:51:44 +0100 Subject: add qlabel one-way transfer option --- facetracknoir/options.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'facetracknoir') diff --git a/facetracknoir/options.h b/facetracknoir/options.h index 1305bd0a..e77988c7 100644 --- a/facetracknoir/options.h +++ b/facetracknoir/options.h @@ -23,6 +23,7 @@ #include #include #include +#include #include #ifdef __GNUC__ @@ -297,6 +298,13 @@ namespace options { le->setText(v); } + template<> + inline void tie_setting(value& v, QLabel* lb) + { + base_value::connect(&v, SIGNAL(valueChanged(QString)), lb, SLOT(setText(QString)), v.CONNTYPE); + lb->setText(v); + } + inline pbundle bundle(const QString& group) { return std::make_shared(group); } -- cgit v1.2.3 From 478923fa291949af2ce1f307f9dd592f451508df Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 1 Jan 2014 12:13:25 +0100 Subject: fix qvariant saying invalid when they're not --- facetracknoir/options.h | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/options.h b/facetracknoir/options.h index e77988c7..7ecf6280 100644 --- a/facetracknoir/options.h +++ b/facetracknoir/options.h @@ -32,6 +32,8 @@ # define ov #endif +#include + namespace options { template inline T qcruft_to_t (const QVariant& t); @@ -193,8 +195,8 @@ namespace options { base_value(pbundle b, const QString& name) : b(b), self_name(name) { connect(b.get(), SIGNAL(reloaded()), this, SLOT(reread_value())); } - virtual QVariant operator=(const QVariant& datum) = 0; protected: + virtual QVariant operator=(const QVariant& datum) = 0; pbundle b; QString self_name; public slots: @@ -203,7 +205,7 @@ namespace options { this->operator=(b->get(self_name)); } public slots: -#define DEFINE_SLOT(t) void setValue(t datum) { this->operator=(datum); } +#define DEFINE_SLOT(t) void setValue(t datum) { this->operator=(qVariantFromValue(datum)); } DEFINE_SLOT(double) DEFINE_SLOT(int) DEFINE_SLOT(QString) @@ -218,24 +220,29 @@ namespace options { template class value : public base_value { - private: T def; + private: + T def; + protected: + QVariant operator=(const QVariant& datum) { + auto foo = qcruft_to_t(datum); + b->store(self_name, qVariantFromValue(foo)); + emit valueChanged(foo); + return datum; + } public: static constexpr const Qt::ConnectionType CONNTYPE = Qt::QueuedConnection; value(pbundle b, const QString& name, T def) : base_value(b, name), def(def) { - if (!b->contains(name)) + if (!b->contains(name) || b->get(name).type() == QVariant::Invalid) { - QVariant cruft(def); - b->store(self_name, cruft); + this->operator=(qVariantFromValue(def)); } } operator T() { return b->get(self_name); } - QVariant operator=(const QVariant& datum) { - b->store(self_name, datum); - auto foo = qcruft_to_t(datum); - emit valueChanged(foo); - return datum; + QVariant operator=(const T& datum) + { + return this->operator =(qVariantFromValue(datum)); } }; -- cgit v1.2.3 From e18f6c36733b206167470619bf97040fa4a3b99f Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 1 Jan 2014 12:24:25 +0100 Subject: reload profile combobox at appropriate time and place --- facetracknoir/facetracknoir.cpp | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index 2006f831..6e97080d 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -262,6 +262,7 @@ void FaceTrackNoIR::open() { QSettings settings("opentrack"); settings.setValue ("SettingsFile", QFileInfo(fileName).absoluteFilePath()); } + fill_profile_cbx(); loadSettings(); } } @@ -587,10 +588,6 @@ void FaceTrackNoIR::fill_profile_cbx() ui.iconcomboProfile->clear(); for ( int i = 0; i < iniFileList.size(); i++) { ui.iconcomboProfile->addItem(QIcon(":/images/settings16.png"), iniFileList.at(i)); - if (iniFileList.at(i) == pathInfo.fileName()) { - ui.iconcomboProfile->setItemIcon(i, QIcon(":/images/settingsopen16.png")); - ui.iconcomboProfile->setCurrentIndex( i ); - } } looping = false; } @@ -602,11 +599,6 @@ void FaceTrackNoIR::profileSelected(int index) QFileInfo pathInfo ( currentFile ); settings.setValue ("SettingsFile", pathInfo.absolutePath() + "/" + ui.iconcomboProfile->itemText(index)); loadSettings(); - if (looping) - return; - looping = true; - fill_profile_cbx(); - looping = false; } #if !defined(_WIN32) -- cgit v1.2.3 From ec3fe4414268acb83c04194247087389c3d1f7f2 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 1 Jan 2014 12:35:58 +0100 Subject: reload profile list when saving a new one --- facetracknoir/facetracknoir.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index 6e97080d..08cd9dfa 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -313,6 +313,8 @@ void FaceTrackNoIR::saveAs() settings.setValue ("SettingsFile", fileName); save(); } + + fill_profile_cbx(); } void FaceTrackNoIR::loadSettings() { -- cgit v1.2.3 From 36ca50cb9a5d575d3fb6ea1b5062c2f96a906b4b Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 1 Jan 2014 12:36:43 +0100 Subject: load right profile when using multiple ones (duh) --- facetracknoir/facetracknoir.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index 08cd9dfa..2bb36a78 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -590,6 +590,10 @@ void FaceTrackNoIR::fill_profile_cbx() ui.iconcomboProfile->clear(); for ( int i = 0; i < iniFileList.size(); i++) { ui.iconcomboProfile->addItem(QIcon(":/images/settings16.png"), iniFileList.at(i)); + if (iniFileList.at(i) == pathInfo.fileName()) { + ui.iconcomboProfile->setItemIcon(i, QIcon(":/images/settingsopen16.png")); + ui.iconcomboProfile->setCurrentIndex( i ); + } } looping = false; } -- cgit v1.2.3 From e38d6ab7472e9adb6bac0550fdffebb748ac4353 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 1 Jan 2014 12:41:29 +0100 Subject: get rid of useless active profile icon --- facetracknoir/facetracknoir.cpp | 1 - facetracknoir/images/settingsopen16.png | Bin 686 -> 0 bytes facetracknoir/main-facetracknoir.qrc | 1 - 3 files changed, 2 deletions(-) delete mode 100644 facetracknoir/images/settingsopen16.png (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index 2bb36a78..309a4a93 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -591,7 +591,6 @@ void FaceTrackNoIR::fill_profile_cbx() for ( int i = 0; i < iniFileList.size(); i++) { ui.iconcomboProfile->addItem(QIcon(":/images/settings16.png"), iniFileList.at(i)); if (iniFileList.at(i) == pathInfo.fileName()) { - ui.iconcomboProfile->setItemIcon(i, QIcon(":/images/settingsopen16.png")); ui.iconcomboProfile->setCurrentIndex( i ); } } diff --git a/facetracknoir/images/settingsopen16.png b/facetracknoir/images/settingsopen16.png deleted file mode 100644 index 5bf65f0d..00000000 Binary files a/facetracknoir/images/settingsopen16.png and /dev/null differ diff --git a/facetracknoir/main-facetracknoir.qrc b/facetracknoir/main-facetracknoir.qrc index eb5ad991..6cb2e300 100644 --- a/facetracknoir/main-facetracknoir.qrc +++ b/facetracknoir/main-facetracknoir.qrc @@ -2,7 +2,6 @@ uielements/tools.png images/settings16.png - images/settingsopen16.png uielements/curves.png images/facetracknoir.png -- cgit v1.2.3 From 9f0ba65825054b182d9a9c2b53dad955a90d4df1 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 1 Jan 2014 13:40:41 +0100 Subject: base spline widget size on config size --- facetracknoir/ftnoir_curves.ui | 12 ++++++------ qfunctionconfigurator/functionconfig.h | 2 ++ qfunctionconfigurator/qfunctionconfigurator.cpp | 7 +++++-- 3 files changed, 13 insertions(+), 8 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/ftnoir_curves.ui b/facetracknoir/ftnoir_curves.ui index f96df044..9b5c8d07 100644 --- a/facetracknoir/ftnoir_curves.ui +++ b/facetracknoir/ftnoir_curves.ui @@ -325,7 +325,7 @@ 100 - 7 + 28 2 @@ -374,7 +374,7 @@ 100 - 7 + 28 2 @@ -415,7 +415,7 @@ 100 - 7 + 28 2 @@ -464,7 +464,7 @@ 100 - 7 + 28 2 @@ -505,7 +505,7 @@ 100 - 7 + 28 2 @@ -554,7 +554,7 @@ 100 - 7 + 28 2 diff --git a/qfunctionconfigurator/functionconfig.h b/qfunctionconfigurator/functionconfig.h index d809259b..ab2d0d0c 100644 --- a/qfunctionconfigurator/functionconfig.h +++ b/qfunctionconfigurator/functionconfig.h @@ -32,6 +32,8 @@ private: int _max_Output; FunctionConfig(const FunctionConfig&) = delete; public: + const int maxInput() const { return _max_Input; } + const int maxOutput() const { return _max_Output; } // // Contructor(s) and destructor // diff --git a/qfunctionconfigurator/qfunctionconfigurator.cpp b/qfunctionconfigurator/qfunctionconfigurator.cpp index 4ad0a9a4..5a02a826 100644 --- a/qfunctionconfigurator/qfunctionconfigurator.cpp +++ b/qfunctionconfigurator/qfunctionconfigurator.cpp @@ -31,8 +31,7 @@ QFunctionConfigurator::QFunctionConfigurator(QWidget *parent) // // Defaults, for when the widget has no values different from the domXML() // - MaxInput = 50; // Maximum input limit - MaxOutput = 180; // Maximum output limit + pPerEGU_Output = 1; // Number of pixels, per EGU pPerEGU_Input = 4; // Number of pixels, per EGU gDistEGU_Input = 5; // Distance of gridlines @@ -74,6 +73,10 @@ void QFunctionConfigurator::setConfig(FunctionConfig* config, QString settingsFi setCaption(config->getTitle()); _draw_function = _draw_background = true; + + setmaxInputEGU(config->maxInput()); + setmaxOutputEGU(config->maxOutput()); + this->update(); } -- cgit v1.2.3 From 04709d458eb5449739648fedb6aa8e60fc9cf7f1 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 1 Jan 2014 14:00:38 +0100 Subject: don't gray out the wrong buttons when tracking --- facetracknoir/facetracknoir.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index 309a4a93..85207b53 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -328,15 +328,13 @@ void FaceTrackNoIR::updateButtonState(bool running) ui.iconcomboProfile->setEnabled ( e ); ui.btnLoad->setEnabled ( e ); ui.btnSaveAs->setEnabled ( e ); - ui.btnShowFilterControls->setEnabled ( e ); ui.btnStartTracker->setEnabled ( e ); ui.btnStopTracker->setEnabled ( running ); - - ui.iconcomboTrackerSource->setEnabled ( e ); - ui.cbxSecondTrackerSource->setEnabled ( e ); ui.iconcomboProtocol->setEnabled ( e ); ui.btnShowServerControls->setEnabled ( e ); ui.iconcomboFilter->setEnabled ( e ); + ui.iconcomboTrackerSource->setEnabled(e); + ui.cbxSecondTrackerSource->setEnabled(e); ui.btnStartTracker->setEnabled(e); ui.btnStopTracker->setEnabled(running); -- cgit v1.2.3 From 53d7258c0151893e95f569cf7f9386d269618672 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 1 Jan 2014 14:37:15 +0100 Subject: remove outdated comment --- facetracknoir/options.h | 1 - 1 file changed, 1 deletion(-) (limited to 'facetracknoir') diff --git a/facetracknoir/options.h b/facetracknoir/options.h index 7ecf6280..bc53a456 100644 --- a/facetracknoir/options.h +++ b/facetracknoir/options.h @@ -132,7 +132,6 @@ namespace options { modified(false) { } - /* keep in mind doesn't fire signals */ void reload() { QMutexLocker l(&mtx); saved = group(group_name); -- cgit v1.2.3 From 519434cd1abb8991635487c6d84bc0d85367fc42 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 3 Jan 2014 10:57:02 +0100 Subject: How about an octopus instead? --- facetracknoir/facetracknoir.ico | Bin 23558 -> 67134 bytes 1 file changed, 0 insertions(+), 0 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.ico b/facetracknoir/facetracknoir.ico index 5115066c..5cac8da1 100644 Binary files a/facetracknoir/facetracknoir.ico and b/facetracknoir/facetracknoir.ico differ -- cgit v1.2.3 From 56bdd3ba1dcfb2153e31e8479c7268ddcb620ddd Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 3 Jan 2014 21:16:48 +0100 Subject: reload combobox item to avoid empty w/ just one item --- facetracknoir/options.h | 1 + 1 file changed, 1 insertion(+) (limited to 'facetracknoir') diff --git a/facetracknoir/options.h b/facetracknoir/options.h index bc53a456..edcbf193 100644 --- a/facetracknoir/options.h +++ b/facetracknoir/options.h @@ -262,6 +262,7 @@ namespace options { base_value::connect(cb, SIGNAL(currentTextChanged(QString)), &v, SLOT(setValue(QString)), v.CONNTYPE); base_value::connect(&v, SIGNAL(valueChanged(QString)), cb, SLOT(setCurrentText(QString)), v.CONNTYPE); cb->setCurrentText(v); + v = cb->currentText(); } template<> -- cgit v1.2.3 From aa88a3fecad630d06cbc44428207b39b99a98395 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 3 Jan 2014 22:26:18 +0100 Subject: rename "curves" to "mapping" --- facetracknoir/facetracknoir.ui | 57 ++++++++++++++++++++++++------------------ 1 file changed, 33 insertions(+), 24 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.ui b/facetracknoir/facetracknoir.ui index 896c4294..bcb37ad0 100644 --- a/facetracknoir/facetracknoir.ui +++ b/facetracknoir/facetracknoir.ui @@ -172,12 +172,21 @@ QLayout::SetMinimumSize - - 10 + + 0 + + + 0 - + 0 + + 0 + + + 10 + @@ -228,9 +237,6 @@ false - - 5 - 5 @@ -283,9 +289,6 @@ false - - 5 - 5 @@ -338,9 +341,6 @@ false - - 5 - 5 @@ -380,9 +380,6 @@ false - - 5 - 5 @@ -467,9 +464,6 @@ false - - 5 - 5 @@ -509,9 +503,6 @@ false - - 5 - 5 @@ -670,7 +661,7 @@ background:none; - Curves + Mapping @@ -1425,7 +1416,16 @@ Qt::AlignHCenter|Qt::AlignTop - + + 0 + + + 0 + + + 0 + + 0 @@ -1656,7 +1656,16 @@ Qt::AlignHCenter|Qt::AlignTop - + + 0 + + + 0 + + + 0 + + 0 -- cgit v1.2.3 From c47611b99d74af449d49a1f6ebf287947162a46c Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 4 Jan 2014 14:42:14 +0100 Subject: add aruco sample printout --- facetracknoir/clientfiles/aruco/test3.jpg | Bin 0 -> 2145 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 facetracknoir/clientfiles/aruco/test3.jpg (limited to 'facetracknoir') diff --git a/facetracknoir/clientfiles/aruco/test3.jpg b/facetracknoir/clientfiles/aruco/test3.jpg new file mode 100644 index 00000000..2ff6dbd0 Binary files /dev/null and b/facetracknoir/clientfiles/aruco/test3.jpg differ -- cgit v1.2.3 From ed1b3deb4a02f5d24c09352a3decf432396bbda9 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 5 Jan 2014 11:47:55 +0100 Subject: move axis inversion into the "mapping" window --- facetracknoir/curve-config.cpp | 7 + facetracknoir/facetracknoir.cpp | 6 - facetracknoir/facetracknoir.ui | 158 ------------ facetracknoir/ftnoir_curves.ui | 560 +++++++++++++++++++++++++--------------- 4 files changed, 358 insertions(+), 373 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/curve-config.cpp b/facetracknoir/curve-config.cpp index 4b07a165..d730e4f7 100644 --- a/facetracknoir/curve-config.cpp +++ b/facetracknoir/curve-config.cpp @@ -32,6 +32,13 @@ CurveConfigurationDialog::CurveConfigurationDialog(FaceTrackNoIR *ftnoir, QWidge tie_setting(mainApp->s.a_pitch.zero, ui.pos_ry); tie_setting(mainApp->s.a_roll.zero, ui.pos_rz); + tie_setting(mainApp->s.a_yaw.invert, ui.chkInvertYaw); + tie_setting(mainApp->s.a_pitch.invert, ui.chkInvertPitch); + tie_setting(mainApp->s.a_roll.invert, ui.chkInvertRoll); + tie_setting(mainApp->s.a_x.invert, ui.chkInvertX); + tie_setting(mainApp->s.a_y.invert, ui.chkInvertY); + tie_setting(mainApp->s.a_z.invert, ui.chkInvertZ); + // Load the settings from the current .INI-file loadSettings(); } diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index 85207b53..de5b491f 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -145,12 +145,6 @@ FaceTrackNoIR::FaceTrackNoIR(QWidget *parent) : fill_combobox("opentrack-tracker-*.", dlopen_trackers, ui.iconcomboTrackerSource, ui.cbxSecondTrackerSource); fill_combobox("opentrack-filter-*.", dlopen_filters, ui.iconcomboFilter, NULL); - tie_setting(s.a_yaw.invert, ui.chkInvertYaw); - tie_setting(s.a_pitch.invert, ui.chkInvertPitch); - tie_setting(s.a_roll.invert, ui.chkInvertRoll); - tie_setting(s.a_x.invert, ui.chkInvertX); - tie_setting(s.a_y.invert, ui.chkInvertY); - tie_setting(s.a_z.invert, ui.chkInvertZ); tie_setting(s.tracker_dll, ui.iconcomboTrackerSource); tie_setting(s.tracker2_dll, ui.cbxSecondTrackerSource); tie_setting(s.protocol_dll, ui.iconcomboProtocol); diff --git a/facetracknoir/facetracknoir.ui b/facetracknoir/facetracknoir.ui index bcb37ad0..c25ee0db 100644 --- a/facetracknoir/facetracknoir.ui +++ b/facetracknoir/facetracknoir.ui @@ -896,164 +896,6 @@ - - - - 600 - 240 - 124 - 117 - - - - - 65536 - 65536 - - - - - true - - - - Axis inversion - - - Qt::AlignCenter - - - true - - - false - - - - QLayout::SetMinAndMaxSize - - - 6 - - - - - - 65536 - 65536 - - - - Qt::RightToLeft - - - background:none; - - - Yaw - - - - - - - - 65536 - 65536 - - - - Qt::RightToLeft - - - background:none; - - - TX - - - - - - - - 65536 - 65536 - - - - Qt::RightToLeft - - - false - - - background:none; - - - Pitch - - - - - - - - 65536 - 65536 - - - - Qt::RightToLeft - - - background:none; - - - TY - - - - - - - - 65536 - 65536 - - - - Qt::RightToLeft - - - background:none; - - - Roll - - - - - - - - 65536 - 65536 - - - - Qt::RightToLeft - - - background:none; - - - TZ - - - - - diff --git a/facetracknoir/ftnoir_curves.ui b/facetracknoir/ftnoir_curves.ui index 9b5c8d07..ae84110f 100644 --- a/facetracknoir/ftnoir_curves.ui +++ b/facetracknoir/ftnoir_curves.ui @@ -579,215 +579,357 @@ Options - - - - 0 - 10 - 306 - 114 - - - - Center pose - - - Qt::AlignCenter - - - true - - - false - - - - - - RX - - - - - - - deg. - - - 3 - - - -180.000000000000000 - - - 180.000000000000000 - - - - - - - TX - - - - - - - cm - - - 3 - - - -100.000000000000000 - - - 100.000000000000000 - - - - - - - RY - - - - - - - deg. - - - 3 - - - -180.000000000000000 - - - 180.000000000000000 - - - - - - - TY - - - - - - - cm - - - 3 - - - -100.000000000000000 - - - 100.000000000000000 - - - - - - - RZ - - - - - - - deg. - - - 3 - - - -180.000000000000000 - - - 180.000000000000000 - - - - - - - TZ - - - - - - - cm - - - 3 - - - -100.000000000000000 - - - 100.000000000000000 - - - - - - - - - 10 - 140 - 291 - 81 - - - - - - - Translation compensation - - - true - - - - - - - 0 - 0 - - - - - - - Enablement - - - - - - - - - - Disable Z axis compensation - - - - - + + + + + Center pose + + + Qt::AlignCenter + + + true + + + false + + + + + + RX + + + + + + + deg. + + + 3 + + + -180.000000000000000 + + + 180.000000000000000 + + + + + + + TX + + + + + + + cm + + + 3 + + + -100.000000000000000 + + + 100.000000000000000 + + + + + + + RY + + + + + + + deg. + + + 3 + + + -180.000000000000000 + + + 180.000000000000000 + + + + + + + TY + + + + + + + cm + + + 3 + + + -100.000000000000000 + + + 100.000000000000000 + + + + + + + TZ + + + + + + + RZ + + + + + + + deg. + + + 3 + + + -180.000000000000000 + + + 180.000000000000000 + + + + + + + cm + + + 3 + + + -100.000000000000000 + + + 100.000000000000000 + + + + + + + + + + + + + Translation compensation + + + true + + + + + + + 0 + 0 + + + + + + + Enablement + + + + + + + + + + Disable Z axis compensation + + + + + + + + + + + 65536 + 65536 + + + + + true + + + + Axis inversion + + + Qt::AlignCenter + + + true + + + false + + + + QLayout::SetMinAndMaxSize + + + 6 + + + + + + 65536 + 65536 + + + + Qt::RightToLeft + + + background:none; + + + Yaw + + + + + + + + 65536 + 65536 + + + + Qt::RightToLeft + + + background:none; + + + TX + + + + + + + + 65536 + 65536 + + + + Qt::RightToLeft + + + false + + + background:none; + + + Pitch + + + + + + + + 65536 + 65536 + + + + Qt::RightToLeft + + + background:none; + + + TY + + + + + + + + 65536 + 65536 + + + + Qt::RightToLeft + + + background:none; + + + Roll + + + + + + + + 65536 + 65536 + + + + Qt::RightToLeft + + + background:none; + + + TZ + + + + + + + -- cgit v1.2.3 From 634e9aa811ed3823df83b25eb7b2a1f49e16ee78 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 5 Jan 2014 11:54:22 +0100 Subject: rename window titles following the fork --- facetracknoir/ftnoir_curves.ui | 2 +- facetracknoir/ftnoir_keyboardshortcuts.ui | 6 +++--- ftnoir_protocol_ftn/ftnoir_ftncontrols.ui | 4 ++-- ftnoir_tracker_joystick/ftnoir_tracker_joystick_controls.ui | 2 +- ftnoir_tracker_udp/ftnoir_ftnclientcontrols.ui | 8 ++++---- 5 files changed, 11 insertions(+), 11 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/ftnoir_curves.ui b/facetracknoir/ftnoir_curves.ui index ae84110f..68d8720d 100644 --- a/facetracknoir/ftnoir_curves.ui +++ b/facetracknoir/ftnoir_curves.ui @@ -17,7 +17,7 @@ - FaceTrackNoIR tracking curves + Mapping properties diff --git a/facetracknoir/ftnoir_keyboardshortcuts.ui b/facetracknoir/ftnoir_keyboardshortcuts.ui index 1477d56d..0d4e9142 100644 --- a/facetracknoir/ftnoir_keyboardshortcuts.ui +++ b/facetracknoir/ftnoir_keyboardshortcuts.ui @@ -6,8 +6,8 @@ 0 0 - 360 - 124 + 371 + 131 @@ -17,7 +17,7 @@ - FaceTrackNoIR Keyboard and Mouse shortcuts + Keyboard shortcuts diff --git a/ftnoir_protocol_ftn/ftnoir_ftncontrols.ui b/ftnoir_protocol_ftn/ftnoir_ftncontrols.ui index 15bc5531..ac6988d7 100644 --- a/ftnoir_protocol_ftn/ftnoir_ftncontrols.ui +++ b/ftnoir_protocol_ftn/ftnoir_ftncontrols.ui @@ -10,11 +10,11 @@ 0 0 411 - 162 + 169 - FTNoIR protocol settings FaceTrackNoIR + UDP protocol settings diff --git a/ftnoir_tracker_joystick/ftnoir_tracker_joystick_controls.ui b/ftnoir_tracker_joystick/ftnoir_tracker_joystick_controls.ui index a19a3cad..e1f1d28c 100644 --- a/ftnoir_tracker_joystick/ftnoir_tracker_joystick_controls.ui +++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick_controls.ui @@ -20,7 +20,7 @@ - FTNoIR tracker settings FaceTrackNoIR + Joystick protcool settings diff --git a/ftnoir_tracker_udp/ftnoir_ftnclientcontrols.ui b/ftnoir_tracker_udp/ftnoir_ftnclientcontrols.ui index 842ccb81..6c71b50b 100644 --- a/ftnoir_tracker_udp/ftnoir_ftnclientcontrols.ui +++ b/ftnoir_tracker_udp/ftnoir_ftnclientcontrols.ui @@ -10,11 +10,11 @@ 0 0 411 - 222 + 232 - FTNoIR tracker settings FaceTrackNoIR + UDP tracker settings @@ -77,8 +77,8 @@ 10 20 - 143 - 64 + 147 + 68 -- cgit v1.2.3 From cc3a10f7117b11b4b3f2644224ae728e395a9e9b Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 5 Jan 2014 12:14:21 +0100 Subject: change icons, remove self-references --- FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui | 2 +- FTNoIR_Tracker_PT/Resources/icon.ico | Bin 4286 -> 0 bytes FTNoIR_Tracker_PT/ftnoir_tracker_pt.qrc | 19 ++++---- facetracknoir/facetracknoir.cpp | 2 +- facetracknoir/facetracknoir.ui | 48 ++++++++++----------- facetracknoir/ftnoir_keyboardshortcuts.ui | 2 +- .../uielements/logo_facetracknoir_32px.jpg | Bin 1082 -> 0 bytes .../uielements/logo_facetracknoir_32px.png | Bin 2822 -> 0 bytes facetracknoir/uielements/logo_noir.png | Bin 26173 -> 0 bytes facetracknoir/uielements/logo_noir_small.png | Bin 6384 -> 0 bytes .../uielements/logo_noir_small_target.png | Bin 5971 -> 0 bytes .../uielements/logo_noir_small_target90px.png | Bin 5582 -> 0 bytes facetracknoir/uielements/logofacetracknoir.png | Bin 5437 -> 0 bytes facetracknoir/uielements/logofacetracknoir60px.png | Bin 3369 -> 0 bytes .../ftnoir_accela_filtercontrols.ui | 14 +++--- ftnoir_filter_ewma2/ftnoir_ewma_filtercontrols.ui | 16 +++---- .../ftnoir_kalman_filtercontrols.ui | 12 +++--- ftnoir_protocol_fg/ftnoir_fgcontrols.ui | 12 +++--- ftnoir_protocol_ft/ftnoir_ftcontrols.ui | 12 +++--- ftnoir_protocol_ftn/ftn-protocol.qrc | 5 --- ftnoir_protocol_ftn/ftnoir_ftncontrols.ui | 8 ++-- ftnoir_protocol_ftn/images/facetracknoir.png | Bin 634 -> 0 bytes ftnoir_protocol_mouse/ftnoir_mousecontrols.ui | 14 +++--- .../ftnoir_tracker_joystick_controls.ui | 4 +- ftnoir_tracker_udp/ftnoir_ftnclientcontrols.ui | 2 +- 25 files changed, 87 insertions(+), 85 deletions(-) delete mode 100644 FTNoIR_Tracker_PT/Resources/icon.ico delete mode 100644 facetracknoir/uielements/logo_facetracknoir_32px.jpg delete mode 100644 facetracknoir/uielements/logo_facetracknoir_32px.png delete mode 100644 facetracknoir/uielements/logo_noir.png delete mode 100644 facetracknoir/uielements/logo_noir_small.png delete mode 100644 facetracknoir/uielements/logo_noir_small_target.png delete mode 100644 facetracknoir/uielements/logo_noir_small_target90px.png delete mode 100644 facetracknoir/uielements/logofacetracknoir.png delete mode 100644 facetracknoir/uielements/logofacetracknoir60px.png delete mode 100644 ftnoir_protocol_ftn/ftn-protocol.qrc delete mode 100644 ftnoir_protocol_ftn/images/facetracknoir.png (limited to 'facetracknoir') diff --git a/FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui b/FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui index ce708849..9f00cf29 100644 --- a/FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui +++ b/FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui @@ -24,7 +24,7 @@ - :/Resources/icon.ico:/Resources/icon.ico + :/Resources/Logo_IR.png:/Resources/Logo_IR.png Qt::LeftToRight diff --git a/FTNoIR_Tracker_PT/Resources/icon.ico b/FTNoIR_Tracker_PT/Resources/icon.ico deleted file mode 100644 index c4b2aedc..00000000 Binary files a/FTNoIR_Tracker_PT/Resources/icon.ico and /dev/null differ diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.qrc b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.qrc index 9b510981..a8f9a1af 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.qrc +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.qrc @@ -1,10 +1,9 @@ - - - Resources/icon.ico - Resources/cap_front.png - Resources/cap_side.png - Resources/clip_front.png - Resources/clip_side.png - Resources/Logo_IR.png - - + + + Resources/cap_front.png + Resources/cap_side.png + Resources/clip_front.png + Resources/clip_side.png + Resources/Logo_IR.png + + diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index de5b491f..f2767587 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -246,7 +246,7 @@ void FaceTrackNoIR::open() { QString fileName = dialog.getOpenFileName( this, - tr("Select one FTNoir settings file"), + tr("Open the settings file"), QCoreApplication::applicationDirPath() + "/settings/", tr("Settings file (*.ini);;All Files (*)"), NULL); diff --git a/facetracknoir/facetracknoir.ui b/facetracknoir/facetracknoir.ui index c25ee0db..d5300b0f 100644 --- a/facetracknoir/facetracknoir.ui +++ b/facetracknoir/facetracknoir.ui @@ -10,8 +10,8 @@ 0 0 - 788 - 554 + 790 + 500 @@ -82,8 +82,8 @@ - 5 - 170 + 10 + 130 320 240 @@ -113,7 +113,7 @@ 0 - -10 + 0 320 240 @@ -141,8 +141,8 @@ - 110 - 50 + 100 + 10 229 121 @@ -516,8 +516,8 @@ - 20 - 50 + 10 + 20 81 100 @@ -545,7 +545,7 @@ 350 - 370 + 270 191 91 @@ -631,7 +631,7 @@ 580 - 460 + 390 171 38 @@ -677,9 +677,9 @@ - 130 - 30 - 651 + 370 + 40 + 411 20 @@ -702,9 +702,9 @@ - 350 - 270 - 191 + 550 + 210 + 231 91 @@ -868,9 +868,9 @@ - 130 - 0 - 651 + 370 + 10 + 411 25 @@ -980,7 +980,7 @@ 350 - 470 + 400 190 65 @@ -1060,7 +1060,7 @@ 580 - 410 + 340 171 38 @@ -1228,7 +1228,7 @@ 10 - 420 + 380 141 106 @@ -1468,7 +1468,7 @@ 160 - 420 + 380 161 111 diff --git a/facetracknoir/ftnoir_keyboardshortcuts.ui b/facetracknoir/ftnoir_keyboardshortcuts.ui index 0d4e9142..94d11734 100644 --- a/facetracknoir/ftnoir_keyboardshortcuts.ui +++ b/facetracknoir/ftnoir_keyboardshortcuts.ui @@ -21,7 +21,7 @@ - images/FaceTrackNoIR.pngimages/FaceTrackNoIR.png + images/facetracknoir.pngimages/facetracknoir.png Qt::LeftToRight diff --git a/facetracknoir/uielements/logo_facetracknoir_32px.jpg b/facetracknoir/uielements/logo_facetracknoir_32px.jpg deleted file mode 100644 index 73ead853..00000000 Binary files a/facetracknoir/uielements/logo_facetracknoir_32px.jpg and /dev/null differ diff --git a/facetracknoir/uielements/logo_facetracknoir_32px.png b/facetracknoir/uielements/logo_facetracknoir_32px.png deleted file mode 100644 index c4e63c76..00000000 Binary files a/facetracknoir/uielements/logo_facetracknoir_32px.png and /dev/null differ diff --git a/facetracknoir/uielements/logo_noir.png b/facetracknoir/uielements/logo_noir.png deleted file mode 100644 index bb654a07..00000000 Binary files a/facetracknoir/uielements/logo_noir.png and /dev/null differ diff --git a/facetracknoir/uielements/logo_noir_small.png b/facetracknoir/uielements/logo_noir_small.png deleted file mode 100644 index 5d49e0b1..00000000 Binary files a/facetracknoir/uielements/logo_noir_small.png and /dev/null differ diff --git a/facetracknoir/uielements/logo_noir_small_target.png b/facetracknoir/uielements/logo_noir_small_target.png deleted file mode 100644 index 4bbaf41f..00000000 Binary files a/facetracknoir/uielements/logo_noir_small_target.png and /dev/null differ diff --git a/facetracknoir/uielements/logo_noir_small_target90px.png b/facetracknoir/uielements/logo_noir_small_target90px.png deleted file mode 100644 index ecaa4e12..00000000 Binary files a/facetracknoir/uielements/logo_noir_small_target90px.png and /dev/null differ diff --git a/facetracknoir/uielements/logofacetracknoir.png b/facetracknoir/uielements/logofacetracknoir.png deleted file mode 100644 index a1a3407b..00000000 Binary files a/facetracknoir/uielements/logofacetracknoir.png and /dev/null differ diff --git a/facetracknoir/uielements/logofacetracknoir60px.png b/facetracknoir/uielements/logofacetracknoir60px.png deleted file mode 100644 index f01f6024..00000000 Binary files a/facetracknoir/uielements/logofacetracknoir60px.png and /dev/null differ diff --git a/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui b/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui index 4ea78c9f..ba750cd6 100644 --- a/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui +++ b/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui @@ -9,8 +9,8 @@ 0 0 - 202 - 241 + 215 + 285 @@ -32,11 +32,11 @@ - Filter settings + Accela filter settings - - images/FaceTrackNoIR.pngimages/FaceTrackNoIR.png + + :/images/filter-16.png:/images/filter-16.png Qt::LeftToRight @@ -346,7 +346,9 @@ background:none; - + + + startEngineClicked() diff --git a/ftnoir_filter_ewma2/ftnoir_ewma_filtercontrols.ui b/ftnoir_filter_ewma2/ftnoir_ewma_filtercontrols.ui index 8a0e485a..a1083265 100644 --- a/ftnoir_filter_ewma2/ftnoir_ewma_filtercontrols.ui +++ b/ftnoir_filter_ewma2/ftnoir_ewma_filtercontrols.ui @@ -9,7 +9,7 @@ 0 0 - 374 + 477 380 @@ -20,15 +20,11 @@ - EWMA2 Filter settings FaceTrackNoIR + EWMA2 filter settings - - - images/facetracknoir.png - - images/facetracknoir.png - + + :/images/filter-16.png:/images/filter-16.png Qt::LeftToRight @@ -486,7 +482,9 @@ p, li { white-space: pre-wrap; } btnOK btnCancel - + + + minSmooth diff --git a/ftnoir_filter_kalman/ftnoir_kalman_filtercontrols.ui b/ftnoir_filter_kalman/ftnoir_kalman_filtercontrols.ui index d1cff81e..a9fdec6e 100644 --- a/ftnoir_filter_kalman/ftnoir_kalman_filtercontrols.ui +++ b/ftnoir_filter_kalman/ftnoir_kalman_filtercontrols.ui @@ -20,13 +20,11 @@ - Filter settings + Kalman settings - - - images/facetracknoir.png - images/facetracknoir.png + + :/images/filter-16.png:/images/filter-16.png Qt::LeftToRight @@ -64,7 +62,9 @@ - + + + diff --git a/ftnoir_protocol_fg/ftnoir_fgcontrols.ui b/ftnoir_protocol_fg/ftnoir_fgcontrols.ui index f3b54486..e351647b 100644 --- a/ftnoir_protocol_fg/ftnoir_fgcontrols.ui +++ b/ftnoir_protocol_fg/ftnoir_fgcontrols.ui @@ -9,16 +9,16 @@ 0 0 - 404 + 415 112 - FlightGear settings FaceTrackNoIR + FlightGear protocol settings - - images/FaceTrackNoIR.pngimages/FaceTrackNoIR.png + + :/images/filter-16.png:/images/filter-16.png Qt::LeftToRight @@ -131,7 +131,9 @@ spinIPFourthNibble spinPortNumber - + + + startEngineClicked() diff --git a/ftnoir_protocol_ft/ftnoir_ftcontrols.ui b/ftnoir_protocol_ft/ftnoir_ftcontrols.ui index f4d94ee8..39787d90 100644 --- a/ftnoir_protocol_ft/ftnoir_ftcontrols.ui +++ b/ftnoir_protocol_ft/ftnoir_ftcontrols.ui @@ -13,7 +13,7 @@ 0 0 407 - 347 + 414 @@ -29,11 +29,11 @@ - FreeTrack 2.0 settings FaceTrackNoIR + freetrack protocol settings - - images/FaceTrackNoIR.icoimages/FaceTrackNoIR.ico + + :/images/freetrack.png:/images/freetrack.png Qt::LeftToRight @@ -214,7 +214,9 @@ - + + + startEngineClicked() diff --git a/ftnoir_protocol_ftn/ftn-protocol.qrc b/ftnoir_protocol_ftn/ftn-protocol.qrc deleted file mode 100644 index 18ae0aae..00000000 --- a/ftnoir_protocol_ftn/ftn-protocol.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - images/facetracknoir.png - - diff --git a/ftnoir_protocol_ftn/ftnoir_ftncontrols.ui b/ftnoir_protocol_ftn/ftnoir_ftncontrols.ui index ac6988d7..429e7046 100644 --- a/ftnoir_protocol_ftn/ftnoir_ftncontrols.ui +++ b/ftnoir_protocol_ftn/ftnoir_ftncontrols.ui @@ -17,8 +17,8 @@ UDP protocol settings - - images/FaceTrackNoIR.pngimages/FaceTrackNoIR.png + + :/images/facetracknoir.png:/images/facetracknoir.png Qt::LeftToRight @@ -254,7 +254,9 @@ btnOK btnCancel - + + + startEngineClicked() diff --git a/ftnoir_protocol_ftn/images/facetracknoir.png b/ftnoir_protocol_ftn/images/facetracknoir.png deleted file mode 100644 index b69a13ef..00000000 Binary files a/ftnoir_protocol_ftn/images/facetracknoir.png and /dev/null differ diff --git a/ftnoir_protocol_mouse/ftnoir_mousecontrols.ui b/ftnoir_protocol_mouse/ftnoir_mousecontrols.ui index ee15ded2..540e4f0d 100644 --- a/ftnoir_protocol_mouse/ftnoir_mousecontrols.ui +++ b/ftnoir_protocol_mouse/ftnoir_mousecontrols.ui @@ -9,16 +9,16 @@ 0 0 - 250 - 112 + 257 + 114 - MouseLook settings FaceTrackNoIR + Mouse protocol settings - - :/images/Mouse.png:/images/Mouse.png + + :/images/mouse.png:/images/mouse.png Qt::LeftToRight @@ -193,7 +193,9 @@ - + + + startEngineClicked() diff --git a/ftnoir_tracker_joystick/ftnoir_tracker_joystick_controls.ui b/ftnoir_tracker_joystick/ftnoir_tracker_joystick_controls.ui index e1f1d28c..a0fa43d3 100644 --- a/ftnoir_tracker_joystick/ftnoir_tracker_joystick_controls.ui +++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick_controls.ui @@ -20,11 +20,11 @@ - Joystick protcool settings + Joystick protocol settings - images/FaceTrackNoIR.pngimages/FaceTrackNoIR.png + ../facetracknoir/images/facetracknoir.png../facetracknoir/images/facetracknoir.png Qt::LeftToRight diff --git a/ftnoir_tracker_udp/ftnoir_ftnclientcontrols.ui b/ftnoir_tracker_udp/ftnoir_ftnclientcontrols.ui index 6c71b50b..fc614477 100644 --- a/ftnoir_tracker_udp/ftnoir_ftnclientcontrols.ui +++ b/ftnoir_tracker_udp/ftnoir_ftnclientcontrols.ui @@ -18,7 +18,7 @@ - images/FaceTrackNoIR.pngimages/FaceTrackNoIR.png + ../facetracknoir/images/facetracknoir.png../facetracknoir/images/facetracknoir.png Qt::LeftToRight -- cgit v1.2.3 From 9f441ef3fc6a001dcada7b8d5718bf9023a07334 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 5 Jan 2014 12:32:54 +0100 Subject: remove empty dtor --- facetracknoir/tracker.cpp | 4 ---- facetracknoir/tracker.h | 1 - 2 files changed, 5 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/tracker.cpp b/facetracknoir/tracker.cpp index ae4398ff..fa1cdee1 100644 --- a/facetracknoir/tracker.cpp +++ b/facetracknoir/tracker.cpp @@ -31,10 +31,6 @@ Tracker::Tracker(FaceTrackNoIR *parent , main_settings& s) : { } -Tracker::~Tracker() -{ -} - static void get_curve(double pos, double& out, THeadPoseDOF& axis) { bool altp = (pos < 0) && axis.opts.altp; if (altp) { diff --git a/facetracknoir/tracker.h b/facetracknoir/tracker.h index 404a8f24..da1b3372 100644 --- a/facetracknoir/tracker.h +++ b/facetracknoir/tracker.h @@ -64,7 +64,6 @@ protected: public: Tracker( FaceTrackNoIR *parent, main_settings& s); - ~Tracker(); void getHeadPose(double *data); void getOutputHeadPose(double *data); -- cgit v1.2.3 From e509f882253e0bbb597efaa749af40760c89437c Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 5 Jan 2014 12:54:10 +0100 Subject: allow for debugging setting modified state firing --- facetracknoir/options.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'facetracknoir') diff --git a/facetracknoir/options.h b/facetracknoir/options.h index edcbf193..9663a5e8 100644 --- a/facetracknoir/options.h +++ b/facetracknoir/options.h @@ -147,6 +147,8 @@ namespace options { QMutexLocker l(&mtx); if (!transient.contains(name) || datum != transient.get(name)) { + if (!modified) + qDebug() << name << transient.get(name) << datum; modified = true; transient.put(name, datum); emit bundleChanged(); -- cgit v1.2.3 From 0a90675abdba52ac175f0ff4d841f4f3fcc5a6d4 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 5 Jan 2014 12:54:24 +0100 Subject: be bit more careful with signals firing --- facetracknoir/options.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/options.h b/facetracknoir/options.h index 9663a5e8..7c5e57ef 100644 --- a/facetracknoir/options.h +++ b/facetracknoir/options.h @@ -253,65 +253,65 @@ namespace options { template<> inline void tie_setting(value& v, QComboBox* cb) { + cb->setCurrentIndex(v); base_value::connect(cb, SIGNAL(currentIndexChanged(int)), &v, SLOT(setValue(int)), v.CONNTYPE); base_value::connect(&v, SIGNAL(valueChanged(int)), cb, SLOT(setCurrentIndex(int)), v.CONNTYPE); - cb->setCurrentIndex(v); } template<> inline void tie_setting(value& v, QComboBox* cb) { + cb->setCurrentText(v); + v = cb->currentText(); base_value::connect(cb, SIGNAL(currentTextChanged(QString)), &v, SLOT(setValue(QString)), v.CONNTYPE); base_value::connect(&v, SIGNAL(valueChanged(QString)), cb, SLOT(setCurrentText(QString)), v.CONNTYPE); - cb->setCurrentText(v); - v = cb->currentText(); } template<> inline void tie_setting(value& v, QCheckBox* cb) { + cb->setChecked(v); base_value::connect(cb, SIGNAL(toggled(bool)), &v, SLOT(setValue(bool)), v.CONNTYPE); base_value::connect(&v, SIGNAL(valueChanged(bool)), cb, SLOT(setChecked(bool)), v.CONNTYPE); - cb->setChecked(v); } template<> inline void tie_setting(value& v, QDoubleSpinBox* dsb) { + dsb->setValue(v); base_value::connect(dsb, SIGNAL(valueChanged(double)), &v, SLOT(setValue(double)), v.CONNTYPE); base_value::connect(&v, SIGNAL(valueChanged(double)), dsb, SLOT(setValue(double)), v.CONNTYPE); - dsb->setValue(v); } template<> inline void tie_setting(value& v, QSpinBox* sb) { + sb->setValue(v); base_value::connect(sb, SIGNAL(valueChanged(int)), &v, SLOT(setValue(int)), v.CONNTYPE); base_value::connect(&v, SIGNAL(valueChanged(int)), sb, SLOT(setValue(int)), v.CONNTYPE); - sb->setValue(v); } template<> inline void tie_setting(value& v, QSlider* sl) { + sl->setValue(v); base_value::connect(sl, SIGNAL(valueChanged(int)), &v, SLOT(setValue(int)), v.CONNTYPE); base_value::connect(&v, SIGNAL(valueChanged(int)), sl, SLOT(setValue(int)), v.CONNTYPE); - sl->setValue(v); } template<> inline void tie_setting(value& v, QLineEdit* le) { + le->setText(v); base_value::connect(le, SIGNAL(textChanged(QString)), &v, SLOT(setValue(QString)), v.CONNTYPE); base_value::connect(&v, SIGNAL(valueChanged(QString)),le, SLOT(setText(QString)), v.CONNTYPE); - le->setText(v); } template<> inline void tie_setting(value& v, QLabel* lb) { - base_value::connect(&v, SIGNAL(valueChanged(QString)), lb, SLOT(setText(QString)), v.CONNTYPE); lb->setText(v); + base_value::connect(&v, SIGNAL(valueChanged(QString)), lb, SLOT(setText(QString)), v.CONNTYPE); } inline pbundle bundle(const QString& group) { -- cgit v1.2.3 From 359fec379f1618766d7f39be12f3b48b0d771c69 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 5 Jan 2014 12:55:01 +0100 Subject: don't modify state by glorified tracker name --- facetracknoir/facetracknoir.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index f2767587..ccbdbb4a 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -137,9 +137,9 @@ FaceTrackNoIR::FaceTrackNoIR(QWidget *parent) : connect(ui.btnShowServerControls, SIGNAL(clicked()), this, SLOT(showServerControls())); connect(ui.btnShowFilterControls, SIGNAL(clicked()), this, SLOT(showFilterControls())); - ui.cbxSecondTrackerSource->addItem(QIcon(), "None"); + ui.cbxSecondTrackerSource->addItem(QIcon(), ""); dlopen_filters.push_back((DynamicLibrary*) NULL); - ui.iconcomboFilter->addItem(QIcon(), "None"); + ui.iconcomboFilter->addItem(QIcon(), ""); fill_combobox("opentrack-proto-*.", dlopen_protocols, ui.iconcomboProtocol, NULL); fill_combobox("opentrack-tracker-*.", dlopen_trackers, ui.iconcomboTrackerSource, ui.cbxSecondTrackerSource); -- cgit v1.2.3 From bbe8552db3fb0d7ab2c3a26b058c059e5df21eeb Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 5 Jan 2014 12:55:11 +0100 Subject: decruft --- facetracknoir/curve-config.cpp | 22 +--------------------- facetracknoir/curve-config.h | 4 +--- 2 files changed, 2 insertions(+), 24 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/curve-config.cpp b/facetracknoir/curve-config.cpp index d730e4f7..b01c2013 100644 --- a/facetracknoir/curve-config.cpp +++ b/facetracknoir/curve-config.cpp @@ -43,29 +43,11 @@ CurveConfigurationDialog::CurveConfigurationDialog(FaceTrackNoIR *ftnoir, QWidge loadSettings(); } -// -// Destructor for server-dialog -// -CurveConfigurationDialog::~CurveConfigurationDialog() { - qDebug() << "~CurveConfigurationDialog() says: started"; -} - -// -// OK clicked on server-dialog -// void CurveConfigurationDialog::doOK() { save(); this->close(); } -// override show event -void CurveConfigurationDialog::showEvent ( QShowEvent * ) { - loadSettings(); -} - -// -// Cancel clicked on server-dialog -// void CurveConfigurationDialog::doCancel() { // // Ask if changed Settings should be saved @@ -73,9 +55,7 @@ void CurveConfigurationDialog::doCancel() { if (settingsDirty || mainApp->s.b->modifiedp()) { int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard ); - qDebug() << "doCancel says: answer =" << ret; - - switch (ret) { + switch (ret) { case QMessageBox::Save: save(); this->close(); diff --git a/facetracknoir/curve-config.h b/facetracknoir/curve-config.h index d2acf371..950f6d14 100644 --- a/facetracknoir/curve-config.h +++ b/facetracknoir/curve-config.h @@ -9,9 +9,7 @@ class CurveConfigurationDialog: public QWidget { Q_OBJECT public: - explicit CurveConfigurationDialog( FaceTrackNoIR *ftnoir, QWidget *parent ); - virtual ~CurveConfigurationDialog(); - void showEvent ( QShowEvent * event ); + CurveConfigurationDialog( FaceTrackNoIR *ftnoir, QWidget *parent ); void loadSettings(); private: Ui::UICCurveConfigurationDialog ui; -- cgit v1.2.3 From 449625118b3d28baabcdb001595a7dec2f8e3593 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 5 Jan 2014 13:02:52 +0100 Subject: remove settings dialog copypasted all over, losing functionality --- FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.cpp | 25 ++---------------- facetracknoir/curve-config.cpp | 28 ++------------------ facetracknoir/shortcuts.cpp | 27 ++----------------- .../ftnoir_filter_accela_dialog.cpp | 27 ++----------------- ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp | 27 ++----------------- ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp | 23 ++--------------- .../ftnoir_protocol_fsuipc_dialog.cpp | 24 ++--------------- ftnoir_protocol_ft/ftnoir_protocol_ft_dialog.cpp | 30 ++-------------------- ftnoir_protocol_ftn/ftnoir_protocol_ftn_dialog.cpp | 21 ++------------- .../ftnoir_protocol_mouse_dialog.cpp | 26 ++----------------- ftnoir_protocol_sc/ftnoir_protocol_sc_dialog.cpp | 22 ++-------------- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 26 ++----------------- .../ftnoir_tracker_hat_dialog.cpp | 27 ++----------------- ftnoir_tracker_ht/ftnoir_tracker_ht.cpp | 25 ++---------------- .../ftnoir_tracker_hydra_dialog.cpp | 26 ++----------------- .../ftnoir_tracker_joystick_dialog.cpp | 27 ++----------------- ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp | 24 ++--------------- ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp | 24 ++--------------- 18 files changed, 36 insertions(+), 423 deletions(-) (limited to 'facetracknoir') diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.cpp b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.cpp index 06f7b2c6..c103b78c 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.cpp +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.cpp @@ -225,29 +225,8 @@ void TrackerDialog::doApply() void TrackerDialog::doCancel() { - if (s.b->modifiedp()) { - int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", - QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard ); - switch (ret) { - case QMessageBox::Save: - save(); - close(); - break; - case QMessageBox::Discard: - s.b->revert(); - close(); - break; - case QMessageBox::Cancel: - // Cancel was clicked - break; - default: - // should never be reached - break; - } - } - else { - close(); - } + s.b->revert(); + close(); } void TrackerDialog::widget_destroyed(QObject* obj) diff --git a/facetracknoir/curve-config.cpp b/facetracknoir/curve-config.cpp index b01c2013..f5ed6aa7 100644 --- a/facetracknoir/curve-config.cpp +++ b/facetracknoir/curve-config.cpp @@ -49,32 +49,8 @@ void CurveConfigurationDialog::doOK() { } void CurveConfigurationDialog::doCancel() { - // - // Ask if changed Settings should be saved - // - if (settingsDirty || mainApp->s.b->modifiedp()) { - int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard ); - - switch (ret) { - case QMessageBox::Save: - save(); - this->close(); - break; - case QMessageBox::Discard: - mainApp->s.b->revert(); - this->close(); - break; - case QMessageBox::Cancel: - // Cancel was clicked - break; - default: - // should never be reached - break; - } - } - else { - this->close(); - } + mainApp->b->revert(); + close(); } // diff --git a/facetracknoir/shortcuts.cpp b/facetracknoir/shortcuts.cpp index 2f117ea4..a905be57 100644 --- a/facetracknoir/shortcuts.cpp +++ b/facetracknoir/shortcuts.cpp @@ -42,31 +42,8 @@ void KeyboardShortcutDialog::doOK() { } void KeyboardShortcutDialog::doCancel() { - // - // Ask if changed Settings should be saved - // - if (mainApp->b->modifiedp()) { - int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel); - - qDebug() << "doCancel says: answer =" << ret; - - switch (ret) { - case QMessageBox::Save: - mainApp->b->save(); - this->close(); - break; - case QMessageBox::Discard: - mainApp->b->revert(); - close(); - break; - case QMessageBox::Cancel: - default: - break; - } - } - else { - this->close(); - } + mainApp->b->revert(); + close(); } #if defined(_WIN32) diff --git a/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp b/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp index 6d1ad384..56b76a55 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp @@ -36,33 +36,10 @@ void FilterControls::doOK() { } void FilterControls::doCancel() { - if (!s.b->modifiedp()) - { - close(); - return; - } - int ret = - QMessageBox::question( this, - "Settings have changed", - "Do you want to save the settings?", - QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel); - - switch (ret) { - case QMessageBox::Save: - save(); - this->close(); - break; - case QMessageBox::Discard: - this->discard(); - this->close(); - break; - case QMessageBox::Cancel: - default: - break; - } + discard(); + close(); } - void FilterControls::discard() { s.b->revert(); diff --git a/ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp b/ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp index 7ab2b09c..395d1058 100644 --- a/ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp +++ b/ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp @@ -57,31 +57,8 @@ void FilterControls::doOK() { } void FilterControls::doCancel() { - // - // Ask if changed Settings should be saved - // - if (s.b->modifiedp()) { - int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel); - - qDebug() << "doCancel says: answer =" << ret; - - switch (ret) { - case QMessageBox::Save: - save(); - this->close(); - break; - case QMessageBox::Discard: - s.b->revert(); - this->close(); - break; - case QMessageBox::Cancel: - default: - break; - } - } - else { - this->close(); - } + s.b->revert(); + this->close(); } void FilterControls::save() { diff --git a/ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp b/ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp index 887020c5..1c3e5ef8 100644 --- a/ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp +++ b/ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp @@ -59,27 +59,8 @@ void FGControls::doOK() { } void FGControls::doCancel() { - if (s.b->modifiedp()) { - int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel ); - switch (ret) { - case QMessageBox::Save: - s.b->save(); - if (theProtocol) - theProtocol->reloadSettings(); - this->close(); - break; - case QMessageBox::Discard: - s.b->revert(); - close(); - break; - case QMessageBox::Cancel: - default: - break; - } - } - else { - this->close(); - } + s.b->revert(); + this->close(); } extern "C" FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDialog* CALLING_CONVENTION GetDialog( ) diff --git a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dialog.cpp b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dialog.cpp index bae3d5df..d97cff99 100644 --- a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dialog.cpp +++ b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dialog.cpp @@ -42,28 +42,8 @@ void FSUIPCControls::doOK() { } void FSUIPCControls::doCancel() { - if (s.b->modifiedp()) { - int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard ); - - qDebug() << "doCancel says: answer =" << ret; - - switch (ret) { - case QMessageBox::Save: - s.b->save(); - this->close(); - break; - case QMessageBox::Discard: - s.b->revert(); - this->close(); - break; - case QMessageBox::Cancel: - default: - break; - } - } - else { - this->close(); - } + s.b->revert(); + close(); } void FSUIPCControls::getLocationOfDLL() diff --git a/ftnoir_protocol_ft/ftnoir_protocol_ft_dialog.cpp b/ftnoir_protocol_ft/ftnoir_protocol_ft_dialog.cpp index b414561d..7f070857 100644 --- a/ftnoir_protocol_ft/ftnoir_protocol_ft_dialog.cpp +++ b/ftnoir_protocol_ft/ftnoir_protocol_ft_dialog.cpp @@ -69,34 +69,8 @@ void FTControls::doOK() { } void FTControls::doCancel() { - // - // Ask if changed Settings should be saved - // - if (s.b->modifiedp()) { - int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel); - - qDebug() << "doCancel says: answer =" << ret; - - switch (ret) { - case QMessageBox::Save: - s.b->save(); - this->close(); - break; - case QMessageBox::Discard: - s.b->revert(); - this->close(); - break; - case QMessageBox::Cancel: - // Cancel was clicked - break; - default: - // should never be reached - break; - } - } - else { - this->close(); - } + s.b->revert(); + this->close(); } void FTControls::selectDLL() { diff --git a/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dialog.cpp b/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dialog.cpp index ce4b3cb0..37db314f 100644 --- a/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dialog.cpp +++ b/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dialog.cpp @@ -52,25 +52,8 @@ void FTNControls::doOK() { // Cancel clicked on server-dialog // void FTNControls::doCancel() { - if (s.b->modifiedp()) { - int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel); - switch (ret) { - case QMessageBox::Save: - s.b->save(); - this->close(); - break; - case QMessageBox::Discard: - s.b->revert(); - this->close(); - break; - case QMessageBox::Cancel: - default: - break; - } - } - else { - this->close(); - } + s.b->revert(); + this->close(); } extern "C" FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDialog* CALLING_CONVENTION GetDialog( ) diff --git a/ftnoir_protocol_mouse/ftnoir_protocol_mouse_dialog.cpp b/ftnoir_protocol_mouse/ftnoir_protocol_mouse_dialog.cpp index cc62b004..22b7024c 100644 --- a/ftnoir_protocol_mouse/ftnoir_protocol_mouse_dialog.cpp +++ b/ftnoir_protocol_mouse/ftnoir_protocol_mouse_dialog.cpp @@ -59,30 +59,8 @@ void MOUSEControls::doOK() { } void MOUSEControls::doCancel() { - if (s.b->modifiedp()) { - int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel); - - qDebug() << "doCancel says: answer =" << ret; - - switch (ret) { - case QMessageBox::Save: - s.b->save(); - this->close(); - if (_proto) - _proto->reload(); - break; - case QMessageBox::Discard: - s.b->revert(); - this->close(); - break; - case QMessageBox::Cancel: - default: - break; - } - } - else { - this->close(); - } + s.b->revert(); + this->close(); } extern "C" FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDialog* CALLING_CONVENTION GetDialog( ) diff --git a/ftnoir_protocol_sc/ftnoir_protocol_sc_dialog.cpp b/ftnoir_protocol_sc/ftnoir_protocol_sc_dialog.cpp index 6af87285..c7428d77 100644 --- a/ftnoir_protocol_sc/ftnoir_protocol_sc_dialog.cpp +++ b/ftnoir_protocol_sc/ftnoir_protocol_sc_dialog.cpp @@ -44,26 +44,8 @@ void SCControls::doOK() { } void SCControls::doCancel() { - if (s.b->modifiedp()) { - int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel); - - switch (ret) { - case QMessageBox::Save: - s.b->save(); - this->close(); - break; - case QMessageBox::Discard: - s.b->revert(); - this->close(); - break; - case QMessageBox::Cancel: - default: - break; - } - } - else { - this->close(); - } + s.b->revert(); + close(); } extern "C" FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDialog* CALLING_CONVENTION GetDialog( ) diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index 50496ed7..2edac4a2 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -472,28 +472,6 @@ void TrackerControls::doOK() void TrackerControls::doCancel() { - if (s.b->modifiedp()) { - int ret = QMessageBox::question ( this, - "Settings have changed", - "Do you want to save the settings?", - QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel ); - - switch (ret) { - case QMessageBox::Save: - s.b->save(); - this->close(); - if (tracker) - tracker->reload(); - break; - case QMessageBox::Discard: - s.b->revert(); - this->close(); - break; - case QMessageBox::Cancel: - break; - } - } - else { - this->close(); - } + s.b->revert(); + this->close(); } diff --git a/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.cpp b/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.cpp index 2ef75b89..83548966 100644 --- a/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.cpp +++ b/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.cpp @@ -238,31 +238,8 @@ void TrackerControls::doOK() { // Cancel clicked on server-dialog // void TrackerControls::doCancel() { - // - // Ask if changed Settings should be saved - // - if (settings.b->modifiedp()) { - int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel); - switch (ret) { - case QMessageBox::Save: - settings.b->save(); - close(); - break; - case QMessageBox::Discard: - settings.b->revert(); - close(); - break; - case QMessageBox::Cancel: - // Cancel was clicked - break; - default: - // should never be reached - break; - } - } - else { - close(); - } + settings.b->revert(); + close(); } diff --git a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp index 5fced44e..4ce56acc 100644 --- a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp +++ b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp @@ -286,27 +286,6 @@ void TrackerControls::doOK() void TrackerControls::doCancel() { - if (!s.b->modifiedp()) - { - close(); - return; - } - int ret = QMessageBox::question ( this, - "Settings have changed", - "Do you want to save the settings?", - QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel); - - switch (ret) { - case QMessageBox::Save: - s.b->save(); - this->close(); - break; - case QMessageBox::Discard: - s.b->revert(); - this->close(); - break; - default: - case QMessageBox::Cancel: - break; - } + s.b->revert(); + this->close(); } diff --git a/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dialog.cpp b/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dialog.cpp index 4a2deb9f..14be2c37 100644 --- a/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dialog.cpp +++ b/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dialog.cpp @@ -24,30 +24,8 @@ void TrackerControls::doOK() { } void TrackerControls::doCancel() { - if (!s.b->modifiedp()) - { - close(); - return; - } - int ret = QMessageBox::question (this, - "Settings have changed", - "Do you want to save the settings?", - QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel); - - switch (ret) { - case QMessageBox::Save: - s.b->save(); - this->close(); - break; - case QMessageBox::Discard: - s.b->revert(); - this->close(); - break; - default: - case QMessageBox::Cancel: - // Cancel was clicked - break; - } + s.b->revert(); + close(); } extern "C" FTNOIR_TRACKER_BASE_EXPORT ITrackerDialog* CALLING_CONVENTION GetDialog( ) diff --git a/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp b/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp index a089385f..b0766634 100644 --- a/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp +++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp @@ -56,31 +56,8 @@ void TrackerControls::doOK() { } void TrackerControls::doCancel() { - if (s.b->modifiedp()) { - int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel ); - - switch (ret) { - case QMessageBox::Save: - s.b->save(); - if (tracker) - tracker->reload(); - this->close(); - break; - case QMessageBox::Discard: - s.b->reload(); - this->close(); - break; - case QMessageBox::Cancel: - // Cancel was clicked - break; - default: - // should never be reached - break; - } - } - else { - this->close(); - } + s.b->revert(); + this->close(); } extern "C" FTNOIR_TRACKER_BASE_EXPORT ITrackerDialog* CALLING_CONVENTION GetDialog( ) diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp b/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp index 763ddd11..ad532100 100644 --- a/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp +++ b/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp @@ -26,28 +26,8 @@ void TrackerControls::doOK() { } void TrackerControls::doCancel() { - // - // Ask if changed Settings should be saved - // - if (s.b->modifiedp()) { - int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel); - switch (ret) { - case QMessageBox::Save: - s.b->save(); - this->close(); - break; - case QMessageBox::Discard: - s.b->revert(); - this->close(); - break; - case QMessageBox::Cancel: - default: - break; - } - } - else { - this->close(); - } + s.b->revert(); + close(); } extern "C" FTNOIR_TRACKER_BASE_EXPORT ITrackerDialog* CALLING_CONVENTION GetDialog( ) diff --git a/ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp b/ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp index 59026288..8d1b99f2 100644 --- a/ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp +++ b/ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp @@ -48,28 +48,8 @@ void TrackerControls::doOK() { } void TrackerControls::doCancel() { - if (s.b->modifiedp()) { - int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel); - switch (ret) { - case QMessageBox::Save: - s.b->save(); - this->close(); - break; - case QMessageBox::Discard: - s.b->revert(); - this->close(); - break; - case QMessageBox::Cancel: - // Cancel was clicked - break; - default: - // should never be reached - break; - } - } - else { - this->close(); - } + s.b->revert(); + this->close(); } extern "C" FTNOIR_TRACKER_BASE_EXPORT ITrackerDialog* CALLING_CONVENTION GetDialog( ) -- cgit v1.2.3 From 8b478090250cd0b1b3195ea42eb9feccca99f077 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 5 Jan 2014 14:35:18 +0100 Subject: remove unused member variable --- facetracknoir/options.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/options.h b/facetracknoir/options.h index 7c5e57ef..057e97af 100644 --- a/facetracknoir/options.h +++ b/facetracknoir/options.h @@ -221,8 +221,6 @@ namespace options { template class value : public base_value { - private: - T def; protected: QVariant operator=(const QVariant& datum) { auto foo = qcruft_to_t(datum); @@ -233,7 +231,7 @@ namespace options { public: static constexpr const Qt::ConnectionType CONNTYPE = Qt::QueuedConnection; value(pbundle b, const QString& name, T def) : - base_value(b, name), def(def) + base_value(b, name) { if (!b->contains(name) || b->get(name).type() == QVariant::Invalid) { -- cgit v1.2.3 From 90b5ad85a6a4e3d96e0272ff8319d3198a338ada Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 5 Jan 2014 16:07:01 +0100 Subject: hopefully prevent busy-looping when changing profile directories --- facetracknoir/facetracknoir.cpp | 8 ++++---- facetracknoir/facetracknoir.h | 4 +--- 2 files changed, 5 insertions(+), 7 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index ccbdbb4a..bf1416ad 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -126,6 +126,8 @@ FaceTrackNoIR::FaceTrackNoIR(QWidget *parent) : QDir::setCurrent(QCoreApplication::applicationDirPath()); + fill_profile_cbx(); + connect(ui.btnLoad, SIGNAL(clicked()), this, SLOT(open())); connect(ui.btnSave, SIGNAL(clicked()), this, SLOT(save())); connect(ui.btnSaveAs, SIGNAL(clicked()), this, SLOT(saveAs())); @@ -165,8 +167,6 @@ FaceTrackNoIR::FaceTrackNoIR(QWidget *parent) : connect(&kbd_quit, SIGNAL(activated()), this, SLOT(exit())); kbd_quit.setEnabled(true); - - fill_profile_cbx(); } FaceTrackNoIR::~FaceTrackNoIR() { @@ -256,8 +256,10 @@ void FaceTrackNoIR::open() { QSettings settings("opentrack"); settings.setValue ("SettingsFile", QFileInfo(fileName).absoluteFilePath()); } + looping = true; fill_profile_cbx(); loadSettings(); + looping = false; } } @@ -569,7 +571,6 @@ void FaceTrackNoIR::fill_profile_cbx() { if (looping) return; - looping = true; QSettings settings("opentrack"); QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); qDebug() << "Config file now" << currentFile; @@ -586,7 +587,6 @@ void FaceTrackNoIR::fill_profile_cbx() ui.iconcomboProfile->setCurrentIndex( i ); } } - looping = false; } void FaceTrackNoIR::profileSelected(int index) diff --git a/facetracknoir/facetracknoir.h b/facetracknoir/facetracknoir.h index 53b83754..0c251c46 100644 --- a/facetracknoir/facetracknoir.h +++ b/facetracknoir/facetracknoir.h @@ -139,10 +139,8 @@ private: #ifndef _WIN32 void bind_keyboard_shortcut(QxtGlobalShortcut&, key_opts& k); #endif - - bool looping; - void fill_profile_cbx(); + bool looping; private slots: void open(); -- cgit v1.2.3 From 796dfcb06bfa6a0bf56c85e8794e1a084e48b9e6 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 5 Jan 2014 16:18:27 +0100 Subject: fix the issue at all call sites --- facetracknoir/facetracknoir.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index bf1416ad..b83f59d7 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -286,6 +286,7 @@ void FaceTrackNoIR::save() { void FaceTrackNoIR::saveAs() { + looping = true; QSettings settings("opentrack"); QString oldFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); @@ -311,6 +312,7 @@ void FaceTrackNoIR::saveAs() } fill_profile_cbx(); + looping = false; } void FaceTrackNoIR::loadSettings() { -- cgit v1.2.3 From f4a13abcb2d93ebd8fda42064cfda59e901a5a76 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 5 Jan 2014 19:09:06 +0100 Subject: resize filter groupbox --- facetracknoir/facetracknoir.ui | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.ui b/facetracknoir/facetracknoir.ui index d5300b0f..b257ae30 100644 --- a/facetracknoir/facetracknoir.ui +++ b/facetracknoir/facetracknoir.ui @@ -39,7 +39,7 @@ opentrack - + :/images/facetracknoir.png:/images/facetracknoir.png @@ -702,16 +702,16 @@ - 550 + 580 210 - 231 + 171 91 - 180 - 80 + 0 + 0 @@ -1721,7 +1721,6 @@ - -- cgit v1.2.3 From f678d7f63800dd200dcfa6938e806778cf1e3aeb Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 5 Jan 2014 19:11:06 +0100 Subject: remove dead code --- facetracknoir/curve-config.cpp | 4 ---- facetracknoir/curve-config.h | 4 ---- 2 files changed, 8 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/curve-config.cpp b/facetracknoir/curve-config.cpp index f5ed6aa7..7840ab96 100644 --- a/facetracknoir/curve-config.cpp +++ b/facetracknoir/curve-config.cpp @@ -89,8 +89,6 @@ void CurveConfigurationDialog::loadSettings() { connect(configs[i], SIGNAL(CurveChanged(bool)), this, SLOT(curveChanged(bool)), Qt::UniqueConnection); connect(alt_configs[i], SIGNAL(CurveChanged(bool)), this, SLOT(curveChanged(bool)), Qt::UniqueConnection); } - - settingsDirty = false; } // @@ -119,6 +117,4 @@ void CurveConfigurationDialog::save() { ui.rxconfig_alt->saveSettings(currentFile); ui.ryconfig_alt->saveSettings(currentFile); ui.rzconfig_alt->saveSettings(currentFile); - - settingsDirty = false; } diff --git a/facetracknoir/curve-config.h b/facetracknoir/curve-config.h index 950f6d14..0949cdc4 100644 --- a/facetracknoir/curve-config.h +++ b/facetracknoir/curve-config.h @@ -14,13 +14,9 @@ public: private: Ui::UICCurveConfigurationDialog ui; void save(); - - bool settingsDirty; FaceTrackNoIR *mainApp; private slots: void doOK(); void doCancel(); - void curveChanged( bool ) { settingsDirty = true; } - void curveChanged( int ) { settingsDirty = true; } }; -- cgit v1.2.3 From 952abb1881f346358828d81facde43316e79d46d Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 5 Jan 2014 19:18:05 +0100 Subject: remove dead code that now barfs on stderr --- facetracknoir/curve-config.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/curve-config.cpp b/facetracknoir/curve-config.cpp index 7840ab96..b6c99fed 100644 --- a/facetracknoir/curve-config.cpp +++ b/facetracknoir/curve-config.cpp @@ -86,8 +86,6 @@ void CurveConfigurationDialog::loadSettings() { alt_configs[i]->setConfig(&mainApp->axis(i).curveAlt, currentFile); configs[i]->loadSettings(currentFile); alt_configs[i]->loadSettings(currentFile); - connect(configs[i], SIGNAL(CurveChanged(bool)), this, SLOT(curveChanged(bool)), Qt::UniqueConnection); - connect(alt_configs[i], SIGNAL(CurveChanged(bool)), this, SLOT(curveChanged(bool)), Qt::UniqueConnection); } } -- cgit v1.2.3 From 12d98b8f244486927e45e2e4accb1f9fca92f6d5 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 6 Jan 2014 19:43:05 +0100 Subject: rename curves -> mapping --- facetracknoir/ftnoir_curves.ui | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/ftnoir_curves.ui b/facetracknoir/ftnoir_curves.ui index 68d8720d..04ff7887 100644 --- a/facetracknoir/ftnoir_curves.ui +++ b/facetracknoir/ftnoir_curves.ui @@ -88,7 +88,7 @@ - Asymmetric curves below + Asymmetric mapping below @@ -175,7 +175,7 @@ - Asymmetric curves below + Asymmetric mapping below @@ -265,7 +265,7 @@ - Asymmetric curves below + Asymmetric mapping below @@ -355,7 +355,7 @@ - Asymmetric curves below + Asymmetric mapping below @@ -445,7 +445,7 @@ - Asymmetric curves below + Asymmetric mapping below @@ -535,7 +535,7 @@ - Asymmetric curves below + Asymmetric mapping below -- cgit v1.2.3 From ce89b81b3755892b86e5218db2f1bc40738ee784 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 8 Jan 2014 17:56:53 +0100 Subject: fix settings race switching back and forth with thanks to George Trigonakis for pointing out --- facetracknoir/options.h | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/options.h b/facetracknoir/options.h index 057e97af..3fd0e767 100644 --- a/facetracknoir/options.h +++ b/facetracknoir/options.h @@ -229,7 +229,8 @@ namespace options { return datum; } public: - static constexpr const Qt::ConnectionType CONNTYPE = Qt::QueuedConnection; + static constexpr const Qt::ConnectionType QT_CONNTYPE = Qt::UniqueConnection; + static constexpr const Qt::ConnectionType OPT_CONNTYPE = Qt::UniqueConnection; value(pbundle b, const QString& name, T def) : base_value(b, name) { @@ -252,8 +253,8 @@ namespace options { inline void tie_setting(value& v, QComboBox* cb) { cb->setCurrentIndex(v); - base_value::connect(cb, SIGNAL(currentIndexChanged(int)), &v, SLOT(setValue(int)), v.CONNTYPE); - base_value::connect(&v, SIGNAL(valueChanged(int)), cb, SLOT(setCurrentIndex(int)), v.CONNTYPE); + base_value::connect(cb, SIGNAL(currentIndexChanged(int)), &v, SLOT(setValue(int)), v.QT_CONNTYPE); + base_value::connect(&v, SIGNAL(valueChanged(int)), cb, SLOT(setCurrentIndex(int)), v.OPT_CONNTYPE); } template<> @@ -261,55 +262,55 @@ namespace options { { cb->setCurrentText(v); v = cb->currentText(); - base_value::connect(cb, SIGNAL(currentTextChanged(QString)), &v, SLOT(setValue(QString)), v.CONNTYPE); - base_value::connect(&v, SIGNAL(valueChanged(QString)), cb, SLOT(setCurrentText(QString)), v.CONNTYPE); + base_value::connect(cb, SIGNAL(currentTextChanged(QString)), &v, SLOT(setValue(QString)), v.QT_CONNTYPE); + base_value::connect(&v, SIGNAL(valueChanged(QString)), cb, SLOT(setCurrentText(QString)), v.OPT_CONNTYPE); } template<> inline void tie_setting(value& v, QCheckBox* cb) { cb->setChecked(v); - base_value::connect(cb, SIGNAL(toggled(bool)), &v, SLOT(setValue(bool)), v.CONNTYPE); - base_value::connect(&v, SIGNAL(valueChanged(bool)), cb, SLOT(setChecked(bool)), v.CONNTYPE); + base_value::connect(cb, SIGNAL(toggled(bool)), &v, SLOT(setValue(bool)), v.QT_CONNTYPE); + base_value::connect(&v, SIGNAL(valueChanged(bool)), cb, SLOT(setChecked(bool)), v.OPT_CONNTYPE); } template<> inline void tie_setting(value& v, QDoubleSpinBox* dsb) { dsb->setValue(v); - base_value::connect(dsb, SIGNAL(valueChanged(double)), &v, SLOT(setValue(double)), v.CONNTYPE); - base_value::connect(&v, SIGNAL(valueChanged(double)), dsb, SLOT(setValue(double)), v.CONNTYPE); + base_value::connect(dsb, SIGNAL(valueChanged(double)), &v, SLOT(setValue(double)), v.QT_CONNTYPE); + base_value::connect(&v, SIGNAL(valueChanged(double)), dsb, SLOT(setValue(double)), v.OPT_CONNTYPE); } template<> inline void tie_setting(value& v, QSpinBox* sb) { sb->setValue(v); - base_value::connect(sb, SIGNAL(valueChanged(int)), &v, SLOT(setValue(int)), v.CONNTYPE); - base_value::connect(&v, SIGNAL(valueChanged(int)), sb, SLOT(setValue(int)), v.CONNTYPE); + base_value::connect(sb, SIGNAL(valueChanged(int)), &v, SLOT(setValue(int)), v.QT_CONNTYPE); + base_value::connect(&v, SIGNAL(valueChanged(int)), sb, SLOT(setValue(int)), v.OPT_CONNTYPE); } template<> inline void tie_setting(value& v, QSlider* sl) { sl->setValue(v); - base_value::connect(sl, SIGNAL(valueChanged(int)), &v, SLOT(setValue(int)), v.CONNTYPE); - base_value::connect(&v, SIGNAL(valueChanged(int)), sl, SLOT(setValue(int)), v.CONNTYPE); + base_value::connect(sl, SIGNAL(valueChanged(int)), &v, SLOT(setValue(int)), v.QT_CONNTYPE); + base_value::connect(&v, SIGNAL(valueChanged(int)), sl, SLOT(setValue(int)), v.OPT_CONNTYPE); } template<> inline void tie_setting(value& v, QLineEdit* le) { le->setText(v); - base_value::connect(le, SIGNAL(textChanged(QString)), &v, SLOT(setValue(QString)), v.CONNTYPE); - base_value::connect(&v, SIGNAL(valueChanged(QString)),le, SLOT(setText(QString)), v.CONNTYPE); + base_value::connect(le, SIGNAL(textChanged(QString)), &v, SLOT(setValue(QString)), v.QT_CONNTYPE); + base_value::connect(&v, SIGNAL(valueChanged(QString)),le, SLOT(setText(QString)), v.OPT_CONNTYPE); } template<> inline void tie_setting(value& v, QLabel* lb) { lb->setText(v); - base_value::connect(&v, SIGNAL(valueChanged(QString)), lb, SLOT(setText(QString)), v.CONNTYPE); + base_value::connect(&v, SIGNAL(valueChanged(QString)), lb, SLOT(setText(QString)), v.OPT_CONNTYPE); } inline pbundle bundle(const QString& group) { -- cgit v1.2.3 From ad708b8a8a2c8d2d898c79823672aba79de7733e Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 12 Jan 2014 16:22:29 +0100 Subject: fix qfc persisting despite cancel --- facetracknoir/curve-config.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'facetracknoir') diff --git a/facetracknoir/curve-config.cpp b/facetracknoir/curve-config.cpp index b6c99fed..1e911ddd 100644 --- a/facetracknoir/curve-config.cpp +++ b/facetracknoir/curve-config.cpp @@ -50,6 +50,7 @@ void CurveConfigurationDialog::doOK() { void CurveConfigurationDialog::doCancel() { mainApp->b->revert(); + loadSettings(); close(); } -- cgit v1.2.3 From 6d6d15e1b328ec5c0469f8bc142848715b1491e8 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 12 Jan 2014 16:22:42 +0100 Subject: fix qfc display artifacts & bugs --- facetracknoir/ftnoir_curves.ui | 48 ++++++++++++------------- qfunctionconfigurator/qfunctionconfigurator.cpp | 13 ++++--- qfunctionconfigurator/qfunctionconfigurator.h | 1 + 3 files changed, 31 insertions(+), 31 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/ftnoir_curves.ui b/facetracknoir/ftnoir_curves.ui index 04ff7887..195083b9 100644 --- a/facetracknoir/ftnoir_curves.ui +++ b/facetracknoir/ftnoir_curves.ui @@ -50,8 +50,8 @@ 0 0 - 921 - 240 + 930 + 260 @@ -96,8 +96,8 @@ 0 300 - 975 - 206 + 930 + 260 @@ -134,8 +134,8 @@ 0 0 - 595 - 240 + 930 + 260 @@ -183,8 +183,8 @@ 0 300 - 1013 - 240 + 930 + 260 @@ -224,8 +224,8 @@ 0 0 - 595 - 240 + 930 + 260 @@ -273,8 +273,8 @@ 0 300 - 595 - 240 + 930 + 260 @@ -314,8 +314,8 @@ 0 0 - 555 - 160 + 930 + 260 @@ -363,8 +363,8 @@ 0 300 - 555 - 160 + 930 + 260 @@ -404,8 +404,8 @@ 0 0 - 555 - 160 + 930 + 260 @@ -453,8 +453,8 @@ 0 300 - 555 - 160 + 930 + 260 @@ -494,8 +494,8 @@ 0 0 - 555 - 160 + 930 + 260 @@ -543,8 +543,8 @@ 0 300 - 555 - 160 + 930 + 260 diff --git a/qfunctionconfigurator/qfunctionconfigurator.cpp b/qfunctionconfigurator/qfunctionconfigurator.cpp index 755e2f9c..6540e66f 100644 --- a/qfunctionconfigurator/qfunctionconfigurator.cpp +++ b/qfunctionconfigurator/qfunctionconfigurator.cpp @@ -44,7 +44,8 @@ void QFunctionConfigurator::setConfig(FunctionConfig* config, QString settingsFi config->loadSettings(iniFile); _config = config; _draw_function = _draw_background = true; - this->update(); + update_range(); + update(); } void QFunctionConfigurator::loadSettings(QString settingsFile) { @@ -87,7 +88,7 @@ void QFunctionConfigurator::drawBackground() // horizontal grid - for (int i = 0; i < maxx; i += xstep) + for (int i = 0; i < maxy; i += xstep) { double y = range.height() - i * c.y() + range.y(); drawLine(&painter, @@ -102,7 +103,7 @@ void QFunctionConfigurator::drawBackground() } { - const int i = maxx; + const int i = maxy; double y = range.height() - i * c.y() + range.y(); drawLine(&painter, QPointF(range.x(), y), @@ -117,7 +118,7 @@ void QFunctionConfigurator::drawBackground() // vertical grid - for (int i = 0; i < maxy; i += ystep) + for (int i = 0; i < maxx; i += ystep) { double x = range.x() + i * c.x(); drawLine(&painter, @@ -132,7 +133,7 @@ void QFunctionConfigurator::drawBackground() text); } { - const int i = maxy; + const int i = maxx; double x = range.x() + i * c.x(); drawLine(&painter, QPointF(x, range.y()), @@ -415,8 +416,6 @@ void QFunctionConfigurator::setColorBezier(QColor color) void QFunctionConfigurator::resizeEvent(QResizeEvent *) { - _draw_background = true; - _draw_function = true; update_range(); repaint(); } diff --git a/qfunctionconfigurator/qfunctionconfigurator.h b/qfunctionconfigurator/qfunctionconfigurator.h index 17cb3a44..bb2aced0 100644 --- a/qfunctionconfigurator/qfunctionconfigurator.h +++ b/qfunctionconfigurator/qfunctionconfigurator.h @@ -68,6 +68,7 @@ private: const double mwr = 15, mhr = 35; range = QRectF(mwl, mhl, (w - mwl - mwr), (h - mhl - mhr)); c = QPointF(range.width() / _config->maxInput(), range.height() / _config->maxOutput()); + _draw_function = _draw_background = true; } QRectF range; // The actual rectangle for the Bezier-curve -- cgit v1.2.3 From 21a6ed9d17d657aa9fc8c6bfa91322307f34c547 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 13 Jan 2014 08:23:11 +0100 Subject: change translation scale back. units in millimeters for most trackers --- facetracknoir/tracker.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/tracker.h b/facetracknoir/tracker.h index da1b3372..7a6f5171 100644 --- a/facetracknoir/tracker.h +++ b/facetracknoir/tracker.h @@ -80,9 +80,9 @@ public: THeadPoseDOF* axes[6]; HeadPoseData(std::vector opts) { - axes[TX] = new THeadPoseDOF("tx","tx_alt", 25, 100, 25, 100, opts[TX]); - axes[TY] = new THeadPoseDOF("ty","ty_alt", 25, 100, 25, 100, opts[TY]); - axes[TZ] = new THeadPoseDOF("tz","tz_alt", 25, 100, 25, 100, opts[TZ]); + axes[TX] = new THeadPoseDOF("tx","tx_alt", 100, 100, 25, 100, opts[TX]); + axes[TY] = new THeadPoseDOF("ty","ty_alt", 100, 100, 25, 100, opts[TY]); + axes[TZ] = new THeadPoseDOF("tz","tz_alt", 100, 100, 25, 100, opts[TZ]); axes[Yaw] = new THeadPoseDOF("rx", "rx_alt", 180, 180, 180, 180, opts[Yaw]); axes[Pitch] = new THeadPoseDOF("ry", "ry_alt", 90, 90, 90, 90, opts[Pitch]); axes[Roll] = new THeadPoseDOF("rz", "rz_alt", 180, 180, 180, 180, opts[Roll]); -- cgit v1.2.3 From da51315f4b733f7beff00b1d5213e004ffae7155 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 13 Jan 2014 08:25:26 +0100 Subject: fix typo --- facetracknoir/tracker.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/tracker.h b/facetracknoir/tracker.h index 7a6f5171..7ebece02 100644 --- a/facetracknoir/tracker.h +++ b/facetracknoir/tracker.h @@ -80,9 +80,9 @@ public: THeadPoseDOF* axes[6]; HeadPoseData(std::vector opts) { - axes[TX] = new THeadPoseDOF("tx","tx_alt", 100, 100, 25, 100, opts[TX]); - axes[TY] = new THeadPoseDOF("ty","ty_alt", 100, 100, 25, 100, opts[TY]); - axes[TZ] = new THeadPoseDOF("tz","tz_alt", 100, 100, 25, 100, opts[TZ]); + axes[TX] = new THeadPoseDOF("tx","tx_alt", 100, 100, 100, 100, opts[TX]); + axes[TY] = new THeadPoseDOF("ty","ty_alt", 100, 100, 100, 100, opts[TY]); + axes[TZ] = new THeadPoseDOF("tz","tz_alt", 100, 100, 100, 100, opts[TZ]); axes[Yaw] = new THeadPoseDOF("rx", "rx_alt", 180, 180, 180, 180, opts[Yaw]); axes[Pitch] = new THeadPoseDOF("ry", "ry_alt", 90, 90, 90, 90, opts[Pitch]); axes[Roll] = new THeadPoseDOF("rz", "rz_alt", 180, 180, 180, 180, opts[Roll]); -- cgit v1.2.3 From f60ced07e25eb48a79645a328b275125b8aa2ea9 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 13 Jan 2014 21:31:35 +0100 Subject: hopefully work around tracker thread freeze on exit (issue #18) Reported-by: @chsims1 Signed-off-by: Stanislaw Halik --- facetracknoir/facetracknoir.cpp | 3 --- facetracknoir/tracker.cpp | 6 ++++++ facetracknoir/tracker.h | 9 +++++---- 3 files changed, 11 insertions(+), 7 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index b83f59d7..d93f2131 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -360,7 +360,6 @@ void FaceTrackNoIR::startTracker( ) { #endif if (tracker) { - tracker->wait(); delete tracker; } @@ -418,8 +417,6 @@ void FaceTrackNoIR::stopTracker( ) { pFilterDialog->unregisterFilter(); if ( tracker ) { - tracker->should_quit = true; - tracker->wait(); delete tracker; tracker = 0; if (Libraries) { diff --git a/facetracknoir/tracker.cpp b/facetracknoir/tracker.cpp index fa1cdee1..57762640 100644 --- a/facetracknoir/tracker.cpp +++ b/facetracknoir/tracker.cpp @@ -31,6 +31,12 @@ Tracker::Tracker(FaceTrackNoIR *parent , main_settings& s) : { } +Tracker::~Tracker() +{ + should_quit = true; + wait(); +} + static void get_curve(double pos, double& out, THeadPoseDOF& axis) { bool altp = (pos < 0) && axis.opts.altp; if (altp) { diff --git a/facetracknoir/tracker.h b/facetracknoir/tracker.h index 7ebece02..a33d8e0d 100644 --- a/facetracknoir/tracker.h +++ b/facetracknoir/tracker.h @@ -51,28 +51,29 @@ public: axis_opts& opts; }; -class Tracker : public QThread { +class Tracker : protected QThread { Q_OBJECT private: FaceTrackNoIR *mainApp; QMutex mtx; main_settings& s; - + volatile bool should_quit; protected: void run(); public: Tracker( FaceTrackNoIR *parent, main_settings& s); + ~Tracker(); void getHeadPose(double *data); void getOutputHeadPose(double *data); - - volatile bool should_quit; volatile bool do_center; volatile bool enabled; T6DOF output_camera; + + void start() { QThread::start(); } }; class HeadPoseData { -- cgit v1.2.3 From 078c82bbb11a077c1e82f9ed4f0f76a7f89cf629 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 13 Jan 2014 23:29:11 +0100 Subject: flip tcomp axis for freetrack protocol It's the easy way out, for now. Need to align 6DOF conventions of all available trackers, eventually --- facetracknoir/tracker.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'facetracknoir') diff --git a/facetracknoir/tracker.cpp b/facetracknoir/tracker.cpp index 57762640..1f3257f5 100644 --- a/facetracknoir/tracker.cpp +++ b/facetracknoir/tracker.cpp @@ -54,7 +54,7 @@ static void get_curve(double pos, double& out, THeadPoseDOF& axis) { static void t_compensate(double* input, double* output, bool rz) { - const auto H = input[Yaw] * M_PI / 180; + const auto H = input[Yaw] * M_PI / -180; const auto P = input[Pitch] * M_PI / 180; const auto B = input[Roll] * M_PI / 180; -- cgit v1.2.3 From de354eaca23e275386b3b2365cb4d4e0531377e1 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 13 Jan 2014 23:41:19 +0100 Subject: remove hatire tracker hatire tracker's unmaintained, unused and has an obvious crash bug The following line: data[frame_cnt] = (long) HAT.Code; contains an arbitrary offset dereference. It's obvious now that the code has only been compile-tested. Because no one reported the issue, it's safe to assume it has no users. If it gets users and becomes actively maintained, it'll return. -sh --- CMakeLists.txt | 17 +- facetracknoir/clientfiles/HAT_100/HAT_100.ino | 389 ------- facetracknoir/clientfiles/HAT_100/README | 35 - ftnoir_tracker_hatire/ftnoir_arduino_type.h | 30 - ftnoir_tracker_hatire/ftnoir_hat.qrc | 6 - ftnoir_tracker_hatire/ftnoir_hatcontrols.ui | 1190 -------------------- ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp | 463 -------- ftnoir_tracker_hatire/ftnoir_tracker_hat.h | 87 -- .../ftnoir_tracker_hat_dialog.cpp | 277 ----- ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.h | 50 - ftnoir_tracker_hatire/ftnoir_tracker_hat_dll.cpp | 81 -- .../ftnoir_tracker_hat_settings.h | 85 -- ftnoir_tracker_hatire/images/hat.png | Bin 376 -> 0 bytes ftnoir_tracker_hatire/images/hat_logo.png | Bin 15210 -> 0 bytes 14 files changed, 1 insertion(+), 2709 deletions(-) delete mode 100644 facetracknoir/clientfiles/HAT_100/HAT_100.ino delete mode 100644 facetracknoir/clientfiles/HAT_100/README delete mode 100644 ftnoir_tracker_hatire/ftnoir_arduino_type.h delete mode 100644 ftnoir_tracker_hatire/ftnoir_hat.qrc delete mode 100644 ftnoir_tracker_hatire/ftnoir_hatcontrols.ui delete mode 100644 ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp delete mode 100644 ftnoir_tracker_hatire/ftnoir_tracker_hat.h delete mode 100644 ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.cpp delete mode 100644 ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.h delete mode 100644 ftnoir_tracker_hatire/ftnoir_tracker_hat_dll.cpp delete mode 100644 ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.h delete mode 100644 ftnoir_tracker_hatire/images/hat.png delete mode 100644 ftnoir_tracker_hatire/images/hat_logo.png (limited to 'facetracknoir') diff --git a/CMakeLists.txt b/CMakeLists.txt index 7b29008b..40682474 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,8 +34,6 @@ if(APPLE) set(CMAKE_CXX_FLAGS " -stdlib=libc++ -std=c++11 ${CMAKE_CXX_FLAGS} -fvisibility=hidden") endif() -set(SDK_HATIRE TRUE CACHE BOOL "hatire: generic Arduino over serial port") - SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) SET(CMAKE_SKIP_INSTALL_RPATH FALSE) @@ -115,10 +113,6 @@ if(MINGW) endif() find_package(OpenCV REQUIRED) -set(maybe-serial-port) -if(SDK_HATIRE) - set(maybe-serial-port SerialPort) -endif() find_package(Qt5 REQUIRED COMPONENTS Core Xml Network Widgets Gui ${maybe-serial-port} QUIET) cmake_policy(SET CMP0020 NEW) @@ -255,7 +249,6 @@ opentrack_module(opentrack-tracker-udp ftnoir_tracker_udp) opentrack_module(opentrack-tracker-joystick ftnoir_tracker_joystick) opentrack_module(opentrack-tracker-rift ftnoir_tracker_rift) opentrack_module(opentrack-tracker-hydra ftnoir_tracker_hydra) -opentrack_module(opentrack-tracker-hatire ftnoir_tracker_hatire) file(GLOB opentrack-csv-c "ftnoir_csv/*.cpp" "ftnoir_csv/*.h") @@ -308,11 +301,7 @@ if(WIN32) set(my-qt-deps ws2_32) endif() -set(maybe-hatire) -if(SDK_HATIRE) -set(maybe-hatire ${Qt5SerialPort_LIBRARIES}) -endif() -set(MY_QT_LIBS ${Qt5Widgets_LIBRARIES} ${Qt5Gui_LIBRARIES} ${Qt5Network_LIBRARIES} ${Qt5Xml_LIBRARIES} ${Qt5Core_LIBRARIES} ${maybe-hatire} ${my-qt-deps}) +set(MY_QT_LIBS ${Qt5Widgets_LIBRARIES} ${Qt5Gui_LIBRARIES} ${Qt5Network_LIBRARIES} ${Qt5Xml_LIBRARIES} ${Qt5Core_LIBRARIES} ${my-qt-deps}) add_library(opentrack-csv SHARED ${opentrack-csv-c}) target_link_libraries(opentrack-csv ${MY_QT_LIBS}) @@ -417,10 +406,6 @@ if(SDK_ARUCO_LIBPATH) endif() endif() -if(SDK_HATIRE) - opentrack_library(opentrack-tracker-hatire) -endif() - link_with_dinput8(opentrack-tracker-ht) link_with_dinput8(opentrack-tracker-joystick) diff --git a/facetracknoir/clientfiles/HAT_100/HAT_100.ino b/facetracknoir/clientfiles/HAT_100/HAT_100.ino deleted file mode 100644 index f8644ffe..00000000 --- a/facetracknoir/clientfiles/HAT_100/HAT_100.ino +++ /dev/null @@ -1,389 +0,0 @@ -// Arduino sketch for MPU6050 on NanoWII using DMP MotionApps v4.1 -// HAT 14/04/2013 by FuraX49 -// -// Head Arduino Tracker for FaceTrackNoIR -// http://facetracknoir.sourceforge.net/home/default.htm -// I2C device class (I2Cdev) -// https://github.com/jrowberg/i2cdevlib - - -#include -#include -#include "I2Cdev.h" -#include "MPU6050_9Axis_MotionApps41.h" - - -MPU6050 mpu; - - -typedef struct { - int16_t Begin ; // 2 Debut - uint16_t Cpt ; // 2 Compteur trame or Code info or error - float gyro[3]; // 12 [Y, P, R] gyro - float acc[3]; // 12 [x, y, z] Acc - int16_t End ; // 2 Fin -} _hatire; - -typedef struct { - int16_t Begin ; // 2 Debut - uint16_t Code ; // 2 Code info - char Msg[24]; // 24 Message - int16_t End ; // 2 Fin -} _msginfo; - -typedef struct -{ - byte rate; - double gyro_offset[3] ; - double acc_offset[3] ; -} _eprom_save; - - -// MPU control/status vars -bool dmpReady = false; // set true if DMP init was successful -bool dmpLoaded = false; // set true if DMP loaded successfuly -uint8_t mpuIntStatus; // holds actual interrupt status byte from MPU -uint8_t devStatus; // return status after each device operation (0 = success, !0 = error) -uint16_t packetSize; // expected DMP packet size (default is 42 bytes) -uint16_t fifoCount; // count of all bytes currently in FIFO -uint8_t fifoBuffer[64]; // FIFO storage buffer - -char Commande; -char Version[] = "HAT V 1.00"; - -// orientation/motion vars -Quaternion q; // [w, x, y, z] quaternion container -VectorInt16 aa; // [x, y, z] accel sensor measurements -VectorFloat gravity; // [x, y, z] gravity vector - -float Rad2Deg = (180/M_PI) ; - -// trame for message -_hatire hatire; -_msginfo msginfo; -_eprom_save eprom_save; - - -bool AskCalibrate = false; // set true when calibrating is ask -int CptCal = 0; -const int NbCal = 5; - - - - -// ================================================================ -// === INTERRUPT DETECTION ROUTINE === -// ================================================================ -volatile bool mpuInterrupt = false; // indicates whether MPU interrupt pin has gone high - -void dmpDataReady() { - mpuInterrupt = true; -} - -// ================================================================ -// === PRINT SERIAL FORMATTE === -// ================================================================ -void PrintCodeSerial(uint16_t code,char Msg[24],bool EOL ) { - msginfo.Code=code; - memset(msginfo.Msg,0x00,24); - strcpy(msginfo.Msg,Msg); - if (EOL) msginfo.Msg[23]=0x0A; - // Send HATIRE message to PC - Serial.write((byte*)&msginfo,30); -} - - -// ================================================================ -// === INITIAL SETUP === -// ================================================================ - -void setup() { - // join I2C bus (I2Cdev library doesn't do this automatically) - Wire.begin(); - - // initialize serial communication - while (!Serial); // wait for Leonardo enumeration, others continue immediately - - Serial.begin(115200); - PrintCodeSerial(2000,Version,true); - - hatire.Begin=0xAAAA; - hatire.Cpt=0; - hatire.End=0x5555; - - msginfo.Begin=0xAAAA; - msginfo.Code=0; - msginfo.End=0x5555; - - // initialize device - PrintCodeSerial(3001,"Initializing I2C",true); - mpu.initialize(); - - // verify connection - PrintCodeSerial(3002,"Testing connections",true); - - if (mpu.testConnection()){ - PrintCodeSerial(3003,"MPU6050 connection OK",true); - } else { - PrintCodeSerial(9007,"MPU6050 ERRROR CNX",true); - } - - while (Serial.available() && Serial.read()); // empty buffer - - // load and configure the DMP - PrintCodeSerial(3004,"Initializing DMP...",true); - devStatus = mpu.dmpInitialize(); - - // make sure it worked (returns 0 if so) - if (devStatus == 0) { - dmpLoaded=true; - - // Read Epprom saved params - PrintCodeSerial(3005,"Reading saved params...",true); - ReadParams(); - - // turn on the DMP, now that it's ready - PrintCodeSerial(3006,"Enabling DMP...",true); - mpu.setDMPEnabled(true); - - // enable Arduino interrupt detection - PrintCodeSerial(3007,"Enabling interrupt",true); - attachInterrupt(0, dmpDataReady, RISING); - mpuIntStatus = mpu.getIntStatus(); - - // set our DMP Ready flag so the main loop() function knows it's okay to use it - PrintCodeSerial(5000,"HAT BEGIN",true); - dmpReady = true; - // get expected DMP packet size for later comparison - packetSize = mpu.dmpGetFIFOPacketSize(); - // Empty FIFO - fifoCount = mpu.getFIFOCount(); - while (fifoCount > packetSize) { - fifoCount = mpu.getFIFOCount(); - mpu.getFIFOBytes(fifoBuffer, fifoCount); - } - } - else { - // ERROR! - // 1 = initial memory load failed - // 2 = DMP configuration updates failed - // (if it's going to break, usually the code will be 1) - dmpLoaded=false; - PrintCodeSerial(9000+devStatus,"DMP Initialization failed",true); - } -} - - -// ================================================================ -// === RAZ OFFSET === -// ================================================================ -void razoffset() { - eprom_save.gyro_offset[0] = 0; - eprom_save.gyro_offset[1] = 0; - eprom_save.gyro_offset[2] = 0; - eprom_save.acc_offset[0] = 0; - eprom_save.acc_offset[1] = 0; - eprom_save.acc_offset[2] = 0; -} - - -// ================================================================ -// === SAVE PARAMS === -// ================================================================ -void SaveParams() { - eeprom_write_block((const void*)&eprom_save, (void*) 0, sizeof(eprom_save)); -} - - - -// ================================================================ -// === READ PARAMS === -// ================================================================ -void ReadParams() { - eeprom_read_block( (void*)&eprom_save, (void*) 0, sizeof(eprom_save)); -} - - -// ================================================================ -// === Serial Command === -// ================================================================ -void serialEvent(){ - Commande = (char)Serial.read(); - switch (Commande) { - case 'S': - PrintCodeSerial(5001,"HAT START",true); - if (dmpLoaded==true) { - mpu.resetFIFO(); - hatire.Cpt=0; - attachInterrupt(0, dmpDataReady, RISING); - mpu.setDMPEnabled(true); - dmpReady = true; - } - else { - PrintCodeSerial(9011,"Error DMP not loaded",true); - } - break; - - case 's': - PrintCodeSerial(5002,"HAT STOP",true); - if (dmpReady==true) { - mpu.setDMPEnabled(false); - detachInterrupt(0); - dmpReady = false; - } - break; - - case 'R': - PrintCodeSerial(5003,"HAT RESET",true); - if (dmpLoaded==true) { - mpu.setDMPEnabled(false); - detachInterrupt(0); - mpu.resetFIFO(); - hatire.Cpt=0; - dmpReady = false; - setup(); - } - else { - PrintCodeSerial(9011,"Error DMP not loaded",true); - } - break; - - - case 'C': - CptCal=0; - razoffset(); - AskCalibrate=true; - break; - - case 'V': - PrintCodeSerial(2000,Version,true); - break; - - case 'I': - Serial.println(); - Serial.print("Version : \t"); - Serial.println(Version); - Serial.println("Gyroscopes offsets"); - for (int i=0; i <= 2; i++) { - Serial.print(i); - Serial.print(" : "); - Serial.print(eprom_save.gyro_offset[i]); - Serial.println(); - } - Serial.println("Accelerometers offsets"); - for (int i=0; i <= 2; i++) { - Serial.print(i); - Serial.print(" : "); - Serial.print(eprom_save.acc_offset[i]); - Serial.println(); - } - break; - - - default: - break; - } -} - - -// ================================================================ -// === MAIN PROGRAM LOOP === -// ================================================================ -void loop() { - // Leonardo BUG (simul Serial Event) - if(Serial.available() > 0) serialEvent(); - - - // if programming failed, don't try to do anything - if (dmpReady) { - - - while (!mpuInterrupt && fifoCount < packetSize) ; - - // reset interrupt flag and get INT_STATUS byte - mpuInterrupt = false; - mpuIntStatus = mpu.getIntStatus(); - - // get current FIFO count - fifoCount = mpu.getFIFOCount(); - - // check for overflow (this should never happen unless our code is too inefficient) - if ((mpuIntStatus & 0x10) || fifoCount == 1024) { - // reset so we can continue cleanly - mpu.resetFIFO(); - PrintCodeSerial(9010,"Overflow FIFO DMP",true); - hatire.Cpt=0; - - // otherwise, check for DMP data ready interrupt (this should happen frequently) - } - else if (mpuIntStatus & 0x02) { - // wait for correct available data length, should be a VERY short wait - while (fifoCount < packetSize) fifoCount = mpu.getFIFOCount(); - - // read a packet from FIFO - mpu.getFIFOBytes(fifoBuffer, packetSize); - - // track FIFO count here in case there is > 1 packet available - // (this lets us immediately read more without waiting for an interrupt) - fifoCount -= packetSize; - - // Get Euler angles in degrees - mpu.dmpGetQuaternion(&q, fifoBuffer); - mpu.dmpGetGravity(&gravity, &q); - mpu.dmpGetYawPitchRoll(hatire.gyro, &q, &gravity); - - // Get real acceleration, adjusted to remove gravity - // not used in this script - // mpu.dmpGetAccel(&aa, fifoBuffer); - // mpu.dmpGetLinearAccel(&hatire.acc, &aa, &gravity); - - // Calibration sur X mesures - if (AskCalibrate) { - if ( CptCal>=NbCal) { - CptCal=0; - eprom_save.gyro_offset[0] = eprom_save.gyro_offset[0] / NbCal ; - eprom_save.gyro_offset[1] = eprom_save.gyro_offset[1] / NbCal ; - eprom_save.gyro_offset[2] = eprom_save.gyro_offset[2] / NbCal ; - AskCalibrate=false; - SaveParams(); - } - else { - eprom_save.gyro_offset[0] += (float) hatire.gyro[0]; - eprom_save.gyro_offset[1] += (float) hatire.gyro[1]; - eprom_save.gyro_offset[2] += (float) hatire.gyro[2]; - - CptCal++; - } - } - - - // Conversion angles Euler en +-180 Degr�es - for (int i=0; i <= 2; i++) { - hatire.gyro[i]= (hatire.gyro[i] - eprom_save.gyro_offset[i] ) * Rad2Deg; - if (hatire.gyro[i]>180) { - hatire.gyro[i] = hatire.gyro[i] - 360; - } - } - - if (AskCalibrate) { - hatire.gyro[0] = 0; - hatire.gyro[1] = 0; - hatire.gyro[2] = 0; - hatire.acc[0]= 0; - hatire.acc[1] = 0; - hatire.acc[2] = 0; - } - - // Send Trame to HATIRE PC - Serial.write((byte*)&hatire,30); - - hatire.Cpt++; - if (hatire.Cpt>999) { - hatire.Cpt=0; - } - } - } - delay(1); -} - - diff --git a/facetracknoir/clientfiles/HAT_100/README b/facetracknoir/clientfiles/HAT_100/README deleted file mode 100644 index 1e4f2926..00000000 --- a/facetracknoir/clientfiles/HAT_100/README +++ /dev/null @@ -1,35 +0,0 @@ - Frame exchange protocol fixed size of 30 bytes like this : - - typedef struct { - int16_t Begin ; // 2 Debut - uint16_t Cpt ; // 2 Compteur trame or Code - float gyro[3]; // 12 [Y, P, R] gyro - float acc[3]; // 12 [x, y, z] Acc - int16_t End ; // 2 Fin -} _hatire; -_hat hat; - - -void setup() { - Serial.begin(115200); - // header frame - hatire.Begin=0xAAAA; - // Frame Number or Error code - hat.Cpt=0; - // footer frame - hat.End=0x5555; -} - - - void loop() { - mpu.dmpGetYawPitchRoll(hatire.gyro); - mpu.dmpAccXYZ(hatire.acc); - // Send Trame to HATIRE PC - Serial.write((byte*)&hatire,30); - hatire.Cpt++; - if (hatire.Cpt>999) { - hatire.Cpt=0; - } - delay(1); -} - diff --git a/ftnoir_tracker_hatire/ftnoir_arduino_type.h b/ftnoir_tracker_hatire/ftnoir_arduino_type.h deleted file mode 100644 index bd5c4246..00000000 --- a/ftnoir_tracker_hatire/ftnoir_arduino_type.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef FTNOIR_TARDUINO_TYPE_H -#define FTNOIR_TARDUINO_TYPE_H - -// Arduino trame structure -#pragma pack(push,2) -struct TArduinoData -{ - quint16 Begin; // Header trame 0xAAAA; - quint16 Code; // 0->999 Num Trame >=2000 Info >=3000 Init >=5000 Start Command >=9000 Error - float Rot[3]; - float Trans[3]; - quint16 End; // End trame 0x5555; -} ; -#pragma pack(pop) - - -inline QDataStream & operator >> ( QDataStream& in, TArduinoData& out ) -{ - in.setFloatingPointPrecision(QDataStream::SinglePrecision ); - - in >> out.Begin >> out.Code - >> out.Rot[0] >> out.Rot[1] >> out.Rot[2] - >> out.Trans[0] >> out.Trans[1] >> out.Trans[2] - >> out.End; - return in; -} - - - -#endif diff --git a/ftnoir_tracker_hatire/ftnoir_hat.qrc b/ftnoir_tracker_hatire/ftnoir_hat.qrc deleted file mode 100644 index ad67b862..00000000 --- a/ftnoir_tracker_hatire/ftnoir_hat.qrc +++ /dev/null @@ -1,6 +0,0 @@ - - - images/hat_logo.png - images/hat.png - - diff --git a/ftnoir_tracker_hatire/ftnoir_hatcontrols.ui b/ftnoir_tracker_hatire/ftnoir_hatcontrols.ui deleted file mode 100644 index 8a6bae62..00000000 --- a/ftnoir_tracker_hatire/ftnoir_hatcontrols.ui +++ /dev/null @@ -1,1190 +0,0 @@ - - - UIHATControls - - - - 0 - 0 - 307 - 567 - - - - - 0 - 0 - - - - - 65536 - 65536 - - - - Qt::NoContextMenu - - - Head Arduino Tracker settings FaceTrackNoIR - - - - :/images/hat.ico:/images/hat.ico - - - 1.000000000000000 - - - Qt::LeftToRight - - - false - - - - - - - 0 - 0 - - - - - 80 - 25 - - - - - 80 - 25 - - - - Cancel - - - - - - - - 0 - 0 - - - - - 80 - 25 - - - - - 80 - 25 - - - - OK - - - - - - - - 0 - 0 - - - - - 65535 - 65535 - - - - 0 - - - - General - - - - - - - - - true - - - - 4 - - - - - - 0 - 0 - - - - - 65535 - 16777215 - - - - false - - - QComboBox::AdjustToMinimumContentsLength - - - 0 - - - - - - - - 0 - 0 - - - - - 65536 - 16777215 - - - - Serial port - - - - - - - - - - - 80 - 20 - - - - Zero - - - - - - - - 80 - 20 - - - - Center - - - - - - - - 80 - 20 - - - - Reset - - - - - - - - 0 - 106 - - - - Axis Configuration - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - Associate Axis - - - - RotX - - - - - RotY - - - - - RotZ - - - - - - - - - 20 - 16777215 - - - - Enable Axis - - - Qt::LeftToRight - - - - - - - - - - - 20 - 16777215 - - - - Enable Axis - - - Qt::LeftToRight - - - - - - - - - - Pitch: - - - - - - - Enable - - - - - - - - 20 - 16777215 - - - - Enable Axis - - - Qt::LeftToRight - - - - - - - - - - Yaw: - - - - - - - Invert - - - - - - - Y: - - - - - - - - 20 - 16777215 - - - - Invert Axis - - - Qt::LeftToRight - - - - - - - - - - - - - X: - - - - - - - - 20 - 16777215 - - - - Invert Axis - - - Qt::LeftToRight - - - - - - - - - - - - - - 20 - 16777215 - - - - Invert Axis - - - Qt::LeftToRight - - - - - - - - - - - - - Associate Axis - - - - X - - - - - Y - - - - - Z - - - - - - - - - 20 - 16777215 - - - - Enable Axis - - - Qt::LeftToRight - - - - - - - - - - Associate Axis - - - - X - - - - - Y - - - - - Z - - - - - - - - Roll: - - - - - - - - 20 - 16777215 - - - - Invert Axis - - - Qt::LeftToRight - - - - - - - - - - - - - Associate Axis - - - - X - - - - - Y - - - - - Z - - - - - - - - - 20 - 16777215 - - - - Invert Axis - - - Qt::LeftToRight - - - - - - - - - - - - - Z: - - - - - - - Associate Axis - - - - RotX - - - - - RotY - - - - - RotZ - - - - - - - - - 20 - 16777215 - - - - Enable Axis - - - Qt::LeftToRight - - - - - - - - - - - - - - 20 - 16777215 - - - - Enable Axis - - - Qt::LeftToRight - - - - - - - - - - - 20 - 16777215 - - - - Invert Axis - - - Qt::LeftToRight - - - - - - - - - - - - - Associate Axis - - - - RotX - - - - - RotY - - - - - RotZ - - - - - - - - Axis - - - - - - - - - - - 0 - 0 - - - - Status - - - false - - - - - - - 31 - 20 - - - - - 60 - 20 - - - - Trame per seconde - - - tps : - - - - - - - - 31 - 20 - - - - - 60 - 20 - - - - 00 - - - - - - - - 0 - 20 - - - - - 60 - 20 - - - - Info : - - - - - - - - 170 - 20 - - - - - 60 - 20 - - - - 00 - - - - - - - - - - - Command - - - - - - Serial Parameters - - - - - - Data bits: - - - - - - - - - - BaudRate: - - - - - - - - - - - - - Flow control: - - - - - - - - - - Parity: - - - - - - - - - - Stop bits: - - - - - - - - - - Arduino Commands - - - - - - Delay Init - - - - - - - Init - - - - - - - Command for Initialising Arduino - - - - - - - Delay Start - - - - - - - Start: - - - - - - - Command for Start send sequence - - - - - - - Delay Sequence - - - - - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Delay after Start Command in ms</span></p></body></html> - - - 5000 - - - 50 - - - - - - - Stop: - - - - - - - Command for Stop send sequence - - - - - - - Center: - - - - - - - Command for Center Gyro arduino - - - - - - - Zero: - - - - - - - Command for Center Gyro arduino - - - - - - - Reset: - - - - - - - Command for Reset Arduino - - - - - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Little or Big Endian for <span style=" font-family:'Arial,Geneva,Helvetica,sans-serif'; font-size:medium; color:#000000;">the serialization of byte order</span></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial,Geneva,Helvetica,sans-serif'; font-size:medium; color:#000000;">Arduino is LittleEndian ( unchecked)</span></p></body></html> - - - Endian - - - - - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Delay after Init command in ms</span></p></body></html> - - - 5000 - - - 50 - - - - - - - - 60 - 16777215 - - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Delay before Init command in ms</span></p></body></html> - - - 5000 - - - 50 - - - - - - - - - - - About - - - - - - - Arial Black - 10 - 75 - true - true - - - - Version 1.0.0 - - - Qt::PlainText - - - true - - - - - - - - - - Send - - - - - - - Qt::ActionsContextMenu - - - true - - - - - - Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse - - - 800 - - - false - - - - - - - false - - - - - - - :/images/hat_logo.png - - - - - 128 - 128 - - - - true - - - - - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt; font-weight:600;">FTNoIR HAT Plugin<br />by FuraX49</span></p> -<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://hatire.sourceforge.net/"><span style=" font-size:8pt; font-weight:600; text-decoration: underline; color:#0000ff;">Manual (external)</span></a></p></body></html> - - - true - - - - - - - - - - - - 80 - 25 - - - - - 80 - 25 - - - - Save - - - - - - - btnOK - btnSave - btnCancel - chkEnableYaw - cb_yaw - chkInvertYaw - chkEnablePitch - cb_pitch - chkInvertPitch - chkEnableRoll - cb_roll - chkInvertRoll - chkEnableX - cb_x - chkInvertX - chkEnableY - cb_y - chkInvertY - chkEnableZ - cb_z - chkInvertZ - QCB_Serial_baudRate - QCB_Serial_dataBits - QCB_Serial_parity - QCB_Serial_stopBits - QCB_Serial_flowControl - lineSend - btnSend - pteINFO - tabWidget - - - - - startEngineClicked() - stopEngineClicked() - cameraSettingsClicked() - - diff --git a/ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp b/ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp deleted file mode 100644 index 6fef2db0..00000000 --- a/ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp +++ /dev/null @@ -1,463 +0,0 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2012 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* Homepage: http://facetracknoir.sourceforge.net/home/default.htm * -* * -* Copyright (C) 2012 FuraX49 (HAT Tracker plugins) * -* Homepage: http://hatire.sourceforge.net * -* * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -********************************************************************************/ - -#include "ftnoir_tracker_hat.h" - -FTNoIR_Tracker::FTNoIR_Tracker() -{ - ComPort = NULL; - - HAT.Rot[0]=0; - HAT.Rot[1]=0; - HAT.Rot[2]=0; - HAT.Trans[0]=0; - HAT.Trans[1]=0; - HAT.Trans[2]=0; - - // prepare & reserve QByteArray - dataRead.resize(4096); - dataRead.clear(); - Begin.append((char) 0xAA); - Begin.append((char) 0xAA); - End.append((char) 0x55); - End.append((char) 0x55); -} - -FTNoIR_Tracker::~FTNoIR_Tracker() -{ - if (ComPort!=NULL) { - if (ComPort->isOpen() ) { - ComPort->close(); - } - delete ComPort; - ComPort=NULL; - } -} - -//send CENTER to Arduino -void FTNoIR_Tracker::notifyCenter() { - sendcmd(static_cast(settings.CmdCenter).toLatin1()); -} - -//send ZERO to Arduino -bool FTNoIR_Tracker::notifyZeroed() { - sendcmd(static_cast(settings.CmdZero).toLatin1()); - return true; -} - -//send RESET to Arduino -void FTNoIR_Tracker::reset() { - sendcmd(static_cast(settings.CmdReset).toLatin1()); -} - - -// Info SerialPort -void FTNoIR_Tracker::SerialInfo() { - QByteArray Msg; - if (ComPort!=NULL) { - if (ComPort->isOpen() ) { - Msg.append("\r\n"); - Msg.append(ComPort->portName()); - Msg.append("\r\n"); - Msg.append("BAUDRATE :"); - Msg.append(QString::number(ComPort->baudRate())); - Msg.append("\r\n"); - Msg.append("DataBits :"); - Msg.append(QString::number(ComPort->dataBits())); - Msg.append("\r\n"); - Msg.append("Parity :"); - switch (ComPort->parity()) { - case 0: Msg.append("No parity"); - break; - case 2: Msg.append("Even parity"); - break; - case 3: Msg.append("Odd parity"); - break; - case 4: Msg.append("Space parity"); - break; - case 5: Msg.append("Mark parity"); - break; - default: Msg.append("Unknown parity"); - break; - } - Msg.append("\r\n"); - Msg.append("Stop Bits :"); - switch (ComPort->stopBits()) { - Msg.append(QString::number(ComPort->stopBits())); - case 1: Msg.append("1 stop bit."); - break; - case 2: Msg.append("2 stop bits."); - break; - case 3: Msg.append("1.5 stop bits."); - break; - default: Msg.append("Unknown number of stop bit."); - break; - } - Msg.append("\r\n"); - Msg.append("Flow Control :"); - switch (ComPort->flowControl()) { - case 0: Msg.append("No flow control"); - break; - case 1: Msg.append("Hardware flow control (RTS/CTS)"); - break; - case 2: Msg.append("Software flow control (XON/XOFF)"); - break; - default: Msg.append("Unknown flow control"); - break; - } - emit sendMsgInfo(Msg); - - } - } -} - - -//send command to Arduino -void FTNoIR_Tracker::sendcmd(const QByteArray &cmd) { - QByteArray Msg; - if (cmd.length()>0) { - if (ComPort->isOpen() ) - { - ComPort->write(cmd); - if (!ComPort->waitForBytesWritten(1000)) { - emit sendMsgInfo("TimeOut in writing CMD"); - } else { - Msg.append("\r\n"); - Msg.append("SEND '"); - Msg.append(cmd); - Msg.append("'\r\n"); - } - if ( !ComPort->waitForReadyRead(1000)) { - emit sendMsgInfo("TimeOut in response to CMD") ; - } else { - emit sendMsgInfo(Msg); - } - } else { - emit sendMsgInfo("ComPort not open") ; - } - } -} - - -// return FPS -void FTNoIR_Tracker::get_info( int *tps ){ - *tps=frame_cnt; - frame_cnt=0; -} - -void FTNoIR_Tracker::SerialRead() -{ - QMutexLocker lck(&mutex); - dataRead+=ComPort->readAll(); -} - -#ifndef OPENTRACK_API -void FTNoIR_Tracker::Initialize( QFrame *videoframe ) -{ - CptError=0; - dataRead.clear(); - frame_cnt=0; - - settings.load_ini(); - applysettings(settings); - ComPort = new QSerialPort(this); - ComPort->setPortName(sSerialPortName); - if (ComPort->open(QIODevice::ReadWrite ) == true) { - connect(ComPort, SIGNAL(readyRead()), this, SLOT(SerialRead())); - if ( - ComPort->setBaudRate((QSerialPort::BaudRate)iBaudRate) - && ComPort->setDataBits((QSerialPort::DataBits)iDataBits) - && ComPort->setParity((QSerialPort::Parity)iParity) - && ComPort->setStopBits((QSerialPort::StopBits)iStopBits) - && ComPort->setFlowControl((QSerialPort::FlowControl)iFlowControl) - && ComPort->clear(QSerialPort::AllDirections) - && ComPort->setDataErrorPolicy(QSerialPort::IgnorePolicy) - ) { - // Wait init arduino sequence - for (int i = 1; i <=iDelayInit; i+=50) { - if (ComPort->waitForReadyRead(50)) break; - } - sendcmd(sCmdInit); - // Wait init MPU sequence - for (int i = 1; i <=iDelayStart; i+=50) { - if (ComPort->waitForReadyRead(50)) break; - } - - } else { - QMessageBox::warning(0,"FaceTrackNoIR Error", ComPort->errorString(),QMessageBox::Ok,QMessageBox::NoButton); - } - } - else { - QMessageBox::warning(0,"FaceTrackNoIR Error", "Unable to open ComPort",QMessageBox::Ok,QMessageBox::NoButton); - delete ComPort; - ComPort = NULL; - } - return; -} - - - -void FTNoIR_Tracker::StartTracker(HWND parent_window) -{ - // Send START cmd to IMU - sendcmd(sCmdStart); - // Wait start MPU sequence - for (int i = 1; i <=iDelaySeq; i+=50) { - if (ComPort->waitForReadyRead(50)) break; - } - return; -} - - -void FTNoIR_Tracker::StopTracker( bool exit ) -{ - QByteArray Msg; - if (sCmdStop.length()>0) { - if (ComPort->isOpen() ) - { - ComPort->write(sCmdStop); - if (!ComPort->waitForBytesWritten(1000)) { - emit sendMsgInfo("TimeOut in writing CMD"); - } else { - Msg.append("\r\n"); - Msg.append("SEND '"); - Msg.append(sCmdStop); - Msg.append("'\r\n"); - } - emit sendMsgInfo(Msg); - } - } - // OK, the thread is not stopped, doing this. That might be dangerous anyway... - // - if (exit || !exit) return; - return; -} - -#else -void FTNoIR_Tracker::StartTracker(QFrame*) -{ - static const int databits_lookup[] = { - QSerialPort::Data5, - QSerialPort::Data6, - QSerialPort::Data7, - QSerialPort::Data8, - QSerialPort::UnknownDataBits - }; - - struct Local { - static int idx(int max, int value) - { - if (value < 0) - return 0; - if (max > value) - return value; - return max - 1; - } - }; - - static const int parity_lookup[] = { - QSerialPort::NoParity, - QSerialPort::EvenParity, - QSerialPort::OddParity, - QSerialPort::SpaceParity, - QSerialPort::MarkParity, - QSerialPort::UnknownParity - }; - - static const int stopbits_lookup[] = { - QSerialPort::OneStop, - QSerialPort::OneAndHalfStop, - QSerialPort::TwoStop, - QSerialPort::UnknownStopBits - }; - - static const int flowctl_lookup[] = { - QSerialPort::NoFlowControl, - QSerialPort::HardwareControl, - QSerialPort::SoftwareControl, - }; - - static const int baudrate_lookup[] = { - QSerialPort::Baud1200, - QSerialPort::Baud2400, - QSerialPort::Baud4800, - QSerialPort::Baud9600, - QSerialPort::Baud19200, - QSerialPort::Baud38400, - QSerialPort::Baud57600, - QSerialPort::Baud115200, - QSerialPort::UnknownBaud - }; - - CptError=0; - dataRead.clear(); - frame_cnt=0; - ComPort = new QSerialPort(this); - { - ComPort->setPortName(QSerialPortInfo::availablePorts().value(settings.SerialPortName).portName()); - } - if (ComPort->open(QIODevice::ReadWrite ) == true) { - connect(ComPort, SIGNAL(readyRead()), this, SLOT(SerialRead())); - if ( - ComPort->setBaudRate(baudrate_lookup[Local::idx(8, settings.pBaudRate)]) - && ComPort->setDataBits((QSerialPort::DataBits)databits_lookup[Local::idx(4, settings.pDataBits)]) - && ComPort->setParity((QSerialPort::Parity)parity_lookup[Local::idx(5, settings.pParity)]) - && ComPort->setStopBits((QSerialPort::StopBits)stopbits_lookup[Local::idx(3, settings.pStopBits)]) - && ComPort->setFlowControl((QSerialPort::FlowControl)flowctl_lookup[Local::idx(3, settings.pFlowControl)]) - && ComPort->clear(QSerialPort::AllDirections) - && ComPort->setDataErrorPolicy(QSerialPort::IgnorePolicy) - ){ - // Wait init arduino sequence - for (int i = 1; i <=settings.DelayInit; i+=50) { - if (ComPort->waitForReadyRead(50)) break; - } - sendcmd(static_cast(settings.CmdInit).toLatin1()); - // Wait init MPU sequence - for (int i = 1; i <=settings.DelayStart; i+=50) { - if (ComPort->waitForReadyRead(50)) break; - } - // Send START cmd to IMU - sendcmd(static_cast(settings.CmdStart).toLatin1()); - - // Wait start MPU sequence - for (int i = 1; i <=settings.DelaySeq; i+=50) { - if (ComPort->waitForReadyRead(50)) break; - } - } else { - QMessageBox::warning(0,"FaceTrackNoIR Error", ComPort->errorString(),QMessageBox::Ok,QMessageBox::NoButton); - } - } - else { - QMessageBox::warning(0,"FaceTrackNoIR Error", "Unable to open ComPort",QMessageBox::Ok,QMessageBox::NoButton); - delete ComPort; - ComPort = NULL; - } - return; - -} -#endif - - -// -// Return 6DOF info -// -#ifdef OPENTRACK_API -#define THeadPoseData double -#endif - -void FTNoIR_Tracker::GetHeadPoseData(THeadPoseData *data) -{ - QMutexLocker lck(&mutex); - while (dataRead.length()>=30) { - if ((dataRead.startsWith(Begin) && ( dataRead.mid(28,2)==End )) ) { // .Begin==0xAAAA .End==0x5555 - QDataStream datastream(dataRead.left(30)); - if (settings.BigEndian) datastream.setByteOrder(QDataStream::BigEndian ); - else datastream.setByteOrder(QDataStream::LittleEndian ); - datastream>>ArduinoData; - frame_cnt++; - if (ArduinoData.Code <= 1000) { - HAT=ArduinoData; - } else { - emit sendMsgInfo(dataRead.mid(4,24)) ; - } - dataRead.remove(0,30); - } else { - // resynchro trame - int index = dataRead.indexOf(Begin); - if (index==-1) { - index=dataRead.length(); - } - emit sendMsgInfo(dataRead.mid(0,index)) ; - dataRead.remove(0,index); - CptError++; - } - } - - if (CptError>50) { - emit sendMsgInfo("Can't find HAT frame") ; - CptError=0; - return; - } - data[frame_cnt] = (long) HAT.Code; - - struct Fun { - static int clamp3(int foo) - { - if (foo > 2) - return 2; - if (foo < 0) - return 0; - return foo; - } - }; - - if (settings.EnableYaw) { - if (settings.InvertYaw) data[Yaw] = (double) HAT.Rot[Fun::clamp3(settings.YawAxe)] * -1.0f; - else data[Yaw] = (double) HAT.Rot[Fun::clamp3(settings.YawAxe)]; - } - - if (settings.EnablePitch) { - if (settings.InvertPitch) data[Pitch] = (double) HAT.Rot[Fun::clamp3(settings.PitchAxe)] * -1.0f; - else data[Pitch] = (double) HAT.Rot[Fun::clamp3(settings.InvertPitch)]; - } - - if (settings.EnableRoll) { - if (settings.InvertRoll) data[Roll] = (double) HAT.Rot[Fun::clamp3(settings.RollAxe)] * -1.0f; - else data[Roll] = (double) HAT.Rot[Fun::clamp3(settings.RollAxe)]; - } - - if (settings.EnableX) { - if (settings.InvertX) data[TX] =(double) HAT.Trans[Fun::clamp3(settings.XAxe)]* -1.0f; - else data[TX] = HAT.Trans[Fun::clamp3(settings.XAxe)]; - } - - if (settings.EnableY) { - if (settings.InvertY) data[TY] =(double) HAT.Trans[Fun::clamp3(settings.YAxe)]* -1.0f; - else data[TY] = HAT.Trans[Fun::clamp3(settings.YAxe)]; - } - - if (settings.EnableZ) { - if (settings.InvertZ) data[TZ] = HAT.Trans[Fun::clamp3(settings.ZAxe)]* -1.0f; - else data[TZ] = HAT.Trans[Fun::clamp3(settings.ZAxe)]; - } -} - -void FTNoIR_Tracker::applysettings(const TrackerSettings& settings){ - QMutexLocker lck(&mutex); - settings.b->reload(); -} - -#ifdef OPENTRACK_API -extern "C" FTNOIR_TRACKER_BASE_EXPORT ITracker* CALLING_CONVENTION GetConstructor() -#else -#pragma comment(linker, "/export:GetTracker=_GetTracker@0") -FTNOIR_TRACKER_BASE_EXPORT ITrackerPtr __stdcall GetTracker() -#endif -{ - return new FTNoIR_Tracker; -} diff --git a/ftnoir_tracker_hatire/ftnoir_tracker_hat.h b/ftnoir_tracker_hatire/ftnoir_tracker_hat.h deleted file mode 100644 index 0dbc4c8c..00000000 --- a/ftnoir_tracker_hatire/ftnoir_tracker_hat.h +++ /dev/null @@ -1,87 +0,0 @@ -#ifndef FTNOIR_TRACKER_HAT_H -#define FTNOIR_TRACKER_HAT_H - -#ifdef OPENTRACK_API -# include "ftnoir_tracker_base/ftnoir_tracker_base.h" -# include "facetracknoir/global-settings.h" -#endif -#include "ftnoir_tracker_hat_settings.h" -#include "ftnoir_arduino_type.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define VER_FILEVERSION_STR "Version 2.0.7\0" - -class FTNoIR_Tracker : public QObject, public ITracker -{ - Q_OBJECT -public: - FTNoIR_Tracker(); - ~FTNoIR_Tracker(); - - virtual void StartTracker(QFrame*); - virtual void GetHeadPoseData(double* data); - void applysettings(const TrackerSettings& settings); - void notifyCenter(); - bool notifyZeroed(); - void reset(); - void SerialInfo(); - void sendcmd(const QByteArray &cmd); - void get_info( int *tps ); - -private Q_SLOTS: - void SerialRead(); - -signals: - void sendMsgInfo(const QByteArray &MsgInfo); - - -private: - QSerialPort *ComPort; - TArduinoData ArduinoData, HAT ; // Trame from Arduino - QByteArray dataRead; - QByteArray dataToSend; - QByteArray Begin; - QByteArray End; - QMutex mutex; - int frame_cnt; - - TrackerSettings settings; - int CptError; -}; - - -//******************************************************************************************************* -// FaceTrackNoIR Tracker DLL. Functions used to get general info on the Tracker -//******************************************************************************************************* -class TrackerDll : -#if defined(OPENTRACK_API) - public Metadata -#else - public ITrackerDll -#endif -{ -public: - TrackerDll(); - ~TrackerDll(); - - void getFullName(QString *strToBeFilled); - void getShortName(QString *strToBeFilled); - void getDescription(QString *strToBeFilled); - void getIcon(QIcon *icon); - -private: - QString trackerFullName; // Trackers' name and description - QString trackerShortName; - QString trackerDescription; -}; - - -#endif // FTNOIR_TRACKER_HAT_H diff --git a/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.cpp b/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.cpp deleted file mode 100644 index 83548966..00000000 --- a/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.cpp +++ /dev/null @@ -1,277 +0,0 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2012 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* Homepage: http://facetracknoir.sourceforge.net/home/default.htm * -* * -* Copyright (C) 2012 FuraX49 (HAT Tracker plugins) * -* Homepage: http://hatire.sourceforge.net * -* * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -********************************************************************************/ -#include "ftnoir_tracker_hat.h" -#include "ftnoir_tracker_hat_dialog.h" - -#include - -//******************************************************************************************************* -// FaceTrackNoIR Client Settings-dialog. -//******************************************************************************************************* - -// -// Constructor for server-settings-dialog -// -TrackerControls::TrackerControls() : theTracker(NULL), timer(this) -{ - - ui.setupUi( this ); - - ui.label_version->setText(VER_FILEVERSION_STR); - - // make SerialPort list - ui.cbSerialPort->clear(); - foreach (QSerialPortInfo PortInfo , QSerialPortInfo::availablePorts() ) { - ui.cbSerialPort->addItem(PortInfo.portName()); - } - - // Stop if no SerialPort dispo - if (ui.cbSerialPort->count()<1) { - QMessageBox::critical(this,"FaceTrackNoIR Error", "No SerialPort avaible"); - } else { - ui.cbSerialPort->setCurrentIndex(settings.SerialPortName); - } - // Serial config - ui.QCB_Serial_baudRate->clear(); - ui.QCB_Serial_baudRate->addItem(QLatin1String("9600"),QSerialPort::Baud9600); - ui.QCB_Serial_baudRate->addItem(QLatin1String("19200"),QSerialPort::Baud19200); - ui.QCB_Serial_baudRate->addItem(QLatin1String("38400"),QSerialPort::Baud38400); - ui.QCB_Serial_baudRate->addItem(QLatin1String("57600"),QSerialPort:: Baud57600); - ui.QCB_Serial_baudRate->addItem(QLatin1String("115200"),QSerialPort::Baud115200); - - ui.QCB_Serial_dataBits->clear(); - ui.QCB_Serial_dataBits->addItem(QLatin1String("5"), QSerialPort::Data5); - ui.QCB_Serial_dataBits->addItem(QLatin1String("6"), QSerialPort::Data6); - ui.QCB_Serial_dataBits->addItem(QLatin1String("7"), QSerialPort::Data7); - ui.QCB_Serial_dataBits->addItem(QLatin1String("8"), QSerialPort::Data8); - - ui.QCB_Serial_parity->clear(); - ui.QCB_Serial_parity->addItem(QLatin1String("None"), QSerialPort::NoParity); - ui.QCB_Serial_parity->addItem(QLatin1String("Even"), QSerialPort::EvenParity); - ui.QCB_Serial_parity->addItem(QLatin1String("Odd"), QSerialPort::OddParity); - ui.QCB_Serial_parity->addItem(QLatin1String("Space"), QSerialPort::SpaceParity); - ui.QCB_Serial_parity->addItem(QLatin1String("Mark"), QSerialPort::MarkParity); - - ui.QCB_Serial_stopBits->clear(); - ui.QCB_Serial_stopBits->addItem(QLatin1String("1")); - ui.QCB_Serial_stopBits->addItem(QLatin1String("1.5")); - ui.QCB_Serial_stopBits->addItem(QLatin1String("2")); - - - ui.QCB_Serial_flowControl->clear(); - ui.QCB_Serial_flowControl->addItem(QLatin1String("None")); - ui.QCB_Serial_flowControl->addItem(QLatin1String("RTS/CTS")); - ui.QCB_Serial_flowControl->addItem(QLatin1String("XON/XOFF")); - - tie_setting(settings.EnableRoll, ui.chkEnableRoll); - tie_setting(settings.EnablePitch, ui.chkEnablePitch); - tie_setting(settings.EnableYaw, ui.chkEnableYaw); - tie_setting(settings.EnableX, ui.chkEnableX); - tie_setting(settings.EnableY, ui.chkEnableY); - tie_setting(settings.EnableZ, ui.chkEnableZ); - - tie_setting(settings.InvertRoll, ui.chkInvertRoll); - tie_setting(settings.InvertPitch, ui.chkInvertPitch); - tie_setting(settings.InvertYaw, ui.chkInvertYaw); - tie_setting(settings.InvertX, ui.chkInvertX); - tie_setting(settings.InvertY, ui.chkInvertY); - tie_setting(settings.InvertZ, ui.chkInvertZ); - - tie_setting(settings.RollAxe, ui.cb_roll); - tie_setting(settings.RollAxe, ui.cb_roll); - tie_setting(settings.RollAxe, ui.cb_roll); - - tie_setting(settings.XAxe, ui.cb_x); - tie_setting(settings.YAxe, ui.cb_y); - tie_setting(settings.ZAxe, ui.cb_z); - - tie_setting(settings.CmdStart, ui.le_cmd_start); - tie_setting(settings.CmdStop, ui.le_cmd_stop); - tie_setting(settings.CmdInit, ui.le_cmd_init); - tie_setting(settings.CmdReset, ui.le_cmd_reset); - tie_setting(settings.CmdCenter, ui.le_cmd_center); - tie_setting(settings.CmdZero, ui.le_cmd_zero); - - tie_setting(settings.DelayInit, ui.spb_BeforeInit); - tie_setting(settings.DelayStart, ui.spb_BeforeStart); - tie_setting(settings.DelaySeq, ui.spb_AfterStart); - - tie_setting(settings.BigEndian, ui.cb_Endian); - - tie_setting(settings.pBaudRate, ui.QCB_Serial_baudRate); - tie_setting(settings.pDataBits, ui.QCB_Serial_dataBits); - tie_setting(settings.pParity, ui.QCB_Serial_parity); - tie_setting(settings.pStopBits, ui.QCB_Serial_stopBits); - tie_setting(settings.pFlowControl, ui.QCB_Serial_flowControl); - - tie_setting(settings.SerialPortName, ui.cbSerialPort); - - // Connect Qt signals to member-functions - connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); - connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); - connect(ui.btnSave, SIGNAL(clicked()), this, SLOT(doSave())); - - connect(ui.btnReset, SIGNAL(clicked()), this, SLOT(doReset())); - connect(ui.btnCenter, SIGNAL(clicked()), this, SLOT(doCenter())); - connect(ui.btnZero, SIGNAL(clicked()), this, SLOT(doZero())); - connect(ui.btnSend, SIGNAL(clicked()), this, SLOT(doSend())); - - connect(ui.btn_icone, SIGNAL(clicked()), this, SLOT(doSerialInfo())); - - connect(&timer,SIGNAL(timeout()), this,SLOT(poll_tracker_info())); -} - -// -// Center asked to ARDUINO -// -void TrackerControls::doCenter() { - if (theTracker) theTracker->notifyCenter(); -} - -// -// Zero asked to ARDUINO -// -void TrackerControls::doZero() { - if (theTracker) theTracker->notifyZeroed(); -} - - -// -// Reset asked to ARDUINO -// -void TrackerControls::doReset() { - if (theTracker) theTracker->reset(); -} - - -// -// Serial Info debug -// -void TrackerControls::doSerialInfo() { - if (theTracker) theTracker->SerialInfo(); -} - - -// -// Send command to ARDUINO -// -void TrackerControls::doSend() { - if (theTracker) { - if (!ui.lineSend->text().isEmpty()) { - theTracker->sendcmd(ui.lineSend->text().toLatin1()); - } - } -} - - -// -// Display FPS of Arduino. -// -void TrackerControls::poll_tracker_info() -{ - if (theTracker) - { - int nb_trame; - - theTracker->get_info(&nb_trame); - ui.lab_vtps->setText(QString::number(nb_trame*(1000/last_time.elapsed()))); - last_time.restart(); - } - -} - - -void TrackerControls::WriteMsgInfo(const QByteArray &MsgInfo) -{ - QApplication::beep(); - ui.pteINFO->moveCursor(QTextCursor::End); - ui.pteINFO->insertPlainText(QString(MsgInfo)); - QScrollBar *bar = ui.pteINFO->verticalScrollBar(); - bar->setValue(bar->maximum()); -} - - - -void TrackerControls::doSave() { - settings.b->save(); - if (theTracker) - theTracker->applysettings(settings); -} - - -// -// OK clicked on server-dialog -// -void TrackerControls::doOK() { - settings.b->save(); - if (theTracker) - theTracker->applysettings(settings); - this->close(); -} - -// -// Cancel clicked on server-dialog -// -void TrackerControls::doCancel() { - settings.b->revert(); - close(); -} - - -void TrackerControls::registerTracker(ITracker *tracker) { - theTracker = static_cast(tracker); - connect(theTracker, SIGNAL(sendMsgInfo(QByteArray)),this , SLOT(WriteMsgInfo(QByteArray))); - - if (isVisible() && settings.b->modifiedp()) theTracker->applysettings(settings); - - ui.cbSerialPort->setEnabled(false); - ui.pteINFO->clear(); - ui.lab_vstatus->setText("HAT START"); - last_time.start(); - timer.start(250); - -} - - -void TrackerControls::unRegisterTracker() { - theTracker=NULL; - timer.stop(); - ui.cbSerialPort->setEnabled(true); - ui.lab_vstatus->setText("HAT STOPPED"); - ui.lab_vtps->setText(""); -} - -#ifdef OPENTRACK_API -extern "C" FTNOIR_TRACKER_BASE_EXPORT ITrackerDialog* CALLING_CONVENTION GetDialog( ) -#else -#pragma comment(linker, "/export:GetTrackerDialog=_GetTrackerDialog@0") -FTNOIR_TRACKER_BASE_EXPORT ITrackerDialogPtr __stdcall GetTrackerDialog( ) -#endif -{ - return new TrackerControls; -} diff --git a/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.h b/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.h deleted file mode 100644 index fe16e5e8..00000000 --- a/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.h +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef FTNOIR_TRACKER_HAT_DIALOG_H -#define FTNOIR_TRACKER_HAT_DIALOG_H - -#ifdef OPENTRACK_API -#include "ftnoir_tracker_base/ftnoir_tracker_base.h" -#else -#include "..\ftnoir_tracker_base\ftnoir_tracker_base.h" -#endif -#include "ftnoir_tracker_hat_settings.h" -#include "ftnoir_tracker_hat.h" -#include "ui_ftnoir_hatcontrols.h" -#include -#include -#include -#include -#include - -// Widget that has controls for FTNoIR protocol client-settings. -class TrackerControls: public QWidget, public ITrackerDialog -{ - Q_OBJECT -public: - explicit TrackerControls(); - void registerTracker(ITracker *tracker) virt_override; - void unRegisterTracker() virt_override; -private: - Ui::UIHATControls ui; - FTNoIR_Tracker *theTracker; - QTime last_time; - -public slots: - void WriteMsgInfo(const QByteArray &MsgInfo); - -protected slots: - void doOK(); - void doCancel(); - void doSave(); - void doReset(); - void doCenter(); - void doZero(); - void doSend(); - void poll_tracker_info(); - void doSerialInfo(); - -protected: - TrackerSettings settings; - QTimer timer; -}; - -#endif //FTNOIR_TRACKER_HAT_DIALOG_H diff --git a/ftnoir_tracker_hatire/ftnoir_tracker_hat_dll.cpp b/ftnoir_tracker_hatire/ftnoir_tracker_hat_dll.cpp deleted file mode 100644 index 5f82d5a0..00000000 --- a/ftnoir_tracker_hatire/ftnoir_tracker_hat_dll.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2012 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* Homepage: http://facetracknoir.sourceforge.net/home/default.htm * -* * -* Copyright (C) 2012 FuraX49 (HAT Tracker plugins) * -* Homepage: http://hatire.sourceforge.net * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -********************************************************************************/ - -#include "ftnoir_tracker_hat.h" -#include -#include - -TrackerDll::TrackerDll() { - //populate the description strings - trackerFullName = "Hatire Arduino"; - trackerShortName = "HAT"; - trackerDescription = "FaceTrackNoIR HAT"; -} - -TrackerDll::~TrackerDll() -{ - -} - -void TrackerDll::getFullName(QString *strToBeFilled) -{ - *strToBeFilled = trackerFullName; -} - -void TrackerDll::getShortName(QString *strToBeFilled) -{ - *strToBeFilled = trackerShortName; -} - -void TrackerDll::getDescription(QString *strToBeFilled) -{ - *strToBeFilled = trackerDescription; -} - -void TrackerDll::getIcon(QIcon *icon) -{ - *icon = QIcon(":/images/hat.png"); -} - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Tracker object. - -// Export both decorated and undecorated names. -// GetTrackerDll - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetTrackerDll@0 - Common name decoration for __stdcall functions in C language. - -#ifdef OPENTRACK_API -# include "facetracknoir/global-settings.h" -extern "C" FTNOIR_TRACKER_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata() -#else -# pragma comment(linker, "/export:GetTrackerDll=_GetTrackerDll@0") -FTNOIR_TRACKER_BASE_EXPORT ITrackerDllPtr __stdcall GetTrackerDll() -#endif -{ - return new TrackerDll; -} diff --git a/ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.h b/ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.h deleted file mode 100644 index 4c0fcb8d..00000000 --- a/ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.h +++ /dev/null @@ -1,85 +0,0 @@ -/* Copyright (c) 2012 Patrick Ruoff - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - */ - -#pragma once - -#include -#include "facetracknoir/options.h" -#include -using namespace options; - -struct TrackerSettings -{ - pbundle b; - value EnableRoll, - EnablePitch, - EnableYaw, - EnableX, - EnableY, - EnableZ, - InvertRoll, - InvertPitch, - InvertYaw, - InvertX, - InvertY, - InvertZ; - value RollAxe, - PitchAxe, - YawAxe, - XAxe, - YAxe, - ZAxe; - value BigEndian; - value CmdStart, - CmdStop, - CmdInit, - CmdReset, - CmdCenter, - CmdZero; - value SerialPortName, DelayInit, DelayStart, DelaySeq; - // unfortunately, no way to distinguish this and enum type - // hence, string type used -sh - value pBaudRate, pDataBits, pParity, pStopBits, pFlowControl; - TrackerSettings() : - b(bundle("HAT")), - EnableRoll(b, "EnableRoll", true), - EnablePitch(b, "EnablePitch", true), - EnableYaw(b, "EnableYaw", true), - EnableX(b, "EnableX", true), - EnableY(b, "EnableY", true), - EnableZ(b, "EnableZ", true), - InvertRoll(b, "InvertRoll", false), - InvertPitch(b, "InvertPitch", false), - InvertYaw(b, "InvertYaw", false), - InvertX(b, "InvertX", false), - InvertY(b, "InvertY", false), - InvertZ(b, "InvertZ", false), - RollAxe(b, "RollAe", 2), - PitchAxe(b, "PitchAxe", 1), - YawAxe(b, "YawAxe", 0), - XAxe(b, "XAxe", 0), - YAxe(b, "YAxe", 1), - ZAxe(b, "ZAxe", 2), - BigEndian(b, "BigEndian", false), - CmdStart(b, "CmdStart", ""), - CmdStop(b, "CmdStop", ""), - CmdInit(b, "CmdInit", ""), - CmdReset(b, "CmdReset", ""), - CmdCenter(b, "CmdCenter", ""), - CmdZero(b, "CmdZero", ""), - SerialPortName(b, "PortName", 0), - DelayInit(b, "DelayInit", 0), - DelayStart(b, "DelayStart", 0), - DelaySeq(b, "DelaySeq", 0), - pBaudRate(b, "BaudRate", 0), - pDataBits(b, "DataBits", 0), - pParity(b, "Parity", 0), - pStopBits(b, "StopBits", 0), - pFlowControl(b, "FlowControl", 0) - { - } -}; diff --git a/ftnoir_tracker_hatire/images/hat.png b/ftnoir_tracker_hatire/images/hat.png deleted file mode 100644 index 46a6e442..00000000 Binary files a/ftnoir_tracker_hatire/images/hat.png and /dev/null differ diff --git a/ftnoir_tracker_hatire/images/hat_logo.png b/ftnoir_tracker_hatire/images/hat_logo.png deleted file mode 100644 index c3a92b1b..00000000 Binary files a/ftnoir_tracker_hatire/images/hat_logo.png and /dev/null differ -- cgit v1.2.3 From 0abdc671d5ffe56284b106fd48da2a1abacee6af Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 14 Jan 2014 00:03:00 +0100 Subject: pitch axis needs inverting too for FT protocol --- facetracknoir/tracker.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'facetracknoir') diff --git a/facetracknoir/tracker.cpp b/facetracknoir/tracker.cpp index 1f3257f5..ebc8246d 100644 --- a/facetracknoir/tracker.cpp +++ b/facetracknoir/tracker.cpp @@ -55,7 +55,7 @@ static void get_curve(double pos, double& out, THeadPoseDOF& axis) { static void t_compensate(double* input, double* output, bool rz) { const auto H = input[Yaw] * M_PI / -180; - const auto P = input[Pitch] * M_PI / 180; + const auto P = input[Pitch] * M_PI / -180; const auto B = input[Roll] * M_PI / 180; const auto cosH = cos(H); -- cgit v1.2.3 From aaa543f3bc04d832f5c3a848eb466b6f76e836c7 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 14 Jan 2014 07:15:57 +0100 Subject: switch to new profile after using the 'save as' function --- facetracknoir/facetracknoir.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index d93f2131..c7ef4c13 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -311,8 +311,8 @@ void FaceTrackNoIR::saveAs() save(); } - fill_profile_cbx(); looping = false; + fill_profile_cbx(); } void FaceTrackNoIR::loadSettings() { -- cgit v1.2.3 From a7f72b988b2036892f7219b90f5b094c8b9c2092 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 15 Jan 2014 19:17:29 +0100 Subject: free dialog windows on tracking stoppage This is necessary to make tracker dialogs non-modal, as otherwise invalid casts occur. --- facetracknoir/facetracknoir.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index c7ef4c13..640672a4 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -409,12 +409,20 @@ void FaceTrackNoIR::stopTracker( ) { if (pTrackerDialog) { pTrackerDialog->unRegisterTracker(); + delete pTrackerDialog; + pTrackerDialog = nullptr; } if (pProtocolDialog) { pProtocolDialog->unRegisterProtocol(); + delete pProtocolDialog; + pProtocolDialog = nullptr; } if (pFilterDialog) + { pFilterDialog->unregisterFilter(); + delete pFilterDialog; + pFilterDialog = nullptr; + } if ( tracker ) { delete tracker; -- cgit v1.2.3 From 32192e466dc3153f5874123b51f012ef9e562ff4 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 15 Jan 2014 22:41:53 +0100 Subject: also free the second tracker's dialog window --- facetracknoir/facetracknoir.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index 640672a4..98c8c2c2 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -423,6 +423,12 @@ void FaceTrackNoIR::stopTracker( ) { delete pFilterDialog; pFilterDialog = nullptr; } + if (pSecondTrackerDialog) + { + pSecondTrackerDialog->unRegisterTracker(); + delete pSecondTrackerDialog; + pSecondTrackerDialog = nullptr; + } if ( tracker ) { delete tracker; -- cgit v1.2.3 From 733b0ff713eb28c7c4b7dab5d3de423f784f2734 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 10 Feb 2014 07:35:59 +0100 Subject: don't load spline config twice --- facetracknoir/curve-config.cpp | 6 ++---- qfunctionconfigurator/qfunctionconfigurator.cpp | 10 +--------- qfunctionconfigurator/qfunctionconfigurator.h | 5 ++--- 3 files changed, 5 insertions(+), 16 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/curve-config.cpp b/facetracknoir/curve-config.cpp index 1e911ddd..2bff009a 100644 --- a/facetracknoir/curve-config.cpp +++ b/facetracknoir/curve-config.cpp @@ -83,10 +83,8 @@ void CurveConfigurationDialog::loadSettings() { for (int i = 0; i < 6; i++) { - configs[i]->setConfig(&mainApp->axis(i).curve, currentFile); - alt_configs[i]->setConfig(&mainApp->axis(i).curveAlt, currentFile); - configs[i]->loadSettings(currentFile); - alt_configs[i]->loadSettings(currentFile); + configs[i]->setConfig(&mainApp->axis(i).curve); + alt_configs[i]->setConfig(&mainApp->axis(i).curveAlt); } } diff --git a/qfunctionconfigurator/qfunctionconfigurator.cpp b/qfunctionconfigurator/qfunctionconfigurator.cpp index b959b56c..55d1e1bc 100644 --- a/qfunctionconfigurator/qfunctionconfigurator.cpp +++ b/qfunctionconfigurator/qfunctionconfigurator.cpp @@ -36,7 +36,7 @@ QFunctionConfigurator::QFunctionConfigurator(QWidget *parent) setMouseTracking(true); } -void QFunctionConfigurator::setConfig(FunctionConfig* config, QString settingsFile) { +void QFunctionConfigurator::setConfig(FunctionConfig* config) { QSettings settings("opentrack"); // 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) @@ -48,14 +48,6 @@ void QFunctionConfigurator::setConfig(FunctionConfig* config, QString settingsFi update(); } -void QFunctionConfigurator::loadSettings(QString settingsFile) { - - QSettings iniFile( settingsFile, QSettings::IniFormat ); // Application settings (in INI-file) - if (_config) { - _config->loadSettings(iniFile); - } -} - void QFunctionConfigurator::saveSettings(QString settingsFile) { QSettings iniFile( settingsFile, QSettings::IniFormat ); // Application settings (in INI-file) diff --git a/qfunctionconfigurator/qfunctionconfigurator.h b/qfunctionconfigurator/qfunctionconfigurator.h index bb2aced0..1f6b4f78 100644 --- a/qfunctionconfigurator/qfunctionconfigurator.h +++ b/qfunctionconfigurator/qfunctionconfigurator.h @@ -34,9 +34,8 @@ public: QFunctionConfigurator(QWidget *parent = 0); FunctionConfig* config(); - void setConfig(FunctionConfig* config, QString settingsFile); // Connect the FunctionConfig to the Widget. - void loadSettings(QString settingsFile); // Load the FunctionConfig (points) from the INI-file - void saveSettings(QString settingsFile); // Save the FunctionConfig (points) to the INI-file + void setConfig(FunctionConfig* config); + void saveSettings(QString settingsFile); signals: void CurveChanged(bool); -- cgit v1.2.3 From afbca18600670b900eaa0ab30a296428d66eaaaf Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 11 Jun 2014 17:41:44 +0200 Subject: implement a high-precision timer untested on OSX so far Signed-off-by: Stanislaw Halik --- CMakeLists.txt | 4 +++ facetracknoir/timer.hpp | 67 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 facetracknoir/timer.hpp (limited to 'facetracknoir') diff --git a/CMakeLists.txt b/CMakeLists.txt index 40682474..7e101bad 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -526,6 +526,10 @@ endif() link_with_dinput8(opentrack) +if(CMAKE_SYSTEM STREQUAL LINUX) + link_libraries(rt) +endif() + if(MSVC) SET_TARGET_PROPERTIES(opentrack PROPERTIES LINK_FLAGS "/ENTRY:mainCRTStartup") endif() diff --git a/facetracknoir/timer.hpp b/facetracknoir/timer.hpp new file mode 100644 index 00000000..306bcaa7 --- /dev/null +++ b/facetracknoir/timer.hpp @@ -0,0 +1,67 @@ +#pragma once +#include +#if defined (_WIN32) +#include +static inline void clock_gettime(int, struct timespec* ts) +{ + static LARGE_INTEGER freq = 0; + + if (!freq) + (void) QueryPerformanceFrequency(&freq); + + freq.QuadPart /= 1000000; + + LARGE_INTEGER d; + + (void) QueryPerformanceCounter(&d); + + d.QuadPart = d.QuadPart / freq.QuadPart; + + ts->tv_sec = d.QuadPart / 1000000; + ts->tv_nsec = d.QuadPart % 1000000; +} + +#else +# if defined(__MACH__) +# define CLOCK_MONOTONIC 0 +# include +# include +static inline void clock_gettime(int, struct timespec* ts) +{ + uint64_t state, nsec; + static mach_timebase_info_data_t sTimebaseInfo; + if ( sTimebaseInfo.denom == 0 ) { + (void) mach_timebase_info(&sTimebaseInfo); + } + state = mach_absolute_time(); + nsec = elapsed * sTimebaseInfo.numer / sTimebaseInfo.denom; + ts->tv_sec = nsec / 1000000; + ts->tv_nsec = nsec % 1000000; +} +# else +class Timer { +private: + struct timespec state; + int conv(const struct timespec& cur) + { + return (cur.tv_sec - state.tv_sec) * 1000L + (cur.tv_nsec - state.tv_nsec) / 1000000L; + } +public: + Timer() { + start(); + } + int start() { + struct timespec cur; + (void) clock_gettime(CLOCK_MONOTONIC, &cur); + int ret = conv(cur); + state = cur; + return ret; + } + int elapsed() { + struct timespec cur; + (void) clock_gettime(CLOCK_MONOTONIC, &cur); + return conv(cur); + } +}; +# endif +#endif -- cgit v1.2.3 From 2f85648fe4b6ec33adb2fa90be16da49acd1ad71 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 11 Jun 2014 17:42:12 +0200 Subject: remove unused header Signed-off-by: Stanislaw Halik --- facetracknoir/facetracknoir.h | 1 - 1 file changed, 1 deletion(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.h b/facetracknoir/facetracknoir.h index 0c251c46..50a6e0ec 100644 --- a/facetracknoir/facetracknoir.h +++ b/facetracknoir/facetracknoir.h @@ -47,7 +47,6 @@ #endif #include #include -#include #include "ui_facetracknoir.h" -- cgit v1.2.3 From 3d6ab158aec3569a13fb790d100f1ce3286772ca Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 11 Jun 2014 20:29:40 +0200 Subject: Fix OSX high resolution timers --- facetracknoir/timer.hpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/timer.hpp b/facetracknoir/timer.hpp index 306bcaa7..d8c15181 100644 --- a/facetracknoir/timer.hpp +++ b/facetracknoir/timer.hpp @@ -28,17 +28,18 @@ static inline void clock_gettime(int, struct timespec* ts) # include static inline void clock_gettime(int, struct timespec* ts) { - uint64_t state, nsec; static mach_timebase_info_data_t sTimebaseInfo; + uint64_t state, nsec; if ( sTimebaseInfo.denom == 0 ) { (void) mach_timebase_info(&sTimebaseInfo); } state = mach_absolute_time(); - nsec = elapsed * sTimebaseInfo.numer / sTimebaseInfo.denom; - ts->tv_sec = nsec / 1000000; - ts->tv_nsec = nsec % 1000000; + nsec = state * sTimebaseInfo.numer / sTimebaseInfo.denom; + ts->tv_sec = nsec / 1000000000L; + ts->tv_nsec = nsec % 1000000000L; } -# else +# endif +#endif class Timer { private: struct timespec state; @@ -63,5 +64,3 @@ public: return conv(cur); } }; -# endif -#endif -- cgit v1.2.3 From 7454496476ba17ea622781d280606161581c9544 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 11 Jun 2014 21:10:22 +0200 Subject: Fix Windows performance counters --- facetracknoir/timer.hpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/timer.hpp b/facetracknoir/timer.hpp index d8c15181..623836db 100644 --- a/facetracknoir/timer.hpp +++ b/facetracknoir/timer.hpp @@ -1,24 +1,24 @@ #pragma once #include #if defined (_WIN32) -#include +# include +# define CLOCK_MONOTONIC 0 static inline void clock_gettime(int, struct timespec* ts) { - static LARGE_INTEGER freq = 0; + static LARGE_INTEGER freq; - if (!freq) + if (!freq.QuadPart) (void) QueryPerformanceFrequency(&freq); - freq.QuadPart /= 1000000; - LARGE_INTEGER d; (void) QueryPerformanceCounter(&d); - d.QuadPart = d.QuadPart / freq.QuadPart; + d.QuadPart *= 1000000000L; + d.QuadPart /= freq.QuadPart; - ts->tv_sec = d.QuadPart / 1000000; - ts->tv_nsec = d.QuadPart % 1000000; + ts->tv_sec = d.QuadPart / 1000000000L; + ts->tv_nsec = d.QuadPart % 1000000000L; } #else -- cgit v1.2.3