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(-) 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(-) 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 60ac7c17eb4786949a130099a4ef26af00c2ea4f Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 19 Aug 2013 12:43:22 +0200 Subject: Simplify Accela's UI and preset equations --- CMakeLists.txt | 2 +- .../ftnoir_accela_filtercontrols.ui | 675 ++++++--------------- ftnoir_filter_accela/ftnoir_filter_accela.cpp | 111 +--- ftnoir_filter_accela/ftnoir_filter_accela.h | 31 +- .../ftnoir_filter_accela_dialog.cpp | 91 +-- ftnoir_filter_accela/ftnoir_filter_accela_dll.cpp | 18 - 6 files changed, 234 insertions(+), 694 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3731d7ec..10460e62 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -320,7 +320,7 @@ endif() target_link_libraries(opentrack-spline-widget ${MY_QT_LIBS}) 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} opentrack-spline-widget) + target_link_libraries(opentrack-filter-accela ${MY_QT_LIBS}) if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) SET_TARGET_PROPERTIES(opentrack-filter-accela diff --git a/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui b/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui index 1478254e..d66dfa80 100644 --- a/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui +++ b/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui @@ -9,8 +9,8 @@ 0 0 - 868 - 729 + 570 + 71 @@ -29,482 +29,193 @@ - - - - - true - - - - 0 - 0 - - - - - 850 - 650 - - - - - 300 - 650 - - - - 0 - - - - Preset - - - - - 10 - 10 - 111 - 16 - - - - Rotation smoothing - - - - - - 10 - 40 - 111 - 16 - - - - Translation smoothing - - - - - - 130 - 10 - 81 - 22 - - - - 0.100000000000000 - - - 10.000000000000000 - - - 3.000000000000000 - - - - - - 130 - 40 - 81 - 22 - - - - 0.100000000000000 - - - 10.000000000000000 - - - 0.750000000000000 - - - - - - 140 - 70 - 75 - 23 - - - - Set curves - - - - - - 60 - 70 - 75 - 23 - - - - Remove all - - - - - - Rotation - - - - - 20 - 10 - 819 - 571 - - - - 10 - - - 10 - - - 57 - - - 57 - - - 1 - - - 1 - - - - 255 - 170 - 0 - - - - - 192 - 192 - 192 - - - - Input - - - Output - - - Translation - - - - - - Translation - - - - - 20 - 10 - 819 - 581 - - - - 10 - - - 10 - - - 57 - - - 57 - - - 1 - - - 1 - - - - 85 - 255 - 0 - - - - - 192 - 192 - 192 - - - - Input - - - Output - - - - - - - - - - - - 25 - 0 - - - - - 150 - 16777215 - - - - color:#0; + + + + 243 + 10 + 76 + 22 + + + + + 25 + 0 + + + + + 150 + 16777215 + + + + color:#0; background:none; - - - Reduction factor: - - - - - - - - 50 - 15 - - - - 1 - - - 1000 - - - 5 - - - 100 - - - Qt::Horizontal - - - QSlider::NoTicks - - - - - - - - 35 - 22 - - - - background:none; - - - false - - - 1 - - - 1000 - - - 100 - - - - - - - - 25 - 0 - - - - - 150 - 16777215 - - - - color:#0; -background:none; - - - Zoom slowness: - - - - - - - - 50 - 15 - - - - 0 - - - 200 - - - 1 - - - 100 - - - Qt::Horizontal - - - QSlider::NoTicks - - - - - - - - 35 - 22 - - - - background:none; - - - false - - - 0 - - - 200 - - - 100 - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - OK - - - - - - - Cancel - - - - - - + + + Zoom slowness: + + + + + + 130 + 40 + 81 + 22 + + + + 0.100000000000000 + + + 65535.000000000000000 + + + 1.000000000000000 + + + + + + 130 + 10 + 81 + 22 + + + + 0.100000000000000 + + + 65535.000000000000000 + + + 1.000000000000000 + + + + + + 10 + 10 + 111 + 16 + + + + Rotation smoothing + + + + + + 325 + 13 + 189 + 15 + + + + + 50 + 15 + + + + 0 + + + 200 + + + 1 + + + 100 + + + Qt::Horizontal + + + QSlider::NoTicks + + + + + + 520 + 10 + 42 + 22 + + + + + 35 + 22 + + + + background:none; + + + false + + + 0 + + + 200 + + + 100 + + + + + + 10 + 40 + 111 + 16 + + + + Translation smoothing + + + + + + 409 + 40 + 75 + 23 + + + + OK + + + + + + 490 + 40 + 75 + 23 + + + + Cancel + + - - - QFunctionConfigurator - QWidget -
qfunctionconfigurator.h
-
-
- - slideReduction - valueChanged(int) - spinReduction - setValue(int) - - - 219 - 620 - - - 310 - 622 - - - - - spinReduction - valueChanged(int) - slideReduction - setValue(int) - - - 315 - 613 - - - 170 - 621 - - - slideZoom valueChanged(int) @@ -512,12 +223,12 @@ background:none; setValue(int) - 547 - 602 + 463 + 19 - 667 - 602 + 537 + 20 @@ -528,12 +239,12 @@ background:none; setValue(int) - 663 - 602 + 533 + 20 - 537 - 602 + 426 + 20 diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.cpp b/ftnoir_filter_accela/ftnoir_filter_accela.cpp index 0aea2f78..66744c2f 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela.cpp @@ -4,29 +4,16 @@ * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. */ -/* - Modifications (last one on top): - 20120807 - WVR: FunctionConfig is now also used for the Filter. The extrapolation was adapted from Stanislaw. - Additional changes: I have added two parameters to the constructor of FunctionConfig and - renamed 3 member-functions (getFilterFullName is now called getFullName). -*/ #include "ftnoir_filter_accela/ftnoir_filter_accela.h" #include "math.h" #include #include #include "facetracknoir/global-settings.h" -#if !defined(_WIN32) && !defined(__WIN32) -# define _isnan isnan -#endif - -FTNoIR_Filter::FTNoIR_Filter() : - functionConfig("Accela-Scaling-Rotation", 10, 10), - translationFunctionConfig("Accela-Scaling-Translation", 10, 10) +FTNoIR_Filter::FTNoIR_Filter() { first_run = true; - kMagicNumber = 1000; - loadSettings(); // Load the Settings + loadSettings(); } FTNoIR_Filter::~FTNoIR_Filter() @@ -40,102 +27,50 @@ void FTNoIR_Filter::loadSettings() { QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) - functionConfig.loadSettings(iniFile); - translationFunctionConfig.loadSettings(iniFile); - iniFile.beginGroup ( "Accela" ); - kMagicNumber = iniFile.value ( "Reduction", 1000 ).toFloat(); - kZoomSlowness = iniFile.value("zoom-slowness", 0).toFloat(); + 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 (); } +static double parabola(const double a, const double x) +{ + const double a1 = 1./a; + return a1 * a1 * x * x; +} + void FTNoIR_Filter::FilterHeadPoseData(double *current_camera_position, double *target_camera_position, double *new_camera_position, double *last_post_filter_values) { - double target[6]; - double prev_output[6]; - float output[6]; - - for (int i = 0; i < 6; i++) - { - prev_output[i] = current_camera_position[i]; - target[i] = target_camera_position[i]; - } - if (first_run) { for (int i = 0; i < 6; i++) { - new_camera_position[i] = target[i]; - current_camera_position[i] = target[i]; + new_camera_position[i] = target_camera_position[i]; + current_camera_position[i] = target_camera_position[i]; } - first_run=false; + first_run = false; return; } for (int i=0;i<6;i++) { - if (_isnan(target[i])) - return; - - if (_isnan(prev_output[i])) - return; - - double e2 = target[i]; - double start = prev_output[i]; - double vec = e2 - start; - int sign = vec < 0 ? -1 : 1; - double x = fabs(vec); - QList points = (i >= 3 ? functionConfig : translationFunctionConfig).getPoints(); - int extrapolatep = 0; - double ratio; - double maxx; - double add; - // linear extrapolation of a spline - if (points.size() > 1) { - QPointF last = points[points.size() - 1]; - QPointF penultimate = points[points.size() - 2]; - ratio = (last.y() - penultimate.y()) / (last.x() - penultimate.x()); - extrapolatep = 1; - add = last.y(); - maxx = last.x(); - } - double foo = extrapolatep && x > maxx ? add + ratio * (x - maxx) : (i >= 3 ? functionConfig : translationFunctionConfig).getValue(x); - // the idea is that "empty" updates without new head pose data are still - // useful for filtering, as skipping them would result in jerky output. - // the magic "100" is the amount of calls to the filter by FTNOIR per sec. - // WVR: Added kMagicNumber for Patrick - double velocity = foo / kMagicNumber * (1 / std::max(1.0, 1 + kZoomSlowness * -last_post_filter_values[TZ] / 100)); - double sum = start + velocity * sign; - bool done = (sign > 0 ? sum >= e2 : sum <= e2); - if (done) { - output[i] = e2; - } else { - output[i] = sum; - } - - if (_isnan(output[i])) - return; + 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; } - - for (int i = 0; i < 6; i++) - { - new_camera_position[i] = output[i]; - current_camera_position[i] = output[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. - 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 6e98c797..a0b7f3ef 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.h +++ b/ftnoir_filter_accela/ftnoir_filter_accela.h @@ -31,13 +31,10 @@ #include "ftnoir_filter_base/ftnoir_filter_base.h" #include "ui_ftnoir_accela_filtercontrols.h" -#include #include "facetracknoir/global-settings.h" -// -// Macro to determine array-size -// -#define NUM_OF(x) (sizeof (x) / sizeof *(x)) +#define ACCELA_SMOOTHING_ROTATION 6.0 +#define ACCELA_SMOOTHING_TRANSLATION 3.0 //******************************************************************************************************* // FaceTrackNoIR Filter class. @@ -54,13 +51,8 @@ public: private: void loadSettings(); // Load the settings from the INI-file - double newHeadPose[6]; // Structure with new headpose - - bool first_run; - double kMagicNumber, kZoomSlowness; // Stanislaws' magic number (should be 100 according to him...) - - FunctionConfig functionConfig; - FunctionConfig translationFunctionConfig; + bool first_run; + double rotation_alpha, translation_alpha, zoom_factor; }; //******************************************************************************************************* @@ -82,21 +74,12 @@ private: Ui::AccelaUICFilterControls ui; void loadSettings(); void save(); - - /** helper **/ bool settingsDirty; - - IFilter* pFilter; // If the filter was active when the dialog was opened, this will hold a pointer to the Filter instance - FunctionConfig functionConfig; - FunctionConfig translationFunctionConfig; - private slots: void doOK(); void doCancel(); void settingChanged(bool) { settingsDirty = true; } void settingChanged(int) { settingsDirty = true; } - void resetCircle(); - void removeAll(); }; //******************************************************************************************************* @@ -108,9 +91,9 @@ public: FTNoIR_FilterDll(); ~FTNoIR_FilterDll(); - void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("Accela Filter Mk2"); } - void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("Accela Mk2"); } - void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("Accela filter Mk2"); } + 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"); } }; diff --git a/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp b/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp index 1de51b10..f0641ea6 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp @@ -39,9 +39,7 @@ // Constructor for server-settings-dialog // FilterControls::FilterControls() : - QWidget(), - functionConfig("Accela-Scaling-Rotation", 10, 10), - translationFunctionConfig("Accela-Scaling-Translation", 10, 10) + QWidget() { ui.setupUi( this ); @@ -49,13 +47,11 @@ FilterControls::FilterControls() : loadSettings(); connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); - connect(ui.scalingConfig, SIGNAL(CurveChanged(bool)), this, SLOT(settingChanged(bool))); - connect(ui.translationScalingConfig, SIGNAL(CurveChanged(bool)), this, SLOT(settingChanged(bool))); - connect(ui.resetCircle, SIGNAL(clicked()), this, SLOT(resetCircle())); - connect(ui.removeAllButton, SIGNAL(clicked()), this, SLOT(removeAll())); + connect(ui.rotation_alpha, SIGNAL(valueChanged(double)), this, SLOT(settingChanged(int))); + connect(ui.translation_alpha, SIGNAL(valueChanged(double)), this, SLOT(settingChanged(int))); - // Connect slider for reduction - //connect(ui.slideReduction, SIGNAL(valueChanged(int)), 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"; } @@ -71,13 +67,6 @@ 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; loadSettings(); QPoint offsetpos(100, 100); @@ -145,74 +134,16 @@ void FilterControls::loadSettings() { //qDebug() << "FTNoIR_Filter::loadSettings2 says: size = " << NUM_OF(defScaleRotation); - ui.translationScalingConfig->setConfig(&translationFunctionConfig, currentFile); - ui.scalingConfig->setConfig(&functionConfig, currentFile); - iniFile.beginGroup ( "Accela" ); - ui.slideReduction->setValue (iniFile.value ( "Reduction", 1000 ).toInt()); ui.slideZoom->setValue(iniFile.value("zoom-slowness", 0).toInt()); - ui.rotationCircle->setValue(iniFile.value("preset-rotation", 3).toDouble()); - ui.translationCircle->setValue(iniFile.value("preset-translation", 0.75).toDouble()); + 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; } -void FilterControls::removeAll() { - translationFunctionConfig.removeAllPoints(); - functionConfig.removeAllPoints(); -} - -void FilterControls::resetCircle() -{ - 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" ); - iniFile.setValue("preset-rotation", ui.rotationCircle->value()); - iniFile.setValue("preset-translation", ui.translationCircle->value()); - iniFile.endGroup(); - - // essentially unit circles elongated on the X axis - double elongations[] = { - ui.rotationCircle->value(), ui.translationCircle->value() - }; - - FunctionConfig* configs[] = { - &functionConfig, &translationFunctionConfig - }; - - QFunctionConfigurator* widgets[] = { - ui.scalingConfig, ui.translationScalingConfig - }; - - for (int i = 0; i < 2; i++) - { - FunctionConfig& cfg = *configs[i]; - double sz = elongations[i]; - - cfg.removeAllPoints(); - - for (double x = 0; x <= sz+1e-2; x += 1e-1) - { - double sq = sz*sz-x*x; - double val; - if (sq <= 1e-4) - val = 0; - else - val = std::min(sqrt(sq), sz); - - cfg.addPoint(QPointF(x, 10*(sz-val)/sz)); - } - - cfg.saveSettings(iniFile); - - widgets[i]->setConfig(&cfg, currentFile); - } - - settingsDirty = false; -} - // // Save the current Settings to the currently 'active' INI-file. // @@ -225,13 +156,11 @@ void FilterControls::save() { qDebug() << "FTNoIR_Filter::save() says: iniFile = " << currentFile; iniFile.beginGroup ( "Accela" ); - iniFile.setValue ( "Reduction", ui.slideReduction->value() ); iniFile.setValue("zoom-slowness", ui.slideZoom->value()); + iniFile.setValue("rotation-alpha", ui.rotation_alpha->value()); + iniFile.setValue("translation-alpha", ui.translation_alpha->value()); iniFile.endGroup (); - functionConfig.saveSettings(iniFile); - translationFunctionConfig.saveSettings(iniFile); - settingsDirty = false; } diff --git a/ftnoir_filter_accela/ftnoir_filter_accela_dll.cpp b/ftnoir_filter_accela/ftnoir_filter_accela_dll.cpp index 3ae273df..0235c067 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela_dll.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela_dll.cpp @@ -22,16 +22,7 @@ * 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_accela.h" -#include #include "facetracknoir/global-settings.h" FTNoIR_FilterDll::FTNoIR_FilterDll() { @@ -42,15 +33,6 @@ 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; -- 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(+) 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(-) 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 afbec6a10b1e718fed134f61295e92f1e94770d4 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 24 Aug 2013 22:33:52 +0200 Subject: Workaround camera frame-retrieval badness --- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index 152c1e32..6fff39d3 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #if defined(_WIN32) || defined(__WIN32) #include @@ -185,12 +186,19 @@ void Tracker::run() aruco::MarkerDetector detector; detector.setDesiredSpeed(3); detector.setThresholdParams(11, 5); - cv::Mat color, grayscale, rvec, tvec; + cv::Mat color, color_, grayscale, rvec, tvec; + + if (!camera.isOpened()) + { + fprintf(stderr, "aruco tracker: can't open camera\n"); + return; + } while (!stop) { - if (!camera.read(color)) - break; + if (!camera.read(color_)) + continue; + color_.copyTo(color); cv::cvtColor(color, grayscale, cv::COLOR_BGR2GRAY); const float focal_length_w = 0.5 * grayscale.cols / tan(0.5 * fov * HT_PI / 180); const float focal_length_h = 0.5 * grayscale.rows / tan(0.5 * fov * grayscale.rows / grayscale.cols * HT_PI / 180.0); -- 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(-) 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(-) 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(+) 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 877ae430dc80280b00ef508f790db6cf0a9d862b Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 13 Sep 2013 13:58:59 +0200 Subject: Cleanup unused functions --- ftnoir_filter_base/ftnoir_filter_base.h | 23 ----------------------- ftnoir_protocol_base/ftnoir_protocol_base.h | 16 ---------------- ftnoir_tracker_base/ftnoir_tracker_base.h | 20 -------------------- 3 files changed, 59 deletions(-) diff --git a/ftnoir_filter_base/ftnoir_filter_base.h b/ftnoir_filter_base/ftnoir_filter_base.h index b38fc226..aef76370 100644 --- a/ftnoir_filter_base/ftnoir_filter_base.h +++ b/ftnoir_filter_base/ftnoir_filter_base.h @@ -30,33 +30,10 @@ struct IFilter virtual void Initialize() = 0; }; -// Factory function that creates instances of the Filter object. - -//////////////////////////////////////////////////////////////////////////////// -// 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 IFilterDll -{ - virtual ~IFilterDll() {} - - virtual void getFullName(QString *strToBeFilled) = 0; - virtual void getShortName(QString *strToBeFilled) = 0; - virtual void getDescription(QString *strToBeFilled) = 0; - virtual void getIcon(QIcon *icon) = 0; -}; - struct IFilterDialog { virtual ~IFilterDialog() {} virtual void Initialize(QWidget *parent, IFilter* ptr) = 0; - - virtual void getFullName(QString *strToBeFilled) {}; - virtual void getShortName(QString *strToBeFilled) {}; - virtual void getDescription(QString *strToBeFilled) {}; - virtual void getIcon(QIcon *icon) {}; }; #endif // FTNOIR_FILTER_BASE_H diff --git a/ftnoir_protocol_base/ftnoir_protocol_base.h b/ftnoir_protocol_base/ftnoir_protocol_base.h index d6e4cb58..8533363d 100644 --- a/ftnoir_protocol_base/ftnoir_protocol_base.h +++ b/ftnoir_protocol_base/ftnoir_protocol_base.h @@ -62,22 +62,6 @@ struct IProtocol virtual QString getGameName() = 0; }; -//////////////////////////////////////////////////////////////////////////////// -// 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 IProtocolDll -{ - virtual ~IProtocolDll() {} - - virtual void getFullName(QString *strToBeFilled) = 0; - virtual void getShortName(QString *strToBeFilled) = 0; - virtual void getDescription(QString *strToBeFilled) = 0; - virtual void getIcon(QIcon *icon) = 0; -}; - struct IProtocolDialog { virtual ~IProtocolDialog() {} diff --git a/ftnoir_tracker_base/ftnoir_tracker_base.h b/ftnoir_tracker_base/ftnoir_tracker_base.h index 182a364c..7c2ab442 100644 --- a/ftnoir_tracker_base/ftnoir_tracker_base.h +++ b/ftnoir_tracker_base/ftnoir_tracker_base.h @@ -59,7 +59,6 @@ struct ITracker virtual bool GiveHeadPoseData(double *data) = 0; virtual void WaitForExit() = 0; - virtual void NotifyCenter() {} }; @@ -79,23 +78,4 @@ struct ITrackerDialog virtual void unRegisterTracker() = 0; }; - -//////////////////////////////////////////////////////////////////////////////// -// 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 ITrackerDll -{ - virtual ~ITrackerDll() {} - virtual void Initialize() = 0; - - virtual void getFullName(QString *strToBeFilled) = 0; - virtual void getShortName(QString *strToBeFilled) = 0; - virtual void getDescription(QString *strToBeFilled) = 0; - virtual void getIcon(QIcon *icon) = 0; -}; - - #endif // FTNOIR_TRACKER_BASE_H -- 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(-) 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(-) 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 7bd12c290e397fbd258f875cbee78cf5f31c4621 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 13 Sep 2013 14:55:55 +0200 Subject: Make Accela dialog non-modal --- ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui b/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui index d66dfa80..bb27ed47 100644 --- a/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui +++ b/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui @@ -3,7 +3,7 @@ AccelaUICFilterControls - Qt::ApplicationModal + Qt::NonModal -- 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(-) 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(-) 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(-) 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(-) 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 04c1f89044a6abc7f922cc8981e74872d63a1bff Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 13 Sep 2013 16:11:31 +0200 Subject: Correct Accela Mk3 default coefficients --- ftnoir_filter_accela/ftnoir_filter_accela.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.h b/ftnoir_filter_accela/ftnoir_filter_accela.h index 0c13c0e8..fb860136 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.h +++ b/ftnoir_filter_accela/ftnoir_filter_accela.h @@ -34,8 +34,8 @@ #include "facetracknoir/global-settings.h" #include -#define ACCELA_SMOOTHING_ROTATION 6.0 -#define ACCELA_SMOOTHING_TRANSLATION 3.0 +#define ACCELA_SMOOTHING_ROTATION 60.0 +#define ACCELA_SMOOTHING_TRANSLATION 40.0 //******************************************************************************************************* // FaceTrackNoIR Filter class. -- 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(-) 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 5ab731d8fce19da39527fcca87567a59e249594d Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 13 Sep 2013 16:58:03 +0200 Subject: Don't conditionalize Q_DECL_{IMPORT,EXPORT} for clarity --- CMakeLists.txt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 10460e62..8c7b1389 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,9 +28,7 @@ if(NOT SDK_FACEAPI_ONLY) find_package(OpenCV) find_package(Qt4 COMPONENTS QtCore QtGui QtDesigner QtXml QtNetwork REQUIRED) - if(WIN32 AND NOT CMAKE_COMPILER_IS_GNUCC) - add_definitions(-DFTNOIR_FILTER_BASE_LIB -DFTNOIR_TRACKER_BASE_LIB -DFTNOIR_PROTOCOL_BASE_LIB) - endif(WIN32 AND NOT CMAKE_COMPILER_IS_GNUCC) + add_definitions(-DFTNOIR_FILTER_BASE_LIB -DFTNOIR_TRACKER_BASE_LIB -DFTNOIR_PROTOCOL_BASE_LIB) if(NOT WIN32) if(NOT QXT_QXTGUI_LIB_RELEASE) -- 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(-) 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 e695bca32e6f34461dfa720a2b693835adbb9422 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 14 Sep 2013 00:43:10 +0200 Subject: Remove the modal flag from PT settings dialog --- ftnoir_tracker_pt/ftnoir_pt_controls.ui | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/ftnoir_tracker_pt/ftnoir_pt_controls.ui b/ftnoir_tracker_pt/ftnoir_pt_controls.ui index 0934a4fb..6a183eae 100644 --- a/ftnoir_tracker_pt/ftnoir_pt_controls.ui +++ b/ftnoir_tracker_pt/ftnoir_pt_controls.ui @@ -3,14 +3,14 @@ UICPTClientControls - Qt::ApplicationModal + Qt::NonModal 0 0 - 451 - 489 + 468 + 528 @@ -962,7 +962,7 @@ - :/resources/clip_side.png + :/resources/clip_side.png @@ -1085,7 +1085,7 @@ - :/resources/clip_front.png + :/resources/clip_front.png @@ -1140,7 +1140,7 @@ - :/resources/cap_side.png + :/resources/cap_side.png @@ -1250,7 +1250,7 @@ - :/resources/cap_front.png + :/resources/cap_front.png @@ -1659,7 +1659,7 @@ - :/resources/logo_ir.png + :/resources/logo_ir.png @@ -1738,9 +1738,7 @@ ok_button cancel_button - - - + dynpose_check -- 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(-) 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(-) 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(-) 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(-) 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 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 cf5a0fb030e44f616475b9c85115f0eafeecde70 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 14 Sep 2013 17:13:34 +0200 Subject: refactor QFunctionConfigurator While the API is more clear now and withstands config changes properly, there's a performance degradation while moving a spline point. It now refreshes whole spline. --- qfunctionconfigurator/qfunctionconfigurator.cpp | 657 ++++++++++++------------ qfunctionconfigurator/qfunctionconfigurator.h | 28 +- 2 files changed, 332 insertions(+), 353 deletions(-) diff --git a/qfunctionconfigurator/qfunctionconfigurator.cpp b/qfunctionconfigurator/qfunctionconfigurator.cpp index 05ebbc4a..418d46c8 100644 --- a/qfunctionconfigurator/qfunctionconfigurator.cpp +++ b/qfunctionconfigurator/qfunctionconfigurator.cpp @@ -55,31 +55,30 @@ QFunctionConfigurator::QFunctionConfigurator(QWidget *parent) : 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 - gDistEGU_Output = 10; // Distance of gridlines - - - // Change compared to BezierConfigurator: X = horizontal (input), Y = vertical (output) - // 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); + // + // 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 + gDistEGU_Output = 10; // Distance of gridlines + + + // Change compared to BezierConfigurator: X = horizontal (input), Y = vertical (output) + // 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 - // - // Variables for FunctionConfig - // - _config = 0; - _points = QList(); - _draw_background = true; - _draw_function = true; + // + // Variables for FunctionConfig + // + _config = 0; + _draw_background = true; + _draw_function = true; // qDebug() << "QFunctionConfigurator::QFunctionConfigurator object created."; @@ -89,10 +88,6 @@ QFunctionConfigurator::QFunctionConfigurator(QWidget *parent) // Attach an existing FunctionConfig to the Widget. // void QFunctionConfigurator::setConfig(FunctionConfig* config, QString settingsFile) { - QPointF currentPoint; - QPointF drawPoint; - qreal x; - 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) @@ -100,32 +95,13 @@ void QFunctionConfigurator::setConfig(FunctionConfig* config, QString settingsFi _config = config; - _points = config->getPoints(); strSettingsFile = settingsFile; // Remember for Reset() qDebug() << "QFunctionConfigurator::setConfig" << config->getTitle(); setCaption(config->getTitle()); - // - // Get the Function Points, one for each pixel in the horizontal range. - // If the curve does not change, there is no need to run this code every time (it slows down drawing). - // - for (int j = 0; j < MaxInput * pPerEGU_Input; j++) { - // - // Weird: not casting to float causes C++ to round the number... - // - x = (float) j / (float) pPerEGU_Input; - currentPoint.setX ( x ); - currentPoint.setY (_config->getValue( x )); - drawPoint = graphicalizePoint(currentPoint, "setConfig"); - //if (withinRect(drawPoint, range)) { - //_draw_points.append(drawPoint); -// qDebug() << "QFunctionConfigurator::setConfig _draw_Point to add = " << drawPoint; - //} - } - - _draw_function = true; - this->update(); + _draw_function = _draw_background = true; + this->update(); } // @@ -133,25 +109,25 @@ void QFunctionConfigurator::setConfig(FunctionConfig* config, QString settingsFi // void QFunctionConfigurator::loadSettings(QString settingsFile) { - QSettings iniFile( settingsFile, QSettings::IniFormat ); // Application settings (in INI-file) - strSettingsFile = settingsFile; // Remember for Reset() - qDebug() << "QFunctionConfigurator::loadSettings = " << settingsFile; - if (_config) { - _config->loadSettings(iniFile); - } + QSettings iniFile( settingsFile, QSettings::IniFormat ); // Application settings (in INI-file) + strSettingsFile = settingsFile; // Remember for Reset() + qDebug() << "QFunctionConfigurator::loadSettings = " << settingsFile; + if (_config) { + _config->loadSettings(iniFile); + } } // // Save the FunctionConfig (points) to the INI-file. // void QFunctionConfigurator::saveSettings(QString settingsFile) { - QSettings iniFile( settingsFile, QSettings::IniFormat ); // Application settings (in INI-file) - strSettingsFile = settingsFile; // Remember for Reset() - qDebug() << "QFunctionConfigurator::saveSettings = " << settingsFile; + QSettings iniFile( settingsFile, QSettings::IniFormat ); // Application settings (in INI-file) + strSettingsFile = settingsFile; // Remember for Reset() + qDebug() << "QFunctionConfigurator::saveSettings = " << settingsFile; - if (_config) { - _config->saveSettings(iniFile); - } + if (_config) { + _config->saveSettings(iniFile); + } } // @@ -163,71 +139,71 @@ void QFunctionConfigurator::drawBackground(const QRectF &fullRect) int i; QRect scale; - qDebug() << "QFunctionConfigurator::drawBackground."; + qDebug() << "QFunctionConfigurator::drawBackground."; - _background = QPixmap(fullRect.width(), fullRect.height()); - QPainter painter(&_background); + _background = QPixmap(fullRect.width(), fullRect.height()); + QPainter painter(&_background); - painter.save(); - painter.setRenderHint(QPainter::Antialiasing); - painter.fillRect(fullRect, colBackground); - QColor bg_color(112, 154, 209); - painter.fillRect(range, bg_color); + painter.save(); + 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("ComicSans", 4); font.setPointSize(8); painter.setFont(font); QPen pen(QColor(55, 104, 170, 127), 1, Qt::SolidLine); - // - // Draw the Caption - // - if (_config) { - strCaption = _config->getTitle(); - } - - scale.setCoords(range.left(), 0, range.right(), 20); - painter.drawText(scale, Qt::AlignCenter, strCaption); - - // - // Draw the horizontal grid - // - for (i = range.bottom() - gDistEGU_Output * pPerEGU_Output; i >= range.top(); i -= gDistEGU_Output * pPerEGU_Output) { - drawLine(&painter, QPointF(40, i), QPointF(range.right(), i), pen); - scale.setCoords(0, i - 5, range.left() - 5, i + 5); - painter.drawText(scale, Qt::AlignRight, tr("%1").arg(((range.bottom() - i))/pPerEGU_Output)); - } - - // - // Draw the vertical guidelines - // - for (i = range.left(); i <= range.right(); i += gDistEGU_Input * pPerEGU_Input) { - drawLine(&painter, QPointF(i, range.top()), QPointF(i, range.bottom()), pen); - scale.setCoords(i - 10, range.bottom() + 2, i + 10, range.bottom() + 15); - painter.drawText(scale, Qt::AlignCenter, tr("%1").arg(abs(((range.left() - i))/pPerEGU_Input))); - } - - scale.setCoords(range.left(), range.bottom() + 20, range.right(), range.bottom() + 35); - painter.drawText(scale, Qt::AlignRight, strInputEGU); - - // - // Draw the EGU of the vertical axis (vertically!) - // - font.setPointSize(10); - painter.translate(range.topLeft().x() - 35, range.topLeft().y()); - painter.rotate(90); - painter.drawText(0,0,strOutputEGU ); - - // - // Draw the two axis - // - pen.setWidth(2); - 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(); + // + // Draw the Caption + // + if (_config) { + strCaption = _config->getTitle(); + } + + scale.setCoords(range.left(), 0, range.right(), 20); + painter.drawText(scale, Qt::AlignCenter, strCaption); + + // + // Draw the horizontal grid + // + for (i = range.bottom() - gDistEGU_Output * pPerEGU_Output; i >= range.top(); i -= gDistEGU_Output * pPerEGU_Output) { + drawLine(&painter, QPointF(40, i), QPointF(range.right(), i), pen); + scale.setCoords(0, i - 5, range.left() - 5, i + 5); + painter.drawText(scale, Qt::AlignRight, tr("%1").arg(((range.bottom() - i))/pPerEGU_Output)); + } + + // + // Draw the vertical guidelines + // + for (i = range.left(); i <= range.right(); i += gDistEGU_Input * pPerEGU_Input) { + drawLine(&painter, QPointF(i, range.top()), QPointF(i, range.bottom()), pen); + scale.setCoords(i - 10, range.bottom() + 2, i + 10, range.bottom() + 15); + painter.drawText(scale, Qt::AlignCenter, tr("%1").arg(abs(((range.left() - i))/pPerEGU_Input))); + } + + scale.setCoords(range.left(), range.bottom() + 20, range.right(), range.bottom() + 35); + painter.drawText(scale, Qt::AlignRight, strInputEGU); + + // + // Draw the EGU of the vertical axis (vertically!) + // + font.setPointSize(10); + painter.translate(range.topLeft().x() - 35, range.topLeft().y()); + painter.rotate(90); + painter.drawText(0,0,strOutputEGU ); + + // + // Draw the two axis + // + pen.setWidth(2); + 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(); } @@ -236,46 +212,48 @@ QRect scale; // void QFunctionConfigurator::drawFunction(const QRectF &fullRect) { - if (!_config) - return; + if (!_config) + return; int i; QPointF prevPoint; QPointF currentPoint; - // - // Use the background picture to draw on. - // ToDo: find out how to add Pixmaps, without getting it all green... - // - _function = QPixmap(_background); - QPainter painter(&_function); + // + // Use the background picture to draw on. + // ToDo: find out how to add Pixmaps, without getting it all green... + // + _function = QPixmap(_background); + QPainter painter(&_function); - painter.save(); + painter.save(); painter.setRenderHint(QPainter::Antialiasing, true); - // - // Draw the handles for the Points - // - for (i = 0; i < _points.size(); i++) { - currentPoint = graphicalizePoint( _points[i], "drawFunction handles" ); // Get the next point and convert it to Widget measures - drawPoint(&painter, currentPoint, QColor(200, 200, 210, 120)); - lastPoint = currentPoint; // Remember which point is the rightmost in the graph -//qDebug() << "QFunctionConfigurator::paintEvent, drawing handle for " << currentPoint; - } + // + // Draw the handles for the Points + // + + QList points = _config->getPoints(); + + for (i = 0; i < points.size(); i++) { + currentPoint = graphicalizePoint( points[i] ); // Get the next point and convert it to Widget measures + drawPoint(&painter, currentPoint, QColor(200, 200, 210, 120)); + lastPoint = currentPoint; // Remember which point is the rightmost in the graph + } QPen pen(colBezier, 1.2, Qt::SolidLine); - prevPoint = graphicalizePoint( QPointF(0,0), "drawFunction lines" ); // Start at the Axis - double max = maxInputEGU(); - QPointF prev = graphicalizePoint(QPointF(0, 0)); + prevPoint = graphicalizePoint( QPointF(0,0) ); // Start at the Axis + double max = maxInputEGU(); + QPointF prev = graphicalizePoint(QPointF(0, 0)); double step = 1e-1 / (double) pixPerEGU_Input(); - for (double i = 0; i < max; i += step) { - double val = _config->getValue(i); - QPointF cur = graphicalizePoint(QPointF(i, val)); - drawLine(&painter, prev, cur, pen); - prev = cur; - } - painter.restore(); + for (double i = 0; i < max; i += step) { + double val = _config->getValue(i); + QPointF cur = graphicalizePoint(QPointF(i, val)); + drawLine(&painter, prev, cur, pen); + prev = cur; + } + painter.restore(); } // @@ -290,80 +268,81 @@ int i; // qDebug() << "QFunctionConfigurator::paintEvent."; - QPainter p(this); + 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 - _draw_background = false; - } - - if (_draw_function) { - drawFunction(e->rect()); // 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); - - // - // Draw the Points, that make up the Curve - // - if (_config) { - // - // When moving, also draw a sketched version of the Function. - // - if (movingPoint >= 0 && movingPoint < _points.size()) { - prevPoint = graphicalizePoint( QPointF(0,0), "paintEvent moving" ); // Start at the Axis - for (i = 0; i < _points.size(); i++) { - currentPoint = graphicalizePoint( _points[i], "paintEvent moving" ); // Get the next point and convert it to Widget measures - drawLine(&p, prevPoint, currentPoint, pen); - prevPoint = currentPoint; + if (_draw_background) { + drawBackground(e->rect()); // Draw the static parts on a Pixmap + p.drawPixmap(0, 0, _background); // Paint the background + _draw_background = false; + } + + if (_draw_function) { + drawFunction(e->rect()); // 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); + + // + // Draw the Points, that make up the Curve + // + if (_config) { + QList points = _config->getPoints(); + // + // When moving, also draw a sketched version of the Function. + // + if (movingPoint >= 0 && movingPoint < points.size()) { + prevPoint = graphicalizePoint( QPointF(0,0) ); // Start at the Axis + for (i = 0; i < points.size(); i++) { + currentPoint = graphicalizePoint( points[i] ); // Get the next point and convert it to Widget measures + drawLine(&p, prevPoint, currentPoint, pen); + prevPoint = currentPoint; // qDebug() << "QFunctionConfigurator::paintEvent, drawing while moving " << currentPoint; - } - - // - // When moving, also draw a few help-lines, so positioning the point gets easier. - // - pen.setWidth(1); - pen.setColor( Qt::white ); - pen.setStyle( Qt::DashLine ); - actualPos = graphicalizePoint(_points[movingPoint], "paintEvent moving help line(s)"); - drawLine(&p, QPoint(range.left(), actualPos.y()), QPoint(actualPos.x(), actualPos.y()), pen); - drawLine(&p, QPoint(actualPos.x(), actualPos.y()), QPoint(actualPos.x(), range.bottom()), pen); - } - - // - // If the Tracker is active, the 'Last Point' it requested is recorded. - // Show that point on the graph, with some lines to assist. - // This new feature is very handy for tweaking the curves! - // - if (_config->getLastPoint( currentPoint )) { + } + + // + // When moving, also draw a few help-lines, so positioning the point gets easier. + // + pen.setWidth(1); + pen.setColor( Qt::white ); + pen.setStyle( Qt::DashLine ); + actualPos = graphicalizePoint(points[movingPoint]); + drawLine(&p, QPoint(range.left(), actualPos.y()), QPoint(actualPos.x(), actualPos.y()), pen); + drawLine(&p, QPoint(actualPos.x(), actualPos.y()), QPoint(actualPos.x(), range.bottom()), pen); + } + + // + // If the Tracker is active, the 'Last Point' it requested is recorded. + // Show that point on the graph, with some lines to assist. + // This new feature is very handy for tweaking the curves! + // + if (_config->getLastPoint( currentPoint )) { // qDebug() << "QFunctionConfigurator::paintEvent, drawing tracked Point " << currentPoint; - actualPos = graphicalizePoint( currentPoint, "paintEvent tracking" ); - drawPoint(&p, actualPos, QColor(255, 0, 0, 120)); + actualPos = graphicalizePoint( currentPoint ); + drawPoint(&p, actualPos, QColor(255, 0, 0, 120)); - pen.setWidth(1); - pen.setColor( Qt::black ); - pen.setStyle( Qt::SolidLine ); - drawLine(&p, QPoint(range.left(), actualPos.y()), QPoint(actualPos.x(), actualPos.y()), pen); - drawLine(&p, QPoint(actualPos.x(), actualPos.y()), QPoint(actualPos.x(), range.bottom()), pen); - } + pen.setWidth(1); + pen.setColor( Qt::black ); + pen.setStyle( Qt::SolidLine ); + drawLine(&p, QPoint(range.left(), actualPos.y()), QPoint(actualPos.x(), actualPos.y()), pen); + drawLine(&p, QPoint(actualPos.x(), actualPos.y()), QPoint(actualPos.x(), range.bottom()), pen); + } - } + } - // - // Draw the delimiters - // - 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); + // + // Draw the delimiters + // + 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); //QTimer::singleShot(50, this, SLOT(update())); } @@ -397,70 +376,69 @@ void QFunctionConfigurator::drawLine(QPainter *painter, const QPointF &start, co // void QFunctionConfigurator::mousePressEvent(QMouseEvent *e) { - // - // First: check the left mouse-button - // - if (e->button() == Qt::LeftButton) { - - // - // Check to see if the cursor is touching one of the points. - // - bool bTouchingPoint = false; - movingPoint = -1; - if (_config) { - - for (int i = 0; i < _points.size(); i++) { - if ( markContains( graphicalizePoint( _points[i], "mousePressEvent markContains" ), e->pos() ) ) { - bTouchingPoint = true; - movingPoint = i; + QList points = _config->getPoints(); + + // + // First: check the left mouse-button + // + if (e->button() == Qt::LeftButton) { + + // + // Check to see if the cursor is touching one of the points. + // + bool bTouchingPoint = false; + movingPoint = -1; + if (_config) { + for (int i = 0; i < points.size(); i++) { + if ( markContains( graphicalizePoint( points[i] ), e->pos() ) ) { + bTouchingPoint = true; + movingPoint = i; break; - } - } - - // - // If the Left Mouse-button was clicked without touching a Point, add a new Point - // - if (!bTouchingPoint) { - if (withinRect(e->pos(), range)) { - _config->addPoint(normalizePoint(e->pos())); - setConfig(_config, strSettingsFile); + } + } + + // + // If the Left Mouse-button was clicked without touching a Point, add a new Point + // + if (!bTouchingPoint) { + if (withinRect(e->pos(), range)) { + _config->addPoint(normalizePoint(e->pos())); movingPoint = -1; - emit CurveChanged( true ); - } - } - } - } - - // - // Then: check the right mouse-button - // - if (e->button() == Qt::RightButton) { - - // - // Check to see if the cursor is touching one of the points. - // - if (_config) { - - for (int i = 0; i < _points.size(); i++) { - if ( markContains( graphicalizePoint( _points[i], "mousePressEvent RightButton" ), e->pos() ) ) { - movingPoint = i; + emit CurveChanged( true ); + } + } + } + } + + // Then: check the right mouse-button + // + if (e->button() == Qt::RightButton) { + + // + // Check to see if the cursor is touching one of the points. + // + if (_config) { + int found_pt = -1; + for (int i = 0; i < points.size(); i++) { + if ( markContains( graphicalizePoint( points[i] ), e->pos() ) ) { + found_pt = i; break; - } - } - - // - // If the Right Mouse-button was clicked while touching a Point, remove the Point - // - if (movingPoint >= 0 && movingPoint < _points.size()) { - _config->removePoint(movingPoint); - movingPoint = -1; - setConfig(_config, strSettingsFile); - emit CurveChanged( true ); - } - else - movingPoint = -1; + } + } + + // + // If the Right Mouse-button was clicked while touching a Point, remove the Point + // + if (found_pt != -1) { + _config->removePoint(found_pt); + emit CurveChanged( true ); + } + movingPoint = -1; } - } + } + + _draw_function = _draw_background = true; + update(); } // @@ -469,47 +447,53 @@ void QFunctionConfigurator::mousePressEvent(QMouseEvent *e) // void QFunctionConfigurator::mouseMoveEvent(QMouseEvent *e) { + QList points = _config->getPoints(); - if (movingPoint >= 0 && movingPoint < _points.size()) { + if (movingPoint >= 0 && movingPoint < points.size()) { - setCursor(Qt::ClosedHandCursor); + setCursor(Qt::ClosedHandCursor); + + // + // Change the currently moving Point. + // + QPointF new_pt = normalizePoint(e->pos()); + points[movingPoint] = new_pt; + _config->movePoint(movingPoint, new_pt); + _draw_function = _draw_background = true; + update(); + } + else { + + // + // Check to see if the cursor is touching one of the points. + // + bool bTouchingPoint = false; + if (_config) { + + for (int i = 0; i < points.size(); i++) { + if ( markContains( graphicalizePoint( points[i] ), e->pos() ) ) { + bTouchingPoint = true; + } + } + } + + if ( bTouchingPoint ) { + setCursor(Qt::OpenHandCursor); + } + else { + setCursor(Qt::ArrowCursor); + } - // - // Change the currently moving Point. - // - _points[movingPoint] = normalizePoint(e->pos()); - update(); } - else { - - // - // Check to see if the cursor is touching one of the points. - // - bool bTouchingPoint = false; - if (_config) { - - for (int i = 0; i < _points.size(); i++) { - if ( markContains( graphicalizePoint( _points[i], "mouseMoveEvent" ), e->pos() ) ) { - bTouchingPoint = true; - } - } - } - - if ( bTouchingPoint ) { - setCursor(Qt::OpenHandCursor); - } - else { - setCursor(Qt::ArrowCursor); - } - - } } void QFunctionConfigurator::mouseReleaseEvent(QMouseEvent *e) { + QList points = _config->getPoints(); + if (e->button() == Qt::LeftButton) { //qDebug()<<"releasing"; - if (movingPoint >= 0 && movingPoint < _points.size()) { + if (movingPoint >= 0 && movingPoint < points.size()) { emit CurveChanged( true ); // @@ -517,12 +501,14 @@ void QFunctionConfigurator::mouseReleaseEvent(QMouseEvent *e) // if (_config) { _config->movePoint(movingPoint, normalizePoint(e->pos())); - setConfig(_config, strSettingsFile); } } setCursor(Qt::ArrowCursor); movingPoint = -1; } + + _draw_function = _draw_background = true; + update(); } // @@ -550,51 +536,49 @@ bool QFunctionConfigurator::withinRect( const QPointF &coord, const QRectF &rect // QPointF QFunctionConfigurator::normalizePoint(QPointF point) const { - QPointF norm; + QPointF norm; - norm.setX( (point.x() - range.left()) / pPerEGU_Input ); + norm.setX( (point.x() - range.left()) / pPerEGU_Input ); norm.setY( (range.bottom() - point.y()) / pPerEGU_Output ); - if (norm.x() > maxInputEGU()) - norm.setX(maxInputEGU()); - else if (norm.x() < 0) - norm.setX(0); - if (norm.y() > maxOutputEGU()) - norm.setY(maxOutputEGU()); - else if (norm.y() < 0) - norm.setY(0); + if (norm.x() > maxInputEGU()) + norm.setX(maxInputEGU()); + else if (norm.x() < 0) + norm.setX(0); + if (norm.y() > maxOutputEGU()) + norm.setY(maxOutputEGU()); + else if (norm.y() < 0) + norm.setY(0); - return norm; + return norm; } // // Convert the real-life Point into the graphical Point. // -QPointF QFunctionConfigurator::graphicalizePoint(QPointF point, QString source) const +QPointF QFunctionConfigurator::graphicalizePoint(QPointF point) const { QPointF graph; - graph.setX( range.left() + (fabs(point.x()) * pPerEGU_Input) ); - graph.setY( range.bottom() - (fabs(point.y()) * pPerEGU_Output) ); - -// qDebug() << "QFunctionConfigurator::graphicalizePoint source = " << source << ", point = " << point << ", graph = " << graph; + graph.setX( range.left() + (fabs(point.x()) * pPerEGU_Input) ); + graph.setY( range.bottom() - (fabs(point.y()) * pPerEGU_Output) ); - return graph; + return graph; } void QFunctionConfigurator::setmaxInputEGU(int value) { MaxInput = value; - setMinimumWidth(MaxInput * pPerEGU_Input + 55); + setMinimumWidth(MaxInput * pPerEGU_Input + 55); // resetCurve(); - resize( MaxInput * pPerEGU_Input + 55, MaxOutput * pPerEGU_Output + 60 ); + resize( MaxInput * pPerEGU_Input + 55, MaxOutput * pPerEGU_Output + 60 ); } void QFunctionConfigurator::setmaxOutputEGU(int value) { MaxOutput = value; - setMinimumHeight(MaxOutput * pPerEGU_Output + 60); + setMinimumHeight(MaxOutput * pPerEGU_Output + 60); // resetCurve(); - resize( MaxInput * pPerEGU_Input + 55, MaxOutput * pPerEGU_Output + 60 ); + resize( MaxInput * pPerEGU_Input + 55, MaxOutput * pPerEGU_Output + 60 ); } // @@ -603,8 +587,8 @@ void QFunctionConfigurator::setmaxOutputEGU(int value) void QFunctionConfigurator::setpixPerEGU_Input(int value) { pPerEGU_Input = value; - setMinimumWidth(MaxInput * pPerEGU_Input + 55); - resize( MaxInput * pPerEGU_Input + 55, MaxOutput * pPerEGU_Output + 60 ); + setMinimumWidth(MaxInput * pPerEGU_Input + 55); + resize( MaxInput * pPerEGU_Input + 55, MaxOutput * pPerEGU_Output + 60 ); } // @@ -613,8 +597,8 @@ void QFunctionConfigurator::setpixPerEGU_Input(int value) void QFunctionConfigurator::setpixPerEGU_Output(int value) { pPerEGU_Output = value; - setMinimumHeight(MaxOutput * pPerEGU_Output + 60); - resize( MaxInput * pPerEGU_Input + 55, MaxOutput * pPerEGU_Output + 60 ); + setMinimumHeight(MaxOutput * pPerEGU_Output + 60); + resize( MaxInput * pPerEGU_Input + 55, MaxOutput * pPerEGU_Output + 60 ); } // @@ -623,9 +607,9 @@ void QFunctionConfigurator::setpixPerEGU_Output(int value) void QFunctionConfigurator::setgridDistEGU_Input(int value) { gDistEGU_Input = value; - _draw_background = true; - _draw_function = true; - repaint(); + _draw_background = true; + _draw_function = true; + repaint(); } // @@ -634,9 +618,9 @@ void QFunctionConfigurator::setgridDistEGU_Input(int value) void QFunctionConfigurator::setgridDistEGU_Output(int value) { gDistEGU_Output = value; - _draw_background = true; - _draw_function = true; - repaint(); + _draw_background = true; + _draw_function = true; + repaint(); } void QFunctionConfigurator::setColorBezier(QColor color) @@ -668,14 +652,11 @@ void QFunctionConfigurator::setCaption(QString cap) void QFunctionConfigurator::resizeEvent(QResizeEvent *e) { - range = QRectF(40, 20, MaxInput * pPerEGU_Input, MaxOutput * pPerEGU_Output); + range = QRectF(40, 20, MaxInput * pPerEGU_Input, MaxOutput * pPerEGU_Output); - qDebug() << "QFunctionConfigurator::resizeEvent, name = " << strCaption << ",range = " << range; + qDebug() << "QFunctionConfigurator::resizeEvent, name = " << strCaption << ",range = " << range; - if (_config) { - setConfig(_config, strSettingsFile); - } - _draw_background = true; - _draw_function = true; - repaint(); + _draw_background = true; + _draw_function = true; + repaint(); } diff --git a/qfunctionconfigurator/qfunctionconfigurator.h b/qfunctionconfigurator/qfunctionconfigurator.h index 963f6b13..d2714ced 100644 --- a/qfunctionconfigurator/qfunctionconfigurator.h +++ b/qfunctionconfigurator/qfunctionconfigurator.h @@ -52,18 +52,18 @@ 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); - Q_PROPERTY(int pixPerEGU_Output READ pixPerEGU_Output WRITE setpixPerEGU_Output); - Q_PROPERTY(int gridDistEGU_Input READ gridDistEGU_Input WRITE setgridDistEGU_Input); - 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); + 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) + Q_PROPERTY(int pixPerEGU_Output READ pixPerEGU_Output WRITE setpixPerEGU_Output) + Q_PROPERTY(int gridDistEGU_Input READ gridDistEGU_Input WRITE setgridDistEGU_Input) + 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) // Return the current value to Designer int maxInputEGU() const @@ -159,7 +159,6 @@ protected: void drawPoint(QPainter *painter, const QPointF &pt, QColor colBG ); void drawLine(QPainter *painter, const QPointF &start, const QPointF &end, QPen pen); bool markContains(const QPointF &pt, const QPointF &coord) const; -// bool withinRange( const QPointF &coord ) const; bool withinRect( const QPointF &coord, const QRectF &rect ) const; protected: @@ -169,7 +168,7 @@ private: QRectF range; // The actual rectangle for the Bezier-curve QPointF lastPoint; // The right-most point of the Function QPointF normalizePoint (QPointF point) const; // Convert the graphical Point to a real-life Point - QPointF graphicalizePoint (QPointF point, QString source = "") const; // Convert the Point to a graphical Point + QPointF graphicalizePoint (QPointF point) const; // Convert the Point to a graphical Point int movingPoint; @@ -197,7 +196,6 @@ private: // QString _title; // Title do display in Widget and to load Settings FunctionConfig* _config; - QList _points; // Function-points }; #endif // QFUNCTIONCONFIGURATOR_H -- cgit v1.2.3 From fbca62b8ef01796127999405b76bbd918c76c69e Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 14 Sep 2013 17:24:04 +0200 Subject: throttle QFunctionConfigurator updates Don't consume whole CPU time when the spline editor control points are being dragged. --- qfunctionconfigurator/qfunctionconfigurator.cpp | 60 ++++++++++++------------- qfunctionconfigurator/qfunctionconfigurator.h | 2 + 2 files changed, 32 insertions(+), 30 deletions(-) diff --git a/qfunctionconfigurator/qfunctionconfigurator.cpp b/qfunctionconfigurator/qfunctionconfigurator.cpp index 418d46c8..76245de4 100644 --- a/qfunctionconfigurator/qfunctionconfigurator.cpp +++ b/qfunctionconfigurator/qfunctionconfigurator.cpp @@ -136,10 +136,8 @@ void QFunctionConfigurator::saveSettings(QString settingsFile) { // void QFunctionConfigurator::drawBackground(const QRectF &fullRect) { -int i; -QRect scale; - - qDebug() << "QFunctionConfigurator::drawBackground."; + int i; + QRect scale; _background = QPixmap(fullRect.width(), fullRect.height()); QPainter painter(&_background); @@ -393,6 +391,7 @@ void QFunctionConfigurator::mousePressEvent(QMouseEvent *e) if ( markContains( graphicalizePoint( points[i] ), e->pos() ) ) { bTouchingPoint = true; movingPoint = i; + timer.restart(); break; } } @@ -450,40 +449,40 @@ void QFunctionConfigurator::mouseMoveEvent(QMouseEvent *e) QList points = _config->getPoints(); if (movingPoint >= 0 && movingPoint < points.size()) { - setCursor(Qt::ClosedHandCursor); - // - // Change the currently moving Point. - // - QPointF new_pt = normalizePoint(e->pos()); - points[movingPoint] = new_pt; - _config->movePoint(movingPoint, new_pt); - _draw_function = _draw_background = true; - update(); + if (timer.isValid() && timer.elapsed() > 100) + { + timer.restart(); + QPointF new_pt = normalizePoint(e->pos()); + points[movingPoint] = new_pt; + _config->movePoint(movingPoint, new_pt); + _draw_function = _draw_background = true; + update(); + } } else { - - // - // Check to see if the cursor is touching one of the points. - // - bool bTouchingPoint = false; - if (_config) { - - for (int i = 0; i < points.size(); i++) { - if ( markContains( graphicalizePoint( points[i] ), e->pos() ) ) { - bTouchingPoint = true; + if (withinRect(e->pos(), rect())) + { + // + // Check to see if the cursor is touching one of the points. + // + bool bTouchingPoint = false; + if (_config) { + for (int i = 0; i < points.size(); i++) { + if ( markContains( graphicalizePoint( points[i] ), e->pos() ) ) { + bTouchingPoint = true; + } } } - } - if ( bTouchingPoint ) { - setCursor(Qt::OpenHandCursor); - } - else { - setCursor(Qt::ArrowCursor); + if ( bTouchingPoint ) { + setCursor(Qt::OpenHandCursor); + } + else { + setCursor(Qt::ArrowCursor); + } } - } } @@ -492,6 +491,7 @@ void QFunctionConfigurator::mouseReleaseEvent(QMouseEvent *e) QList points = _config->getPoints(); if (e->button() == Qt::LeftButton) { + timer.invalidate(); //qDebug()<<"releasing"; if (movingPoint >= 0 && movingPoint < points.size()) { emit CurveChanged( true ); diff --git a/qfunctionconfigurator/qfunctionconfigurator.h b/qfunctionconfigurator/qfunctionconfigurator.h index d2714ced..fc2a1957 100644 --- a/qfunctionconfigurator/qfunctionconfigurator.h +++ b/qfunctionconfigurator/qfunctionconfigurator.h @@ -39,6 +39,7 @@ #include #include #include +#include #include "qfunctionconfigurator/functionconfig.h" #include "ftnoir_tracker_base/ftnoir_tracker_base.h" @@ -171,6 +172,7 @@ private: QPointF graphicalizePoint (QPointF point) const; // Convert the Point to a graphical Point int movingPoint; + QElapsedTimer timer; int MaxInput; // Maximum input limit int MaxOutput; // Maximum output limit -- cgit v1.2.3 From 14f9db1312149fcf391c95e9c6cadbc6bdaaf7cc Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 14 Sep 2013 17:27:00 +0200 Subject: QFC: Don't throttle as much, it's jerky --- qfunctionconfigurator/qfunctionconfigurator.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/qfunctionconfigurator/qfunctionconfigurator.cpp b/qfunctionconfigurator/qfunctionconfigurator.cpp index 76245de4..79c5f949 100644 --- a/qfunctionconfigurator/qfunctionconfigurator.cpp +++ b/qfunctionconfigurator/qfunctionconfigurator.cpp @@ -447,11 +447,12 @@ void QFunctionConfigurator::mousePressEvent(QMouseEvent *e) void QFunctionConfigurator::mouseMoveEvent(QMouseEvent *e) { QList points = _config->getPoints(); + const int refresh_delay = 50; if (movingPoint >= 0 && movingPoint < points.size()) { setCursor(Qt::ClosedHandCursor); - if (timer.isValid() && timer.elapsed() > 100) + if (timer.isValid() && timer.elapsed() > refresh_delay) { timer.restart(); QPointF new_pt = normalizePoint(e->pos()); -- cgit v1.2.3 From 475df2d12176e906d99822f4517fbb85579f8683 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 14 Sep 2013 17:33:12 +0200 Subject: QFC: cleanup logic and unused stuff --- qfunctionconfigurator/qfunctionconfigurator.cpp | 1 - qfunctionconfigurator/qfunctionconfigurator.h | 9 --------- 2 files changed, 10 deletions(-) diff --git a/qfunctionconfigurator/qfunctionconfigurator.cpp b/qfunctionconfigurator/qfunctionconfigurator.cpp index 79c5f949..97d89cbb 100644 --- a/qfunctionconfigurator/qfunctionconfigurator.cpp +++ b/qfunctionconfigurator/qfunctionconfigurator.cpp @@ -402,7 +402,6 @@ void QFunctionConfigurator::mousePressEvent(QMouseEvent *e) if (!bTouchingPoint) { if (withinRect(e->pos(), range)) { _config->addPoint(normalizePoint(e->pos())); - movingPoint = -1; emit CurveChanged( true ); } } diff --git a/qfunctionconfigurator/qfunctionconfigurator.h b/qfunctionconfigurator/qfunctionconfigurator.h index fc2a1957..7260de1f 100644 --- a/qfunctionconfigurator/qfunctionconfigurator.h +++ b/qfunctionconfigurator/qfunctionconfigurator.h @@ -143,11 +143,6 @@ public slots: void setOutputEGU(QString); void setCaption(QString); - void resetCurve() { - qDebug() << "QFunctionConfigurator::resetCurve = " << strSettingsFile; - loadSettings( strSettingsFile ); - } - protected slots: void paintEvent(QPaintEvent *e); void mousePressEvent(QMouseEvent *e); @@ -193,10 +188,6 @@ private: bool _draw_function; // Flag to determine if the function should be (re-)drawn on the QPixmap QPixmap _function; // Image of the function (static unless edited by the user) - // - // Properties of the CurveConfigurator Widget - // - QString _title; // Title do display in Widget and to load Settings FunctionConfig* _config; }; -- 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 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(-) 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(-) 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(-) 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(-) 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 352f02ba874510d32ce5d2e6972f68bc1c7d14ea Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 14 Sep 2013 18:21:15 +0200 Subject: Update copyright information for rewritten class --- ftnoir_posewidget/glwidget.h | 31 ++++++------------------------- 1 file changed, 6 insertions(+), 25 deletions(-) diff --git a/ftnoir_posewidget/glwidget.h b/ftnoir_posewidget/glwidget.h index f46f3c9e..0bb693c8 100644 --- a/ftnoir_posewidget/glwidget.h +++ b/ftnoir_posewidget/glwidget.h @@ -1,28 +1,9 @@ -/******************************************************************************** -* 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 . * -*********************************************************************************/ +/* 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. + */ #ifndef GLWIDGET_H #define GLWIDGET_H -- 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(-) 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(-) 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(-) 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(-) 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(-) 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(-) 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(-) 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(-) 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 fff386c0d854b8f5c12e7de66ed4790e168ab5e6 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 14 Sep 2013 19:01:29 +0200 Subject: Prevent text overlap with bigger fonts --- ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui b/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui index bb27ed47..305b1b1d 100644 --- a/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui +++ b/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui @@ -9,7 +9,7 @@ 0 0 - 570 + 620 71 @@ -34,7 +34,7 @@ 243 10 - 76 + 111 22 @@ -55,7 +55,7 @@ background:none; - Zoom slowness: + Zoom slowness @@ -112,7 +112,7 @@ background:none; - 325 + 346 13 189 15 @@ -146,7 +146,7 @@ background:none; - 520 + 541 10 42 22 @@ -190,7 +190,7 @@ background:none; - 409 + 430 40 75 23 @@ -203,7 +203,7 @@ background:none; - 490 + 511 40 75 23 -- 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(-) 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(-) 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(-) 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(-) 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 c4afb886739079135d881ec2edaf8d63b6ed6dfd Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 14 Sep 2013 19:39:41 +0200 Subject: Handle hotplug camera indices --- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 2 +- ftnoir_tracker_ht/ftnoir_tracker_ht.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index 3f5960ef..e40c92d2 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -79,7 +79,7 @@ static QList get_camera_names(void) { if (access(buf, R_OK | W_OK) == 0) { ret.append(buf); } else { - break; + continue; } } #endif diff --git a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp index 9be50efa..2ca5a3de 100644 --- a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp +++ b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp @@ -69,7 +69,7 @@ static QList get_camera_names(void) { if (access(buf, R_OK | W_OK) == 0) { ret.append(buf); } else { - break; + continue; } } #endif -- cgit v1.2.3 From c155fe9087ef1433deb6e43d040a90bc2423d60a Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 14 Sep 2013 19:43:53 +0200 Subject: Remove copy-pasted per-file revision history --- ftnoir_protocol_wine/ftnoir_protocol_wine.cpp | 10 ---------- ftnoir_protocol_wine/ftnoir_protocol_wine_dialog.cpp | 8 -------- ftnoir_protocol_wine/ftnoir_protocol_wine_dll.cpp | 8 -------- 3 files changed, 26 deletions(-) diff --git a/ftnoir_protocol_wine/ftnoir_protocol_wine.cpp b/ftnoir_protocol_wine/ftnoir_protocol_wine.cpp index bb877cc6..a5a21200 100644 --- a/ftnoir_protocol_wine/ftnoir_protocol_wine.cpp +++ b/ftnoir_protocol_wine/ftnoir_protocol_wine.cpp @@ -24,16 +24,6 @@ * FTServer FTServer is the Class, that communicates headpose-data * * to games, using the FreeTrackClient.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 - 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 "ftnoir_protocol_wine.h" #include #include diff --git a/ftnoir_protocol_wine/ftnoir_protocol_wine_dialog.cpp b/ftnoir_protocol_wine/ftnoir_protocol_wine_dialog.cpp index 4021a8e5..f833af1d 100644 --- a/ftnoir_protocol_wine/ftnoir_protocol_wine_dialog.cpp +++ b/ftnoir_protocol_wine/ftnoir_protocol_wine_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_wine.h" #include #include "facetracknoir/global-settings.h" diff --git a/ftnoir_protocol_wine/ftnoir_protocol_wine_dll.cpp b/ftnoir_protocol_wine/ftnoir_protocol_wine_dll.cpp index 1e9298b0..bd07ba79 100644 --- a/ftnoir_protocol_wine/ftnoir_protocol_wine_dll.cpp +++ b/ftnoir_protocol_wine/ftnoir_protocol_wine_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_wine.h" #include #include "facetracknoir/global-settings.h" -- cgit v1.2.3 From a8dd32cbf76aa5082e8bb8af0fe5218242282c26 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 14 Sep 2013 19:44:26 +0200 Subject: Remove incorrect copyright information --- ftnoir_protocol_wine/ftnoir_protocol_wine.cpp | 26 ---------------------- .../ftnoir_protocol_wine_dialog.cpp | 24 -------------------- ftnoir_protocol_wine/ftnoir_protocol_wine_dll.cpp | 24 -------------------- 3 files changed, 74 deletions(-) diff --git a/ftnoir_protocol_wine/ftnoir_protocol_wine.cpp b/ftnoir_protocol_wine/ftnoir_protocol_wine.cpp index a5a21200..96a15b93 100644 --- a/ftnoir_protocol_wine/ftnoir_protocol_wine.cpp +++ b/ftnoir_protocol_wine/ftnoir_protocol_wine.cpp @@ -1,29 +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 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 "ftnoir_protocol_wine.h" #include #include diff --git a/ftnoir_protocol_wine/ftnoir_protocol_wine_dialog.cpp b/ftnoir_protocol_wine/ftnoir_protocol_wine_dialog.cpp index f833af1d..ecbc2137 100644 --- a/ftnoir_protocol_wine/ftnoir_protocol_wine_dialog.cpp +++ b/ftnoir_protocol_wine/ftnoir_protocol_wine_dialog.cpp @@ -1,27 +1,3 @@ -/******************************************************************************** -* 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_wine.h" #include #include "facetracknoir/global-settings.h" diff --git a/ftnoir_protocol_wine/ftnoir_protocol_wine_dll.cpp b/ftnoir_protocol_wine/ftnoir_protocol_wine_dll.cpp index bd07ba79..dd7f17a6 100644 --- a/ftnoir_protocol_wine/ftnoir_protocol_wine_dll.cpp +++ b/ftnoir_protocol_wine/ftnoir_protocol_wine_dll.cpp @@ -1,27 +1,3 @@ -/******************************************************************************** -* 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_wine.h" #include #include "facetracknoir/global-settings.h" -- cgit v1.2.3 From 74240d04b14cffc93693b0033b65907655fcf218 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 14 Sep 2013 19:46:28 +0200 Subject: Use __declspec(dllimport) --- compat/compat.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/compat/compat.h b/compat/compat.h index 6a95f167..c34add10 100644 --- a/compat/compat.h +++ b/compat/compat.h @@ -21,8 +21,10 @@ #if defined(IN_FTNOIR_COMPAT) && defined(_WIN32) # define COMPAT_EXPORT __declspec(dllexport) +#elif defined(_WIN32) +# define COMPAT_EXPORT __declspec(dllimport) #else -# define COMPAT_EXPORT +# define COMPAT_EXPORT #endif class COMPAT_EXPORT PortableLockedShm { -- cgit v1.2.3 From eb3fac6ac66f85db0778cd47f01ba6a2854c9ab8 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 14 Sep 2013 21:27:35 +0200 Subject: Use a sensible default for Accela zoom slowness --- ftnoir_filter_accela/ftnoir_filter_accela.cpp | 2 +- ftnoir_filter_accela/ftnoir_filter_accela.h | 1 + ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.cpp b/ftnoir_filter_accela/ftnoir_filter_accela.cpp index 2c0765e8..ee7289a4 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela.cpp @@ -30,7 +30,7 @@ void FTNoIR_Filter::loadSettings() { QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) iniFile.beginGroup ( "Accela" ); - zoom_factor = iniFile.value("zoom-slowness", 0).toDouble(); + 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(); iniFile.endGroup (); diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.h b/ftnoir_filter_accela/ftnoir_filter_accela.h index 49b551e7..333ab08d 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.h +++ b/ftnoir_filter_accela/ftnoir_filter_accela.h @@ -36,6 +36,7 @@ #define ACCELA_SMOOTHING_ROTATION 6.0 #define ACCELA_SMOOTHING_TRANSLATION 3.0 +#define ACCELA_ZOOM_SLOWNESS 35 //******************************************************************************************************* // FaceTrackNoIR Filter class. diff --git a/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp b/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp index 0e3660d6..18ef284e 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp @@ -141,8 +141,8 @@ void FilterControls::loadSettings() { //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.slideZoom->setValue(iniFile.value("zoom-slowness", ACCELA_ZOOM_SLOWNESS).toInt()); + 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()); iniFile.endGroup (); -- 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(-) 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 1f4a829c70b29e5d466799959a2d84fad017bf51 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 14 Sep 2013 21:44:37 +0200 Subject: X-Plane: remove dead code --- x-plane-plugin/plugin.c | 40 ---------------------------------------- 1 file changed, 40 deletions(-) diff --git a/x-plane-plugin/plugin.c b/x-plane-plugin/plugin.c index 18a01aa2..455c202f 100644 --- a/x-plane-plugin/plugin.c +++ b/x-plane-plugin/plugin.c @@ -122,42 +122,7 @@ PLUGIN_API int XPluginStart ( char * outName, char * outSignature, char * outDes return 0; } -#if 0 -static int camera_callback(XPLMCameraPosition_t* outCameraPosition, int inIsLosingControl, void* inRefCon) { - if (!inIsLosingControl && XPLMGetCycleNumber() > 0) { - //XPLMReadCameraPosition(outCameraPosition); - PortableLockedShm_lock(lck_posix); - outCameraPosition->heading = shm_posix->rx * 57.295781; - outCameraPosition->pitch = shm_posix->ry * 57.295781; - outCameraPosition->roll = shm_posix->rz * 57.295781; - outCameraPosition->x = XPLMGetDataf(view_x); - outCameraPosition->y = XPLMGetDataf(view_y); - outCameraPosition->z = XPLMGetDataf(view_z); - PortableLockedShm_unlock(lck_posix); - return 1; - } - return 0; -} -static float flight_loop ( - float inElapsedSinceLastCall, - float inElapsedTimeSinceLastFlightLoop, - int inCounter, - void * inRefcon) -{ - XPLMControlCamera(xplm_ControlCameraForever, camera_callback, NULL); - // don't want it called anymore - return 0; -} -#endif - PLUGIN_API void XPluginStop ( void ) { -#if 0 - // crashes due to race - if (lck_posix) - PortableLockedShm_free(lck_posix); - lck_posix = NULL; - shm_posix = NULL; -#endif } PLUGIN_API void XPluginEnable ( void ) { @@ -173,11 +138,6 @@ PLUGIN_API void XPluginDisable ( void ) { XPLMSetDataf(view_x, offset_x); XPLMSetDataf(view_y, offset_y); XPLMSetDataf(view_z, offset_z); -#if 0 - XPLMUnregisterFlightLoopCallback(flight_loop, NULL); - if (XPLMIsCameraBeingControlled(NULL)) - XPLMDontControlCamera(); -#endif } PLUGIN_API void XPluginReceiveMessage( -- cgit v1.2.3 From 471358347615c5cd4719ff727fc1c9f6aacdc2b6 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 14 Sep 2013 21:48:05 +0200 Subject: Play nice with IDE analysis --- x-plane-plugin/plugin.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/x-plane-plugin/plugin.c b/x-plane-plugin/plugin.c index 455c202f..b98dc975 100644 --- a/x-plane-plugin/plugin.c +++ b/x-plane-plugin/plugin.c @@ -15,6 +15,10 @@ #include "ftnoir_tracker_base/ftnoir_tracker_types.h" +#ifndef PLUGIN_API +#define PLUGIN_API +#endif + // using Wine name to ease things #define WINE_SHM_NAME "facetracknoir-wine-shm" #define WINE_MTX_NAME "facetracknoir-wine-mtx" -- cgit v1.2.3 From b25bc9bf12fe8dffadde9e03ab1f9119a681158c Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 14 Sep 2013 21:48:41 +0200 Subject: Even more dead code --- x-plane-plugin/plugin.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/x-plane-plugin/plugin.c b/x-plane-plugin/plugin.c index b98dc975..33023a81 100644 --- a/x-plane-plugin/plugin.c +++ b/x-plane-plugin/plugin.c @@ -132,9 +132,6 @@ PLUGIN_API void XPluginStop ( void ) { PLUGIN_API void XPluginEnable ( void ) { reinit_offset(); XPLMRegisterDrawCallback(write_head_position, xplm_Phase_LastScene, 1, NULL); -#if 0 - XPLMRegisterFlightLoopCallback(flight_loop, -1, NULL); -#endif } PLUGIN_API void XPluginDisable ( void ) { -- cgit v1.2.3 From bab1d6596f1a8404e88e2d93092e7be1f9d4ca93 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 14 Sep 2013 21:50:35 +0200 Subject: Don't leak any memory, ever (?) --- x-plane-plugin/plugin.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/x-plane-plugin/plugin.c b/x-plane-plugin/plugin.c index 33023a81..9bc5c484 100644 --- a/x-plane-plugin/plugin.c +++ b/x-plane-plugin/plugin.c @@ -127,6 +127,8 @@ PLUGIN_API int XPluginStart ( char * outName, char * outSignature, char * outDes } PLUGIN_API void XPluginStop ( void ) { + if (lck_posix) + PortableLockedShm_free(lck_posix); } PLUGIN_API void XPluginEnable ( void ) { -- cgit v1.2.3 From 0e2632a716297a3811caa8117b3ec8f1046a9a7e Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 14 Sep 2013 23:46:06 +0200 Subject: Unbreak mingw-w64 build --- CMakeLists.txt | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6e5b6978..3256cb9b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -81,13 +81,13 @@ if(NOT SDK_FACEAPI_ONLY) endif() if(WIN32) - ENABLE_LANGUAGE(RC) if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) - set(CMAKE_RC_COMPILER_INIT windres) + #set(CMAKE_RC_COMPILER_INIT windres) SET(CMAKE_RC_COMPILE_OBJECT " -O coff -i -o ") else() - set(CMAKE_RC_COMPILER_INIT rc) + #set(CMAKE_RC_COMPILER_INIT rc) endif() + ENABLE_LANGUAGE(RC) endif(WIN32) if(SDK_FSUIPC AND WIN32) @@ -371,7 +371,14 @@ endif() add_library(opentrack-proto-win32-mouse SHARED ${opentrack-proto-win32-mouse-c} ${opentrack-proto-win32-mouse-moc} ${opentrack-proto-win32-mouse-uih} ${opentrack-proto-win32-mouse-rcc}) target_link_libraries(opentrack-proto-win32-mouse ${MY_QT_LIBS}) - add_library(freetrackclient SHARED ${opentrack-freetrack-c}) + add_library(freetrackclient SHARED ${opentrack-freetrack-c}) + if(CMAKE_COMPILER_IS_GNUCC) + set_target_properties(freetrackclient PROPERTIES + LINK_FLAGS "-Wl,--kill-at" + LIBRARY_OUTPUT_NAME "freetrackclient.dll" + PREFIX "" SUFFIX "" + ) + endif() endif() add_library(opentrack-proto-udp SHARED ${opentrack-proto-udp-c} ${opentrack-proto-udp-moc} ${opentrack-proto-udp-uih} ${opentrack-proto-udp-rcc}) -- 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(-) 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 15c88252feb95fa73b993cb086c9b10137efd935 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 14 Sep 2013 23:47:14 +0200 Subject: Unbreak mingw-w64 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3256cb9b..d5d4684a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -430,7 +430,7 @@ endif() endif() endif() - if(WIN32 AND NOT CMAKE_COMPILER_IS_GNUCC) + if(WIN32) target_link_libraries(opentrack-tracker-ht "${CMAKE_SOURCE_DIR}/dinput/dinput8.lib" "${CMAKE_SOURCE_DIR}/dinput/dxguid.lib" -- cgit v1.2.3 From 8a953439f1fe8d331dd2fc51c244b0003f68dae0 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 15 Sep 2013 00:23:46 +0200 Subject: Workaround GNU ld bugs with win32-specific stuff --- CMakeLists.txt | 10 ++++------ freetrackclient/freetrackclient.def | 6 ++++++ 2 files changed, 10 insertions(+), 6 deletions(-) create mode 100644 freetrackclient/freetrackclient.def diff --git a/CMakeLists.txt b/CMakeLists.txt index d5d4684a..b022e79b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -371,13 +371,11 @@ endif() add_library(opentrack-proto-win32-mouse SHARED ${opentrack-proto-win32-mouse-c} ${opentrack-proto-win32-mouse-moc} ${opentrack-proto-win32-mouse-uih} ${opentrack-proto-win32-mouse-rcc}) target_link_libraries(opentrack-proto-win32-mouse ${MY_QT_LIBS}) - add_library(freetrackclient SHARED ${opentrack-freetrack-c}) if(CMAKE_COMPILER_IS_GNUCC) - set_target_properties(freetrackclient PROPERTIES - LINK_FLAGS "-Wl,--kill-at" - LIBRARY_OUTPUT_NAME "freetrackclient.dll" - PREFIX "" SUFFIX "" - ) + add_library(freetrackclient SHARED ${opentrack-freetrack-c} "${CMAKE_SOURCE_DIR}/freetrackclient/freetrackclient.def") + set_target_properties(freetrackclient PROPERTIES LINK_FLAGS "-Wl,--enable-stdcall-fixup") + else() + add_library(freetrackclient SHARED ${opentrack-freetrack-c}) endif() endif() diff --git a/freetrackclient/freetrackclient.def b/freetrackclient/freetrackclient.def new file mode 100644 index 00000000..155648dd --- /dev/null +++ b/freetrackclient/freetrackclient.def @@ -0,0 +1,6 @@ +LIBRARY freetrackclient.dll +EXPORTS +FTGetData@4 = FTGetData +FTReportName@4 = FTReportName +FTGetDllVersion@0 = FTGetDllVersion +FTProvider@0 = FTProvider -- cgit v1.2.3 From b948329c7ae6ab2ff546cba43cdc4aca9b743cfd Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 15 Sep 2013 00:54:33 +0200 Subject: Try to unbreak mingw-w64 build --- CMakeLists.txt | 3 ++- ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h | 7 +++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b022e79b..25d3a809 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -432,7 +432,8 @@ endif() target_link_libraries(opentrack-tracker-ht "${CMAKE_SOURCE_DIR}/dinput/dinput8.lib" "${CMAKE_SOURCE_DIR}/dinput/dxguid.lib" - "${CMAKE_SOURCE_DIR}/dinput/strmiids.lib") + "${CMAKE_SOURCE_DIR}/dinput/strmiids.lib" + uuid) endif() if(OpenCV_FOUND) diff --git a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h index 99478a54..d901b63e 100644 --- a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h +++ b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h @@ -28,13 +28,12 @@ #ifndef INCLUDED_FSUIPCSERVER_H #define INCLUDED_FSUIPCSERVER_H -#include "Windows.h" +#include #include #include "FSUIPC_User.h" #include "facetracknoir/global-settings.h" - -#include "..\ftnoir_protocol_base\ftnoir_protocol_base.h" -#include "ui_FTNoIR_FSUIPCcontrols.h" +#include "ftnoir_protocol_base/ftnoir_protocol_base.h" +#include "ui_ftnoir_fsuipccontrols.h" #include #include #include -- 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(-) 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 ec228053011db8a2d265e39ed0ba2ce240177d17 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 15 Sep 2013 03:51:42 +0200 Subject: Use double precision for intermediate computation --- qfunctionconfigurator/functionconfig.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/qfunctionconfigurator/functionconfig.cpp b/qfunctionconfigurator/functionconfig.cpp index 5dab2b52..6e1569f9 100644 --- a/qfunctionconfigurator/functionconfig.cpp +++ b/qfunctionconfigurator/functionconfig.cpp @@ -138,20 +138,20 @@ void FunctionConfig::reload() { 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; + double t = (j - start) / (double) (end - start); + double t2 = t*t; + double t3 = t*t*t; - int x = .5 * ((2 * p1.x()) + + 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) + (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()) + + 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); + (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; -- cgit v1.2.3 From 28a6805bbc37590612836d32cc4321bd4bbd4c5d Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 15 Sep 2013 03:52:06 +0200 Subject: Reduce UI artifacts in edge cases --- qfunctionconfigurator/qfunctionconfigurator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qfunctionconfigurator/qfunctionconfigurator.cpp b/qfunctionconfigurator/qfunctionconfigurator.cpp index 97d89cbb..4a5f7ca6 100644 --- a/qfunctionconfigurator/qfunctionconfigurator.cpp +++ b/qfunctionconfigurator/qfunctionconfigurator.cpp @@ -244,7 +244,7 @@ QPointF currentPoint; prevPoint = graphicalizePoint( QPointF(0,0) ); // Start at the Axis double max = maxInputEGU(); QPointF prev = graphicalizePoint(QPointF(0, 0)); - double step = 1e-1 / (double) pixPerEGU_Input(); + const double step = 1.01; for (double i = 0; i < max; i += step) { double val = _config->getValue(i); QPointF cur = graphicalizePoint(QPointF(i, val)); -- 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(-) 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 842d261e5d0d2af65b6327288cecc845d452db5a Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 15 Sep 2013 04:14:06 +0200 Subject: Link against uuid.lib on win32 explicitly --- CMakeLists.txt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f906d0a2..8f21defc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -494,7 +494,12 @@ endif() 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) + target_link_libraries(opentrack "${CMAKE_SOURCE_DIR}/dinput/dinput8.lib" + "${CMAKE_SOURCE_DIR}/dinput/dxguid.lib" + "${CMAKE_SOURCE_DIR}/dinput/strmiids.lib" + winmm + uuid + ) else() target_link_libraries(opentrack X11) endif() -- 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(-) 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 fc14725b4699aff7119e99272e63959d68615855 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 15 Sep 2013 04:33:00 +0200 Subject: Ensure FaceAPI is only compiled by MSVC80 --- CMakeLists.txt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8f21defc..29baf906 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -521,8 +521,10 @@ if(SDK_SM_FACEAPI_PATH) add_library(opentrack-tracker-faceapi SHARED ${opentrack-tracker-faceapi-c} ${opentrack-tracker-faceapi-moc} ${opentrack-tracker-faceapi-uih} ${opentrack-tracker-faceapi-rcc}) target_link_libraries(opentrack-tracker-faceapi ${MY_QT_LIBS} opentrack-compat) endif() - add_executable(opentrack-faceapi-wrapper ${opentrack-faceapi-wrapper-c}) - target_link_libraries(opentrack-faceapi-wrapper "${SDK_SM_FACEAPI_PATH}/bin/smft32.lib") + if(MSVC80) + add_executable(opentrack-faceapi-wrapper ${opentrack-faceapi-wrapper-c}) + target_link_libraries(opentrack-faceapi-wrapper "${SDK_SM_FACEAPI_PATH}/bin/smft32.lib") + endif() endif() if(NOT SDK_FACEAPI_ONLY) @@ -666,7 +668,7 @@ if(MSVC) install(FILES ${pdbs} DESTINATION .) endif() -if(WIN32 AND SDK_SM_FACEAPI_PATH) +if(WIN32 AND SDK_SM_FACEAPI_PATH AND MSVC80) install(TARGETS opentrack-faceapi-wrapper RUNTIME DESTINATION faceapi LIBRARY DESTINATION faceapi -- cgit v1.2.3 From 2d4c954c9e66c2612fb7e4d1e92bbc8127f35014 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 15 Sep 2013 05:01:27 +0200 Subject: Don't use dummy exe, it prevents users from deleting app directory --- ftnoir_protocol_ft/ftnoir_protocol_ft.cpp | 2 +- ftnoir_protocol_ft/ftnoir_protocol_ft_dialog.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp b/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp index b72adb22..ec4eb532 100644 --- a/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp +++ b/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp @@ -85,7 +85,7 @@ void FTNoIR_Protocol::loadSettings() { // iniFile.beginGroup ( "FTIR" ); useTIRViews = iniFile.value ( "useTIRViews", 0 ).toBool(); - useDummyExe = iniFile.value ( "useDummyExe", 1 ).toBool(); + useDummyExe = iniFile.value ( "useDummyExe", 0 ).toBool(); iniFile.endGroup (); } diff --git a/ftnoir_protocol_ft/ftnoir_protocol_ft_dialog.cpp b/ftnoir_protocol_ft/ftnoir_protocol_ft_dialog.cpp index eb2d0e76..93742129 100644 --- a/ftnoir_protocol_ft/ftnoir_protocol_ft_dialog.cpp +++ b/ftnoir_protocol_ft/ftnoir_protocol_ft_dialog.cpp @@ -158,7 +158,7 @@ void FTControls::loadSettings() { iniFile.beginGroup ( "FTIR" ); ui.chkTIRViews->setChecked (iniFile.value ( "useTIRViews", 0 ).toBool()); - ui.chkStartDummy->setChecked (iniFile.value ( "useDummyExe", 1 ).toBool()); + ui.chkStartDummy->setChecked (iniFile.value ( "useDummyExe", 0 ).toBool()); iniFile.endGroup (); settingsDirty = false; -- 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(-) 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 7b15426c5a1e8ce1f17cf7fe01f8594ab75f98e9 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 15 Sep 2013 05:13:51 +0200 Subject: Add innosetup-based installer script --- .gitignore | 15 ++++++------ installer/opentrack-installer.iss | 48 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 7 deletions(-) create mode 100644 installer/opentrack-installer.iss diff --git a/.gitignore b/.gitignore index 7a420ac8..f367cb02 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,11 @@ /CMakeLists.txt.user *~ /build* -/install -/bin/tracker-ht/headtracker-ftnoir.exe -/bin/tracker-ht/libgcc_s_dw2-1.dll -/bin/tracker-ht/libstdc++-6.dll -/bin/tracker-ht/bounding-box.raw -/bin/tracker-ht/flandmark_model.dat -/bin/tracker-ht/head.raw +/install +/bin/tracker-ht/headtracker-ftnoir.exe +/bin/tracker-ht/libgcc_s_dw2-1.dll +/bin/tracker-ht/libstdc++-6.dll +/bin/tracker-ht/bounding-box.raw +/bin/tracker-ht/flandmark_model.dat +/bin/tracker-ht/head.raw +/installer/Output diff --git a/installer/opentrack-installer.iss b/installer/opentrack-installer.iss new file mode 100644 index 00000000..4e43b587 --- /dev/null +++ b/installer/opentrack-installer.iss @@ -0,0 +1,48 @@ +; Script generated by the Inno Setup Script Wizard. +; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! + +#define MyAppName "opentrack" +#define MyAppVersion "2.0a1" +#define MyAppPublisher "opentrack" +#define MyAppURL "http://github.com/opentrack/opentrack" +#define MyAppExeName "opentrack.exe" + +[Setup] +; NOTE: The value of AppId uniquely identifies this application. +; Do not use the same AppId value in installers for other applications. +; (To generate a new GUID, click Tools | Generate GUID inside the IDE.) +AppId={{E454805B-11A6-469F-9FA9-865BEAD787D0} +AppName={#MyAppName} +AppVersion={#MyAppVersion} +;AppVerName={#MyAppName} {#MyAppVersion} +AppPublisher={#MyAppPublisher} +AppPublisherURL={#MyAppURL} +AppSupportURL={#MyAppURL} +AppUpdatesURL={#MyAppURL} +DefaultDirName={pf}\{#MyAppName} +DefaultGroupName={#MyAppName} +AllowNoIcons=yes +OutputBaseFilename=opentrack-setup +SetupIconFile=C:\Users\Administrator\Projects\opentrack\facetracknoir\facetracknoir.ico +Compression=lzma +SolidCompression=yes +DisableWelcomePage=True +DisableReadyPage=True +DisableReadyMemo=True + +[Languages] +Name: "english"; MessagesFile: "compiler:Default.isl" + +[Tasks] +Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked + +[Files] +Source: "C:\Users\Administrator\Projects\opentrack\install\*"; DestDir: "{app}"; Flags: ignoreversion createallsubdirs recursesubdirs + +[Icons] +Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}" +Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon + +[Run] +Filename: "{app}\redist\vc80redist_x86.exe"; Parameters: "/q:a"; Flags: postinstall waituntilterminated; Description: "Install MSVC 8.0 runtime for FaceAPI" +Filename: "{app}\{#MyAppExeName}"; Flags: nowait postinstall skipifsilent; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}" \ No newline at end of file -- cgit v1.2.3 From 3734ab61a6f0d4d8aad32a17a2eb5fc49245626e Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 15 Sep 2013 05:19:34 +0200 Subject: Finish installer script --- installer/opentrack-installer.iss | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/installer/opentrack-installer.iss b/installer/opentrack-installer.iss index 4e43b587..d0567a14 100644 --- a/installer/opentrack-installer.iss +++ b/installer/opentrack-installer.iss @@ -24,11 +24,15 @@ DefaultGroupName={#MyAppName} AllowNoIcons=yes OutputBaseFilename=opentrack-setup SetupIconFile=C:\Users\Administrator\Projects\opentrack\facetracknoir\facetracknoir.ico -Compression=lzma +Compression=lzma/ultra64 SolidCompression=yes DisableWelcomePage=True DisableReadyPage=True DisableReadyMemo=True +RestartIfNeededByRun=False +InternalCompressLevel=ultra +CompressionThreads=2 +MinVersion=0,5.01sp2 [Languages] Name: "english"; MessagesFile: "compiler:Default.isl" @@ -44,5 +48,5 @@ Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}" Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon [Run] -Filename: "{app}\redist\vc80redist_x86.exe"; Parameters: "/q:a"; Flags: postinstall waituntilterminated; Description: "Install MSVC 8.0 runtime for FaceAPI" -Filename: "{app}\{#MyAppExeName}"; Flags: nowait postinstall skipifsilent; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}" \ No newline at end of file +Filename: "{app}\redist\vc80redist_x86.exe"; Parameters: "/q:a"; Flags: waituntilterminated; Description: "Install MSVC 8.0 runtime for FaceAPI" +Filename: "{app}\{#MyAppExeName}"; Flags: nowait postinstall skipifsilent; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}" -- cgit v1.2.3 From bef7aff31e5ea073f0f160ca6a2f1e56b7dd881a Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 15 Sep 2013 12:39:32 +0200 Subject: Initial PT 1.1 import Codebase broken at this stage --- CMakeLists.txt | 8 +- FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui | 1856 ++++++++++++++++++++ FTNoIR_Tracker_PT/FTNoIR_Tracker_PT.rc | 61 + FTNoIR_Tracker_PT/FTNoIR_Tracker_PT_vc10.vcxproj | 212 +++ FTNoIR_Tracker_PT/Resources/Logo_IR.png | Bin 0 -> 10386 bytes FTNoIR_Tracker_PT/Resources/cap_front.png | Bin 0 -> 1164 bytes FTNoIR_Tracker_PT/Resources/cap_side.png | Bin 0 -> 1733 bytes FTNoIR_Tracker_PT/Resources/clip_front.png | Bin 0 -> 571 bytes FTNoIR_Tracker_PT/Resources/clip_side.png | Bin 0 -> 2677 bytes FTNoIR_Tracker_PT/Resources/icon.ico | Bin 0 -> 4286 bytes FTNoIR_Tracker_PT/camera.cpp | 263 +++ FTNoIR_Tracker_PT/camera.h | 139 ++ FTNoIR_Tracker_PT/doc/index.htm | 262 +++ FTNoIR_Tracker_PT/doc/logo.png | Bin 0 -> 10386 bytes FTNoIR_Tracker_PT/doc/ptrack.ico | Bin 0 -> 4286 bytes FTNoIR_Tracker_PT/doc/settings1.png | Bin 0 -> 25013 bytes FTNoIR_Tracker_PT/doc/settings2.png | Bin 0 -> 26841 bytes FTNoIR_Tracker_PT/doc/settings3.png | Bin 0 -> 29547 bytes FTNoIR_Tracker_PT/doc/style.css | 131 ++ FTNoIR_Tracker_PT/frame_observer.cpp | 18 + FTNoIR_Tracker_PT/frame_observer.h | 72 + FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp | 265 +++ FTNoIR_Tracker_PT/ftnoir_tracker_pt.h | 99 ++ FTNoIR_Tracker_PT/ftnoir_tracker_pt.qrc | 10 + FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.cpp | 406 +++++ FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.h | 116 ++ FTNoIR_Tracker_PT/ftnoir_tracker_pt_dll.cpp | 40 + FTNoIR_Tracker_PT/ftnoir_tracker_pt_dll.h | 19 + FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.cpp | 154 ++ FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.h | 88 + FTNoIR_Tracker_PT/point_extractor.cpp | 101 ++ FTNoIR_Tracker_PT/point_extractor.h | 31 + FTNoIR_Tracker_PT/point_tracker.cpp | 359 ++++ FTNoIR_Tracker_PT/point_tracker.h | 125 ++ FTNoIR_Tracker_PT/resource.h | 14 + FTNoIR_Tracker_PT/timer.cpp | 66 + FTNoIR_Tracker_PT/timer.h | 44 + FTNoIR_Tracker_PT/trans_calib.cpp | 44 + FTNoIR_Tracker_PT/trans_calib.h | 39 + FTNoIR_Tracker_PT/video_widget.cpp | 119 ++ FTNoIR_Tracker_PT/video_widget.h | 58 + ftnoir_protocol_fg/ftnoir_protocol_fg.cpp.autosave | 222 +++ ftnoir_tracker_pt/camera.cpp | 213 --- ftnoir_tracker_pt/camera.h | 119 -- ftnoir_tracker_pt/ftnoir_pt_controls.ui | 1765 ------------------- ftnoir_tracker_pt/ftnoir_tracker_pt.cpp | 261 --- ftnoir_tracker_pt/ftnoir_tracker_pt.h | 96 - ftnoir_tracker_pt/ftnoir_tracker_pt.qrc | 10 - ftnoir_tracker_pt/ftnoir_tracker_pt.rc | 61 - ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.cpp | 337 ---- ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.h | 102 -- ftnoir_tracker_pt/ftnoir_tracker_pt_dll.cpp | 40 - ftnoir_tracker_pt/ftnoir_tracker_pt_dll.h | 18 - ftnoir_tracker_pt/ftnoir_tracker_pt_settings.cpp | 150 -- ftnoir_tracker_pt/ftnoir_tracker_pt_settings.h | 84 - ftnoir_tracker_pt/point_extractor.cpp | 96 - ftnoir_tracker_pt/point_extractor.h | 31 - ftnoir_tracker_pt/point_tracker.cpp | 352 ---- ftnoir_tracker_pt/point_tracker.h | 114 -- ftnoir_tracker_pt/resource.h | 14 - ftnoir_tracker_pt/resources/cap_front.png | Bin 1164 -> 0 bytes ftnoir_tracker_pt/resources/cap_side.png | Bin 1733 -> 0 bytes ftnoir_tracker_pt/resources/clip_front.png | Bin 571 -> 0 bytes ftnoir_tracker_pt/resources/clip_side.png | Bin 2677 -> 0 bytes ftnoir_tracker_pt/resources/icon.png | Bin 1701 -> 0 bytes ftnoir_tracker_pt/resources/logo_ir.png | Bin 10386 -> 0 bytes ftnoir_tracker_pt/timer.cpp | 65 - ftnoir_tracker_pt/timer.h | 44 - ftnoir_tracker_pt/trans_calib.cpp | 44 - ftnoir_tracker_pt/trans_calib.h | 39 - ftnoir_tracker_pt/video_widget.cpp | 52 - ftnoir_tracker_pt/video_widget.h | 42 - ftnoir_tracker_pt/videoinput/videoinput.h | 385 ---- ftnoir_tracker_pt/videoinput/videoinput_vc8.lib | Bin 2145206 -> 0 bytes ftnoir_tracker_pt/videoinput/videoinput_vc9.lib | Bin 2119546 -> 0 bytes 75 files changed, 5437 insertions(+), 4538 deletions(-) create mode 100644 FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui create mode 100644 FTNoIR_Tracker_PT/FTNoIR_Tracker_PT.rc create mode 100644 FTNoIR_Tracker_PT/FTNoIR_Tracker_PT_vc10.vcxproj create mode 100644 FTNoIR_Tracker_PT/Resources/Logo_IR.png create mode 100644 FTNoIR_Tracker_PT/Resources/cap_front.png create mode 100644 FTNoIR_Tracker_PT/Resources/cap_side.png create mode 100644 FTNoIR_Tracker_PT/Resources/clip_front.png create mode 100644 FTNoIR_Tracker_PT/Resources/clip_side.png create mode 100644 FTNoIR_Tracker_PT/Resources/icon.ico create mode 100644 FTNoIR_Tracker_PT/camera.cpp create mode 100644 FTNoIR_Tracker_PT/camera.h create mode 100644 FTNoIR_Tracker_PT/doc/index.htm create mode 100644 FTNoIR_Tracker_PT/doc/logo.png create mode 100644 FTNoIR_Tracker_PT/doc/ptrack.ico create mode 100644 FTNoIR_Tracker_PT/doc/settings1.png create mode 100644 FTNoIR_Tracker_PT/doc/settings2.png create mode 100644 FTNoIR_Tracker_PT/doc/settings3.png create mode 100644 FTNoIR_Tracker_PT/doc/style.css create mode 100644 FTNoIR_Tracker_PT/frame_observer.cpp create mode 100644 FTNoIR_Tracker_PT/frame_observer.h create mode 100644 FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp create mode 100644 FTNoIR_Tracker_PT/ftnoir_tracker_pt.h create mode 100644 FTNoIR_Tracker_PT/ftnoir_tracker_pt.qrc create mode 100644 FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.cpp create mode 100644 FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.h create mode 100644 FTNoIR_Tracker_PT/ftnoir_tracker_pt_dll.cpp create mode 100644 FTNoIR_Tracker_PT/ftnoir_tracker_pt_dll.h create mode 100644 FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.cpp create mode 100644 FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.h create mode 100644 FTNoIR_Tracker_PT/point_extractor.cpp create mode 100644 FTNoIR_Tracker_PT/point_extractor.h create mode 100644 FTNoIR_Tracker_PT/point_tracker.cpp create mode 100644 FTNoIR_Tracker_PT/point_tracker.h create mode 100644 FTNoIR_Tracker_PT/resource.h create mode 100644 FTNoIR_Tracker_PT/timer.cpp create mode 100644 FTNoIR_Tracker_PT/timer.h create mode 100644 FTNoIR_Tracker_PT/trans_calib.cpp create mode 100644 FTNoIR_Tracker_PT/trans_calib.h create mode 100644 FTNoIR_Tracker_PT/video_widget.cpp create mode 100644 FTNoIR_Tracker_PT/video_widget.h create mode 100644 ftnoir_protocol_fg/ftnoir_protocol_fg.cpp.autosave delete mode 100644 ftnoir_tracker_pt/camera.cpp delete mode 100644 ftnoir_tracker_pt/camera.h delete mode 100644 ftnoir_tracker_pt/ftnoir_pt_controls.ui delete mode 100644 ftnoir_tracker_pt/ftnoir_tracker_pt.cpp delete mode 100644 ftnoir_tracker_pt/ftnoir_tracker_pt.h delete mode 100644 ftnoir_tracker_pt/ftnoir_tracker_pt.qrc delete mode 100644 ftnoir_tracker_pt/ftnoir_tracker_pt.rc delete mode 100644 ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.cpp delete mode 100644 ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.h delete mode 100644 ftnoir_tracker_pt/ftnoir_tracker_pt_dll.cpp delete mode 100644 ftnoir_tracker_pt/ftnoir_tracker_pt_dll.h delete mode 100644 ftnoir_tracker_pt/ftnoir_tracker_pt_settings.cpp delete mode 100644 ftnoir_tracker_pt/ftnoir_tracker_pt_settings.h delete mode 100644 ftnoir_tracker_pt/point_extractor.cpp delete mode 100644 ftnoir_tracker_pt/point_extractor.h delete mode 100644 ftnoir_tracker_pt/point_tracker.cpp delete mode 100644 ftnoir_tracker_pt/point_tracker.h delete mode 100644 ftnoir_tracker_pt/resource.h delete mode 100644 ftnoir_tracker_pt/resources/cap_front.png delete mode 100644 ftnoir_tracker_pt/resources/cap_side.png delete mode 100644 ftnoir_tracker_pt/resources/clip_front.png delete mode 100644 ftnoir_tracker_pt/resources/clip_side.png delete mode 100644 ftnoir_tracker_pt/resources/icon.png delete mode 100644 ftnoir_tracker_pt/resources/logo_ir.png delete mode 100644 ftnoir_tracker_pt/timer.cpp delete mode 100644 ftnoir_tracker_pt/timer.h delete mode 100644 ftnoir_tracker_pt/trans_calib.cpp delete mode 100644 ftnoir_tracker_pt/trans_calib.h delete mode 100644 ftnoir_tracker_pt/video_widget.cpp delete mode 100644 ftnoir_tracker_pt/video_widget.h delete mode 100644 ftnoir_tracker_pt/videoinput/videoinput.h delete mode 100644 ftnoir_tracker_pt/videoinput/videoinput_vc8.lib delete mode 100644 ftnoir_tracker_pt/videoinput/videoinput_vc9.lib diff --git a/CMakeLists.txt b/CMakeLists.txt index 29baf906..0669fb74 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -216,11 +216,11 @@ if(NOT SDK_FACEAPI_ONLY) QT4_WRAP_UI(opentrack-tracker-aruco-uih ${opentrack-tracker-aruco-ui}) QT4_ADD_RESOURCES(opentrack-tracker-aruco-rcc ${opentrack-tracker-aruco-rc}) - file(GLOB opentrack-tracker-pt-c "ftnoir_tracker_pt/*.cpp") - file(GLOB opentrack-tracker-pt-h "ftnoir_tracker_pt/*.h") + file(GLOB opentrack-tracker-pt-c "FTNoIR_Tracker_PT/*.cpp") + file(GLOB opentrack-tracker-pt-h "FTNoIR_Tracker_PT/*.h") QT4_WRAP_CPP(opentrack-tracker-pt-moc ${opentrack-tracker-pt-h}) - file(GLOB opentrack-tracker-pt-ui "ftnoir_tracker_pt/*.ui") - file(GLOB opentrack-tracker-pt-rc "ftnoir_tracker_pt/*.qrc") + file(GLOB opentrack-tracker-pt-ui "FTNoIR_Tracker_PT/*.ui") + file(GLOB opentrack-tracker-pt-rc "FTNoIR_Tracker_PT/*.qrc") QT4_WRAP_UI(opentrack-tracker-pt-uih ${opentrack-tracker-pt-ui}) QT4_ADD_RESOURCES(opentrack-tracker-pt-rcc ${opentrack-tracker-pt-rc}) diff --git a/FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui b/FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui new file mode 100644 index 00000000..7bb7eb50 --- /dev/null +++ b/FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui @@ -0,0 +1,1856 @@ + + + UICPTClientControls + + + Qt::ApplicationModal + + + + 0 + 0 + 395 + 552 + + + + + 0 + 0 + + + + PointTracker Settings + + + + :/Resources/icon.ico:/Resources/icon.ico + + + Qt::LeftToRight + + + false + + + + QLayout::SetFixedSize + + + + + + 0 + 0 + + + + + 0 + 0 + + + + + + + 0 + + + + General + + + + + + Tracker Thread + + + + + + + + + + + Dynamic Pose Resolution + + + + + + + Sleep time + + + sleep_spin + + + + + + + + + Time the tracker thread sleeps after each processed frame + + + + + + 9999 + + + + + + + ms + + + + + + + + + Auto-reset time + + + reset_spin + + + + + + + + + Time until automatic reset of tracker's internal state when no valid tracking result is found + + + 9999 + + + + + + + ms + + + + + + + + + Whether to update the content of the VideoWidget + + + Show VideoWidget + + + + + + + Qt::Horizontal + + + + 30 + 20 + + + + + + + + Qt::Horizontal + + + + 30 + 20 + + + + + + + + false + + + Reset the tracker's internal state + + + Reset + + + + + + + + + + + + + 0 + 85 + + + + Enable Axis + + + + + + + + Roll: + + + chkEnableRoll + + + + + + + Pitch: + + + chkEnablePitch + + + + + + + Yaw: + + + chkEnableYaw + + + + + + + + 20 + 16777215 + + + + Qt::LeftToRight + + + + + + + + + + + + + + 20 + 16777215 + + + + Qt::LeftToRight + + + + + + + + + + + 20 + 16777215 + + + + Qt::LeftToRight + + + + + + + + + + X: + + + chkEnableX + + + + + + + + 20 + 16777215 + + + + Qt::LeftToRight + + + + + + + + + + Y: + + + chkEnableY + + + + + + + + 20 + 16777215 + + + + Qt::LeftToRight + + + + + + + + + + Z: + + + chkEnableZ + + + + + + + + 20 + 16777215 + + + + Qt::LeftToRight + + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Minimum + + + + 40 + 20 + + + + + + + + Qt::Horizontal + + + QSizePolicy::Minimum + + + + 40 + 20 + + + + + + + + Qt::Horizontal + + + QSizePolicy::Minimum + + + + 40 + 20 + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + Qt::Vertical + + + + 20 + 20 + + + + + + + + + Camera + + + + + + The camera device used as input + + + Camera Settings + + + + + + + + + 55 + 0 + + + + Device + + + camdevice_combo + + + + + + + + 0 + 0 + + + + Camera device used as input + + + + + + + + + + + + + + 55 + 0 + + + + Resolution + + + + + + + FPS + + + fps_spin + + + + + + + + 0 + 0 + + + + Desired capture framerate + + + 999 + + + + + + + x + + + + + + + + 0 + 0 + + + + Desired capture width + + + 2000 + + + 10 + + + + + + + Desired capture height + + + 2000 + + + 10 + + + + + + + F/W + + + f_dspin + + + + + + + The camera's focal length devided by its sensor width + + + 2 + + + 0.100000000000000 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Horizontal + + + + 0 + 20 + + + + + + + + + + + + + + false + + + + 130 + 0 + + + + + + + VideoWidget + + + + + + + Qt::Horizontal + + + + 0 + 20 + + + + + + + + + + + + + Camera Orientation + + + + + + + + + + Pitch + + + campitch_spin + + + + + + + Qt::DefaultContextMenu + + + The angle the camera is facing upwards + + + -99 + + + + + + + Yaw + + + camyaw_spin + + + + + + + Qt::DefaultContextMenu + + + The angle the camera is facing leftwards + + + -99 + + + + + + + deg (positve = leftwards) + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + Rotation of the camera image + + + + + + + deg (positive = upwards) + + + + + + + deg + + + + + + + Roll + + + camroll_combo + + + + + + + + + Qt::Horizontal + + + + 0 + 20 + + + + + + + + + + + + + Qt::Vertical + + + + 20 + 0 + + + + + + + + Point Extraction + + + + + + + + Threshold + + + threshold_slider + + + + + + + Intensity threshold for point extraction + + + 255 + + + 127 + + + Qt::Horizontal + + + + + + + + + + + Min Diameter + + + mindiam_spin + + + + + + + Minimum point diameter + + + + + + + px + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Max Diameter + + + maxdiam_spin + + + + + + + Maximum point diameter + + + + + + + px + + + + + + + + + + + + + Model + + + + + + QTabWidget::Rounded + + + 2 + + + false + + + false + + + false + + + + Clip + + + + + + Model Dimensions (mm) + + + + + + + 0 + 0 + + + + + 150 + 160 + + + + + + 30 + 30 + 71 + 111 + + + + + + + :/Resources/clip_side.png + + + + + + 100 + 50 + 46 + 22 + + + + 999 + + + + + + 60 + 10 + 46 + 22 + + + + 999 + + + + + + 100 + 90 + 46 + 22 + + + + 999 + + + + + + 10 + 10 + 46 + 13 + + + + Side + + + + + + 40 + 140 + 46 + 22 + + + + 999 + + + + + + 70 + 70 + 16 + 16 + + + + R + + + + + + + + + 0 + 0 + + + + + 100 + 140 + + + + + + 10 + 10 + 46 + 13 + + + + Front + + + + + + 40 + 30 + 21 + 111 + + + + + + + :/Resources/clip_front.png + + + + + + 60 + 70 + 16 + 16 + + + + R + + + + + + + + + + + + Cap + + + + + + Model Dimensions (mm) + + + + + + + 140 + 130 + + + + + + 20 + 50 + 111 + 81 + + + + + + + :/Resources/cap_side.png + + + + + + 30 + 80 + 46 + 22 + + + + 999 + + + + + + 130 + 50 + 16 + 16 + + + + R + + + + + + 10 + 10 + 46 + 13 + + + + Side + + + + + + 50 + 40 + 46 + 22 + + + + 999 + + + + + + + + + 0 + 0 + + + + + 100 + 130 + + + + + + 10 + 10 + 46 + 13 + + + + Front + + + + + + 30 + 50 + 16 + 16 + + + + R + + + + + + 10 + 50 + 81 + 81 + + + + + + + :/Resources/cap_front.png + + + + + + 50 + 30 + 46 + 22 + + + + 999 + + + + + + + + + + + + Custom + + + + + + Model Dimensions (mm) + + + + + + <html><head/><body><p>Location of the two remaining model points<br/>with respect to the reference point in default pose</p></body></html> + + + + + + + Qt::Vertical + + + + 20 + 0 + + + + + + + + + + Qt::Horizontal + + + + 10 + 20 + + + + + + + + + + -999 + + + 999 + + + + + + + y: + + + + + + + -999 + + + 999 + + + + + + + z: + + + + + + + M1: + + + + + + + -999 + + + 999 + + + + + + + x: + + + + + + + + + Qt::Horizontal + + + + 20 + 20 + + + + + + + + + + -999 + + + 999 + + + + + + + x: + + + + + + + z: + + + + + + + -999 + + + 999 + + + + + + + y: + + + + + + + M2: + + + + + + + + + + -999 + + + 999 + + + + + + + + + Qt::Horizontal + + + + 10 + 20 + + + + + + + + + + Qt::Vertical + + + + 20 + 0 + + + + + + + + + + + + + + + Model Position (mm) + + + + + + <html><head/><body><p>Translation from head center to model reference point<br/> in default pose</p></body></html> + + + + + + + + + Qt::Horizontal + + + + 10 + 20 + + + + + + + + + + + + + -999 + + + 999 + + + + + + + x: + + + + + + + y: + + + + + + + z: + + + + + + + -999 + + + 999 + + + + + + + -999 + + + 999 + + + + + + + + + Qt::Horizontal + + + + 20 + 20 + + + + + + + + false + + + Calibrate + + + true + + + + + + + Qt::Horizontal + + + + 10 + 20 + + + + + + + + + + + + + + About + + + + + 30 + 30 + 161 + 111 + + + + <html><head/><body><p><span style=" font-weight:600;">FTNoIR PointTracker Plugin<br/>Version 1.1</span></p><p><span style=" font-weight:600;">by Patrick Ruoff</span></p><p><a href="http://ftnoirpt.sourceforge.net/"><span style=" font-weight:600; text-decoration: underline; color:#0000ff;">Manual (external)</span></a></p></body></html> + + + true + + + + + + 200 + 30 + 141 + 141 + + + + + + + :/Resources/Logo_IR.png + + + + + + + + + Status + + + + + + QFormLayout::AllNonFixedFieldsGrow + + + + + Camera Info: + + + + + + + + 0 + 0 + + + + + 120 + 0 + + + + + + + + + + + Extracted Points: + + + + + + + + 50 + 0 + + + + + + + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + Ok + + + + + + + + + + Cancel + + + + + + + + + tabWidget + videowidget_check + sleep_spin + dynpose_check + reset_spin + reset_button + chkEnableRoll + chkEnablePitch + chkEnableYaw + chkEnableX + chkEnableY + chkEnableZ + camdevice_combo + res_x_spin + res_y_spin + fps_spin + f_dspin + camroll_combo + campitch_spin + camyaw_spin + threshold_slider + mindiam_spin + maxdiam_spin + model_tabs + clip_tlength_spin + clip_theight_spin + clip_bheight_spin + clip_blength_spin + cap_length_spin + cap_height_spin + cap_width_spin + m1x_spin + m1y_spin + m1z_spin + m2x_spin + m2y_spin + m2z_spin + tx_spin + ty_spin + tz_spin + tcalib_button + ok_button + cancel_button + + + + + + + dynpose_check + toggled(bool) + reset_spin + setEnabled(bool) + + + 172 + 110 + + + 351 + 112 + + + + + + startEngineClicked() + stopEngineClicked() + cameraSettingsClicked() + + diff --git a/FTNoIR_Tracker_PT/FTNoIR_Tracker_PT.rc b/FTNoIR_Tracker_PT/FTNoIR_Tracker_PT.rc new file mode 100644 index 00000000..11c5d52f --- /dev/null +++ b/FTNoIR_Tracker_PT/FTNoIR_Tracker_PT.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_PT/FTNoIR_Tracker_PT_vc10.vcxproj b/FTNoIR_Tracker_PT/FTNoIR_Tracker_PT_vc10.vcxproj new file mode 100644 index 00000000..b777077b --- /dev/null +++ b/FTNoIR_Tracker_PT/FTNoIR_Tracker_PT_vc10.vcxproj @@ -0,0 +1,212 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Template + Win32 + + + + FTNoIR_Tracker_PT + {7A2A2560-9253-4CC8-A9D5-4B9D9C224D9D} + FTNoIR_Tracker_PT + Qt4VSv1.0 + + + + DynamicLibrary + + + DynamicLibrary + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + $(SolutionDir)\bin\ + $(SolutionDir)\$(Configuration)\ + $(SolutionDir)/bin_dbg\ + $(SolutionDir)\$(Configuration)\ + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + MaxSpeed + .;.\GeneratedFiles;.\GeneratedFiles\$(Configuration);$(QTDIR)\include;$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(OPENCV_DIR)\include;$(BOOST_DIR);$(QTDIR)\include\QtOpenGL;%(AdditionalIncludeDirectories) + UNICODE;WIN32;QT_DLL;QT_NO_DEBUG;NDEBUG;QT_CORE_LIB;QT_GUI_LIB;FTNOIR_TRACKER_BASE_LIB;QT_OPENGL_LIB;%(PreprocessorDefinitions) + MultiThreadedDLL + false + + + + + qtmain.lib;QtCore4.lib;QtGui4.lib;QtOpenGL4.lib;opengl32.lib;glu32.lib;opencv_core242.lib;opencv_imgproc242.lib;opencv_calib3d242.lib;videoInput_vc10.lib;%(AdditionalDependencies) + $(OutDir)$(ProjectName).dll + $(QTDIR)\lib;$(OPENCV_DIR)\x86\vc10\lib;$(ProjectDir)\videoInput;%(AdditionalLibraryDirectories) + atlthunk.lib;libcmt;%(IgnoreSpecificDefaultLibraries) + false + Windows + + + + + Disabled + .;.\GeneratedFiles;.\GeneratedFiles\$(Configuration);$(QTDIR)\include;$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(OPENCV_DIR)\include;$(BOOST_DIR);$(QTDIR)\include\QtOpenGL;%(AdditionalIncludeDirectories) + UNICODE;WIN32;QT_DLL;QT_CORE_LIB;QT_GUI_LIB;FTNOIR_TRACKER_BASE_LIB;QT_OPENGL_LIB;%(PreprocessorDefinitions) + MultiThreadedDebugDLL + false + ProgramDatabase + + + qtmaind.lib;QtCored4.lib;QtGuid4.lib;QtOpenGLd4.lib;opengl32.lib;glu32.lib;opencv_core242d.lib;opencv_imgproc242d.lib;opencv_calib3d242d.lib;videoInput_vc10.lib;%(AdditionalDependencies) + $(OutDir)$(ProjectName).dll + $(QTDIR)\lib;$(OPENCV_DIR)\x86\vc10\lib;$(ProjectDir)\videoInput;%(AdditionalLibraryDirectories) + atlthunk.lib;libcmt;%(IgnoreSpecificDefaultLibraries) + true + Windows + + + + + + + + + + + + + + + + + + + + + + true + true + + + true + true + + + true + true + + + true + true + + + + + + + + + + + + %(AdditionalInputs) + %(Outputs) + + + + + %(AdditionalInputs) + %(Outputs) + + + Moc%27ing ftnoir_tracker_pt_dialog.h... + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DQT_DLL -DQT_CORE_LIB -DQT_GUI_LIB -DFTNOIR_TRACKER_BASE_LIB -DQT_OPENGL_LIB -D_WINDLL "-I." "-I.\GeneratedFiles" "-I.\GeneratedFiles\$(Configuration)\." "-I$(QTDIR)\include" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" "-I$(OPENCV_DIR)\include" "-I$(BOOST_DIR)\." "-I$(QTDIR)\include\QtOpenGL" + $(QTDIR)\bin\moc.exe;%(FullPath);%(AdditionalInputs) + .\GeneratedFiles\$(Configuration)\moc_%(Filename).cpp;%(Outputs) + Moc%27ing ftnoir_tracker_pt_dialog.h... + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DQT_DLL -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_GUI_LIB -DFTNOIR_TRACKER_BASE_LIB -DQT_OPENGL_LIB -D_WINDLL "-I." "-I.\GeneratedFiles" "-I.\GeneratedFiles\$(Configuration)\." "-I$(QTDIR)\include" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" "-I$(OPENCV_DIR)\include" "-I$(BOOST_DIR)\." "-I$(QTDIR)\include\QtOpenGL" + $(QTDIR)\bin\moc.exe;%(FullPath);%(AdditionalInputs) + .\GeneratedFiles\$(Configuration)\moc_%(Filename).cpp;%(Outputs) + + + + + + + + + + Moc%27ing video_widget.h... + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DQT_DLL -DQT_CORE_LIB -DQT_GUI_LIB -DFTNOIR_TRACKER_BASE_LIB -DQT_OPENGL_LIB -D_WINDLL "-I." "-I.\GeneratedFiles" "-I.\GeneratedFiles\$(Configuration)\." "-I$(QTDIR)\include" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" "-I$(OPENCV_DIR)\include" "-I$(BOOST_DIR)\." "-I$(QTDIR)\include\QtOpenGL" + $(QTDIR)\bin\moc.exe;%(FullPath);%(AdditionalInputs) + .\GeneratedFiles\$(Configuration)\moc_%(Filename).cpp;%(Outputs) + Moc%27ing video_widget.h... + "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DQT_DLL -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_GUI_LIB -DFTNOIR_TRACKER_BASE_LIB -DQT_OPENGL_LIB -D_WINDLL "-I." "-I.\GeneratedFiles" "-I.\GeneratedFiles\$(Configuration)\." "-I$(QTDIR)\include" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" "-I$(OPENCV_DIR)\include" "-I$(BOOST_DIR)\." "-I$(QTDIR)\include\QtOpenGL" + $(QTDIR)\bin\moc.exe;%(FullPath);%(AdditionalInputs) + .\GeneratedFiles\$(Configuration)\moc_%(Filename).cpp;%(Outputs) + + + + + + Uic%27ing %(Filename)%(Extension)... + "$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)" + + $(QTDIR)\bin\uic.exe;%(AdditionalInputs) + .\GeneratedFiles\ui_%(Filename).h;%(Outputs) + Uic%27ing %(Filename)%(Extension)... + "$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)" + + $(QTDIR)\bin\uic.exe;%(AdditionalInputs) + .\GeneratedFiles\ui_%(Filename).h;%(Outputs) + + + Rcc%27ing %(Filename)%(Extension)... + "$(QTDIR)\bin\rcc.exe" -name "%(Filename)" -no-compress "%(FullPath)" -o .\GeneratedFiles\qrc_%(Filename).cpp + + %(FullPath);.\Resources\icon.ico;.\Resources\Logo_IR.png;%(AdditionalInputs) + .\GeneratedFiles\qrc_%(Filename).cpp;%(Outputs) + Rcc%27ing %(Filename)%(Extension)... + "$(QTDIR)\bin\rcc.exe" -name "%(Filename)" -no-compress "%(FullPath)" -o .\GeneratedFiles\qrc_%(Filename).cpp + + %(FullPath);.\Resources\icon.ico;.\Resources\Logo_IR.png;%(AdditionalInputs) + .\GeneratedFiles\qrc_%(Filename).cpp;%(Outputs) + + + + + + + + + + + + + + \ No newline at end of file diff --git a/FTNoIR_Tracker_PT/Resources/Logo_IR.png b/FTNoIR_Tracker_PT/Resources/Logo_IR.png new file mode 100644 index 00000000..95032a25 Binary files /dev/null and b/FTNoIR_Tracker_PT/Resources/Logo_IR.png differ diff --git a/FTNoIR_Tracker_PT/Resources/cap_front.png b/FTNoIR_Tracker_PT/Resources/cap_front.png new file mode 100644 index 00000000..14207a67 Binary files /dev/null and b/FTNoIR_Tracker_PT/Resources/cap_front.png differ diff --git a/FTNoIR_Tracker_PT/Resources/cap_side.png b/FTNoIR_Tracker_PT/Resources/cap_side.png new file mode 100644 index 00000000..5ad4ee65 Binary files /dev/null and b/FTNoIR_Tracker_PT/Resources/cap_side.png differ diff --git a/FTNoIR_Tracker_PT/Resources/clip_front.png b/FTNoIR_Tracker_PT/Resources/clip_front.png new file mode 100644 index 00000000..04880138 Binary files /dev/null and b/FTNoIR_Tracker_PT/Resources/clip_front.png differ diff --git a/FTNoIR_Tracker_PT/Resources/clip_side.png b/FTNoIR_Tracker_PT/Resources/clip_side.png new file mode 100644 index 00000000..72667ac7 Binary files /dev/null and b/FTNoIR_Tracker_PT/Resources/clip_side.png differ diff --git a/FTNoIR_Tracker_PT/Resources/icon.ico b/FTNoIR_Tracker_PT/Resources/icon.ico new file mode 100644 index 00000000..c4b2aedc Binary files /dev/null and b/FTNoIR_Tracker_PT/Resources/icon.ico differ diff --git a/FTNoIR_Tracker_PT/camera.cpp b/FTNoIR_Tracker_PT/camera.cpp new file mode 100644 index 00000000..21a910c1 --- /dev/null +++ b/FTNoIR_Tracker_PT/camera.cpp @@ -0,0 +1,263 @@ +/* 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 get_camera_device_names(std::vector& device_names) +{ + videoInput VI; + VI.listDevices(); + std::string device_name; + for(int index = 0; ; ++index) { + device_name = VI.getDeviceName(index); + if (device_name.empty()) break; + device_names.push_back(device_name); + } +} + +// ---------------------------------------------------------------------------- +void Camera::set_device_index(int index) +{ + if (desired_index != index) + { + desired_index = index; + _set_device_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 = cvCreateCameraCapture(desired_index); + // extract camera info + if (cap) + { + 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); + } +} + +void CVCamera::stop() +{ + if (cap) cvReleaseCapture(&cap); + active = false; +} + +bool CVCamera::_get_frame(Mat* frame) +{ + if (cap && cvGrabFrame(cap) != 0) + { + // 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; + } + } + return false; +} + +void CVCamera::_set_index() +{ + if (active) restart(); +} + +void CVCamera::_set_f() +{ + cam_info.f = cam_desired.f; +} + +void CVCamera::_set_fps() +{ + if (cap) cvSetCaptureProperty(cap, 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); + } +} +*/ + +// ---------------------------------------------------------------------------- +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_device_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(); +} + + +// ---------------------------------------------------------------------------- +Mat FrameRotation::rotate_frame(Mat frame) +{ + switch (rotation) + { + case CLOCKWISE: + { + Mat dst; + transpose(frame, dst); + flip(dst, dst, 1); + return dst; + } + + case COUNTER_CLOCKWISE: + { + Mat dst; + transpose(frame, dst); + flip(dst, dst, 0); + return dst; + } + + default: + return frame; + } +} \ No newline at end of file diff --git a/FTNoIR_Tracker_PT/camera.h b/FTNoIR_Tracker_PT/camera.h new file mode 100644 index 00000000..c0876d0a --- /dev/null +++ b/FTNoIR_Tracker_PT/camera.h @@ -0,0 +1,139 @@ +/* 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 "videoInput/videoInput.h" +#include +#include + +// ---------------------------------------------------------------------------- +void get_camera_device_names(std::vector& device_names); + + +// ---------------------------------------------------------------------------- +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, calculates the frame rate +class Camera +{ +public: + 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(); } + + // 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); + + // 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; +}; + + +// ---------------------------------------------------------------------------- +// camera based on OpenCV's videoCapture +/* +class CVCamera : public Camera +{ +public: + CVCamera() : cap(NULL) {} + ~CVCamera() { stop(); } + + virtual void start(); + virtual void stop(); + +protected: + virtual bool _get_frame(cv::Mat* frame); + virtual void _set_index(); + virtual void _set_f(); + virtual void _set_fps(); + virtual void _set_res(); + + CvCapture* cap; +}; +*/ + +// ---------------------------------------------------------------------------- +// Camera based on the videoInput library +class VICamera : public Camera +{ +public: + VICamera(); + ~VICamera() { stop(); } + + virtual void start(); + virtual void stop(); + +protected: + virtual bool _get_frame(cv::Mat* frame); + virtual void _set_device_index(); + virtual void _set_f(); + virtual void _set_fps(); + virtual void _set_res(); + + videoInput VI; + cv::Mat new_frame; + unsigned char* frame_buffer; +}; + + +// ---------------------------------------------------------------------------- +class FrameRotation +{ +public: + typedef enum Rotation + { + CLOCKWISE = -1, + ZERO = 0, + COUNTER_CLOCKWISE = 1 + }; + Rotation rotation; + + cv::Mat rotate_frame(cv::Mat frame); +}; + +#endif //CAMERA_H diff --git a/FTNoIR_Tracker_PT/doc/index.htm b/FTNoIR_Tracker_PT/doc/index.htm new file mode 100644 index 00000000..87b7356f --- /dev/null +++ b/FTNoIR_Tracker_PT/doc/index.htm @@ -0,0 +1,262 @@ + + + + + FTNoIR PointTracker Help + + + + + + + + + + + + + + +
+

FaceTrackNoIR PointTracker Plugin

PointTracker Plugin Logo
+ + +

About

+
+

+PointTracker is a plugin for the free head tracking software FaceTrackNoIR +which introduces the capability to track a (typically IR-) point model comprising 3 bright points to FaceTrackNoIR, +much like the popular free tracking software Freetrack does.
+It was created as a stable modular alternative to Freetrack, which has some stability issues with newer systems and seems to be no longer actively developped. +

+
+ + +

Settings

+
+

+This section desribes the various settings of the PointTracker plugin in detail. +

+ +Settings Pane 1 +
+
Show VideoWidget
Whether the video widget is updated or not. It may save some performance to turn this off when not needed
+
Sleep time
Time the tracking thread sleeps after each processed image. It's inverse should be below the framefrate you want to achieve. +(check the framerate in the status region when tracker is active, in case the sleep time is too high, the framerate will decrease). +Low values will result in more CPU-load.
+
Dynamic Pose Resolution
Whether the point correspondence and pose ambiquity is resolved using a more sophisticated dynamic algorithm (constant velocity prediction) or a simple static resolution. +Dynamic pose resolution can capture more extreme poses but may occasionally get stuck in a wrong pose estimates so that a reset of the internal state becomes neccessary.
+
Auto-reset time
If no valid tracking result can be found when using dynamic pose resolution, the tracker will automatically reset its internal state (used for resolving the pose ambiguity and point correspondence) +and return to a fail-safe initialization phase that assumes a neutral pose after this time. +Decrease this time, if you get stuck in a wrong pose too often.
+
Reset
Manually reset the trackers internal state used for dynamic pose resolution and return to a fail-safe initialization phase that assumes a neutral pose. +You may use this in case you get stuck in a wrong pose.
+
Enable Axis ...
Which axis to use for FTNoIR.
+
+ +Settings Pane 2 +
+
Device
The camera used for tracking.
+
Resolution
The desired capture resolution. If your camera does not support the entered resolution the true output resolution may be different or even invalid. +You may check the true capture resolution in the status area while the tracker is running. A higher resolution results in more accurate point positions and will increase the +stability of the tracking result, as long as the signal/noise ratio is sufficiently high.
+
FPS
The desired capture framerate. Again, if your camera does not support the entered framerate, the true caputre framerate may be different or invalid. +You may check the true processing framerate in the status area while the tracker is running.
+
F/W
The focal length of the camera divided by the sensor width (of course in the same units). +In case you don't have access to your camera's specifications, you can measure this yourself by placing a plane object of known width (for example a piece of cardboard) in front of the camera until it fills the whole image width. +Then measure the distance between the object and the camera and divide by the object width.
+
VideoWidget
Shows a resizable stand-alone video widget that shows the same content as the integrated video widget in FTNoIR. +Update rate is only 10 fps and may lag behind a bit. Mainly useful during calibration of the point extraction. Same as for the integrated wiget, to save resources, this widget should only be shown when needed.
+
Roll Pitch Yaw...
The orientation of the camera relative to the reference frame. +If these angles are setup properly, the direction of translations may not be correct. +Roll is treated in a special way since it is implemented as a frame rotation by +/- 90 deg that is transparent to the rest of the processing pipeline. +
+
Threshold
The threshold for point recognition. Areas above the threshold are shown in blue in the VideoWidget. +Since point accuracy is best if the points are as big as possible in pixels, the theshold should be chosen as low as possible (stop before the contour of the points becomes "noisy"). +If small reflections are being falsely classified as points, increasing the minimum point diameter (see below) may help.
+
Min Diameter
Minimum diameter of blobs to be classified as a pointmodel-point.
+
Max Diameter
Maximum diameter of blobs to be classified as a pointmodel-point.
+
Status
The tracker's status is shown in this area while the tracker is running. +The FPS shown here correspond to the framerate of the whole tracker processing chain and may be lower than what your camera is able to provide, when
+1. The processing gets not enough CPU time
+2. The sleep time of the tracking thread is set too high
+
+ +Settings Pane 3 +
+
Model Selection and Dimensions ...
+First select your model type (point, clip, custom), then enter the dimensions of your model in milimeters here.
+For the custom setting, the coordinates of the two remaining model points have to be entered (reference point M0 is at (0,0,0)) in a pose where the model roughly faces the camera. +For orientation, the coordinates for the standard Freetrack clip are (0,40,-30), (0,-70,-80) and the ones for the cap (40,-60,-100), (-40,-60,-100).
+When using a custom point-model configuration, the following restrictions should be observed:
+The plane in which the 3 points lie should never be parallel to the image plane, M0-M1 and M0-M2 should be roughly perpendicular.
+ +
Model Position
The vector from the model to the center of the head in the model frame. Can be calibrated automatically.
+
Calibrate
In order to automatically calibrate the model-head offset, do the following:
Press the Calibrate button, then look around while not moving your shoulder. (i.e. only rotation, no translation). +Do not stay in one pose for too long. The current translation estimate will be updated in real time. As soon as the values stabilized sufficiently, press the Calibrate button again to stop the calibration process.
+
+
+ + +

Filter Setup

+
+

+This section desribes how the FTNoIR filter work and what the recommended settings for PointTracker are. +

+

+Filtering is always a tradeoff between stability, accuracy and responsiveness. +

+

+The Smoothing filter in FTNoIR is just a simple average over the last n samples. +Since this filter produces input lag no matter how fast the head-movements are, it is recommended to turn it off by setting samples to 1. +

+

+In the filter tab, it is recommended to select Accela Filter Mk2. +Accela is a non-linear filter that works as follows:
+It looks at the difference between the new raw values new_val from the tracker and the last filtered value old_val +and maps this difference via the customizable response function f via:
+

+

+new_val = old_val + f(new_val - old_val) / reduction_factor +

+

+So by setting f(x) = reduction_factor * x, one will get no filtering at all.
+If you set lower values for small x, small deviations (usually noise) will get dampened. +This results in a dynamic dead-zone around the current position. +

+

+The last two points are used by accela to extrapolate for large deviations. +So in order to get a fast unfiltered response for large deviations, the line connecting the last two points should have a slope >= reduction_factor. +

+

+More aggressive accela settings than the default FTNoIR accela settings are recommended in order to decrease the filtering lag and fully use the potential of point tracking.
+My current settings are: +

+

+[Accela]
+Reduction=20
+
+[Curves-Accela-Scaling-Rotation]
+point-count=4
+point-0-x=0.1
+point-0-y=0
+point-1-x=1.43
+point-1-y=2.45
+point-2-x=2.0
+point-2-y=5.44
+point-3-x=2.06
+point-3-y=6
+
+

+The curve is not too different from the standard one (except that I like a small dynamic dead zone for steady aiming, that's why the curve has a slope of 0 at the beginning).
+However, the reduction factor is decreased to a value of 20 (compared to the standard value of 100). This implies that each value of the curve is effectively 5 times higher than in standard FTNoIR (see formula above), which means higher responsiveness but can also lead to jitter/shaking.
+Keep in mind that there are no best filter settings. Since filtering is always a compromise it's a matter of personal taste and +playing around with the filter settings is highly recommended. +

+
+ + +

Support

+
+

+For questions/feedback about the plugin, post to the FTNoIR-Forum.
+In case you like this plugin and would like to support the author, you may consider making a donation. +

+
+
+
+ + + + +
+
+
+
+ + +

ChangeLog

+
+

1.1

+
    +
  • Added camera yaw and roll correction (intended for vertically mounted cameras)
  • +
  • Improved point extraction algorithm, thanks to Michael Welter
  • +
  • UI improvements: Select camera by device name, different VideoWidget architecture
  • +
  • Bugfixes: Removed 99 FPS limitation
  • +
+ +

1.0

+
    +
  • Added camera pitch correction
  • +
  • Better communication with FTNoIR: output axis configuration, status report
  • +
+ +

1.0 beta

+
    +
  • Switchted to videoInput library for capture. Desired capture resolution and fps can now be customized
  • +
  • Introduced dynamic point-correspondence and POSIT-ambiguity resolution, which allows for the reconstruction of more extreme poses
  • +
  • More convenient freetrack-like model dimension GUI
  • +
  • Bugfixes: VideoWidget skipping frames, Timer resolution too low for accurate FPS measurement
  • +
+
+ + +

Build Instructions

+
+

+This section describes what you need to do in order to build PointTracker yourself.
+You can find the sources at the project site +or as part of the FTNoIR sources. +

+

The project was created with Visual Studio.

+ +

Dependencies

+
    +
  • Qt 4.8.2 library
  • +
  • Qt plugin for Visual studio
  • +
  • OpenCV 2.4 prebuilt for Windows
  • +
  • Boost 1.47
  • +
+ +

Details

+
+

Common

+
    +
  • setup environment variable "QTDIR" (example value "D:\Devel\Libs\Qt\4.8.2")
  • +
  • add "%QTDIR%\bin" to PATH
  • +
  • setup environment variable "BOOST_DIR" (example value "D:\Devel\Libs\boost_1_47_0")
  • +
  • setup environment variable "OPENCV_DIR" (example value "D:\Devel\Libs\opencv\build")
  • +
+

Debug

+

opencv linked dynamically:

+
    +
  • add "%OPENCV_DIR%\x86\vc9\bin" to PATH
  • +
+

(in case of different Visual studio, change PATH and linker dependencies accordingly)

+

Release

+

opencv linked statically:

+
    +
  • custom build a statically linked version of opencv with the buil-option BUILD_WITH_STATIC_CRT set to OFF!
  • +
  • copy resulting libaries to "%OPENCV_DIR%\x86\vc9\static_lib"
  • +
+

(in case of different Visual studio, change PATH and linker dependencies accordingly)

+
+
+ +
+ + + \ No newline at end of file diff --git a/FTNoIR_Tracker_PT/doc/logo.png b/FTNoIR_Tracker_PT/doc/logo.png new file mode 100644 index 00000000..95032a25 Binary files /dev/null and b/FTNoIR_Tracker_PT/doc/logo.png differ diff --git a/FTNoIR_Tracker_PT/doc/ptrack.ico b/FTNoIR_Tracker_PT/doc/ptrack.ico new file mode 100644 index 00000000..c4b2aedc Binary files /dev/null and b/FTNoIR_Tracker_PT/doc/ptrack.ico differ diff --git a/FTNoIR_Tracker_PT/doc/settings1.png b/FTNoIR_Tracker_PT/doc/settings1.png new file mode 100644 index 00000000..35b84c5c Binary files /dev/null and b/FTNoIR_Tracker_PT/doc/settings1.png differ diff --git a/FTNoIR_Tracker_PT/doc/settings2.png b/FTNoIR_Tracker_PT/doc/settings2.png new file mode 100644 index 00000000..c6cfd1f3 Binary files /dev/null and b/FTNoIR_Tracker_PT/doc/settings2.png differ diff --git a/FTNoIR_Tracker_PT/doc/settings3.png b/FTNoIR_Tracker_PT/doc/settings3.png new file mode 100644 index 00000000..5922403d Binary files /dev/null and b/FTNoIR_Tracker_PT/doc/settings3.png differ diff --git a/FTNoIR_Tracker_PT/doc/style.css b/FTNoIR_Tracker_PT/doc/style.css new file mode 100644 index 00000000..a8d3e333 --- /dev/null +++ b/FTNoIR_Tracker_PT/doc/style.css @@ -0,0 +1,131 @@ +body { + width: 1000px; + font-size: 13px; + color: #000000; + padding: 0; + margin: 0 auto; + background: #444444; + font-family: verdana,arial; +} + +table { + border-width: 3px; + border-color: #0000FF; + border-style: ridge; + margin-top: 5px; + background-color: #E0E0FF; +} + +table.blind { + border: none; + background-color: #E6E6E6; +} + +fieldset.blind { + border: none; +} + +h1 { font-size: 160%; } +h2 { font-size: 140%; } +h3 { font-size: 115%; } + +.indent { + margin-left: 25px; +} + +p +{ + margin-left: 10px; +} + +li +{ + margin: 10px; +} + + +dl +{ + /*width: 80%;*/ + border-bottom: 1px solid #999; +} + +dt +{ + padding-top: 5px; + font-weight: bold; + border-top: 1px solid #999; +} + +dd +{ + padding: 5px; +} + + +hr { + color: #688938; +} + +a:link, a:visited { + color: #0000BF; +} +a:hover { + color: #0000FF; +} + +a.nav { + position: relative; + top: -30px; + display: block; + visibility: hidden; +} + +#navbar { + width: 1000px; + height: 30px; + background-color:#1a1a1b; + position: fixed; + margin: 0 auto; + padding: 0; +} + +#navbar ul +{ + list-style-type: none; + margin: 0 auto; + padding: 0; + overflow: hidden; +} + +#navbar li +{ + margin: 0 auto; + padding: 5px; + float:left; +} + +#navbar a:link,a:visited +{ + display:block; + width:150px; + font-weight:bold; + color:#e85d02; + text-align:center; + /*padding:4px;*/ + text-decoration:none; + /*text-transform:uppercase;*/ +} + +#navbar a:hover,a:active +{ + color:#ffffff; +} + +#content { + background-color:#ffffff; + padding: 15px; + padding-top: 40px; + padding-right: 40px; + margin: 0 auto; +} diff --git a/FTNoIR_Tracker_PT/frame_observer.cpp b/FTNoIR_Tracker_PT/frame_observer.cpp new file mode 100644 index 00000000..7e4bb3e3 --- /dev/null +++ b/FTNoIR_Tracker_PT/frame_observer.cpp @@ -0,0 +1,18 @@ +/* Copyright (c) 2013 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 "frame_observer.h" + +//----------------------------------------------------------------------------- +FrameProvider::~FrameProvider() +{ + QMutexLocker lock(&observer_mutex); + for (auto 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 new file mode 100644 index 00000000..4afbd72c --- /dev/null +++ b/FTNoIR_Tracker_PT/frame_observer.h @@ -0,0 +1,72 @@ +/* Copyright (c) 2013 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 FRAME_OBSERVER_H +#define FRAME_OBSERVER_H + +#include +#include +#include +#include + +//----------------------------------------------------------------------------- +// Forward declarations +class FrameObserver; + +//----------------------------------------------------------------------------- +// Provides means to copy frame and point information if it has observers +// Instantiate a FrameObserver to get the information +class FrameProvider +{ + friend class FrameObserver; +public: + ~FrameProvider(); + +protected: + virtual bool get_frame_and_points(cv::Mat& frame, boost::shared_ptr< std::vector >& points) = 0; + + bool has_observers() const { QMutexLocker lock(&observer_mutex); return !frame_observers.empty(); } + +private: + mutable QMutex observer_mutex; + void add_observer(FrameObserver* obs) { QMutexLocker lock(&observer_mutex); frame_observers.insert(obs); } + void remove_observer(FrameObserver* obs) { QMutexLocker lock(&observer_mutex); frame_observers.erase(obs); } + std::set frame_observers; +}; + +//----------------------------------------------------------------------------- +// Used to get frame and point information from MutexedFrameProvider +// Destroy instance if not interested anymore since a living +// FrameObserver instance causes MutexedFrameProvider to provide the information, +// potentially reducing its performance +class FrameObserver +{ +public: + FrameObserver(FrameProvider* provider) : provider(provider) { + provider->add_observer(this); + } + + ~FrameObserver() { + if (provider) provider->remove_observer(this); + } + + bool get_frame_and_points(cv::Mat& frame, boost::shared_ptr< std::vector >& points) { + return provider ? provider->get_frame_and_points(frame, points) : false; + } + + void on_frame_provider_destroy() { + provider = NULL; + } + +protected: + FrameProvider* provider; + +private: + FrameObserver(const FrameObserver&); +}; + +#endif //FRAME_OBSERVER_H \ No newline at end of file diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp new file mode 100644 index 00000000..88a3fc8d --- /dev/null +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp @@ -0,0 +1,265 @@ +/* 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 + +using namespace std; +using namespace cv; +using namespace boost; + +//#define PT_PERF_LOG //log performance + +const float rad2deg = 180.0/3.14159265; +const float deg2rad = 1.0/rad2deg; + +//----------------------------------------------------------------------------- +Tracker::Tracker() + : frame_count(0), + commands(0), + video_widget(NULL), + video_frame(NULL), + tracking_valid(false) +{ + qDebug()<<"Tracker::Tracker"; + TrackerSettings settings; + settings.load_ini(); + apply(settings); + camera.start(); + start(); +} + +Tracker::~Tracker() +{ + qDebug()<<"Tracker::~Tracker"; + // terminate tracker thread + set_command(ABORT); + wait(); + // destroy video widget + show_video_widget = false; + update_show_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 (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()) + { + frame = frame_rotation.rotate_frame(frame); + 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 PT_PERF_LOG + log_stream<<"dt: "<(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; + sleep_time = settings.sleep_time; + point_tracker.dt_reset = settings.reset_time / 1000.0; + show_video_widget = settings.video_widget; + update_show_video_widget(); + bEnableRoll = settings.bEnableRoll; + bEnablePitch = settings.bEnablePitch; + bEnableYaw = settings.bEnableYaw; + bEnableX = settings.bEnableX; + bEnableY = settings.bEnableY; + bEnableZ = settings.bEnableZ; + + t_MH = settings.t_MH; + R_GC = Matx33f( cos(deg2rad*settings.cam_yaw), 0, sin(deg2rad*settings.cam_yaw), + 0, 1, 0, + -sin(deg2rad*settings.cam_yaw), 0, cos(deg2rad*settings.cam_yaw)); + R_GC = R_GC * Matx33f( 1, 0, 0, + 0, cos(deg2rad*settings.cam_pitch), sin(deg2rad*settings.cam_pitch), + 0, -sin(deg2rad*settings.cam_pitch), cos(deg2rad*settings.cam_pitch)); + + FrameTrafo X_MH(Matx33f::eye(), t_MH); + X_GH_0 = R_GC * X_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_GH_0 = R_GC * X_CM_0 * X_MH; +} + +bool Tracker::get_frame_and_points(cv::Mat& frame_copy, boost::shared_ptr< std::vector >& points) +{ + QMutexLocker lock(&mutex); + if (frame.empty()) return false; + + // copy the frame and points from the tracker thread + frame_copy = frame.clone(); + points = boost::shared_ptr< vector >(new vector(point_extractor.get_points())); + return true; +} + +void Tracker::update_show_video_widget() +{ + if (!show_video_widget && video_widget) { + delete video_widget; + video_widget = NULL; + if (video_frame->layout()) delete video_frame->layout(); + } + else if (video_frame && show_video_widget && !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); + video_layout->addWidget(video_widget); + video_frame->setLayout(video_layout); + video_widget->resize(VIDEO_FRAME_WIDTH, VIDEO_FRAME_HEIGHT); + } +} + +//----------------------------------------------------------------------------- +// ITracker interface +void Tracker::Initialize(QFrame *video_frame) +{ + qDebug("Tracker::Initialize"); + // setup video frame + this->video_frame = video_frame; + video_frame->setAttribute(Qt::WA_NativeWindow); + video_frame->show(); + update_show_video_widget(); +} + +void Tracker::refreshVideo() +{ + if (video_widget) video_widget->update_frame_and_points(); +} + +void Tracker::StartTracker(HWND parent_window) +{ + reset_command(PAUSE); +} + +void Tracker::StopTracker(bool exit) +{ + set_command(PAUSE); +} + +bool Tracker::GiveHeadPoseData(THeadPoseData *data) +{ + { + QMutexLocker lock(&mutex); + + if (!tracking_valid) return false; + + 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(); + Vec3f t = X_GH.t - X_GH_0.t; + + // 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; + + // translate rotation matrix from opengl (G) to roll-pitch-yaw (E) frame + // -z -> x, y -> z, x -> -y + Matx33f R_EG( 0, 0,-1, + -1, 0, 0, + 0, 1, 0); + R = R_EG * R * R_EG.t(); + + // extract rotation angles + float alpha, beta, gamma; + 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; // FTNoIR expects a minus here + if (bEnableRoll) data->roll = rad2deg * gamma; + } + return true; +} + +//----------------------------------------------------------------------------- +#pragma comment(linker, "/export:GetTracker=_GetTracker@0") + +FTNOIR_TRACKER_BASE_EXPORT ITrackerPtr __stdcall GetTracker() +{ + 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 new file mode 100644 index 00000000..6eef945a --- /dev/null +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h @@ -0,0 +1,99 @@ +/* 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 "frame_observer.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 + +//----------------------------------------------------------------------------- +// Constantly processes the tracking chain in a separate thread +class Tracker : public ITracker, QThread, public FrameProvider +{ +public: + Tracker(); + ~Tracker(); + + // --- ITracker interface --- + virtual void Initialize(QFrame *videoframe); + virtual void StartTracker(HWND parent_window); + virtual void StopTracker(bool exit); + virtual bool GiveHeadPoseData(THeadPoseData *data); + virtual void refreshVideo(); + + void apply(const TrackerSettings& settings); + void center(); + void reset(); // reset the trackers internal state variables + void run(); + + 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: + // --- MutexedFrameProvider interface --- + virtual bool get_frame_and_points(cv::Mat& frame, boost::shared_ptr< std::vector >& points); + + // --- thread --- + QMutex mutex; + // thread commands + enum Command { + ABORT = 1<<0, + PAUSE = 1<<1 + }; + void set_command(Command command); + void reset_command(Command command); + int commands; + + int sleep_time; + + // --- tracking chain --- + VICamera camera; + FrameRotation frame_rotation; + PointExtractor point_extractor; + PointTracker point_tracker; + bool tracking_valid; + + FrameTrafo X_GH_0; // for centering + cv::Vec3f t_MH; // translation from model frame to head frame + cv::Matx33f R_GC; // rotation from opengl reference frame to camera frame + + // --- ui --- + cv::Mat frame; // the output frame for display + + void update_show_video_widget(); + bool show_video_widget; + VideoWidget* video_widget; + QFrame* video_frame; + + // --- misc --- + bool bEnableRoll; + bool bEnablePitch; + bool bEnableYaw; + bool bEnableX; + bool bEnableY; + bool bEnableZ; + + long frame_count; + Timer time; +}; + +#endif // FTNOIR_TRACKER_PT_H diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.qrc b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.qrc new file mode 100644 index 00000000..9b510981 --- /dev/null +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.qrc @@ -0,0 +1,10 @@ + + + Resources/icon.ico + Resources/cap_front.png + Resources/cap_side.png + Resources/clip_front.png + Resources/clip_side.png + Resources/Logo_IR.png + + diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.cpp b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.cpp new file mode 100644 index 00000000..c99f4d67 --- /dev/null +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.cpp @@ -0,0 +1,406 @@ +/* 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 +#include +#include + +using namespace std; + +//----------------------------------------------------------------------------- +TrackerDialog::TrackerDialog() + : settings_dirty(false), + tracker(NULL), + video_widget_dialog(NULL), + timer(this), + trans_calib_running(false) +{ + 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); + + vector device_names; + get_camera_device_names(device_names); + for (auto iter = device_names.begin(); iter != device_names.end(); ++iter) + { + ui.camdevice_combo->addItem(iter->c_str()); + } + ui.camdevice_combo->setCurrentIndex(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.camroll_combo->addItem("-90", -1); + ui.camroll_combo->addItem("0" , 0); + ui.camroll_combo->addItem("90" , 1); + int i = ui.camroll_combo->findData(settings.cam_roll); + ui.camroll_combo->setCurrentIndex(i>=0 ? i : 0); + + ui.campitch_spin->setValue(settings.cam_pitch); + ui.camyaw_spin->setValue(settings.cam_yaw); + 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.camdevice_combo,SIGNAL(currentIndexChanged(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.camroll_combo,SIGNAL(currentIndexChanged(int)), this,SLOT(set_cam_roll(int)) ); + connect( ui.campitch_spin,SIGNAL(valueChanged(int)), this,SLOT(set_cam_pitch(int)) ); + connect( ui.camyaw_spin,SIGNAL(valueChanged(int)), this,SLOT(set_cam_yaw(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.videowidget_button,SIGNAL(clicked()), this,SLOT(create_video_widget()) ); + + 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_cam_roll(int idx) +{ + settings.cam_roll = ui.camroll_combo->itemData(idx).toInt(); + settings_changed(); +} + +void TrackerDialog::set_model_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_model_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_model_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_model_clip(); + break; + + case TrackerDialogSettings::MODEL_CAP: + set_model_cap(); + break; + + case TrackerDialogSettings::MODEL_CUSTOM: + set_model_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::widget_destroyed(QObject* obj) +{ + if (obj == video_widget_dialog) { + // widget was / will be already deleted by Qt + destroy_video_widget(false); + } +} + +void TrackerDialog::create_video_widget() +{ + // this should not happen but better be sure + if (video_widget_dialog) destroy_video_widget(); + if (!tracker) return; + + video_widget_dialog = new VideoWidgetDialog(this, tracker); + video_widget_dialog->setAttribute( Qt::WA_DeleteOnClose ); + connect( video_widget_dialog, SIGNAL(destroyed(QObject*)), this, SLOT(widget_destroyed(QObject*)) ); + video_widget_dialog->show(); + + ui.videowidget_button->setEnabled(false); +} + +void TrackerDialog::destroy_video_widget(bool do_delete /*= true*/) +{ + if (video_widget_dialog) { + if (do_delete) delete video_widget_dialog; + video_widget_dialog = NULL; + } + if (tracker) ui.videowidget_button->setEnabled(true); +} + +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); + + // 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); + + // update calibration + if (trans_calib_running) trans_calib_step(); + + // update videowidget + if (video_widget_dialog) { + video_widget_dialog->get_video_widget()->update_frame_and_points(); + } + } + else + { + QString to_print = "Tracker offline"; + ui.caminfo_label->setText(to_print); + ui.pointinfo_label->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.videowidget_button->setEnabled(true); + 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; + destroy_video_widget(); + ui.videowidget_button->setEnabled(false); + ui.tcalib_button->setEnabled(false); + //ui.center_button->setEnabled(false); + ui.reset_button->setEnabled(false); +} + +//----------------------------------------------------------------------------- +#pragma comment(linker, "/export:GetTrackerDialog=_GetTrackerDialog@0") + +FTNOIR_TRACKER_BASE_EXPORT ITrackerDialogPtr __stdcall GetTrackerDialog( ) +{ + 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 new file mode 100644 index 00000000..bf0a90f2 --- /dev/null +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.h @@ -0,0 +1,116 @@ +/* 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 "trans_calib.h" +#include "video_widget.h" +#include "ui_FTNoIR_PT_Controls.h" + +#include + +//----------------------------------------------------------------------------- +// The dialog that shows up when the user presses "Settings" +class TrackerDialog : public QWidget, Ui::UICPTClientControls, 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 idx) { settings.cam_index = idx; 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_roll(int idx); + void set_cam_pitch(int val) { settings.cam_pitch = val; settings_changed(); } + void set_cam_yaw(int val) { settings.cam_yaw = 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_model_clip(); } + void set_clip_t_length(int val) { dialog_settings.clip_tz = val; set_model_clip(); } + void set_clip_b_height(int val) { dialog_settings.clip_by = val; set_model_clip(); } + void set_clip_b_length(int val) { dialog_settings.clip_bz = val; set_model_clip(); } + void set_cap_width(int val) { dialog_settings.cap_x = val; set_model_cap(); } + void set_cap_height(int val) { dialog_settings.cap_y = val; set_model_cap(); } + void set_cap_length(int val) { dialog_settings.cap_z = val; set_model_cap(); } + void set_m1x(int val) { dialog_settings.M01x = val; set_model_custom(); } + void set_m1y(int val) { dialog_settings.M01y = val; set_model_custom(); } + void set_m1z(int val) { dialog_settings.M01z = val; set_model_custom(); } + void set_m2x(int val) { dialog_settings.M02x = val; set_model_custom(); } + void set_m2y(int val) { dialog_settings.M02y = val; set_model_custom(); } + void set_m2z(int val) { dialog_settings.M02z = val; set_model_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 widget_destroyed(QObject* obj); + + void create_video_widget(); + + void poll_tracker_info(); + +protected: + void destroy_video_widget(bool do_delete = true); + + void set_model_clip(); + void set_model_cap(); + void set_model_custom(); + + void settings_changed(); + + TrackerSettings settings; + TrackerDialogSettings dialog_settings; + bool settings_dirty; + + Tracker* tracker; + QTimer timer; + + VideoWidgetDialog* video_widget_dialog; + + TranslationCalibrator trans_calib; + bool trans_calib_running; + + Ui::UICPTClientControls ui; +}; + +#endif //FTNOIR_TRACKER_PT_DIALOG_H \ No newline at end of file diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dll.cpp b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dll.cpp new file mode 100644 index 00000000..3a73f679 --- /dev/null +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dll.cpp @@ -0,0 +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 + +//----------------------------------------------------------------------------- +void TrackerDll::getFullName(QString *strToBeFilled) +{ + *strToBeFilled = "PointTracker 1.1"; +} + +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.ico"); +} + + +//----------------------------------------------------------------------------- +#pragma comment(linker, "/export:GetTrackerDll=_GetTrackerDll@0") + +FTNOIR_TRACKER_BASE_EXPORT ITrackerDllPtr __stdcall GetTrackerDll() +{ + return new TrackerDll; +} diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dll.h b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dll.h new file mode 100644 index 00000000..15ad63aa --- /dev/null +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dll.h @@ -0,0 +1,19 @@ +/* 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" + +//----------------------------------------------------------------------------- +class TrackerDll : public ITrackerDll +{ + // ITrackerDll interface + void Initialize() {} + 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/ftnoir_tracker_pt_settings.cpp b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.cpp new file mode 100644 index 00000000..13ef49ec --- /dev/null +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.cpp @@ -0,0 +1,154 @@ +/* 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("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( "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_roll = iniFile.value("CameraRoll", 0).toInt(); + cam_pitch = iniFile.value("CameraPitch", 0).toInt(); + cam_yaw = iniFile.value("CameraYaw", 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("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 ( "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("CameraRoll", cam_roll); + iniFile.setValue("CameraPitch", cam_pitch); + iniFile.setValue("CameraYaw", cam_yaw); + 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("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( "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("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 ( "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 new file mode 100644 index 00000000..1cf60853 --- /dev/null +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.h @@ -0,0 +1,88 @@ +/* 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" + + +//----------------------------------------------------------------------------- +// Tracker settings and their ini-IO +struct TrackerSettings +{ + // camera + int cam_index; + float cam_f; + int cam_res_x; + int cam_res_y; + int cam_fps; + int cam_roll; + int cam_pitch; + int cam_yaw; + + // 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; +}; + + +//----------------------------------------------------------------------------- +// Settings specific to the tracker dialog and their ini-IO +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 new file mode 100644 index 00000000..76a152a7 --- /dev/null +++ b/FTNoIR_Tracker_PT/point_extractor.cpp @@ -0,0 +1,101 @@ +/* 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_gray; + cvtColor(frame, frame_gray, CV_RGB2GRAY); + + // convert to binary + Mat frame_bin; + threshold(frame_gray, frame_bin, threshold_val, 255, THRESH_BINARY); + + unsigned int region_size_min = 3.14*min_size*min_size/4.0; + unsigned int region_size_max = 3.14*max_size*max_size/4.0; + + int blob_index = 1; + for (int y=0; y= 255) break; + for (int x=0; x= 255) break; + + // find connected components with floodfill + if (frame_bin.at(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_gray.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); + } + } + + // draw output image + if (draw_output) { + vector channels; + frame_bin.setTo(170, frame_bin); + channels.push_back(frame_gray + frame_bin); + channels.push_back(frame_gray - frame_bin); + channels.push_back(frame_gray - frame_bin); + merge(channels, frame); + } + + return points; +} diff --git a/FTNoIR_Tracker_PT/point_extractor.h b/FTNoIR_Tracker_PT/point_extractor.h new file mode 100644 index 00000000..b142d2bb --- /dev/null +++ b/FTNoIR_Tracker_PT/point_extractor.h @@ -0,0 +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 diff --git a/FTNoIR_Tracker_PT/point_tracker.cpp b/FTNoIR_Tracker_PT/point_tracker.cpp new file mode 100644 index 00000000..acde9154 --- /dev/null +++ b/FTNoIR_Tracker_PT/point_tracker.cpp @@ -0,0 +1,359 @@ +/* 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 boost; +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); +} + +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(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); + + for (int i = 0; i& 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 + +// ---------------------------------------------------------------------------- +// Affine 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 FrameTrafo operator*(const cv::Matx33f& X, const FrameTrafo& Y) +{ + return FrameTrafo(X*Y.R, X*Y.t); +} + +inline FrameTrafo operator*(const FrameTrafo& X, const cv::Matx33f& Y) +{ + return FrameTrafo(X.R*Y, 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; // discriminant 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); + boost::shared_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 new file mode 100644 index 00000000..c14e94ad --- /dev/null +++ b/FTNoIR_Tracker_PT/resource.h @@ -0,0 +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 diff --git a/FTNoIR_Tracker_PT/timer.cpp b/FTNoIR_Tracker_PT/timer.cpp new file mode 100644 index 00000000..363b5b09 --- /dev/null +++ b/FTNoIR_Tracker_PT/timer.cpp @@ -0,0 +1,66 @@ +/* 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 + if(!stopped) + 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 new file mode 100644 index 00000000..f189e23c --- /dev/null +++ b/FTNoIR_Tracker_PT/timer.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 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 new file mode 100644 index 00000000..9b75a1b6 --- /dev/null +++ b/FTNoIR_Tracker_PT/trans_calib.cpp @@ -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. + */ + +#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 new file mode 100644 index 00000000..f2521690 --- /dev/null +++ b/FTNoIR_Tracker_PT/trans_calib.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 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 new file mode 100644 index 00000000..236faaf7 --- /dev/null +++ b/FTNoIR_Tracker_PT/video_widget.cpp @@ -0,0 +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. + * + * 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; +using namespace boost; + +// ---------------------------------------------------------------------------- +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(); +} + +// ---------------------------------------------------------------------------- +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 diff --git a/FTNoIR_Tracker_PT/video_widget.h b/FTNoIR_Tracker_PT/video_widget.h new file mode 100644 index 00000000..dd5fb642 --- /dev/null +++ b/FTNoIR_Tracker_PT/video_widget.h @@ -0,0 +1,58 @@ +/* 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 +#include +#include + +// ---------------------------------------------------------------------------- +// 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; +}; + +// ---------------------------------------------------------------------------- +// A VideoWidget embedded in a dialog frame +class VideoWidgetDialog : public QDialog +{ +public: + VideoWidgetDialog(QWidget *parent, FrameProvider* provider); + virtual ~VideoWidgetDialog() {} + + VideoWidget* get_video_widget() { return video_widget; } + +private: + VideoWidget* video_widget; +}; + +#endif // VIDEOWIDGET_H diff --git a/ftnoir_protocol_fg/ftnoir_protocol_fg.cpp.autosave b/ftnoir_protocol_fg/ftnoir_protocol_fg.cpp.autosave new file mode 100644 index 00000000..0b67b0d2 --- /dev/null +++ b/ftnoir_protocol_fg/ftnoir_protocol_fg.cpp.autosave @@ -0,0 +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->writeD atagram((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_tracker_pt/camera.cpp b/ftnoir_tracker_pt/camera.cpp deleted file mode 100644 index 46dd20c5..00000000 --- a/ftnoir_tracker_pt/camera.cpp +++ /dev/null @@ -1,213 +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 "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 deleted file mode 100644 index 5f1f56b0..00000000 --- a/ftnoir_tracker_pt/camera.h +++ /dev/null @@ -1,119 +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 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_pt_controls.ui b/ftnoir_tracker_pt/ftnoir_pt_controls.ui deleted file mode 100644 index 6a183eae..00000000 --- a/ftnoir_tracker_pt/ftnoir_pt_controls.ui +++ /dev/null @@ -1,1765 +0,0 @@ - - - UICPTClientControls - - - Qt::NonModal - - - - 0 - 0 - 468 - 528 - - - - - 0 - 0 - - - - PointTracker Settings - - - - :/Resources/icon.png:/Resources/icon.png - - - Qt::LeftToRight - - - false - - - - QLayout::SetFixedSize - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - - - 1 - - - - General - - - - - - Tracker Thread - - - - - - - - - - - Dynamic Pose Resolution - - - - - - - Sleep time - - - sleep_spin - - - - - - - - - Time the tracker thread sleeps after each processed frame - - - - - - 9999 - - - - - - - ms - - - - - - - - - Auto-reset time - - - reset_spin - - - - - - - - - Time until automatic reset of tracker's internal state when no valid tracking result is found - - - 9999 - - - - - - - ms - - - - - - - - - Whether to update the content of the VideoWidget - - - Show VideoWidget - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - false - - - Reset the tracker's internal state - - - Reset - - - - - - - - - - - - - 0 - 85 - - - - Enable Axis - - - - - - - - Roll: - - - chkEnableRoll - - - - - - - Pitch: - - - chkEnablePitch - - - - - - - Yaw: - - - chkEnableYaw - - - - - - - - 20 - 16777215 - - - - Qt::LeftToRight - - - - - - - - - - - - - - 20 - 16777215 - - - - Qt::LeftToRight - - - - - - - - - - - 20 - 16777215 - - - - Qt::LeftToRight - - - - - - - - - - X: - - - chkEnableX - - - - - - - - 20 - 16777215 - - - - Qt::LeftToRight - - - - - - - - - - Y: - - - chkEnableY - - - - - - - - 20 - 16777215 - - - - Qt::LeftToRight - - - - - - - - - - Z: - - - chkEnableZ - - - - - - - - 20 - 16777215 - - - - Qt::LeftToRight - - - - - - - - - - Qt::Horizontal - - - QSizePolicy::Minimum - - - - 40 - 20 - - - - - - - - Qt::Horizontal - - - QSizePolicy::Minimum - - - - 40 - 20 - - - - - - - - Qt::Horizontal - - - QSizePolicy::Minimum - - - - 40 - 20 - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - Qt::Vertical - - - - 20 - 20 - - - - - - - - Status - - - - - - QFormLayout::AllNonFixedFieldsGrow - - - - - Camera Info: - - - - - - - - 0 - 0 - - - - - 120 - 0 - - - - - - - - - - - Extracted Points: - - - - - - - - 50 - 0 - - - - - - - - - - - - - - - - - Camera - - - - - - Camera Settings - - - - - - - - - - Index - - - camindex_spin - - - - - - - Capture device index - - - - - - - FPS - - - fps_spin - - - - - - - Desired capture framerate - - - 300 - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - Resolution - - - - - - - Qt::Horizontal - - - - 20 - 20 - - - - - - - - Desired capture width - - - 2000 - - - 10 - - - - - - - x - - - - - - - Desired capture height - - - 2000 - - - 10 - - - - - - - - - - - (Focal length)/(Sensor width) - - - f_dspin - - - - - - - The camera's focal length devided by its sensor width - - - 2 - - - 0.100000000000000 - - - - - - - - - - - - - - - Camera Pitch (upwards = positive) - - - campitch_spin - - - - - - - Qt::DefaultContextMenu - - - The angle the camera is facing upwards - - - -99 - - - - - - - deg - - - - - - - Qt::Horizontal - - - - 20 - 20 - - - - - - - - - - - - - Point Extraction - - - - - - - - Threshold - - - threshold_slider - - - - - - - Intensity threshold for point extraction - - - 255 - - - 127 - - - Qt::Horizontal - - - - - - - - - - - Min Diameter - - - mindiam_spin - - - - - - - Minimum point diameter - - - - - - - px - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Max Diameter - - - maxdiam_spin - - - - - - - Maximum point diameter - - - - - - - px - - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - Status - - - - - - QFormLayout::AllNonFixedFieldsGrow - - - - - Camera Info: - - - - - - - - 0 - 0 - - - - - 120 - 0 - - - - - - - - - - - Extracted Points: - - - - - - - - 50 - 0 - - - - - - - - - - - - - - - - - Model - - - - - - QTabWidget::Rounded - - - 2 - - - false - - - false - - - false - - - - Clip - - - - - - Model Dimensions (mm) - - - - - - - 0 - 0 - - - - - 150 - 170 - - - - - - 30 - 30 - 71 - 111 - - - - - - - :/resources/clip_side.png - - - - - - 100 - 50 - 46 - 22 - - - - 999 - - - - - - 60 - 10 - 46 - 22 - - - - 999 - - - - - - 100 - 90 - 46 - 22 - - - - 999 - - - - - - 10 - 10 - 46 - 13 - - - - Side - - - - - - 40 - 140 - 46 - 22 - - - - 999 - - - - - - 70 - 70 - 16 - 16 - - - - R - - - - - - - - - 0 - 0 - - - - - 100 - 140 - - - - - - 10 - 10 - 46 - 13 - - - - Front - - - - - - 40 - 30 - 21 - 111 - - - - - - - :/resources/clip_front.png - - - - - - 60 - 70 - 16 - 16 - - - - R - - - - - - - - - - - - Cap - - - - - - Model Dimensions (mm) - - - - - - - 140 - 130 - - - - - - 20 - 50 - 111 - 81 - - - - - - - :/resources/cap_side.png - - - - - - 30 - 80 - 46 - 22 - - - - 999 - - - - - - 130 - 50 - 16 - 16 - - - - R - - - - - - 10 - 10 - 46 - 13 - - - - Side - - - - - - 50 - 40 - 46 - 22 - - - - 999 - - - - - - - - - 0 - 0 - - - - - 100 - 130 - - - - - - 10 - 10 - 46 - 13 - - - - Front - - - - - - 30 - 50 - 16 - 16 - - - - R - - - - - - 10 - 50 - 81 - 81 - - - - - - - :/resources/cap_front.png - - - - - - 50 - 30 - 46 - 22 - - - - 999 - - - - - - - - - - - - Custom - - - - - - Model Dimensions (mm) - - - - - - <html><head/><body><p>Location of the two remaining model points<br/>with respect to the reference point in default pose</p></body></html> - - - - - - - Qt::Vertical - - - - 20 - 20 - - - - - - - - - - Qt::Horizontal - - - - 20 - 20 - - - - - - - - - - -999 - - - 999 - - - - - - - y: - - - - - - - -999 - - - 999 - - - - - - - z: - - - - - - - M1: - - - - - - - -999 - - - 999 - - - - - - - x: - - - - - - - - - Qt::Horizontal - - - - 20 - 20 - - - - - - - - - - -999 - - - 999 - - - - - - - x: - - - - - - - z: - - - - - - - -999 - - - 999 - - - - - - - y: - - - - - - - M2: - - - - - - - - - - -999 - - - 999 - - - - - - - - - Qt::Horizontal - - - - 20 - 20 - - - - - - - - - - Qt::Vertical - - - - 20 - 20 - - - - - - - - - - - - - - - Model Position (mm) - - - - - - <html><head/><body><p>Translation from head center to model reference point<br/> in default pose</p></body></html> - - - - - - - - - Qt::Horizontal - - - - 20 - 20 - - - - - - - - - - - - - -999 - - - 999 - - - - - - - x: - - - - - - - y: - - - - - - - z: - - - - - - - -999 - - - 999 - - - - - - - -999 - - - 999 - - - - - - - - - Qt::Horizontal - - - - 20 - 20 - - - - - - - - false - - - Calibrate - - - true - - - - - - - Qt::Horizontal - - - - 20 - 20 - - - - - - - - - - - - - - About - - - - - 30 - 30 - 161 - 111 - - - - <html><head/><body><p><span style=" font-weight:600;">FTNoIR PointTracker Plugin<br/>Version 1.0</span></p><p><span style=" font-weight:600;">by Patrick Ruoff</span></p><p><a href="http://ftnoirpt.sourceforge.net/"><span style=" font-weight:600; text-decoration: underline; color:#0000ff;">Manual (external)</span></a></p></body></html> - - - true - - - - - - 200 - 30 - 141 - 141 - - - - - - - :/resources/logo_ir.png - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Ok - - - - - - - Cancel - - - - - - - - - tabWidget - sleep_spin - reset_spin - chkEnableRoll - chkEnablePitch - chkEnableYaw - chkEnableX - chkEnableY - chkEnableZ - camindex_spin - res_x_spin - res_y_spin - fps_spin - f_dspin - campitch_spin - threshold_slider - mindiam_spin - maxdiam_spin - model_tabs - clip_tlength_spin - clip_theight_spin - clip_bheight_spin - clip_blength_spin - cap_length_spin - cap_height_spin - cap_width_spin - m1x_spin - m1y_spin - m1z_spin - m2x_spin - m2y_spin - m2z_spin - tx_spin - ty_spin - tz_spin - tcalib_button - ok_button - cancel_button - - - - - dynpose_check - toggled(bool) - reset_spin - setEnabled(bool) - - - 285 - 105 - - - 139 - 111 - - - - - - startEngineClicked() - stopEngineClicked() - cameraSettingsClicked() - - diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp b/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp deleted file mode 100644 index 48702d19..00000000 --- a/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp +++ /dev/null @@ -1,261 +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 "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 deleted file mode 100644 index 3825fce7..00000000 --- a/ftnoir_tracker_pt/ftnoir_tracker_pt.h +++ /dev/null @@ -1,96 +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 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.qrc b/ftnoir_tracker_pt/ftnoir_tracker_pt.qrc deleted file mode 100644 index 5734917f..00000000 --- a/ftnoir_tracker_pt/ftnoir_tracker_pt.qrc +++ /dev/null @@ -1,10 +0,0 @@ - - - resources/icon.png - resources/cap_front.png - resources/cap_side.png - resources/clip_front.png - resources/clip_side.png - resources/logo_ir.png - - diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt.rc b/ftnoir_tracker_pt/ftnoir_tracker_pt.rc deleted file mode 100644 index 11c5d52f..00000000 --- a/ftnoir_tracker_pt/ftnoir_tracker_pt.rc +++ /dev/null @@ -1,61 +0,0 @@ -// 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_pt/ftnoir_tracker_pt_dialog.cpp b/ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.cpp deleted file mode 100644 index f222085e..00000000 --- a/ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.cpp +++ /dev/null @@ -1,337 +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 "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 deleted file mode 100644 index f13fe13e..00000000 --- a/ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.h +++ /dev/null @@ -1,102 +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 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 deleted file mode 100644 index 1c486382..00000000 --- a/ftnoir_tracker_pt/ftnoir_tracker_pt_dll.cpp +++ /dev/null @@ -1,40 +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 "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 deleted file mode 100644 index 4dc94173..00000000 --- a/ftnoir_tracker_pt/ftnoir_tracker_pt_dll.h +++ /dev/null @@ -1,18 +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 "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 deleted file mode 100644 index 787a5265..00000000 --- a/ftnoir_tracker_pt/ftnoir_tracker_pt_settings.cpp +++ /dev/null @@ -1,150 +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 "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 deleted file mode 100644 index a1523898..00000000 --- a/ftnoir_tracker_pt/ftnoir_tracker_pt_settings.h +++ /dev/null @@ -1,84 +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 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 deleted file mode 100644 index 09be967a..00000000 --- a/ftnoir_tracker_pt/point_extractor.cpp +++ /dev/null @@ -1,96 +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 "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 deleted file mode 100644 index 9a6f7f2c..00000000 --- a/ftnoir_tracker_pt/point_extractor.h +++ /dev/null @@ -1,31 +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 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 deleted file mode 100644 index 210ed2eb..00000000 --- a/ftnoir_tracker_pt/point_tracker.cpp +++ /dev/null @@ -1,352 +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 "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 - -// ---------------------------------------------------------------------------- -// 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 deleted file mode 100644 index 4ca527a3..00000000 --- a/ftnoir_tracker_pt/resource.h +++ /dev/null @@ -1,14 +0,0 @@ -//{{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/resources/cap_front.png b/ftnoir_tracker_pt/resources/cap_front.png deleted file mode 100644 index 14207a67..00000000 Binary files a/ftnoir_tracker_pt/resources/cap_front.png and /dev/null differ diff --git a/ftnoir_tracker_pt/resources/cap_side.png b/ftnoir_tracker_pt/resources/cap_side.png deleted file mode 100644 index 5ad4ee65..00000000 Binary files a/ftnoir_tracker_pt/resources/cap_side.png and /dev/null differ diff --git a/ftnoir_tracker_pt/resources/clip_front.png b/ftnoir_tracker_pt/resources/clip_front.png deleted file mode 100644 index 04880138..00000000 Binary files a/ftnoir_tracker_pt/resources/clip_front.png and /dev/null differ diff --git a/ftnoir_tracker_pt/resources/clip_side.png b/ftnoir_tracker_pt/resources/clip_side.png deleted file mode 100644 index 72667ac7..00000000 Binary files a/ftnoir_tracker_pt/resources/clip_side.png and /dev/null differ diff --git a/ftnoir_tracker_pt/resources/icon.png b/ftnoir_tracker_pt/resources/icon.png deleted file mode 100644 index 49af20e4..00000000 Binary files a/ftnoir_tracker_pt/resources/icon.png and /dev/null differ diff --git a/ftnoir_tracker_pt/resources/logo_ir.png b/ftnoir_tracker_pt/resources/logo_ir.png deleted file mode 100644 index 95032a25..00000000 Binary files a/ftnoir_tracker_pt/resources/logo_ir.png and /dev/null differ diff --git a/ftnoir_tracker_pt/timer.cpp b/ftnoir_tracker_pt/timer.cpp deleted file mode 100644 index 07379853..00000000 --- a/ftnoir_tracker_pt/timer.cpp +++ /dev/null @@ -1,65 +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 "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 deleted file mode 100644 index 1c2c3559..00000000 --- a/ftnoir_tracker_pt/timer.h +++ /dev/null @@ -1,44 +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 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 deleted file mode 100644 index 729a0b7f..00000000 --- a/ftnoir_tracker_pt/trans_calib.cpp +++ /dev/null @@ -1,44 +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 "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 deleted file mode 100644 index 6288546a..00000000 --- a/ftnoir_tracker_pt/trans_calib.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 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 deleted file mode 100644 index 2b554aba..00000000 --- a/ftnoir_tracker_pt/video_widget.cpp +++ /dev/null @@ -1,52 +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 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 deleted file mode 100644 index 3051919b..00000000 --- a/ftnoir_tracker_pt/video_widget.h +++ /dev/null @@ -1,42 +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 -#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_pt/videoinput/videoinput.h b/ftnoir_tracker_pt/videoinput/videoinput.h deleted file mode 100644 index 02841418..00000000 --- a/ftnoir_tracker_pt/videoinput/videoinput.h +++ /dev/null @@ -1,385 +0,0 @@ -#ifndef _VIDEOINPUT -#define _VIDEOINPUT - -//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -//THE SOFTWARE. - -////////////////////////////////////////////////////////// -//Written by Theodore Watson - theo.watson@gmail.com // -//Do whatever you want with this code but if you find // -//a bug or make an improvement I would love to know! // -// // -//Warning This code is experimental // -//use at your own risk :) // -////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////// -/* Shoutouts - -Thanks to: - - Dillip Kumar Kara for crossbar code. - Zachary Lieberman for getting me into this stuff - and for being so generous with time and code. - The guys at Potion Design for helping me with VC++ - Josh Fisher for being a serious C++ nerd :) - Golan Levin for helping me debug the strangest - and slowest bug in the world! - - And all the people using this library who send in - bugs, suggestions and improvements who keep me working on - the next version - yeah thanks a lot ;) - -*/ -///////////////////////////////////////////////////////// - - - -#include -#include -#include -#include -#include - -//this is for TryEnterCriticalSection -#ifndef _WIN32_WINNT - # define _WIN32_WINNT 0x400 -#endif -#include - - -//Example Usage -/* - //create a videoInput object - videoInput VI; - - //Prints out a list of available devices and returns num of devices found - int numDevices = VI.listDevices(); - - int device1 = 0; //this could be any deviceID that shows up in listDevices - int device2 = 1; //this could be any deviceID that shows up in listDevices - - //if you want to capture at a different frame rate (default is 30) - //specify it here, you are not guaranteed to get this fps though. - //VI.setIdealFramerate(dev, 60); - - //setup the first device - there are a number of options: - - VI.setupDevice(device1); //setup the first device with the default settings - //VI.setupDevice(device1, VI_COMPOSITE); //or setup device with specific connection type - //VI.setupDevice(device1, 320, 240); //or setup device with specified video size - //VI.setupDevice(device1, 320, 240, VI_COMPOSITE); //or setup device with video size and connection type - - //VI.setFormat(device1, VI_NTSC_M); //if your card doesn't remember what format it should be - //call this with the appropriate format listed above - //NOTE: must be called after setupDevice! - - //optionally setup a second (or third, fourth ...) device - same options as above - VI.setupDevice(device2); - - //As requested width and height can not always be accomodated - //make sure to check the size once the device is setup - - int width = VI.getWidth(device1); - int height = VI.getHeight(device1); - int size = VI.getSize(device1); - - unsigned char * yourBuffer1 = new unsigned char[size]; - unsigned char * yourBuffer2 = new unsigned char[size]; - - //to get the data from the device first check if the data is new - if(VI.isFrameNew(device1)){ - VI.getPixels(device1, yourBuffer1, false, false); //fills pixels as a BGR (for openCV) unsigned char array - no flipping - VI.getPixels(device1, yourBuffer2, true, true); //fills pixels as a RGB (for openGL) unsigned char array - flipping! - } - - //same applies to device2 etc - - //to get a settings dialog for the device - VI.showSettingsWindow(device1); - - - //Shut down devices properly - VI.stopDevice(device1); - VI.stopDevice(device2); -*/ - - -////////////////////////////////////// VARS AND DEFS ////////////////////////////////// - - -//STUFF YOU CAN CHANGE - -//change for verbose debug info -static bool verbose = true; - -//if you need VI to use multi threaded com -//#define VI_COM_MULTI_THREADED - -//STUFF YOU DON'T CHANGE - -//videoInput defines -#define VI_VERSION 0.1995 -#define VI_MAX_CAMERAS 20 -#define VI_NUM_TYPES 18 //DON'T TOUCH -#define VI_NUM_FORMATS 18 //DON'T TOUCH - -//defines for setPhyCon - tuner is not as well supported as composite and s-video -#define VI_COMPOSITE 0 -#define VI_S_VIDEO 1 -#define VI_TUNER 2 -#define VI_USB 3 -#define VI_1394 4 - -//defines for formats -#define VI_NTSC_M 0 -#define VI_PAL_B 1 -#define VI_PAL_D 2 -#define VI_PAL_G 3 -#define VI_PAL_H 4 -#define VI_PAL_I 5 -#define VI_PAL_M 6 -#define VI_PAL_N 7 -#define VI_PAL_NC 8 -#define VI_SECAM_B 9 -#define VI_SECAM_D 10 -#define VI_SECAM_G 11 -#define VI_SECAM_H 12 -#define VI_SECAM_K 13 -#define VI_SECAM_K1 14 -#define VI_SECAM_L 15 -#define VI_NTSC_M_J 16 -#define VI_NTSC_433 17 - - -//allows us to directShow classes here with the includes in the cpp -struct ICaptureGraphBuilder2; -struct IGraphBuilder; -struct IBaseFilter; -struct IAMCrossbar; -struct IMediaControl; -struct ISampleGrabber; -struct IMediaEventEx; -struct IAMStreamConfig; -struct _AMMediaType; -class SampleGrabberCallback; -typedef _AMMediaType AM_MEDIA_TYPE; - -//keeps track of how many instances of VI are being used -//don't touch -static int comInitCount = 0; - - -//////////////////////////////////////// VIDEO DEVICE /////////////////////////////////// - -class videoDevice{ - - - public: - - videoDevice(); - void setSize(int w, int h); - void NukeDownstream(IBaseFilter *pBF); - void destroyGraph(); - ~videoDevice(); - - int videoSize; - int width; - int height; - int tryWidth; - int tryHeight; - - ICaptureGraphBuilder2 *pCaptureGraph; // Capture graph builder object - IGraphBuilder *pGraph; // Graph builder object - IMediaControl *pControl; // Media control object - IBaseFilter *pVideoInputFilter; // Video Capture filter - IBaseFilter *pGrabberF; - IBaseFilter * pDestFilter; - IAMStreamConfig *streamConf; - ISampleGrabber * pGrabber; // Grabs frame - AM_MEDIA_TYPE * pAmMediaType; - - IMediaEventEx * pMediaEvent; - - GUID videoType; - long formatType; - - SampleGrabberCallback * sgCallback; - - bool tryDiffSize; - bool useCrossbar; - bool readyToCapture; - bool sizeSet; - bool setupStarted; - bool specificFormat; - bool autoReconnect; - int nFramesForReconnect; - unsigned long nFramesRunning; - int connection; - int storeConn; - int myID; - long requestedFrameTime; //ie fps - - char nDeviceName[255]; - WCHAR wDeviceName[255]; - - unsigned char * pixels; - char * pBuffer; - -}; - - - - -////////////////////////////////////// VIDEO INPUT ///////////////////////////////////// - - - -class videoInput{ - - public: - videoInput(); - ~videoInput(); - - //turns off console messages - default is to print messages - static void setVerbose(bool _verbose); - - //Functions in rough order they should be used. - static int listDevices(bool silent = false); - - //needs to be called after listDevices - otherwise returns NULL - static char * getDeviceName(int deviceID); - - //choose to use callback based capture - or single threaded - void setUseCallback(bool useCallback); - - //call before setupDevice - //directshow will try and get the closest possible framerate to what is requested - void setIdealFramerate(int deviceID, int idealFramerate); - - //some devices will stop delivering frames after a while - this method gives you the option to try and reconnect - //to a device if videoInput detects that a device has stopped delivering frames. - //you MUST CALL isFrameNew every app loop for this to have any effect - void setAutoReconnectOnFreeze(int deviceNumber, bool doReconnect, int numMissedFramesBeforeReconnect); - - //Choose one of these four to setup your device - bool setupDevice(int deviceID); - bool setupDevice(int deviceID, int w, int h); - - //These two are only for capture cards - //USB and Firewire cameras souldn't specify connection - bool setupDevice(int deviceID, int connection); - bool setupDevice(int deviceID, int w, int h, int connection); - - //If you need to you can set your NTSC/PAL/SECAM - //preference here. if it is available it will be used. - //see #defines above for available formats - eg VI_NTSC_M or VI_PAL_B - //should be called after setupDevice - //can be called multiple times - bool setFormat(int deviceNumber, int format); - - //Tells you when a new frame has arrived - you should call this if you have specified setAutoReconnectOnFreeze to true - bool isFrameNew(int deviceID); - - bool isDeviceSetup(int deviceID); - - //Returns the pixels - flipRedAndBlue toggles RGB/BGR flipping - and you can flip the image too - unsigned char * getPixels(int deviceID, bool flipRedAndBlue = true, bool flipImage = false); - - //Or pass in a buffer for getPixels to fill returns true if successful. - bool getPixels(int id, unsigned char * pixels, bool flipRedAndBlue = true, bool flipImage = false); - - //Launches a pop up settings window - //For some reason in GLUT you have to call it twice each time. - void showSettingsWindow(int deviceID); - - //Manual control over settings thanks..... - //These are experimental for now. - bool setVideoSettingFilter(int deviceID, long Property, long lValue, long Flags = NULL, bool useDefaultValue = false); - bool setVideoSettingFilterPct(int deviceID, long Property, float pctValue, long Flags = NULL); - bool getVideoSettingFilter(int deviceID, long Property, long &min, long &max, long &SteppingDelta, long ¤tValue, long &flags, long &defaultValue); - - bool setVideoSettingCamera(int deviceID, long Property, long lValue, long Flags = NULL, bool useDefaultValue = false); - bool setVideoSettingCameraPct(int deviceID, long Property, float pctValue, long Flags = NULL); - bool getVideoSettingCamera(int deviceID, long Property, long &min, long &max, long &SteppingDelta, long ¤tValue, long &flags, long &defaultValue); - - //bool setVideoSettingCam(int deviceID, long Property, long lValue, long Flags = NULL, bool useDefaultValue = false); - - //get width, height and number of pixels - int getWidth(int deviceID); - int getHeight(int deviceID); - int getSize(int deviceID); - - //completely stops and frees a device - void stopDevice(int deviceID); - - //as above but then sets it up with same settings - bool restartDevice(int deviceID); - - //number of devices available - int devicesFound; - - long propBrightness; - long propContrast; - long propHue; - long propSaturation; - long propSharpness; - long propGamma; - long propColorEnable; - long propWhiteBalance; - long propBacklightCompensation; - long propGain; - - long propPan; - long propTilt; - long propRoll; - long propZoom; - long propExposure; - long propIris; - long propFocus; - - - private: - void setPhyCon(int deviceID, int conn); - void setAttemptCaptureSize(int deviceID, int w, int h); - bool setup(int deviceID); - void processPixels(unsigned char * src, unsigned char * dst, int width, int height, bool bRGB, bool bFlip); - int start(int deviceID, videoDevice * VD); - int getDeviceCount(); - void getMediaSubtypeAsString(GUID type, char * typeAsString); - - HRESULT getDevice(IBaseFilter **pSrcFilter, int deviceID, WCHAR * wDeviceName, char * nDeviceName); - static HRESULT ShowFilterPropertyPages(IBaseFilter *pFilter); - HRESULT SaveGraphFile(IGraphBuilder *pGraph, WCHAR *wszPath); - HRESULT routeCrossbar(ICaptureGraphBuilder2 **ppBuild, IBaseFilter **pVidInFilter, int conType, GUID captureMode); - - //don't touch - static bool comInit(); - static bool comUnInit(); - - int connection; - int callbackSetCount; - bool bCallback; - - GUID CAPTURE_MODE; - - //Extra video subtypes - GUID MEDIASUBTYPE_Y800; - GUID MEDIASUBTYPE_Y8; - GUID MEDIASUBTYPE_GREY; - - videoDevice * VDList[VI_MAX_CAMERAS]; - GUID mediaSubtypes[VI_NUM_TYPES]; - long formatTypes[VI_NUM_FORMATS]; - - static void __cdecl basicThread(void * objPtr); - - static char deviceNames[VI_MAX_CAMERAS][255]; - -}; - - #endif diff --git a/ftnoir_tracker_pt/videoinput/videoinput_vc8.lib b/ftnoir_tracker_pt/videoinput/videoinput_vc8.lib deleted file mode 100644 index 15ca9cf3..00000000 Binary files a/ftnoir_tracker_pt/videoinput/videoinput_vc8.lib and /dev/null differ diff --git a/ftnoir_tracker_pt/videoinput/videoinput_vc9.lib b/ftnoir_tracker_pt/videoinput/videoinput_vc9.lib deleted file mode 100644 index 32637cc9..00000000 Binary files a/ftnoir_tracker_pt/videoinput/videoinput_vc9.lib and /dev/null differ -- 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 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 e481697ea6e156e456f3d51ba7c816ad4a908792 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 15 Sep 2013 16:00:25 +0200 Subject: Fix mingw-w64 cross-compile from Linux Case-sensitivity and MSVC-isms bite again. --- CMakeLists.txt | 23 ++- FTNoIR_Tracker_PT/camera.cpp | 7 +- ftnoir_protocol_sc/ftnoir_protocol_sc.h | 6 +- ftnoir_protocol_sc/ftnoir_protocol_sc_dll.cpp | 2 +- ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.h | 31 +++- ftnoir_tracker_rift/ftnoir_rift_clientcontrols.ui | 170 ++++++++++------------ ftnoir_tracker_rift/ftnoir_tracker_rift.cpp | 2 +- 7 files changed, 133 insertions(+), 108 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6c5bed0f..ba4857a2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -342,10 +342,10 @@ endif() if(WIN32 AND SDK_VJOY) include_directories(${SDK_VJOY}) add_library(opentrack-proto-vjoy SHARED ${opentrack-proto-vjoy-c} ${opentrack-proto-vjoy-moc} ${opentrack-proto-vjoy-uih} ${opentrack-proto-vjoy-rcc}) - target_link_libraries(opentrack-proto-vjoy ${MY_QT_LIBS} "${SDK_VJOY}/vjoy.lib") + target_link_libraries(opentrack-proto-vjoy ${MY_QT_LIBS} "${SDK_VJOY}/VJoy.dll") if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) SET_TARGET_PROPERTIES(opentrack-proto-vjoy - PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt") + PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt -Wl,--enable-stdcall-fixup") endif() endif() @@ -362,7 +362,7 @@ endif() add_library(opentrack-proto-simconnect SHARED ${opentrack-proto-simconnect-c} ${opentrack-proto-simconnect-moc} ${opentrack-proto-simconnect-uih} ${opentrack-proto-simconnect-rcc}) target_link_libraries(opentrack-proto-simconnect ${MY_QT_LIBS}) include_directories("${SDK_SIMCONNECT}/inc") - target_link_libraries(opentrack-proto-simconnect "${SDK_SIMCONNECT}/lib/simconnect.lib") + target_link_libraries(opentrack-proto-simconnect "${SDK_SIMCONNECT}/lib/SimConnect.lib") endif() add_library(opentrack-proto-freetrack SHARED ${opentrack-proto-freetrack-c} ${opentrack-proto-freetrack-moc} ${opentrack-proto-freetrack-uih} ${opentrack-proto-freetrack-rcc}) @@ -458,16 +458,19 @@ endif() endif() if(SDK_RIFT) - include_directories("${SDK_RIFT}/include") + include_directories("${SDK_RIFT}/Include") include_directories("${SDK_RIFT}/Src") add_library(opentrack-tracker-rift SHARED ${opentrack-tracker-rift-c} ${opentrack-tracker-rift-moc} ${opentrack-tracker-rift-uih} ${opentrack-tracker-rift-rcc}) target_link_libraries(opentrack-tracker-rift ${MY_QT_LIBS}) if(WIN32) - target_link_libraries(opentrack-tracker-rift "${SDK_RIFT}/lib/win32/libovr.lib" winmm.lib) + target_link_libraries(opentrack-tracker-rift "${SDK_RIFT}/Lib/Win32/libovr.lib" winmm.lib) endif() if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) SET_TARGET_PROPERTIES(opentrack-tracker-rift - PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt") + PROPERTIES + LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt" + COMPILE_FLAGS "-fno-strict-aliasing" + ) endif() endif() @@ -477,7 +480,13 @@ endif() add_library(opentrack-tracker-hydra SHARED ${opentrack-tracker-hydra-c} ${opentrack-tracker-hydra-moc} ${opentrack-tracker-hydra-uih} ${opentrack-tracker-hydra-rcc}) target_link_libraries(opentrack-tracker-hydra ${MY_QT_LIBS}) if(WIN32) - target_link_libraries(opentrack-tracker-hydra "${SDK_HYDRA}/lib/win32/release_static/sixense_s.lib" "${SDK_HYDRA}/lib/win32/release_static/sixense_utils_s.lib") + if(CMAKE_COMPILER_IS_GNUCXX) + target_link_libraries(opentrack-tracker-hydra "${SDK_HYDRA}/lib/win32/release_dll/sixense.lib" "${SDK_HYDRA}/lib/win32/release_dll/sixense_utils.lib") + install(FILES "${SDK_HYDRA}/bin/win32/release_dll/sixense.dll" "${SDK_HYDRA}/bin/win32/release_dll/sixense_utils.dll" + DESTINATION .) + else() + target_link_libraries(opentrack-tracker-hydra "${SDK_HYDRA}/lib/win32/release_static/sixense_s.lib" "${SDK_HYDRA}/lib/win32/release_static/sixense_utils_s.lib") + endif() endif() if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) SET_TARGET_PROPERTIES(opentrack-tracker-hydra diff --git a/FTNoIR_Tracker_PT/camera.cpp b/FTNoIR_Tracker_PT/camera.cpp index a372373d..14f7a6be 100644 --- a/FTNoIR_Tracker_PT/camera.cpp +++ b/FTNoIR_Tracker_PT/camera.cpp @@ -14,6 +14,11 @@ using namespace cv; #include #endif +#if defined(OPENTRACK_API) && defined(_WIN32) +#include +#include +#endif + #ifdef OPENTRACK_API void get_camera_device_names(std::vector& device_names) { # if defined(_WIN32) @@ -23,7 +28,7 @@ void get_camera_device_names(std::vector& device_names) { hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER, IID_ICreateDevEnum, (void **)&pSysDevEnum); if (FAILED(hr)) { - return ret; + return; } // Obtain a class enumerator for the video compressor category. IEnumMoniker *pEnumCat = NULL; diff --git a/ftnoir_protocol_sc/ftnoir_protocol_sc.h b/ftnoir_protocol_sc/ftnoir_protocol_sc.h index b3596722..8fcf7c1f 100644 --- a/ftnoir_protocol_sc/ftnoir_protocol_sc.h +++ b/ftnoir_protocol_sc/ftnoir_protocol_sc.h @@ -37,11 +37,11 @@ #define SIMCONNECT_H_NOMANIFEST #define _WIN32_WINNT 0x0502 -#include +#include #include -#include <..\ftnoir_protocol_base\ftnoir_protocol_base.h> -#include +#include +#include #include #include #include diff --git a/ftnoir_protocol_sc/ftnoir_protocol_sc_dll.cpp b/ftnoir_protocol_sc/ftnoir_protocol_sc_dll.cpp index fce8753a..59a921b8 100644 --- a/ftnoir_protocol_sc/ftnoir_protocol_sc_dll.cpp +++ b/ftnoir_protocol_sc/ftnoir_protocol_sc_dll.cpp @@ -22,7 +22,7 @@ * with this program; if not, see . * * * ********************************************************************************/ -#include "ftnoir_protocol_SC.h" +#include "ftnoir_protocol_sc.h" #include #include "facetracknoir/global-settings.h" diff --git a/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.h b/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.h index 5c260d2e..30d89572 100644 --- a/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.h +++ b/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.h @@ -28,8 +28,8 @@ #pragma once #include "ftnoir_protocol_base/ftnoir_protocol_base.h" #include "ui_ftnoir_vjoy_controls.h" -#include -#include +#include + #include #include #include @@ -92,3 +92,30 @@ public: void getIcon(QIcon *icon) { *icon = QIcon(":/images/vjoy.png"); } }; + +#define VJOY_AXIS_MIN -32768 +#define VJOY_AXIS_NIL 0 +#define VJOY_AXIS_MAX 32767 + +#include + +typedef struct _JOYSTICK_STATE +{ + UCHAR ReportId; // Report Id + SHORT XAxis; // X Axis + SHORT YAxis; // Y Axis + SHORT ZAxis; // Z Axis + SHORT XRotation; // X Rotation + SHORT YRotation; // Y Rotation + SHORT ZRotation; // Z Rotation + SHORT Slider; // Slider + SHORT Dial; // Dial + USHORT POV; // POV + UINT32 Buttons; // 32 Buttons +} JOYSTICK_STATE, * PJOYSTICK_STATE; + +#include + +extern "C" BOOL __stdcall VJoy_Initialize(PCHAR name, PCHAR serial); +extern "C" VOID __stdcall VJoy_Shutdown(); +extern "C" BOOL __stdcall VJoy_UpdateJoyState(int id, PJOYSTICK_STATE pJoyState); diff --git a/ftnoir_tracker_rift/ftnoir_rift_clientcontrols.ui b/ftnoir_tracker_rift/ftnoir_rift_clientcontrols.ui index eaf5b9d6..612c61f1 100644 --- a/ftnoir_tracker_rift/ftnoir_rift_clientcontrols.ui +++ b/ftnoir_tracker_rift/ftnoir_rift_clientcontrols.ui @@ -1,13 +1,16 @@ UIRiftControls - + + + Qt::ApplicationModal + 0 0 411 - 142 + 145 @@ -45,97 +48,78 @@ - - - - - - - Pitch: - - - - - - - - - 20 - 16777215 - - - - Qt::LeftToRight - - - - - - - - - - - - - - Yaw: - - - - - - - - - - 20 - 16777215 - - - - Qt::LeftToRight - - - - - - - - - - - - - Roll: - - - - - - - - - 20 - 16777215 - - - - Qt::LeftToRight - - - - - - - - - - - - - - + + + + Pitch: + + + + + + + + 20 + 16777215 + + + + Qt::LeftToRight + + + + + + + + + + + + + Yaw: + + + + + + + + 20 + 16777215 + + + + Qt::LeftToRight + + + + + + + + + + Roll: + + + + + + + + 20 + 16777215 + + + + Qt::LeftToRight + + + + + + diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp b/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp index f5e1f5fa..0c3984ac 100644 --- a/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp +++ b/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp @@ -55,7 +55,7 @@ void Rift_Tracker::StartTracker(QFrame* videoFrame) // System::Init(Log::ConfigureDefaultLog(LogMask_All)); pManager = *DeviceManager::Create(); - DeviceEnumerator& enumerator = pManager->EnumerateDevices(); + DeviceEnumerator enumerator = pManager->EnumerateDevices(); if (enumerator.IsAvailable()) { pHMD = *enumerator.CreateDevice(); -- cgit v1.2.3 From 747dcf7cfbc2498312bdcdbd89eb741493dfb44b Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 15 Sep 2013 16:02:20 +0200 Subject: Make every tracker/protocol/filter dialog modal This is since changing the tracker/protocol/filter from a combobox will cause a use-after-free and a nasty crash. --- .../ftnoir_accela_filtercontrols.ui | 2 +- ftnoir_filter_ewma2/ftnoir_ewma_filtercontrols.ui | 8 +- ftnoir_protocol_fg/ftnoir_fgcontrols.ui | 7 +- ftnoir_protocol_fsuipc/ftnoir_fsuipccontrols.ui | 5 +- ftnoir_protocol_ft/ftnoir_ftcontrols.ui | 6 + ftnoir_protocol_ftn/ftnoir_ftncontrols.ui | 7 +- ftnoir_protocol_mouse/ftnoir_mousecontrols.ui | 5 +- ftnoir_protocol_sc/ftnoir_sccontrols.ui | 3 + ftnoir_protocol_vjoy/ftnoir_vjoy_controls.ui | 5 +- ftnoir_protocol_wine/ftnoir_winecontrols.ui | 3 + ftnoir_tracker_aruco/aruco-trackercontrols.ui | 9 +- ftnoir_tracker_ht/ht-trackercontrols.ui | 2 +- .../ftnoir_hydra_clientcontrols.ui | 353 +++++++++------------ ftnoir_tracker_sm/ftnoir_sm_controls.ui | 7 +- ftnoir_tracker_udp/ftnoir_ftnclientcontrols.ui | 7 +- 15 files changed, 207 insertions(+), 222 deletions(-) diff --git a/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui b/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui index 305b1b1d..24b296ea 100644 --- a/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui +++ b/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui @@ -3,7 +3,7 @@ AccelaUICFilterControls - Qt::NonModal + Qt::ApplicationModal diff --git a/ftnoir_filter_ewma2/ftnoir_ewma_filtercontrols.ui b/ftnoir_filter_ewma2/ftnoir_ewma_filtercontrols.ui index 0f31bcd3..8a0e485a 100644 --- a/ftnoir_filter_ewma2/ftnoir_ewma_filtercontrols.ui +++ b/ftnoir_filter_ewma2/ftnoir_ewma_filtercontrols.ui @@ -2,11 +2,14 @@ UICFilterControls + + Qt::ApplicationModal + 0 0 - 371 + 374 380 @@ -21,6 +24,9 @@ + + images/facetracknoir.png + images/facetracknoir.png diff --git a/ftnoir_protocol_fg/ftnoir_fgcontrols.ui b/ftnoir_protocol_fg/ftnoir_fgcontrols.ui index 116f830b..51b5693c 100644 --- a/ftnoir_protocol_fg/ftnoir_fgcontrols.ui +++ b/ftnoir_protocol_fg/ftnoir_fgcontrols.ui @@ -2,12 +2,15 @@ UICFGControls + + Qt::ApplicationModal + 0 0 - 411 - 194 + 486 + 210 diff --git a/ftnoir_protocol_fsuipc/ftnoir_fsuipccontrols.ui b/ftnoir_protocol_fsuipc/ftnoir_fsuipccontrols.ui index d02297f3..9ccfa119 100644 --- a/ftnoir_protocol_fsuipc/ftnoir_fsuipccontrols.ui +++ b/ftnoir_protocol_fsuipc/ftnoir_fsuipccontrols.ui @@ -2,12 +2,15 @@ UICFSUIPCControls + + Qt::ApplicationModal + 0 0 541 - 127 + 139 diff --git a/ftnoir_protocol_ft/ftnoir_ftcontrols.ui b/ftnoir_protocol_ft/ftnoir_ftcontrols.ui index fc5abbcf..a2216314 100644 --- a/ftnoir_protocol_ft/ftnoir_ftcontrols.ui +++ b/ftnoir_protocol_ft/ftnoir_ftcontrols.ui @@ -2,6 +2,12 @@ UICFTControls + + Qt::ApplicationModal + + + true + 0 diff --git a/ftnoir_protocol_ftn/ftnoir_ftncontrols.ui b/ftnoir_protocol_ftn/ftnoir_ftncontrols.ui index d8efec61..15bc5531 100644 --- a/ftnoir_protocol_ftn/ftnoir_ftncontrols.ui +++ b/ftnoir_protocol_ftn/ftnoir_ftncontrols.ui @@ -2,12 +2,15 @@ UICFTNControls + + Qt::ApplicationModal + 0 0 411 - 156 + 162 @@ -15,7 +18,7 @@ - images/FaceTrackNoIR.pngimages/facetracknoir.png + images/FaceTrackNoIR.pngimages/FaceTrackNoIR.png Qt::LeftToRight diff --git a/ftnoir_protocol_mouse/ftnoir_mousecontrols.ui b/ftnoir_protocol_mouse/ftnoir_mousecontrols.ui index 8794e9cd..ee15ded2 100644 --- a/ftnoir_protocol_mouse/ftnoir_mousecontrols.ui +++ b/ftnoir_protocol_mouse/ftnoir_mousecontrols.ui @@ -2,12 +2,15 @@ UICMOUSEControls + + Qt::ApplicationModal + 0 0 250 - 99 + 112 diff --git a/ftnoir_protocol_sc/ftnoir_sccontrols.ui b/ftnoir_protocol_sc/ftnoir_sccontrols.ui index a0cbf393..be42072c 100644 --- a/ftnoir_protocol_sc/ftnoir_sccontrols.ui +++ b/ftnoir_protocol_sc/ftnoir_sccontrols.ui @@ -2,6 +2,9 @@ UICSCControls + + Qt::ApplicationModal + 0 diff --git a/ftnoir_protocol_vjoy/ftnoir_vjoy_controls.ui b/ftnoir_protocol_vjoy/ftnoir_vjoy_controls.ui index 1a244410..94b229fb 100644 --- a/ftnoir_protocol_vjoy/ftnoir_vjoy_controls.ui +++ b/ftnoir_protocol_vjoy/ftnoir_vjoy_controls.ui @@ -2,12 +2,15 @@ UICVJoyControls + + Qt::ApplicationModal + 0 0 228 - 64 + 69 diff --git a/ftnoir_protocol_wine/ftnoir_winecontrols.ui b/ftnoir_protocol_wine/ftnoir_winecontrols.ui index 71e99d88..c5e19f2c 100644 --- a/ftnoir_protocol_wine/ftnoir_winecontrols.ui +++ b/ftnoir_protocol_wine/ftnoir_winecontrols.ui @@ -2,6 +2,9 @@ UICFTControls + + Qt::ApplicationModal + 0 diff --git a/ftnoir_tracker_aruco/aruco-trackercontrols.ui b/ftnoir_tracker_aruco/aruco-trackercontrols.ui index 3ad9fa40..4fe97e51 100644 --- a/ftnoir_tracker_aruco/aruco-trackercontrols.ui +++ b/ftnoir_tracker_aruco/aruco-trackercontrols.ui @@ -3,7 +3,7 @@ Form - Qt::NonModal + Qt::ApplicationModal @@ -464,15 +464,18 @@ Rafael Muñoz Salinas <rmsalinas@uco.es> - 370 + 327 200 - 181 + 255 20 https://github.com/rmsalinas/aruco + + Qt::AlignCenter + true diff --git a/ftnoir_tracker_ht/ht-trackercontrols.ui b/ftnoir_tracker_ht/ht-trackercontrols.ui index fbe7a41a..6153637a 100644 --- a/ftnoir_tracker_ht/ht-trackercontrols.ui +++ b/ftnoir_tracker_ht/ht-trackercontrols.ui @@ -3,7 +3,7 @@ Form - Qt::NonModal + Qt::ApplicationModal diff --git a/ftnoir_tracker_hydra/ftnoir_hydra_clientcontrols.ui b/ftnoir_tracker_hydra/ftnoir_hydra_clientcontrols.ui index 0cee05f0..94d22cb5 100644 --- a/ftnoir_tracker_hydra/ftnoir_hydra_clientcontrols.ui +++ b/ftnoir_tracker_hydra/ftnoir_hydra_clientcontrols.ui @@ -2,12 +2,15 @@ UIHydraControls + + Qt::ApplicationModal + 0 0 411 - 142 + 145 @@ -45,210 +48,150 @@ - - - - - - - - - - - - Pitch: - - - - - - - - - 20 - 16777215 - - - - Qt::LeftToRight - - - - - - - - - - - - - - Yaw: - - - - - - - - - - 20 - 16777215 - - - - Qt::LeftToRight - - - - - - - - - - - - - Roll: - - - - - - - - - 20 - 16777215 - - - - Qt::LeftToRight - - - - - - - - - - - - - - - - - - - - - - - - - - - - - X: - - - - - - - - - 20 - 16777215 - - - - Qt::LeftToRight - - - - - - - - - - - - - - Y: - - - - - - - - - - 20 - 16777215 - - - - Qt::LeftToRight - - - - - - - - - - - - - Z: - - - - - - - - - 20 - 16777215 - - - - Qt::LeftToRight - - - - - - - - - - - - - - - - - - - - - - - + + + + Pitch: + + + + + + + + 20 + 16777215 + + + + Qt::LeftToRight + + + + + + + + + + + + + Yaw: + + + + + + + + 20 + 16777215 + + + + Qt::LeftToRight + + + + + + + + + + Roll: + + + + + + + + 20 + 16777215 + + + + Qt::LeftToRight + + + + + + + + + + X: + + + + + + + + 20 + 16777215 + + + + Qt::LeftToRight + + + + + + + + + + + + + Y: + + + + + + + + 20 + 16777215 + + + + Qt::LeftToRight + + + + + + + + + + Z: + + + + + + + + 20 + 16777215 + + + + Qt::LeftToRight + + + + + + diff --git a/ftnoir_tracker_sm/ftnoir_sm_controls.ui b/ftnoir_tracker_sm/ftnoir_sm_controls.ui index 06ebc9ca..7d69059b 100644 --- a/ftnoir_tracker_sm/ftnoir_sm_controls.ui +++ b/ftnoir_tracker_sm/ftnoir_sm_controls.ui @@ -2,11 +2,14 @@ UICSMClientControls + + Qt::ApplicationModal + 0 0 - 388 + 399 313 @@ -109,7 +112,7 @@ 10 20 55 - 110 + 122 diff --git a/ftnoir_tracker_udp/ftnoir_ftnclientcontrols.ui b/ftnoir_tracker_udp/ftnoir_ftnclientcontrols.ui index 5883e317..842ccb81 100644 --- a/ftnoir_tracker_udp/ftnoir_ftnclientcontrols.ui +++ b/ftnoir_tracker_udp/ftnoir_ftnclientcontrols.ui @@ -2,12 +2,15 @@ UICFTNClientControls + + Qt::ApplicationModal + 0 0 411 - 210 + 222 @@ -75,7 +78,7 @@ 10 20 143 - 60 + 64 -- cgit v1.2.3 From 0965a0665e232425373b942291716f968191f04f Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 15 Sep 2013 16:02:46 +0200 Subject: Where did that come from? --- ftnoir_protocol_fg/ftnoir_protocol_fg.cpp.autosave | 222 --------------------- 1 file changed, 222 deletions(-) delete mode 100644 ftnoir_protocol_fg/ftnoir_protocol_fg.cpp.autosave diff --git a/ftnoir_protocol_fg/ftnoir_protocol_fg.cpp.autosave b/ftnoir_protocol_fg/ftnoir_protocol_fg.cpp.autosave deleted file mode 100644 index 0b67b0d2..00000000 --- a/ftnoir_protocol_fg/ftnoir_protocol_fg.cpp.autosave +++ /dev/null @@ -1,222 +0,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 . * -* * -* 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->writeD atagram((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; -} -- cgit v1.2.3 From e5644bff6531717503c14b209041c1a7524e9998 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 15 Sep 2013 19:10:40 +0200 Subject: Fix Rift build on mingw-w64 --- CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ba4857a2..67dcd1ee 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -462,8 +462,12 @@ endif() include_directories("${SDK_RIFT}/Src") add_library(opentrack-tracker-rift SHARED ${opentrack-tracker-rift-c} ${opentrack-tracker-rift-moc} ${opentrack-tracker-rift-uih} ${opentrack-tracker-rift-rcc}) target_link_libraries(opentrack-tracker-rift ${MY_QT_LIBS}) - if(WIN32) + if(MSVC) target_link_libraries(opentrack-tracker-rift "${SDK_RIFT}/Lib/Win32/libovr.lib" winmm.lib) + else(WIN32) + target_link_libraries(opentrack-tracker-rift "${SDK_RIFT}/LibOVR.a" winmm.lib setupapi.lib) + else() + target_link_libraries(opentrack-tracker-rift "${SDK_RIFT}/LibOVR.a") endif() if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) SET_TARGET_PROPERTIES(opentrack-tracker-rift -- 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(-) 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 d09b20e237345a9fd7eac2da91acf72622e2ce0a Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 16 Sep 2013 20:56:45 +0200 Subject: VJoy: correct visibility of getGameName() --- CMakeLists.txt | 21 +++++++++++++++++++++ ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.h | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 67dcd1ee..a0207df4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,6 +9,9 @@ SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}") add_definitions(-DOPENTRACK_API) +if(UNIX) + set(SDK_ENABLE_LIBEVDEV FALSE CACHE BOOL "libevdev virtual joystick protocol support (probably Linux only)") +endif() if(WIN32) SET(SDK_FACEAPI_ONLY FALSE CACHE BOOL "FaceAPI only (MSVC 2005)") endif() @@ -200,6 +203,14 @@ if(NOT SDK_FACEAPI_ONLY) QT4_WRAP_UI(opentrack-proto-vjoy-uih ${opentrack-proto-vjoy-ui}) QT4_ADD_RESOURCES(opentrack-proto-vjoy-rcc ${opentrack-proto-vjoy-rc}) + file(GLOB opentrack-proto-libevdev-c "ftnoir_protocol_libevdev/*.cpp") + file(GLOB opentrack-proto-libevdev-h "ftnoir_protocol_libevdev/*.h") + QT4_WRAP_CPP(opentrack-proto-libevdev-moc ${opentrack-proto-libevdev-h}) + file(GLOB opentrack-proto-libevdev-ui "ftnoir_protocol_libevdev/*.ui") + file(GLOB opentrack-proto-libevdev-rc "ftnoir_protocol_libevdev/*.qrc") + QT4_WRAP_UI(opentrack-proto-libevdev-uih ${opentrack-proto-libevdev-ui}) + QT4_ADD_RESOURCES(opentrack-proto-libevdev-rcc ${opentrack-proto-libevdev-rc}) + # trackers file(GLOB opentrack-tracker-ht-c "ftnoir_tracker_ht/*.cpp") @@ -349,6 +360,16 @@ endif() endif() endif() + if(UNIX AND SDK_ENABLE_LIBEVDEV) + add_library(opentrack-proto-libevdev SHARED ${opentrack-proto-libevdev-c} ${opentrack-proto-libevdev-moc} ${opentrack-proto-libevdev-uih} ${opentrack-proto-libevdev-rcc}) + target_link_libraries(opentrack-proto-libevdev ${MY_QT_LIBS} evdev) + if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) + SET_TARGET_PROPERTIES(opentrack-proto-libevdev + PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt") + endif() + install(TARGETS opentrack-proto-libevdev DESTINATION .) + endif() + if(WIN32) if(SDK_FSUIPC) add_library(opentrack-proto-fsuipc SHARED ${opentrack-proto-fsuipc-c} ${opentrack-proto-fsuipc-moc} ${opentrack-proto-fsuipc-uih} ${opentrack-proto-fsuipc-rcc}) diff --git a/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.h b/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.h index 30d89572..fe8b67fa 100644 --- a/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.h +++ b/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.h @@ -48,10 +48,10 @@ public: return true; } void sendHeadposeToGame( double *headpose, double *rawheadpose ); -private: QString getGameName() { return "Virtual joystick"; } +private: }; // Widget that has controls for FTNoIR protocol client-settings. -- cgit v1.2.3 From ad37ec007baf1170657ba51baea44688c52290e0 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 16 Sep 2013 22:16:21 +0200 Subject: initial libevdev impl --- .../ftnoir_libevdev_controls.ui | 111 +++++++++++++++++++++ .../ftnoir_protocol_libevdev.cpp | 77 ++++++++++++++ .../ftnoir_protocol_libevdev.h | 72 +++++++++++++ .../ftnoir_protocol_libevdev_dialog.cpp | 41 ++++++++ .../ftnoir_protocol_libevdev_dll.cpp | 16 +++ ftnoir_protocol_libevdev/libevdev-protocol.qrc | 5 + 6 files changed, 322 insertions(+) create mode 100644 ftnoir_protocol_libevdev/ftnoir_libevdev_controls.ui create mode 100644 ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.cpp create mode 100644 ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.h create mode 100644 ftnoir_protocol_libevdev/ftnoir_protocol_libevdev_dialog.cpp create mode 100644 ftnoir_protocol_libevdev/ftnoir_protocol_libevdev_dll.cpp create mode 100644 ftnoir_protocol_libevdev/libevdev-protocol.qrc diff --git a/ftnoir_protocol_libevdev/ftnoir_libevdev_controls.ui b/ftnoir_protocol_libevdev/ftnoir_libevdev_controls.ui new file mode 100644 index 00000000..f9a55547 --- /dev/null +++ b/ftnoir_protocol_libevdev/ftnoir_libevdev_controls.ui @@ -0,0 +1,111 @@ + + + UICVJoyControls + + + Qt::ApplicationModal + + + + 0 + 0 + 228 + 69 + + + + VJoy + + + + :/images/vjoy.png:/images/vjoy.png + + + Qt::LeftToRight + + + false + + + + + + Make sure rw for /dev/input/uinput! + + + + + + + + + QLayout::SetDefaultConstraint + + + + + + 0 + 0 + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + OK + + + + + + + + 0 + 0 + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + Cancel + + + + + + + + + + + btnOK + btnCancel + + + + + startEngineClicked() + stopEngineClicked() + cameraSettingsClicked() + + diff --git a/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.cpp b/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.cpp new file mode 100644 index 00000000..6f34d20b --- /dev/null +++ b/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.cpp @@ -0,0 +1,77 @@ +#include "ftnoir_protocol_libevdev.h" +#include "facetracknoir/global-settings.h" +//#include "ftnoir_tracker_base/ftnoir_tracker_types.h" + +#define CHECK_LIBEVDEV(expr) if ((expr) != 0) goto error; + +FTNoIR_Protocol::FTNoIR_Protocol() : dev(NULL), uidev(NULL) +{ + int error; + + dev = libevdev_new(); + + if (!dev) + goto error; + + libevdev_set_name(dev, "opentrack headpose"); + + struct input_absinfo absinfo; + + absinfo.minimum = -ABS_MAX; + absinfo.maximum = ABS_MAX; + absinfo.resolution= 1; /* units per radian? let's go shopping */ + absinfo.value = 0; + absinfo.fuzz = 1; /* no filtering in evdev subsystem, we do our own */ + + CHECK_LIBEVDEV(libevdev_enable_event_type(dev, EV_ABS)) + CHECK_LIBEVDEV(libevdev_enable_event_code(dev, EV_ABS, ABS_X, &absinfo)) + CHECK_LIBEVDEV(libevdev_enable_event_code(dev, EV_ABS, ABS_Y, &absinfo)) + CHECK_LIBEVDEV(libevdev_enable_event_code(dev, EV_ABS, ABS_Z, &absinfo)) + CHECK_LIBEVDEV(libevdev_enable_event_code(dev, EV_ABS, ABS_RX, &absinfo)) + CHECK_LIBEVDEV(libevdev_enable_event_code(dev, EV_ABS, ABS_RY, &absinfo)) + CHECK_LIBEVDEV(libevdev_enable_event_code(dev, EV_ABS, ABS_RZ, &absinfo)) + + CHECK_LIBEVDEV(error = libevdev_uinput_create_from_device(dev, LIBEVDEV_UINPUT_OPEN_MANAGED, &uidev)) + + return; +error: + if (uidev) + libevdev_uinput_destroy(uidev); + if (dev) + libevdev_free(dev); + uidev = NULL; + dev = NULL; +} + +FTNoIR_Protocol::~FTNoIR_Protocol() +{ + if (uidev) + libevdev_uinput_destroy(uidev); + if (dev) + libevdev_free(dev); +} + +void FTNoIR_Protocol::sendHeadposeToGame( double *headpose, double *rawheadpose ) { + static const int axes[] = { + /* translation goes first */ + ABS_X, ABS_Y, ABS_Z, ABS_RX, ABS_RY, ABS_RZ + }; + static const int ranges[] = { + 2, + 2, + 2, + 2, /* | pitch | only goes to 90 */ + 1, + 2 + }; + + const int max_euler = 90; + + for (int i = 0; i < 6; i++) + (void) libevdev_uinput_write_event(uidev, EV_ABS, axes[i], ranges[i] * headpose[i] * max_euler / ABS_MAX); +} + +extern "C" FTNOIR_PROTOCOL_BASE_EXPORT IProtocol* CALLING_CONVENTION GetConstructor() +{ + return new FTNoIR_Protocol; +} diff --git a/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.h b/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.h new file mode 100644 index 00000000..b71738f1 --- /dev/null +++ b/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.h @@ -0,0 +1,72 @@ +/* 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 "ftnoir_protocol_base/ftnoir_protocol_base.h" +#include "ui_ftnoir_libevdev_controls.h" + +#include +#include +#include "facetracknoir/global-settings.h" + +#include +#include + +class FTNoIR_Protocol : public IProtocol +{ +public: + FTNoIR_Protocol(); + ~FTNoIR_Protocol(); + bool checkServerInstallationOK() { + return dev != NULL; + } + void sendHeadposeToGame( double *headpose, double *rawheadpose ); + QString getGameName() { + return "Virtual joystick for Linux"; + } +private: + struct libevdev* dev; + struct libevdev_uinput* uidev; +}; + +// Widget that has controls for FTNoIR protocol client-settings. +class LibevdevControls: public QWidget, public IProtocolDialog +{ + Q_OBJECT +public: + + explicit LibevdevControls(); + virtual ~LibevdevControls(); + void showEvent ( QShowEvent *) {} + + void Initialize(QWidget *); + void registerProtocol(IProtocol *l) {} + void unRegisterProtocol() {} + +private: + Ui::UICVJoyControls ui; + void save(); + +private slots: + void doOK(); + void doCancel(); +}; + +//******************************************************************************************************* +// 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("libevdev"); } + void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("libevdev"); } + void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("libevdev"); } + + void getIcon(QIcon *icon) { *icon = QIcon(":/images/linux.png"); } +}; diff --git a/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev_dialog.cpp b/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev_dialog.cpp new file mode 100644 index 00000000..6665a3d2 --- /dev/null +++ b/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev_dialog.cpp @@ -0,0 +1,41 @@ +#include "ftnoir_protocol_libevdev.h" +#include "facetracknoir/global-settings.h" + +LibevdevControls::LibevdevControls() : QWidget() +{ + ui.setupUi( this ); + connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); + connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); +} + +LibevdevControls::~LibevdevControls() { +} + +// +// Initialize tracker-client-dialog +// +void LibevdevControls::Initialize(QWidget *parent) { + + QPoint offsetpos(100, 100); + if (parent) { + this->move(parent->pos() + offsetpos); + } + show(); +} + +void LibevdevControls::doOK() { + save(); + this->close(); +} + +void LibevdevControls::doCancel() { + this->close(); +} + +void LibevdevControls::save() { +} + +extern "C" FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDialog* CALLING_CONVENTION GetDialog( ) +{ + return new LibevdevControls; +} diff --git a/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev_dll.cpp b/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev_dll.cpp new file mode 100644 index 00000000..79a22d5e --- /dev/null +++ b/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev_dll.cpp @@ -0,0 +1,16 @@ +#include "ftnoir_protocol_libevdev.h" +#include +#include "facetracknoir/global-settings.h" + +FTNoIR_ProtocolDll::FTNoIR_ProtocolDll() { +} + +FTNoIR_ProtocolDll::~FTNoIR_ProtocolDll() +{ + +} + +extern "C" FTNOIR_PROTOCOL_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata() +{ + return new FTNoIR_ProtocolDll; +} diff --git a/ftnoir_protocol_libevdev/libevdev-protocol.qrc b/ftnoir_protocol_libevdev/libevdev-protocol.qrc new file mode 100644 index 00000000..70bb415f --- /dev/null +++ b/ftnoir_protocol_libevdev/libevdev-protocol.qrc @@ -0,0 +1,5 @@ + + + images/linux.png + + -- cgit v1.2.3 From 40f95d58324609d74b1e3a7ff81d4ef3b2388550 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 16 Sep 2013 23:54:16 +0200 Subject: proto-libevdev: first version. NEEDS UDEV RULE --- .../ftnoir_protocol_libevdev.cpp | 57 +++++++++++++++------- .../ftnoir_protocol_libevdev.h | 6 ++- 2 files changed, 43 insertions(+), 20 deletions(-) diff --git a/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.cpp b/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.cpp index 6f34d20b..74986299 100644 --- a/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.cpp +++ b/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.cpp @@ -1,37 +1,52 @@ #include "ftnoir_protocol_libevdev.h" #include "facetracknoir/global-settings.h" //#include "ftnoir_tracker_base/ftnoir_tracker_types.h" +#include +#include -#define CHECK_LIBEVDEV(expr) if ((expr) != 0) goto error; +#include +#include + +#define CHECK_LIBEVDEV(expr) if (error = (expr) != 0) goto error; + +static const int max_input = 8192; +static const int mid_input = 4096; +static const int min_input = 0; + +#define HT_PI 3.1415926535 FTNoIR_Protocol::FTNoIR_Protocol() : dev(NULL), uidev(NULL) { - int error; + int error = 0; dev = libevdev_new(); if (!dev) goto error; + CHECK_LIBEVDEV(libevdev_enable_property(dev, INPUT_PROP_BUTTONPAD)); + libevdev_set_name(dev, "opentrack headpose"); struct input_absinfo absinfo; - absinfo.minimum = -ABS_MAX; - absinfo.maximum = ABS_MAX; - absinfo.resolution= 1; /* units per radian? let's go shopping */ - absinfo.value = 0; - absinfo.fuzz = 1; /* no filtering in evdev subsystem, we do our own */ + absinfo.minimum = min_input; + absinfo.maximum = max_input; + absinfo.resolution = 1; + absinfo.value = mid_input; + absinfo.flat = 8192 / 180; + absinfo.fuzz = 1; + + CHECK_LIBEVDEV(libevdev_enable_event_type(dev, EV_ABS)); + CHECK_LIBEVDEV(libevdev_enable_event_code(dev, EV_ABS, ABS_X, &absinfo)); + CHECK_LIBEVDEV(libevdev_enable_event_code(dev, EV_ABS, ABS_Y, &absinfo)); + CHECK_LIBEVDEV(libevdev_enable_event_code(dev, EV_ABS, ABS_Z, &absinfo)); + CHECK_LIBEVDEV(libevdev_enable_event_code(dev, EV_ABS, ABS_RX, &absinfo)); + CHECK_LIBEVDEV(libevdev_enable_event_code(dev, EV_ABS, ABS_RY, &absinfo)); - CHECK_LIBEVDEV(libevdev_enable_event_type(dev, EV_ABS)) - CHECK_LIBEVDEV(libevdev_enable_event_code(dev, EV_ABS, ABS_X, &absinfo)) - CHECK_LIBEVDEV(libevdev_enable_event_code(dev, EV_ABS, ABS_Y, &absinfo)) - CHECK_LIBEVDEV(libevdev_enable_event_code(dev, EV_ABS, ABS_Z, &absinfo)) - CHECK_LIBEVDEV(libevdev_enable_event_code(dev, EV_ABS, ABS_RX, &absinfo)) - CHECK_LIBEVDEV(libevdev_enable_event_code(dev, EV_ABS, ABS_RY, &absinfo)) - CHECK_LIBEVDEV(libevdev_enable_event_code(dev, EV_ABS, ABS_RZ, &absinfo)) + CHECK_LIBEVDEV(libevdev_enable_event_code(dev, EV_ABS, ABS_RZ, &absinfo)); - CHECK_LIBEVDEV(error = libevdev_uinput_create_from_device(dev, LIBEVDEV_UINPUT_OPEN_MANAGED, &uidev)) + CHECK_LIBEVDEV(libevdev_uinput_create_from_device(dev, LIBEVDEV_UINPUT_OPEN_MANAGED, &uidev)); return; error: @@ -39,6 +54,8 @@ error: libevdev_uinput_destroy(uidev); if (dev) libevdev_free(dev); + if (error) + fprintf(stderr, "libevdev error: %d\n", error); uidev = NULL; dev = NULL; } @@ -60,15 +77,19 @@ void FTNoIR_Protocol::sendHeadposeToGame( double *headpose, double *rawheadpose 2, 2, 2, - 2, /* | pitch | only goes to 90 */ - 1, + 2, + 1, /* |pitch| only goes to 90 */ 2 }; const int max_euler = 90; for (int i = 0; i < 6; i++) - (void) libevdev_uinput_write_event(uidev, EV_ABS, axes[i], ranges[i] * headpose[i] * max_euler / ABS_MAX); + { + int value = headpose[i] * mid_input / (max_euler * ranges[i]) + mid_input; + int normalized = std::max(std::min(max_input, value), min_input); + (void) libevdev_uinput_write_event(uidev, EV_ABS, axes[i], normalized); + } } extern "C" FTNOIR_PROTOCOL_BASE_EXPORT IProtocol* CALLING_CONVENTION GetConstructor() diff --git a/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.h b/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.h index b71738f1..42864a07 100644 --- a/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.h +++ b/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.h @@ -12,8 +12,10 @@ #include #include "facetracknoir/global-settings.h" -#include -#include +extern "C" { +# include +# include +} class FTNoIR_Protocol : public IProtocol { -- cgit v1.2.3 From 4fc7efa31f385baaaf8db16a3fc59c695dd5ee47 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 17 Sep 2013 00:07:26 +0200 Subject: add missing evdev driver icon --- ftnoir_protocol_libevdev/images/linux.png | Bin 0 -> 668 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 ftnoir_protocol_libevdev/images/linux.png diff --git a/ftnoir_protocol_libevdev/images/linux.png b/ftnoir_protocol_libevdev/images/linux.png new file mode 100644 index 00000000..8836c0e2 Binary files /dev/null and b/ftnoir_protocol_libevdev/images/linux.png differ -- cgit v1.2.3 From a1c5b014da305b43da45b57e76c2c273270ad4b4 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 17 Sep 2013 00:34:48 +0200 Subject: Pretend to be a joystick a bit harder for udev --- ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.cpp b/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.cpp index 74986299..dec4f847 100644 --- a/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.cpp +++ b/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.cpp @@ -46,6 +46,9 @@ FTNoIR_Protocol::FTNoIR_Protocol() : dev(NULL), uidev(NULL) CHECK_LIBEVDEV(libevdev_enable_event_code(dev, EV_ABS, ABS_RZ, &absinfo)); + CHECK_LIBEVDEV(libevdev_enable_event_type(dev, EV_KEY)); + CHECK_LIBEVDEV(libevdev_enable_event_code(dev, EV_KEY, BTN_JOYSTICK, NULL)); + CHECK_LIBEVDEV(libevdev_uinput_create_from_device(dev, LIBEVDEV_UINPUT_OPEN_MANAGED, &uidev)); return; -- cgit v1.2.3 From 37fb6559536685df97f6b6b35614dff43cb901a1 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 17 Sep 2013 00:41:34 +0200 Subject: Rename UI class from copied boilerplate --- ftnoir_protocol_libevdev/ftnoir_libevdev_controls.ui | 4 ++-- ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ftnoir_protocol_libevdev/ftnoir_libevdev_controls.ui b/ftnoir_protocol_libevdev/ftnoir_libevdev_controls.ui index f9a55547..e85e001e 100644 --- a/ftnoir_protocol_libevdev/ftnoir_libevdev_controls.ui +++ b/ftnoir_protocol_libevdev/ftnoir_libevdev_controls.ui @@ -1,7 +1,7 @@ - UICVJoyControls - + UICLibevdevControls + Qt::ApplicationModal diff --git a/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.h b/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.h index 42864a07..e753269e 100644 --- a/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.h +++ b/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.h @@ -49,7 +49,7 @@ public: void unRegisterProtocol() {} private: - Ui::UICVJoyControls ui; + Ui::UICLibevdevControls ui; void save(); private slots: -- cgit v1.2.3 From 46029fe376e358a6a3ab021cfd8252945460d84a Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 17 Sep 2013 00:42:22 +0200 Subject: Add a note to future self --- ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.cpp b/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.cpp index dec4f847..80b075d6 100644 --- a/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.cpp +++ b/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.cpp @@ -46,6 +46,7 @@ FTNoIR_Protocol::FTNoIR_Protocol() : dev(NULL), uidev(NULL) CHECK_LIBEVDEV(libevdev_enable_event_code(dev, EV_ABS, ABS_RZ, &absinfo)); + /* do not remove next 2 lines or udev scripts won't assign 0664 permissions -sh */ CHECK_LIBEVDEV(libevdev_enable_event_type(dev, EV_KEY)); CHECK_LIBEVDEV(libevdev_enable_event_code(dev, EV_KEY, BTN_JOYSTICK, NULL)); -- cgit v1.2.3 From b2dcd14ef0a12803c82b7aaf374d3f88098ad4e8 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 17 Sep 2013 00:47:55 +0200 Subject: Take a peek on how uglyDwarf doesIt --- ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.cpp b/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.cpp index 80b075d6..60922967 100644 --- a/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.cpp +++ b/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.cpp @@ -46,9 +46,10 @@ FTNoIR_Protocol::FTNoIR_Protocol() : dev(NULL), uidev(NULL) CHECK_LIBEVDEV(libevdev_enable_event_code(dev, EV_ABS, ABS_RZ, &absinfo)); - /* do not remove next 2 lines or udev scripts won't assign 0664 permissions -sh */ + /* do not remove next 3 lines or udev scripts won't assign 0664 permissions -sh */ CHECK_LIBEVDEV(libevdev_enable_event_type(dev, EV_KEY)); CHECK_LIBEVDEV(libevdev_enable_event_code(dev, EV_KEY, BTN_JOYSTICK, NULL)); + CHECK_LIBEVDEV(libevdev_enable_event_code(dev, EV_KEY, BTN_TRIGGER, NULL)); CHECK_LIBEVDEV(libevdev_uinput_create_from_device(dev, LIBEVDEV_UINPUT_OPEN_MANAGED, &uidev)); -- 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(-) 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 4109274cf3ae8ddd586a85196680084bee40f5b9 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 17 Sep 2013 01:57:42 +0200 Subject: Refactor for proper translation output range --- .../ftnoir_protocol_libevdev.cpp | 27 +++++++++++----------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.cpp b/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.cpp index 60922967..a64f252e 100644 --- a/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.cpp +++ b/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.cpp @@ -9,8 +9,8 @@ #define CHECK_LIBEVDEV(expr) if (error = (expr) != 0) goto error; -static const int max_input = 8192; -static const int mid_input = 4096; +static const int max_input = 65535; +static const int mid_input = 32767; static const int min_input = 0; #define HT_PI 3.1415926535 @@ -34,8 +34,8 @@ FTNoIR_Protocol::FTNoIR_Protocol() : dev(NULL), uidev(NULL) absinfo.maximum = max_input; absinfo.resolution = 1; absinfo.value = mid_input; - absinfo.flat = 8192 / 180; - absinfo.fuzz = 1; + absinfo.flat = 1; + absinfo.fuzz = 0; CHECK_LIBEVDEV(libevdev_enable_event_type(dev, EV_ABS)); CHECK_LIBEVDEV(libevdev_enable_event_code(dev, EV_ABS, ABS_X, &absinfo)); @@ -78,20 +78,19 @@ void FTNoIR_Protocol::sendHeadposeToGame( double *headpose, double *rawheadpose /* translation goes first */ ABS_X, ABS_Y, ABS_Z, ABS_RX, ABS_RY, ABS_RZ }; - static const int ranges[] = { - 2, - 2, - 2, - 2, - 1, /* |pitch| only goes to 90 */ - 2 - }; - const int max_euler = 90; + static const int max_value[] = { + 100, + 100, + 100, + 180, + 90, + 180 + }; for (int i = 0; i < 6; i++) { - int value = headpose[i] * mid_input / (max_euler * ranges[i]) + mid_input; + int value = headpose[i] * mid_input / max_value[i] + mid_input; int normalized = std::max(std::min(max_input, value), min_input); (void) libevdev_uinput_write_event(uidev, EV_ABS, axes[i], normalized); } -- cgit v1.2.3 From b3f2cfa87ba25a85e486f4e45ce419fc0e823ca2 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 17 Sep 2013 02:09:23 +0200 Subject: remove empty line --- ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.cpp b/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.cpp index a64f252e..3f74f462 100644 --- a/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.cpp +++ b/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.cpp @@ -43,7 +43,6 @@ FTNoIR_Protocol::FTNoIR_Protocol() : dev(NULL), uidev(NULL) CHECK_LIBEVDEV(libevdev_enable_event_code(dev, EV_ABS, ABS_Z, &absinfo)); CHECK_LIBEVDEV(libevdev_enable_event_code(dev, EV_ABS, ABS_RX, &absinfo)); CHECK_LIBEVDEV(libevdev_enable_event_code(dev, EV_ABS, ABS_RY, &absinfo)); - CHECK_LIBEVDEV(libevdev_enable_event_code(dev, EV_ABS, ABS_RZ, &absinfo)); /* do not remove next 3 lines or udev scripts won't assign 0664 permissions -sh */ -- cgit v1.2.3 From 169bd7eb0396cd8d9474e47b669f5db7bcaf38bf Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 17 Sep 2013 12:52:43 +0200 Subject: proto-libevdev: End bulk updates with EV_SYN --- ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.cpp b/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.cpp index 3f74f462..f0950d80 100644 --- a/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.cpp +++ b/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.cpp @@ -93,6 +93,8 @@ void FTNoIR_Protocol::sendHeadposeToGame( double *headpose, double *rawheadpose int normalized = std::max(std::min(max_input, value), min_input); (void) libevdev_uinput_write_event(uidev, EV_ABS, axes[i], normalized); } + + (void) libevdev_uinput_write_event(uidev, EV_SYN, SYN_REPORT, 0); } extern "C" FTNOIR_PROTOCOL_BASE_EXPORT IProtocol* CALLING_CONVENTION GetConstructor() -- cgit v1.2.3 From d47b8311d249a8bbccad9afec5c8ced53f6bff1a Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 17 Sep 2013 12:56:27 +0200 Subject: proto-wine: Fix incorrect usage of mutex-locker --- ftnoir_protocol_wine/ftnoir_protocol_wine.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/ftnoir_protocol_wine/ftnoir_protocol_wine.h b/ftnoir_protocol_wine/ftnoir_protocol_wine.h index c4837992..300501ad 100644 --- a/ftnoir_protocol_wine/ftnoir_protocol_wine.h +++ b/ftnoir_protocol_wine/ftnoir_protocol_wine.h @@ -52,7 +52,10 @@ public: bool checkServerInstallationOK(); void sendHeadposeToGame(double* headpose, double* rawheadpose ); - + QString getGameName() { + QMutexLocker foo(&game_name_mutex); + return connected_game; + } private: PortableLockedShm lck_shm; WineSHM* shm; @@ -60,10 +63,6 @@ private: int gameid; QString connected_game; QMutex game_name_mutex; - QString getGameName() { - QMutexLocker((QMutex*)&game_name_mutex); - return connected_game; - } }; // Widget that has controls for FTNoIR protocol client-settings. -- cgit v1.2.3 From 49d6de31c4ba587d73fac8204cf92569bfaa7e6a Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 17 Sep 2013 12:56:39 +0200 Subject: proto: Correct visibility --- ftnoir_protocol_fg/ftnoir_protocol_fg.h | 6 +++--- ftnoir_protocol_mouse/ftnoir_protocol_mouse.h | 7 +++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/ftnoir_protocol_fg/ftnoir_protocol_fg.h b/ftnoir_protocol_fg/ftnoir_protocol_fg.h index 5c2531be..40a83384 100644 --- a/ftnoir_protocol_fg/ftnoir_protocol_fg.h +++ b/ftnoir_protocol_fg/ftnoir_protocol_fg.h @@ -48,6 +48,9 @@ public: ~FTNoIR_Protocol(); bool checkServerInstallationOK(); void sendHeadposeToGame( double *headpose, double *rawheadpose ); + QString getGameName() { + return "FlightGear"; + } private: bool blnConnectionActive; @@ -61,9 +64,6 @@ private: 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. diff --git a/ftnoir_protocol_mouse/ftnoir_protocol_mouse.h b/ftnoir_protocol_mouse/ftnoir_protocol_mouse.h index b537fc4e..5aad9c01 100644 --- a/ftnoir_protocol_mouse/ftnoir_protocol_mouse.h +++ b/ftnoir_protocol_mouse/ftnoir_protocol_mouse.h @@ -61,7 +61,9 @@ public: ~FTNoIR_Protocol(); bool checkServerInstallationOK(); void sendHeadposeToGame( double *headpose, double *rawheadpose ); - + QString getGameName() { + return "Mouse tracker"; + } private: HANDLE h; INPUT MouseStruct; @@ -70,9 +72,6 @@ private: FTN_AngleName Mouse_Y; FTN_AngleName Mouse_Wheel; void loadSettings(); - QString getGameName() { - return "Mouse tracker"; - } }; // Widget that has controls for FTNoIR protocol client-settings. -- cgit v1.2.3 From 92ce8f4ee9b5f54de6032e0f59446f13dffd8a7a Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 17 Sep 2013 17:27:13 +0200 Subject: Rename UDP protocol description only. NB ABI compat with facetracknoir was lost due to removal of unused struct member. --- ftnoir_protocol_ftn/ftnoir_protocol_ftn.h | 6 +++--- ftnoir_tracker_udp/ftnoir_tracker_udp_dll.cpp | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ftnoir_protocol_ftn/ftnoir_protocol_ftn.h b/ftnoir_protocol_ftn/ftnoir_protocol_ftn.h index 31247d1e..4c1c34cd 100644 --- a/ftnoir_protocol_ftn/ftnoir_protocol_ftn.h +++ b/ftnoir_protocol_ftn/ftnoir_protocol_ftn.h @@ -93,9 +93,9 @@ 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 getFullName(QString *strToBeFilled) { *strToBeFilled = QString("UDP"); } + void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("UDP"); } + void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("opentrack UDP protocol"); } void getIcon(QIcon *icon) { *icon = QIcon(":/images/facetracknoir.png"); } }; diff --git a/ftnoir_tracker_udp/ftnoir_tracker_udp_dll.cpp b/ftnoir_tracker_udp/ftnoir_tracker_udp_dll.cpp index dcdbe487..7d7b7c81 100644 --- a/ftnoir_tracker_udp/ftnoir_tracker_udp_dll.cpp +++ b/ftnoir_tracker_udp/ftnoir_tracker_udp_dll.cpp @@ -28,9 +28,9 @@ FTNoIR_TrackerDll::FTNoIR_TrackerDll() { //populate the description strings - trackerFullName = "FaceTrackNoIR UDP"; + trackerFullName = "UDP"; trackerShortName = "UDP"; - trackerDescription = "FaceTrackNoIR UDP"; + trackerDescription = "opentrack UDP client"; } FTNoIR_TrackerDll::~FTNoIR_TrackerDll() -- 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(-) 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 5bedf6f81342356c197604a9484281db0a726611 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 17 Sep 2013 17:34:14 +0200 Subject: Appease GNU CC -Wall -Wno-reorder --- ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.cpp b/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.cpp index f0950d80..60d9e90c 100644 --- a/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.cpp +++ b/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.cpp @@ -7,7 +7,7 @@ #include #include -#define CHECK_LIBEVDEV(expr) if (error = (expr) != 0) goto error; +#define CHECK_LIBEVDEV(expr) if ((error = (expr)) != 0) goto error; static const int max_input = 65535; static const int mid_input = 32767; -- 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(-) 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 7b907c5f88836effdefcad320d398ce1b18e857d Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 17 Sep 2013 17:42:44 +0200 Subject: splines: mutex without ptr; appease -Wreorder --- qfunctionconfigurator/functionconfig.cpp | 33 +++++++++++++++----------------- qfunctionconfigurator/functionconfig.h | 4 ++-- 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/qfunctionconfigurator/functionconfig.cpp b/qfunctionconfigurator/functionconfig.cpp index 6e1569f9..f9c9957e 100644 --- a/qfunctionconfigurator/functionconfig.cpp +++ b/qfunctionconfigurator/functionconfig.cpp @@ -21,9 +21,9 @@ // // Constructor with List of Points in argument. // -FunctionConfig::FunctionConfig(QString title, int intMaxInput, int intMaxOutput) +FunctionConfig::FunctionConfig(QString title, int intMaxInput, int intMaxOutput) : + _mutex(QMutex::Recursive) { - _mutex = new QMutex(QMutex::Recursive); _title = title; _points = QList(); _data = 0; @@ -45,14 +45,13 @@ void FunctionConfig::setTrackingActive(bool blnActive) } FunctionConfig::FunctionConfig() : + _mutex(QMutex::Recursive), + _data(0), + _size(0), _tracking_active(false), _max_Input(0), - _max_Output(0), - _data(0), - _mutex(0), - _size(0) + _max_Output(0) { - _mutex = new QMutex(); } // @@ -61,7 +60,7 @@ FunctionConfig::FunctionConfig() : // 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); + QMutexLocker foo(&_mutex); int x2 = (int) (std::min(std::max(x, -360), 360) * MEMOIZE_PRECISION); float ret = getValueInternal(x2); lastValueTracked.setX(x); @@ -73,7 +72,7 @@ float FunctionConfig::getValue(float x) { // 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); + QMutexLocker foo(&_mutex); point = lastValueTracked; return _tracking_active; } @@ -172,8 +171,6 @@ void FunctionConfig::reload() { FunctionConfig::~FunctionConfig() { if (_data) delete[] _data; - if (_mutex) - delete _mutex; } // @@ -181,7 +178,7 @@ FunctionConfig::~FunctionConfig() { // Used by the Widget. // void FunctionConfig::removePoint(int i) { - QMutexLocker foo(_mutex); + QMutexLocker foo(&_mutex); if (i >= 0 && i < _points.size()) { _points.removeAt(i); @@ -194,7 +191,7 @@ void FunctionConfig::removePoint(int i) { // Used by the Widget and by loadSettings. // void FunctionConfig::addPoint(QPointF pt) { - QMutexLocker foo(_mutex); + QMutexLocker foo(&_mutex); _points.append(pt); reload(); } @@ -204,7 +201,7 @@ void FunctionConfig::addPoint(QPointF pt) { // Used by the Widget. // void FunctionConfig::movePoint(int idx, QPointF pt) { - QMutexLocker foo(_mutex); + QMutexLocker foo(&_mutex); if (idx >= 0 && idx < _points.size()) { _points[idx] = pt; @@ -218,8 +215,8 @@ void FunctionConfig::movePoint(int idx, QPointF pt) { // QList FunctionConfig::getPoints() { QList ret; - QMutexLocker foo(_mutex); - for (int i = 0; i < _points.size(); i++) { + QMutexLocker foo(&_mutex); + for (int i = 0; i < _points.size(); i++) { ret.append(_points[i]); } return ret; @@ -230,7 +227,7 @@ QList FunctionConfig::getPoints() { // Settings for a specific Curve are loaded from their own Group in the INI-file. // void FunctionConfig::loadSettings(QSettings& settings) { - QMutexLocker foo(_mutex); + QMutexLocker foo(&_mutex); QPointF newPoint; QList points; @@ -266,7 +263,7 @@ void FunctionConfig::loadSettings(QSettings& settings) { // The number of Points is also saved, to make loading more convenient. // void FunctionConfig::saveSettings(QSettings& settings) { - QMutexLocker foo(_mutex); + QMutexLocker foo(&_mutex); settings.beginGroup(QString("Curves-%1").arg(_title)); int max = _points.size(); settings.setValue("point-count", max); diff --git a/qfunctionconfigurator/functionconfig.h b/qfunctionconfigurator/functionconfig.h index f1310a8c..b6257df2 100644 --- a/qfunctionconfigurator/functionconfig.h +++ b/qfunctionconfigurator/functionconfig.h @@ -19,7 +19,7 @@ class FTNOIR_TRACKER_BASE_EXPORT FunctionConfig { private: - QMutex* _mutex; + QMutex _mutex; QList _points; void reload(); float* _data; @@ -47,7 +47,7 @@ public: // void removePoint(int i); void removeAllPoints() { - QMutexLocker foo(_mutex); + QMutexLocker foo(&_mutex); _points.clear(); reload(); } -- 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(-) 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 2586fadcb331761acb622a863dc6525ccb56744a Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 17 Sep 2013 18:18:59 +0200 Subject: freetrack: warnings-safe on mingw-w64 --- ftnoir_protocol_ft/ftnoir_protocol_ft_dialog.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/ftnoir_protocol_ft/ftnoir_protocol_ft_dialog.cpp b/ftnoir_protocol_ft/ftnoir_protocol_ft_dialog.cpp index 93742129..b59d3637 100644 --- a/ftnoir_protocol_ft/ftnoir_protocol_ft_dialog.cpp +++ b/ftnoir_protocol_ft/ftnoir_protocol_ft_dialog.cpp @@ -190,13 +190,7 @@ void FTControls::save() { // 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 (*)")); + 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. -- cgit v1.2.3 From 7307bae90d560eca572e9f063981c97aa70e5968 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 17 Sep 2013 18:19:40 +0200 Subject: simconnect: don't redefine internal constant --- ftnoir_protocol_sc/ftnoir_protocol_sc.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ftnoir_protocol_sc/ftnoir_protocol_sc.h b/ftnoir_protocol_sc/ftnoir_protocol_sc.h index 8fcf7c1f..b24eb0cf 100644 --- a/ftnoir_protocol_sc/ftnoir_protocol_sc.h +++ b/ftnoir_protocol_sc/ftnoir_protocol_sc.h @@ -29,14 +29,14 @@ #pragma once #ifndef INCLUDED_SCSERVER_H #define INCLUDED_SCSERVER_H +#undef _WIN32_WINNT +#define _WIN32_WINNT 0x0502 #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 -- 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(-) 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(-) 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(+) 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(-) 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(-) 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(+) 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(-) 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 334eb6a4f25240441ec4e2cd5c31dec0f9fa0453 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 17 Sep 2013 19:42:39 +0200 Subject: New README --- README.md | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ readme.txt | 1 - 2 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 README.md delete mode 100644 readme.txt diff --git a/README.md b/README.md new file mode 100644 index 00000000..0ca24ef0 --- /dev/null +++ b/README.md @@ -0,0 +1,53 @@ +Windows binary builds are available at + +Source code access available at + +-- + +**opentrack** is an application dedicated to tracking user's head +movements and relaying them to games and flight simulation software. + +** Tracking sources + +- SeeingMachines FaceAPI +- PointTracker by Patrick Ruoff, freetrack-like light sources +- Oculus Rift (Linux testers welcome!) +- AR marker support via the ArUco library +- HT tracker > +- Razer Hydra (Windows only) +- Relaying via UDP from a different computer + +** Protocols + +- FlightGear Nasal script +- FSUIPC for Microsoft FSX (Windows) +- freetrack emulation (Windows) +- Relaying udp to another computer +- Joystick support via freedesktop.org libevdev (Linux) +- Joystick support via VJoy (Windows) +- Wine freetrack glue protocol (Linux) +- Tablet-like coordinate output (Windows) + +** Configuration + +**opentrack** offers output shaping, filtering, is buildable on +both MS Windows and GNU/Linux. + +Don't be afraid to submit an issue/feature request if the need arises. + +** Credits + +- mm0zct +- StanisÅ‚aw Halik +- Donovan Baarda +- Patrick Ruoff (merging) +- Wim Vriend (historically) +- Ron Hendriks (historically) + +** Licensing information + +The code originally licensed under GPLv3, new code is required to be +compatible with it unless resides in separate address space. + +It's recommended to submit new code under ISC license, it's a shorter +boilerplate header than MIT/X11 or new BSD. diff --git a/readme.txt b/readme.txt deleted file mode 100644 index eb01d3c0..00000000 --- a/readme.txt +++ /dev/null @@ -1 +0,0 @@ -Windows binary builds are available at \ No newline at end of file -- cgit v1.2.3 From 1b1aeea49e780a3927a0ee339b5eb6cd6428ff51 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 17 Sep 2013 19:44:43 +0200 Subject: readme: maybe get markup right --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 0ca24ef0..e47f5172 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Source code access available at **opentrack** is an application dedicated to tracking user's head movements and relaying them to games and flight simulation software. -** Tracking sources +# Tracking sources - SeeingMachines FaceAPI - PointTracker by Patrick Ruoff, freetrack-like light sources @@ -17,7 +17,7 @@ movements and relaying them to games and flight simulation software. - Razer Hydra (Windows only) - Relaying via UDP from a different computer -** Protocols +# Protocols - FlightGear Nasal script - FSUIPC for Microsoft FSX (Windows) @@ -28,14 +28,14 @@ movements and relaying them to games and flight simulation software. - Wine freetrack glue protocol (Linux) - Tablet-like coordinate output (Windows) -** Configuration +# Configuration **opentrack** offers output shaping, filtering, is buildable on both MS Windows and GNU/Linux. Don't be afraid to submit an issue/feature request if the need arises. -** Credits +# Credits - mm0zct - StanisÅ‚aw Halik @@ -44,7 +44,7 @@ Don't be afraid to submit an issue/feature request if the need arises. - Wim Vriend (historically) - Ron Hendriks (historically) -** Licensing information +# Licensing information The code originally licensed under GPLv3, new code is required to be compatible with it unless resides in separate address space. -- cgit v1.2.3 From 00af84a7ce1c04610428588661dfe203eb4aa325 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 17 Sep 2013 19:46:30 +0200 Subject: Clarify SM FaceAPI availability --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e47f5172..ade57394 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ movements and relaying them to games and flight simulation software. # Tracking sources -- SeeingMachines FaceAPI +- SeeingMachines FaceAPI (Windows) - PointTracker by Patrick Ruoff, freetrack-like light sources - Oculus Rift (Linux testers welcome!) - AR marker support via the ArUco library -- cgit v1.2.3 From 5066045c9ba532aae151a2176a0afdb8bd2fcdfc Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 17 Sep 2013 19:49:47 +0200 Subject: readme: rename header --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ade57394..9b9aad71 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ movements and relaying them to games and flight simulation software. - Razer Hydra (Windows only) - Relaying via UDP from a different computer -# Protocols +# Output - FlightGear Nasal script - FSUIPC for Microsoft FSX (Windows) -- cgit v1.2.3 From f159fc2b84d2c7139c348d167c7491fb43fb7e5e Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 17 Sep 2013 20:24:25 +0200 Subject: proto-wine: fix warnings, dependencies, reformat --- CMakeLists.txt | 4 ++++ compat/compat.h | 12 ++++++++---- ftnoir_protocol_wine/opentrack-wrapper-wine-posix.cxx | 7 +++++-- ftnoir_protocol_wine/opentrack-wrapper-wine-windows.cxx | 4 ++++ 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bc734e43..6385f04d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -416,6 +416,9 @@ endif() if(NOT SDK_WINE_NO_WRAPPER) add_custom_command( OUTPUT opentrack-wrapper-wine.exe.so + DEPENDS "${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" COMMAND "${SDK_WINE_PREFIX}/bin/wineg++" -g -O2 -m32 -o opentrack-wrapper-wine.exe -I "${CMAKE_SOURCE_DIR}" "${CMAKE_SOURCE_DIR}/ftnoir_protocol_wine/opentrack-wrapper-wine-main.cxx" @@ -423,6 +426,7 @@ endif() "${CMAKE_SOURCE_DIR}/ftnoir_protocol_wine/opentrack-wrapper-wine-windows.cxx" -lrt) add_custom_target(wine-wrapper ALL DEPENDS opentrack-wrapper-wine.exe.so) + add_dependencies(wine-wrapper opentrack-compat opentrack-proto-wine) endif() endif() diff --git a/compat/compat.h b/compat/compat.h index c34add10..3d54ae1d 100644 --- a/compat/compat.h +++ b/compat/compat.h @@ -19,10 +19,14 @@ #include #endif -#if defined(IN_FTNOIR_COMPAT) && defined(_WIN32) -# define COMPAT_EXPORT __declspec(dllexport) -#elif defined(_WIN32) -# define COMPAT_EXPORT __declspec(dllimport) +#if !defined(OPENTRACK_COMPAT_BUNDLED) +# if defined(IN_FTNOIR_COMPAT) && defined(_WIN32) +# define COMPAT_EXPORT __declspec(dllexport) +# elif defined(_WIN32) +# define COMPAT_EXPORT __declspec(dllimport) +# else +# define COMPAT_EXPORT +# endif #else # define COMPAT_EXPORT #endif diff --git a/ftnoir_protocol_wine/opentrack-wrapper-wine-posix.cxx b/ftnoir_protocol_wine/opentrack-wrapper-wine-posix.cxx index c88dd332..42d39ff2 100644 --- a/ftnoir_protocol_wine/opentrack-wrapper-wine-posix.cxx +++ b/ftnoir_protocol_wine/opentrack-wrapper-wine-posix.cxx @@ -1,9 +1,12 @@ +#define OPENTRACK_COMPAT_BUNDLED #ifdef _WIN32 -#undef _WIN32 +# undef _WIN32 #endif + #ifdef __WIN32 -#undef __WIN32 +# undef __WIN32 #endif + #define PortableLockedShm ShmPosix #include "compat/compat.h" #include "compat/compat.cpp" diff --git a/ftnoir_protocol_wine/opentrack-wrapper-wine-windows.cxx b/ftnoir_protocol_wine/opentrack-wrapper-wine-windows.cxx index 6d5484a9..e7102600 100644 --- a/ftnoir_protocol_wine/opentrack-wrapper-wine-windows.cxx +++ b/ftnoir_protocol_wine/opentrack-wrapper-wine-windows.cxx @@ -1,7 +1,11 @@ +#define OPENTRACK_COMPAT_BUNDLED + #ifndef __WIN32 #define __WIN32 #endif + #define PortableLockedShm ShmWine + #include "ftnoir_protocol_ft/fttypes.h" #include "compat/compat.h" #include "compat/compat.cpp" -- cgit v1.2.3 From 1824a10ebe285d4b81ed0c50197e5fa78685587f Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 17 Sep 2013 20:28:36 +0200 Subject: wine: get rid of mingw-ism --- ftnoir_protocol_wine/opentrack-wrapper-wine-posix.cxx | 4 ---- 1 file changed, 4 deletions(-) diff --git a/ftnoir_protocol_wine/opentrack-wrapper-wine-posix.cxx b/ftnoir_protocol_wine/opentrack-wrapper-wine-posix.cxx index 42d39ff2..010c4440 100644 --- a/ftnoir_protocol_wine/opentrack-wrapper-wine-posix.cxx +++ b/ftnoir_protocol_wine/opentrack-wrapper-wine-posix.cxx @@ -3,10 +3,6 @@ # undef _WIN32 #endif -#ifdef __WIN32 -# undef __WIN32 -#endif - #define PortableLockedShm ShmPosix #include "compat/compat.h" #include "compat/compat.cpp" -- cgit v1.2.3 From 4ab718bdd67ee0b5327269e24675070c2a705cc5 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 17 Sep 2013 20:32:46 +0200 Subject: xpl: rename user-visible data following fork --- x-plane-plugin/plugin.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/x-plane-plugin/plugin.c b/x-plane-plugin/plugin.c index 9bc5c484..eae2bf0b 100644 --- a/x-plane-plugin/plugin.c +++ b/x-plane-plugin/plugin.c @@ -108,19 +108,19 @@ PLUGIN_API int XPluginStart ( char * outName, char * outSignature, char * outDes if (view_x && view_y && view_z && view_heading && view_pitch) { lck_posix = PortableLockedShm_init(WINE_SHM_NAME, WINE_MTX_NAME, sizeof(WineSHM)); if (lck_posix->mem == (void*)-1) { - fprintf(stderr, "FTNOIR failed to init SHM #1!\n"); + fprintf(stderr, "opentrack failed to init SHM #1!\n"); return 0; } if (lck_posix->mem == NULL) { - fprintf(stderr, "FTNOIR failed to init SHM #2!\n"); + fprintf(stderr, "opentrack failed to init SHM #2!\n"); return 0; } shm_posix = (WineSHM*) lck_posix->mem; memset(shm_posix, 0, sizeof(WineSHM)); - strcpy(outName, "FaceTrackNoIR"); - strcpy(outSignature, "FaceTrackNoIR - FreeTrack lives!"); - strcpy(outDescription, "Face tracking view control"); - fprintf(stderr, "FTNOIR init complete\n"); + strcpy(outName, "opentrack"); + strcpy(outSignature, "opentrack - freetrack lives!"); + strcpy(outDescription, "head tracking view control"); + fprintf(stderr, "opentrack init complete\n"); return 1; } return 0; -- cgit v1.2.3 From 7a2ce4fc1450dfccf9fd2e98e34c0449a5c7112a Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 17 Sep 2013 21:42:10 +0200 Subject: fix faceapi build with mingw-w64, fix build error --- CMakeLists.txt | 8 ++++++-- ftnoir_tracker_sm/ftnoir_tracker_sm.h | 8 ++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6385f04d..0d0f7cf1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -559,9 +559,13 @@ if(SDK_SM_FACEAPI_PATH) add_library(opentrack-tracker-faceapi SHARED ${opentrack-tracker-faceapi-c} ${opentrack-tracker-faceapi-moc} ${opentrack-tracker-faceapi-uih} ${opentrack-tracker-faceapi-rcc}) target_link_libraries(opentrack-tracker-faceapi ${MY_QT_LIBS} opentrack-compat) endif() - if(MSVC80) + if(MSVC80 OR MINGW) add_executable(opentrack-faceapi-wrapper ${opentrack-faceapi-wrapper-c}) target_link_libraries(opentrack-faceapi-wrapper "${SDK_SM_FACEAPI_PATH}/bin/smft32.lib") + if(CMAKE_COMPILER_IS_GNUCXX) + #target_link_libraries(opentrack-faceapi-wrapper msvcr80) + SET_TARGET_PROPERTIES(opentrack-faceapi-wrapper PROPERTIES LINK_FLAGS "-mdll") + endif() endif() endif() @@ -608,7 +612,7 @@ if(NOT SDK_FACEAPI_ONLY) NAMELINK_SKIP ) - if(SDK_VJOY) + if(WIN32 AND SDK_VJOY) install(TARGETS opentrack-proto-vjoy RUNTIME DESTINATION . LIBRARY DESTINATION . diff --git a/ftnoir_tracker_sm/ftnoir_tracker_sm.h b/ftnoir_tracker_sm/ftnoir_tracker_sm.h index 5d692ea0..6c76b149 100644 --- a/ftnoir_tracker_sm/ftnoir_tracker_sm.h +++ b/ftnoir_tracker_sm/ftnoir_tracker_sm.h @@ -22,14 +22,14 @@ * 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 "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 #include "math.h" #include "facetracknoir/global-settings.h" #include "compat/compat.h" -- cgit v1.2.3 From b21091e965e79437d4bcc7581d0b17c79982b8c4 Mon Sep 17 00:00:00 2001 From: mm0zct Date: Tue, 17 Sep 2013 22:23:56 +0100 Subject: Minor modification to attribution in the README.md -mm0zct --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9b9aad71..c0e12058 100644 --- a/README.md +++ b/README.md @@ -37,8 +37,8 @@ Don't be afraid to submit an issue/feature request if the need arises. # Credits -- mm0zct - StanisÅ‚aw Halik +- Chris Thompson (aka mm0zct) - Donovan Baarda - Patrick Ruoff (merging) - Wim Vriend (historically) -- cgit v1.2.3 From d41a05fe32ef6741fbc52a5e29392e3fe01b6bc3 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 18 Sep 2013 00:27:02 +0200 Subject: cmakelists: fix brain damage --- CMakeLists.txt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0d0f7cf1..67d16f87 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -562,10 +562,6 @@ if(SDK_SM_FACEAPI_PATH) if(MSVC80 OR MINGW) add_executable(opentrack-faceapi-wrapper ${opentrack-faceapi-wrapper-c}) target_link_libraries(opentrack-faceapi-wrapper "${SDK_SM_FACEAPI_PATH}/bin/smft32.lib") - if(CMAKE_COMPILER_IS_GNUCXX) - #target_link_libraries(opentrack-faceapi-wrapper msvcr80) - SET_TARGET_PROPERTIES(opentrack-faceapi-wrapper PROPERTIES LINK_FLAGS "-mdll") - endif() endif() endif() -- cgit v1.2.3 From 4190c03321eefd6d2a191990c1f241245708f4d3 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 18 Sep 2013 08:02:14 +0200 Subject: Fix build error on OpenCV 2.4 (alterscape) --- FTNoIR_Tracker_PT/camera.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FTNoIR_Tracker_PT/camera.h b/FTNoIR_Tracker_PT/camera.h index d1a8104c..78fe8dfb 100644 --- a/FTNoIR_Tracker_PT/camera.h +++ b/FTNoIR_Tracker_PT/camera.h @@ -13,7 +13,7 @@ # include #else # include "FTNoIR_Tracker_PT/boost-compat.h" -# include +# include # include #endif #include -- cgit v1.2.3 From 13d130ae0ca1527475a80161ce2ffffae0ace6f2 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 18 Sep 2013 08:08:22 +0200 Subject: build: enable faceapi on mingw-w64 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 67d16f87..15e1e3b7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -706,7 +706,7 @@ if(MSVC) install(FILES ${pdbs} DESTINATION .) endif() -if(WIN32 AND SDK_SM_FACEAPI_PATH AND MSVC80) +if(SDK_SM_FACEAPI_PATH AND (MSVC80 OR MINGW)) install(TARGETS opentrack-faceapi-wrapper RUNTIME DESTINATION faceapi LIBRARY DESTINATION faceapi -- cgit v1.2.3 From d3509f15e95dd0e2fb884f0028fabfceb3ddf4fa Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 18 Sep 2013 08:11:07 +0200 Subject: build: hopefully fix tracker-pt for alterscape --- CMakeLists.txt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 15e1e3b7..e5dc9d55 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -459,7 +459,7 @@ endif() "${CMAKE_SOURCE_DIR}/dinput/strmiids.lib" uuid) endif() - + if(OpenCV_FOUND) include_directories(${OpenCV_INCLUDE_DIRS}) include_directories(${OpenCV_DIR}/include) @@ -473,6 +473,14 @@ endif() SET_TARGET_PROPERTIES(opentrack-tracker-pt PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt") endif() + + if(WIN32) + target_link_libraries(opentrack-tracker-pt + "${CMAKE_SOURCE_DIR}/dinput/dinput8.lib" + "${CMAKE_SOURCE_DIR}/dinput/dxguid.lib" + "${CMAKE_SOURCE_DIR}/dinput/strmiids.lib" + uuid) + endif() endif() add_library(opentrack-tracker-udp SHARED ${opentrack-tracker-udp-c} ${opentrack-tracker-udp-moc} ${opentrack-tracker-udp-uih} ${opentrack-tracker-udp-rcc}) -- cgit v1.2.3 From 904a461aa6bfca437eb3144d2133a029a7d032a0 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 18 Sep 2013 08:52:16 +0200 Subject: build: decruft --- CMakeLists.txt | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e5dc9d55..c436e30d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -667,22 +667,17 @@ if(NOT SDK_FACEAPI_ONLY) ) install(FILES ${opentrack-opencv-files} DESTINATION .) endif() - get_filename_component(opentrack-qt-bin "${QT_QMAKE_EXECUTABLE}" PATH) if(WIN32 AND NOT CMAKE_COMPILER_IS_GNUCC) - GET_FILENAME_COMPONENT(qt-dirname "${QT_QTCORE_LIBRARY_RELEASE}" PATH) - SET(qt-dirname "${qt-dirname}/../bin/") - if(NOT EXISTS "${qt-dirname}/../bin/") GET_FILENAME_COMPONENT(qt-dirname "${QT_QTCORE_LIBRARY_RELEASE}" PATH) SET(qt-dirname "${qt-dirname}/../bin/") - endif() - install(FILES - "${qt-dirname}/QtCore4.dll" - "${qt-dirname}/QtGui4.dll" - "${qt-dirname}/QtNetwork4.dll" - "${qt-dirname}/QtSvg4.dll" - "${qt-dirname}/QtXml4.dll" - DESTINATION . - ) + install(FILES + "${qt-dirname}/QtCore4.dll" + "${qt-dirname}/QtGui4.dll" + "${qt-dirname}/QtNetwork4.dll" + "${qt-dirname}/QtSvg4.dll" + "${qt-dirname}/QtXml4.dll" + DESTINATION . + ) endif() install(TARGETS opentrack-proto-freetrack -- cgit v1.2.3 From 003b309a224a31119dd767f4b0dd0998f16a4582 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 18 Sep 2013 09:14:01 +0200 Subject: build: trackers only need dshow, no dinput --- CMakeLists.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c436e30d..d804c9e8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -454,7 +454,6 @@ endif() if(WIN32) target_link_libraries(opentrack-tracker-ht - "${CMAKE_SOURCE_DIR}/dinput/dinput8.lib" "${CMAKE_SOURCE_DIR}/dinput/dxguid.lib" "${CMAKE_SOURCE_DIR}/dinput/strmiids.lib" uuid) @@ -476,7 +475,6 @@ endif() if(WIN32) target_link_libraries(opentrack-tracker-pt - "${CMAKE_SOURCE_DIR}/dinput/dinput8.lib" "${CMAKE_SOURCE_DIR}/dinput/dxguid.lib" "${CMAKE_SOURCE_DIR}/dinput/strmiids.lib" uuid) -- cgit v1.2.3 From 8dbd762469cef179f5ca48e337481223fc86272b Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 18 Sep 2013 15:20:48 +0200 Subject: Clarify Oculus Rift platform availability --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c0e12058..4258461c 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ movements and relaying them to games and flight simulation software. - SeeingMachines FaceAPI (Windows) - PointTracker by Patrick Ruoff, freetrack-like light sources -- Oculus Rift (Linux testers welcome!) +- Oculus Rift (Windows; Linux testers welcome!) - AR marker support via the ArUco library - HT tracker > - Razer Hydra (Windows only) -- cgit v1.2.3 From df757ac29f3a365792cd4c410b87d980f8d527fd Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 18 Sep 2013 15:31:54 +0200 Subject: readme: typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4258461c..7ce146e6 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ movements and relaying them to games and flight simulation software. - PointTracker by Patrick Ruoff, freetrack-like light sources - Oculus Rift (Windows; Linux testers welcome!) - AR marker support via the ArUco library -- HT tracker > +- HT tracker - Razer Hydra (Windows only) - Relaying via UDP from a different computer -- cgit v1.2.3 From 4075e340d6cdce5afd7a50145ef8e6ca81eb0da0 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 18 Sep 2013 16:34:16 +0200 Subject: build: include readme in install dir --- CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index d804c9e8..edbaa133 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -571,6 +571,8 @@ if(SDK_SM_FACEAPI_PATH) endif() endif() +install(FILES "${CMAKE_SOURCE_DIR}/README.md" DESTINATION .) + if(NOT SDK_FACEAPI_ONLY) if(SDK_XPLANE) install(TARGETS opentrack-xplane-plugin LIBRARY DESTINATION . NAMELINK_SKIP) -- 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(-) 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 b37d9f82420d545f650f5f5eb39de513c9dbce80 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 18 Sep 2013 17:16:46 +0200 Subject: libevdev: since don't care about sensor resolution, cleanup unused macro --- ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.cpp b/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.cpp index 60d9e90c..fc01552e 100644 --- a/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.cpp +++ b/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.cpp @@ -13,8 +13,6 @@ static const int max_input = 65535; static const int mid_input = 32767; static const int min_input = 0; -#define HT_PI 3.1415926535 - FTNoIR_Protocol::FTNoIR_Protocol() : dev(NULL), uidev(NULL) { int error = 0; -- cgit v1.2.3 From 8fe5959661d9cff122eeaeeafbb53e9c25395bba Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 18 Sep 2013 18:59:51 +0200 Subject: Quick hack to include pdb in 2.0a2 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index edbaa133..ffb1c384 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -705,7 +705,7 @@ if(SDK_SM_FACEAPI_PATH AND NOT SDK_FACEAPI_ONLY) endif() if(MSVC) - file(GLOB pdbs "${CMAKE_BINARY_DIR}/*.pdb") + file(GLOB pdbs "${CMAKE_BINARY_DIR}/*.pdb" "${CMAKE_BINARY_DIR}/release/*.pdb") install(FILES ${pdbs} DESTINATION .) endif() -- cgit v1.2.3 From 3a987e2382acab0d36fe7f2037304f3fb9493544 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 18 Sep 2013 19:44:37 +0200 Subject: dot.gitignore: dos2unix --- .gitignore | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index f367cb02..509a52d5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,11 @@ /CMakeLists.txt.user *~ /build* -/install -/bin/tracker-ht/headtracker-ftnoir.exe -/bin/tracker-ht/libgcc_s_dw2-1.dll -/bin/tracker-ht/libstdc++-6.dll -/bin/tracker-ht/bounding-box.raw -/bin/tracker-ht/flandmark_model.dat -/bin/tracker-ht/head.raw -/installer/Output +/install +/bin/tracker-ht/headtracker-ftnoir.exe +/bin/tracker-ht/libgcc_s_dw2-1.dll +/bin/tracker-ht/libstdc++-6.dll +/bin/tracker-ht/bounding-box.raw +/bin/tracker-ht/flandmark_model.dat +/bin/tracker-ht/head.raw +/installer/Output -- cgit v1.2.3 From d2dfb776907ec0513fa0647b9d4dd89b11a7ad34 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 18 Sep 2013 19:45:02 +0200 Subject: installer: accomodate new build machine --- installer/opentrack-installer.iss | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/installer/opentrack-installer.iss b/installer/opentrack-installer.iss index d0567a14..1e64b8c3 100644 --- a/installer/opentrack-installer.iss +++ b/installer/opentrack-installer.iss @@ -23,7 +23,7 @@ DefaultDirName={pf}\{#MyAppName} DefaultGroupName={#MyAppName} AllowNoIcons=yes OutputBaseFilename=opentrack-setup -SetupIconFile=C:\Users\Administrator\Projects\opentrack\facetracknoir\facetracknoir.ico +SetupIconFile=C:\Users\Administrator\SDK\opentrack\facetracknoir\facetracknoir.ico Compression=lzma/ultra64 SolidCompression=yes DisableWelcomePage=True @@ -41,7 +41,7 @@ Name: "english"; MessagesFile: "compiler:Default.isl" Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked [Files] -Source: "C:\Users\Administrator\Projects\opentrack\install\*"; DestDir: "{app}"; Flags: ignoreversion createallsubdirs recursesubdirs +Source: "C:\Users\Administrator\SDK\opentrack\install\*"; DestDir: "{app}"; Flags: ignoreversion createallsubdirs recursesubdirs [Icons] Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}" -- cgit v1.2.3 From 9d3311c8377f79a8551ff470b56d8fb35b67d98d Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 19 Sep 2013 01:46:48 +0200 Subject: dot.gitignore: ignore netbeans project metadata --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 509a52d5..9c4f50ff 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ /bin/tracker-ht/flandmark_model.dat /bin/tracker-ht/head.raw /installer/Output +/nbproject/ -- cgit v1.2.3 From f3aa3b391bb5159801029770d139c1cc0bfc9df5 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 19 Sep 2013 10:59:31 +0200 Subject: misc: fix API boilerplate, encoding --- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 1 - ftnoir_tracker_aruco/ftnoir_tracker_aruco_dll.h | 3 +-- ftnoir_tracker_ht/ftnoir_tracker_ht_dll.h | 3 +-- ftnoir_tracker_hydra/ftnoir_tracker_hydra.h | 2 -- ftnoir_tracker_hydra/ftnoir_tracker_hydra_dll.cpp | 5 ----- ftnoir_tracker_sm/ftnoir_tracker_sm.h | 2 -- 6 files changed, 2 insertions(+), 14 deletions(-) diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index b781f390..781bf711 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -299,7 +299,6 @@ bool Tracker::GiveHeadPoseData(double *data) class TrackerDll : public Metadata { // ITrackerDll interface - void Initialize() {} void getFullName(QString *strToBeFilled); void getShortName(QString *strToBeFilled); void getDescription(QString *strToBeFilled); diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco_dll.h b/ftnoir_tracker_aruco/ftnoir_tracker_aruco_dll.h index 1e53f802..ffdc5262 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco_dll.h +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco_dll.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2013 Stanis³aw Halik +/* Copyright (c) 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 @@ -12,7 +12,6 @@ class TrackerDll : public Metadata { // ITrackerDll interface - void Initialize() {} void getFullName(QString *strToBeFilled); void getShortName(QString *strToBeFilled); void getDescription(QString *strToBeFilled); diff --git a/ftnoir_tracker_ht/ftnoir_tracker_ht_dll.h b/ftnoir_tracker_ht/ftnoir_tracker_ht_dll.h index 1e53f802..ffdc5262 100644 --- a/ftnoir_tracker_ht/ftnoir_tracker_ht_dll.h +++ b/ftnoir_tracker_ht/ftnoir_tracker_ht_dll.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2013 Stanis³aw Halik +/* Copyright (c) 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 @@ -12,7 +12,6 @@ class TrackerDll : public Metadata { // ITrackerDll interface - void Initialize() {} void getFullName(QString *strToBeFilled); void getShortName(QString *strToBeFilled); void getDescription(QString *strToBeFilled); diff --git a/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h b/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h index 3f7bf0a8..82a72f56 100644 --- a/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h +++ b/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h @@ -74,8 +74,6 @@ public: FTNoIR_TrackerDll(); ~FTNoIR_TrackerDll(); - void Initialize(); - void getFullName(QString *strToBeFilled); void getShortName(QString *strToBeFilled); void getDescription(QString *strToBeFilled); diff --git a/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dll.cpp b/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dll.cpp index 4f5d8b10..64eaaa42 100644 --- a/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dll.cpp +++ b/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dll.cpp @@ -15,11 +15,6 @@ FTNoIR_TrackerDll::~FTNoIR_TrackerDll() } -void FTNoIR_TrackerDll::Initialize() -{ - return; -} - void FTNoIR_TrackerDll::getFullName(QString *strToBeFilled) { *strToBeFilled = trackerFullName; diff --git a/ftnoir_tracker_sm/ftnoir_tracker_sm.h b/ftnoir_tracker_sm/ftnoir_tracker_sm.h index 6c76b149..44a5627a 100644 --- a/ftnoir_tracker_sm/ftnoir_tracker_sm.h +++ b/ftnoir_tracker_sm/ftnoir_tracker_sm.h @@ -142,8 +142,6 @@ public: FTNoIR_TrackerDll(); ~FTNoIR_TrackerDll(); - void Initialize(); - void getFullName(QString *strToBeFilled); void getShortName(QString *strToBeFilled); void getDescription(QString *strToBeFilled); -- cgit v1.2.3 From af71f2534fc1e99ed7d483190e99d4dc674bcd76 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 19 Sep 2013 12:20:30 +0200 Subject: compat: new API, check for success --- compat/compat.cpp | 9 +++++++++ compat/compat.h | 1 + 2 files changed, 10 insertions(+) diff --git a/compat/compat.cpp b/compat/compat.cpp index d8aac9bc..f6261738 100644 --- a/compat/compat.cpp +++ b/compat/compat.cpp @@ -61,6 +61,15 @@ PortableLockedShm::PortableLockedShm(const char *shmName, const char *mutexName, mem = (void*) -1; } +PortableLockedShm::success() +{ +#ifndef _WIN32 + return (void*) mem != (void*) -1 +#else + return (void*) mem != NULL; +#endif +} + PortableLockedShm::~PortableLockedShm() { //(void) shm_unlink(shm_filename); diff --git a/compat/compat.h b/compat/compat.h index 3d54ae1d..8c307b14 100644 --- a/compat/compat.h +++ b/compat/compat.h @@ -37,6 +37,7 @@ public: ~PortableLockedShm(); void lock(); void unlock(); + bool success(); void* mem; private: #if defined(_WIN32) -- cgit v1.2.3 From 9ddf5d3ba5024c0266b910365e86c6fa58e9d266 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 19 Sep 2013 12:23:57 +0200 Subject: proto-wine: use compat-shm::success() --- ftnoir_protocol_wine/ftnoir_protocol_wine.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ftnoir_protocol_wine/ftnoir_protocol_wine.cpp b/ftnoir_protocol_wine/ftnoir_protocol_wine.cpp index 96a15b93..698c2236 100644 --- a/ftnoir_protocol_wine/ftnoir_protocol_wine.cpp +++ b/ftnoir_protocol_wine/ftnoir_protocol_wine.cpp @@ -7,7 +7,7 @@ /** constructor **/ FTNoIR_Protocol::FTNoIR_Protocol() : lck_shm(WINE_SHM_NAME, WINE_MTX_NAME, sizeof(WineSHM)), shm(NULL), gameid(0) { - if (lck_shm.mem != (void*) -1) { + if (lck_shm.success()) { shm = (WineSHM*) lck_shm.mem; memset(shm, 0, sizeof(*shm)); } @@ -53,7 +53,7 @@ void FTNoIR_Protocol::sendHeadposeToGame( double *headpose, double *rawheadpose // bool FTNoIR_Protocol::checkServerInstallationOK() { - return lck_shm.mem != (void*)-1; + return lck_shm.success(); } //////////////////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From a65e9de1d016dcf958753233113560008b629aff Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 19 Sep 2013 12:40:38 +0200 Subject: compat: fix build --- compat/compat.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compat/compat.cpp b/compat/compat.cpp index f6261738..7d9f9357 100644 --- a/compat/compat.cpp +++ b/compat/compat.cpp @@ -61,10 +61,10 @@ PortableLockedShm::PortableLockedShm(const char *shmName, const char *mutexName, mem = (void*) -1; } -PortableLockedShm::success() +bool PortableLockedShm::success() { #ifndef _WIN32 - return (void*) mem != (void*) -1 + return (void*) mem != (void*) -1; #else return (void*) mem != NULL; #endif -- cgit v1.2.3 From 017a906cde67e246655de5f95e7f4f27f0d8169f Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 19 Sep 2013 12:41:31 +0200 Subject: compat: fix win32 build --- compat/compat.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/compat/compat.cpp b/compat/compat.cpp index 7d9f9357..6d9298bb 100644 --- a/compat/compat.cpp +++ b/compat/compat.cpp @@ -61,15 +61,6 @@ PortableLockedShm::PortableLockedShm(const char *shmName, const char *mutexName, mem = (void*) -1; } -bool PortableLockedShm::success() -{ -#ifndef _WIN32 - return (void*) mem != (void*) -1; -#else - return (void*) mem != NULL; -#endif -} - PortableLockedShm::~PortableLockedShm() { //(void) shm_unlink(shm_filename); @@ -88,6 +79,13 @@ void PortableLockedShm::unlock() flock(fd, LOCK_UN); } +#endif - +bool PortableLockedShm::success() +{ +#ifndef _WIN32 + return (void*) mem != (void*) -1; +#else + return (void*) mem != NULL; #endif +} \ No newline at end of file -- cgit v1.2.3 From 0578bd819884172ca4b1e197931e5490e8ef7bbd Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 19 Sep 2013 12:42:54 +0200 Subject: proto-freetrack: use new compat bool ::success() --- ftnoir_protocol_ft/ftnoir_protocol_ft.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp b/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp index ec4eb532..47e99d31 100644 --- a/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp +++ b/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp @@ -256,7 +256,7 @@ bool FTNoIR_Protocol::checkServerInstallationOK() start_dummy(); } - if (shm.mem == (void*) 0 || shm.mem == (void*) -1) + if (!shm.success()) return false; pMemData->data.DataID = 1; -- cgit v1.2.3 From 635874182399703bb1ec2fc714eb49d0186bc61c Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 19 Sep 2013 12:46:36 +0200 Subject: wine-wrapper: use new bool compat::success() api --- ftnoir_protocol_wine/opentrack-wrapper-wine-main.cxx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ftnoir_protocol_wine/opentrack-wrapper-wine-main.cxx b/ftnoir_protocol_wine/opentrack-wrapper-wine-main.cxx index a81bccae..6e512b6e 100644 --- a/ftnoir_protocol_wine/opentrack-wrapper-wine-main.cxx +++ b/ftnoir_protocol_wine/opentrack-wrapper-wine-main.cxx @@ -12,6 +12,7 @@ public: ~ShmPosix(); void lock(); void unlock(); + bool success(); void* mem; private: int fd, size; @@ -23,6 +24,7 @@ public: ~ShmWine(); void lock(); void unlock(); + bool success(); void* mem; private: void *hMutex, *hMapFile; @@ -33,11 +35,11 @@ int main(void) { ShmPosix lck_posix(WINE_SHM_NAME, WINE_MTX_NAME, sizeof(WineSHM)); ShmWine lck_wine("FT_SharedMem", "FT_Mutext", sizeof(FTMemMap)); - if(lck_posix.mem == (void*)-1) { + if(!lck_posix.success()) { printf("Can't open posix map: %d\n", errno); return 1; } - if(lck_wine.mem == NULL) { + if(!lck_wine.success()) { printf("Can't open Wine map\n"); return 1; } -- cgit v1.2.3 From 4496e10f1315a72c915871801d95788884bfdb92 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 19 Sep 2013 14:18:27 +0200 Subject: xpl: dead code. mmap(2) (void*)-1 on failure --- x-plane-plugin/plugin.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/x-plane-plugin/plugin.c b/x-plane-plugin/plugin.c index eae2bf0b..dd771ab5 100644 --- a/x-plane-plugin/plugin.c +++ b/x-plane-plugin/plugin.c @@ -108,11 +108,7 @@ PLUGIN_API int XPluginStart ( char * outName, char * outSignature, char * outDes if (view_x && view_y && view_z && view_heading && view_pitch) { lck_posix = PortableLockedShm_init(WINE_SHM_NAME, WINE_MTX_NAME, sizeof(WineSHM)); if (lck_posix->mem == (void*)-1) { - fprintf(stderr, "opentrack failed to init SHM #1!\n"); - return 0; - } - if (lck_posix->mem == NULL) { - fprintf(stderr, "opentrack failed to init SHM #2!\n"); + fprintf(stderr, "opentrack failed to init SHM!\n"); return 0; } shm_posix = (WineSHM*) lck_posix->mem; -- cgit v1.2.3 From 0436e0c00df4c0e26c9691dc3d739402fdababc3 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 19 Sep 2013 14:21:07 +0200 Subject: tracker-base: pass -pedantic in GNUC89 --- ftnoir_tracker_base/ftnoir_tracker_types.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ftnoir_tracker_base/ftnoir_tracker_types.h b/ftnoir_tracker_base/ftnoir_tracker_types.h index 74612371..4abc29bc 100644 --- a/ftnoir_tracker_base/ftnoir_tracker_types.h +++ b/ftnoir_tracker_base/ftnoir_tracker_types.h @@ -29,4 +29,4 @@ enum Axis { TX = 0, TY, TZ, Yaw, Pitch, Roll}; -#endif // FTNOIR_TRACKER_TYPES_H +#endif /*FTNOIR_TRACKER_TYPES_H*/ -- cgit v1.2.3 From 629d7221887f506f1542ec8970569fb48210dfdb Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 19 Sep 2013 14:22:06 +0200 Subject: xpl: pass -Wall -pedantic in gnuc89 --- x-plane-plugin/plugin.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/x-plane-plugin/plugin.c b/x-plane-plugin/plugin.c index dd771ab5..1f30f04d 100644 --- a/x-plane-plugin/plugin.c +++ b/x-plane-plugin/plugin.c @@ -19,7 +19,7 @@ #define PLUGIN_API #endif -// using Wine name to ease things +/* using Wine name to ease things */ #define WINE_SHM_NAME "facetracknoir-wine-shm" #define WINE_MTX_NAME "facetracknoir-wine-mtx" @@ -48,7 +48,7 @@ PortableLockedShm* PortableLockedShm_init(const char *shmName, const char *mutex strncpy(shm_filename+1, shmName, NAME_MAX-2); shm_filename[NAME_MAX-1] = '\0'; sprintf(shm_filename + strlen(shm_filename), "%ld\n", (long) getuid()); - //(void) shm_unlink(shm_filename); + /* (void) shm_unlink(shm_filename); */ self->fd = shm_open(shm_filename, O_RDWR | O_CREAT, 0600); if (ftruncate(self->fd, mapSize) == 0) @@ -60,7 +60,7 @@ PortableLockedShm* PortableLockedShm_init(const char *shmName, const char *mutex void PortableLockedShm_free(PortableLockedShm* self) { - //(void) shm_unlink(shm_filename); + /*(void) shm_unlink(shm_filename);*/ (void) munmap(self->mem, self->size); (void) close(self->fd); free(self); -- cgit v1.2.3 From a5c5962d4650dcf41b8f78f52233982d1c3d3849 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 19 Sep 2013 14:27:21 +0200 Subject: accela: actually mark UI settings as dirty --- ftnoir_filter_accela/ftnoir_filter_accela.h | 1 + ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.h b/ftnoir_filter_accela/ftnoir_filter_accela.h index effb06c2..3dae7580 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.h +++ b/ftnoir_filter_accela/ftnoir_filter_accela.h @@ -82,6 +82,7 @@ private slots: void doCancel(); void settingChanged(bool) { settingsDirty = true; } void settingChanged(int) { settingsDirty = true; } + void settingChanged(double) { settingsDirty = true; } }; //******************************************************************************************************* diff --git a/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp b/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp index 18ef284e..c5cebb32 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp @@ -43,8 +43,8 @@ FilterControls::FilterControls() : 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.rotation_alpha, SIGNAL(valueChanged(double)), this, SLOT(settingChanged(double))); + connect(ui.translation_alpha, SIGNAL(valueChanged(double)), this, SLOT(settingChanged(double))); connect(ui.slideZoom, SIGNAL(valueChanged(int)), this, SLOT(settingChanged(int))); connect(ui.spinZoom, SIGNAL(valueChanged(int)), this, SLOT(settingChanged(int))); -- cgit v1.2.3 From e0c2456c61f0d9054aca8649bff7c5aa59935607 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 19 Sep 2013 14:40:00 +0200 Subject: installer: untested, auto-version installer --- installer/opentrack-installer.iss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/installer/opentrack-installer.iss b/installer/opentrack-installer.iss index 1e64b8c3..740eec94 100644 --- a/installer/opentrack-installer.iss +++ b/installer/opentrack-installer.iss @@ -22,7 +22,7 @@ AppUpdatesURL={#MyAppURL} DefaultDirName={pf}\{#MyAppName} DefaultGroupName={#MyAppName} AllowNoIcons=yes -OutputBaseFilename=opentrack-setup +OutputBaseFilename=opentrack-setup-{#AppVersion} SetupIconFile=C:\Users\Administrator\SDK\opentrack\facetracknoir\facetracknoir.ico Compression=lzma/ultra64 SolidCompression=yes -- cgit v1.2.3 From 93a6f3ba19998e7590c263d5673c8f26cd6a4b1e Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 19 Sep 2013 15:50:55 +0200 Subject: installer: bump version for the next alpha --- installer/opentrack-installer.iss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/installer/opentrack-installer.iss b/installer/opentrack-installer.iss index 740eec94..3b2a2d50 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.0a1" +#define MyAppVersion "2.0a3" #define MyAppPublisher "opentrack" #define MyAppURL "http://github.com/opentrack/opentrack" #define MyAppExeName "opentrack.exe" -- cgit v1.2.3 From 9c605834652206f550ecca66c464ca990e4d30c0 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 19 Sep 2013 15:51:11 +0200 Subject: qfc: pass -Wall -pedantic -Wextra --- qfunctionconfigurator/qfunctionconfigurator.cpp | 6 +++--- qfunctionconfigurator/qfunctionconfigurator.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/qfunctionconfigurator/qfunctionconfigurator.cpp b/qfunctionconfigurator/qfunctionconfigurator.cpp index 4a5f7ca6..0bd9aad0 100644 --- a/qfunctionconfigurator/qfunctionconfigurator.cpp +++ b/qfunctionconfigurator/qfunctionconfigurator.cpp @@ -208,7 +208,7 @@ void QFunctionConfigurator::drawBackground(const QRectF &fullRect) // // Draw the Function for the graph, on a Pixmap. // -void QFunctionConfigurator::drawFunction(const QRectF &fullRect) +void QFunctionConfigurator::drawFunction() { if (!_config) return; @@ -277,7 +277,7 @@ int i; } if (_draw_function) { - drawFunction(e->rect()); // Draw the Function on a Pixmap + drawFunction(); // Draw the Function on a Pixmap _draw_function = false; } p.drawPixmap(0, 0, _function); // Always draw the background and the function @@ -650,7 +650,7 @@ void QFunctionConfigurator::setCaption(QString cap) update(); } -void QFunctionConfigurator::resizeEvent(QResizeEvent *e) +void QFunctionConfigurator::resizeEvent(QResizeEvent *) { range = QRectF(40, 20, MaxInput * pPerEGU_Input, MaxOutput * pPerEGU_Output); diff --git a/qfunctionconfigurator/qfunctionconfigurator.h b/qfunctionconfigurator/qfunctionconfigurator.h index c9290722..6669f92e 100644 --- a/qfunctionconfigurator/qfunctionconfigurator.h +++ b/qfunctionconfigurator/qfunctionconfigurator.h @@ -153,7 +153,7 @@ protected slots: protected: void drawBackground(const QRectF &rect); - void drawFunction(const QRectF &rect); + void drawFunction(); void drawPoint(QPainter *painter, const QPointF &pt, QColor colBG ); void drawLine(QPainter *painter, const QPointF &start, const QPointF &end, QPen pen); bool markContains(const QPointF &pt, const QPointF &coord) const; -- cgit v1.2.3 From 73f1fd6553b9839473e034a402ee9b34737b2af7 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 19 Sep 2013 15:58:40 +0200 Subject: compat: pass -Wextra --- compat/compat.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compat/compat.cpp b/compat/compat.cpp index 6d9298bb..808a8645 100644 --- a/compat/compat.cpp +++ b/compat/compat.cpp @@ -44,7 +44,7 @@ void PortableLockedShm::unlock() } #else -PortableLockedShm::PortableLockedShm(const char *shmName, const char *mutexName, int mapSize) : size(mapSize) +PortableLockedShm::PortableLockedShm(const char *shmName, const char* /*mutexName*/, int mapSize) : size(mapSize) { char shm_filename[NAME_MAX]; shm_filename[0] = '/'; -- 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(-) 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(-) 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(-) 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 b5f9865453a024ad1a6f5a9016a3fa8259c8d6ec Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 19 Sep 2013 17:50:57 +0200 Subject: hpp: drop comments, probably from Web example --- ftnoir_filter_base/ftnoir_filter_base.h | 13 ------------- ftnoir_protocol_base/ftnoir_protocol_base.h | 17 ----------------- 2 files changed, 30 deletions(-) diff --git a/ftnoir_filter_base/ftnoir_filter_base.h b/ftnoir_filter_base/ftnoir_filter_base.h index 0f73310f..fe1ad19a 100644 --- a/ftnoir_filter_base/ftnoir_filter_base.h +++ b/ftnoir_filter_base/ftnoir_filter_base.h @@ -10,19 +10,6 @@ #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() {} diff --git a/ftnoir_protocol_base/ftnoir_protocol_base.h b/ftnoir_protocol_base/ftnoir_protocol_base.h index 1ebafdd5..d20e01b5 100644 --- a/ftnoir_protocol_base/ftnoir_protocol_base.h +++ b/ftnoir_protocol_base/ftnoir_protocol_base.h @@ -36,24 +36,7 @@ #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() {} -- 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(-) 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(-) 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(-) 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 214a8083c3a4e794c0d88b939606a263dc045563 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 19 Sep 2013 18:30:04 +0200 Subject: ewma: fix filter lack of idempotence Bug introduced by self in c4f6c12187ed423edc17501b0f6bda129d192bca --- ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp b/ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp index 69d18d9b..6bf2396a 100644 --- a/ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp +++ b/ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp @@ -115,7 +115,7 @@ void FTNoIR_Filter::FilterHeadPoseData(const double *target_camera_position, //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]); + largest_alpha=std::min(largest_alpha, alpha[i]); } // Calculate the new camera position. -- cgit v1.2.3 From 6b2fcdcbafffcd6a1c3c9141616b79f2f70ee755 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 19 Sep 2013 19:36:47 +0200 Subject: faceapi: move SM .h to appropriate dir --- faceapi/main.cpp | 2 +- ftnoir_tracker_base/ftnoir_tracker_ma_types.h | 33 ------------------------ ftnoir_tracker_base/ftnoir_tracker_sm_types.h | 36 --------------------------- ftnoir_tracker_sm/ftnoir_tracker_sm.h | 2 +- ftnoir_tracker_sm/ftnoir_tracker_sm_types.h | 36 +++++++++++++++++++++++++++ 5 files changed, 38 insertions(+), 71 deletions(-) delete mode 100644 ftnoir_tracker_base/ftnoir_tracker_ma_types.h delete mode 100644 ftnoir_tracker_base/ftnoir_tracker_sm_types.h create mode 100644 ftnoir_tracker_sm/ftnoir_tracker_sm_types.h diff --git a/faceapi/main.cpp b/faceapi/main.cpp index 8128ee97..fb7d3f0a 100644 --- a/faceapi/main.cpp +++ b/faceapi/main.cpp @@ -27,7 +27,7 @@ //FaceAPI headers #include -#include "ftnoir_tracker_base/ftnoir_tracker_sm_types.h" +#include "ftnoir_tracker_sm/ftnoir_tracker_sm_types.h" #include "utils.h" #include diff --git a/ftnoir_tracker_base/ftnoir_tracker_ma_types.h b/ftnoir_tracker_base/ftnoir_tracker_ma_types.h deleted file mode 100644 index b3101ad3..00000000 --- a/ftnoir_tracker_base/ftnoir_tracker_ma_types.h +++ /dev/null @@ -1,33 +0,0 @@ -// -// Definitions for the Shared Memory to send the data to FaceTrackNoIR -// -#define MA_MM_DATA "MA_SharedMem" -#define MA_FACEAPI "MA_FaceAPI" -#define MA_MUTEX "MA_Mutex" - -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_MA_START = 10, - FT_MA_STOP = 20, - FT_MA_SHOW_CAM = 30, - FT_MA_SET_PAR_FILTER = 50, - FT_MA_EXIT = 100 -}; diff --git a/ftnoir_tracker_base/ftnoir_tracker_sm_types.h b/ftnoir_tracker_base/ftnoir_tracker_sm_types.h deleted file mode 100644 index 526f8cdc..00000000 --- a/ftnoir_tracker_base/ftnoir_tracker_sm_types.h +++ /dev/null @@ -1,36 +0,0 @@ -// -// 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_sm/ftnoir_tracker_sm.h b/ftnoir_tracker_sm/ftnoir_tracker_sm.h index 44a5627a..95e1edeb 100644 --- a/ftnoir_tracker_sm/ftnoir_tracker_sm.h +++ b/ftnoir_tracker_sm/ftnoir_tracker_sm.h @@ -23,7 +23,7 @@ * * ********************************************************************************/ #include "ftnoir_tracker_base/ftnoir_tracker_base.h" -#include "ftnoir_tracker_base/ftnoir_tracker_sm_types.h" +#include "ftnoir_tracker_sm/ftnoir_tracker_sm_types.h" #include "ui_ftnoir_sm_controls.h" #include diff --git a/ftnoir_tracker_sm/ftnoir_tracker_sm_types.h b/ftnoir_tracker_sm/ftnoir_tracker_sm_types.h new file mode 100644 index 00000000..526f8cdc --- /dev/null +++ b/ftnoir_tracker_sm/ftnoir_tracker_sm_types.h @@ -0,0 +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 +}; -- cgit v1.2.3 From 42ded0f1b6c1bd2b8d06bbaee2b87698a93cf85a Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 19 Sep 2013 19:39:50 +0200 Subject: base: remove incorrect copyright/authorship info --- ftnoir_tracker_base/ftnoir_tracker_types.h | 34 +++--------------------------- 1 file changed, 3 insertions(+), 31 deletions(-) diff --git a/ftnoir_tracker_base/ftnoir_tracker_types.h b/ftnoir_tracker_base/ftnoir_tracker_types.h index 4abc29bc..d38baee4 100644 --- a/ftnoir_tracker_base/ftnoir_tracker_types.h +++ b/ftnoir_tracker_base/ftnoir_tracker_types.h @@ -1,32 +1,4 @@ -/******************************************************************************** -* 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 * -*********************************************************************************/ -#ifndef FTNOIR_TRACKER_TYPES_H -#define FTNOIR_TRACKER_TYPES_H - - +#pragma once enum Axis { - TX = 0, TY, TZ, Yaw, Pitch, Roll}; - -#endif /*FTNOIR_TRACKER_TYPES_H*/ + TX = 0, TY, TZ, Yaw, Pitch, Roll +}; -- cgit v1.2.3 From 5dcddc5a347846363cba95a6d8c4d37091f893b6 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 28 Sep 2013 13:04:02 +0200 Subject: clarify MSFS protocol --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7ce146e6..b3bb2556 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,8 @@ movements and relaying them to games and flight simulation software. # Output - FlightGear Nasal script -- FSUIPC for Microsoft FSX (Windows) +- FSUIPC for Microsoft Flight Simulator (Windows) +- SimConnect for newer Microsoft Flight Simulator (Windows) - freetrack emulation (Windows) - Relaying udp to another computer - Joystick support via freedesktop.org libevdev (Linux) -- cgit v1.2.3 From ee843add4063931d8a0331eba3d60c8a579d0661 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 1 Oct 2013 18:04:58 +0200 Subject: add new game ids --- bin/settings/facetracknoir supported games.csv | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bin/settings/facetracknoir supported games.csv b/bin/settings/facetracknoir supported games.csv index e5d3d6aa..05e17605 100644 --- a/bin/settings/facetracknoir supported games.csv +++ b/bin/settings/facetracknoir supported games.csv @@ -1,4 +1,4 @@ -No;Game Name;Game protocol;Supported since;Verified;By;INTERNATIONAL_ID;FTN_ID +No;Game Name;Game protocol;Supported since;Verified;By;INTERNATIONAL_ID;FTN_ID 1;18 Wheels of Steel: Haulin';FreeTrack20;V160;V;doc-uk;13601;000121F172F35116A02100 2;1944 D-Day;FreeTrack20;V160;;;15701;00022E542A6A0575F05200 497;2KMarinNEXT;FreeTrack20;V170;;;3425;0D614F6A0820D1EA8EE800 @@ -23,6 +23,7 @@ No;Game Name;Game protocol;Supported since;Verified;By;INTERNATIONAL_ID;FTN_ID 21;Apache: Air Assault;FreeTrack20;V160;V;paleta77;1875;001591D997A2D912AAA200 22;Aprisoft Gartenplaner;FreeTrack20;V160;;;20014;0016F2F27A5762FA937A00 23;Aprisoft Traumhaus Designer;FreeTrack20;V160;;;20013;00174655E792BB825B9300 +498;ARI;FreeTrack20;V160;;;20795;01F23FB9A61044E206E200 24;ArmA;FreeTrack20;V160;V;EmBeES;10601;0018F2F27A57631A40F200 25;ArmA 2;FreeTrack20;V170;V;V4Friend, Ronski;7502;0019EB3616B3A44F05B900 26;ArmA 2 Operation Arrowhead;FreeTrack20;V160;V;vn88holden;0;001ABC224B7783DAF0D500 @@ -180,6 +181,7 @@ No;Game Name;Game protocol;Supported since;Verified;By;INTERNATIONAL_ID;FTN_ID 166;Halo;FreeTrack20;V160;;;3801;00A656BA018130AF3F9C00 167;Hardware Control Simulator, Railway Electronics;FreeTrack20;V160;;;20705;00A7F3E85B1A8930B42F00 168;Harrier Attack II;FreeTrack20;V160;;;1175;00A8F2F27A57D20A940900 +499;Harry's Hard Choices Interactive;FreeTrack20;V160;;;20800;01F33A21BAE3DB6D48A000 169;HAWX;FreeTrack20;V160;V;EmBeES ;0;00A9D615A9C8B088717000 170;Herissons (Paris France);FreeTrack20;V160;;;20001;00AAEA1CBED8C20B430B00 171;HOBI;FreeTrack20;V160;;;20335;00ABB253777F1779168900 @@ -380,6 +382,7 @@ No;Game Name;Game protocol;Supported since;Verified;By;INTERNATIONAL_ID;FTN_ID 357;Space Shuttle Mission 2007;FreeTrack20;V160;V;purewhitewings ;1225;0165662B03863D912F9700 358;SRI;FreeTrack20;V160;;;20620;01663FD0FC9D8B218D8100 359;Stanford University;FreeTrack20;V160;;;20004;0167CE35BAF9933A62AA00 +500;Star Citizen;FreeTrack20;V170;;;3450;0D7AF4CE4E343EC6B4A200 360;Starshatter;FreeTrack20;V160;;;6401;0168F079578A3F9A3BB600 361;Steel Beasts 2;FreeTrack20;V160;;;11703;0169DCC441A9443A831A00 362;Steel Beasts Pro;FreeTrack20;V160;;;11701;016A8F54A20833CAA23900 @@ -405,6 +408,7 @@ No;Game Name;Game protocol;Supported since;Verified;By;INTERNATIONAL_ID;FTN_ID 380;Telepresence;FreeTrack20;V160;;;20450;017CF478D278B33B02DA00 381;Tenstar Simulator;FreeTrack20;V160;;;20605;017D318F88A2EA62DBA200 382;Test Drive Unlimited;FreeTrack20;V160;;;13201;017E6F2699559730A84000 +501;The Crew;FreeTrack20;V170;;;1009;03F1F534E94F4834D9B100 488;The Gallery;FreeTrack20;V160;;;3350;01E8CE152EDE5FFD267700 383;The Sky Gods;FreeTrack20;V170;;;1525;017FDFF782DCCEEA27C200 384;theHunter;FreeTrack20;V170;;;2375;0180BFF3A86D34DA24C000 -- cgit v1.2.3 From e5f1e165616bd1dfcfbdf8fd19228fee2a657bc9 Mon Sep 17 00:00:00 2001 From: mm0zct Date: Sat, 5 Oct 2013 11:14:46 +0100 Subject: added a re-centre spring effect, optional compiler preprocessor, enabled by default --- ftnoir_tracker_rift/ftnoir_tracker_rift.cpp | 13 ++++++++++++- ftnoir_tracker_rift/ftnoir_tracker_rift.h | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp b/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp index 0c3984ac..e58dbf1b 100644 --- a/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp +++ b/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp @@ -6,6 +6,9 @@ using namespace OVR; +//used to turn on the re-centre spring effect +#define RECENTRE_SPRING + Rift_Tracker::Rift_Tracker() { pSensor.Clear(); @@ -14,6 +17,7 @@ Rift_Tracker::Rift_Tracker() bEnableRoll = true; bEnablePitch = true; bEnableYaw = true; + old_yaw = 0.0; #if 0 bEnableX = true; bEnableY = true; @@ -100,7 +104,14 @@ bool Rift_Tracker::GiveHeadPoseData(double *data) float pitch = 0.0f; float roll = 0.0f; hmdOrient.GetEulerAngles(&yaw, &pitch , &roll); - newHeadPose[Yaw] = yaw; +#ifdef RECENTRE_SPRING + newHeadPose[Yaw] = newHeadPose[Yaw]*0.99999 + (yaw-old_yaw); + if(newHeadPose[Yaw]>0.02)newHeadPose[Yaw]-= 0.000005; + if(newHeadPose[Yaw]<-0.02)newHeadPose[Yaw]+= 0.000005; + old_yaw=yaw; +#else + newHeadPose[Yaw] = yaw; +#endif newHeadPose[Pitch] =pitch; newHeadPose[Roll] = roll; diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift.h b/ftnoir_tracker_rift/ftnoir_tracker_rift.h index 7bacb91c..579d7d34 100644 --- a/ftnoir_tracker_rift/ftnoir_tracker_rift.h +++ b/ftnoir_tracker_rift/ftnoir_tracker_rift.h @@ -30,7 +30,7 @@ private: // Magnetometer calibration and yaw correction OVR::Util::MagCalibration MagCal; bool isCalibrated; - + double old_yaw; double newHeadPose[6]; // Structure with new headpose bool bEnableRoll; bool bEnablePitch; -- cgit v1.2.3 From 819823b8d35db9101e89fa31dae58d689bb597cd Mon Sep 17 00:00:00 2001 From: mm0zct Date: Sat, 5 Oct 2013 11:25:17 +0100 Subject: renamed the re-centre spring define to OPENTRACK_RIFT_RECENTRE_SPRING no longer default --- ftnoir_tracker_rift/ftnoir_tracker_rift.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp b/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp index e58dbf1b..1af99803 100644 --- a/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp +++ b/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp @@ -7,7 +7,7 @@ using namespace OVR; //used to turn on the re-centre spring effect -#define RECENTRE_SPRING +//#define OPENTRACK_RIFT_RECENTRE_SPRING Rift_Tracker::Rift_Tracker() { @@ -104,7 +104,7 @@ bool Rift_Tracker::GiveHeadPoseData(double *data) float pitch = 0.0f; float roll = 0.0f; hmdOrient.GetEulerAngles(&yaw, &pitch , &roll); -#ifdef RECENTRE_SPRING +#ifdef OPENTRACK_RIFT_RECENTRE_SPRING newHeadPose[Yaw] = newHeadPose[Yaw]*0.99999 + (yaw-old_yaw); if(newHeadPose[Yaw]>0.02)newHeadPose[Yaw]-= 0.000005; if(newHeadPose[Yaw]<-0.02)newHeadPose[Yaw]+= 0.000005; -- cgit v1.2.3 From 011c62ee59d9675095d40dee5079c91348959e91 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 5 Oct 2013 12:52:04 +0200 Subject: add recenter spring cache option for Rift Signed-off-by: Stanislaw Halik --- CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index ffb1c384..8ae29e4e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,10 +22,15 @@ endif() IF(WIN32) SET(SDK_SM_FACEAPI_PATH "" CACHE PATH "SeeingMachines FaceAPI SDK path") SET(SDK_RIFT "" CACHE PATH "libOVR path") + SET(SDK_RIFT_RECENTRE_SPRING TRUE CACHE BOOL "recenter yaw aggressively") SET(SDK_HYDRA "" CACHE PATH "libSixense path") SET(SDK_VJOY "" CACHE PATH "VJoy SDK path") ENDIF() +if(SDK_RIFT_RECENTRE_SPRING) + add_definitions(-DOPENTRACK_RIFT_RECENTRE_SPRING) +endif() + file(GLOB opentrack-faceapi-wrapper-c "faceapi/*.cpp") include_directories(${CMAKE_SOURCE_DIR}) -- cgit v1.2.3 From 685ec5d237e9825dc16d7b8fe3554f8f3b9555e9 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 5 Oct 2013 20:04:58 +0200 Subject: add todo Signed-off-by: Stanislaw Halik --- TODO.txt | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 TODO.txt diff --git a/TODO.txt b/TODO.txt new file mode 100644 index 00000000..290b004e --- /dev/null +++ b/TODO.txt @@ -0,0 +1,4 @@ +20131005 sh + what do you think about boost 1.54 for property maps -> qsettings? + also, boost concepts + and qt5 -- cgit v1.2.3 From 277e8beee609ecd728ba8110c6807dbabb0f498b Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 7 Oct 2013 15:41:46 +0200 Subject: further todo Signed-off-by: Stanislaw Halik --- TODO.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/TODO.txt b/TODO.txt index 290b004e..026288d2 100644 --- a/TODO.txt +++ b/TODO.txt @@ -2,3 +2,7 @@ what do you think about boost 1.54 for property maps -> qsettings? also, boost concepts and qt5 +20131007 sh + respect hier(7) with regard to shared object installation. + install them inside ../lib/opentrack relative to ./bin where + the main program oughta reside. -- 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(-) 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 a12d2533e2025959a33ebf692e2a65bffa3684fa Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 8 Oct 2013 18:26:24 +0200 Subject: add another TODO item Signed-off-by: Stanislaw Halik --- TODO.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/TODO.txt b/TODO.txt index 026288d2..91fa7b28 100644 --- a/TODO.txt +++ b/TODO.txt @@ -6,3 +6,6 @@ respect hier(7) with regard to shared object installation. install them inside ../lib/opentrack relative to ./bin where the main program oughta reside. +20131008 sh + during the switch to qt5, recreate widgets, this time with layouts. + the original layouts were pretty crappy, hence the original breakage. -- 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 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 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 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(+) 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 e74cad83f41e759a37a56c623dafe2d05a692129 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 9 Oct 2013 00:33:17 +0200 Subject: blur before segmenting to win big (2x perf) Signed-off-by: Stanislaw Halik --- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index 781bf711..8025e956 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -188,7 +188,7 @@ void Tracker::run() aruco::MarkerDetector detector; detector.setDesiredSpeed(3); detector.setThresholdParams(11, 5); - cv::Mat color, color_, grayscale, rvec, tvec; + cv::Mat color, color_, grayscale, grayscale2, rvec, tvec; if (!camera.isOpened()) { @@ -201,7 +201,12 @@ void Tracker::run() if (!camera.read(color_)) continue; color_.copyTo(color); - cv::cvtColor(color, grayscale, cv::COLOR_BGR2GRAY); + cv::cvtColor(color, grayscale2, cv::COLOR_BGR2GRAY); + const int kernel = grayscale2.cols > 480 ? 7 : 5; + int kernel2 = kernel * grayscale2.rows / grayscale2.cols; + if ((kernel2 % 2) == 0) + kernel2++; + cv::GaussianBlur(grayscale2, grayscale, cv::Size(kernel, kernel2), 0, 0); const float focal_length_w = 0.5 * grayscale.cols / tan(0.5 * fov * HT_PI / 180); const float focal_length_h = 0.5 * grayscale.rows / tan(0.5 * fov * grayscale.rows / grayscale.cols * HT_PI / 180.0); cv::Mat intrinsics = cv::Mat::eye(3, 3, CV_32FC1); -- cgit v1.2.3 From ba0a2ac0bb886c6b3adfc581a5e41d94ab7ea602 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 9 Oct 2013 14:24:17 +0200 Subject: enable Rift on Linux, maybe someone will *finally* test! Signed-off-by: Stanislaw Halik --- CMakeLists.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8ae29e4e..a477dd77 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,12 +21,14 @@ endif() IF(WIN32) SET(SDK_SM_FACEAPI_PATH "" CACHE PATH "SeeingMachines FaceAPI SDK path") - SET(SDK_RIFT "" CACHE PATH "libOVR path") - SET(SDK_RIFT_RECENTRE_SPRING TRUE CACHE BOOL "recenter yaw aggressively") SET(SDK_HYDRA "" CACHE PATH "libSixense path") SET(SDK_VJOY "" CACHE PATH "VJoy SDK path") ENDIF() +SET(SDK_RIFT "" CACHE PATH "libOVR path") + +SET(SDK_RIFT_RECENTRE_SPRING TRUE CACHE BOOL "recenter yaw aggressively") + if(SDK_RIFT_RECENTRE_SPRING) add_definitions(-DOPENTRACK_RIFT_RECENTRE_SPRING) endif() -- 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(-) 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(-) 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(-) 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 2ae4c7ef3243e10f10edbb0a7cfe13a8d4eb990b Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 9 Oct 2013 18:44:34 +0200 Subject: fix installer, build inbound Let's expend the ordnance with extreme prejudice. War is bad. Signed-off-by: Stanislaw Halik --- installer/opentrack-installer.iss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/installer/opentrack-installer.iss b/installer/opentrack-installer.iss index 3b2a2d50..dc6e624b 100644 --- a/installer/opentrack-installer.iss +++ b/installer/opentrack-installer.iss @@ -22,7 +22,7 @@ AppUpdatesURL={#MyAppURL} DefaultDirName={pf}\{#MyAppName} DefaultGroupName={#MyAppName} AllowNoIcons=yes -OutputBaseFilename=opentrack-setup-{#AppVersion} +OutputBaseFilename=opentrack-setup-{#MyAppVersion} SetupIconFile=C:\Users\Administrator\SDK\opentrack\facetracknoir\facetracknoir.ico Compression=lzma/ultra64 SolidCompression=yes -- cgit v1.2.3 From 63461cea1a06434343a800a57004b326d4905f03 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 11 Oct 2013 12:58:08 +0200 Subject: clarify copyright Please see facetracknoir/develop: 336fc06ebe550d2c5fefae7dc1f967377eef998d https://sourceforge.net/p/facetracknoir/codegit/ci/336fc06ebe550d2c5fefae7dc1f967377eef998d/tree/ % git clone http://git.code.sf.net/p/facetracknoir/codegit Signed-off-by: Stanislaw Halik --- freetrackclient/freetrackclient.cpp | 45 ++++++++---------- ftnoir_protocol_ft/fttypes.h | 55 +++++++++------------- qfunctionconfigurator/qfunctionconfigurator.cpp | 41 +++------------- qfunctionconfigurator/qfunctionconfigurator.h | 40 +++------------- .../qfunctionconfiguratorplugin.cpp | 40 +++------------- .../qfunctionconfiguratorplugin.h | 6 +++ 6 files changed, 65 insertions(+), 162 deletions(-) diff --git a/freetrackclient/freetrackclient.cpp b/freetrackclient/freetrackclient.cpp index 0f8ced65..efc639ca 100644 --- a/freetrackclient/freetrackclient.cpp +++ b/freetrackclient/freetrackclient.cpp @@ -1,29 +1,22 @@ -/******************************************************************************** -* FreeTrackClientDll Implements the FreeTrack 2.0 interface for FT-enabled * -* games. * -* It uses the FreeTrack protocol (memory mapping) to * -* receive data from FaceTrackNoIR (or FreeTrack, or ...). * -* * -* Copyright (C) 2013 Wim Vriend (Developing) * -* Ron Hendriks (Testing and Research) * -* * -* 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 . * -* * -********************************************************************************/ - +/*********************************************************************************** + * * FTTypes FTTypes contains the specific type definitions for the * + * * FreeTrack protocol. * + * * It was loosely translated from FTTypes.pas * + * * which was created by the FreeTrack-team. * + * * * + * * Wim Vriend (Developing) * + * * Ron Hendriks (Testing and Research) * + * * * + * * Homepage * + * * * + * * 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. * + * * * + * * * + * * The FreeTrackClient sources were translated from the original Delphi sources * + * * created by the FreeTrack developers. * + */ #define FT_EXPORT(t) extern "C" t __declspec(dllexport) __stdcall #define NP_AXIS_MAX 16383 diff --git a/ftnoir_protocol_ft/fttypes.h b/ftnoir_protocol_ft/fttypes.h index 0c65fc2f..ced844dc 100644 --- a/ftnoir_protocol_ft/fttypes.h +++ b/ftnoir_protocol_ft/fttypes.h @@ -1,34 +1,21 @@ -/******************************************************************************** -* FTTypes FTTypes contains th specific type definitions for the * -* FreeTrack protocol. * -* It was loosely translated from FTTypes.pas * -* which was created by the FreeTrack-team. * -* * -* Copyright (C) 2013 Wim Vriend (Developing) * -* Ron Hendriks (Testing and Research) * -* * -* 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 . * -* * -* We would like to extend our grattitude to the creators of SweetSpotter, * -* which has become the basis of this program: "Great work guys!" * -********************************************************************************/ -/* - Modifications (last one on top): - 20130125 - WVR: Upgraded to FT2.0: now the FreeTrack protocol supports all TIR-enabled games. The memory-mapping was expanded for this purpose. -*/ +/************************************************************************************ + * * FTTypes FTTypes contains the specific type definitions for the * + * * FreeTrack protocol. * + * * It was loosely translated from FTTypes.pas * + * * which was created by the FreeTrack-team. * + * * * + * * Wim Vriend (Developing) * + * * Ron Hendriks (Testing and Research) * + * * * + * * Homepage * + * * * + * * 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. * + * * * + * * The FTTypes sources were translated from the original Delphi sources * + * * created by the FreeTrack developers. * + */ #ifndef INCLUDED_FTTYPES_H #define INCLUDED_FTTYPES_H @@ -50,8 +37,8 @@ typedef __int32 my_32bit_int; #define FREETRACK_MUTEX "FT_Mutext" struct TFreeTrackData { - int DataID; - int CamWidth; + int DataID; + int CamWidth; int CamHeight; // virtual pose float Yaw; // positive yaw to the left @@ -80,7 +67,7 @@ struct TFreeTrackData { typedef TFreeTrackData * PFreetrackData; struct FTMemMap { - TFreeTrackData data; + TFreeTrackData data; my_32bit_int GameID; unsigned char table[8]; my_32bit_int GameID2; diff --git a/qfunctionconfigurator/qfunctionconfigurator.cpp b/qfunctionconfigurator/qfunctionconfigurator.cpp index 802c0a1d..bad06f8a 100644 --- a/qfunctionconfigurator/qfunctionconfigurator.cpp +++ b/qfunctionconfigurator/qfunctionconfigurator.cpp @@ -1,37 +1,10 @@ -/******************************************************************************** -* 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 . * -* * -* The FunctionConfigurator was made by Stanislaw Halik, and adapted to * -* FaceTrackNoIR. * -* * -* All credits for this nice piece of code should go to Stanislaw. * -* * -* 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. * -********************************************************************************/ +/* Copyright (c) 2011-2012 Stanislaw Halik + * Adapted to FaceTrackNoIR by Wim Vriend. + * 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 "qfunctionconfigurator/qfunctionconfigurator.h" #include #include diff --git a/qfunctionconfigurator/qfunctionconfigurator.h b/qfunctionconfigurator/qfunctionconfigurator.h index 07eeeae3..8460751a 100644 --- a/qfunctionconfigurator/qfunctionconfigurator.h +++ b/qfunctionconfigurator/qfunctionconfigurator.h @@ -1,37 +1,9 @@ -/******************************************************************************** -* 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 . * -* * -* The FunctionConfigurator was made by Stanislaw Halik, and adapted to * -* FaceTrackNoIR. * -* * -* All credits for this nice piece of code should go to Stanislaw. * -* * -* 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. * -********************************************************************************/ +/* Copyright (c) 2011-2012 Stanislaw Halik + * Adapted to FaceTrackNoIR by Wim Vriend. + * 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 QFUNCTIONCONFIGURATOR_H #define QFUNCTIONCONFIGURATOR_H diff --git a/qfunctionconfigurator/qfunctionconfiguratorplugin.cpp b/qfunctionconfigurator/qfunctionconfiguratorplugin.cpp index 5e98eb39..9bed2c9e 100644 --- a/qfunctionconfigurator/qfunctionconfiguratorplugin.cpp +++ b/qfunctionconfigurator/qfunctionconfiguratorplugin.cpp @@ -1,37 +1,9 @@ -/******************************************************************************** -* 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 . * -* * -* The FunctionConfigurator was made by Stanislaw Halik, and adapted to * -* FaceTrackNoIR. * -* * -* All credits for this nice piece of code should go to Stanislaw. * -* * -* 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. * -********************************************************************************/ +/* Copyright (c) 2011-2012 Stanislaw Halik + * Adapted to FaceTrackNoIR by Wim Vriend. + * 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 "qfunctionconfigurator.h" #include diff --git a/qfunctionconfigurator/qfunctionconfiguratorplugin.h b/qfunctionconfigurator/qfunctionconfiguratorplugin.h index c6b65fcc..c854d3a2 100644 --- a/qfunctionconfigurator/qfunctionconfiguratorplugin.h +++ b/qfunctionconfigurator/qfunctionconfiguratorplugin.h @@ -1,3 +1,9 @@ +/* Copyright (c) 2011-2012 Stanislaw Halik + * Adapted to FaceTrackNoIR by Wim Vriend. + * 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 QFUNCTIONCONFIGURATORPLUGIN_H #define QFUNCTIONCONFIGURATORPLUGIN_H -- cgit v1.2.3 From da2158b8bf411c8d4a83895c9c7519cb45cb34ac Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 11 Oct 2013 15:08:27 +0200 Subject: add Hydra supported plat sdks Signed-off-by: Stanislaw Halik --- CMakeLists.txt | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a477dd77..d235f0e9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,9 +21,10 @@ endif() IF(WIN32) SET(SDK_SM_FACEAPI_PATH "" CACHE PATH "SeeingMachines FaceAPI SDK path") - SET(SDK_HYDRA "" CACHE PATH "libSixense path") SET(SDK_VJOY "" CACHE PATH "VJoy SDK path") ENDIF() +SET(SDK_HYDRA "" CACHE PATH "libSixense path") +SET(SDK_HYDRA_AMD64 FALSE CACHE BOOL "whether target is amd64 (else ia-32)") SET(SDK_RIFT "" CACHE PATH "libOVR path") @@ -526,9 +527,18 @@ endif() target_link_libraries(opentrack-tracker-hydra "${SDK_HYDRA}/lib/win32/release_dll/sixense.lib" "${SDK_HYDRA}/lib/win32/release_dll/sixense_utils.lib") install(FILES "${SDK_HYDRA}/bin/win32/release_dll/sixense.dll" "${SDK_HYDRA}/bin/win32/release_dll/sixense_utils.dll" DESTINATION .) - else() - target_link_libraries(opentrack-tracker-hydra "${SDK_HYDRA}/lib/win32/release_static/sixense_s.lib" "${SDK_HYDRA}/lib/win32/release_static/sixense_utils_s.lib") endif() + else() + if(SDK_HYDRA_AMD64) + set(underscore-sixtyfour _x64) + else() + set(underscore-sixtyfour) + endif() + if (APPLE) + target_link_libraries(opentrack-tracker-hydra "${SDK_HYDRA}/lib/osx${underscore-sixtyfour}/release_dll/libsixense${underscore-sixtyfour}.dylib" "${SDK_HYDRA}/lib/osx${underscore-sixtyfour}/release_dll/libsixense_utils${underscore-sixtyfour}.dylib") + else() # NB assume linux binary-compat, e.g. freebsd + target_link_libraries(opentrack-tracker-hydra "${SDK_HYDRA}/lib/linux${underscore-sixtyfour}/release_dll/libsixense${underscore-sixtyfour}.so" "${SDK_HYDRA}/lib/linux${underscore-sixtyfour}/release_dll/libsixense_utils${underscore-sixtyfour}.so") + endif() endif() if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) SET_TARGET_PROPERTIES(opentrack-tracker-hydra -- cgit v1.2.3 From 10e285066e8249850ea8f9007e2313b5fdbe9fbd Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 11 Oct 2013 15:23:48 +0200 Subject: add hydra plats linux/osx Signed-off-by: Stanislaw Halik --- CMakeLists.txt | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d235f0e9..0fd9fda0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -534,11 +534,16 @@ endif() else() set(underscore-sixtyfour) endif() - if (APPLE) - target_link_libraries(opentrack-tracker-hydra "${SDK_HYDRA}/lib/osx${underscore-sixtyfour}/release_dll/libsixense${underscore-sixtyfour}.dylib" "${SDK_HYDRA}/lib/osx${underscore-sixtyfour}/release_dll/libsixense_utils${underscore-sixtyfour}.dylib") - else() # NB assume linux binary-compat, e.g. freebsd - target_link_libraries(opentrack-tracker-hydra "${SDK_HYDRA}/lib/linux${underscore-sixtyfour}/release_dll/libsixense${underscore-sixtyfour}.so" "${SDK_HYDRA}/lib/linux${underscore-sixtyfour}/release_dll/libsixense_utils${underscore-sixtyfour}.so") + if(APPLE) + set(underscore-dll _dll) + set(soext dylib) + set(sixense-plat osx) + else() + set(underscore-dll) + set(soext so) + set(sixense-plat linux) endif() + target_link_libraries(opentrack-tracker-hydra "${SDK_HYDRA}/lib/${sixense-plat}${underscore-sixtyfour}/release${underscore-dll}/libsixense${underscore-sixtyfour}.${soext}" "${SDK_HYDRA}/lib/${sixense-plat}${underscore-sixtyfour}/release${underscore-dll}/libsixense_utils${underscore-sixtyfour}.${soext}") endif() if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) SET_TARGET_PROPERTIES(opentrack-tracker-hydra -- cgit v1.2.3 From 9bfdc0779ef425113589604652c834e1ae8432e0 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 11 Oct 2013 15:31:05 +0200 Subject: There are only shared libraries for non-win32 :( Signed-off-by: Stanislaw Halik --- CMakeLists.txt | 4 ++++ ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0fd9fda0..f263f47d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -543,6 +543,10 @@ endif() set(soext so) set(sixense-plat linux) endif() + install(FILES + "${SDK_HYDRA}/lib/${sixense-plat}${underscore-sixtyfour}/release${underscore-dll}/libsixense${underscore-sixtyfour}.${soext}" + "${SDK_HYDRA}/lib/${sixense-plat}${underscore-sixtyfour}/release${underscore-dll}/libsixense_utils${underscore-sixtyfour}.${soext}" + DESTINATION .) target_link_libraries(opentrack-tracker-hydra "${SDK_HYDRA}/lib/${sixense-plat}${underscore-sixtyfour}/release${underscore-dll}/libsixense${underscore-sixtyfour}.${soext}" "${SDK_HYDRA}/lib/${sixense-plat}${underscore-sixtyfour}/release${underscore-dll}/libsixense_utils${underscore-sixtyfour}.${soext}") endif() if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) diff --git a/ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp b/ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp index 81307cd6..2561c624 100644 --- a/ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp +++ b/ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp @@ -3,8 +3,10 @@ #include "facetracknoir/global-settings.h" #include "facetracknoir/rotation.h" #include -#define SIXENSE_STATIC_LIB -#define SIXENSE_UTILS_STATIC_LIB +#ifdef _WIN32 +# define SIXENSE_STATIC_LIB +# define SIXENSE_UTILS_STATIC_LIB +#endif #include #include #ifdef WIN32 -- cgit v1.2.3 From 0a71de67746ce83e35290f6609181cddf930d998 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 11 Oct 2013 15:42:29 +0200 Subject: update todo Signed-off-by: Stanislaw Halik --- TODO.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/TODO.txt b/TODO.txt index 91fa7b28..4194a6f0 100644 --- a/TODO.txt +++ b/TODO.txt @@ -9,3 +9,9 @@ 20131008 sh during the switch to qt5, recreate widgets, this time with layouts. the original layouts were pretty crappy, hence the original breakage. +20131011 sh + low-hanging fruit: default saving profiles to a directory in user home, + not into global stuffies + + as for build system, low-hangin fruit is writing functions/macrology + for all the repetition out there. -- 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 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 206ca67c2292cd5577e759a28a8f50501b592969 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 15 Oct 2013 05:08:16 +0200 Subject: proto-freetrack: fix layouts, end confusion Confusion ensued due to 'dummy TrackIR.exe' which people keep enabling despite it only existing for the EZCA software. Signed-off-by: Stanislaw Halik --- ftnoir_protocol_ft/ftnoir_ftcontrols.ui | 690 ++++++++++++++------------------ 1 file changed, 290 insertions(+), 400 deletions(-) diff --git a/ftnoir_protocol_ft/ftnoir_ftcontrols.ui b/ftnoir_protocol_ft/ftnoir_ftcontrols.ui index a2216314..1b78efab 100644 --- a/ftnoir_protocol_ft/ftnoir_ftcontrols.ui +++ b/ftnoir_protocol_ft/ftnoir_ftcontrols.ui @@ -12,13 +12,19 @@ 0 0 - 645 - 416 + 412 + 328 + + + 0 + 0 + + - 645 + 0 0 @@ -35,403 +41,287 @@ false - - - - - - - - 0 - 70 - - - - TIRViews - - - - - 80 - 30 - 88 - 17 - - - - Qt::RightToLeft - - - Use TIRViews - - - - - - 189 - 10 - 421 - 16 - - - - TIRViews is only required for some older games (like CFS3). For it to work, TIRViews.dll - - - - - - 189 - 30 - 421 - 16 - - - - must be placed in the FaceTrackNoIR program folder. If the checkbox is disabled, the - - - true - - - - - - 189 - 50 - 411 - 16 - - - - the DLL was not found. You can get it from NaturalPoint. - - - - - - - - - 0 - 70 - - - - TrackIR.exe - - - - - 20 - 30 - 145 - 17 - - - - Qt::RightToLeft - - - Start dummy TrackIR.exe - - - - - - 189 - 10 - 351 - 16 - - - - Some programs check, to see if a process called TrackIR.exe is running, - - - - - - 189 - 30 - 261 - 16 - - - - before enabling head-tracking (EZCA is one of them). - - - true - - - - - - 189 - 50 - 231 - 16 - - - - Check the checkbox, to overcome this problem. - - - - - - - - - 0 - 70 - - - - Select interface - - - - - 189 - 10 - 351 - 16 - - - - Some games support both FreeTrack and TrackIR and may get confused, - - - - - - 189 - 30 - 261 - 16 - - - - when both interfaces are visible. - - - true - - - - - - 189 - 50 - 381 - 16 - - - - Try to disable one interface, if you experience problems. - - - - - - 6 - 30 - 168 - 22 - - - - - - - - - - 0 - 70 - - - - Repair NPClient location - - - - - 188 - 10 - 381 - 20 - - - - Users who use other software with an NPClient DLL (like TrackIR, FreeTrack or - - - - - - 184 - 30 - 411 - 20 - - - - GlovePIE) may need to repair the location of the DLL, after running FaceTrackNoIR. - - - true - - - - - - 187 - 50 - 391 - 20 - - - - Use this button to locate the desired NPClient DLL. - - - - - - 4 - 30 - 171 - 23 - - - - Locate DLL - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - QLayout::SetDefaultConstraint - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - OK - - - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - Cancel - - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 10 - 20 - - - - - - - + + + true + + + + 320 + 300 + 80 + 23 + + + + + 0 + 0 + + + + + 0 + 0 + + + + + 100 + 16777215 + + + + Cancel + + + + + true + + + + 230 + 300 + 80 + 23 + + + + + 0 + 0 + + + + + 0 + 0 + + + + + 100 + 16777215 + + + + OK + + + + + + 10 + 6 + 401 + 70 + + + + + 0 + 70 + + + + TIRViews + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + 30 + 40 + 78 + 19 + + + + Qt::RightToLeft + + + TRViews + + + + + + 120 + 30 + 281 + 41 + + + + Only for very old and buggy old games such as CFS3. + + + false + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + true + + + + + + + 10 + 68 + 401 + 70 + + + + + 0 + 70 + + + + TrackIR.exe + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + 8 + 30 + 100 + 19 + + + + Qt::RightToLeft + + + Using EZCA + + + + + + 120 + 23 + 250 + 51 + + + + Spawn a useless "dummy" process called TrackIR.exe in order to fool EZCA. + + + true + + + + + + + 10 + 144 + 401 + 70 + + + + + 0 + 70 + + + + Select interface + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + 120 + 23 + 275 + 41 + + + + Disable one of the protocols if games are confused by presence of both at the same time. + + + true + + + + + + 10 + 30 + 95 + 23 + + + + + + + + 10 + 220 + 401 + 70 + + + + + 0 + 70 + + + + Repair NPClient location + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + 120 + 23 + 278 + 51 + + + + Replace the registry entry if you want to use other software with the TrackIR protocol and it doesn't work automatically. + + + true + + + + + + 8 + 23 + 93 + 23 + + + + Locate DLL + + + -- cgit v1.2.3 From a73f49c89299ec69dda73e3e7a16cebe76da373e Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 15 Oct 2013 08:48:22 +0200 Subject: finished cmake makefile for qt5 --- CMakeLists.txt | 163 +++++++++++++++++++++++++++------------------------------ 1 file changed, 78 insertions(+), 85 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f263f47d..09f55da6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,9 +6,20 @@ 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}") +set(CMAKE_INCLUDE_CURRENT_DIR ON) +set(CMAKE_AUTOMOC ON) +set(CMAKE_POSITION_INDEPENDENT_CODE ON) add_definitions(-DOPENTRACK_API) +if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + add_definitions(-std=c++11) +endif() + +if(CMAKE_COMPILER_IS_GNUCXX) + add_definitions(-std=c++11) +endif() + if(UNIX) set(SDK_ENABLE_LIBEVDEV FALSE CACHE BOOL "libevdev virtual joystick protocol support (probably Linux only)") endif() @@ -39,26 +50,10 @@ include_directories(${CMAKE_SOURCE_DIR}) if(NOT SDK_FACEAPI_ONLY) find_package(OpenCV) - find_package(Qt4 COMPONENTS QtCore QtGui QtDesigner QtXml QtNetwork REQUIRED) - - if(NOT WIN32) - if(NOT QXT_QXTGUI_LIB_RELEASE) - find_package(Qxt COMPONENTS QxtGui REQUIRED) - endif() + find_package(Qt5 REQUIRED COMPONENTS Core Xml Network Widgets Gui QUIET) + 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}) - if(NOT QXT_QXTGUI_INCLUDE_DIR OR QXT_QXTGUI_INCLUDE_DIR STREQUAL "QXT_QXTGUI_INCLUDE_DIR-NOTFOUND") - message(FATAL_ERROR "Qxt not found, required for keybindings, get from http://libqxt.org") - endif() - - include_directories(${QXT_QXTGUI_INCLUDE_DIR}) - include_directories(${QXT_QXTCORE_INCLUDE_DIR}) - if(EXISTS "${QXT_QXTCORE_INCLUDE_DIR}/QxtCore/") - include_directories(${QXT_QXTCORE_INCLUDE_DIR}/QxtCore) - endif() - if(EXISTS "${QXT_QXTGUI_INCLUDE_DIR}/QxtGui/") - include_directories(${QXT_QXTGUI_INCLUDE_DIR}/QxtGui) - endif() - endif() INCLUDE_DIRECTORIES(${QT_QTDESIGNER_INCLUDE_DIR}) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) @@ -107,175 +102,164 @@ if(SDK_FSUIPC AND WIN32) endif() if(NOT SDK_FACEAPI_ONLY) +# Qxt bundled :: sorry for this, but gentoo ebuild is broken + if(APPLE) + set(qxt-mini-c qxt-mini/plat/qxtglobalshortcut_mac.cpp qxt-mini/qxtglobalshortcut.cpp) + include_directories("qxt-mini/") + else() + if(UNIX) + set(qxt-mini-c qxt-mini/plat/qxtglobalshortcut_x11.cpp qxt-mini/qxtglobalshortcut.cpp) + include_directories("qxt-mini/") + endif() + endif() # main app file(GLOB opentrack-bin-c "facetracknoir/*.cpp" "facetracknoir/*.rc") file(GLOB opentrack-bin-h "facetracknoir/*.h") - QT4_WRAP_CPP(opentrack-bin-moc ${opentrack-bin-h}) file(GLOB opentrack-bin-ui "facetracknoir/*.ui") file(GLOB opentrack-bin-rc "facetracknoir/*.qrc") - QT4_WRAP_UI(opentrack-bin-uih ${opentrack-bin-ui}) - QT4_ADD_RESOURCES(opentrack-bin-rcc ${opentrack-bin-rc}) + QT5_WRAP_UI(opentrack-bin-uih ${opentrack-bin-ui}) + QT5_ADD_RESOURCES(opentrack-bin-rcc ${opentrack-bin-rc}) file(GLOB opentrack-pose-widget-c "ftnoir_posewidget/*.cpp") file(GLOB opentrack-pose-widget-h "ftnoir_posewidget/*.h") - QT4_WRAP_CPP(opentrack-pose-widget-moc ${opentrack-pose-widget-h}) file(GLOB opentrack-pose-widget-rc "ftnoir_posewidget/*.qrc") - QT4_ADD_RESOURCES(opentrack-pose-widget-rcc ${opentrack-pose-widget-rc}) + QT5_ADD_RESOURCES(opentrack-pose-widget-rcc ${opentrack-pose-widget-rc}) file(GLOB opentrack-spline-widget-c "qfunctionconfigurator/*.cpp") file(GLOB opentrack-spline-widget-h "qfunctionconfigurator/*.h") - QT4_WRAP_CPP(opentrack-spline-widget-moc ${opentrack-spline-widget-h}) # filters file(GLOB opentrack-filter-accela-c "ftnoir_filter_accela/*.cpp") file(GLOB opentrack-filter-accela-h "ftnoir_filter_accela/*.h") - QT4_WRAP_CPP(opentrack-filter-accela-moc ${opentrack-filter-accela-h}) file(GLOB opentrack-filter-accela-ui "ftnoir_filter_accela/*.ui") file(GLOB opentrack-filter-accela-rc "ftnoir_filter_accela/*.qrc") - QT4_WRAP_UI(opentrack-filter-accela-uih ${opentrack-filter-accela-ui}) - QT4_ADD_RESOURCES(opentrack-filter-accela-rcc ${opentrack-filter-accela-rc}) + QT5_WRAP_UI(opentrack-filter-accela-uih ${opentrack-filter-accela-ui}) + QT5_ADD_RESOURCES(opentrack-filter-accela-rcc ${opentrack-filter-accela-rc}) file(GLOB opentrack-filter-ewma-c "ftnoir_filter_ewma2/*.cpp") file(GLOB opentrack-filter-ewma-h "ftnoir_filter_ewma2/*.h") - QT4_WRAP_CPP(opentrack-filter-ewma-moc ${opentrack-filter-ewma-h}) file(GLOB opentrack-filter-ewma-ui "ftnoir_filter_ewma2/*.ui") file(GLOB opentrack-filter-ewma-rc "ftnoir_filter_ewma2/*.qrc") - QT4_WRAP_UI(opentrack-filter-ewma-uih ${opentrack-filter-ewma-ui}) - QT4_ADD_RESOURCES(opentrack-filter-ewma-rcc ${opentrack-filter-ewma-rc}) + QT5_WRAP_UI(opentrack-filter-ewma-uih ${opentrack-filter-ewma-ui}) + QT5_ADD_RESOURCES(opentrack-filter-ewma-rcc ${opentrack-filter-ewma-rc}) # protocols file(GLOB opentrack-proto-fgfs-c "ftnoir_protocol_fg/*.cpp") file(GLOB opentrack-proto-fgfs-h "ftnoir_protocol_fg/*.h") - QT4_WRAP_CPP(opentrack-proto-fgfs-moc ${opentrack-proto-fgfs-h}) file(GLOB opentrack-proto-fgfs-ui "ftnoir_protocol_fg/*.ui") file(GLOB opentrack-proto-fgfs-rc "ftnoir_protocol_fg/*.qrc") - QT4_WRAP_UI(opentrack-proto-fgfs-uih ${opentrack-proto-fgfs-ui}) - QT4_ADD_RESOURCES(opentrack-proto-fgfs-rcc ${opentrack-proto-fgfs-rc}) + QT5_WRAP_UI(opentrack-proto-fgfs-uih ${opentrack-proto-fgfs-ui}) + QT5_ADD_RESOURCES(opentrack-proto-fgfs-rcc ${opentrack-proto-fgfs-rc}) file(GLOB opentrack-proto-fsuipc-c "ftnoir_protocol_fsuipc/*.cpp") file(GLOB opentrack-proto-fsuipc-h "ftnoir_protocol_fsuipc/*.h") - QT4_WRAP_CPP(opentrack-proto-fsuipc-moc ${opentrack-proto-fsuipc-h}) file(GLOB opentrack-proto-fsuipc-ui "ftnoir_protocol_fsuipc/*.ui") file(GLOB opentrack-proto-fsuipc-rc "ftnoir_protocol_fsuipc/*.qrc") - QT4_WRAP_UI(opentrack-proto-fsuipc-uih ${opentrack-proto-fsuipc-ui}) - QT4_ADD_RESOURCES(opentrack-proto-fsuipc-rcc ${opentrack-proto-fsuipc-rc}) + QT5_WRAP_UI(opentrack-proto-fsuipc-uih ${opentrack-proto-fsuipc-ui}) + QT5_ADD_RESOURCES(opentrack-proto-fsuipc-rcc ${opentrack-proto-fsuipc-rc}) file(GLOB opentrack-proto-freetrack-c "ftnoir_protocol_ft/*.cpp") file(GLOB opentrack-proto-freetrack-h "ftnoir_protocol_ft/*.h") - QT4_WRAP_CPP(opentrack-proto-freetrack-moc ${opentrack-proto-freetrack-h}) file(GLOB opentrack-proto-freetrack-ui "ftnoir_protocol_ft/*.ui") file(GLOB opentrack-proto-freetrack-rc "ftnoir_protocol_ft/*.qrc") - QT4_WRAP_UI(opentrack-proto-freetrack-uih ${opentrack-proto-freetrack-ui}) - QT4_ADD_RESOURCES(opentrack-proto-freetrack-rcc ${opentrack-proto-freetrack-rc}) + QT5_WRAP_UI(opentrack-proto-freetrack-uih ${opentrack-proto-freetrack-ui}) + QT5_ADD_RESOURCES(opentrack-proto-freetrack-rcc ${opentrack-proto-freetrack-rc}) file(GLOB opentrack-proto-udp-c "ftnoir_protocol_ftn/*.cpp") file(GLOB opentrack-proto-udp-h "ftnoir_protocol_ftn/*.h") - QT4_WRAP_CPP(opentrack-proto-udp-moc ${opentrack-proto-udp-h}) file(GLOB opentrack-proto-udp-ui "ftnoir_protocol_ftn/*.ui") file(GLOB opentrack-proto-udp-rc "ftnoir_protocol_ftn/*.qrc") - QT4_WRAP_UI(opentrack-proto-udp-uih ${opentrack-proto-udp-ui}) - QT4_ADD_RESOURCES(opentrack-proto-udp-rcc ${opentrack-proto-udp-rc}) + QT5_WRAP_UI(opentrack-proto-udp-uih ${opentrack-proto-udp-ui}) + QT5_ADD_RESOURCES(opentrack-proto-udp-rcc ${opentrack-proto-udp-rc}) file(GLOB opentrack-proto-wine-c "ftnoir_protocol_wine/*.cpp") file(GLOB opentrack-proto-wine-h "ftnoir_protocol_wine/*.h") - QT4_WRAP_CPP(opentrack-proto-wine-moc ${opentrack-proto-wine-h}) file(GLOB opentrack-proto-wine-ui "ftnoir_protocol_wine/*.ui") file(GLOB opentrack-proto-wine-rc "ftnoir_protocol_wine/*.qrc") - QT4_WRAP_UI(opentrack-proto-wine-uih ${opentrack-proto-wine-ui}) - QT4_ADD_RESOURCES(opentrack-proto-wine-rcc ${opentrack-proto-wine-rc}) + QT5_WRAP_UI(opentrack-proto-wine-uih ${opentrack-proto-wine-ui}) + QT5_ADD_RESOURCES(opentrack-proto-wine-rcc ${opentrack-proto-wine-rc}) file(GLOB opentrack-proto-win32-mouse-c "ftnoir_protocol_mouse/*.cpp") file(GLOB opentrack-proto-win32-mouse-h "ftnoir_protocol_mouse/*.h") - QT4_WRAP_CPP(opentrack-proto-win32-mouse-moc ${opentrack-proto-win32-mouse-h}) file(GLOB opentrack-proto-win32-mouse-ui "ftnoir_protocol_mouse/*.ui") file(GLOB opentrack-proto-win32-mouse-rc "ftnoir_protocol_mouse/*.qrc") - QT4_WRAP_UI(opentrack-proto-win32-mouse-uih ${opentrack-proto-win32-mouse-ui}) - QT4_ADD_RESOURCES(opentrack-proto-win32-mouse-rcc ${opentrack-proto-win32-mouse-rc}) + QT5_WRAP_UI(opentrack-proto-win32-mouse-uih ${opentrack-proto-win32-mouse-ui}) + QT5_ADD_RESOURCES(opentrack-proto-win32-mouse-rcc ${opentrack-proto-win32-mouse-rc}) file(GLOB opentrack-proto-simconnect-c "ftnoir_protocol_sc/*.cpp" "ftnoir_protocol_sc/ftnoir-protocol-sc.rc") file(GLOB opentrack-proto-simconnect-h "ftnoir_protocol_sc/*.h") - QT4_WRAP_CPP(opentrack-proto-simconnect-moc ${opentrack-proto-simconnect-h}) file(GLOB opentrack-proto-simconnect-ui "ftnoir_protocol_sc/*.ui") file(GLOB opentrack-proto-simconnect-rc "ftnoir_protocol_sc/*.qrc") - QT4_WRAP_UI(opentrack-proto-simconnect-uih ${opentrack-proto-simconnect-ui}) - QT4_ADD_RESOURCES(opentrack-proto-simconnect-rcc ${opentrack-proto-simconnect-rc}) + QT5_WRAP_UI(opentrack-proto-simconnect-uih ${opentrack-proto-simconnect-ui}) + QT5_ADD_RESOURCES(opentrack-proto-simconnect-rcc ${opentrack-proto-simconnect-rc}) file(GLOB opentrack-proto-vjoy-c "ftnoir_protocol_vjoy/*.cpp") file(GLOB opentrack-proto-vjoy-h "ftnoir_protocol_vjoy/*.h") - QT4_WRAP_CPP(opentrack-proto-vjoy-moc ${opentrack-proto-vjoy-h}) file(GLOB opentrack-proto-vjoy-ui "ftnoir_protocol_vjoy/*.ui") file(GLOB opentrack-proto-vjoy-rc "ftnoir_protocol_vjoy/*.qrc") - QT4_WRAP_UI(opentrack-proto-vjoy-uih ${opentrack-proto-vjoy-ui}) - QT4_ADD_RESOURCES(opentrack-proto-vjoy-rcc ${opentrack-proto-vjoy-rc}) + QT5_WRAP_UI(opentrack-proto-vjoy-uih ${opentrack-proto-vjoy-ui}) + QT5_ADD_RESOURCES(opentrack-proto-vjoy-rcc ${opentrack-proto-vjoy-rc}) file(GLOB opentrack-proto-libevdev-c "ftnoir_protocol_libevdev/*.cpp") file(GLOB opentrack-proto-libevdev-h "ftnoir_protocol_libevdev/*.h") - QT4_WRAP_CPP(opentrack-proto-libevdev-moc ${opentrack-proto-libevdev-h}) file(GLOB opentrack-proto-libevdev-ui "ftnoir_protocol_libevdev/*.ui") file(GLOB opentrack-proto-libevdev-rc "ftnoir_protocol_libevdev/*.qrc") - QT4_WRAP_UI(opentrack-proto-libevdev-uih ${opentrack-proto-libevdev-ui}) - QT4_ADD_RESOURCES(opentrack-proto-libevdev-rcc ${opentrack-proto-libevdev-rc}) + QT5_WRAP_UI(opentrack-proto-libevdev-uih ${opentrack-proto-libevdev-ui}) + QT5_ADD_RESOURCES(opentrack-proto-libevdev-rcc ${opentrack-proto-libevdev-rc}) # trackers file(GLOB opentrack-tracker-ht-c "ftnoir_tracker_ht/*.cpp") file(GLOB opentrack-tracker-ht-h "ftnoir_tracker_ht/*.h") - QT4_WRAP_CPP(opentrack-tracker-ht-moc ${opentrack-tracker-ht-h}) file(GLOB opentrack-tracker-ht-ui "ftnoir_tracker_ht/*.ui") file(GLOB opentrack-tracker-ht-rc "ftnoir_tracker_ht/*.qrc") - QT4_WRAP_UI(opentrack-tracker-ht-uih ${opentrack-tracker-ht-ui}) - QT4_ADD_RESOURCES(opentrack-tracker-ht-rcc ${opentrack-tracker-ht-rc}) + QT5_WRAP_UI(opentrack-tracker-ht-uih ${opentrack-tracker-ht-ui}) + QT5_ADD_RESOURCES(opentrack-tracker-ht-rcc ${opentrack-tracker-ht-rc}) file(GLOB opentrack-tracker-aruco-c "ftnoir_tracker_aruco/*.cpp") file(GLOB opentrack-tracker-aruco-h "ftnoir_tracker_aruco/*.h") - QT4_WRAP_CPP(opentrack-tracker-aruco-moc ${opentrack-tracker-aruco-h}) file(GLOB opentrack-tracker-aruco-ui "ftnoir_tracker_aruco/*.ui") file(GLOB opentrack-tracker-aruco-rc "ftnoir_tracker_aruco/*.qrc") - QT4_WRAP_UI(opentrack-tracker-aruco-uih ${opentrack-tracker-aruco-ui}) - QT4_ADD_RESOURCES(opentrack-tracker-aruco-rcc ${opentrack-tracker-aruco-rc}) + QT5_WRAP_UI(opentrack-tracker-aruco-uih ${opentrack-tracker-aruco-ui}) + QT5_ADD_RESOURCES(opentrack-tracker-aruco-rcc ${opentrack-tracker-aruco-rc}) file(GLOB opentrack-tracker-pt-c "FTNoIR_Tracker_PT/*.cpp") file(GLOB opentrack-tracker-pt-h "FTNoIR_Tracker_PT/*.h") - QT4_WRAP_CPP(opentrack-tracker-pt-moc ${opentrack-tracker-pt-h}) file(GLOB opentrack-tracker-pt-ui "FTNoIR_Tracker_PT/*.ui") file(GLOB opentrack-tracker-pt-rc "FTNoIR_Tracker_PT/*.qrc") - QT4_WRAP_UI(opentrack-tracker-pt-uih ${opentrack-tracker-pt-ui}) - QT4_ADD_RESOURCES(opentrack-tracker-pt-rcc ${opentrack-tracker-pt-rc}) + QT5_WRAP_UI(opentrack-tracker-pt-uih ${opentrack-tracker-pt-ui}) + QT5_ADD_RESOURCES(opentrack-tracker-pt-rcc ${opentrack-tracker-pt-rc}) file(GLOB opentrack-tracker-udp-c "ftnoir_tracker_udp/*.cpp") file(GLOB opentrack-tracker-udp-h "ftnoir_tracker_udp/*.h") - QT4_WRAP_CPP(opentrack-tracker-udp-moc ${opentrack-tracker-udp-h}) file(GLOB opentrack-tracker-udp-ui "ftnoir_tracker_udp/*.ui") file(GLOB opentrack-tracker-udp-rc "ftnoir_tracker_udp/*.qrc") - QT4_WRAP_UI(opentrack-tracker-udp-uih ${opentrack-tracker-udp-ui}) - QT4_ADD_RESOURCES(opentrack-tracker-udp-rcc ${opentrack-tracker-udp-rc}) + QT5_WRAP_UI(opentrack-tracker-udp-uih ${opentrack-tracker-udp-ui}) + QT5_ADD_RESOURCES(opentrack-tracker-udp-rcc ${opentrack-tracker-udp-rc}) file(GLOB opentrack-tracker-rift-c "ftnoir_tracker_rift/*.cpp") file(GLOB opentrack-tracker-rift-h "ftnoir_tracker_rift/*.h") - QT4_WRAP_CPP(opentrack-tracker-rift-moc ${opentrack-tracker-rift-h}) file(GLOB opentrack-tracker-rift-ui "ftnoir_tracker_rift/*.ui") file(GLOB opentrack-tracker-rift-rc "ftnoir_tracker_rift/*.qrc") - QT4_WRAP_UI(opentrack-tracker-rift-uih ${opentrack-tracker-rift-ui}) - QT4_ADD_RESOURCES(opentrack-tracker-rift-rcc ${opentrack-tracker-rift-rc}) + QT5_WRAP_UI(opentrack-tracker-rift-uih ${opentrack-tracker-rift-ui}) + QT5_ADD_RESOURCES(opentrack-tracker-rift-rcc ${opentrack-tracker-rift-rc}) file(GLOB opentrack-tracker-hydra-c "ftnoir_tracker_hydra/*.cpp") file(GLOB opentrack-tracker-hydra-h "ftnoir_tracker_hydra/*.h") - QT4_WRAP_CPP(opentrack-tracker-hydra-moc ${opentrack-tracker-hydra-h}) file(GLOB opentrack-tracker-hydra-ui "ftnoir_tracker_hydra/*.ui") file(GLOB opentrack-tracker-hydra-rc "ftnoir_tracker_hydra/*.qrc") - QT4_WRAP_UI(opentrack-tracker-hydra-uih ${opentrack-tracker-hydra-ui}) - QT4_ADD_RESOURCES(opentrack-tracker-hydra-rcc ${opentrack-tracker-hydra-rc}) + 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-faceapi-c "ftnoir_tracker_sm/*.cpp") file(GLOB opentrack-tracker-faceapi-h "ftnoir_tracker_sm/*.h") - QT4_WRAP_CPP(opentrack-tracker-faceapi-moc ${opentrack-tracker-faceapi-h}) file(GLOB opentrack-tracker-faceapi-ui "ftnoir_tracker_sm/*.ui") file(GLOB opentrack-tracker-faceapi-rc "ftnoir_tracker_sm/*.qrc") - QT4_WRAP_UI(opentrack-tracker-faceapi-uih ${opentrack-tracker-faceapi-ui}) - QT4_ADD_RESOURCES(opentrack-tracker-faceapi-rcc ${opentrack-tracker-faceapi-rc}) + QT5_WRAP_UI(opentrack-tracker-faceapi-uih ${opentrack-tracker-faceapi-ui}) + QT5_ADD_RESOURCES(opentrack-tracker-faceapi-rcc ${opentrack-tracker-faceapi-rc}) file(GLOB opentrack-csv-c "ftnoir_csv/*.cpp") @@ -321,11 +305,7 @@ endif() target_link_libraries(opentrack-compat rt) endif() - IF(CMAKE_BUILD_TYPE MATCHES DEBUG) - SET(MY_QT_LIBS ${QT_QTCORE_LIBRARY_DEBUG} ${QT_QTGUI_LIBRARY_DEBUG} ${QT_QTNETWORK_LIBRARY_DEBUG} ${QT_QTXML_LIBRARY_DEBUG}) - ELSE() - SET(MY_QT_LIBS ${QT_QTCORE_LIBRARY_RELEASE} ${QT_QTGUI_LIBRARY_RELEASE} ${QT_QTNETWORK_LIBRARY_RELEASE} ${QT_QTXML_LIBRARY_RELEASE}) - ENDIF() + SET(MY_QT_LIBS ${Qt5Widgets_LIBRARIES} ${Qt5Gui_LIBRARIES} ${Qt5Network_LIBRARIES} ${Qt5Xml_LIBRARIES} ${Qt5Core_LIBRARIES}) add_library(opentrack-csv SHARED ${opentrack-csv-c}) target_link_libraries(opentrack-csv ${MY_QT_LIBS}) @@ -564,7 +544,20 @@ endif() else() set(opentrack-win32-executable "") endif() + if(UNIX) + 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}) + endif() add_executable(opentrack ${opentrack-win32-executable} ${opentrack-bin-c} ${opentrack-bin-moc} ${opentrack-bin-uih} ${opentrack-bin-rcc}) + if(UNIX) + target_link_libraries(opentrack opentrack-qxt-mini) + endif() + + if(UNIX) + install(TARGETS opentrack-qxt-mini DESTINATION .) + endif() + if(WIN32) target_link_libraries(opentrack "${CMAKE_SOURCE_DIR}/dinput/dinput8.lib" "${CMAKE_SOURCE_DIR}/dinput/dxguid.lib" @@ -576,7 +569,7 @@ endif() if(MSVC) SET_TARGET_PROPERTIES(opentrack PROPERTIES LINK_FLAGS "/ENTRY:mainCRTStartup") endif() - target_link_libraries(opentrack opentrack-pose-widget opentrack-spline-widget ${MY_QT_LIBS} ${QXT_QXTCORE_LIB_RELEASE} ${QXT_QXTGUI_LIB_RELEASE}) + target_link_libraries(opentrack opentrack-pose-widget opentrack-spline-widget ${MY_QT_LIBS} ${QXT_QXTCORE_LIB_RELEASE} ${QXT_QXTWIDGETS_LIB_RELEASE}) if(NOT WIN32) target_link_libraries(opentrack dl) endif() -- 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 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 0a226bcfc232553c19723cbcd76e53ff3827a25e Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 15 Oct 2013 08:52:42 +0200 Subject: adjust obsolete toAscii() Signed-off-by: Stanislaw Halik --- ftnoir_csv/csv.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ftnoir_csv/csv.cpp b/ftnoir_csv/csv.cpp index 26b675fc..4753e8df 100644 --- a/ftnoir_csv/csv.cpp +++ b/ftnoir_csv/csv.cpp @@ -136,7 +136,7 @@ void CSV::getGameData( const int id, unsigned char* table, QString& gamename) // if (gameLine.count() > 6) { if (gameLine.at(6).compare( gameID, Qt::CaseInsensitive ) == 0) { - QByteArray id = gameLine.at(7).toAscii(); + QByteArray id = gameLine.at(7).toLatin1(); int tmp[8]; int fuzz[3]; if (gameLine.at(3) == QString("V160")) @@ -177,4 +177,4 @@ void CSV::getGameData( const int id, unsigned char* table, QString& gamename) // qDebug() << "Unknown game connected" << gameID; file.close(); -} \ No newline at end of file +} -- cgit v1.2.3 From e3c36cc73d7cdcaa51bfb5e2b80709f636385d1f Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 15 Oct 2013 08:53:04 +0200 Subject: drop designer plugins for now, no time to fix them Signed-off-by: Stanislaw Halik --- cmake/FindQxt.cmake | 155 --------------------- .../broken/qfunctionconfiguratorplugin.cpp | 118 ++++++++++++++++ .../broken/qfunctionconfiguratorplugin.h | 37 +++++ .../qfunctionconfiguratorplugin.cpp | 118 ---------------- .../qfunctionconfiguratorplugin.h | 36 ----- 5 files changed, 155 insertions(+), 309 deletions(-) delete mode 100644 cmake/FindQxt.cmake create mode 100644 qfunctionconfigurator/broken/qfunctionconfiguratorplugin.cpp create mode 100644 qfunctionconfigurator/broken/qfunctionconfiguratorplugin.h delete mode 100644 qfunctionconfigurator/qfunctionconfiguratorplugin.cpp delete mode 100644 qfunctionconfigurator/qfunctionconfiguratorplugin.h diff --git a/cmake/FindQxt.cmake b/cmake/FindQxt.cmake deleted file mode 100644 index 1ddfa0dd..00000000 --- a/cmake/FindQxt.cmake +++ /dev/null @@ -1,155 +0,0 @@ -############# -## basic FindQxt.cmake -## This is an *EXTREMELY BASIC* cmake find/config file for -## those times you have a cmake project and wish to use -## libQxt. -## -## It should be noted that at the time of writing, that -## I (mschnee) have an extremely limited understanding of the -## way Find*.cmake files work, but I have attempted to -## emulate what FindQt4.cmake and a few others do. -## -## To enable a specific component, set your QXT_USE_${modname}: -## SET(QXT_USE_QXTCORE TRUE) -## SET(QXT_USE_QXTGUI FALSE) -## Currently available components: -## QxtCore, QxtGui, QxtNetwork, QxtWeb, QxtSql -## Auto-including directories are enabled with INCLUDE_DIRECTORIES(), but -## can be accessed if necessary via ${QXT_INCLUDE_DIRS} -## -## To add the libraries to your build, TARGET_LINK_LIBRARIES(), such as... -## TARGET_LINK_LIBRARIES(YourTargetNameHere ${QXT_LIBRARIES}) -## ...or.. -## TARGET_LINK_LIBRARIES(YourTargetNameHere ${QT_LIBRARIES} ${QXT_LIBRARIES}) -################### TODO: -## The purpose of this cmake file is to find what components -## exist, regardless of how libQxt was build or configured, thus -## it should search/find all possible options. As I am not aware -## that any module requires anything special to be used, adding all -## modules to ${QXT_MODULES} below should be sufficient. -## Eventually, there should be version numbers, but -## I am still too unfamiliar with cmake to determine how to do -## version checks and comparisons. -## At the moment, this cmake returns a failure if you -## try to use a component that doesn't exist. I don't know how to -## set up warnings. -## It would be nice having a FindQxt.cmake and a UseQxt.cmake -## file like done for Qt - one to check for everything in advance - -############## - -###### setup -SET(QXT_MODULES QxtGui QxtWeb QxtZeroConf QxtNetwork QxtSql QxtBerkeley QxtCore) -SET(QXT_FOUND_MODULES) -FOREACH(mod ${QXT_MODULES}) - STRING(TOUPPER ${mod} U_MOD) - SET(QXT_${U_MOD}_INCLUDE_DIR NOTFOUND) - SET(QXT_${U_MOD}_LIB_DEBUG NOTFOUND) - SET(QXT_${U_MOD}_LIB_RELEASE NOTFOUND) - SET(QXT_FOUND_${U_MOD} FALSE) -ENDFOREACH(mod) -SET(QXT_QXTGUI_DEPENDSON QxtCore) -SET(QXT_QXTWEB_DEPENDSON QxtCore QxtNetwork) -SET(QXT_QXTZEROCONF_DEPENDSON QxtCore QxtNetwork) -SET(QXT_QXTNETWORK_DEPENDSON QxtCore) -SET(QXT_QXTQSQL_DEPENDSON QxtCore) -SET(QXT_QXTBERKELEY_DEPENDSON QxtCore) - -FOREACH(mod ${QXT_MODULES}) - STRING(TOUPPER ${mod} U_MOD) - IF(NOT ${U_MOD}_INCLUDE_DIR) - FIND_PATH(QXT_${U_MOD}_INCLUDE_DIR NAME ${mod} - PATH_SUFFIXES ${mod} include/${mod} - qxt/include/${mod} include/qxt/${mod} - Qxt/include/${mod} include/Qxt/${mod} - PATHS - ~/Library/Frameworks/ - /Library/Frameworks/ - /sw/ - /usr/local/ - /usr - /opt/local/ - /opt/csw - /opt - "C:/Program Files/libqxt/include" - "C:/Program Files (x86)/libqxt/include" - NO_DEFAULT_PATH - ) - FIND_LIBRARY(QXT_${U_MOD}_LIB_RELEASE NAME ${mod} - PATH_SUFFIXES Qxt/lib64 Qxt/lib lib64 lib lib/${CMAKE_LIBRARY_ARCHITECTURE} - PATHS - /sw - /usr/local - /usr - /opt/local - /opt/csw - /opt - "C:/Program Files/libqxt" - "C:/Program Files (x86)/libqxt" - NO_DEFAULT_PATH - ) - FIND_LIBRARY(QXT_${U_MOD}_LIB_DEBUG NAME ${mod}d - PATH_SUFFIXES Qxt/lib64 Qxt/lib lib64 lib lib/${CMAKE_LIBRARY_ARCHITECTURE} - PATHS - /sw - /usr/local - /usr - /opt/local - /opt/csw - /opt - "C:/Program Files/libqxt/" - "C:/Program Files (x86)/libqxt/" - NO_DEFAULT_PATH - ) - IF (QXT_${U_MOD}_LIB_RELEASE) - SET(QXT_FOUND_MODULES "${QXT_FOUND_MODULES} ${mod}") - ENDIF (QXT_${U_MOD}_LIB_RELEASE) - - IF (QXT_${U_MOD}_LIB_DEBUG) - SET(QXT_FOUND_MODULES "${QXT_FOUND_MODULES} ${mod}") - ENDIF (QXT_${U_MOD}_LIB_DEBUG) - ENDIF() -ENDFOREACH(mod) - -FOREACH(mod ${QXT_MODULES}) - STRING(TOUPPER ${mod} U_MOD) - IF(QXT_${U_MOD}_INCLUDE_DIR AND QXT_${U_MOD}_LIB_RELEASE) - SET(QXT_FOUND_${U_MOD} TRUE) - ENDIF(QXT_${U_MOD}_INCLUDE_DIR AND QXT_${U_MOD}_LIB_RELEASE) -ENDFOREACH(mod) - - -##### find and include -# To use a Qxt Library.... -# SET(QXT_FIND_COMPONENTS QxtCore, QxtGui) -# ...and this will do the rest -IF( QXT_FIND_COMPONENTS ) - FOREACH( component ${QXT_FIND_COMPONENTS} ) - STRING( TOUPPER ${component} _COMPONENT ) - SET(QXT_USE_${_COMPONENT}_COMPONENT TRUE) - ENDFOREACH( component ) -ENDIF( QXT_FIND_COMPONENTS ) - -SET(QXT_LIBRARIES "") -SET(QXT_INCLUDE_DIRS "") - -# like FindQt4.cmake, in order of dependence -FOREACH( module ${QXT_MODULES} ) - STRING(TOUPPER ${module} U_MOD) - IF(QXT_USE_${U_MOD} OR QXT_DEPENDS_${U_MOD}) - IF(QXT_FOUND_${U_MOD}) - STRING(REPLACE "QXT" "" qxt_module_def "${U_MOD}") - ADD_DEFINITIONS(-DQXT_${qxt_module_def}_LIB) - SET(QXT_INCLUDE_DIRS ${QXT_INCLUDE_DIRS} ${QXT_${U_MOD}_INCLUDE_DIR}) - INCLUDE_DIRECTORIES(${QXT_${U_MOD}_INCLUDE_DIR}) - SET(QXT_LIBRARIES ${QXT_LIBRARIES} ${QXT_${U_MOD}_LIB_RELEASE}) - ELSE(QXT_FOUND_${U_MOD}) - MESSAGE("Could not find Qxt Module ${module}") - RETURN() - ENDIF(QXT_FOUND_${U_MOD}) - FOREACH(dep QXT_${U_MOD}_DEPENDSON) - SET(QXT_DEPENDS_${dep} TRUE) - ENDFOREACH(dep) - ENDIF(QXT_USE_${U_MOD} OR QXT_DEPENDS_${U_MOD}) -ENDFOREACH(module) -MESSAGE(STATUS "Found Qxt Libraries:${QXT_FOUND_MODULES}") diff --git a/qfunctionconfigurator/broken/qfunctionconfiguratorplugin.cpp b/qfunctionconfigurator/broken/qfunctionconfiguratorplugin.cpp new file mode 100644 index 00000000..9bed2c9e --- /dev/null +++ b/qfunctionconfigurator/broken/qfunctionconfiguratorplugin.cpp @@ -0,0 +1,118 @@ +/* Copyright (c) 2011-2012 Stanislaw Halik + * Adapted to FaceTrackNoIR by Wim Vriend. + * 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 "qfunctionconfigurator.h" + +#include +#include "qfunctionconfiguratorplugin.h" + + +QFunctionConfiguratorPlugin::QFunctionConfiguratorPlugin(QObject *parent) + : QObject(parent) +{ + initialized = false; +} + +void QFunctionConfiguratorPlugin::initialize(QDesignerFormEditorInterface *) +{ + if (initialized) + return; + + initialized = true; +} + +bool QFunctionConfiguratorPlugin::isInitialized() const +{ + return initialized; +} + +QWidget *QFunctionConfiguratorPlugin::createWidget(QWidget *parent) +{ + return new QFunctionConfigurator(parent); +} + +QString QFunctionConfiguratorPlugin::name() const +{ + return "QFunctionConfigurator"; +} + +QString QFunctionConfiguratorPlugin::group() const +{ + return "My Plugins"; +} + +QIcon QFunctionConfiguratorPlugin::icon() const +{ + return QIcon(); +} + +QString QFunctionConfiguratorPlugin::toolTip() const +{ + return QString(); +} + +QString QFunctionConfiguratorPlugin::whatsThis() const +{ + return QString(); +} + +bool QFunctionConfiguratorPlugin::isContainer() const +{ + return false; +} + +QString QFunctionConfiguratorPlugin::domXml() const +{ + return "\n" + " \n" + " \n" + " 0\n" + " 0\n" + " 161\n" + " 220\n" + " \n" + " \n" + " \n" + " \n" + " 255\n" + " 170\n" + " 0\n" + " \n" + " \n" + " \n" + " \n" + " 192\n" + " 192\n" + " 192\n" + " \n" + " \n" + " \n" + " Input Yaw (degr.)\n" + " \n" + " \n" + " Output Yaw (degr.)\n" + " \n" + " \n" + " 50\n" + " \n" + " \n" + " 180\n" + " \n" + " \n" + " 2\n" + " \n" + " \n" + " 1\n" + " \n" + "\n"; +} + +QString QFunctionConfiguratorPlugin::includeFile() const +{ + return "qfunctionconfigurator.h"; +} + +Q_EXPORT_PLUGIN2(qfunctionconfigurator, QFunctionConfiguratorPlugin) diff --git a/qfunctionconfigurator/broken/qfunctionconfiguratorplugin.h b/qfunctionconfigurator/broken/qfunctionconfiguratorplugin.h new file mode 100644 index 00000000..bc637338 --- /dev/null +++ b/qfunctionconfigurator/broken/qfunctionconfiguratorplugin.h @@ -0,0 +1,37 @@ +/* Copyright (c) 2011-2012 Stanislaw Halik + * Adapted to FaceTrackNoIR by Wim Vriend. + * 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 QFUNCTIONCONFIGURATORPLUGIN_H +#define QFUNCTIONCONFIGURATORPLUGIN_H + +#include + +class QFunctionConfiguratorPlugin : public QObject, public QDesignerCustomWidgetInterface +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDesignerCustomWidgetInterface" FILE "analogclock.json") + Q_INTERFACES(QDesignerCustomWidgetInterface) + +public: + QFunctionConfiguratorPlugin(QObject *parent = 0); + + bool isContainer() const; + bool isInitialized() const; + QIcon icon() const; + QString domXml() const; + QString group() const; + QString includeFile() const; + QString name() const; + QString toolTip() const; + QString whatsThis() const; + QWidget *createWidget(QWidget *parent); + void initialize(QDesignerFormEditorInterface *core); + +private: + bool initialized; +}; + +#endif // QFUNCTIONCONFIGURATORPLUGIN_H diff --git a/qfunctionconfigurator/qfunctionconfiguratorplugin.cpp b/qfunctionconfigurator/qfunctionconfiguratorplugin.cpp deleted file mode 100644 index 9bed2c9e..00000000 --- a/qfunctionconfigurator/qfunctionconfiguratorplugin.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/* Copyright (c) 2011-2012 Stanislaw Halik - * Adapted to FaceTrackNoIR by Wim Vriend. - * 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 "qfunctionconfigurator.h" - -#include -#include "qfunctionconfiguratorplugin.h" - - -QFunctionConfiguratorPlugin::QFunctionConfiguratorPlugin(QObject *parent) - : QObject(parent) -{ - initialized = false; -} - -void QFunctionConfiguratorPlugin::initialize(QDesignerFormEditorInterface *) -{ - if (initialized) - return; - - initialized = true; -} - -bool QFunctionConfiguratorPlugin::isInitialized() const -{ - return initialized; -} - -QWidget *QFunctionConfiguratorPlugin::createWidget(QWidget *parent) -{ - return new QFunctionConfigurator(parent); -} - -QString QFunctionConfiguratorPlugin::name() const -{ - return "QFunctionConfigurator"; -} - -QString QFunctionConfiguratorPlugin::group() const -{ - return "My Plugins"; -} - -QIcon QFunctionConfiguratorPlugin::icon() const -{ - return QIcon(); -} - -QString QFunctionConfiguratorPlugin::toolTip() const -{ - return QString(); -} - -QString QFunctionConfiguratorPlugin::whatsThis() const -{ - return QString(); -} - -bool QFunctionConfiguratorPlugin::isContainer() const -{ - return false; -} - -QString QFunctionConfiguratorPlugin::domXml() const -{ - return "\n" - " \n" - " \n" - " 0\n" - " 0\n" - " 161\n" - " 220\n" - " \n" - " \n" - " \n" - " \n" - " 255\n" - " 170\n" - " 0\n" - " \n" - " \n" - " \n" - " \n" - " 192\n" - " 192\n" - " 192\n" - " \n" - " \n" - " \n" - " Input Yaw (degr.)\n" - " \n" - " \n" - " Output Yaw (degr.)\n" - " \n" - " \n" - " 50\n" - " \n" - " \n" - " 180\n" - " \n" - " \n" - " 2\n" - " \n" - " \n" - " 1\n" - " \n" - "\n"; -} - -QString QFunctionConfiguratorPlugin::includeFile() const -{ - return "qfunctionconfigurator.h"; -} - -Q_EXPORT_PLUGIN2(qfunctionconfigurator, QFunctionConfiguratorPlugin) diff --git a/qfunctionconfigurator/qfunctionconfiguratorplugin.h b/qfunctionconfigurator/qfunctionconfiguratorplugin.h deleted file mode 100644 index c854d3a2..00000000 --- a/qfunctionconfigurator/qfunctionconfiguratorplugin.h +++ /dev/null @@ -1,36 +0,0 @@ -/* Copyright (c) 2011-2012 Stanislaw Halik - * Adapted to FaceTrackNoIR by Wim Vriend. - * 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 QFUNCTIONCONFIGURATORPLUGIN_H -#define QFUNCTIONCONFIGURATORPLUGIN_H - -#include - -class QFunctionConfiguratorPlugin : public QObject, public QDesignerCustomWidgetInterface -{ - Q_OBJECT - Q_INTERFACES(QDesignerCustomWidgetInterface) - -public: - QFunctionConfiguratorPlugin(QObject *parent = 0); - - bool isContainer() const; - bool isInitialized() const; - QIcon icon() const; - QString domXml() const; - QString group() const; - QString includeFile() const; - QString name() const; - QString toolTip() const; - QString whatsThis() const; - QWidget *createWidget(QWidget *parent); - void initialize(QDesignerFormEditorInterface *core); - -private: - bool initialized; -}; - -#endif // QFUNCTIONCONFIGURATORPLUGIN_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(-) 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(-) 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 5ef2679167e1dbe19f738587f1e59f812e38211b Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 15 Oct 2013 08:54:37 +0200 Subject: import cut out qxtgui/global-shortcuts :( sorry guys! --- qxt-mini/QxtGlobalShortcut | 2 + qxt-mini/plat/qxtglobalshortcut_mac.cpp | 258 ++++++++++++++++++++++++++++++++ qxt-mini/plat/qxtglobalshortcut_x11.cpp | 235 +++++++++++++++++++++++++++++ qxt-mini/qplatformnativeinterface.h | 99 ++++++++++++ qxt-mini/qxtglobal.h | 233 ++++++++++++++++++++++++++++ qxt-mini/qxtglobalshortcut.cpp | 223 +++++++++++++++++++++++++++ qxt-mini/qxtglobalshortcut.h | 64 ++++++++ qxt-mini/qxtglobalshortcut_p.h | 84 +++++++++++ 8 files changed, 1198 insertions(+) create mode 100644 qxt-mini/QxtGlobalShortcut create mode 100644 qxt-mini/plat/qxtglobalshortcut_mac.cpp create mode 100644 qxt-mini/plat/qxtglobalshortcut_x11.cpp create mode 100644 qxt-mini/qplatformnativeinterface.h create mode 100644 qxt-mini/qxtglobal.h create mode 100644 qxt-mini/qxtglobalshortcut.cpp create mode 100644 qxt-mini/qxtglobalshortcut.h create mode 100644 qxt-mini/qxtglobalshortcut_p.h diff --git a/qxt-mini/QxtGlobalShortcut b/qxt-mini/QxtGlobalShortcut new file mode 100644 index 00000000..d673035b --- /dev/null +++ b/qxt-mini/QxtGlobalShortcut @@ -0,0 +1,2 @@ +#include "qxtglobalshortcut.h" + diff --git a/qxt-mini/plat/qxtglobalshortcut_mac.cpp b/qxt-mini/plat/qxtglobalshortcut_mac.cpp new file mode 100644 index 00000000..58b9a904 --- /dev/null +++ b/qxt-mini/plat/qxtglobalshortcut_mac.cpp @@ -0,0 +1,258 @@ +#include +/**************************************************************************** +** Copyright (c) 2006 - 2011, the LibQxt project. +** See the Qxt AUTHORS file for a list of authors and copyright holders. +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** * Neither the name of the LibQxt project nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +** DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +** +*****************************************************************************/ + +#include "qxtglobalshortcut_p.h" +#include +#include +#include +#include + +typedef QPair Identifier; +static QMap keyRefs; +static QHash keyIDs; +static quint32 hotKeySerial = 0; +static bool qxt_mac_handler_installed = false; + +OSStatus qxt_mac_handle_hot_key(EventHandlerCallRef nextHandler, EventRef event, void* data) +{ + Q_UNUSED(nextHandler); + Q_UNUSED(data); + if (GetEventClass(event) == kEventClassKeyboard && GetEventKind(event) == kEventHotKeyPressed) + { + EventHotKeyID keyID; + GetEventParameter(event, kEventParamDirectObject, typeEventHotKeyID, NULL, sizeof(keyID), NULL, &keyID); + Identifier id = keyIDs.key(keyID.id); + QxtGlobalShortcutPrivate::activateShortcut(id.second, id.first); + } + return noErr; +} + +quint32 QxtGlobalShortcutPrivate::nativeModifiers(Qt::KeyboardModifiers modifiers) +{ + quint32 native = 0; + if (modifiers & Qt::ShiftModifier) + native |= shiftKey; + if (modifiers & Qt::ControlModifier) + native |= cmdKey; + if (modifiers & Qt::AltModifier) + native |= optionKey; + if (modifiers & Qt::MetaModifier) + native |= controlKey; + if (modifiers & Qt::KeypadModifier) + native |= kEventKeyModifierNumLockMask; + return native; +} + +quint32 QxtGlobalShortcutPrivate::nativeKeycode(Qt::Key key) +{ + UTF16Char ch; + // Constants found in NSEvent.h from AppKit.framework + switch (key) + { + case Qt::Key_Return: + return kVK_Return; + case Qt::Key_Enter: + return kVK_ANSI_KeypadEnter; + case Qt::Key_Tab: + return kVK_Tab; + case Qt::Key_Space: + return kVK_Space; + case Qt::Key_Backspace: + return kVK_Delete; + case Qt::Key_Control: + return kVK_Command; + case Qt::Key_Shift: + return kVK_Shift; + case Qt::Key_CapsLock: + return kVK_CapsLock; + case Qt::Key_Option: + return kVK_Option; + case Qt::Key_Meta: + return kVK_Control; + case Qt::Key_F17: + return kVK_F17; + case Qt::Key_VolumeUp: + return kVK_VolumeUp; + case Qt::Key_VolumeDown: + return kVK_VolumeDown; + case Qt::Key_F18: + return kVK_F18; + case Qt::Key_F19: + return kVK_F19; + case Qt::Key_F20: + return kVK_F20; + case Qt::Key_F5: + return kVK_F5; + case Qt::Key_F6: + return kVK_F6; + case Qt::Key_F7: + return kVK_F7; + case Qt::Key_F3: + return kVK_F3; + case Qt::Key_F8: + return kVK_F8; + case Qt::Key_F9: + return kVK_F9; + case Qt::Key_F11: + return kVK_F11; + case Qt::Key_F13: + return kVK_F13; + case Qt::Key_F16: + return kVK_F16; + case Qt::Key_F14: + return kVK_F14; + case Qt::Key_F10: + return kVK_F10; + case Qt::Key_F12: + return kVK_F12; + case Qt::Key_F15: + return kVK_F15; + case Qt::Key_Help: + return kVK_Help; + case Qt::Key_Home: + return kVK_Home; + case Qt::Key_PageUp: + return kVK_PageUp; + case Qt::Key_Delete: + return kVK_ForwardDelete; + case Qt::Key_F4: + return kVK_F4; + case Qt::Key_End: + return kVK_End; + case Qt::Key_F2: + return kVK_F2; + case Qt::Key_PageDown: + return kVK_PageDown; + case Qt::Key_F1: + return kVK_F1; + case Qt::Key_Left: + return kVK_LeftArrow; + case Qt::Key_Right: + return kVK_RightArrow; + case Qt::Key_Down: + return kVK_DownArrow; + case Qt::Key_Up: + return kVK_UpArrow; + default: + ; + } + + if (key == Qt::Key_Escape) ch = 27; + else if (key == Qt::Key_Return) ch = 13; + else if (key == Qt::Key_Enter) ch = 3; + else if (key == Qt::Key_Tab) ch = 9; + else ch = key; + + CFDataRef currentLayoutData; + TISInputSourceRef currentKeyboard = TISCopyCurrentKeyboardInputSource(); + + if (currentKeyboard == NULL) + return 0; + + currentLayoutData = (CFDataRef)TISGetInputSourceProperty(currentKeyboard, kTISPropertyUnicodeKeyLayoutData); + CFRelease(currentKeyboard); + if (currentLayoutData == NULL) + return 0; + + UCKeyboardLayout* header = (UCKeyboardLayout*)CFDataGetBytePtr(currentLayoutData); + UCKeyboardTypeHeader* table = header->keyboardTypeList; + + uint8_t *data = (uint8_t*)header; + // God, would a little documentation for this shit kill you... + for (quint32 i=0; i < header->keyboardTypeCount; i++) + { + UCKeyStateRecordsIndex* stateRec = 0; + if (table[i].keyStateRecordsIndexOffset != 0) + { + stateRec = reinterpret_cast(data + table[i].keyStateRecordsIndexOffset); + if (stateRec->keyStateRecordsIndexFormat != kUCKeyStateRecordsIndexFormat) stateRec = 0; + } + + UCKeyToCharTableIndex* charTable = reinterpret_cast(data + table[i].keyToCharTableIndexOffset); + if (charTable->keyToCharTableIndexFormat != kUCKeyToCharTableIndexFormat) continue; + + for (quint32 j=0; j < charTable->keyToCharTableCount; j++) + { + UCKeyOutput* keyToChar = reinterpret_cast(data + charTable->keyToCharTableOffsets[j]); + for (quint32 k=0; k < charTable->keyToCharTableSize; k++) + { + if (keyToChar[k] & kUCKeyOutputTestForIndexMask) + { + long idx = keyToChar[k] & kUCKeyOutputGetIndexMask; + if (stateRec && idx < stateRec->keyStateRecordCount) + { + UCKeyStateRecord* rec = reinterpret_cast(data + stateRec->keyStateRecordOffsets[idx]); + if (rec->stateZeroCharData == ch) return k; + } + } + else if (!(keyToChar[k] & kUCKeyOutputSequenceIndexMask) && keyToChar[k] < 0xFFFE) + { + if (keyToChar[k] == ch) return k; + } + } // for k + } // for j + } // for i + return 0; +} + +bool QxtGlobalShortcutPrivate::registerShortcut(quint32 nativeKey, quint32 nativeMods) +{ + if (!qxt_mac_handler_installed) + { + EventTypeSpec t; + t.eventClass = kEventClassKeyboard; + t.eventKind = kEventHotKeyPressed; + InstallApplicationEventHandler(&qxt_mac_handle_hot_key, 1, &t, NULL, NULL); + } + + EventHotKeyID keyID; + keyID.signature = 'cute'; + keyID.id = ++hotKeySerial; + + EventHotKeyRef ref = 0; + bool rv = !RegisterEventHotKey(nativeKey, nativeMods, keyID, GetApplicationEventTarget(), 0, &ref); + if (rv) + { + keyIDs.insert(Identifier(nativeMods, nativeKey), keyID.id); + keyRefs.insert(keyID.id, ref); + } + return rv; +} + +bool QxtGlobalShortcutPrivate::unregisterShortcut(quint32 nativeKey, quint32 nativeMods) +{ + Identifier id(nativeMods, nativeKey); + if (!keyIDs.contains(id)) return false; + + EventHotKeyRef ref = keyRefs.take(keyIDs[id]); + keyIDs.remove(id); + return !UnregisterEventHotKey(ref); +} diff --git a/qxt-mini/plat/qxtglobalshortcut_x11.cpp b/qxt-mini/plat/qxtglobalshortcut_x11.cpp new file mode 100644 index 00000000..0c203dd8 --- /dev/null +++ b/qxt-mini/plat/qxtglobalshortcut_x11.cpp @@ -0,0 +1,235 @@ +#include "../qxtglobalshortcut_p.h" +/**************************************************************************** +** Copyright (c) 2006 - 2011, the LibQxt project. +** See the Qxt AUTHORS file for a list of authors and copyright holders. +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** * Neither the name of the LibQxt project nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +** DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +** +*****************************************************************************/ + +#include +#include +// include private header for great justice -sh 20131015 +#include +#include +#include "qplatformnativeinterface.h" + +namespace { + +const QVector maskModifiers = QVector() + << 0 << Mod2Mask << LockMask << (Mod2Mask | LockMask); + +typedef int (*X11ErrorHandler)(Display *display, XErrorEvent *event); + +class QxtX11ErrorHandler { +public: + static bool error; + + static int qxtX11ErrorHandler(Display *display, XErrorEvent *event) + { + Q_UNUSED(display); + switch (event->error_code) + { + case BadAccess: + case BadValue: + case BadWindow: + if (event->request_code == 33 /* X_GrabKey */ || + event->request_code == 34 /* X_UngrabKey */) + { + error = true; + //TODO: + //char errstr[256]; + //XGetErrorText(dpy, err->error_code, errstr, 256); + } + } + return 0; + } + + QxtX11ErrorHandler() + { + error = false; + m_previousErrorHandler = XSetErrorHandler(qxtX11ErrorHandler); + } + + ~QxtX11ErrorHandler() + { + XSetErrorHandler(m_previousErrorHandler); + } + +private: + X11ErrorHandler m_previousErrorHandler; +}; + +bool QxtX11ErrorHandler::error = false; + +class QxtX11Data { +public: + QxtX11Data() + { +#if QT_VERSION < QT_VERSION_CHECK(5,0,0) + m_display = QX11Info::display(); +#else + QPlatformNativeInterface *native = qApp->platformNativeInterface(); + void *display = native->nativeResourceForScreen(QByteArray("display"), + QGuiApplication::primaryScreen()); + m_display = reinterpret_cast(display); +#endif + } + + bool isValid() + { + return m_display != 0; + } + + Display *display() + { + Q_ASSERT(isValid()); + return m_display; + } + + Window rootWindow() + { + return DefaultRootWindow(display()); + } + + bool grabKey(quint32 keycode, quint32 modifiers, Window window) + { + QxtX11ErrorHandler errorHandler; + + for (int i = 0; !errorHandler.error && i < maskModifiers.size(); ++i) { + XGrabKey(display(), keycode, modifiers | maskModifiers[i], window, True, + GrabModeAsync, GrabModeAsync); + } + + if (errorHandler.error) { + ungrabKey(keycode, modifiers, window); + return false; + } + + return true; + } + + bool ungrabKey(quint32 keycode, quint32 modifiers, Window window) + { + QxtX11ErrorHandler errorHandler; + + foreach (quint32 maskMods, maskModifiers) { + XUngrabKey(display(), keycode, modifiers | maskMods, window); + } + + return !errorHandler.error; + } + +private: + Display *m_display; +}; + +} // namespace + +#if QT_VERSION < QT_VERSION_CHECK(5,0,0) +bool QxtGlobalShortcutPrivate::eventFilter(void *message) +{ + XEvent *event = static_cast(message); + if (event->type == KeyPress) + { + XKeyEvent *key = reinterpret_cast(event); + unsigned int keycode = key->keycode; + unsigned int keystate = key->state; +#else +bool QxtGlobalShortcutPrivate::nativeEventFilter(const QByteArray & eventType, + void *message, long *result) +{ + Q_UNUSED(result); + + xcb_key_press_event_t *kev = 0; + if (eventType == "xcb_generic_event_t") { + xcb_generic_event_t *ev = static_cast(message); + if ((ev->response_type & 127) == XCB_KEY_PRESS) + kev = static_cast(message); + } + + if (kev != 0) { + unsigned int keycode = kev->detail; + unsigned int keystate = 0; + if(kev->state & XCB_MOD_MASK_1) + keystate |= Mod1Mask; + if(kev->state & XCB_MOD_MASK_CONTROL) + keystate |= ControlMask; + if(kev->state & XCB_MOD_MASK_4) + keystate |= Mod4Mask; + if(kev->state & XCB_MOD_MASK_SHIFT) + keystate |= ShiftMask; +#endif + activateShortcut(keycode, + // Mod1Mask == Alt, Mod4Mask == Meta + keystate & (ShiftMask | ControlMask | Mod1Mask | Mod4Mask)); + } + return false; +} + +quint32 QxtGlobalShortcutPrivate::nativeModifiers(Qt::KeyboardModifiers modifiers) +{ + // ShiftMask, LockMask, ControlMask, Mod1Mask, Mod2Mask, Mod3Mask, Mod4Mask, and Mod5Mask + quint32 native = 0; + if (modifiers & Qt::ShiftModifier) + native |= ShiftMask; + if (modifiers & Qt::ControlModifier) + native |= ControlMask; + if (modifiers & Qt::AltModifier) + native |= Mod1Mask; + if (modifiers & Qt::MetaModifier) + native |= Mod4Mask; + + // TODO: resolve these? + //if (modifiers & Qt::MetaModifier) + //if (modifiers & Qt::KeypadModifier) + //if (modifiers & Qt::GroupSwitchModifier) + return native; +} + +quint32 QxtGlobalShortcutPrivate::nativeKeycode(Qt::Key key) +{ + QxtX11Data x11; + if (!x11.isValid()) + return 0; + + KeySym keysym = XStringToKeysym(QKeySequence(key).toString().toLatin1().data()); + if (keysym == NoSymbol) + keysym = static_cast(key); + + return XKeysymToKeycode(x11.display(), keysym); +} + +bool QxtGlobalShortcutPrivate::registerShortcut(quint32 nativeKey, quint32 nativeMods) +{ + QxtX11Data x11; + return x11.isValid() && x11.grabKey(nativeKey, nativeMods, x11.rootWindow()); +} + +bool QxtGlobalShortcutPrivate::unregisterShortcut(quint32 nativeKey, quint32 nativeMods) +{ + QxtX11Data x11; + return x11.isValid() && x11.ungrabKey(nativeKey, nativeMods, x11.rootWindow()); +} diff --git a/qxt-mini/qplatformnativeinterface.h b/qxt-mini/qplatformnativeinterface.h new file mode 100644 index 00000000..eaa24a9e --- /dev/null +++ b/qxt-mini/qplatformnativeinterface.h @@ -0,0 +1,99 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QPLATFORMNATIVEINTERFACE_H +#define QPLATFORMNATIVEINTERFACE_H + +// +// W A R N I N G +// ------------- +// +// This file is part of the QPA API and is not meant to be used +// in applications. Usage of this API may make your code +// source and binary incompatible with future versions of Qt. +// + +#include +#include +#include + +QT_BEGIN_NAMESPACE + + +class QOpenGLContext; +class QScreen; +class QWindow; +class QPlatformWindow; +class QBackingStore; + +class Q_GUI_EXPORT QPlatformNativeInterface : public QObject +{ + Q_OBJECT +public: + virtual void *nativeResourceForIntegration(const QByteArray &resource); + virtual void *nativeResourceForContext(const QByteArray &resource, QOpenGLContext *context); + virtual void *nativeResourceForScreen(const QByteArray &resource, QScreen *screen); + virtual void *nativeResourceForWindow(const QByteArray &resource, QWindow *window); + virtual void *nativeResourceForBackingStore(const QByteArray &resource, QBackingStore *backingStore); + + typedef void * (*NativeResourceForIntegrationFunction)(); + typedef void * (*NativeResourceForContextFunction)(QOpenGLContext *context); + typedef void * (*NativeResourceForScreenFunction)(QScreen *screen); + typedef void * (*NativeResourceForWindowFunction)(QWindow *window); + typedef void * (*NativeResourceForBackingStoreFunction)(QBackingStore *backingStore); + virtual NativeResourceForIntegrationFunction nativeResourceFunctionForIntegration(const QByteArray &resource); + virtual NativeResourceForContextFunction nativeResourceFunctionForContext(const QByteArray &resource); + virtual NativeResourceForScreenFunction nativeResourceFunctionForScreen(const QByteArray &resource); + virtual NativeResourceForWindowFunction nativeResourceFunctionForWindow(const QByteArray &resource); + virtual NativeResourceForBackingStoreFunction nativeResourceFunctionForBackingStore(const QByteArray &resource); + + virtual QVariantMap windowProperties(QPlatformWindow *window) const; + virtual QVariant windowProperty(QPlatformWindow *window, const QString &name) const; + virtual QVariant windowProperty(QPlatformWindow *window, const QString &name, const QVariant &defaultValue) const; + virtual void setWindowProperty(QPlatformWindow *window, const QString &name, const QVariant &value); + +Q_SIGNALS: + void windowPropertyChanged(QPlatformWindow *window, const QString &propertyName); +}; + +QT_END_NAMESPACE + +#endif // QPLATFORMNATIVEINTERFACE_H diff --git a/qxt-mini/qxtglobal.h b/qxt-mini/qxtglobal.h new file mode 100644 index 00000000..7d5abfbe --- /dev/null +++ b/qxt-mini/qxtglobal.h @@ -0,0 +1,233 @@ + +/**************************************************************************** +** Copyright (c) 2006 - 2011, the LibQxt project. +** See the Qxt AUTHORS file for a list of authors and copyright holders. +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** * Neither the name of the LibQxt project nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +** DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +** +*****************************************************************************/ + +#ifndef QXTGLOBAL_H +#define QXTGLOBAL_H + +#include + +#define QXT_VERSION 0x000700 +#define QXT_VERSION_STR "0.7.0" + +//--------------------------global macros------------------------------ + +#ifndef QXT_NO_MACROS + +#ifndef _countof +#define _countof(x) (sizeof(x)/sizeof(*x)) +#endif + +#endif // QXT_NO_MACROS + +//--------------------------export macros------------------------------ + +#define QXT_DLLEXPORT DO_NOT_USE_THIS_ANYMORE + +#if !defined(QXT_STATIC) && !defined(QXT_DOXYGEN_RUN) +# if defined(BUILD_QXT_CORE) +# define QXT_CORE_EXPORT Q_DECL_EXPORT +# else +# define QXT_CORE_EXPORT Q_DECL_IMPORT +# endif +#else +# define QXT_CORE_EXPORT +#endif // BUILD_QXT_CORE + +#if !defined(QXT_STATIC) && !defined(QXT_DOXYGEN_RUN) +# if defined(BUILD_QXT_GUI) +# define QXT_GUI_EXPORT Q_DECL_EXPORT +# else +# define QXT_GUI_EXPORT Q_DECL_IMPORT +# endif +#else +# define QXT_GUI_EXPORT +#endif // BUILD_QXT_GUI + +#if !defined(QXT_STATIC) && !defined(QXT_DOXYGEN_RUN) +# if defined(BUILD_QXT_NETWORK) +# define QXT_NETWORK_EXPORT Q_DECL_EXPORT +# else +# define QXT_NETWORK_EXPORT Q_DECL_IMPORT +# endif +#else +# define QXT_NETWORK_EXPORT +#endif // BUILD_QXT_NETWORK + +#if !defined(QXT_STATIC) && !defined(QXT_DOXYGEN_RUN) +# if defined(BUILD_QXT_SQL) +# define QXT_SQL_EXPORT Q_DECL_EXPORT +# else +# define QXT_SQL_EXPORT Q_DECL_IMPORT +# endif +#else +# define QXT_SQL_EXPORT +#endif // BUILD_QXT_SQL + +#if !defined(QXT_STATIC) && !defined(QXT_DOXYGEN_RUN) +# if defined(BUILD_QXT_WEB) +# define QXT_WEB_EXPORT Q_DECL_EXPORT +# else +# define QXT_WEB_EXPORT Q_DECL_IMPORT +# endif +#else +# define QXT_WEB_EXPORT +#endif // BUILD_QXT_WEB + +#if !defined(QXT_STATIC) && !defined(QXT_DOXYGEN_RUN) +# if defined(BUILD_QXT_BERKELEY) +# define QXT_BERKELEY_EXPORT Q_DECL_EXPORT +# else +# define QXT_BERKELEY_EXPORT Q_DECL_IMPORT +# endif +#else +# define QXT_BERKELEY_EXPORT +#endif // BUILD_QXT_BERKELEY + +#if !defined(QXT_STATIC) && !defined(QXT_DOXYGEN_RUN) +# if defined(BUILD_QXT_ZEROCONF) +# define QXT_ZEROCONF_EXPORT Q_DECL_EXPORT +# else +# define QXT_ZEROCONF_EXPORT Q_DECL_IMPORT +# endif +#else +# define QXT_ZEROCONF_EXPORT +#endif // QXT_ZEROCONF_EXPORT + +#if defined(BUILD_QXT_CORE) || defined(BUILD_QXT_GUI) || defined(BUILD_QXT_SQL) || defined(BUILD_QXT_NETWORK) || defined(BUILD_QXT_WEB) || defined(BUILD_QXT_BERKELEY) || defined(BUILD_QXT_ZEROCONF) +# define BUILD_QXT +#endif + +QXT_CORE_EXPORT const char* qxtVersion(); + +#ifndef QT_BEGIN_NAMESPACE +#define QT_BEGIN_NAMESPACE +#endif + +#ifndef QT_END_NAMESPACE +#define QT_END_NAMESPACE +#endif + +#ifndef QT_FORWARD_DECLARE_CLASS +#define QT_FORWARD_DECLARE_CLASS(Class) class Class; +#endif + +/**************************************************************************** +** This file is derived from code bearing the following notice: +** The sole author of this file, Adam Higerd, has explicitly disclaimed all +** copyright interest and protection for the content within. This file has +** been placed in the public domain according to United States copyright +** statute and case law. In jurisdictions where this public domain dedication +** is not legally recognized, anyone who receives a copy of this file is +** permitted to use, modify, duplicate, and redistribute this file, in whole +** or in part, with no restrictions or conditions. In these jurisdictions, +** this file shall be copyright (C) 2006-2008 by Adam Higerd. +****************************************************************************/ + +#define QXT_DECLARE_PRIVATE(PUB) friend class PUB##Private; QxtPrivateInterface qxt_d; +#define QXT_DECLARE_PUBLIC(PUB) friend class PUB; +#define QXT_INIT_PRIVATE(PUB) qxt_d.setPublic(this); +#define QXT_D(PUB) PUB##Private& d = qxt_d() +#define QXT_P(PUB) PUB& p = qxt_p() + +template +class QxtPrivate +{ +public: + virtual ~QxtPrivate() + {} + inline void QXT_setPublic(PUB* pub) + { + qxt_p_ptr = pub; + } + +protected: + inline PUB& qxt_p() + { + return *qxt_p_ptr; + } + inline const PUB& qxt_p() const + { + return *qxt_p_ptr; + } + inline PUB* qxt_ptr() + { + return qxt_p_ptr; + } + inline const PUB* qxt_ptr() const + { + return qxt_p_ptr; + } + +private: + PUB* qxt_p_ptr; +}; + +template +class QxtPrivateInterface +{ + friend class QxtPrivate; +public: + QxtPrivateInterface() + { + pvt = new PVT; + } + ~QxtPrivateInterface() + { + delete pvt; + } + + inline void setPublic(PUB* pub) + { + pvt->QXT_setPublic(pub); + } + inline PVT& operator()() + { + return *static_cast(pvt); + } + inline const PVT& operator()() const + { + return *static_cast(pvt); + } + inline PVT * operator->() + { + return static_cast(pvt); + } + inline const PVT * operator->() const + { + return static_cast(pvt); + } +private: + QxtPrivateInterface(const QxtPrivateInterface&) { } + QxtPrivateInterface& operator=(const QxtPrivateInterface&) { } + QxtPrivate* pvt; +}; + +#endif // QXT_GLOBAL diff --git a/qxt-mini/qxtglobalshortcut.cpp b/qxt-mini/qxtglobalshortcut.cpp new file mode 100644 index 00000000..72548d6f --- /dev/null +++ b/qxt-mini/qxtglobalshortcut.cpp @@ -0,0 +1,223 @@ +#include "qxtglobalshortcut.h" +/**************************************************************************** +** Copyright (c) 2006 - 2011, the LibQxt project. +** See the Qxt AUTHORS file for a list of authors and copyright holders. +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** * Neither the name of the LibQxt project nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +** DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +** +*****************************************************************************/ + +#include "qxtglobalshortcut_p.h" +#include +#include + +#ifndef Q_WS_MAC +int QxtGlobalShortcutPrivate::ref = 0; +# if QT_VERSION < QT_VERSION_CHECK(5,0,0) +QAbstractEventDispatcher::EventFilter QxtGlobalShortcutPrivate::prevEventFilter = 0; +# endif +#endif // Q_WS_MAC +QHash, QxtGlobalShortcut*> QxtGlobalShortcutPrivate::shortcuts; + +QxtGlobalShortcutPrivate::QxtGlobalShortcutPrivate() : enabled(true), key(Qt::Key(0)), mods(Qt::NoModifier) +{ +#ifndef Q_WS_MAC + if (ref == 0) { +# if QT_VERSION < QT_VERSION_CHECK(5,0,0) + prevEventFilter = QAbstractEventDispatcher::instance()->setEventFilter(eventFilter); +# else + QAbstractEventDispatcher::instance()->installNativeEventFilter(this); +#endif + } + ++ref; +#endif // Q_WS_MAC +} + +QxtGlobalShortcutPrivate::~QxtGlobalShortcutPrivate() +{ +#ifndef Q_WS_MAC + --ref; + if (ref == 0) { + QAbstractEventDispatcher *ed = QAbstractEventDispatcher::instance(); + if (ed != 0) { +# if QT_VERSION < QT_VERSION_CHECK(5,0,0) + ed->setEventFilter(prevEventFilter); +# else + ed->removeNativeEventFilter(this); +# endif + } + } +#endif // Q_WS_MAC +} + +bool QxtGlobalShortcutPrivate::setShortcut(const QKeySequence& shortcut) +{ + Qt::KeyboardModifiers allMods = Qt::ShiftModifier | Qt::ControlModifier | Qt::AltModifier | Qt::MetaModifier; + key = shortcut.isEmpty() ? Qt::Key(0) : Qt::Key((shortcut[0] ^ allMods) & shortcut[0]); + mods = shortcut.isEmpty() ? Qt::KeyboardModifiers(0) : Qt::KeyboardModifiers(shortcut[0] & allMods); + const quint32 nativeKey = nativeKeycode(key); + const quint32 nativeMods = nativeModifiers(mods); + const bool res = registerShortcut(nativeKey, nativeMods); + if (res) + shortcuts.insert(qMakePair(nativeKey, nativeMods), &qxt_p()); + else + qWarning() << "QxtGlobalShortcut failed to register:" << QKeySequence(key + mods).toString(); + return res; +} + +bool QxtGlobalShortcutPrivate::unsetShortcut() +{ + bool res = false; + const quint32 nativeKey = nativeKeycode(key); + const quint32 nativeMods = nativeModifiers(mods); + if (shortcuts.value(qMakePair(nativeKey, nativeMods)) == &qxt_p()) + res = unregisterShortcut(nativeKey, nativeMods); + if (res) + shortcuts.remove(qMakePair(nativeKey, nativeMods)); + else + qWarning() << "QxtGlobalShortcut failed to unregister:" << QKeySequence(key + mods).toString(); + key = Qt::Key(0); + mods = Qt::KeyboardModifiers(0); + return res; +} + +void QxtGlobalShortcutPrivate::activateShortcut(quint32 nativeKey, quint32 nativeMods) +{ + QxtGlobalShortcut* shortcut = shortcuts.value(qMakePair(nativeKey, nativeMods)); + if (shortcut && shortcut->isEnabled()) + emit shortcut->activated(); +} + +/*! + \class QxtGlobalShortcut + \inmodule QxtWidgets + \brief The QxtGlobalShortcut class provides a global shortcut aka "hotkey". + + A global shortcut triggers even if the application is not active. This + makes it easy to implement applications that react to certain shortcuts + still if some other application is active or if the application is for + example minimized to the system tray. + + Example usage: + \code + QxtGlobalShortcut* shortcut = new QxtGlobalShortcut(window); + connect(shortcut, SIGNAL(activated()), window, SLOT(toggleVisibility())); + shortcut->setShortcut(QKeySequence("Ctrl+Shift+F12")); + \endcode + + \bold {Note:} Since Qxt 0.6 QxtGlobalShortcut no more requires QxtApplication. + */ + +/*! + \fn QxtGlobalShortcut::activated() + + This signal is emitted when the user types the shortcut's key sequence. + + \sa shortcut + */ + +/*! + Constructs a new QxtGlobalShortcut with \a parent. + */ +QxtGlobalShortcut::QxtGlobalShortcut(QObject* parent) + : QObject(parent) +{ + QXT_INIT_PRIVATE(QxtGlobalShortcut); +} + +/*! + Constructs a new QxtGlobalShortcut with \a shortcut and \a parent. + */ +QxtGlobalShortcut::QxtGlobalShortcut(const QKeySequence& shortcut, QObject* parent) + : QObject(parent) +{ + QXT_INIT_PRIVATE(QxtGlobalShortcut); + setShortcut(shortcut); +} + +/*! + Destructs the QxtGlobalShortcut. + */ +QxtGlobalShortcut::~QxtGlobalShortcut() +{ + if (qxt_d().key != 0) + qxt_d().unsetShortcut(); +} + +/*! + \property QxtGlobalShortcut::shortcut + \brief the shortcut key sequence + + \bold {Note:} Notice that corresponding key press and release events are not + delivered for registered global shortcuts even if they are disabled. + Also, comma separated key sequences are not supported. + Only the first part is used: + + \code + qxtShortcut->setShortcut(QKeySequence("Ctrl+Alt+A,Ctrl+Alt+B")); + Q_ASSERT(qxtShortcut->shortcut() == QKeySequence("Ctrl+Alt+A")); + \endcode + */ +QKeySequence QxtGlobalShortcut::shortcut() const +{ + return QKeySequence(qxt_d().key | qxt_d().mods); +} + +bool QxtGlobalShortcut::setShortcut(const QKeySequence& shortcut) +{ + if (qxt_d().key != 0) + qxt_d().unsetShortcut(); + return qxt_d().setShortcut(shortcut); +} + +/*! + \property QxtGlobalShortcut::enabled + \brief whether the shortcut is enabled + + A disabled shortcut does not get activated. + + The default value is \c true. + + \sa setDisabled() + */ +bool QxtGlobalShortcut::isEnabled() const +{ + return qxt_d().enabled; +} + +void QxtGlobalShortcut::setEnabled(bool enabled) +{ + qxt_d().enabled = enabled; +} + +/*! + Sets the shortcut \a disabled. + + \sa enabled + */ +void QxtGlobalShortcut::setDisabled(bool disabled) +{ + qxt_d().enabled = !disabled; +} diff --git a/qxt-mini/qxtglobalshortcut.h b/qxt-mini/qxtglobalshortcut.h new file mode 100644 index 00000000..a81942d2 --- /dev/null +++ b/qxt-mini/qxtglobalshortcut.h @@ -0,0 +1,64 @@ +#ifndef QXTGLOBALSHORTCUT_H +/**************************************************************************** +** Copyright (c) 2006 - 2011, the LibQxt project. +** See the Qxt AUTHORS file for a list of authors and copyright holders. +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** * Neither the name of the LibQxt project nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +** DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +** +*****************************************************************************/ + +#define QXTGLOBALSHORTCUT_H + +#include "qxtglobal.h" +#include +#include +class QxtGlobalShortcutPrivate; + +class QXT_GUI_EXPORT QxtGlobalShortcut : public QObject +{ + Q_OBJECT + QXT_DECLARE_PRIVATE(QxtGlobalShortcut) + Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled) + Q_PROPERTY(QKeySequence shortcut READ shortcut WRITE setShortcut) + +public: + explicit QxtGlobalShortcut(QObject* parent = 0); + explicit QxtGlobalShortcut(const QKeySequence& shortcut, QObject* parent = 0); + virtual ~QxtGlobalShortcut(); + + QKeySequence shortcut() const; + bool setShortcut(const QKeySequence& shortcut); + + bool isEnabled() const; + +public Q_SLOTS: + void setEnabled(bool enabled = true); + void setDisabled(bool disabled = true); + +Q_SIGNALS: + void activated(); +}; + +#endif // QXTGLOBALSHORTCUT_H diff --git a/qxt-mini/qxtglobalshortcut_p.h b/qxt-mini/qxtglobalshortcut_p.h new file mode 100644 index 00000000..1a788852 --- /dev/null +++ b/qxt-mini/qxtglobalshortcut_p.h @@ -0,0 +1,84 @@ +#ifndef QXTGLOBALSHORTCUT_P_H +/**************************************************************************** +** Copyright (c) 2006 - 2011, the LibQxt project. +** See the Qxt AUTHORS file for a list of authors and copyright holders. +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** * Neither the name of the LibQxt project nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +** DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +** +*****************************************************************************/ + +#define QXTGLOBALSHORTCUT_P_H + +#include "qxtglobalshortcut.h" +#include +#include +#include + +#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) +#include +#endif + + +class QxtGlobalShortcutPrivate : public QxtPrivate +#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) + ,public QAbstractNativeEventFilter +#endif +{ +public: + QXT_DECLARE_PUBLIC(QxtGlobalShortcut) + QxtGlobalShortcutPrivate(); + ~QxtGlobalShortcutPrivate(); + + bool enabled; + Qt::Key key; + Qt::KeyboardModifiers mods; + + bool setShortcut(const QKeySequence& shortcut); + bool unsetShortcut(); + + static bool error; +#ifndef Q_WS_MAC + static int ref; +#if QT_VERSION < QT_VERSION_CHECK(5,0,0) + static QAbstractEventDispatcher::EventFilter prevEventFilter; + static bool eventFilter(void* message); +#else + virtual bool nativeEventFilter(const QByteArray & eventType, void * message, long * result); +#endif // QT_VERSION < QT_VERSION_CHECK(5,0,0) +#endif // Q_WS_MAC + + static void activateShortcut(quint32 nativeKey, quint32 nativeMods); + +private: + static quint32 nativeKeycode(Qt::Key keycode); + static quint32 nativeModifiers(Qt::KeyboardModifiers modifiers); + + static bool registerShortcut(quint32 nativeKey, quint32 nativeMods); + static bool unregisterShortcut(quint32 nativeKey, quint32 nativeMods); + + static QHash, QxtGlobalShortcut*> shortcuts; +}; + +#endif // QXTGLOBALSHORTCUT_P_H -- cgit v1.2.3 -- 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(-) 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 609a29983506525ddb914668ba6634d73357d566 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 15 Oct 2013 11:56:29 +0200 Subject: on't link sixense static even on 'doze these /MT-built archives may be bad news... --- ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp b/ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp index 2561c624..869882f9 100644 --- a/ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp +++ b/ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp @@ -3,10 +3,12 @@ #include "facetracknoir/global-settings.h" #include "facetracknoir/rotation.h" #include +#if 0 #ifdef _WIN32 # define SIXENSE_STATIC_LIB # define SIXENSE_UTILS_STATIC_LIB #endif +#endif #include #include #ifdef WIN32 -- 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(-) 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 6a61c0dd7dc3587db3d0a690ea44783734507873 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 15 Oct 2013 12:07:01 +0200 Subject: Actually, static link doesn't pull in two CRTs --- CMakeLists.txt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 09f55da6..52fac07c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -504,9 +504,10 @@ endif() target_link_libraries(opentrack-tracker-hydra ${MY_QT_LIBS}) if(WIN32) if(CMAKE_COMPILER_IS_GNUCXX) - target_link_libraries(opentrack-tracker-hydra "${SDK_HYDRA}/lib/win32/release_dll/sixense.lib" "${SDK_HYDRA}/lib/win32/release_dll/sixense_utils.lib") - install(FILES "${SDK_HYDRA}/bin/win32/release_dll/sixense.dll" "${SDK_HYDRA}/bin/win32/release_dll/sixense_utils.dll" - DESTINATION .) + target_link_libraries(opentrack-tracker-hydra + "${SDK_HYDRA}/lib/win32/release_static/sixense_s.slib" + "${SDK_HYDRA}/lib/win32/release_static/sixense_utils_s.lib") + set_target_properties (opentrack-tracker-hydra PROPERTIES LINK_FLAGS "/NODEFAULTLIB:libcmt.lib") endif() else() if(SDK_HYDRA_AMD64) -- cgit v1.2.3 From 9037b736e2c6f24a4a3ee06e8ae1489deded622e Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 15 Oct 2013 12:07:32 +0200 Subject: bleh --- ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp b/ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp index 869882f9..2561c624 100644 --- a/ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp +++ b/ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp @@ -3,12 +3,10 @@ #include "facetracknoir/global-settings.h" #include "facetracknoir/rotation.h" #include -#if 0 #ifdef _WIN32 # define SIXENSE_STATIC_LIB # define SIXENSE_UTILS_STATIC_LIB #endif -#endif #include #include #ifdef WIN32 -- cgit v1.2.3 From d689972d6cd0774d5deaf2eeafdad17656b7fbc2 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 15 Oct 2013 12:09:13 +0200 Subject: try to fix #define min in M$ headers Signed-off-by: Stanislaw Halik --- ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.h b/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.h index fe8b67fa..30c4b9b5 100644 --- a/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.h +++ b/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.h @@ -28,14 +28,13 @@ #pragma once #include "ftnoir_protocol_base/ftnoir_protocol_base.h" #include "ui_ftnoir_vjoy_controls.h" -#include - #include #include #include #include #include #include "facetracknoir/global-settings.h" +#include #define FT_PROGRAMID "FT_ProgramID" -- cgit v1.2.3 From 32196af69447cd2c901e6d01f72b640f2eaa6b2b Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 15 Oct 2013 13:02:11 +0200 Subject: fix win32 build --- CMakeLists.txt | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 52fac07c..152ba842 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,6 @@ project(opentrack) cmake_minimum_required(VERSION 2.8) +cmake_policy(SET CMP0020 NEW) set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${CMAKE_SOURCE_DIR}/cmake/") SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) @@ -12,6 +13,10 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON) add_definitions(-DOPENTRACK_API) +if(MSVC) + add_definitions(-DNOMINMAX) +endif() + if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") add_definitions(-std=c++11) endif() @@ -63,7 +68,7 @@ if(NOT SDK_FACEAPI_ONLY) set(SDK_ARUCO_LIBPATH "" CACHE FILEPATH "Path to Aruco static library") SET(SDK_OPENCV_STATIC FALSE CACHE BOOL "Whether OpenCV is statically linked") - if (WIN32) + if(WIN32) SET(SDK_SM_FACEAPI_PATH "" CACHE PATH "SeeingMachines FaceAPI SDK path") set(SDK_SIMCONNECT "" CACHE PATH "Path to SimConnect SDK") set(SDK_DIRECTX "" CACHE PATH "Path to DirectX SDK") @@ -341,7 +346,11 @@ endif() if(WIN32 AND SDK_VJOY) include_directories(${SDK_VJOY}) add_library(opentrack-proto-vjoy SHARED ${opentrack-proto-vjoy-c} ${opentrack-proto-vjoy-moc} ${opentrack-proto-vjoy-uih} ${opentrack-proto-vjoy-rcc}) - target_link_libraries(opentrack-proto-vjoy ${MY_QT_LIBS} "${SDK_VJOY}/VJoy.dll") + if(MSVC) + target_link_libraries(opentrack-proto-vjoy ${MY_QT_LIBS} "${SDK_VJOY}/VJoy.lib") + else() + target_link_libraries(opentrack-proto-vjoy ${MY_QT_LIBS} "${SDK_VJOY}/VJoy.dll") + endif() if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) SET_TARGET_PROPERTIES(opentrack-proto-vjoy PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt -Wl,--enable-stdcall-fixup") @@ -503,12 +512,10 @@ endif() add_library(opentrack-tracker-hydra SHARED ${opentrack-tracker-hydra-c} ${opentrack-tracker-hydra-moc} ${opentrack-tracker-hydra-uih} ${opentrack-tracker-hydra-rcc}) target_link_libraries(opentrack-tracker-hydra ${MY_QT_LIBS}) if(WIN32) - if(CMAKE_COMPILER_IS_GNUCXX) - target_link_libraries(opentrack-tracker-hydra - "${SDK_HYDRA}/lib/win32/release_static/sixense_s.slib" - "${SDK_HYDRA}/lib/win32/release_static/sixense_utils_s.lib") - set_target_properties (opentrack-tracker-hydra PROPERTIES LINK_FLAGS "/NODEFAULTLIB:libcmt.lib") - endif() + target_link_libraries(opentrack-tracker-hydra + "${SDK_HYDRA}/lib/win32/release_static/sixense_s.lib" + "${SDK_HYDRA}/lib/win32/release_static/sixense_utils_s.lib") + set_target_properties (opentrack-tracker-hydra PROPERTIES LINK_FLAGS "/NODEFAULTLIB:libcmt.lib") else() if(SDK_HYDRA_AMD64) set(underscore-sixtyfour _x64) -- cgit v1.2.3 From 216af92eae96b014758a9bc89b9eacb3e0dff9de Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 15 Oct 2013 13:03:02 +0200 Subject: hydra: don't include as many headers when not used --- ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp b/ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp index 2561c624..7333fbc4 100644 --- a/ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp +++ b/ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp @@ -9,13 +9,12 @@ #endif #include #include -#ifdef WIN32 -#include -#endif +#if 0 #include #include #include #include +#endif Hydra_Tracker::Hydra_Tracker() { -- cgit v1.2.3 From bb84d3767648fda977a2ff29c7de80aed4f2205f Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 15 Oct 2013 13:03:30 +0200 Subject: freetrackclient: don't include unnecessary headers --- freetrackclient/freetrackclient.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/freetrackclient/freetrackclient.cpp b/freetrackclient/freetrackclient.cpp index efc639ca..71e0e3a7 100644 --- a/freetrackclient/freetrackclient.cpp +++ b/freetrackclient/freetrackclient.cpp @@ -25,7 +25,7 @@ #include #include #include -#include +//#include #include "ftnoir_protocol_ft/fttypes.h" -- cgit v1.2.3 From b3472ae4e00679714e4abdd3a682183779f42865 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 15 Oct 2013 13:06:11 +0200 Subject: fix win32 faceapi bitrot --- ftnoir_tracker_sm/ftnoir_tracker_faceapi.cpp | 2 +- ftnoir_tracker_sm/ftnoir_tracker_sm.h | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ftnoir_tracker_sm/ftnoir_tracker_faceapi.cpp b/ftnoir_tracker_sm/ftnoir_tracker_faceapi.cpp index 71e9c558..af37d925 100644 --- a/ftnoir_tracker_sm/ftnoir_tracker_faceapi.cpp +++ b/ftnoir_tracker_sm/ftnoir_tracker_faceapi.cpp @@ -52,7 +52,7 @@ void FTNoIR_Tracker::StartTracker(QFrame *videoframe ) if ( pMemData != NULL ) { pMemData->command = 0; // Reset any and all commands if (videoframe != NULL) { - pMemData->handle = videoframe->winId(); // Handle of Videoframe widget + pMemData->handle = (HWND) videoframe->winId(); // Handle of Videoframe widget } else { pMemData->handle = NULL; // reset Handle of Videoframe widget diff --git a/ftnoir_tracker_sm/ftnoir_tracker_sm.h b/ftnoir_tracker_sm/ftnoir_tracker_sm.h index 95e1edeb..49ae7ff5 100644 --- a/ftnoir_tracker_sm/ftnoir_tracker_sm.h +++ b/ftnoir_tracker_sm/ftnoir_tracker_sm.h @@ -69,9 +69,7 @@ private: // 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 ); @@ -128,8 +126,10 @@ private slots: settingsDirty = true; } -signals: - void stateChanged(int newState); +public slots: + void stateChanged(int newState) { + settingsDirty = true; + } }; -- 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(-) 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 c1e08d60e51ce515273a6e5b9d31db5425025a58 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 15 Oct 2013 13:22:35 +0200 Subject: fix vjoy the hard way --- ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.h | 15 ++++++++++++--- ftnoir_protocol_vjoy/vjoy.def | 5 +++++ 2 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 ftnoir_protocol_vjoy/vjoy.def diff --git a/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.h b/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.h index 30c4b9b5..5a1d30fb 100644 --- a/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.h +++ b/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.h @@ -115,6 +115,15 @@ typedef struct _JOYSTICK_STATE #include -extern "C" BOOL __stdcall VJoy_Initialize(PCHAR name, PCHAR serial); -extern "C" VOID __stdcall VJoy_Shutdown(); -extern "C" BOOL __stdcall VJoy_UpdateJoyState(int id, PJOYSTICK_STATE pJoyState); +#undef EXTERN_C +#if _MSC_VER +# define EXTERN_C +#else +# define EXTERN_C extern "C" +#endif +#if _MSC_VER +# pragma comment(linker, "/implib:vjoy.def") +#endif +EXTERN_C BOOL __stdcall VJoy_Initialize(PCHAR name, PCHAR serial); +EXTERN_C VOID __stdcall VJoy_Shutdown(); +EXTERN_C BOOL __stdcall VJoy_UpdateJoyState(int id, PJOYSTICK_STATE pJoyState); diff --git a/ftnoir_protocol_vjoy/vjoy.def b/ftnoir_protocol_vjoy/vjoy.def new file mode 100644 index 00000000..aea590a4 --- /dev/null +++ b/ftnoir_protocol_vjoy/vjoy.def @@ -0,0 +1,5 @@ +LIBRARY vjoy.dll +IMPORTS +VJoy_Initialize = _VJoy_Initialize +VJoy_Shutdown = _VJoy_Shutdown +VJoy_UpdateJoyState = _VJoy_UpdateJoyState -- cgit v1.2.3 From 8a6cf016021a9932dc5029cb8942dc93db89b573 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 15 Oct 2013 13:23:18 +0200 Subject: decruft --- ftnoir_tracker_base/ftnoir_tracker_base.h | 7 ------- 1 file changed, 7 deletions(-) diff --git a/ftnoir_tracker_base/ftnoir_tracker_base.h b/ftnoir_tracker_base/ftnoir_tracker_base.h index edbe7379..e9e11b61 100644 --- a/ftnoir_tracker_base/ftnoir_tracker_base.h +++ b/ftnoir_tracker_base/ftnoir_tracker_base.h @@ -33,13 +33,6 @@ #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. -- cgit v1.2.3 From 8e988b5a8509cf811ababd8e49ce85aa4afe4da0 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 15 Oct 2013 13:58:42 +0200 Subject: Fix install target on 'doze --- CMakeLists.txt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 152ba842..adf692af 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -695,14 +695,14 @@ if(NOT SDK_FACEAPI_ONLY) install(FILES ${opentrack-opencv-files} DESTINATION .) endif() if(WIN32 AND NOT CMAKE_COMPILER_IS_GNUCC) - GET_FILENAME_COMPONENT(qt-dirname "${QT_QTCORE_LIBRARY_RELEASE}" PATH) - SET(qt-dirname "${qt-dirname}/../bin/") + GET_FILENAME_COMPONENT(qt-dirname "${Qt5Core_DIR}" PATH) + SET(qt-dirname "${qt-dirname}/../../bin") install(FILES - "${qt-dirname}/QtCore4.dll" - "${qt-dirname}/QtGui4.dll" - "${qt-dirname}/QtNetwork4.dll" - "${qt-dirname}/QtSvg4.dll" - "${qt-dirname}/QtXml4.dll" + "${qt-dirname}/Qt5Core.dll" + "${qt-dirname}/Qt5Gui.dll" + "${qt-dirname}/Qt5Widgets.dll" + "${qt-dirname}/Qt5Network.dll" + "${qt-dirname}/Qt5Xml.dll" DESTINATION . ) endif() -- 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(-) 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(-) 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(-) 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(-) 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(-) 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(-) 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(-) 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(-) 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(-) 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(-) 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(-) 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 4157874768594164e1d5b366e5a9cb9bc931e761 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 16 Oct 2013 23:29:16 +0200 Subject: pass -Wall -Wextra -pedantic --- ftnoir_csv/csv.cpp | 2 +- ftnoir_tracker_aruco/ftnoir_tracker_aruco.h | 2 +- ftnoir_tracker_aruco/include/markerdetector.h | 5 ++++- ftnoir_tracker_hydra/ftnoir_tracker_hydra_dll.cpp | 8 ++++---- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/ftnoir_csv/csv.cpp b/ftnoir_csv/csv.cpp index 4753e8df..4e76e844 100644 --- a/ftnoir_csv/csv.cpp +++ b/ftnoir_csv/csv.cpp @@ -137,7 +137,7 @@ void CSV::getGameData( const int id, unsigned char* table, QString& gamename) if (gameLine.count() > 6) { if (gameLine.at(6).compare( gameID, Qt::CaseInsensitive ) == 0) { QByteArray id = gameLine.at(7).toLatin1(); - int tmp[8]; + unsigned int tmp[8]; int fuzz[3]; if (gameLine.at(3) == QString("V160")) { diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h index ddbdd179..0f811f5d 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h @@ -57,7 +57,7 @@ public: void showEvent ( QShowEvent * event ); void Initialize(QWidget *parent); - void registerTracker(ITracker *tracker) {} + void registerTracker(ITracker *) {} void unRegisterTracker() {} private: diff --git a/ftnoir_tracker_aruco/include/markerdetector.h b/ftnoir_tracker_aruco/include/markerdetector.h index 35369cea..68aa7f8a 100644 --- a/ftnoir_tracker_aruco/include/markerdetector.h +++ b/ftnoir_tracker_aruco/include/markerdetector.h @@ -52,10 +52,13 @@ class ARUCO_EXPORTS MarkerDetector contour=M.contour; idx=M.idx; } - MarkerCandidate & operator=(const MarkerCandidate &M){ + MarkerCandidate operator=(const MarkerCandidate &M){ + if (this == &M) + return *this; (*(Marker*)this)=(*(Marker*)&M); contour=M.contour; idx=M.idx; + return M; } vector contour;//all the points of its contour diff --git a/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dll.cpp b/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dll.cpp index 64eaaa42..db6f658c 100644 --- a/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dll.cpp +++ b/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dll.cpp @@ -18,22 +18,22 @@ 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. -- 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(-) 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 1f96d6ac964697a98fe5ae1e34d07008b0b89dd9 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 16 Oct 2013 23:30:08 +0200 Subject: pass -Wall -Wextra -pedantic --- ftnoir_filter_accela/ftnoir_filter_accela.h | 2 +- ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp | 2 +- ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp | 2 +- ftnoir_filter_ewma2/ftnoir_filter_ewma2.h | 5 ++--- ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp | 2 +- 5 files changed, 6 insertions(+), 7 deletions(-) diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.h b/ftnoir_filter_accela/ftnoir_filter_accela.h index 3dae7580..86baf72f 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.h +++ b/ftnoir_filter_accela/ftnoir_filter_accela.h @@ -67,7 +67,7 @@ class FTNOIR_FILTER_BASE_EXPORT FilterControls: public QWidget, public IFilterDi public: explicit FilterControls(); virtual ~FilterControls(); - void showEvent ( QShowEvent * event ); + void showEvent (QShowEvent *); void Initialize(QWidget *parent); void registerFilter(IFilter* filter); void unregisterFilter(); diff --git a/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp b/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp index c5cebb32..6ae1e4bc 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp @@ -91,7 +91,7 @@ void FilterControls::doOK() { } // override show event -void FilterControls::showEvent ( QShowEvent * event ) { +void FilterControls::showEvent ( QShowEvent * ) { } // diff --git a/ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp b/ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp index 6bf2396a..3b208ef2 100644 --- a/ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp +++ b/ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp @@ -81,7 +81,7 @@ void FTNoIR_Filter::loadSettings() { void FTNoIR_Filter::FilterHeadPoseData(const double *target_camera_position, double *new_camera_position, - const double *last_post_filter) + const double *) { double delta; double new_alpha; diff --git a/ftnoir_filter_ewma2/ftnoir_filter_ewma2.h b/ftnoir_filter_ewma2/ftnoir_filter_ewma2.h index e3a264be..656b2895 100644 --- a/ftnoir_filter_ewma2/ftnoir_filter_ewma2.h +++ b/ftnoir_filter_ewma2/ftnoir_filter_ewma2.h @@ -45,8 +45,7 @@ public: void Initialize() {} void FilterHeadPoseData(const double *target_camera_position, - double *new_camera_position, - const double *last_post_filter); + double *new_camera_position, const double *); void receiveSettings(double smin, double smax, double sexpt); private: @@ -75,7 +74,7 @@ class FilterControls: public QWidget, public IFilterDialog public: explicit FilterControls(); virtual ~FilterControls(); - void showEvent ( QShowEvent * event ); + void showEvent (QShowEvent *); void Initialize(QWidget *parent); void registerFilter(IFilter* flt); void unregisterFilter(); diff --git a/ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp b/ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp index f4b8aad2..c304eb0a 100644 --- a/ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp +++ b/ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp @@ -99,7 +99,7 @@ void FilterControls::doOK() { } // override show event -void FilterControls::showEvent ( QShowEvent * event ) { +void FilterControls::showEvent ( QShowEvent * ) { loadSettings(); } -- cgit v1.2.3 From 8905749b7949f10a3635faa13b44cba01a6edbe4 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 16 Oct 2013 23:30:16 +0200 Subject: default to Qt background Signed-off-by: Stanislaw Halik --- ftnoir_posewidget/glwidget.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ftnoir_posewidget/glwidget.cpp b/ftnoir_posewidget/glwidget.cpp index 9f495e0b..275953a7 100644 --- a/ftnoir_posewidget/glwidget.cpp +++ b/ftnoir_posewidget/glwidget.cpp @@ -139,9 +139,9 @@ void GLWidget::project_quad_texture() { 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); + QColor bgColor = palette().color(QPalette::Normal, QPalette::Background); + texture.fill(bgColor); const Vec2f projected[2][3] = { { p2[0], p2[1], p2[2] }, { p2[3], p2[1], p2[2] } }; const Vec2f origs[2][3] = { @@ -227,4 +227,4 @@ void GLWidget::project_quad_texture() { } } pixmap = QPixmap::fromImage(texture); -} \ No newline at end of file +} -- 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(-) 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 3e71e6218557bf14220a23d5afb772c170545cb4 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 16 Oct 2013 23:30:53 +0200 Subject: reformat Signed-off-by: Stanislaw Halik --- x-plane-plugin/plugin.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x-plane-plugin/plugin.c b/x-plane-plugin/plugin.c index 1f30f04d..67dab7ad 100644 --- a/x-plane-plugin/plugin.c +++ b/x-plane-plugin/plugin.c @@ -83,8 +83,8 @@ static void reinit_offset() { } int write_head_position( - XPLMDrawingPhase inPhase, - int inIsBefore, + XPLMDrawingPhase inPhase, + int inIsBefore, void * inRefcon) { if (lck_posix != NULL && shm_posix != NULL) { -- cgit v1.2.3 From a8a8cfac5f1be7e0cbfadcc2def8aaa0e8d9d9a0 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 16 Oct 2013 23:44:58 +0200 Subject: all except 3rdparty-maintained stuff pass -Wall -Wextra -pedantic Signed-off-by: Stanislaw Halik --- FTNoIR_Tracker_PT/boost-compat.h | 2 +- ftnoir_csv/csv.cpp | 4 ++-- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 4 ++-- ftnoir_tracker_aruco/ftnoir_tracker_aruco.h | 4 ++-- ftnoir_tracker_aruco/include/boarddetector.h | 2 +- ftnoir_tracker_aruco/include/cvdrawingutils.h | 2 +- ftnoir_tracker_aruco/include/markerdetector.h | 6 +----- ftnoir_tracker_ht/ftnoir_tracker_ht.cpp | 4 ++-- ftnoir_tracker_ht/ftnoir_tracker_ht.h | 6 +++--- ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp | 5 +---- ftnoir_tracker_hydra/ftnoir_tracker_hydra.h | 8 ++++---- ftnoir_tracker_hydra/ftnoir_tracker_hydra_dialog.cpp | 2 +- ftnoir_tracker_udp/ftnoir_tracker_udp.cpp | 2 +- ftnoir_tracker_udp/ftnoir_tracker_udp.h | 8 ++++---- ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp | 2 +- x-plane-plugin/plugin.c | 20 +++++++++++++------- 16 files changed, 40 insertions(+), 41 deletions(-) diff --git a/FTNoIR_Tracker_PT/boost-compat.h b/FTNoIR_Tracker_PT/boost-compat.h index b5be237a..612f2c4d 100644 --- a/FTNoIR_Tracker_PT/boost-compat.h +++ b/FTNoIR_Tracker_PT/boost-compat.h @@ -2,4 +2,4 @@ #include namespace boost { using std::shared_ptr; -}; +} diff --git a/ftnoir_csv/csv.cpp b/ftnoir_csv/csv.cpp index 4e76e844..ebdf50bb 100644 --- a/ftnoir_csv/csv.cpp +++ b/ftnoir_csv/csv.cpp @@ -138,7 +138,7 @@ void CSV::getGameData( const int id, unsigned char* table, QString& gamename) if (gameLine.at(6).compare( gameID, Qt::CaseInsensitive ) == 0) { QByteArray id = gameLine.at(7).toLatin1(); unsigned int tmp[8]; - int fuzz[3]; + unsigned int fuzz[3]; if (gameLine.at(3) == QString("V160")) { qDebug() << "no table"; @@ -155,7 +155,7 @@ void CSV::getGameData( const int id, unsigned char* table, QString& gamename) tmp + 6, tmp + 5, tmp + 4, - fuzz + 1) != 11 || ((fuzz[2] << 8) | fuzz[0]) != gameLine.at(0).toInt()) + fuzz + 1) != 11 || (int) ((fuzz[2] << 8) | fuzz[0]) != gameLine.at(0).toInt()) { qDebug() << "scanf failed" << fuzz[0] << fuzz[1] << fuzz[2]; } diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index c735b479..a221c2ff 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -385,11 +385,11 @@ TrackerControls::~TrackerControls() { } -void TrackerControls::showEvent(QShowEvent *event) +void TrackerControls::showEvent(QShowEvent *) { } -void TrackerControls::Initialize(QWidget* parent) +void TrackerControls::Initialize(QWidget*) { loadSettings(); show(); diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h index 0f811f5d..260ca41e 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h @@ -54,9 +54,9 @@ public: explicit TrackerControls(); virtual ~TrackerControls(); - void showEvent ( QShowEvent * event ); + void showEvent (QShowEvent *); - void Initialize(QWidget *parent); + void Initialize(QWidget *); void registerTracker(ITracker *) {} void unRegisterTracker() {} diff --git a/ftnoir_tracker_aruco/include/boarddetector.h b/ftnoir_tracker_aruco/include/boarddetector.h index a0ee2361..4770b5c9 100644 --- a/ftnoir_tracker_aruco/include/boarddetector.h +++ b/ftnoir_tracker_aruco/include/boarddetector.h @@ -134,6 +134,6 @@ private: }; -}; +} #endif diff --git a/ftnoir_tracker_aruco/include/cvdrawingutils.h b/ftnoir_tracker_aruco/include/cvdrawingutils.h index ff67242f..38e9986e 100644 --- a/ftnoir_tracker_aruco/include/cvdrawingutils.h +++ b/ftnoir_tracker_aruco/include/cvdrawingutils.h @@ -46,7 +46,7 @@ namespace aruco static void draw3dCube(cv::Mat &Image,Board &m,const CameraParameters &CP); }; -}; +} #endif diff --git a/ftnoir_tracker_aruco/include/markerdetector.h b/ftnoir_tracker_aruco/include/markerdetector.h index 68aa7f8a..4d6e7b90 100644 --- a/ftnoir_tracker_aruco/include/markerdetector.h +++ b/ftnoir_tracker_aruco/include/markerdetector.h @@ -353,9 +353,5 @@ private: void draw(cv::Mat out,const std::vector &markers ); }; - - - - -}; +} #endif diff --git a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp index b4fd03f6..14cd3942 100644 --- a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp +++ b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp @@ -305,11 +305,11 @@ TrackerControls::~TrackerControls() { } -void TrackerControls::showEvent(QShowEvent *event) +void TrackerControls::showEvent(QShowEvent *) { } -void TrackerControls::Initialize(QWidget* parent) +void TrackerControls::Initialize(QWidget*) { loadSettings(); show(); diff --git a/ftnoir_tracker_ht/ftnoir_tracker_ht.h b/ftnoir_tracker_ht/ftnoir_tracker_ht.h index 96607411..aae4e6d6 100644 --- a/ftnoir_tracker_ht/ftnoir_tracker_ht.h +++ b/ftnoir_tracker_ht/ftnoir_tracker_ht.h @@ -46,10 +46,10 @@ public: explicit TrackerControls(); virtual ~TrackerControls(); - void showEvent ( QShowEvent * event ); + void showEvent (QShowEvent *); - void Initialize(QWidget *parent); - void registerTracker(ITracker *tracker) {} + void Initialize(QWidget *); + void registerTracker(ITracker *) {} void unRegisterTracker() {} private: diff --git a/ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp b/ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp index 7333fbc4..86ca8888 100644 --- a/ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp +++ b/ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp @@ -48,7 +48,7 @@ void controller_manager_setup_callback( sixenseUtils::ControllerManager::setup_s } }*/ -void Hydra_Tracker::StartTracker(QFrame* videoFrame) +void Hydra_Tracker::StartTracker(QFrame*) { //QMessageBox::warning(0,"FaceTrackNoIR Notification", "Tracking loading settings...",QMessageBox::Ok,QMessageBox::NoButton); loadSettings(); @@ -78,9 +78,6 @@ bool Hydra_Tracker::GiveHeadPoseData(double *data) //Rotation quat = Rotation(acd.controllers[0].rot_quat[1],acd.controllers[0].rot_quat[2],acd.controllers[0].rot_quat[3],acd.controllers[0].rot_quat[0]); sixenseMath::Matrix4 mat = sixenseMath::Matrix4(acd.controllers[0].rot_mat);// sixenseMath::Quat(acd.controllers[0].rot_quat[1],acd.controllers[0].rot_quat[2],acd.controllers[0].rot_quat[3],acd.controllers[0].rot_quat[0]); - double yaw = 0.0f; - double pitch = 0.0f; - double roll = 0.0f; float ypr[3]; mat.getEulerAngles().fill(ypr); diff --git a/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h b/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h index 82a72f56..19f2a685 100644 --- a/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h +++ b/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h @@ -11,7 +11,7 @@ public: Hydra_Tracker(); ~Hydra_Tracker(); - void StartTracker( QFrame *videoframe ); + void StartTracker(QFrame *); bool GiveHeadPoseData(double *data); void loadSettings(); volatile bool should_quit; @@ -44,11 +44,11 @@ public: explicit TrackerControls(); ~TrackerControls(); - void showEvent ( QShowEvent * event ); + void showEvent (QShowEvent *); void Initialize(QWidget *parent); - void registerTracker(ITracker *tracker) {}; - void unRegisterTracker() {}; + void registerTracker(ITracker *) {} + void unRegisterTracker() {} private: Ui::UIHydraControls ui; diff --git a/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dialog.cpp b/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dialog.cpp index 913f8070..165f8573 100644 --- a/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dialog.cpp +++ b/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dialog.cpp @@ -81,7 +81,7 @@ void TrackerControls::doOK() { } // override show event -void TrackerControls::showEvent ( QShowEvent * event ) { +void TrackerControls::showEvent ( QShowEvent * ) { loadSettings(); } diff --git a/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp b/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp index d67fb636..1539707e 100644 --- a/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp +++ b/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp @@ -88,7 +88,7 @@ quint16 senderPort; } } -void FTNoIR_Tracker::StartTracker(QFrame* videoFrame) +void FTNoIR_Tracker::StartTracker(QFrame*) { loadSettings(); // diff --git a/ftnoir_tracker_udp/ftnoir_tracker_udp.h b/ftnoir_tracker_udp/ftnoir_tracker_udp.h index e5ea7ff3..d158630b 100644 --- a/ftnoir_tracker_udp/ftnoir_tracker_udp.h +++ b/ftnoir_tracker_udp/ftnoir_tracker_udp.h @@ -15,7 +15,7 @@ public: FTNoIR_Tracker(); ~FTNoIR_Tracker(); - void StartTracker( QFrame *videoframe ); + void StartTracker(QFrame *); bool GiveHeadPoseData(double *data); void loadSettings(); volatile bool should_quit; @@ -49,11 +49,11 @@ public: explicit TrackerControls(); ~TrackerControls(); - void showEvent ( QShowEvent * event ); + void showEvent (QShowEvent *); void Initialize(QWidget *parent); - void registerTracker(ITracker *tracker) {}; - void unRegisterTracker() {}; + void registerTracker(ITracker *) {} + void unRegisterTracker() {} private: Ui::UICFTNClientControls ui; diff --git a/ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp b/ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp index 55bb6c97..e17d5c32 100644 --- a/ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp +++ b/ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp @@ -81,7 +81,7 @@ void TrackerControls::doOK() { } // override show event -void TrackerControls::showEvent ( QShowEvent * event ) { +void TrackerControls::showEvent ( QShowEvent * ) { loadSettings(); } diff --git a/x-plane-plugin/plugin.c b/x-plane-plugin/plugin.c index 67dab7ad..38e1e7bf 100644 --- a/x-plane-plugin/plugin.c +++ b/x-plane-plugin/plugin.c @@ -40,7 +40,13 @@ static WineSHM* shm_posix = NULL; static void *view_x, *view_y, *view_z, *view_heading, *view_pitch; static float offset_x, offset_y, offset_z; -PortableLockedShm* PortableLockedShm_init(const char *shmName, const char *mutexName, int mapSize) +#ifdef __GNUC__ +# define OT_UNUSED(varname) varname __attribute__((__unused__)) +#else +# define OT_UNUSED(varname) varname +#endif + +PortableLockedShm* PortableLockedShm_init(const char *shmName, const char *OT_UNUSED(mutexName), int mapSize) { PortableLockedShm* self = malloc(sizeof(PortableLockedShm)); char shm_filename[NAME_MAX]; @@ -83,9 +89,9 @@ static void reinit_offset() { } int write_head_position( - XPLMDrawingPhase inPhase, - int inIsBefore, - void * inRefcon) + XPLMDrawingPhase OT_UNUSED(inPhase), + int OT_UNUSED(inIsBefore), + void * OT_UNUSED(inRefcon)) { if (lck_posix != NULL && shm_posix != NULL) { PortableLockedShm_lock(lck_posix); @@ -140,9 +146,9 @@ PLUGIN_API void XPluginDisable ( void ) { } PLUGIN_API void XPluginReceiveMessage( - XPLMPluginID inFromWho, - int inMessage, - void * inParam) + XPLMPluginID OT_UNUSED(inFromWho), + int OT_UNUSED(inMessage), + void * OT_UNUSED(inParam)) { if (inMessage == XPLM_MSG_AIRPORT_LOADED) reinit_offset(); -- 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(-) 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(-) 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 b8f2a9109288101f7388a1c3f7aaff8ae13d5bdf Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 17 Oct 2013 01:18:38 +0200 Subject: fix size Signed-off-by: Stanislaw Halik --- ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui b/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui index 24b296ea..ba77f1a8 100644 --- a/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui +++ b/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui @@ -9,10 +9,22 @@ 0 0 - 620 - 71 + 615 + 68 + + + 0 + 0 + + + + + 616 + 68 + + Filter settings -- cgit v1.2.3 From 916e32dd0b6c369d1e75c8339860ab443ef6ff32 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 17 Oct 2013 01:18:46 +0200 Subject: fix exports Signed-off-by: Stanislaw Halik --- ftnoir_filter_accela/ftnoir_filter_accela.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.h b/ftnoir_filter_accela/ftnoir_filter_accela.h index 86baf72f..4afe127b 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.h +++ b/ftnoir_filter_accela/ftnoir_filter_accela.h @@ -38,7 +38,7 @@ //******************************************************************************************************* // FaceTrackNoIR Filter class. //******************************************************************************************************* -class FTNOIR_FILTER_BASE_EXPORT FTNoIR_Filter : public IFilter +class FTNoIR_Filter : public IFilter { public: FTNoIR_Filter(); @@ -61,7 +61,7 @@ private: //******************************************************************************************************* // Widget that has controls for FTNoIR protocol filter-settings. -class FTNOIR_FILTER_BASE_EXPORT FilterControls: public QWidget, public IFilterDialog +class FilterControls: public QWidget, public IFilterDialog { Q_OBJECT public: -- cgit v1.2.3 From 4abd05ba1a4f45791d37dbf12ecdaa23d6b029ec Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 17 Oct 2013 01:18:59 +0200 Subject: change bg color Signed-off-by: Stanislaw Halik --- ftnoir_posewidget/glwidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ftnoir_posewidget/glwidget.cpp b/ftnoir_posewidget/glwidget.cpp index 275953a7..71af8a08 100644 --- a/ftnoir_posewidget/glwidget.cpp +++ b/ftnoir_posewidget/glwidget.cpp @@ -140,7 +140,7 @@ void GLWidget::project_quad_texture() { for (int i = 0; i < 4; i++) p2[i] = Vec2f(pt[i].x, pt[i].y); QImage texture(QSize(sx, sy), QImage::Format_RGB888); - QColor bgColor = palette().color(QPalette::Normal, QPalette::Background); + QColor bgColor = palette().color(QPalette::Current, QPalette::Window); texture.fill(bgColor); const Vec2f projected[2][3] = { { p2[0], p2[1], p2[2] }, { p2[3], p2[1], p2[2] } }; -- cgit v1.2.3 From 1889d02d28d31ce45783c30d90479d17e7f021bb Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 17 Oct 2013 01:19:20 +0200 Subject: resize slightly --- ftnoir_protocol_wine/ftnoir_winecontrols.ui | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ftnoir_protocol_wine/ftnoir_winecontrols.ui b/ftnoir_protocol_wine/ftnoir_winecontrols.ui index c5e19f2c..749feb0f 100644 --- a/ftnoir_protocol_wine/ftnoir_winecontrols.ui +++ b/ftnoir_protocol_wine/ftnoir_winecontrols.ui @@ -9,8 +9,8 @@ 0 0 - 411 - 112 + 409 + 110 -- cgit v1.2.3 From 1abc4a8aaba0cb1d01492b60d655181814e67ac0 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 17 Oct 2013 01:19:53 +0200 Subject: simplify color stuffies Signed-off-by: Stanislaw Halik --- qfunctionconfigurator/qfunctionconfigurator.cpp | 8 +++----- qfunctionconfigurator/qfunctionconfigurator.h | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/qfunctionconfigurator/qfunctionconfigurator.cpp b/qfunctionconfigurator/qfunctionconfigurator.cpp index bad06f8a..a068a53c 100644 --- a/qfunctionconfigurator/qfunctionconfigurator.cpp +++ b/qfunctionconfigurator/qfunctionconfigurator.cpp @@ -17,10 +17,9 @@ #include #include #include - #include - -#include +#include +#include static const int pointSize = 5; @@ -111,9 +110,8 @@ void QFunctionConfigurator::drawBackground(const QRectF &fullRect) { int i; QRect scale; - _background = QPixmap(fullRect.width(), fullRect.height()); - QColor bgColor = palette().color(QPalette::Normal, QPalette::Background); + auto bgColor = palette().button(); QPainter painter(&_background); painter.fillRect(fullRect, bgColor); painter.setRenderHint(QPainter::Antialiasing); diff --git a/qfunctionconfigurator/qfunctionconfigurator.h b/qfunctionconfigurator/qfunctionconfigurator.h index fa72fb72..1ac919fe 100644 --- a/qfunctionconfigurator/qfunctionconfigurator.h +++ b/qfunctionconfigurator/qfunctionconfigurator.h @@ -112,7 +112,7 @@ protected slots: void mouseReleaseEvent(QMouseEvent *e); protected: - void drawBackground(const QRectF &rect); + void drawBackground(const QRectF &); 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 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(-) 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 b15ec9f185e600e45213b5727e9b2a28c104940f Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 17 Oct 2013 08:04:59 +0200 Subject: fix win32 build breakage Signed-off-by: Stanislaw Halik --- ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp | 2 +- ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h | 2 +- ftnoir_protocol_ft/ftnoir_protocol_ft.cpp | 55 +++++++++-------------- ftnoir_protocol_mouse/ftnoir_protocol_mouse.cpp | 2 +- ftnoir_protocol_mouse/ftnoir_protocol_mouse.h | 2 +- ftnoir_protocol_sc/ftnoir_protocol_sc.cpp | 2 +- ftnoir_protocol_sc/ftnoir_protocol_sc.h | 2 +- ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.cpp | 2 +- ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.h | 2 +- 9 files changed, 30 insertions(+), 41 deletions(-) diff --git a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp index df25e9ed..986ccc65 100644 --- a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp +++ b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp @@ -87,7 +87,7 @@ void FTNoIR_Protocol::loadSettings() { // // Update Headpose in Game. // -void FTNoIR_Protocol::sendHeadposeToGame(double *headpose, double *rawheadpose ) { +void FTNoIR_Protocol::sendHeadposeToGame(const double *headpose ) { DWORD result; TFSState pitch; TFSState yaw; diff --git a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h index d901b63e..52b2cd98 100644 --- a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h +++ b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h @@ -61,7 +61,7 @@ public: FTNoIR_Protocol(); ~FTNoIR_Protocol(); bool checkServerInstallationOK(); - void sendHeadposeToGame( double *headpose, double *rawheadpose ); + void sendHeadposeToGame(const double* headpose); QString getGameName() { return "Microsoft Flight Simulator X"; } diff --git a/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp b/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp index 47e99d31..186562cf 100644 --- a/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp +++ b/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp @@ -92,39 +92,28 @@ void FTNoIR_Protocol::loadSettings() { // // 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; +void FTNoIR_Protocol::sendHeadposeToGame(const double* headpose) { + float virtPosX; + float virtPosY; + float virtPosZ; + + float virtRotX; + float virtRotY; + float virtRotZ; + + float headPosX; + float headPosY; + float headPosZ; + + float headRotX; + float headRotY; + float headRotZ; + headRotX = virtRotX = getRadsFromDegrees(headpose[Pitch]); + headRotY = virtRotY = getRadsFromDegrees(headpose[Yaw]); + headRotZ = virtRotZ = getRadsFromDegrees(headpose[Roll]); + headPosX = virtPosX = headpose[TX] * 10; + headPosY = virtPosY = headpose[TY] * 10; + headPosZ = virtPosZ = headpose[TZ] * 10; shm.lock(); diff --git a/ftnoir_protocol_mouse/ftnoir_protocol_mouse.cpp b/ftnoir_protocol_mouse/ftnoir_protocol_mouse.cpp index 8601bdfd..64e010a8 100644 --- a/ftnoir_protocol_mouse/ftnoir_protocol_mouse.cpp +++ b/ftnoir_protocol_mouse/ftnoir_protocol_mouse.cpp @@ -58,7 +58,7 @@ void FTNoIR_Protocol::loadSettings() { // // Update Headpose in Game. // -void FTNoIR_Protocol::sendHeadposeToGame(double *headpose, double *rawheadpose ) { +void FTNoIR_Protocol::sendHeadposeToGame(const double *headpose ) { float fMouse_X = 0; float fMouse_Y = 0; diff --git a/ftnoir_protocol_mouse/ftnoir_protocol_mouse.h b/ftnoir_protocol_mouse/ftnoir_protocol_mouse.h index 5aad9c01..1eb80b12 100644 --- a/ftnoir_protocol_mouse/ftnoir_protocol_mouse.h +++ b/ftnoir_protocol_mouse/ftnoir_protocol_mouse.h @@ -60,7 +60,7 @@ public: FTNoIR_Protocol(); ~FTNoIR_Protocol(); bool checkServerInstallationOK(); - void sendHeadposeToGame( double *headpose, double *rawheadpose ); + void sendHeadposeToGame( const double *headpose); QString getGameName() { return "Mouse tracker"; } diff --git a/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp b/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp index ca07fbf6..8a60f8fb 100644 --- a/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp +++ b/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp @@ -82,7 +82,7 @@ void FTNoIR_Protocol::loadSettings() { // // Update Headpose in Game. // -void FTNoIR_Protocol::sendHeadposeToGame( double *headpose, double *rawheadpose ) { +void FTNoIR_Protocol::sendHeadposeToGame( const double *headpose ) { PDWORD_PTR MsgResult = 0; diff --git a/ftnoir_protocol_sc/ftnoir_protocol_sc.h b/ftnoir_protocol_sc/ftnoir_protocol_sc.h index b24eb0cf..9ac56b30 100644 --- a/ftnoir_protocol_sc/ftnoir_protocol_sc.h +++ b/ftnoir_protocol_sc/ftnoir_protocol_sc.h @@ -83,7 +83,7 @@ public: FTNoIR_Protocol(); ~FTNoIR_Protocol(); bool checkServerInstallationOK(); - void sendHeadposeToGame( double *headpose, double *rawheadpose ); + void sendHeadposeToGame(const double* headpose); QString getGameName() { return "FS2004/FSX"; } diff --git a/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.cpp b/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.cpp index 50a7bf97..76767c3b 100644 --- a/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.cpp +++ b/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.cpp @@ -14,7 +14,7 @@ FTNoIR_Protocol::~FTNoIR_Protocol() VJoy_Shutdown(); } -void FTNoIR_Protocol::sendHeadposeToGame( double *headpose, double *rawheadpose ) { +void FTNoIR_Protocol::sendHeadposeToGame( const double *headpose ) { JOYSTICK_STATE state[2] = { 0 }; state[0].XAxis = std::min(VJOY_AXIS_MAX, std::max(VJOY_AXIS_MIN, headpose[Yaw] * VJOY_AXIS_MAX / 180.0)); diff --git a/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.h b/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.h index 5a1d30fb..2fe53669 100644 --- a/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.h +++ b/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.h @@ -46,7 +46,7 @@ public: bool checkServerInstallationOK() { return true; } - void sendHeadposeToGame( double *headpose, double *rawheadpose ); + void sendHeadposeToGame( const double *headpose ); QString getGameName() { return "Virtual joystick"; } -- cgit v1.2.3 From 4d21a6c5db8ec555ed94c5f8a85482b988fec34b Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 17 Oct 2013 08:09:09 +0200 Subject: fix last woe32 breakage --- ftnoir_protocol_ft/ftnoir_protocol_ft.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ftnoir_protocol_ft/ftnoir_protocol_ft.h b/ftnoir_protocol_ft/ftnoir_protocol_ft.h index 05860907..cd77bbe4 100644 --- a/ftnoir_protocol_ft/ftnoir_protocol_ft.h +++ b/ftnoir_protocol_ft/ftnoir_protocol_ft.h @@ -55,7 +55,7 @@ public: FTNoIR_Protocol(); ~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; -- 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(-) 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(-) 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 b47421b6b86aed973bc35407dfe2a44c977bd968 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 17 Oct 2013 20:41:38 +0200 Subject: Now that mouse tracking is gone, increase point bbox Signed-off-by: Stanislaw Halik --- qfunctionconfigurator/qfunctionconfigurator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qfunctionconfigurator/qfunctionconfigurator.cpp b/qfunctionconfigurator/qfunctionconfigurator.cpp index 0b4df033..1d401ddd 100644 --- a/qfunctionconfigurator/qfunctionconfigurator.cpp +++ b/qfunctionconfigurator/qfunctionconfigurator.cpp @@ -486,7 +486,7 @@ bool QFunctionConfigurator::markContains(const QPointF &pos, const QPointF &coor { QRectF rect(pos.x() - pointSize, pos.y() - pointSize, - pointSize*2, pointSize*2); + pointSize*3, pointSize*3); QPainterPath path; path.addEllipse(rect); return path.contains(coord); -- cgit v1.2.3 From 136151e9499ac8f2f7ec1a169a973d65b15820bb Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 19 Oct 2013 15:43:21 +0200 Subject: untested unbreakage Signed-off-by: Stanislaw Halik --- FTNoIR_Tracker_PT/ftnoir_tracker_pt.h | 2 +- ftnoir_tracker_aruco/ftnoir_tracker_aruco.h | 2 +- ftnoir_tracker_base/ftnoir_tracker_base.h | 2 +- ftnoir_tracker_ht/ftnoir_tracker_ht.h | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h index 2430f5f0..e00ab1df 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h @@ -38,7 +38,7 @@ class Tracker : public ITracker, QThread, public FrameProvider { public: Tracker(); - ~Tracker(); + virtual ~Tracker() override; // --- ITracker interface --- virtual void Initialize(QFrame *videoframe); diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h index 260ca41e..ec4c6c9d 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h @@ -24,7 +24,7 @@ class Tracker : public QThread, public ITracker Q_OBJECT public: Tracker(); - ~Tracker(); + virtual ~Tracker() override; void StartTracker(QFrame* frame); bool GiveHeadPoseData(double *data); bool enableTX, enableTY, enableTZ, enableRX, enableRY, enableRZ; diff --git a/ftnoir_tracker_base/ftnoir_tracker_base.h b/ftnoir_tracker_base/ftnoir_tracker_base.h index e9e11b61..66304bd7 100644 --- a/ftnoir_tracker_base/ftnoir_tracker_base.h +++ b/ftnoir_tracker_base/ftnoir_tracker_base.h @@ -41,7 +41,7 @@ // Instances are obtained via factory function. struct ITracker { - virtual ~ITracker() {} + virtual ~ITracker() = 0; virtual void StartTracker( QFrame* frame ) = 0; virtual bool GiveHeadPoseData(double *data) = 0; }; diff --git a/ftnoir_tracker_ht/ftnoir_tracker_ht.h b/ftnoir_tracker_ht/ftnoir_tracker_ht.h index aae4e6d6..20648c51 100644 --- a/ftnoir_tracker_ht/ftnoir_tracker_ht.h +++ b/ftnoir_tracker_ht/ftnoir_tracker_ht.h @@ -22,7 +22,7 @@ class Tracker : public QObject, public ITracker Q_OBJECT public: Tracker(); - ~Tracker(); + virtual ~Tracker() override; void StartTracker(QFrame* frame); bool GiveHeadPoseData(double *data); bool enableTX, enableTY, enableTZ, enableRX, enableRY, enableRZ; -- cgit v1.2.3 From 7153a0b4daa30cef7d6e721e7b2edc511a1adf71 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 19 Oct 2013 15:55:52 +0200 Subject: unbreak build Signed-off-by: Stanislaw Halik Reported-by: mm0zct --- CMakeLists.txt | 5 ++++- FTNoIR_Tracker_PT/ftnoir_tracker_pt.h | 2 +- ftnoir_tracker_aruco/ftnoir_tracker_aruco.h | 2 +- ftnoir_tracker_ht/ftnoir_tracker_ht.h | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index adf692af..f875665f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,9 @@ project(opentrack) cmake_minimum_required(VERSION 2.8) -cmake_policy(SET CMP0020 NEW) + +if(NOT CMAKE_VERSION LESS "2.10.0") + cmake_policy(SET CMP0020 NEW) +endif() set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${CMAKE_SOURCE_DIR}/cmake/") SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h index e00ab1df..64f282b6 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h @@ -38,7 +38,7 @@ class Tracker : public ITracker, QThread, public FrameProvider { public: Tracker(); - virtual ~Tracker() override; + virtual ~Tracker(); // --- ITracker interface --- virtual void Initialize(QFrame *videoframe); diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h index ec4c6c9d..815ca91c 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h @@ -24,7 +24,7 @@ class Tracker : public QThread, public ITracker Q_OBJECT public: Tracker(); - virtual ~Tracker() override; + virtual ~Tracker(); void StartTracker(QFrame* frame); bool GiveHeadPoseData(double *data); bool enableTX, enableTY, enableTZ, enableRX, enableRY, enableRZ; diff --git a/ftnoir_tracker_ht/ftnoir_tracker_ht.h b/ftnoir_tracker_ht/ftnoir_tracker_ht.h index 20648c51..bde4ca67 100644 --- a/ftnoir_tracker_ht/ftnoir_tracker_ht.h +++ b/ftnoir_tracker_ht/ftnoir_tracker_ht.h @@ -22,7 +22,7 @@ class Tracker : public QObject, public ITracker Q_OBJECT public: Tracker(); - virtual ~Tracker() override; + virtual ~Tracker(); void StartTracker(QFrame* frame); bool GiveHeadPoseData(double *data); bool enableTX, enableTY, enableTZ, enableRX, enableRY, enableRZ; -- cgit v1.2.3 From 1dbae4063904354aa7c63187da242a88e0de9fc2 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 19 Oct 2013 16:00:23 +0200 Subject: fix build #2 Signed-off-by: Stanislaw Halik Reported-by: mm0zct --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f875665f..73ffec68 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ project(opentrack) cmake_minimum_required(VERSION 2.8) -if(NOT CMAKE_VERSION LESS "2.10.0") +if(CMAKE_VERSION VERSION_GREATER "2.10.0") cmake_policy(SET CMP0020 NEW) endif() set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${CMAKE_SOURCE_DIR}/cmake/") -- cgit v1.2.3 From 0cdf32cea57c01b8850a200656712c525c8cff4b Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 19 Oct 2013 16:13:58 +0200 Subject: fix build #3 Signed-off-by: Stanislaw Halik Reported-by: mm0zct --- ftnoir_tracker_base/ftnoir_tracker_base.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ftnoir_tracker_base/ftnoir_tracker_base.h b/ftnoir_tracker_base/ftnoir_tracker_base.h index 66304bd7..cb83aea3 100644 --- a/ftnoir_tracker_base/ftnoir_tracker_base.h +++ b/ftnoir_tracker_base/ftnoir_tracker_base.h @@ -46,6 +46,8 @@ struct ITracker virtual bool GiveHeadPoseData(double *data) = 0; }; +inline ITracker::~ITracker() { } + typedef ITracker* ITrackerPtr; //////////////////////////////////////////////////////////////////////////////// -- 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(-) 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 17f5ad8bc8a10668f4e0968fd5a6c14ac4a034aa Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 19 Oct 2013 16:52:12 +0200 Subject: untested kill dummy on tracking stop Signed-off-by: Stanislaw Halik --- ftnoir_protocol_ft/ftnoir_protocol_ft.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp b/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp index 186562cf..27e88136 100644 --- a/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp +++ b/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp @@ -60,6 +60,7 @@ FTNoIR_Protocol::~FTNoIR_Protocol() viewsStop(); FTIRViewsLib.unload(); } + dummyTrackIR.kill(); } // -- cgit v1.2.3 From 79697936ef3ce7f0bbd1965931cdfb4b2c4c9f5b Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 19 Oct 2013 17:06:23 +0200 Subject: Fix proto/filter dtor not being called Signed-off-by: Stanislaw Halik Reported-by: mm0zct --- ftnoir_filter_accela/ftnoir_filter_accela.h | 2 +- ftnoir_filter_base/ftnoir_filter_base.h | 4 +++- ftnoir_filter_ewma2/ftnoir_filter_ewma2.h | 2 +- ftnoir_protocol_base/ftnoir_protocol_base.h | 4 +++- ftnoir_protocol_fg/ftnoir_protocol_fg.h | 2 +- ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h | 2 +- ftnoir_protocol_ft/ftnoir_protocol_ft.cpp | 1 + ftnoir_protocol_ft/ftnoir_protocol_ft.h | 2 +- ftnoir_protocol_ftn/ftnoir_protocol_ftn.h | 2 +- ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.h | 2 +- ftnoir_protocol_mouse/ftnoir_protocol_mouse.h | 2 +- ftnoir_protocol_sc/ftnoir_protocol_sc.h | 2 +- ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.h | 2 +- ftnoir_protocol_wine/ftnoir_protocol_wine.h | 2 +- 14 files changed, 18 insertions(+), 13 deletions(-) diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.h b/ftnoir_filter_accela/ftnoir_filter_accela.h index 4afe127b..f1807fd0 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.h +++ b/ftnoir_filter_accela/ftnoir_filter_accela.h @@ -42,7 +42,7 @@ class FTNoIR_Filter : public IFilter { public: FTNoIR_Filter(); - ~FTNoIR_Filter(); + virtual ~FTNoIR_Filter(); void FilterHeadPoseData(const double* target_camera_position, double *new_camera_position, const double* last_post_filter_values); void Initialize() { first_run = true; diff --git a/ftnoir_filter_base/ftnoir_filter_base.h b/ftnoir_filter_base/ftnoir_filter_base.h index fe1ad19a..48a4a6b9 100644 --- a/ftnoir_filter_base/ftnoir_filter_base.h +++ b/ftnoir_filter_base/ftnoir_filter_base.h @@ -12,11 +12,13 @@ struct IFilter { - virtual ~IFilter() {} + virtual ~IFilter() = 0; virtual void FilterHeadPoseData(const double *target_camera_position, double *new_camera_position, const double *last_post_filter) = 0; virtual void Initialize() = 0; }; +inline IFilter::~IFilter() { } + struct IFilterDialog { virtual ~IFilterDialog() {} diff --git a/ftnoir_filter_ewma2/ftnoir_filter_ewma2.h b/ftnoir_filter_ewma2/ftnoir_filter_ewma2.h index 656b2895..7f2f21e6 100644 --- a/ftnoir_filter_ewma2/ftnoir_filter_ewma2.h +++ b/ftnoir_filter_ewma2/ftnoir_filter_ewma2.h @@ -41,7 +41,7 @@ class FTNoIR_Filter : public IFilter { public: FTNoIR_Filter(); - ~FTNoIR_Filter(); + virtual ~FTNoIR_Filter(); void Initialize() {} void FilterHeadPoseData(const double *target_camera_position, diff --git a/ftnoir_protocol_base/ftnoir_protocol_base.h b/ftnoir_protocol_base/ftnoir_protocol_base.h index 5db49f01..e4ca1977 100644 --- a/ftnoir_protocol_base/ftnoir_protocol_base.h +++ b/ftnoir_protocol_base/ftnoir_protocol_base.h @@ -39,12 +39,14 @@ struct IProtocol { - virtual ~IProtocol() {} + virtual ~IProtocol() = 0; virtual bool checkServerInstallationOK() = 0; virtual void sendHeadposeToGame( const double* headpose ) = 0; virtual QString getGameName() = 0; }; +inline IProtocol::~IProtocol() { } + struct IProtocolDialog { virtual ~IProtocolDialog() {} diff --git a/ftnoir_protocol_fg/ftnoir_protocol_fg.h b/ftnoir_protocol_fg/ftnoir_protocol_fg.h index 43d1b05a..9a4f304c 100644 --- a/ftnoir_protocol_fg/ftnoir_protocol_fg.h +++ b/ftnoir_protocol_fg/ftnoir_protocol_fg.h @@ -44,7 +44,7 @@ class FTNoIR_Protocol : public IProtocol { public: FTNoIR_Protocol(); - ~FTNoIR_Protocol(); + virtual ~FTNoIR_Protocol(); bool checkServerInstallationOK(); void sendHeadposeToGame(const double *headpose); QString getGameName() { diff --git a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h index 52b2cd98..87c6a3a4 100644 --- a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h +++ b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h @@ -59,7 +59,7 @@ class FTNoIR_Protocol : public IProtocol { public: FTNoIR_Protocol(); - ~FTNoIR_Protocol(); + virtual ~FTNoIR_Protocol(); bool checkServerInstallationOK(); void sendHeadposeToGame(const double* headpose); QString getGameName() { diff --git a/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp b/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp index 27e88136..65d877a7 100644 --- a/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp +++ b/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp @@ -61,6 +61,7 @@ FTNoIR_Protocol::~FTNoIR_Protocol() FTIRViewsLib.unload(); } dummyTrackIR.kill(); + dummyTrackIR.waitForFinished(5); } // diff --git a/ftnoir_protocol_ft/ftnoir_protocol_ft.h b/ftnoir_protocol_ft/ftnoir_protocol_ft.h index cd77bbe4..e13d260f 100644 --- a/ftnoir_protocol_ft/ftnoir_protocol_ft.h +++ b/ftnoir_protocol_ft/ftnoir_protocol_ft.h @@ -53,7 +53,7 @@ class FTNoIR_Protocol : public IProtocol { public: FTNoIR_Protocol(); - ~FTNoIR_Protocol(); + virtual ~FTNoIR_Protocol(); bool checkServerInstallationOK( ); void sendHeadposeToGame( const double *headpose ); QString getGameName() { diff --git a/ftnoir_protocol_ftn/ftnoir_protocol_ftn.h b/ftnoir_protocol_ftn/ftnoir_protocol_ftn.h index 4e814ddf..9aee73ac 100644 --- a/ftnoir_protocol_ftn/ftnoir_protocol_ftn.h +++ b/ftnoir_protocol_ftn/ftnoir_protocol_ftn.h @@ -43,7 +43,7 @@ class FTNoIR_Protocol : public IProtocol { public: FTNoIR_Protocol(); - ~FTNoIR_Protocol(); + virtual ~FTNoIR_Protocol(); bool checkServerInstallationOK(); void sendHeadposeToGame(const double *headpose); QString getGameName() { diff --git a/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.h b/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.h index 3c6f591c..aabd3e51 100644 --- a/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.h +++ b/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.h @@ -21,7 +21,7 @@ class FTNoIR_Protocol : public IProtocol { public: FTNoIR_Protocol(); - ~FTNoIR_Protocol(); + virtual ~FTNoIR_Protocol(); bool checkServerInstallationOK() { return dev != NULL; } diff --git a/ftnoir_protocol_mouse/ftnoir_protocol_mouse.h b/ftnoir_protocol_mouse/ftnoir_protocol_mouse.h index 1eb80b12..1ce72f69 100644 --- a/ftnoir_protocol_mouse/ftnoir_protocol_mouse.h +++ b/ftnoir_protocol_mouse/ftnoir_protocol_mouse.h @@ -58,7 +58,7 @@ class FTNoIR_Protocol : public IProtocol { public: FTNoIR_Protocol(); - ~FTNoIR_Protocol(); + virtual ~FTNoIR_Protocol(); bool checkServerInstallationOK(); void sendHeadposeToGame( const double *headpose); QString getGameName() { diff --git a/ftnoir_protocol_sc/ftnoir_protocol_sc.h b/ftnoir_protocol_sc/ftnoir_protocol_sc.h index 9ac56b30..e17cabb5 100644 --- a/ftnoir_protocol_sc/ftnoir_protocol_sc.h +++ b/ftnoir_protocol_sc/ftnoir_protocol_sc.h @@ -81,7 +81,7 @@ class FTNoIR_Protocol : public IProtocol { public: FTNoIR_Protocol(); - ~FTNoIR_Protocol(); + virtual ~FTNoIR_Protocol(); bool checkServerInstallationOK(); void sendHeadposeToGame(const double* headpose); QString getGameName() { diff --git a/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.h b/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.h index 2fe53669..c4db29e4 100644 --- a/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.h +++ b/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.h @@ -42,7 +42,7 @@ class FTNoIR_Protocol : public IProtocol { public: FTNoIR_Protocol(); - ~FTNoIR_Protocol(); + virtual ~FTNoIR_Protocol(); bool checkServerInstallationOK() { return true; } diff --git a/ftnoir_protocol_wine/ftnoir_protocol_wine.h b/ftnoir_protocol_wine/ftnoir_protocol_wine.h index 01bfc93d..d7276b8e 100644 --- a/ftnoir_protocol_wine/ftnoir_protocol_wine.h +++ b/ftnoir_protocol_wine/ftnoir_protocol_wine.h @@ -48,7 +48,7 @@ class FTNoIR_Protocol : public IProtocol { public: FTNoIR_Protocol(); - ~FTNoIR_Protocol(); + virtual ~FTNoIR_Protocol(); bool checkServerInstallationOK(); void sendHeadposeToGame(const double* headpose); -- 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(+) 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(+) 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(-) 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 5dbc97ebc29bdfe540cd44ab12997ad1310b1057 Mon Sep 17 00:00:00 2001 From: mm0zct Date: Sat, 19 Oct 2013 16:51:13 +0100 Subject: Fixed FT2.0 tracker to actually start and kill TrackIR.exe dummy correctly -mm0zct&shalik --- ftnoir_protocol_ft/ftnoir_protocol_ft.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp b/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp index 65d877a7..ec5972fc 100644 --- a/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp +++ b/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp @@ -32,6 +32,7 @@ FTNoIR_Protocol::FTNoIR_Protocol() : shm(FT_MM_DATA, FREETRACK_MUTEX, sizeof(FTMemMap)) { + fprintf(stderr,"calling constructor\n"); pMemData = (FTMemMap*) shm.mem; useTIRViews = false; useDummyExe = false; @@ -51,7 +52,7 @@ FTNoIR_Protocol::~FTNoIR_Protocol() { qDebug()<< "~FTNoIR_Protocol: Destructor started."; - + // // Stop if started // @@ -60,8 +61,10 @@ FTNoIR_Protocol::~FTNoIR_Protocol() viewsStop(); FTIRViewsLib.unload(); } + dummyTrackIR.terminate(); dummyTrackIR.kill(); - dummyTrackIR.waitForFinished(5); + dummyTrackIR.waitForFinished(50); + } // @@ -195,8 +198,11 @@ void FTNoIR_Protocol::start_tirviews() { } void FTNoIR_Protocol::start_dummy() { + + QString program = QCoreApplication::applicationDirPath() + "/TrackIR.exe"; - dummyTrackIR.startDetached("\"" + program + "\""); + dummyTrackIR.setProgram("\"" + program + "\""); + dummyTrackIR.start(); qDebug() << "FTServer::run() says: TrackIR.exe executed!" << program; } -- cgit v1.2.3 From a4e9654a0a1a69fb84ab0318c533c70200b00a5c Mon Sep 17 00:00:00 2001 From: mm0zct Date: Sat, 19 Oct 2013 16:53:48 +0100 Subject: removed a stray fprintf -mm0zct --- ftnoir_protocol_ft/ftnoir_protocol_ft.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp b/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp index ec5972fc..4410b7a5 100644 --- a/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp +++ b/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp @@ -32,7 +32,6 @@ FTNoIR_Protocol::FTNoIR_Protocol() : shm(FT_MM_DATA, FREETRACK_MUTEX, sizeof(FTMemMap)) { - fprintf(stderr,"calling constructor\n"); pMemData = (FTMemMap*) shm.mem; useTIRViews = false; useDummyExe = false; -- cgit v1.2.3 From dfafa60a91b5a2578beead9a16db1e5af729e942 Mon Sep 17 00:00:00 2001 From: mm0zct Date: Sat, 19 Oct 2013 17:09:31 +0100 Subject: added a little to the TODO.txt --- TODO.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/TODO.txt b/TODO.txt index 4194a6f0..03226e41 100644 --- a/TODO.txt +++ b/TODO.txt @@ -1,3 +1,8 @@ +20131019 mm0zct + Ship more then one profile for configuring the curves etc. + There are two main user bases, HMD and traditional monitor+webcam users, + each wants a drastically different curve profile (HMD is 1:1 on all axes) + Also re:boost, I'd rather avoid extra library dependences if possible. 20131005 sh what do you think about boost 1.54 for property maps -> qsettings? also, boost concepts -- cgit v1.2.3 From 1d4776beab92c264ffb5b12f2eef93da9169441d Mon Sep 17 00:00:00 2001 From: mm0zct Date: Sat, 19 Oct 2013 17:12:15 +0100 Subject: added some toto items -mm0zct --- TODO.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/TODO.txt b/TODO.txt index 03226e41..185c794e 100644 --- a/TODO.txt +++ b/TODO.txt @@ -3,6 +3,10 @@ There are two main user bases, HMD and traditional monitor+webcam users, each wants a drastically different curve profile (HMD is 1:1 on all axes) Also re:boost, I'd rather avoid extra library dependences if possible. + + Rift tracker could do with positional estimation using intertial sensors. + Rift could do with a return-yaw-to-centre hotkey that's not the global all-axis option. + Hydra is really just a hack just now, could be improved a lot. 20131005 sh what do you think about boost 1.54 for property maps -> qsettings? also, boost concepts -- cgit v1.2.3 From 383d9237f407533b61039bfe99713dd674462d81 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 19 Oct 2013 19:08:16 +0200 Subject: add todo --- TODO.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/TODO.txt b/TODO.txt index 185c794e..6e1c48b0 100644 --- a/TODO.txt +++ b/TODO.txt @@ -1,3 +1,5 @@ +20131019 sh + Add a joystick tracker source, with selectable axes. 20131019 mm0zct Ship more then one profile for configuring the curves etc. There are two main user bases, HMD and traditional monitor+webcam users, -- cgit v1.2.3 From 726875b0b40f8a43ae5ca763667dc707e84f39aa Mon Sep 17 00:00:00 2001 From: mm0zct Date: Sat, 19 Oct 2013 18:36:19 +0100 Subject: added todo and virtual function in tracker base class --- TODO.txt | 2 ++ ftnoir_tracker_base/ftnoir_tracker_base.h | 1 + 2 files changed, 3 insertions(+) diff --git a/TODO.txt b/TODO.txt index 6e1c48b0..ef4dc10e 100644 --- a/TODO.txt +++ b/TODO.txt @@ -9,6 +9,8 @@ Rift tracker could do with positional estimation using intertial sensors. Rift could do with a return-yaw-to-centre hotkey that's not the global all-axis option. Hydra is really just a hack just now, could be improved a lot. + + Add per-tracker hotkey support 20131005 sh what do you think about boost 1.54 for property maps -> qsettings? also, boost concepts diff --git a/ftnoir_tracker_base/ftnoir_tracker_base.h b/ftnoir_tracker_base/ftnoir_tracker_base.h index cb83aea3..8b720620 100644 --- a/ftnoir_tracker_base/ftnoir_tracker_base.h +++ b/ftnoir_tracker_base/ftnoir_tracker_base.h @@ -44,6 +44,7 @@ struct ITracker virtual ~ITracker() = 0; virtual void StartTracker( QFrame* frame ) = 0; virtual bool GiveHeadPoseData(double *data) = 0; + virtual void HotkeyCallback(unsigned int *) = 0; }; inline ITracker::~ITracker() { } -- 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(-) 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 66d5cfb7636eee667f74a150571968bbecc2a749 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 20 Oct 2013 16:27:52 +0200 Subject: HT: pointless tweaks --- ftnoir_tracker_ht/ftnoir_tracker_ht.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp index 14cd3942..e31b6d3f 100644 --- a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp +++ b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp @@ -97,10 +97,10 @@ static void load_settings(ht_config_t* config, Tracker* tracker) iniFile.beginGroup( "HT-Tracker" ); config->classification_delay = 500; config->field_of_view = iniFile.value("fov", 52).toFloat(); - config->pyrlk_pyramids = 3; + config->pyrlk_pyramids = 2; config->pyrlk_win_size_w = config->pyrlk_win_size_h = 21; - config->max_keypoints = 200; - config->keypoint_distance = 4.5; + config->max_keypoints = 250; + config->keypoint_distance = 4.2; //config->force_width = 640; //config->force_height = 480; config->force_fps = iniFile.value("fps", 0).toInt(); @@ -111,14 +111,14 @@ static void load_settings(ht_config_t* config, Tracker* tracker) config->ransac_abs_max_mean_error = 15; config->ransac_max_mean_error = 4.5; config->debug = 0; - config->ransac_min_features = 0.8; + config->ransac_min_features = 0.78; int res = iniFile.value("resolution", 0).toInt(); if (res < 0 || res >= (int)(sizeof(resolution_choices) / sizeof(resolution_tuple))) res = 0; resolution_tuple r = resolution_choices[res]; config->force_width = r.width; config->force_height = r.height; - config->flandmark_delay = 200; + config->flandmark_delay = 250; qDebug() << "width" << r.width << "height" << r.height; if (tracker) { -- 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(-) 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 f6968a7453b9f66a695f76a21b0d6046b585d9d3 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 20 Oct 2013 16:44:06 +0200 Subject: Implement axis limits Signed-off-by: Stanislaw Halik --- ftnoir_tracker_ht/ftnoir_tracker_ht.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp index e31b6d3f..62606395 100644 --- a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp +++ b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp @@ -224,6 +224,12 @@ bool Tracker::GiveHeadPoseData(double *data) if (enableTZ) data[TZ] = shm->result.tz; ret = true; + if (fabs(data[Yaw]) > 60 || fabs(data[Pitch]) > 50 || fabs(data[Roll]) > 40) + { + shm->pause = true; + } + } else { + shm->pause = false; } lck_shm.unlock(); -- 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(-) 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 22da33051b7ff52d9526508bdd681205517a0c25 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 20 Oct 2013 16:51:39 +0200 Subject: add todo Signed-off-by: Stanislaw Halik --- TODO.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/TODO.txt b/TODO.txt index 6e1c48b0..5b783ca1 100644 --- a/TODO.txt +++ b/TODO.txt @@ -1,3 +1,7 @@ +20131020 sh + Add unit testing by means of batch execution, protocol/filter that does + nothing, add separate executables for readers of specific protocols, + and run continuous integration every time commit happens that day. 20131019 sh Add a joystick tracker source, with selectable axes. 20131019 mm0zct @@ -5,7 +9,7 @@ There are two main user bases, HMD and traditional monitor+webcam users, each wants a drastically different curve profile (HMD is 1:1 on all axes) Also re:boost, I'd rather avoid extra library dependences if possible. - + Rift tracker could do with positional estimation using intertial sensors. Rift could do with a return-yaw-to-centre hotkey that's not the global all-axis option. Hydra is really just a hack just now, could be improved a lot. -- cgit v1.2.3 From bbf30cecd0dac02164ee4346d42d6750a6a962a1 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 20 Oct 2013 16:52:00 +0200 Subject: respecting hier(7) is pointless, remove TODO Signed-off-by: Stanislaw Halik --- TODO.txt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/TODO.txt b/TODO.txt index 5b783ca1..9d49f9d4 100644 --- a/TODO.txt +++ b/TODO.txt @@ -17,10 +17,6 @@ what do you think about boost 1.54 for property maps -> qsettings? also, boost concepts and qt5 -20131007 sh - respect hier(7) with regard to shared object installation. - install them inside ../lib/opentrack relative to ./bin where - the main program oughta reside. 20131008 sh during the switch to qt5, recreate widgets, this time with layouts. the original layouts were pretty crappy, hence the original breakage. -- cgit v1.2.3 From 46ce801efbc0bfe83599a762bd6c6dfcfafb20bf Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 20 Oct 2013 16:52:27 +0200 Subject: remove half-completed TODO Signed-off-by: Stanislaw Halik --- TODO.txt | 3 --- 1 file changed, 3 deletions(-) diff --git a/TODO.txt b/TODO.txt index 9d49f9d4..5e523536 100644 --- a/TODO.txt +++ b/TODO.txt @@ -17,9 +17,6 @@ what do you think about boost 1.54 for property maps -> qsettings? also, boost concepts and qt5 -20131008 sh - during the switch to qt5, recreate widgets, this time with layouts. - the original layouts were pretty crappy, hence the original breakage. 20131011 sh low-hanging fruit: default saving profiles to a directory in user home, not into global stuffies -- cgit v1.2.3 From 7ceee24163affc05ff2da7dcdb7952db5de8db85 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 20 Oct 2013 16:55:20 +0200 Subject: add todo Signed-off-by: Stanislaw Halik --- TODO.txt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/TODO.txt b/TODO.txt index 5e523536..e22dd812 100644 --- a/TODO.txt +++ b/TODO.txt @@ -2,6 +2,11 @@ Add unit testing by means of batch execution, protocol/filter that does nothing, add separate executables for readers of specific protocols, and run continuous integration every time commit happens that day. + + Add statically-typed settings trees, convert result to qsettings-enabled + ini files. Use metadata props in order to get class name for ini section. + Required here are also arrays of settings. Use QList for template + specialization. 20131019 sh Add a joystick tracker source, with selectable axes. 20131019 mm0zct @@ -13,10 +18,6 @@ Rift tracker could do with positional estimation using intertial sensors. Rift could do with a return-yaw-to-centre hotkey that's not the global all-axis option. Hydra is really just a hack just now, could be improved a lot. -20131005 sh - what do you think about boost 1.54 for property maps -> qsettings? - also, boost concepts - and qt5 20131011 sh low-hanging fruit: default saving profiles to a directory in user home, not into global stuffies -- cgit v1.2.3 From 5186144127a0ec24f50d5c73a9515906787b2568 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 20 Oct 2013 17:20:02 +0200 Subject: update buildbot Signed-off-by: Stanislaw Halik --- installer/opentrack-installer.iss | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/installer/opentrack-installer.iss b/installer/opentrack-installer.iss index 5ff42ea5..60d9963b 100644 --- a/installer/opentrack-installer.iss +++ b/installer/opentrack-installer.iss @@ -23,7 +23,7 @@ DefaultDirName={pf}\{#MyAppName} DefaultGroupName={#MyAppName} AllowNoIcons=yes OutputBaseFilename=opentrack-setup-{#MyAppVersion} -SetupIconFile=C:\Users\Administrator\SDK\opentrack\facetracknoir\facetracknoir.ico +SetupIconFile=d:\opentrack-win32-sdk\opentrack\facetracknoir\facetracknoir.ico Compression=lzma/ultra64 SolidCompression=yes DisableWelcomePage=True @@ -41,7 +41,7 @@ Name: "english"; MessagesFile: "compiler:Default.isl" Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked [Files] -Source: "C:\Users\Administrator\SDK\opentrack\install\*"; DestDir: "{app}"; Flags: ignoreversion createallsubdirs recursesubdirs +Source: "d:\opentrack-win32-sdk\opentrack\build\install\*"; DestDir: "{app}"; Flags: ignoreversion createallsubdirs recursesubdirs [Icons] Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}" -- 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(-) 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(-) 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 e9a3e290740fc4bf2a6f25923edcff96e8a99c37 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 21 Oct 2013 00:26:03 +0200 Subject: Fix build --- CMakeLists.txt | 69 ++++++++++++++++++++++++++-------------------------------- 1 file changed, 31 insertions(+), 38 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 73ffec68..5a10f8b9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,9 +1,6 @@ project(opentrack) cmake_minimum_required(VERSION 2.8) -if(CMAKE_VERSION VERSION_GREATER "2.10.0") - cmake_policy(SET CMP0020 NEW) -endif() set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${CMAKE_SOURCE_DIR}/cmake/") SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) @@ -47,18 +44,13 @@ SET(SDK_HYDRA_AMD64 FALSE CACHE BOOL "whether target is amd64 (else ia-32)") SET(SDK_RIFT "" CACHE PATH "libOVR path") -SET(SDK_RIFT_RECENTRE_SPRING TRUE CACHE BOOL "recenter yaw aggressively") - -if(SDK_RIFT_RECENTRE_SPRING) - add_definitions(-DOPENTRACK_RIFT_RECENTRE_SPRING) -endif() - file(GLOB opentrack-faceapi-wrapper-c "faceapi/*.cpp") include_directories(${CMAKE_SOURCE_DIR}) if(NOT SDK_FACEAPI_ONLY) find_package(OpenCV) find_package(Qt5 REQUIRED COMPONENTS Core Xml Network Widgets Gui 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}) @@ -313,7 +305,12 @@ endif() target_link_libraries(opentrack-compat rt) endif() - SET(MY_QT_LIBS ${Qt5Widgets_LIBRARIES} ${Qt5Gui_LIBRARIES} ${Qt5Network_LIBRARIES} ${Qt5Xml_LIBRARIES} ${Qt5Core_LIBRARIES}) + # hack to avoid breakage on buildbot + set(my-qt-deps) + 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}) add_library(opentrack-csv SHARED ${opentrack-csv-c}) target_link_libraries(opentrack-csv ${MY_QT_LIBS}) @@ -516,38 +513,34 @@ endif() target_link_libraries(opentrack-tracker-hydra ${MY_QT_LIBS}) if(WIN32) target_link_libraries(opentrack-tracker-hydra - "${SDK_HYDRA}/lib/win32/release_static/sixense_s.lib" - "${SDK_HYDRA}/lib/win32/release_static/sixense_utils_s.lib") - set_target_properties (opentrack-tracker-hydra PROPERTIES LINK_FLAGS "/NODEFAULTLIB:libcmt.lib") - else() - if(SDK_HYDRA_AMD64) - set(underscore-sixtyfour _x64) - else() - set(underscore-sixtyfour) - endif() - if(APPLE) - set(underscore-dll _dll) - set(soext dylib) - set(sixense-plat osx) - else() - set(underscore-dll) - set(soext so) - set(sixense-plat linux) - endif() - install(FILES - "${SDK_HYDRA}/lib/${sixense-plat}${underscore-sixtyfour}/release${underscore-dll}/libsixense${underscore-sixtyfour}.${soext}" - "${SDK_HYDRA}/lib/${sixense-plat}${underscore-sixtyfour}/release${underscore-dll}/libsixense_utils${underscore-sixtyfour}.${soext}" - DESTINATION .) - target_link_libraries(opentrack-tracker-hydra "${SDK_HYDRA}/lib/${sixense-plat}${underscore-sixtyfour}/release${underscore-dll}/libsixense${underscore-sixtyfour}.${soext}" "${SDK_HYDRA}/lib/${sixense-plat}${underscore-sixtyfour}/release${underscore-dll}/libsixense_utils${underscore-sixtyfour}.${soext}") + "${SDK_HYDRA}/lib/win32/release_dll/sixense.lib" + "${SDK_HYDRA}/lib/win32/release_dll/sixense_utils.lib") + install(FILES "${SDK_HYDRA}/bin/win32/release_dll/sixense.dll" "${SDK_HYDRA}/bin/win32/release_dll/sixense_utils.dll" DESTINATION .) + else() + if(SDK_HYDRA_AMD64) + set(underscore-sixtyfour _x64) + else() + set(underscore-sixtyfour) + endif() + if(APPLE) + set(underscore-dll _dll) + set(soext dylib) + set(sixense-plat osx) + else() + set(underscore-dll) + set(soext so) + set(sixense-plat linux) + endif() + install(FILES + "${SDK_HYDRA}/lib/${sixense-plat}${underscore-sixtyfour}/release${underscore-dll}/libsixense${underscore-sixtyfour}.${soext}" + "${SDK_HYDRA}/lib/${sixense-plat}${underscore-sixtyfour}/release${underscore-dll}/libsixense_utils${underscore-sixtyfour}.${soext}" + DESTINATION .) + target_link_libraries(opentrack-tracker-hydra "${SDK_HYDRA}/lib/${sixense-plat}${underscore-sixtyfour}/release${underscore-dll}/libsixense${underscore-sixtyfour}.${soext}" "${SDK_HYDRA}/lib/${sixense-plat}${underscore-sixtyfour}/release${underscore-dll}/libsixense_utils${underscore-sixtyfour}.${soext}") endif() if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) SET_TARGET_PROPERTIES(opentrack-tracker-hydra PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt") - else() - if(MSVC) - SET_TARGET_PROPERTIES(opentrack-tracker-hydra PROPERTIES LINK_FLAGS "/NODEFAULTLIB:libcmt.lib") - endif() - endif() + endif() endif() if(WIN32 AND NOT SDK_CONSOLE_DEBUG) -- cgit v1.2.3 From e45ea26f4a43fc38d47dbc2edfbf31c8efa41edd Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 21 Oct 2013 00:26:43 +0200 Subject: api cleanup --- ftnoir_tracker_hydra/ftnoir_tracker_hydra.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h b/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h index 19f2a685..2601ac55 100644 --- a/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h +++ b/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h @@ -15,9 +15,6 @@ public: bool GiveHeadPoseData(double *data); void loadSettings(); volatile bool should_quit; - void WaitForExit() { - return; - } protected: void run(); // qthread override run method -- cgit v1.2.3 From c58db6e1df2a47bd10bcbd82624604d05ccd28b3 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 21 Oct 2013 00:27:30 +0200 Subject: Update to libovr 0.2.5, fix crash when no device attached. Signed-off-by: Stanislaw Halik In-absence-of: mm0zct --- ftnoir_tracker_rift/ftnoir_tracker_rift.cpp | 94 +++++++++++------------------ ftnoir_tracker_rift/ftnoir_tracker_rift.h | 11 +--- 2 files changed, 38 insertions(+), 67 deletions(-) diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp b/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp index 1af99803..ab694108 100644 --- a/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp +++ b/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp @@ -11,29 +11,19 @@ using namespace OVR; Rift_Tracker::Rift_Tracker() { - pSensor.Clear(); - pHMD.Clear(); - pManager.Clear(); bEnableRoll = true; bEnablePitch = true; bEnableYaw = true; - old_yaw = 0.0; #if 0 bEnableX = true; bEnableY = true; bEnableZ = true; #endif - isCalibrated = false; should_quit = false; - for (int i = 0; i < 6; i++) - newHeadPose[i] = 0; } Rift_Tracker::~Rift_Tracker() { - pSensor.Clear(); - pHMD.Clear(); - pManager.Clear(); System::Destroy(); } @@ -58,78 +48,64 @@ void Rift_Tracker::StartTracker(QFrame* videoFrame) // Startup the Oculus SDK device handling, use the first Rift sensor we find. // System::Init(Log::ConfigureDefaultLog(LogMask_All)); - pManager = *DeviceManager::Create(); - DeviceEnumerator enumerator = pManager->EnumerateDevices(); - if (enumerator.IsAvailable()) - { - pHMD = *enumerator.CreateDevice(); - - pSensor = *pHMD->GetSensor(); + auto ptr_manager = DeviceManager::Create(); + if (ptr_manager != nullptr) + { + pManager = *ptr_manager; + DeviceEnumerator enumerator = pManager->EnumerateDevices(); + if (enumerator.IsAvailable()) + { + auto ptr_hmd = enumerator.CreateDevice(); + + if (ptr_hmd != nullptr) + { + pHMD = *ptr_hmd; + auto ptr_sensor = pHMD->GetSensor(); + if (ptr_sensor != 0) + pSensor = *ptr_sensor; + } - if (pSensor){ - SFusion.AttachToSensor(pSensor); - }else{ - QMessageBox::warning(0,"FaceTrackNoIR Error", "Unable to find Rift tracker",QMessageBox::Ok,QMessageBox::NoButton); - } - isCalibrated = false; - MagCal.BeginAutoCalibration(SFusion); - - } + if (pSensor){ + SFusion.reset(new OVR::SensorFusion()); + SFusion->AttachToSensor(pSensor); + }else{ + QMessageBox::warning(0,"FaceTrackNoIR Error", "Unable to find Rift tracker",QMessageBox::Ok,QMessageBox::NoButton); + } + //isCalibrated = false; + //MagCal.BeginAutoCalibration(SFusion); + } + } } bool Rift_Tracker::GiveHeadPoseData(double *data) { - if (pHMD.GetPtr() != NULL) { - - if (MagCal.IsAutoCalibrating()) - { - MagCal.UpdateAutoCalibration(SFusion); - if (MagCal.IsCalibrated()) - { - if(isCalibrated == false){ - //QMessageBox::warning(0,"OpenTrack Info", "Calibrated magnetic sensor",QMessageBox::Ok,QMessageBox::NoButton); - //fprintf(stderr,"magnetic calibration complete\n"); - isCalibrated = true; - } - //Vector3f mc = MagCal.GetMagCenter(); - //SetAdjustMessage("Magnetometer Calibration Complete\nCenter: %f %f %f",mc.x,mc.y,mc.z); - } - //SetAdjustMessage("Mag has been successfully calibrated"); - } - - Quatf hmdOrient = SFusion.GetOrientation(); + if (SFusion != nullptr) { + Quatf hmdOrient = SFusion->GetOrientation(); + float newHeadPose[6]; float yaw = 0.0f; float pitch = 0.0f; float roll = 0.0f; hmdOrient.GetEulerAngles(&yaw, &pitch , &roll); -#ifdef OPENTRACK_RIFT_RECENTRE_SPRING - newHeadPose[Yaw] = newHeadPose[Yaw]*0.99999 + (yaw-old_yaw); - if(newHeadPose[Yaw]>0.02)newHeadPose[Yaw]-= 0.000005; - if(newHeadPose[Yaw]<-0.02)newHeadPose[Yaw]+= 0.000005; - old_yaw=yaw; -#else newHeadPose[Yaw] = yaw; -#endif newHeadPose[Pitch] =pitch; newHeadPose[Roll] = roll; #if 0 - newHeadPose[TX] = acd.controllers[0].pos[0]/50.0f; newHeadPose[TY] = acd.controllers[0].pos[1]/50.0f; newHeadPose[TZ] = acd.controllers[0].pos[2]/50.0f; - //if (bEnableX) { + if (bEnableX) { data[TX] = newHeadPose[TX]; - //} - //if (bEnableY) { + } + if (bEnableY) { data[TY] = newHeadPose[TY]; - //} - //if (bEnableY) { + } + if (bEnableY) { data[TZ] = newHeadPose[TZ]; - //} + } #endif if (bEnableYaw) { data[Yaw] = newHeadPose[Yaw] * 57.295781f; diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift.h b/ftnoir_tracker_rift/ftnoir_tracker_rift.h index 579d7d34..34742d6c 100644 --- a/ftnoir_tracker_rift/ftnoir_tracker_rift.h +++ b/ftnoir_tracker_rift/ftnoir_tracker_rift.h @@ -6,18 +6,17 @@ #include #include "facetracknoir/global-settings.h" #include "OVR.h" -#include "Util/Util_MagCalibration.h" +#include class Rift_Tracker : public ITracker { public: Rift_Tracker(); - ~Rift_Tracker(); + virtual ~Rift_Tracker(); void StartTracker( QFrame *videoframe ); bool GiveHeadPoseData(double *data); void loadSettings(); volatile bool should_quit; - void WaitForExit() {} protected: void run(); // qthread override run method @@ -26,12 +25,8 @@ private: OVR::Ptr pManager; OVR::Ptr pHMD; OVR::Ptr pSensor; - OVR::SensorFusion SFusion; + std::unique_ptr SFusion; // Magnetometer calibration and yaw correction - OVR::Util::MagCalibration MagCal; - bool isCalibrated; - double old_yaw; - double newHeadPose[6]; // Structure with new headpose bool bEnableRoll; bool bEnablePitch; bool bEnableYaw; -- cgit v1.2.3 From 5048961fa205ecebb2cea4f8d68d51dfbe993189 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 21 Oct 2013 21:10:23 +0200 Subject: Rift: avoid leaks, reformat --- ftnoir_tracker_rift/ftnoir_tracker_rift.cpp | 129 ++++++++++++++-------------- 1 file changed, 66 insertions(+), 63 deletions(-) diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp b/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp index ab694108..e94b9d03 100644 --- a/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp +++ b/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp @@ -11,33 +11,36 @@ using namespace OVR; Rift_Tracker::Rift_Tracker() { - bEnableRoll = true; - bEnablePitch = true; - bEnableYaw = true; + bEnableRoll = true; + bEnablePitch = true; + bEnableYaw = true; #if 0 - bEnableX = true; - bEnableY = true; - bEnableZ = true; + bEnableX = true; + bEnableY = true; + bEnableZ = true; #endif - should_quit = false; + should_quit = false; } Rift_Tracker::~Rift_Tracker() { - System::Destroy(); + pSensor.Clear(); + pHMD.Clear(); + pManager.Clear(); + System::Destroy(); } /* void controller_manager_setup_callback( sixenseUtils::ControllerManager::setup_step step ) { - QMessageBox::warning(0,"OpenTrack Info", "controller manager callback",QMessageBox::Ok,QMessageBox::NoButton); - if( sixenseUtils::getTheControllerManager()->isMenuVisible() ) { - // Ask the controller manager what the next instruction string should be. - std::string controller_manager_text_string = sixenseUtils::getTheControllerManager()->getStepString(); - QMessageBox::warning(0,"OpenTrack Info", controller_manager_text_string.c_str(),QMessageBox::Ok,QMessageBox::NoButton); - // We could also load the supplied controllermanager textures using the filename: sixenseUtils::getTheControllerManager()->getTextureFileName(); + QMessageBox::warning(0,"OpenTrack Info", "controller manager callback",QMessageBox::Ok,QMessageBox::NoButton); + if( sixenseUtils::getTheControllerManager()->isMenuVisible() ) { + // Ask the controller manager what the next instruction string should be. + std::string controller_manager_text_string = sixenseUtils::getTheControllerManager()->getStepString(); + QMessageBox::warning(0,"OpenTrack Info", controller_manager_text_string.c_str(),QMessageBox::Ok,QMessageBox::NoButton); + // We could also load the supplied controllermanager textures using the filename: sixenseUtils::getTheControllerManager()->getTextureFileName(); - } + } }*/ void Rift_Tracker::StartTracker(QFrame* videoFrame) @@ -48,33 +51,33 @@ void Rift_Tracker::StartTracker(QFrame* videoFrame) // Startup the Oculus SDK device handling, use the first Rift sensor we find. // System::Init(Log::ConfigureDefaultLog(LogMask_All)); - auto ptr_manager = DeviceManager::Create(); - if (ptr_manager != nullptr) - { - pManager = *ptr_manager; - DeviceEnumerator enumerator = pManager->EnumerateDevices(); - if (enumerator.IsAvailable()) - { - auto ptr_hmd = enumerator.CreateDevice(); - - if (ptr_hmd != nullptr) - { - pHMD = *ptr_hmd; - auto ptr_sensor = pHMD->GetSensor(); - if (ptr_sensor != 0) - pSensor = *ptr_sensor; - } + auto ptr_manager = DeviceManager::Create(); + if (ptr_manager != nullptr) + { + pManager = *ptr_manager; + DeviceEnumerator enumerator = pManager->EnumerateDevices(); + if (enumerator.IsAvailable()) + { + auto ptr_hmd = enumerator.CreateDevice(); + + if (ptr_hmd != nullptr) + { + pHMD = *ptr_hmd; + auto ptr_sensor = pHMD->GetSensor(); + if (ptr_sensor != 0) + pSensor = *ptr_sensor; + } - if (pSensor){ - SFusion.reset(new OVR::SensorFusion()); - SFusion->AttachToSensor(pSensor); - }else{ - QMessageBox::warning(0,"FaceTrackNoIR Error", "Unable to find Rift tracker",QMessageBox::Ok,QMessageBox::NoButton); - } - //isCalibrated = false; - //MagCal.BeginAutoCalibration(SFusion); - } - } + if (pSensor){ + SFusion.reset(new OVR::SensorFusion()); + SFusion->AttachToSensor(pSensor); + }else{ + QMessageBox::warning(0,"FaceTrackNoIR Error", "Unable to find Rift tracker",QMessageBox::Ok,QMessageBox::NoButton); + } + //isCalibrated = false; + //MagCal.BeginAutoCalibration(SFusion); + } + } } @@ -82,22 +85,22 @@ bool Rift_Tracker::GiveHeadPoseData(double *data) { if (SFusion != nullptr) { Quatf hmdOrient = SFusion->GetOrientation(); - float newHeadPose[6]; - + float newHeadPose[6]; + float yaw = 0.0f; float pitch = 0.0f; float roll = 0.0f; hmdOrient.GetEulerAngles(&yaw, &pitch , &roll); - newHeadPose[Yaw] = yaw; + newHeadPose[Yaw] = yaw; newHeadPose[Pitch] =pitch; newHeadPose[Roll] = roll; #if 0 - newHeadPose[TX] = acd.controllers[0].pos[0]/50.0f; - newHeadPose[TY] = acd.controllers[0].pos[1]/50.0f; - newHeadPose[TZ] = acd.controllers[0].pos[2]/50.0f; - - if (bEnableX) { + newHeadPose[TX] = acd.controllers[0].pos[0]/50.0f; + newHeadPose[TY] = acd.controllers[0].pos[1]/50.0f; + newHeadPose[TZ] = acd.controllers[0].pos[2]/50.0f; + + if (bEnableX) { data[TX] = newHeadPose[TX]; } if (bEnableY) { @@ -117,7 +120,7 @@ bool Rift_Tracker::GiveHeadPoseData(double *data) data[Roll] = newHeadPose[Roll] * 57.295781f; } } - return pHMD.GetPtr() != NULL; + return pHMD.GetPtr() != NULL; } @@ -126,24 +129,24 @@ bool Rift_Tracker::GiveHeadPoseData(double *data) // void Rift_Tracker::loadSettings() { - qDebug() << "FTNoIR_Tracker::loadSettings says: Starting "; - QSettings settings("opentrack"); // Registry settings (in HK_USER) + 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) + 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; + qDebug() << "FTNoIR_Tracker::loadSettings says: iniFile = " << currentFile; - iniFile.beginGroup ( "Rift" ); - bEnableRoll = iniFile.value ( "EnableRoll", 1 ).toBool(); - bEnablePitch = iniFile.value ( "EnablePitch", 1 ).toBool(); - bEnableYaw = iniFile.value ( "EnableYaw", 1 ).toBool(); + iniFile.beginGroup ( "Rift" ); + bEnableRoll = iniFile.value ( "EnableRoll", 1 ).toBool(); + bEnablePitch = iniFile.value ( "EnablePitch", 1 ).toBool(); + bEnableYaw = iniFile.value ( "EnableYaw", 1 ).toBool(); #if 0 - bEnableX = iniFile.value ( "EnableX", 1 ).toBool(); - bEnableY = iniFile.value ( "EnableY", 1 ).toBool(); - bEnableZ = iniFile.value ( "EnableZ", 1 ).toBool(); + bEnableX = iniFile.value ( "EnableX", 1 ).toBool(); + bEnableY = iniFile.value ( "EnableY", 1 ).toBool(); + bEnableZ = iniFile.value ( "EnableZ", 1 ).toBool(); #endif - iniFile.endGroup (); + iniFile.endGroup (); } -- cgit v1.2.3 From 7e659504cb12541a571c042d01838d5c72b11bb2 Mon Sep 17 00:00:00 2001 From: mm0zct Date: Mon, 21 Oct 2013 22:12:36 +0100 Subject: fixed Rift tracker for libovr SDK 0.2.5 --- ftnoir_tracker_rift/ftnoir_tracker_rift.cpp | 65 +++++++++++++---------------- ftnoir_tracker_rift/ftnoir_tracker_rift.h | 11 +++-- 2 files changed, 34 insertions(+), 42 deletions(-) diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp b/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp index e94b9d03..7fade51c 100644 --- a/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp +++ b/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp @@ -6,9 +6,6 @@ using namespace OVR; -//used to turn on the re-centre spring effect -//#define OPENTRACK_RIFT_RECENTRE_SPRING - Rift_Tracker::Rift_Tracker() { bEnableRoll = true; @@ -20,71 +17,67 @@ Rift_Tracker::Rift_Tracker() bEnableZ = true; #endif should_quit = false; + pManager = NULL; + pHMD = NULL; + pSensor = NULL; + pSFusion = NULL; } Rift_Tracker::~Rift_Tracker() { - pSensor.Clear(); - pHMD.Clear(); - pManager.Clear(); + pSensor->Release(); + delete pSFusion; + pHMD->Release(); + pManager->Release(); System::Destroy(); } -/* -void controller_manager_setup_callback( sixenseUtils::ControllerManager::setup_step step ) { - - QMessageBox::warning(0,"OpenTrack Info", "controller manager callback",QMessageBox::Ok,QMessageBox::NoButton); - if( sixenseUtils::getTheControllerManager()->isMenuVisible() ) { - // Ask the controller manager what the next instruction string should be. - std::string controller_manager_text_string = sixenseUtils::getTheControllerManager()->getStepString(); - QMessageBox::warning(0,"OpenTrack Info", controller_manager_text_string.c_str(),QMessageBox::Ok,QMessageBox::NoButton); - // We could also load the supplied controllermanager textures using the filename: sixenseUtils::getTheControllerManager()->getTextureFileName(); - } -}*/ void Rift_Tracker::StartTracker(QFrame* videoFrame) { - //QMessageBox::warning(0,"FaceTrackNoIR Notification", "Tracking loading settings...",QMessageBox::Ok,QMessageBox::NoButton); + loadSettings(); // // Startup the Oculus SDK device handling, use the first Rift sensor we find. // System::Init(Log::ConfigureDefaultLog(LogMask_All)); - auto ptr_manager = DeviceManager::Create(); - if (ptr_manager != nullptr) + pManager = DeviceManager::Create(); + if (pManager != NULL) { - pManager = *ptr_manager; DeviceEnumerator enumerator = pManager->EnumerateDevices(); if (enumerator.IsAvailable()) { - auto ptr_hmd = enumerator.CreateDevice(); + pHMD = enumerator.CreateDevice(); - if (ptr_hmd != nullptr) + if (pHMD != NULL) { - pHMD = *ptr_hmd; - auto ptr_sensor = pHMD->GetSensor(); - if (ptr_sensor != 0) - pSensor = *ptr_sensor; + pSensor = pHMD->GetSensor(); + }else{ + QMessageBox::warning(0,"FaceTrackNoIR Error", "Unable to find Rift tracker",QMessageBox::Ok,QMessageBox::NoButton); } if (pSensor){ - SFusion.reset(new OVR::SensorFusion()); - SFusion->AttachToSensor(pSensor); + pSFusion = new OVR::SensorFusion(); + pSFusion->Reset(); + pSFusion->AttachToSensor(pSensor); }else{ - QMessageBox::warning(0,"FaceTrackNoIR Error", "Unable to find Rift tracker",QMessageBox::Ok,QMessageBox::NoButton); + QMessageBox::warning(0,"FaceTrackNoIR Error", "Unable to create Rift sensor",QMessageBox::Ok,QMessageBox::NoButton); } - //isCalibrated = false; - //MagCal.BeginAutoCalibration(SFusion); + + }else{ + QMessageBox::warning(0,"FaceTrackNoIR Error", "Unable to find Rift tracker",QMessageBox::Ok,QMessageBox::NoButton); } - } + }else{ + QMessageBox::warning(0,"FaceTrackNoIR Error", "Unable to start Rift tracker",QMessageBox::Ok,QMessageBox::NoButton); + } } bool Rift_Tracker::GiveHeadPoseData(double *data) { - if (SFusion != nullptr) { - Quatf hmdOrient = SFusion->GetOrientation(); + if (pSFusion != NULL) { + Quatf hmdOrient = pSFusion->GetOrientation(); float newHeadPose[6]; float yaw = 0.0f; @@ -120,7 +113,7 @@ bool Rift_Tracker::GiveHeadPoseData(double *data) data[Roll] = newHeadPose[Roll] * 57.295781f; } } - return pHMD.GetPtr() != NULL; + return pHMD != NULL; } diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift.h b/ftnoir_tracker_rift/ftnoir_tracker_rift.h index 34742d6c..970a64a2 100644 --- a/ftnoir_tracker_rift/ftnoir_tracker_rift.h +++ b/ftnoir_tracker_rift/ftnoir_tracker_rift.h @@ -22,11 +22,10 @@ protected: private: static bool isInitialised; - OVR::Ptr pManager; - OVR::Ptr pHMD; - OVR::Ptr pSensor; - std::unique_ptr SFusion; - // Magnetometer calibration and yaw correction + OVR::DeviceManager* pManager; + OVR::HMDDevice* pHMD; + OVR::SensorDevice* pSensor; + OVR::SensorFusion* pSFusion; bool bEnableRoll; bool bEnablePitch; bool bEnableYaw; @@ -35,7 +34,7 @@ private: bool bEnableY; bool bEnableZ; #endif - QMutex mutex; + }; // Widget that has controls for FTNoIR protocol client-settings. -- cgit v1.2.3 From 52cb9e157db8823dc8318ce2df79fac837413e7f Mon Sep 17 00:00:00 2001 From: mm0zct Date: Mon, 21 Oct 2013 22:20:10 +0100 Subject: stupid git being a pain, I don't want this change to appear in lib-ovr branch --- ftnoir_tracker_base/ftnoir_tracker_base.h | 1 - 1 file changed, 1 deletion(-) diff --git a/ftnoir_tracker_base/ftnoir_tracker_base.h b/ftnoir_tracker_base/ftnoir_tracker_base.h index 84629547..cb83aea3 100644 --- a/ftnoir_tracker_base/ftnoir_tracker_base.h +++ b/ftnoir_tracker_base/ftnoir_tracker_base.h @@ -44,7 +44,6 @@ struct ITracker virtual ~ITracker() = 0; virtual void StartTracker( QFrame* frame ) = 0; virtual bool GiveHeadPoseData(double *data) = 0; -// virtual void HotkeyCallback(unsigned int *) = 0; }; inline ITracker::~ITracker() { } -- 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(-) 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 245f909db8ab5549ae2e08e39178a4c7463419ef Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 22 Oct 2013 01:52:22 +0200 Subject: fix race Signed-off-by: Stanislaw Halik --- FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp index 745d98e9..43ecc775 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp @@ -30,11 +30,6 @@ Tracker::Tracker() tracking_valid(false) { qDebug()<<"Tracker::Tracker"; - TrackerSettings settings; - settings.load_ini(); - apply(settings); - camera.start(); - start(); } Tracker::~Tracker() @@ -207,6 +202,11 @@ void Tracker::Initialize(QFrame *video_frame) video_frame->setAttribute(Qt::WA_NativeWindow); video_frame->show(); update_show_video_widget(); + TrackerSettings settings; + settings.load_ini(); + apply(settings); + camera.start(); + start(); } void Tracker::refreshVideo() -- cgit v1.2.3 From f50036627c4175ad307552fa40a78042934139f2 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 22 Oct 2013 01:52:44 +0200 Subject: fix camera name & crash bug Signed-off-by: Stanislaw Halik --- FTNoIR_Tracker_PT/camera.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/FTNoIR_Tracker_PT/camera.cpp b/FTNoIR_Tracker_PT/camera.cpp index 14f7a6be..0ef617c3 100644 --- a/FTNoIR_Tracker_PT/camera.cpp +++ b/FTNoIR_Tracker_PT/camera.cpp @@ -6,6 +6,7 @@ */ #include "camera.h" +#include #include using namespace cv; @@ -48,7 +49,9 @@ void get_camera_device_names(std::vector& device_names) { hr = pPropBag->Read(L"FriendlyName", &varName, 0); if (SUCCEEDED(hr)) { - device_names.push_back(std::string(reinterpret_cast(varName.bstrVal))); + auto wstr = std::wstring(varName.bstrVal); + auto str = std::string(wstr.begin(), wstr.end()); + device_names.push_back(str); } VariantClear(&varName); @@ -71,8 +74,6 @@ void get_camera_device_names(std::vector& device_names) { sprintf(buf, "/dev/video%d", i); if (access(buf, R_OK | W_OK) == 0) { device_names.push_back(std::string(buf)); - } else { - continue; } } # endif @@ -162,10 +163,6 @@ void CVCamera::start() 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() @@ -180,7 +177,7 @@ void CVCamera::stop() bool CVCamera::_get_frame(Mat* frame) { - if (cap) + if (cap && cap->isOpened()) { Mat img; /* @@ -188,9 +185,12 @@ bool CVCamera::_get_frame(Mat* frame) * frames and then some every once in a while * -sh */ - while (!cap->read(img))\ + while (!cap->read(img)) ;; + if (img.empty()) + return false; + *frame = img; return true; } -- 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(-) 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 5bf0964212f2210e9a454e1bcf24b1f96b479922 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 22 Oct 2013 02:32:15 +0200 Subject: bump --- installer/opentrack-installer.iss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/installer/opentrack-installer.iss b/installer/opentrack-installer.iss index 47bafe7a..f7b2c272 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.0a5" +#define MyAppVersion "2.0a6" #define MyAppPublisher "opentrack" #define MyAppURL "http://github.com/opentrack/opentrack" #define MyAppExeName "opentrack.exe" -- cgit v1.2.3 From d7d733131d62777481c9a72fee9005dd58cf0c74 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 22 Oct 2013 02:33:11 +0200 Subject: Optimize widget redraw Signed-off-by: Stanislaw Halik --- FTNoIR_Tracker_PT/pt_video_widget.cpp | 35 ++++++++++++++++++++------------ FTNoIR_Tracker_PT/pt_video_widget.h | 4 +++- ftnoir_tracker_aruco/ar_video_widget.cpp | 26 ++++++++++++++++++------ ftnoir_tracker_aruco/ar_video_widget.h | 10 ++++++++- 4 files changed, 54 insertions(+), 21 deletions(-) diff --git a/FTNoIR_Tracker_PT/pt_video_widget.cpp b/FTNoIR_Tracker_PT/pt_video_widget.cpp index 03c42fc7..35a2c42b 100644 --- a/FTNoIR_Tracker_PT/pt_video_widget.cpp +++ b/FTNoIR_Tracker_PT/pt_video_widget.cpp @@ -18,19 +18,7 @@ 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); + _frame = frame; } // ---------------------------------------------------------------------------- @@ -50,3 +38,24 @@ VideoWidgetDialog::VideoWidgetDialog(QWidget *parent, FrameProvider* provider) setLayout(layout); resize(VIDEO_FRAME_WIDTH, VIDEO_FRAME_HEIGHT); } + +void PTVideoWidget::update_and_repaint() +{ + QMutexLocker foo(&mtx); + if (_frame.empty()) + return; + 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); + update(); +} diff --git a/FTNoIR_Tracker_PT/pt_video_widget.h b/FTNoIR_Tracker_PT/pt_video_widget.h index e67e6d57..f5663e47 100644 --- a/FTNoIR_Tracker_PT/pt_video_widget.h +++ b/FTNoIR_Tracker_PT/pt_video_widget.h @@ -31,7 +31,7 @@ class PTVideoWidget : public QWidget, public FrameObserver public: PTVideoWidget(QWidget *parent, FrameProvider* provider) : QWidget(parent), /* to avoid linker errors */ FrameObserver(provider) { - connect(&timer, SIGNAL(timeout()), this, SLOT(update())); + connect(&timer, SIGNAL(timeout()), this, SLOT(update_and_repaint())); timer.start(45); } void update_image(const cv::Mat &frame); @@ -42,10 +42,12 @@ protected slots: QPainter painter(this); painter.drawPixmap(e->rect(), pixmap, e->rect()); } + void update_and_repaint(); private: QMutex mtx; QPixmap pixmap; QTimer timer; + cv::Mat _frame; }; // ---------------------------------------------------------------------------- diff --git a/ftnoir_tracker_aruco/ar_video_widget.cpp b/ftnoir_tracker_aruco/ar_video_widget.cpp index 6a4572a0..b727679b 100644 --- a/ftnoir_tracker_aruco/ar_video_widget.cpp +++ b/ftnoir_tracker_aruco/ar_video_widget.cpp @@ -14,17 +14,31 @@ using namespace std; void ArucoVideoWidget::update_image(unsigned char *frame, int width, int height) { QMutexLocker foo(&mtx); + memcpy(fb, frame, width * height * 3); + this->width = width; + this->height = height; +} + +void ArucoVideoWidget::update_and_repaint() +{ + QMutexLocker foo(&mtx); + if (width*height <= 0) + return; QImage qframe = QImage(width, height, QImage::Format_RGB888); uchar* data = qframe.bits(); const int pitch = qframe.bytesPerLine(); for (int y = 0; y < height; y++) + { + const int part = y*width; 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]; + const int pos = 3 * (part + x); + data[y * pitch + x * 3 + 0] = fb[pos + 2]; + data[y * pitch + x * 3 + 1] = fb[pos + 1]; + data[y * pitch + x * 3 + 2] = fb[pos + 0]; } - qframe = qframe.scaled(size(), Qt::IgnoreAspectRatio, Qt::FastTransformation); - pixmap = QPixmap::fromImage(qframe); + } + auto qframe2 = qframe.scaled(size(), Qt::IgnoreAspectRatio, Qt::FastTransformation); + pixmap = QPixmap::fromImage(qframe2); + update(); } diff --git a/ftnoir_tracker_aruco/ar_video_widget.h b/ftnoir_tracker_aruco/ar_video_widget.h index dd0c16ac..3a1574cd 100644 --- a/ftnoir_tracker_aruco/ar_video_widget.h +++ b/ftnoir_tracker_aruco/ar_video_widget.h @@ -15,6 +15,7 @@ #include #include #include +#include // ---------------------------------------------------------------------------- class ArucoVideoWidget : public QWidget @@ -22,7 +23,9 @@ class ArucoVideoWidget : public QWidget Q_OBJECT public: - ArucoVideoWidget(QWidget *parent) : QWidget(parent), mtx() { + ArucoVideoWidget(QWidget *parent) : QWidget(parent), width(0), height(0), fb{0} { + connect(&timer, SIGNAL(timeout()), this, SLOT(update_and_repaint())); + timer.start(60); } void update_image(unsigned char* frame, int width, int height); protected slots: @@ -31,9 +34,14 @@ protected slots: QPainter painter(this); painter.drawPixmap(e->rect(), pixmap, e->rect()); } + void update_and_repaint(); + private: QMutex mtx; QPixmap pixmap; + QTimer timer; + char fb[2048*2048*3]; + int width,height; }; #endif // VIDEOWIDGET_H -- cgit v1.2.3 From 8503f538d18f8df0f18ee4973e96f3889a11419a Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 22 Oct 2013 02:40:02 +0200 Subject: optimize HT widget refresh Signed-off-by: Stanislaw Halik --- ftnoir_tracker_ht/ftnoir_tracker_ht.cpp | 9 --------- ftnoir_tracker_ht/ftnoir_tracker_ht.h | 4 ---- ftnoir_tracker_ht/ht_video_widget.cpp | 26 ++++++++++++++++++++------ ftnoir_tracker_ht/ht_video_widget.h | 14 +++++++++++--- 4 files changed, 31 insertions(+), 22 deletions(-) diff --git a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp index 62606395..d14fa5e0 100644 --- a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp +++ b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp @@ -184,15 +184,6 @@ void Tracker::StartTracker(QFrame* videoframe) #else subprocess.start(QCoreApplication::applicationDirPath() + "/tracker-ht/headtracker-ftnoir"); #endif - connect(&timer, SIGNAL(timeout()), this, SLOT(paint_widget())); - timer.start(40); -} - -void Tracker::paint_widget() { - if (fresh) { - fresh = false; - videoWidget->update(); - } } bool Tracker::GiveHeadPoseData(double *data) diff --git a/ftnoir_tracker_ht/ftnoir_tracker_ht.h b/ftnoir_tracker_ht/ftnoir_tracker_ht.h index bde4ca67..e1810232 100644 --- a/ftnoir_tracker_ht/ftnoir_tracker_ht.h +++ b/ftnoir_tracker_ht/ftnoir_tracker_ht.h @@ -15,7 +15,6 @@ #include "ht_video_widget.h" #include "compat/compat.h" #include -#include class Tracker : public QObject, public ITracker { @@ -28,14 +27,11 @@ public: bool enableTX, enableTY, enableTZ, enableRX, enableRY, enableRZ; ht_shm_t* shm; private: - QTimer timer; PortableLockedShm lck_shm; QProcess subprocess; HTVideoWidget* videoWidget; QHBoxLayout* layout; volatile bool fresh; -private slots: - void paint_widget(); }; // Widget that has controls for FTNoIR protocol client-settings. diff --git a/ftnoir_tracker_ht/ht_video_widget.cpp b/ftnoir_tracker_ht/ht_video_widget.cpp index 4d7d66a2..8ccec997 100644 --- a/ftnoir_tracker_ht/ht_video_widget.cpp +++ b/ftnoir_tracker_ht/ht_video_widget.cpp @@ -14,17 +14,31 @@ using namespace std; void HTVideoWidget::update_image(unsigned char *frame, int width, int height) { QMutexLocker foo(&mtx); + memcpy(fb, frame, width * height * 3); + this->width = width; + this->height = height; +} + +void HTVideoWidget::update_and_repaint() +{ + QMutexLocker foo(&mtx); + if (width*height <= 0) + return; QImage qframe = QImage(width, height, QImage::Format_RGB888); uchar* data = qframe.bits(); const int pitch = qframe.bytesPerLine(); for (int y = 0; y < height; y++) + { + const int part = y*width; 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]; + const int pos = 3 * (part + x); + data[y * pitch + x * 3 + 0] = fb[pos + 2]; + data[y * pitch + x * 3 + 1] = fb[pos + 1]; + data[y * pitch + x * 3 + 2] = fb[pos + 0]; } - qframe = qframe.scaled(size(), Qt::IgnoreAspectRatio, Qt::FastTransformation); - pixmap = QPixmap::fromImage(qframe); + } + auto qframe2 = qframe.scaled(size(), Qt::IgnoreAspectRatio, Qt::FastTransformation); + pixmap = QPixmap::fromImage(qframe2); + update(); } diff --git a/ftnoir_tracker_ht/ht_video_widget.h b/ftnoir_tracker_ht/ht_video_widget.h index b1182d8b..78000afa 100644 --- a/ftnoir_tracker_ht/ht_video_widget.h +++ b/ftnoir_tracker_ht/ht_video_widget.h @@ -15,15 +15,18 @@ #include #include #include +#include // ---------------------------------------------------------------------------- class HTVideoWidget : public QWidget { - Q_OBJECT + Q_OBJECT public: - HTVideoWidget(QWidget *parent) : QWidget(parent), mtx() { - } + HTVideoWidget(QWidget *parent) : QWidget(parent), width(0), height(0), fb{0} { + connect(&timer, SIGNAL(timeout()), this, SLOT(update_and_repaint())); + timer.start(60); + } void update_image(unsigned char* frame, int width, int height); protected slots: void paintEvent( QPaintEvent* e ) { @@ -31,9 +34,14 @@ protected slots: QPainter painter(this); painter.drawPixmap(e->rect(), pixmap, e->rect()); } + void update_and_repaint(); + private: QMutex mtx; QPixmap pixmap; + QTimer timer; + char fb[2048*2048*3]; + int width,height; }; #endif // VIDEOWIDGET_H -- cgit v1.2.3 From 6fa9e7bb7810f89b0bcc376c940b0c74ac91fdf3 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 22 Oct 2013 02:45:26 +0200 Subject: aruco: remove dead/broken code Signed-off-by: Stanislaw Halik --- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 13 +------------ ftnoir_tracker_aruco/ftnoir_tracker_aruco.h | 6 +----- 2 files changed, 2 insertions(+), 17 deletions(-) diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index a221c2ff..099c1f85 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -127,7 +127,6 @@ void Tracker::load_settings() Tracker::Tracker() { - fresh = false; stop = false; videoWidget = NULL; layout = NULL; @@ -158,20 +157,11 @@ void Tracker::StartTracker(QFrame* videoframe) videoWidget->show(); this->layout = layout; load_settings(); - connect(&timer, SIGNAL(timeout()), this, SLOT(paint_widget())); - timer.start(50); start(); for (int i = 0; i < 6; i++) pose[i] = 0; } -void Tracker::paint_widget() { - if (fresh) { - fresh = false; - videoWidget->update(); - } -} - #define HT_PI 3.1415926535 void Tracker::run() @@ -232,10 +222,9 @@ void Tracker::run() frame = color; - if (frame.rows > 0 && !fresh) + if (frame.rows > 0) { videoWidget->update_image(frame.data, frame.cols, frame.rows); - fresh = true; } if (markers.size() == 1 && markers[0].size() == 4) { diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h index 815ca91c..8d532b4c 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h @@ -12,7 +12,6 @@ #include "ui_aruco-trackercontrols.h" #include "ar_video_widget.h" #include -#include #include #include #include @@ -31,10 +30,9 @@ public: void run(); private: QMutex mtx; - QTimer timer; ArucoVideoWidget* videoWidget; QHBoxLayout* layout; - volatile bool fresh, stop; + volatile bool stop; float fov; int camera_index; float dc[5]; @@ -42,8 +40,6 @@ private: void load_settings(); double pose[6]; cv::Mat frame; -private slots: - void paint_widget(); }; // Widget that has controls for FTNoIR protocol client-settings. -- cgit v1.2.3 From 576f6d7448c7666d140d613253a8a57d0d8edf4b Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 22 Oct 2013 02:45:39 +0200 Subject: ht: remove dead code Signed-off-by: Stanislaw Halik --- ftnoir_tracker_ht/ftnoir_tracker_ht.cpp | 3 +-- ftnoir_tracker_ht/ftnoir_tracker_ht.h | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp index d14fa5e0..010741c6 100644 --- a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp +++ b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp @@ -136,7 +136,7 @@ static void load_settings(ht_config_t* config, Tracker* tracker) iniFile.endGroup(); } -Tracker::Tracker() : lck_shm(HT_SHM_NAME, HT_MUTEX_NAME, sizeof(ht_shm_t)), fresh(false) +Tracker::Tracker() : lck_shm(HT_SHM_NAME, HT_MUTEX_NAME, sizeof(ht_shm_t)) { videoWidget = NULL; layout = NULL; @@ -196,7 +196,6 @@ bool Tracker::GiveHeadPoseData(double *data) { videoWidget->update_image(shm->frame.frame, shm->frame.width, shm->frame.height); //memcpy(foo, shm->frame.frame, shm->frame.width * shm->frame.height * 3); - fresh = true; shm->frame.width = 0; } if (shm->result.filled) { diff --git a/ftnoir_tracker_ht/ftnoir_tracker_ht.h b/ftnoir_tracker_ht/ftnoir_tracker_ht.h index e1810232..c19e2d93 100644 --- a/ftnoir_tracker_ht/ftnoir_tracker_ht.h +++ b/ftnoir_tracker_ht/ftnoir_tracker_ht.h @@ -31,7 +31,6 @@ private: QProcess subprocess; HTVideoWidget* videoWidget; QHBoxLayout* layout; - volatile bool fresh; }; // Widget that has controls for FTNoIR protocol client-settings. -- cgit v1.2.3 From 1ad91f92226facb3306003f19407f45b727c3973 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 22 Oct 2013 02:51:19 +0200 Subject: hopefully fix msvc2010 build Signed-off-by: Stanislaw Halik --- ftnoir_tracker_aruco/ar_video_widget.h | 2 +- ftnoir_tracker_ht/ht_video_widget.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ftnoir_tracker_aruco/ar_video_widget.h b/ftnoir_tracker_aruco/ar_video_widget.h index 3a1574cd..d16cb017 100644 --- a/ftnoir_tracker_aruco/ar_video_widget.h +++ b/ftnoir_tracker_aruco/ar_video_widget.h @@ -23,7 +23,7 @@ class ArucoVideoWidget : public QWidget Q_OBJECT public: - ArucoVideoWidget(QWidget *parent) : QWidget(parent), width(0), height(0), fb{0} { + ArucoVideoWidget(QWidget *parent) : QWidget(parent), width(0), height(0), fb() { connect(&timer, SIGNAL(timeout()), this, SLOT(update_and_repaint())); timer.start(60); } diff --git a/ftnoir_tracker_ht/ht_video_widget.h b/ftnoir_tracker_ht/ht_video_widget.h index 78000afa..33f21226 100644 --- a/ftnoir_tracker_ht/ht_video_widget.h +++ b/ftnoir_tracker_ht/ht_video_widget.h @@ -23,7 +23,7 @@ class HTVideoWidget : public QWidget Q_OBJECT public: - HTVideoWidget(QWidget *parent) : QWidget(parent), width(0), height(0), fb{0} { + HTVideoWidget(QWidget *parent) : QWidget(parent), width(0), height(0), fb() { connect(&timer, SIGNAL(timeout()), this, SLOT(update_and_repaint())); timer.start(60); } -- 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 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 61dd97ad85b43c96c4cc81a637f24e8160615438 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 22 Oct 2013 02:57:40 +0200 Subject: installer: use LZMA2 --- installer/opentrack-installer.iss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/installer/opentrack-installer.iss b/installer/opentrack-installer.iss index 30669ee5..3c97fe46 100644 --- a/installer/opentrack-installer.iss +++ b/installer/opentrack-installer.iss @@ -25,7 +25,7 @@ DefaultGroupName={#MyAppName} AllowNoIcons=yes OutputBaseFilename=opentrack-setup-{#MyAppVersion} SetupIconFile=d:\opentrack-win32-sdk\opentrack\facetracknoir\facetracknoir.ico -Compression=lzma/ultra64 +Compression=lzma2/ultra64 SolidCompression=yes DisableWelcomePage=True DisableReadyPage=True -- 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(-) 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 ed9316744519fadf113f8c8ee280b1c5d6267f1e Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 23 Oct 2013 08:16:24 +0200 Subject: uses non-linear scaling factor for translation Testing suggests that for optimizing numeric solvers, Z value is by far the least idempotent of the three Signed-off-by: Stanislaw Halik --- ftnoir_filter_accela/ftnoir_filter_accela.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.cpp b/ftnoir_filter_accela/ftnoir_filter_accela.cpp index 4060a8eb..76f6e687 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela.cpp @@ -26,11 +26,11 @@ 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" ); - zoom_factor = iniFile.value("zoom-slowness", ACCELA_ZOOM_SLOWNESS).toDouble(); + 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(); iniFile.endGroup (); @@ -45,7 +45,7 @@ void FTNoIR_Filter::receiveSettings(double rot, double trans, double zoom_fac) zoom_factor = zoom_fac; } -static double parabola(const double a, const double x) +static inline double parabola(const double a, const double x) { const double a1 = 1./a; return a1 * x * x; @@ -69,6 +69,15 @@ void FTNoIR_Filter::FilterHeadPoseData(const double* target_camera_position, QMutexLocker foo(&mutex); + static const double scaling[] = { + 1.5, + 1.5, + 1, + 1, + 1, + 1 + }; + for (int i=0;i<6;i++) { const double vec = target_camera_position[i] - current_camera_position[i]; @@ -76,7 +85,7 @@ void FTNoIR_Filter::FilterHeadPoseData(const double* target_camera_position, 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 velocity = parabola(a, x * scaling[i]) * 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; -- cgit v1.2.3 From da9cec1a426d6ef3139d02794c5e1b8690808161 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 23 Oct 2013 08:44:26 +0200 Subject: accela: configurable axis speed Signed-off-by: Stanislaw Halik --- .../ftnoir_accela_filtercontrols.ui | 229 ++++++++++++++++++++- ftnoir_filter_accela/ftnoir_filter_accela.cpp | 25 ++- ftnoir_filter_accela/ftnoir_filter_accela.h | 1 + .../ftnoir_filter_accela_dialog.cpp | 60 ++++++ 4 files changed, 302 insertions(+), 13 deletions(-) diff --git a/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui b/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui index ba77f1a8..2dac7a51 100644 --- a/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui +++ b/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui @@ -9,8 +9,8 @@ 0 0 - 615 - 68 + 623 + 293 @@ -21,8 +21,8 @@ - 616 - 68 + 42000 + 42000 @@ -160,7 +160,7 @@ background:none; 541 10 - 42 + 51 22 @@ -225,6 +225,225 @@ background:none; Cancel
+ + + + 440 + 70 + 151 + 214 + + + + Axis speed + + + + QFormLayout::ExpandingFieldsGrow + + + 20 + + + + + X + + + + + + + 4 + + + 0.100000000000000 + + + 3.000000000000000 + + + 0.100000000000000 + + + 1.000000000000000 + + + + + + + Y + + + + + + + 4 + + + 0.100000000000000 + + + 3.000000000000000 + + + 0.100000000000000 + + + 1.000000000000000 + + + + + + + Z + + + + + + + 4 + + + 0.100000000000000 + + + 3.000000000000000 + + + 0.100000000000000 + + + 1.000000000000000 + + + + + + + Yaw + + + + + + + false + + + 4 + + + 0.100000000000000 + + + 3.000000000000000 + + + 0.100000000000000 + + + 1.000000000000000 + + + + + + + Pitch + + + + + + + false + + + 4 + + + 0.100000000000000 + + + 3.000000000000000 + + + 0.100000000000000 + + + 1.000000000000000 + + + + + + + Roll + + + + + + + false + + + 4 + + + 0.100000000000000 + + + 3.000000000000000 + + + 0.100000000000000 + + + 1.000000000000000 + + + + + + + + + 20 + 100 + 371 + 51 + + + + QFrame::NoFrame + + + Accela filter by Stanisław Halik <sthalik@misaki.pl> +With kind help from Donovan Baarda. +2012-2013 + + + Qt::AutoText + + + false + + + Qt::AlignJustify|Qt::AlignTop + + + true + + + 0 + +
diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.cpp b/ftnoir_filter_accela/ftnoir_filter_accela.cpp index 76f6e687..25716973 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela.cpp @@ -34,6 +34,22 @@ void FTNoIR_Filter::loadSettings() { rotation_alpha = iniFile.value("rotation-alpha", ACCELA_SMOOTHING_ROTATION).toDouble(); translation_alpha = iniFile.value("translation-alpha", ACCELA_SMOOTHING_TRANSLATION).toDouble(); iniFile.endGroup (); + + iniFile.beginGroup("Accela-Scaling"); + // bigger means less filtering + static const double init_scaling[] = { + 1.5, // X + 1.5, // Y + 1, // Z + 0.8, // Yaw + 0.9, // Pitch + 1.25 // Roll + }; + for (int i = 0; i < 6; i++) + { + scaling[i] = iniFile.value(QString("axis-%1").arg(QString::number(i)), init_scaling[i]).toDouble(); + } + iniFile.endGroup(); } void FTNoIR_Filter::receiveSettings(double rot, double trans, double zoom_fac) @@ -69,14 +85,7 @@ void FTNoIR_Filter::FilterHeadPoseData(const double* target_camera_position, QMutexLocker foo(&mutex); - static const double scaling[] = { - 1.5, - 1.5, - 1, - 1, - 1, - 1 - }; + 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 f1807fd0..512b4576 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.h +++ b/ftnoir_filter_accela/ftnoir_filter_accela.h @@ -54,6 +54,7 @@ private: bool first_run; double rotation_alpha, translation_alpha, zoom_factor; double current_camera_position[6]; + double scaling[6]; }; //******************************************************************************************************* diff --git a/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp b/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp index 6ae1e4bc..4cd45910 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include "facetracknoir/global-settings.h" //******************************************************************************************************* @@ -49,6 +50,20 @@ FilterControls::FilterControls() : connect(ui.slideZoom, SIGNAL(valueChanged(int)), this, SLOT(settingChanged(int))); connect(ui.spinZoom, SIGNAL(valueChanged(int)), this, SLOT(settingChanged(int))); + QDoubleSpinBox* boxen[] = { + ui.doubleSpinBox, + ui.doubleSpinBox_2, + ui.doubleSpinBox_3, + ui.doubleSpinBox_4, + ui.doubleSpinBox_5, + ui.doubleSpinBox_6, + }; + + for (int i = 0; i < 6; i++) + { + connect(boxen[i], SIGNAL(valueChanged(double)), this, SLOT(settingChanged(double))); + } + qDebug() << "FilterControls() says: started"; } @@ -147,6 +162,34 @@ void FilterControls::loadSettings() { ui.translation_alpha->setValue(iniFile.value("translation-alpha", ACCELA_SMOOTHING_TRANSLATION).toDouble()); iniFile.endGroup (); + iniFile.beginGroup("Accela-Scaling"); + // bigger means less filtering + static const double init_scaling[] = { + 1.5, // X + 1.5, // Y + 1, // Z + 0.8, // Yaw + 0.9, // Pitch + 1.25 // Roll + }; + + QDoubleSpinBox* boxen[] = { + ui.doubleSpinBox, + ui.doubleSpinBox_2, + ui.doubleSpinBox_3, + ui.doubleSpinBox_4, + ui.doubleSpinBox_5, + ui.doubleSpinBox_6, + }; + + for (int i = 0; i < 6; i++) + { + boxen[i]->setValue(iniFile.value(QString("axis-%1").arg(QString::number(i)), init_scaling[i]).toDouble()); + } + iniFile.endGroup(); + + + settingsDirty = false; } @@ -169,6 +212,23 @@ void FilterControls::save() { iniFile.setValue("translation-alpha", trans = ui.translation_alpha->value()); iniFile.endGroup (); + iniFile.beginGroup("Accela-Scaling"); + + QDoubleSpinBox* boxen[] = { + ui.doubleSpinBox, + ui.doubleSpinBox_2, + ui.doubleSpinBox_3, + ui.doubleSpinBox_4, + ui.doubleSpinBox_5, + ui.doubleSpinBox_6, + }; + + for (int i = 0; i < 6; i++) + { + iniFile.setValue(QString("axis-%1").arg(QString::number(i)), boxen[i]->value()); + } + iniFile.endGroup(); + settingsDirty = false; if (accela_filter) -- cgit v1.2.3 From f4437d3b2c86d28bfa9230fd49386c89ad28b18c Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 23 Oct 2013 08:50:47 +0200 Subject: Accela: use layouts Signed-off-by: Stanislaw Halik --- .../ftnoir_accela_filtercontrols.ui | 760 ++++++++++----------- 1 file changed, 355 insertions(+), 405 deletions(-) diff --git a/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui b/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui index 2dac7a51..df730fad 100644 --- a/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui +++ b/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui @@ -9,8 +9,8 @@ 0 0 - 623 - 293 + 670 + 320 @@ -21,8 +21,8 @@ - 42000 - 42000 + 670 + 320 @@ -41,409 +41,359 @@ - - - - 243 - 10 - 111 - 22 - - - - - 25 - 0 - - - - - 150 - 16777215 - - - - color:#0; -background:none; - - - Zoom slowness - - - - - - 130 - 40 - 81 - 22 - - - - 0.100000000000000 - - - 65535.000000000000000 - - - 1.000000000000000 - - - - - - 130 - 10 - 81 - 22 - - - - 0.100000000000000 - - - 65535.000000000000000 - - - 1.000000000000000 - - - - - - 10 - 10 - 111 - 16 - - - - Rotation smoothing - - - - - - 346 - 13 - 189 - 15 - - - - - 50 - 15 - - - - 0 - - - 200 - - - 1 - - - 100 - - - Qt::Horizontal - - - QSlider::NoTicks - - - - - - 541 - 10 - 51 - 22 - - - - - 35 - 22 - - - - background:none; - - - false - - - 0 - - - 200 - - - 100 - - - - - - 10 - 40 - 111 - 16 - - - - Translation smoothing - - - - - - 430 - 40 - 75 - 23 - - - - OK - - - - - - 511 - 40 - 75 - 23 - - - - Cancel - - - - - - 440 - 70 - 151 - 214 - - - - Axis speed - - - - QFormLayout::ExpandingFieldsGrow - - - 20 - - - - - X - - - - - - - 4 - - - 0.100000000000000 - - - 3.000000000000000 - - - 0.100000000000000 - - - 1.000000000000000 - - - - - - - Y - - - - - - - 4 - - - 0.100000000000000 - - - 3.000000000000000 - - - 0.100000000000000 - - - 1.000000000000000 - - - - - - - Z - - - - - - - 4 - - - 0.100000000000000 - - - 3.000000000000000 - - - 0.100000000000000 - - - 1.000000000000000 - - - - - - - Yaw - - - - - - - false - - - 4 - - - 0.100000000000000 - - - 3.000000000000000 - - - 0.100000000000000 - - - 1.000000000000000 - - - - - - - Pitch - - - - - - - false - - - 4 - - - 0.100000000000000 - - - 3.000000000000000 - - - 0.100000000000000 - - - 1.000000000000000 - - - - - - - Roll - - - - - - - false - - - 4 - - - 0.100000000000000 - - - 3.000000000000000 - - - 0.100000000000000 - - - 1.000000000000000 - - - - - - - - - 20 - 100 - 371 - 51 - - - - QFrame::NoFrame - - - Accela filter by StanisÅ‚aw Halik <sthalik@misaki.pl> + + + QLayout::SetMinAndMaxSize + + + + + Axis speed + + + + QFormLayout::ExpandingFieldsGrow + + + 20 + + + + + X + + + + + + + 4 + + + 0.100000000000000 + + + 3.000000000000000 + + + 0.100000000000000 + + + 1.000000000000000 + + + + + + + Y + + + + + + + 4 + + + 0.100000000000000 + + + 3.000000000000000 + + + 0.100000000000000 + + + 1.000000000000000 + + + + + + + Z + + + + + + + 4 + + + 0.100000000000000 + + + 3.000000000000000 + + + 0.100000000000000 + + + 1.000000000000000 + + + + + + + Yaw + + + + + + + false + + + 4 + + + 0.100000000000000 + + + 3.000000000000000 + + + 0.100000000000000 + + + 1.000000000000000 + + + + + + + Pitch + + + + + + + false + + + 4 + + + 0.100000000000000 + + + 3.000000000000000 + + + 0.100000000000000 + + + 1.000000000000000 + + + + + + + Roll + + + + + + + false + + + 4 + + + 0.100000000000000 + + + 3.000000000000000 + + + 0.100000000000000 + + + 1.000000000000000 + + + + + + + + + + Cancel + + + + + + + + 8 + + + + QFrame::NoFrame + + + Accela filter by StanisÅ‚aw Halik <sthalik@misaki.pl> With kind help from Donovan Baarda. 2012-2013 - - - Qt::AutoText - - - false - - - Qt::AlignJustify|Qt::AlignTop - - - true - - - 0 - - + + + Qt::AutoText + + + false + + + Qt::AlignJustify|Qt::AlignTop + + + true + + + 0 + + + + + + + 3 + + + 0.100000000000000 + + + 65535.000000000000000 + + + 1.000000000000000 + + + + + + + OK + + + + + + + Translation smoothing + + + + + + + + 50 + 15 + + + + 0 + + + 200 + + + 1 + + + 100 + + + Qt::Horizontal + + + QSlider::NoTicks + + + + + + + + 35 + 22 + + + + background:none; + + + false + + + 0 + + + 200 + + + 45 + + + + + + + Rotation smoothing + + + + + + + 3 + + + 0.100000000000000 + + + 65535.000000000000000 + + + 1.000000000000000 + + + + + + + + 25 + 0 + + + + + 150 + 16777215 + + + + color:#0; +background:none; + + + Zoom speed + + + + -- cgit v1.2.3 From 139d8b71e617b138dd17ddf12d54fe2e676d9089 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 23 Oct 2013 09:10:33 +0200 Subject: redo layout Signed-off-by: Stanislaw Halik --- .../ftnoir_accela_filtercontrols.ui | 807 +++++++++++---------- .../ftnoir_filter_accela_dialog.cpp | 3 - 2 files changed, 420 insertions(+), 390 deletions(-) diff --git a/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui b/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui index df730fad..bc66fdc2 100644 --- a/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui +++ b/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui @@ -9,8 +9,8 @@ 0 0 - 670 - 320 + 450 + 350 @@ -21,8 +21,8 @@ - 670 - 320 + 450 + 350 @@ -41,395 +41,428 @@ - - - QLayout::SetMinAndMaxSize + + + + 260 + 4 + 160 + 201 + - - - - Axis speed - - - - QFormLayout::ExpandingFieldsGrow - - - 20 - - - - - X - - - - - - - 4 - - - 0.100000000000000 - - - 3.000000000000000 - - - 0.100000000000000 - - - 1.000000000000000 - - - - - - - Y - - - - - - - 4 - - - 0.100000000000000 - - - 3.000000000000000 - - - 0.100000000000000 - - - 1.000000000000000 - - - - - - - Z - - - - - - - 4 - - - 0.100000000000000 - - - 3.000000000000000 - - - 0.100000000000000 - - - 1.000000000000000 - - - - - - - Yaw - - - - - - - false - - - 4 - - - 0.100000000000000 - - - 3.000000000000000 - - - 0.100000000000000 - - - 1.000000000000000 - - - - - - - Pitch - - - - - - - false - - - 4 - - - 0.100000000000000 - - - 3.000000000000000 - - - 0.100000000000000 - - - 1.000000000000000 - - - - - - - Roll - - - - - - - false - - - 4 - - - 0.100000000000000 - - - 3.000000000000000 - - - 0.100000000000000 - - - 1.000000000000000 - - - - - - - - - - Cancel - - - - - - - - 8 - - - - QFrame::NoFrame - - - Accela filter by StanisÅ‚aw Halik <sthalik@misaki.pl> + + + 150 + 100 + + + + Axis speed + + + + QFormLayout::ExpandingFieldsGrow + + + 20 + + + 2 + + + 20 + + + 7 + + + 10 + + + 15 + + + + + X + + + + + + + 4 + + + 0.100000000000000 + + + 3.000000000000000 + + + 0.100000000000000 + + + 1.000000000000000 + + + + + + + Y + + + + + + + 4 + + + 0.100000000000000 + + + 3.000000000000000 + + + 0.100000000000000 + + + 1.000000000000000 + + + + + + + Z + + + + + + + 4 + + + 0.100000000000000 + + + 3.000000000000000 + + + 0.100000000000000 + + + 1.000000000000000 + + + + + + + Yaw + + + + + + + false + + + 4 + + + 0.100000000000000 + + + 3.000000000000000 + + + 0.100000000000000 + + + 1.000000000000000 + + + + + + + Pitch + + + + + + + false + + + 4 + + + 0.100000000000000 + + + 3.000000000000000 + + + 0.100000000000000 + + + 1.000000000000000 + + + + + + + Roll + + + + + + + false + + + 4 + + + 0.100000000000000 + + + 3.000000000000000 + + + 0.100000000000000 + + + 1.000000000000000 + + + + + + + + + 50 + 270 + 321 + 71 + + + + + 0 + 0 + + + + + 9 + + + + QFrame::NoFrame + + + Accela filter by StanisÅ‚aw Halik <sthalik@misaki.pl> With kind help from Donovan Baarda. 2012-2013 - - - Qt::AutoText - - - false - - - Qt::AlignJustify|Qt::AlignTop - - - true - - - 0 - - - - - - - 3 - - - 0.100000000000000 - - - 65535.000000000000000 - - - 1.000000000000000 - - - - - - - OK - - - - - - - Translation smoothing - - - - - - - - 50 - 15 - - - - 0 - - - 200 - - - 1 - - - 100 - - - Qt::Horizontal - - - QSlider::NoTicks - - - - - - - - 35 - 22 - - - - background:none; - - - false - - - 0 - - - 200 - - - 45 - - - - - - - Rotation smoothing - - - - - - - 3 - - - 0.100000000000000 - - - 65535.000000000000000 - - - 1.000000000000000 - - - - - - - - 25 - 0 - - - - - 150 - 16777215 - - - - color:#0; + + + Qt::AutoText + + + false + + + Qt::AlignJustify|Qt::AlignTop + + + true + + + 0 + + + + + + 350 + 210 + 69 + 31 + + + + + 0 + 0 + + + + Cancel + + + + + + 260 + 210 + 91 + 31 + + + + + 0 + 0 + + + + OK + + + + + + 4 + 4 + 252 + 108 + + + + Basic settings + + + + + + + 0 + 0 + + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + QAbstractSpinBox::CorrectToPreviousValue + + + 3 + + + 0.100000000000000 + + + 65535.000000000000000 + + + 1.000000000000000 + + + + + + + Translation smoothing + + + + + + + + 35 + 22 + + + + background:none; + + + false + + + 0 + + + 200 + + + 45 + + + + + + + + 0 + 0 + + + + Rotation smoothing + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + 3 + + + 0.100000000000000 + + + 65535.000000000000000 + + + 1.000000000000000 + + + + + + + + 25 + 0 + + + + + 150 + 16777215 + + + + color:#0; background:none; - - - Zoom speed - - - - + + + Zoom speed + + + + + - - - slideZoom - valueChanged(int) - spinZoom - setValue(int) - - - 463 - 19 - - - 537 - 20 - - - - - spinZoom - valueChanged(int) - slideZoom - setValue(int) - - - 533 - 20 - - - 426 - 20 - - - - + startEngineClicked() stopEngineClicked() diff --git a/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp b/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp index 4cd45910..feff0ba9 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp @@ -47,7 +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.slideZoom, SIGNAL(valueChanged(int)), this, SLOT(settingChanged(int))); connect(ui.spinZoom, SIGNAL(valueChanged(int)), this, SLOT(settingChanged(int))); QDoubleSpinBox* boxen[] = { @@ -156,7 +155,6 @@ void FilterControls::loadSettings() { //qDebug() << "FTNoIR_Filter::loadSettings2 says: size = " << NUM_OF(defScaleRotation); iniFile.beginGroup ( "Accela" ); - ui.slideZoom->setValue(iniFile.value("zoom-slowness", ACCELA_ZOOM_SLOWNESS).toInt()); 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()); @@ -207,7 +205,6 @@ void FilterControls::save() { 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 (); -- cgit v1.2.3 From 9e2999cf9c1d42a09350d094fc83b00963f22a68 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 23 Oct 2013 09:12:53 +0200 Subject: whitespace Signed-off-by: Stanislaw Halik --- ftnoir_filter_accela/ftnoir_filter_accela.cpp | 2 -- ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp | 2 -- 2 files changed, 4 deletions(-) diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.cpp b/ftnoir_filter_accela/ftnoir_filter_accela.cpp index 25716973..abde4d46 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela.cpp @@ -85,8 +85,6 @@ void FTNoIR_Filter::FilterHeadPoseData(const double* target_camera_position, QMutexLocker foo(&mutex); - - for (int i=0;i<6;i++) { const double vec = target_camera_position[i] - current_camera_position[i]; diff --git a/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp b/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp index feff0ba9..da6c6565 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp @@ -186,8 +186,6 @@ void FilterControls::loadSettings() { } iniFile.endGroup(); - - settingsDirty = false; } -- cgit v1.2.3 From d348f86b3448d6076ab4cb405eb4bf08635545c1 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 23 Oct 2013 09:21:26 +0200 Subject: accela: relayout #2 Signed-off-by: Stanislaw Halik --- .../ftnoir_accela_filtercontrols.ui | 828 +++++++++++---------- 1 file changed, 423 insertions(+), 405 deletions(-) diff --git a/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui b/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui index bc66fdc2..63fab0a1 100644 --- a/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui +++ b/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui @@ -10,7 +10,7 @@ 0 0 450 - 350 + 225 @@ -21,8 +21,8 @@ - 450 - 350 + 458 + 225 @@ -41,425 +41,443 @@ - - - - 260 - 4 - 160 - 201 - - - - - 150 - 100 - - - - Axis speed - - - - QFormLayout::ExpandingFieldsGrow - - - 20 - - - 2 - - - 20 - - - 7 - - - 10 - - - 15 - - - - - X - - - - - - - 4 - - - 0.100000000000000 - - - 3.000000000000000 - - - 0.100000000000000 - - - 1.000000000000000 - - - - - - - Y - - - - - - - 4 - - - 0.100000000000000 - - - 3.000000000000000 - - - 0.100000000000000 - - - 1.000000000000000 - - - - - - - Z - - - - - - - 4 - - - 0.100000000000000 - - - 3.000000000000000 - - - 0.100000000000000 - - - 1.000000000000000 - - - - - - - Yaw - - - - - - - false - - - 4 - - - 0.100000000000000 - - - 3.000000000000000 - - - 0.100000000000000 - - - 1.000000000000000 - - - - - - - Pitch - - - - - - - false - - - 4 - - - 0.100000000000000 - - - 3.000000000000000 - - - 0.100000000000000 - - - 1.000000000000000 - - - - - - - Roll - - - - - - - false - - - 4 - - - 0.100000000000000 - - - 3.000000000000000 - - - 0.100000000000000 - - - 1.000000000000000 - - - - - - - - - 50 - 270 - 321 - 71 - - - - - 0 - 0 - - - - - 9 - - - - QFrame::NoFrame - - - Accela filter by StanisÅ‚aw Halik <sthalik@misaki.pl> -With kind help from Donovan Baarda. -2012-2013 - - - Qt::AutoText + + + QLayout::SetMaximumSize - - false + + 4 - - Qt::AlignJustify|Qt::AlignTop - - - true - - + 0 - - - - - 350 - 210 - 69 - 31 - - - - - 0 - 0 - - - - Cancel - - - - - - 260 - 210 - 91 - 31 - - - - - 0 - 0 - - - - OK - - - - - - 4 - 4 - 252 - 108 - - - - Basic settings - - - - - - - 0 - 0 - + + + + Basic settings + + + + QLayout::SetMaximumSize - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + 10 - - QAbstractSpinBox::CorrectToPreviousValue + + 10 - - 3 + + 10 - - 0.100000000000000 - - - 65535.000000000000000 - - - 1.000000000000000 - - - - - - - Translation smoothing - - - - - - - - 35 - 22 - - - - background:none; - - - false - - + 0 - - 200 - - - 45 - - - - - - - - 0 - 0 - - - - Rotation smoothing + + 20 - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - - - 3 - - - 0.100000000000000 - - - 65535.000000000000000 + + 0 - - 1.000000000000000 + + + + + 0 + 0 + + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + QAbstractSpinBox::CorrectToPreviousValue + + + 3 + + + 0.100000000000000 + + + 65535.000000000000000 + + + 1.000000000000000 + + + + + + + Translation smoothing + + + + + + + + 35 + 22 + + + + background:none; + + + false + + + 0 + + + 200 + + + 45 + + + + + + + + 0 + 0 + + + + Rotation smoothing + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + 3 + + + 0.100000000000000 + + + 65535.000000000000000 + + + 1.000000000000000 + + + + + + + + 25 + 0 + + + + + 150 + 16777215 + + + + color:#0; +background:none; + + + Zoom speed + + + + + + + + + + + 150 + 100 + + + + Axis speed + + + + QFormLayout::ExpandingFieldsGrow + + + 20 + + + 0 - - - - - - - 25 - 0 - + + 20 - - - 150 - 16777215 - + + 7 - - color:#0; -background:none; + + 10 - - Zoom speed + + 0 - - - - + + + + X + + + + + + + 4 + + + 0.100000000000000 + + + 3.000000000000000 + + + 0.100000000000000 + + + 1.000000000000000 + + + + + + + Y + + + + + + + 4 + + + 0.100000000000000 + + + 3.000000000000000 + + + 0.100000000000000 + + + 1.000000000000000 + + + + + + + Z + + + + + + + 4 + + + 0.100000000000000 + + + 3.000000000000000 + + + 0.100000000000000 + + + 1.000000000000000 + + + + + + + Yaw + + + + + + + false + + + 4 + + + 0.100000000000000 + + + 3.000000000000000 + + + 0.100000000000000 + + + 1.000000000000000 + + + + + + + Pitch + + + + + + + false + + + 4 + + + 0.100000000000000 + + + 3.000000000000000 + + + 0.100000000000000 + + + 1.000000000000000 + + + + + + + Roll + + + + + + + false + + + 4 + + + 0.100000000000000 + + + 3.000000000000000 + + + 0.100000000000000 + + + 1.000000000000000 + + + + + + + + + + -1 + + + QLayout::SetMaximumSize + + + 0 + + + 0 + + + + + + 0 + 0 + + + + OK + + + + + + + + 0 + 0 + + + + Cancel + + + + + + + + + + 0 + 0 + + + + + 9 + + + + QFrame::NoFrame + + + Accela filter by StanisÅ‚aw Halik +With kind help from Donovan Baarda. +2012-2013 + + + Qt::AutoText + + + false + + + Qt::AlignBottom|Qt::AlignJustify + + + true + + + 0 + + + + -- cgit v1.2.3 From e246c43fc97171d3c70310684a1335ed231ceed0 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 23 Oct 2013 12:34:45 +0200 Subject: pt fix: frame race, framerate Signed-off-by: Stanislaw Halik --- FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp index 43ecc775..b1392953 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp @@ -88,7 +88,7 @@ void Tracker::run() tracking_valid = point_tracker.track(points, camera.get_info().f, dt); frame_count++; #ifdef OPENTRACK_API - video_widget->update_image(frame); + video_widget->update_image(frame.clone()); #endif } #ifdef PT_PERF_LOG @@ -206,6 +206,7 @@ void Tracker::Initialize(QFrame *video_frame) settings.load_ini(); apply(settings); camera.start(); + apply(settings); start(); } -- cgit v1.2.3 From 866441314a5dd6294a1e396d9f24f3dfdef8f953 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 23 Oct 2013 12:34:52 +0200 Subject: fix Unix frame counter Signed-off-by: Stanislaw Halik --- FTNoIR_Tracker_PT/timer.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/FTNoIR_Tracker_PT/timer.cpp b/FTNoIR_Tracker_PT/timer.cpp index ed7606e5..a3141113 100644 --- a/FTNoIR_Tracker_PT/timer.cpp +++ b/FTNoIR_Tracker_PT/timer.cpp @@ -58,9 +58,9 @@ double Timer::elapsed() if(running) gettimeofday(&endCount, NULL); - startTime = (startCount.tv_sec * 1e3) + startCount.tv_usec; - endTime = (endCount.tv_sec * 1e3) + endCount.tv_usec; + startTime = (startCount.tv_sec) + startCount.tv_usec * 1e-6; + endTime = (endCount.tv_sec) + endCount.tv_usec * 1e-6; #endif - return endTime - startTime; + return (endTime - startTime) * 1e3; } -- cgit v1.2.3 From 8ae1e1cb8f2107945715072b19e6996749bc8652 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 23 Oct 2013 12:35:04 +0200 Subject: accela: redo the UI again Signed-off-by: Stanislaw Halik --- .../ftnoir_accela_filtercontrols.ui | 145 ++++++++++++++------- 1 file changed, 98 insertions(+), 47 deletions(-) diff --git a/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui b/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui index 63fab0a1..386d73d8 100644 --- a/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui +++ b/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui @@ -9,20 +9,26 @@ 0 0 - 450 - 225 + 410 + 300 - + 0 0 + + + 290 + 300 + + - 458 - 225 + 443 + 360 @@ -41,18 +47,24 @@ - + QLayout::SetMaximumSize - 4 + -1 0 + + + 0 + 0 + + Basic settings @@ -199,7 +211,7 @@ background:none; - + 150 100 @@ -218,7 +230,7 @@ background:none; 0 - 20 + 5 7 @@ -238,6 +250,12 @@ background:none; + + + 0 + 0 + + 4 @@ -264,6 +282,12 @@ background:none; + + + 0 + 0 + + 4 @@ -290,6 +314,12 @@ background:none; + + + 0 + 0 + + 4 @@ -316,6 +346,12 @@ background:none; + + + 0 + 0 + + false @@ -345,6 +381,12 @@ background:none; + + + 0 + 0 + + false @@ -374,6 +416,12 @@ background:none; + + + 0 + 0 + + false @@ -397,6 +445,47 @@ background:none; + + + + + 0 + 0 + + + + + 9 + + + + QFrame::NoFrame + + + Accela filter by StanisÅ‚aw Halik +With kind help from Donovan Baarda. +2012-2013 + + + Qt::PlainText + + + false + + + Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft + + + true + + + 0 + + + Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse|Qt::TextBrowserInteraction|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + @@ -439,44 +528,6 @@ background:none; - - - - - 0 - 0 - - - - - 9 - - - - QFrame::NoFrame - - - Accela filter by StanisÅ‚aw Halik -With kind help from Donovan Baarda. -2012-2013 - - - Qt::AutoText - - - false - - - Qt::AlignBottom|Qt::AlignJustify - - - true - - - 0 - - - -- 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(+) 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 9a30b3f916e302295bf8fc8df0e029855e6a4447 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 23 Oct 2013 13:10:11 +0200 Subject: accela: layouts done, sorry for commit spam Signed-off-by: Stanislaw Halik --- .../ftnoir_accela_filtercontrols.ui | 360 +++++++++++++-------- 1 file changed, 218 insertions(+), 142 deletions(-) diff --git a/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui b/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui index 386d73d8..6cf3d20b 100644 --- a/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui +++ b/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui @@ -9,26 +9,26 @@ 0 0 - 410 - 300 + 427 + 235 - + 0 0 - 290 - 300 + 248 + 235 - 443 - 360 + 428 + 235 @@ -47,7 +47,7 @@ - + QLayout::SetMaximumSize @@ -59,19 +59,25 @@ + + true + - + 0 0 + + + 0 + 0 + + Basic settings - - QLayout::SetMaximumSize - 10 @@ -82,7 +88,7 @@ 10 - 0 + 2 20 @@ -90,43 +96,30 @@ 0 - - + + - + 0 0 + + Rotation + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - QAbstractSpinBox::CorrectToPreviousValue - - - 3 - - - 0.100000000000000 - - - 65535.000000000000000 - - - 1.000000000000000 - - - - - - - Translation smoothing - + + + 0 + 0 + + 35 @@ -150,24 +143,20 @@ - - + + - + 0 0 - - Rotation smoothing - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - + + QAbstractSpinBox::CorrectToPreviousValue + 3 @@ -184,6 +173,12 @@ + + + 0 + 0 + + 25 @@ -201,19 +196,147 @@ background:none; - Zoom speed + Zoomed + + + + + + + + 0 + 0 + + + + Translation + + + + + + + + 0 + 0 + + + + 3 + + + 0.100000000000000 + + + 65535.000000000000000 + + + 1.000000000000000 + + + + -1 + + + QLayout::SetMaximumSize + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + 0 + 32 + + + + OK + + + + + + + + 0 + 0 + + + + + 0 + 32 + + + + Cancel + + + + + + + + + + 0 + 0 + + + + + 8 + + + + QFrame::NoFrame + + + <html><head/><body><p align="justify">Accela filter by StanisÅ‚aw Halik<br/>With kind help from Donovan Baarda</p><p align="right">2012-2013</p></body></html> + + + Qt::RichText + + + false + + + Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft + + + true + + + 0 + + + Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse|Qt::TextBrowserInteraction|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + - - 150 - 100 + + 0 + 0 @@ -239,10 +362,16 @@ background:none; 10 - 0 + 2 + + + 0 + 0 + + X @@ -251,7 +380,7 @@ background:none; - + 0 0 @@ -275,6 +404,12 @@ background:none; + + + 0 + 0 + + Y @@ -283,7 +418,7 @@ background:none; - + 0 0 @@ -307,6 +442,12 @@ background:none; + + + 0 + 0 + + Z @@ -315,7 +456,7 @@ background:none; - + 0 0 @@ -339,6 +480,12 @@ background:none; + + + 0 + 0 + + Yaw @@ -347,7 +494,7 @@ background:none; - + 0 0 @@ -374,6 +521,12 @@ background:none; + + + 0 + 0 + + Pitch @@ -382,7 +535,7 @@ background:none; - + 0 0 @@ -409,6 +562,12 @@ background:none; + + + 0 + 0 + + Roll @@ -417,7 +576,7 @@ background:none; - + 0 0 @@ -445,89 +604,6 @@ background:none; - - - - - 0 - 0 - - - - - 9 - - - - QFrame::NoFrame - - - Accela filter by StanisÅ‚aw Halik -With kind help from Donovan Baarda. -2012-2013 - - - Qt::PlainText - - - false - - - Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft - - - true - - - 0 - - - Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse|Qt::TextBrowserInteraction|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse - - - - - - - -1 - - - QLayout::SetMaximumSize - - - 0 - - - 0 - - - - - - 0 - 0 - - - - OK - - - - - - - - 0 - 0 - - - - Cancel - - - - - -- cgit v1.2.3 From a8da187fca48e2eacce81f920a3c6be7b3e6b84c Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 23 Oct 2013 13:10:23 +0200 Subject: use cmath instead of C header Signed-off-by: Stanislaw Halik --- ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp b/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp index da6c6565..0c04a32a 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp @@ -23,7 +23,7 @@ * * ********************************************************************************/ #include "ftnoir_filter_accela/ftnoir_filter_accela.h" -#include +#include #include #include #include @@ -38,7 +38,7 @@ FilterControls::FilterControls() : QWidget(), accela_filter(NULL) { - ui.setupUi( this ); + ui.setupUi( this ); // Load the settings from the current .INI-file loadSettings(); -- cgit v1.2.3 From 8a49b4fb4da78833e9e1d0a37132af2631924fa8 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 23 Oct 2013 13:15:28 +0200 Subject: update TODO Signed-off-by: Stanislaw Halik --- TODO.txt | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/TODO.txt b/TODO.txt index 927a5709..b81b731a 100644 --- a/TODO.txt +++ b/TODO.txt @@ -20,21 +20,9 @@ Hydra is really just a hack just now, could be improved a lot. Add per-tracker hotkey support - -20131005 sh - what do you think about boost 1.54 for property maps -> qsettings? - also, boost concepts - and qt5 -20131007 sh - respect hier(7) with regard to shared object installation. - install them inside ../lib/opentrack relative to ./bin where - the main program oughta reside. -20131008 sh - during the switch to qt5, recreate widgets, this time with layouts. - the original layouts were pretty crappy, hence the original breakage. 20131011 sh low-hanging fruit: default saving profiles to a directory in user home, not into global stuffies - as for build system, low-hangin fruit is writing functions/macrology + as for build system, low-hanging fruit is writing functions/macrology for all the repetition out there. -- cgit v1.2.3 From 8f5a5ae3420841abb46504e9ecbb909e19f770cb Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 23 Oct 2013 14:05:29 +0200 Subject: Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index b3bb2556..33423069 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,8 @@ Source code access available at **opentrack** is an application dedicated to tracking user's head movements and relaying them to games and flight simulation software. +Not to be confused with railway planning software + # Tracking sources - SeeingMachines FaceAPI (Windows) -- 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(-) 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 d1ea33dddbcceef3cb50d4e38d15fc024b6972bc Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 23 Oct 2013 16:08:38 +0200 Subject: fix Linux Rift build! Signed-off-by: Stanislaw Halik --- CMakeLists.txt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5a10f8b9..e458fab3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -492,11 +492,13 @@ endif() target_link_libraries(opentrack-tracker-rift ${MY_QT_LIBS}) if(MSVC) target_link_libraries(opentrack-tracker-rift "${SDK_RIFT}/Lib/Win32/libovr.lib" winmm.lib) - else(WIN32) - target_link_libraries(opentrack-tracker-rift "${SDK_RIFT}/LibOVR.a" winmm.lib setupapi.lib) else() - target_link_libraries(opentrack-tracker-rift "${SDK_RIFT}/LibOVR.a") - endif() + if(WIN32) + target_link_libraries(opentrack-tracker-rift "${SDK_RIFT}/LibOVR.a" winmm.lib setupapi.lib) + else() + target_link_libraries(opentrack-tracker-rift "${SDK_RIFT}/LibOVR.a" udev Xinerama) + endif() + endif() if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) SET_TARGET_PROPERTIES(opentrack-tracker-rift PROPERTIES -- cgit v1.2.3 From a524644f99ab28c5e98bca0fa2210dfd3fa124ef Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 23 Oct 2013 16:25:47 +0200 Subject: small optimization Signed-off-by: Stanislaw Halik --- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index 099c1f85..4daffe5e 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -193,7 +193,7 @@ void Tracker::run() color_.copyTo(color); cv::cvtColor(color, grayscale2, cv::COLOR_BGR2GRAY); const int kernel = grayscale2.cols > 480 ? 7 : 5; - int kernel2 = kernel * grayscale2.rows / grayscale2.cols; + int kernel2 = kernel * grayscale2.rows / grayscale2.cols - 1; if ((kernel2 % 2) == 0) kernel2++; cv::GaussianBlur(grayscale2, grayscale, cv::Size(kernel, kernel2), 0, 0); -- cgit v1.2.3 From 0b2b8207b6ac55789ac6c402986870aaa7a6841d Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 23 Oct 2013 16:25:50 +0200 Subject: add todo --- TODO.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/TODO.txt b/TODO.txt index b81b731a..c5fbf58d 100644 --- a/TODO.txt +++ b/TODO.txt @@ -1,3 +1,6 @@ +20131023 sh + Low-hanging fruit: Go through all forms and replace ok/cancel with + QButtonBox which works better with layouts. 20131020 sh Add unit testing by means of batch execution, protocol/filter that does nothing, add separate executables for readers of specific protocols, -- cgit v1.2.3 From 4907f040892b798ab973de542cf7465d48c6e5d8 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 23 Oct 2013 16:26:01 +0200 Subject: fix layout (again, sorry) Signed-off-by: Stanislaw Halik --- .../ftnoir_accela_filtercontrols.ui | 287 +++++++++------------ .../ftnoir_filter_accela_dialog.cpp | 4 +- 2 files changed, 125 insertions(+), 166 deletions(-) diff --git a/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui b/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui index 6cf3d20b..098213ef 100644 --- a/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui +++ b/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui @@ -9,8 +9,8 @@ 0 0 - 427 - 235 + 459 + 207 @@ -21,14 +21,14 @@ - 248 - 235 + 0 + 0 - 428 - 235 + 459 + 207 @@ -47,23 +47,14 @@ - - - QLayout::SetMaximumSize - - - -1 - - - 0 - + true - + 0 0 @@ -77,29 +68,32 @@ Basic settings - - - 10 + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + QFormLayout::ExpandingFieldsGrow - - 10 + + QFormLayout::DontWrapRows - - 10 + + Qt::AlignRight|Qt::AlignTop|Qt::AlignTrailing - - 2 + + Qt::AlignRight|Qt::AlignTop|Qt::AlignTrailing - 20 + 6 - 0 + 2 - + - + 0 0 @@ -112,50 +106,57 @@ - - + + - + 0 0 - - - 35 - 22 - + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - background:none; + + QAbstractSpinBox::CorrectToPreviousValue - - false + + 3 - 0 + 0.100000000000000 - 200 + 65535.000000000000000 - 45 + 1.000000000000000 - - + + - + 0 0 - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + Translation - - QAbstractSpinBox::CorrectToPreviousValue + + + + + + + 0 + 0 + + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter 3 @@ -174,7 +175,7 @@ - + 0 0 @@ -200,141 +201,92 @@ background:none; - - + + - + 0 0 - - Translation + + + 96 + 22 + + + + background:none; + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + false + + + % + + + 0 + + + 200 + + + 1 + + + 45 - - + + - + 0 0 - - 3 + + + 8 + - - 0.100000000000000 + + QFrame::NoFrame - - 65535.000000000000000 + + <html><head/><body><p align="justify">Accela filter by StanisÅ‚aw Halik<br/>With kind help from Donovan Baarda</p><p align="right">2012-2013</p></body></html> - - 1.000000000000000 + + Qt::RichText + + + false + + + Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft + + + true + + + 0 + + + Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse|Qt::TextBrowserInteraction|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse - - - - -1 - - - QLayout::SetMaximumSize - - - 0 - - - 0 - - - - - - 0 - 0 - - - - - 0 - 32 - - - - OK - - - - - - - - 0 - 0 - - - - - 0 - 32 - - - - Cancel - - - - - - - - - - 0 - 0 - - - - - 8 - - - - QFrame::NoFrame - - - <html><head/><body><p align="justify">Accela filter by StanisÅ‚aw Halik<br/>With kind help from Donovan Baarda</p><p align="right">2012-2013</p></body></html> - - - Qt::RichText - - - false - - - Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft - - - true - - - 0 - - - Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse|Qt::TextBrowserInteraction|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse - - - - + 0 0 @@ -356,7 +308,7 @@ background:none; 5 - 7 + 0 10 @@ -604,6 +556,13 @@ background:none; + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + diff --git a/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp b/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp index 0c04a32a..b0999070 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp @@ -42,8 +42,8 @@ FilterControls::FilterControls() : // 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.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); + connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); connect(ui.rotation_alpha, SIGNAL(valueChanged(double)), this, SLOT(settingChanged(double))); connect(ui.translation_alpha, SIGNAL(valueChanged(double)), this, SLOT(settingChanged(double))); -- cgit v1.2.3 From 8857523fada67140e1a07cabb1b7c8b48200a753 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 23 Oct 2013 17:36:01 +0200 Subject: Hopefully include PDBs now --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e458fab3..2f8daadb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -730,7 +730,7 @@ if(SDK_SM_FACEAPI_PATH AND NOT SDK_FACEAPI_ONLY) endif() if(MSVC) - file(GLOB pdbs "${CMAKE_BINARY_DIR}/*.pdb" "${CMAKE_BINARY_DIR}/release/*.pdb") + file(GLOB pdbs "${CMAKE_BINARY_DIR}/Release/*.pdb") install(FILES ${pdbs} DESTINATION .) endif() -- 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(-) 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 82d38a7ed6f1238909c6a493b002a9d4cafe548d Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 23 Oct 2013 19:11:32 +0200 Subject: cmake: only include breakpad for release MSVC builds The build system isn't yet ready to accomodate mingw breakpad Signed-off-by: Stanislaw Halik --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cffe88cd..d374f0ae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,11 +25,11 @@ if(CMAKE_COMPILER_IS_GNUCXX) add_definitions(-std=c++11) endif() -if(WIN32) +if(WIN32 AND MSVC) set(SDK_GOOGLE_BREAKPAD "" CACHE PATH "google-breakpad for crash reporting") endif() -if(SDK_GOOGLE_BREAKPAD) +if(SDK_GOOGLE_BREAKPAD AND MSVC) add_definitions(-DOPENTRACK_BREAKPAD) include_directories("${SDK_GOOGLE_BREAKPAD}/src/client/windows/handler") include_directories("${SDK_GOOGLE_BREAKPAD}/src/") -- 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 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(-) 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(-) 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(-) 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 -- cgit v1.2.3 From 772bffe82e365d6466e41ed88626b9a5ab3e3d9e Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 24 Oct 2013 14:29:54 +0200 Subject: add 3rdparty notices to be clear with copyright Signed-off-by: Stanislaw Halik --- 3rdparty-notices/GOOGLE-BREAKPAD-COPYING.txt | 29 ++++++++++++++++++++++ 3rdparty-notices/OPENCV-COPYING.txt | 37 ++++++++++++++++++++++++++++ CMakeLists.txt | 1 + 3 files changed, 67 insertions(+) create mode 100644 3rdparty-notices/GOOGLE-BREAKPAD-COPYING.txt create mode 100644 3rdparty-notices/OPENCV-COPYING.txt diff --git a/3rdparty-notices/GOOGLE-BREAKPAD-COPYING.txt b/3rdparty-notices/GOOGLE-BREAKPAD-COPYING.txt new file mode 100644 index 00000000..80f54ae2 --- /dev/null +++ b/3rdparty-notices/GOOGLE-BREAKPAD-COPYING.txt @@ -0,0 +1,29 @@ +Copyright (c) 2006, Google Inc. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + diff --git a/3rdparty-notices/OPENCV-COPYING.txt b/3rdparty-notices/OPENCV-COPYING.txt new file mode 100644 index 00000000..8824228d --- /dev/null +++ b/3rdparty-notices/OPENCV-COPYING.txt @@ -0,0 +1,37 @@ +IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. + + By downloading, copying, installing or using the software you agree to this license. + If you do not agree to this license, do not download, install, + copy or use the software. + + + License Agreement + For Open Source Computer Vision Library + +Copyright (C) 2000-2008, Intel Corporation, all rights reserved. +Copyright (C) 2008-2011, Willow Garage Inc., all rights reserved. +Third party copyrights are property of their respective owners. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + * The name of the copyright holders may not be used to endorse or promote products + derived from this software without specific prior written permission. + +This software is provided by the copyright holders and contributors "as is" and +any express or implied warranties, including, but not limited to, the implied +warranties of merchantability and fitness for a particular purpose are disclaimed. +In no event shall the Intel Corporation or contributors be liable for any direct, +indirect, incidental, special, exemplary, or consequential damages +(including, but not limited to, procurement of substitute goods or services; +loss of use, data, or profits; or business interruption) however caused +and on any theory of liability, whether in contract, strict liability, +or tort (including negligence or otherwise) arising in any way out of +the use of this software, even if advised of the possibility of such damage. diff --git a/CMakeLists.txt b/CMakeLists.txt index 7a1cb8b6..93a43dae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -633,6 +633,7 @@ if(NOT SDK_FACEAPI_ONLY) install(DIRECTORY "${CMAKE_SOURCE_DIR}/bin/tracker-ht" DESTINATION .) install(TARGETS freetrackclient RUNTIME DESTINATION .) endif() + install(DIRECTORY "${CMAKE_SOURCE_DIR}/3rdparty-notices" DESTINATION .) install(FILES "${CMAKE_SOURCE_DIR}/bin/NPClient.dll" "${CMAKE_SOURCE_DIR}/bin/NPClient64.dll" "${CMAKE_SOURCE_DIR}/bin/TrackIR.exe" DESTINATION .) install(DIRECTORY "${CMAKE_SOURCE_DIR}/bin/settings" "${CMAKE_SOURCE_DIR}/facetracknoir/clientfiles" DESTINATION .) -- cgit v1.2.3 From 56b573ef018871bec00da1d412c8f53b68b7557c Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 24 Oct 2013 14:32:56 +0200 Subject: readme: minor formatting nit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 33423069..e6215546 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Source code access available at **opentrack** is an application dedicated to tracking user's head movements and relaying them to games and flight simulation software. -Not to be confused with railway planning software +Not to be confused with railway planning software <> # Tracking sources -- cgit v1.2.3 From 47c96c59b1eb0e7b54ff9e1e53fc9b14365cf314 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 24 Oct 2013 14:35:27 +0200 Subject: Add Qt5 LGPL license in all its bloater glory Signed-off-by: Stanislaw Halik --- 3rdparty-notices/QT5-COPYING.txt | 514 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 514 insertions(+) create mode 100644 3rdparty-notices/QT5-COPYING.txt diff --git a/3rdparty-notices/QT5-COPYING.txt b/3rdparty-notices/QT5-COPYING.txt new file mode 100644 index 00000000..b2e7909d --- /dev/null +++ b/3rdparty-notices/QT5-COPYING.txt @@ -0,0 +1,514 @@ + GNU LESSER GENERAL PUBLIC LICENSE + + The Qt Toolkit is Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). + Contact: http://www.qt-project.org/legal + + You may use, distribute and copy the Qt GUI Toolkit under the terms of + GNU Lesser General Public License version 2.1, which is displayed below. + +------------------------------------------------------------------------- + + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! + + -- cgit v1.2.3 From d71edf94b306ffa320d48b09c834133fe1cfe9c9 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 24 Oct 2013 14:37:28 +0200 Subject: add ARUCO copying Signed-off-by: Stanislaw Halik --- 3rdparty-notices/ARUCO-COPYING.txt | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 3rdparty-notices/ARUCO-COPYING.txt diff --git a/3rdparty-notices/ARUCO-COPYING.txt b/3rdparty-notices/ARUCO-COPYING.txt new file mode 100644 index 00000000..24e57080 --- /dev/null +++ b/3rdparty-notices/ARUCO-COPYING.txt @@ -0,0 +1,35 @@ +The ARUCO Library has been developed by the Ava group of the Univeristy of Cordoba(Spain) +Contact to Rafael Muñoz Salinas + +----------------------------------------------------------------------- + +Copyright 2011 Rafael Muñoz Salinas. All rights reserved. + + +Redistribution and use in source and binary forms, with or without modification, are +permitted provided that the following conditions are met: + + + 1. Redistributions of source code must retain the above copyright notice, this list of + conditions and the following disclaimer. + + + 2. Redistributions in binary form must reproduce the above copyright notice, this list + of conditions and the following disclaimer in the documentation and/or other materials + provided with the distribution. + + +THIS SOFTWARE IS PROVIDED BY Rafael Muñoz Salinas ''AS IS'' AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Rafael Muñoz Salinas OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +The views and conclusions contained in the software and documentation are those of the +authors and should not be interpreted as representing official policies, either expressed +or implied, of Rafael Muñoz Salinas. -- cgit v1.2.3 From 5ab058493a1b38b6406d2bf449598ebcb2902254 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 24 Oct 2013 14:38:59 +0200 Subject: add faceapi license Signed-off-by: Stanislaw Halik --- 3rdparty-notices/SM-FACEAPI-COPYING.txt | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 3rdparty-notices/SM-FACEAPI-COPYING.txt diff --git a/3rdparty-notices/SM-FACEAPI-COPYING.txt b/3rdparty-notices/SM-FACEAPI-COPYING.txt new file mode 100644 index 00000000..b317bb76 --- /dev/null +++ b/3rdparty-notices/SM-FACEAPI-COPYING.txt @@ -0,0 +1,9 @@ +-------------------------------------------------------------------------------- +FaceTrackingAPI Version 3.2.6 - August 2010 +Copyright (C) 2010 Seeing Machines Limited +-------------------------------------------------------------------------------- + +The use of this API is strictly governed by the terms of a mandatory +prior license agreement between the user and Seeing Machines Ltd. + +-------------------------------------------------------------------------------- \ No newline at end of file -- cgit v1.2.3 From aafe7673bd29cf0bf82ddc4b5c51e8eaa02d7abd Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 24 Oct 2013 14:43:04 +0200 Subject: libovr license Signed-off-by: Stanislaw Halik --- 3rdparty-notices/LIBOVR-COPYING.txt | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 3rdparty-notices/LIBOVR-COPYING.txt diff --git a/3rdparty-notices/LIBOVR-COPYING.txt b/3rdparty-notices/LIBOVR-COPYING.txt new file mode 100644 index 00000000..e23c0490 --- /dev/null +++ b/3rdparty-notices/LIBOVR-COPYING.txt @@ -0,0 +1,5 @@ +Copyright : Copyright 2012 Oculus VR, Inc. All Rights reserved. + +Use of this software is subject to the terms of the Oculus license +agreement provided at the time of installation or download, or which +otherwise accompanies this software in either electronic or hard copy form. \ No newline at end of file -- cgit v1.2.3 From 84c990a768bb144d58ecf299de7e085a27ffef40 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 24 Oct 2013 14:43:21 +0200 Subject: facetracknoir copying Signed-off-by: Stanislaw Halik --- 3rdparty-notices/FACETRACKNOIR-COPYING.txt | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 3rdparty-notices/FACETRACKNOIR-COPYING.txt diff --git a/3rdparty-notices/FACETRACKNOIR-COPYING.txt b/3rdparty-notices/FACETRACKNOIR-COPYING.txt new file mode 100644 index 00000000..ab583e2a --- /dev/null +++ b/3rdparty-notices/FACETRACKNOIR-COPYING.txt @@ -0,0 +1,23 @@ +******************************************************************************** +* 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 . * +********************************************************************************* \ No newline at end of file -- cgit v1.2.3 From 19eab3db0359963acf734bd6bfee1213e40f1171 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 24 Oct 2013 14:46:07 +0200 Subject: :retab ftnoir-copying.txt --- 3rdparty-notices/FACETRACKNOIR-COPYING.txt | 44 +++++++++++++++--------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/3rdparty-notices/FACETRACKNOIR-COPYING.txt b/3rdparty-notices/FACETRACKNOIR-COPYING.txt index ab583e2a..befeafb5 100644 --- a/3rdparty-notices/FACETRACKNOIR-COPYING.txt +++ b/3rdparty-notices/FACETRACKNOIR-COPYING.txt @@ -1,23 +1,23 @@ ******************************************************************************** -* 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 . * -********************************************************************************* \ No newline at end of file +* 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 . * +********************************************************************************* -- cgit v1.2.3 From 25e19a66f165835816034d61e98801312b91a4a3 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 24 Oct 2013 15:37:18 +0200 Subject: rift: fix crash with no device Signed-off-by: Stanislaw Halik --- ftnoir_tracker_rift/ftnoir_tracker_rift.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp b/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp index 7fade51c..965e849b 100644 --- a/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp +++ b/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp @@ -25,10 +25,14 @@ Rift_Tracker::Rift_Tracker() Rift_Tracker::~Rift_Tracker() { - pSensor->Release(); - delete pSFusion; - pHMD->Release(); - pManager->Release(); + if (pSensor) + pSensor->Release(); + if (pSFusion) + delete pSFusion; + if (pHMD) + pHMD->Release(); + if (pManager) + pManager->Release(); System::Destroy(); } @@ -36,7 +40,6 @@ Rift_Tracker::~Rift_Tracker() void Rift_Tracker::StartTracker(QFrame* videoFrame) { - loadSettings(); // // Startup the Oculus SDK device handling, use the first Rift sensor we find. -- cgit v1.2.3 From a9c96301d3772a78d69a17cd21ef6d40dad72770 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 24 Oct 2013 15:37:27 +0200 Subject: rift-ui: add layout Signed-off-by: Stanislaw Halik --- ftnoir_tracker_rift/ftnoir_rift_clientcontrols.ui | 325 +++++++++------------ ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp | 4 +- 2 files changed, 135 insertions(+), 194 deletions(-) diff --git a/ftnoir_tracker_rift/ftnoir_rift_clientcontrols.ui b/ftnoir_tracker_rift/ftnoir_rift_clientcontrols.ui index 612c61f1..9c3ec53a 100644 --- a/ftnoir_tracker_rift/ftnoir_rift_clientcontrols.ui +++ b/ftnoir_tracker_rift/ftnoir_rift_clientcontrols.ui @@ -9,7 +9,7 @@ 0 0 - 411 + 176 145 @@ -26,213 +26,154 @@ false - - + + + + + 0 + 0 + + 0 - 85 + 0 Enable Axis - - - - 10 - 20 - 143 - 60 - - - - - - - Pitch: - - - - - - - - 20 - 16777215 - - - - Qt::LeftToRight - - - - - - - - - - - - - Yaw: - - - - - - - - 20 - 16777215 - - - - Qt::LeftToRight - - - - - - - - - - Roll: - - - - - - - - 20 - 16777215 - - - - Qt::LeftToRight - - - - - - - - + + false + + + + + + + 0 + 0 + + + + Pitch: + + + + + + + + 0 + 0 + + + + + 20 + 16777215 + + + + Qt::LeftToRight + + + + + + + + + + + + + + 0 + 0 + + + + Yaw: + + + + + + + + 0 + 0 + + + + + 20 + 16777215 + + + + Qt::LeftToRight + + + + + + + + + + + 0 + 0 + + + + Roll: + + + + + + + + 0 + 0 + + + + + 20 + 16777215 + + + + Qt::LeftToRight + + + + + + + - - - - Qt::Vertical + + + + + 0 + 0 + - - - 20 - 40 - + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - QLayout::SetDefaultConstraint - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - OK - - - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - Cancel - - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 10 - 20 - - - - - + - - btnOK - btnCancel - diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp b/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp index 26fbbc9f..90d4cb68 100644 --- a/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp +++ b/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp @@ -38,8 +38,8 @@ 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.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); + connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); connect(ui.chkEnableRoll, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); connect(ui.chkEnablePitch, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); -- cgit v1.2.3 From 2323153f0eba6c1079ce91669468cc44c157a484 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 24 Oct 2013 15:37:38 +0200 Subject: aruco-ui: add layout Signed-off-by: Stanislaw Halik --- .../ftnoir_accela_filtercontrols.ui | 108 +-- ftnoir_tracker_aruco/aruco-trackercontrols.ui | 795 +++++++++------------ ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 6 +- 3 files changed, 414 insertions(+), 495 deletions(-) diff --git a/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui b/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui index 098213ef..324acdf9 100644 --- a/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui +++ b/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui @@ -9,8 +9,8 @@ 0 0 - 459 - 207 + 347 + 268 @@ -27,8 +27,8 @@ - 459 - 207 + 6667 + 6666 @@ -48,13 +48,25 @@ + + QFormLayout::ExpandingFieldsGrow + + + 4 + + + 4 + + + 6 + true - + 0 0 @@ -241,45 +253,6 @@ background:none; - - - - - 0 - 0 - - - - - 8 - - - - QFrame::NoFrame - - - <html><head/><body><p align="justify">Accela filter by StanisÅ‚aw Halik<br/>With kind help from Donovan Baarda</p><p align="right">2012-2013</p></body></html> - - - Qt::RichText - - - false - - - Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft - - - true - - - 0 - - - Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse|Qt::TextBrowserInteraction|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse - - - @@ -556,7 +529,52 @@ background:none; - + + + + + 0 + 0 + + + + + 7 + + + + QFrame::NoFrame + + + <html><head/><body><p align="justify">Accela by <a href="https://github.com/sthalik"><span style=" text-decoration: underline; color:#0057ae;">StanisÅ‚aw Halik</span></a><br/>Help from <a href="https://github.com/dbaarda"><span style=" text-decoration: underline; color:#0057ae;">Donovan Baarda</span></a></p><p align="justify">2012-2013</p></body></html> + + + Qt::RichText + + + false + + + Qt::AlignCenter + + + true + + + 0 + + + 0 + + + true + + + Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse|Qt::TextBrowserInteraction|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok diff --git a/ftnoir_tracker_aruco/aruco-trackercontrols.ui b/ftnoir_tracker_aruco/aruco-trackercontrols.ui index 4fe97e51..c007e93b 100644 --- a/ftnoir_tracker_aruco/aruco-trackercontrols.ui +++ b/ftnoir_tracker_aruco/aruco-trackercontrols.ui @@ -9,8 +9,8 @@ 0 0 - 593 - 280 + 704 + 273 @@ -21,465 +21,364 @@ - 750 - 280 + 6666 + 6666 HT tracker settings - - - - 10 - 10 - 141 - 16 - - - - Horizontal FOV - - - - - - 130 - 10 - 251 - 22 - - - - - - - 35.000000000000000 - - - 180.000000000000000 - - - 52.000000000000000 - - - - - - 10 - 40 - 137 - 16 - - - - Frames per second - - - - - - 130 - 40 - 251 - 22 - - - - - Default - + + + -1 + + + + + Distortion coefficients + + - - - 30 - + + + + + 0 + 0 + + + + true + + + QAbstractSpinBox::NoButtons + + + 11 + + + -1000.000000000000000 + + + 1000.000000000000000 + + + 0.000000000000000 + + - - - 60 - + + + + + 0 + 0 + + + + true + + + QAbstractSpinBox::NoButtons + + + 11 + + + -1000.000000000000000 + + + 1000.000000000000000 + + + 0.000000000000000 + + - - - 120 - + + + + + 0 + 0 + + + + true + + + QAbstractSpinBox::NoButtons + + + 11 + + + -1000.000000000000000 + + + 1000.000000000000000 + + + 0.000000000000000 + + - - - - - 10 - 70 - 133 - 16 - - - - Camera name - - - - - - 430 - 250 - 75 - 23 - - - - OK - - - - - - 510 - 250 - 75 - 23 - - - - Cancel - - - - - - 390 - 10 - 101 - 81 - - - - Enable axes - - - - - 10 - 20 - 70 - 17 - - - - RX - - - - - - 10 - 40 - 70 - 17 - - - - RY - - - - - - 10 - 60 - 70 - 17 - - - - RZ - - - - - - 60 - 20 - 70 - 17 - - - - TX - - - - - - 60 - 40 - 70 - 17 - - - - TY - - - - - - 60 - 60 - 70 - 17 - - - - TZ - - - - - - - 130 - 70 - 251 - 22 - - - - - - - 10 - 100 - 128 - 16 - - - - Resolution - - - - - - 130 - 100 - 251 - 22 - - - - - 640x480 - + + + + + 0 + 0 + + + + true + + + QAbstractSpinBox::NoButtons + + + 11 + + + -1000.000000000000000 + + + 1000.000000000000000 + + + 0.000000000000000 + + - - - 320x240 - + + + + + 0 + 0 + + + + true + + + QAbstractSpinBox::NoButtons + + + 11 + + + -1000.000000000000000 + + + 1000.000000000000000 + + + 0.000000000000000 + + - - - 320x200 - + + + + + 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 (not recommended!) - + + + + + Default + + + + + 30 + + + + + 60 + + + + + 120 + + + - - - - - 130 - 130 - 171 - 22 - - - - true - - - QAbstractSpinBox::NoButtons - - - 24 - - - -1000.000000000000000 - - - 1000.000000000000000 - - - 0.000000000000000 - - - - - - 10 - 130 - 111 - 16 - - - - Distortion coefficients - - - - - - 130 - 160 - 171 - 22 - - - - true - - - QAbstractSpinBox::NoButtons - - - 24 - - - -1000.000000000000000 - - - 1000.000000000000000 - - - 0.000000000000000 - - - - - - 130 - 190 - 171 - 22 - - - - true - - - QAbstractSpinBox::NoButtons - - - 24 - - - -1000.000000000000000 - - - 1000.000000000000000 - - - 0.000000000000000 - - - - - - 130 - 220 - 171 - 22 - - - - true - - - QAbstractSpinBox::NoButtons - - - 24 - - - -1000.000000000000000 - - - 1000.000000000000000 - - - 0.000000000000000 - - - - - - 130 - 250 - 171 - 22 - - - - true - - - QAbstractSpinBox::NoButtons - - - 24 - - - -1000.000000000000000 - - - 1000.000000000000000 - - - 0.000000000000000 - - - - - - 325 - 133 - 253 - 60 - - - - The ARUCO Library has been developed by -the Ava group of the Univeristy of Cordoba(Spain) -Contact to -Rafael Muñoz Salinas <rmsalinas@uco.es> - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - - 327 - 200 - 255 - 20 - - - - https://github.com/rmsalinas/aruco - - - Qt::AlignCenter - - - true - - + + + + 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 + + + + + + + diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index 4daffe5e..25273f35 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -363,9 +363,11 @@ TrackerControls::TrackerControls() 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.buttonCancel, SIGNAL(clicked()), this, SLOT(doCancel())); - connect(ui.buttonOK, SIGNAL(clicked()), this, SLOT(doOK())); + //connect(ui.buttonCancel, SIGNAL(clicked()), this, SLOT(doCancel())); + //connect(ui.buttonOK, SIGNAL(clicked()), this, SLOT(doOK())); //connect(ui.buttonSettings, SIGNAL(clicked()), this, SLOT(cameraSettings())); + connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); + connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); loadSettings(); settingsDirty = false; } -- cgit v1.2.3 From 50899703dd0fb81231114c98deb387471ca92264 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 24 Oct 2013 15:47:19 +0200 Subject: sm: add layout Signed-off-by: Stanislaw Halik --- ftnoir_tracker_sm/ftnoir_sm_controls.ui | 518 +++++++++++--------------------- 1 file changed, 178 insertions(+), 340 deletions(-) diff --git a/ftnoir_tracker_sm/ftnoir_sm_controls.ui b/ftnoir_tracker_sm/ftnoir_sm_controls.ui index 7d69059b..2be55a91 100644 --- a/ftnoir_tracker_sm/ftnoir_sm_controls.ui +++ b/ftnoir_tracker_sm/ftnoir_sm_controls.ui @@ -9,8 +9,8 @@ 0 0 - 399 - 313 + 252 + 222 @@ -26,272 +26,9 @@ false - - - - - - - - 100 - 0 - - - - wait... - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Camera - - - - - - - Start - - - - - - - Stop - - - - - - - Engine state: - - - - - - - Internal filtering: - - - - - - - - - - - - - 0 - 140 - - - - Enable Axis - - - - - 10 - 20 - 55 - 122 - - - - - - - Roll: - - - - - - - Pitch: - - - - - - - Yaw: - - - - - - - - 20 - 16777215 - - - - Qt::LeftToRight - - - - - - - - - - - - - X: - - - - - - - Y: - - - - - - - Z: - - - - - - - - 20 - 16777215 - - - - Qt::LeftToRight - - - - - - - - - - - 20 - 16777215 - - - - Qt::LeftToRight - - - - - - - - - - - 20 - 16777215 - - - - Qt::LeftToRight - - - - - - - - - - - 20 - 16777215 - - - - Qt::LeftToRight - - - - - - - - - - - 20 - 16777215 - - - - Qt::LeftToRight - - - - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - + + - - - - Qt::Horizontal - - - - 40 - 20 - - - - @@ -318,86 +55,187 @@ - - - QLayout::SetDefaultConstraint - - - - - - 0 - 0 - - - - - 70 - 0 - - - - - 100 - 16777215 - - - - OK - - - - - - - - 0 - 0 - - - - - 70 - 0 - - - - - 100 - 16777215 - - - - Cancel - - - - - - - - - Qt::Horizontal + + + + 0 + 0 + - - QSizePolicy::Fixed + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - 10 - 20 - - - + + + + + + 0 + 0 + + + + + 0 + 140 + + + + Enable Axis + + + + QLayout::SetMinAndMaxSize + + + + + Roll: + + + + + + + + 20 + 16777215 + + + + Qt::LeftToRight + + + + + + + + + + + + + Pitch: + + + + + + + + 20 + 16777215 + + + + Qt::LeftToRight + + + + + + + + + + Yaw: + + + + + + + + 20 + 16777215 + + + + Qt::LeftToRight + + + + + + + + + + X: + + + + + + + + 20 + 16777215 + + + + Qt::LeftToRight + + + + + + + + + + Y: + + + + + + + + 20 + 16777215 + + + + Qt::LeftToRight + + + + + + + + + + Z: + + + + + + + + 20 + 16777215 + + + + Qt::LeftToRight + + + + + + + + + - - btnOK - btnCancel - -- cgit v1.2.3 From 296d8d26bc918a0ed96aa6b1b9a8ec1920c72636 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 24 Oct 2013 15:47:29 +0200 Subject: SM FaceAPI: add deprecation Signed-off-by: Stanislaw Halik --- ftnoir_tracker_sm/ftnoir_tracker_faceapi.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ftnoir_tracker_sm/ftnoir_tracker_faceapi.cpp b/ftnoir_tracker_sm/ftnoir_tracker_faceapi.cpp index af37d925..7fdb8229 100644 --- a/ftnoir_tracker_sm/ftnoir_tracker_faceapi.cpp +++ b/ftnoir_tracker_sm/ftnoir_tracker_faceapi.cpp @@ -24,6 +24,7 @@ ********************************************************************************/ #include "ftnoir_tracker_sm.h" #include +#include #include "facetracknoir/global-settings.h" FTNoIR_Tracker::FTNoIR_Tracker() : lck_shm(SM_MM_DATA, SM_MUTEX, sizeof(SMMemMap)) @@ -46,6 +47,11 @@ FTNoIR_Tracker::~FTNoIR_Tracker() void FTNoIR_Tracker::StartTracker(QFrame *videoframe ) { qDebug() << "FTNoIR_Tracker::Initialize says: Starting "; + QMessageBox::warning(this, + "Tracker deprecation", + "Non-free SM FaceAPI is deprecated, hence this annoying message.\n" + "It'll be removed for 2.0-final.", + QMessageBox::Ok, QMessageBox::NoButton); loadSettings(); -- cgit v1.2.3 From 485bdbf7868d93dea403a583b64c6fc0055b0af5 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 24 Oct 2013 15:54:20 +0200 Subject: sm: fix build hopefully, more to follow Signed-off-by: Stanislaw Halik --- ftnoir_tracker_sm/ftnoir_sm_controls.ui | 78 +++++++--------------- .../ftnoir_tracker_faceapi_dialog.cpp | 30 ++------- ftnoir_tracker_sm/ftnoir_tracker_sm.h | 2 - 3 files changed, 27 insertions(+), 83 deletions(-) diff --git a/ftnoir_tracker_sm/ftnoir_sm_controls.ui b/ftnoir_tracker_sm/ftnoir_sm_controls.ui index 2be55a91..732f0598 100644 --- a/ftnoir_tracker_sm/ftnoir_sm_controls.ui +++ b/ftnoir_tracker_sm/ftnoir_sm_controls.ui @@ -9,8 +9,8 @@ 0 0 - 252 - 222 + 172 + 220 @@ -26,50 +26,8 @@ false - - - - - - - - 0 - 0 - - - - - 70 - 0 - - - - - 100 - 16777215 - - - - Save - - - - - - - - 0 - 0 - - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - + + @@ -77,18 +35,15 @@ 0 - - - 0 - 140 - - - Enable Axis + Axis enablement - - QLayout::SetMinAndMaxSize + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop @@ -234,6 +189,19 @@ + + + + + 0 + 0 + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + diff --git a/ftnoir_tracker_sm/ftnoir_tracker_faceapi_dialog.cpp b/ftnoir_tracker_sm/ftnoir_tracker_faceapi_dialog.cpp index 8c3cd922..d8f90e62 100644 --- a/ftnoir_tracker_sm/ftnoir_tracker_faceapi_dialog.cpp +++ b/ftnoir_tracker_sm/ftnoir_tracker_faceapi_dialog.cpp @@ -44,24 +44,13 @@ TrackerControls::TrackerControls() : 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())); + //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.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); + connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); connect(ui.chkEnableRoll, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); connect(ui.chkEnablePitch, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); @@ -201,17 +190,6 @@ void TrackerControls::save() { 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. // diff --git a/ftnoir_tracker_sm/ftnoir_tracker_sm.h b/ftnoir_tracker_sm/ftnoir_tracker_sm.h index 49ae7ff5..615d9d1b 100644 --- a/ftnoir_tracker_sm/ftnoir_tracker_sm.h +++ b/ftnoir_tracker_sm/ftnoir_tracker_sm.h @@ -98,8 +98,6 @@ private: SMMemMap *pMemData; smEngineHandle *engine_handle; - QTimer *timUpdateSettings; // Timer to display current settings - FTNoIR_Tracker *theTracker; PortableLockedShm shm; -- cgit v1.2.3 From b9126a18d673dd51bc3bcce8dc97973bddacfc45 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 24 Oct 2013 15:57:51 +0200 Subject: ft proto: fun with layouts Signed-off-by: Stanislaw Halik --- ftnoir_protocol_ft/ftnoir_ftcontrols.ui | 457 +++++++++-------------- ftnoir_protocol_ft/ftnoir_protocol_ft_dialog.cpp | 4 +- 2 files changed, 176 insertions(+), 285 deletions(-) diff --git a/ftnoir_protocol_ft/ftnoir_ftcontrols.ui b/ftnoir_protocol_ft/ftnoir_ftcontrols.ui index 1b78efab..f4d94ee8 100644 --- a/ftnoir_protocol_ft/ftnoir_ftcontrols.ui +++ b/ftnoir_protocol_ft/ftnoir_ftcontrols.ui @@ -12,8 +12,8 @@ 0 0 - 412 - 328 + 407 + 347 @@ -41,287 +41,178 @@ false - - - true - - - - 320 - 300 - 80 - 23 - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 100 - 16777215 - - - - Cancel - - - - - true - - - - 230 - 300 - 80 - 23 - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 100 - 16777215 - - - - OK - - - - - - 10 - 6 - 401 - 70 - - - - - 0 - 70 - - - - TIRViews - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - 30 - 40 - 78 - 19 - - - - Qt::RightToLeft - - - TRViews - - - - - - 120 - 30 - 281 - 41 - - - - Only for very old and buggy old games such as CFS3. - - - false - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - true - - - - - - - 10 - 68 - 401 - 70 - - - - - 0 - 70 - - - - TrackIR.exe - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - 8 - 30 - 100 - 19 - - - - Qt::RightToLeft - - - Using EZCA - - - - - - 120 - 23 - 250 - 51 - - - - Spawn a useless "dummy" process called TrackIR.exe in order to fool EZCA. - - - true - - - - - - - 10 - 144 - 401 - 70 - - - - - 0 - 70 - - - - Select interface - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - 120 - 23 - 275 - 41 - - - - Disable one of the protocols if games are confused by presence of both at the same time. - - - true - - - - - - 10 - 30 - 95 - 23 - - - - - - - - 10 - 220 - 401 - 70 - - - - - 0 - 70 - - - - Repair NPClient location - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - 120 - 23 - 278 - 51 - - - - Replace the registry entry if you want to use other software with the TrackIR protocol and it doesn't work automatically. - - - true - - - - - - 8 - 23 - 93 - 23 - - - - Locate DLL - - - + + + + + + 0 + 0 + + + + TIRViews + + + Qt::AlignJustify|Qt::AlignTop + + + false + + + + + + Qt::RightToLeft + + + TRViews + + + + + + + Only for very old and buggy old games such as CFS3. + + + false + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + true + + + + + + + + + + + 0 + 0 + + + + TrackIR.exe + + + Qt::AlignJustify|Qt::AlignTop + + + false + + + + + + Qt::RightToLeft + + + Using EZCA + + + + + + + Spawn a useless "dummy" process called TrackIR.exe in order to fool EZCA. + + + true + + + + + + + + + + + 0 + 0 + + + + Select interface + + + Qt::AlignJustify|Qt::AlignTop + + + false + + + + QFormLayout::ExpandingFieldsGrow + + + + + + + + Disable one of the protocols if games are confused by presence of both at the same time. + + + true + + + + + + + + + + + 0 + 0 + + + + Repair NPClient location + + + Qt::AlignJustify|Qt::AlignTop + + + false + + + + + + Locate DLL + + + + + + + Replace the registry entry if you want to use other software with the TrackIR protocol and it doesn't work automatically. + + + true + + + + + + + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + diff --git a/ftnoir_protocol_ft/ftnoir_protocol_ft_dialog.cpp b/ftnoir_protocol_ft/ftnoir_protocol_ft_dialog.cpp index b59d3637..df13a6dc 100644 --- a/ftnoir_protocol_ft/ftnoir_protocol_ft_dialog.cpp +++ b/ftnoir_protocol_ft/ftnoir_protocol_ft_dialog.cpp @@ -41,8 +41,8 @@ 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.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); + connect(ui.buttonBox, SIGNAL(rejected()), 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())); -- cgit v1.2.3 From 92fc39fcfc054effcf1da6017858f3541805f08a Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 24 Oct 2013 16:34:40 +0200 Subject: faceapi: unbreak build --- ftnoir_tracker_sm/ftnoir_tracker_faceapi.cpp | 58 ++++++++++++++--- .../ftnoir_tracker_faceapi_dialog.cpp | 74 +--------------------- ftnoir_tracker_sm/ftnoir_tracker_sm.h | 50 ++++----------- 3 files changed, 63 insertions(+), 119 deletions(-) diff --git a/ftnoir_tracker_sm/ftnoir_tracker_faceapi.cpp b/ftnoir_tracker_sm/ftnoir_tracker_faceapi.cpp index 7fdb8229..b867c60a 100644 --- a/ftnoir_tracker_sm/ftnoir_tracker_faceapi.cpp +++ b/ftnoir_tracker_sm/ftnoir_tracker_faceapi.cpp @@ -26,10 +26,51 @@ #include #include #include "facetracknoir/global-settings.h" +#include -FTNoIR_Tracker::FTNoIR_Tracker() : lck_shm(SM_MM_DATA, SM_MUTEX, sizeof(SMMemMap)) +FTNoIR_Tracker::FTNoIR_Tracker() : shm(SM_MM_DATA, SM_MUTEX, sizeof(SMMemMap)), started(false) { - pMemData = (SMMemMap*) lck_shm.mem; + pMemData = (SMMemMap*) shm.mem; +} + +static void wait_for_cmd(SMMemMap *pMemData, PortableLockedShm& shm) { + qDebug() << "faceapi: waiting for cmd"; + for (int _ = 0; _ < 3000; _++) + { + bool br = false; + shm.lock(); + if (pMemData->command == 0) + { + br = true; + } + shm.unlock(); + if (br) + break; + QThread::msleep(1); + } + qDebug() << "faceapi: done waiting for cmd"; +} + +// Send a command without parameter-value to the tracking Engine. +// +void FTNoIR_Tracker::doCommand(int command) +{ + shm.lock(); + pMemData->command = command; + shm.unlock(); + wait_for_cmd(pMemData, shm); +} + +// +// Send a command with integer parameter-value to the tracking Engine. +// +void FTNoIR_Tracker::doCommand(int command, int value) +{ + shm.lock(); + pMemData->command = command; // Send command + pMemData->par_val_int = value; + shm.unlock(); + wait_for_cmd(pMemData, shm); } FTNoIR_Tracker::~FTNoIR_Tracker() @@ -47,7 +88,7 @@ FTNoIR_Tracker::~FTNoIR_Tracker() void FTNoIR_Tracker::StartTracker(QFrame *videoframe ) { qDebug() << "FTNoIR_Tracker::Initialize says: Starting "; - QMessageBox::warning(this, + QMessageBox::warning(videoframe, "Tracker deprecation", "Non-free SM FaceAPI is deprecated, hence this annoying message.\n" "It'll be removed for 2.0-final.", @@ -74,12 +115,8 @@ void FTNoIR_Tracker::StartTracker(QFrame *videoframe ) 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 } } @@ -100,10 +137,13 @@ void FTNoIR_Tracker::WaitForExit() bool FTNoIR_Tracker::GiveHeadPoseData(double *data) { + if (!started) + doStartEngine(); + started = true; // // Check if the pointer is OK and wait for the Mutex. // - lck_shm.lock(); + shm.lock(); // // Copy the measurements to FaceTrackNoIR. @@ -131,7 +171,7 @@ bool FTNoIR_Tracker::GiveHeadPoseData(double *data) // Reset the handshake, to let faceAPI know we're still here! // pMemData->handshake = 0; - lck_shm.unlock(); + shm.unlock(); return ( pMemData->data.new_pose.confidence > 0 ); } diff --git a/ftnoir_tracker_sm/ftnoir_tracker_faceapi_dialog.cpp b/ftnoir_tracker_sm/ftnoir_tracker_faceapi_dialog.cpp index d8f90e62..1dbdd67f 100644 --- a/ftnoir_tracker_sm/ftnoir_tracker_faceapi_dialog.cpp +++ b/ftnoir_tracker_sm/ftnoir_tracker_faceapi_dialog.cpp @@ -33,17 +33,10 @@ // // Constructor for server-settings-dialog // -TrackerControls::TrackerControls() : - QWidget(), - shm(SM_MM_DATA, SM_MUTEX, sizeof(TFaceData)) +TrackerControls::TrackerControls() : QWidget() { - pMemData = (SMMemMap*) shm.mem; - ui.setupUi( this ); - theTracker = NULL; - prev_state = -1; - //connect(ui.cbxFilterSetting, SIGNAL(currentIndexChanged(int)), this, SLOT(doSetFilter( int ))); //connect(ui.btnCameraSettings, SIGNAL(clicked()), this, SLOT(doShowCam())); @@ -93,7 +86,6 @@ void TrackerControls::doOK() { // override show event void TrackerControls::showEvent ( QShowEvent * event ) { - prev_state = -1; loadSettings(); } @@ -144,8 +136,6 @@ void TrackerControls::loadSettings() { // 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()); @@ -169,8 +159,6 @@ void TrackerControls::save() { 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() ); @@ -180,70 +168,10 @@ void TrackerControls::save() { 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::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. diff --git a/ftnoir_tracker_sm/ftnoir_tracker_sm.h b/ftnoir_tracker_sm/ftnoir_tracker_sm.h index 615d9d1b..4f38a045 100644 --- a/ftnoir_tracker_sm/ftnoir_tracker_sm.h +++ b/ftnoir_tracker_sm/ftnoir_tracker_sm.h @@ -47,14 +47,20 @@ public: void StopTracker( bool exit ); bool GiveHeadPoseData(double *data); // Returns true if confidence is good void WaitForExit(); - + void doCommand(int foo); + void doCommand(int foo, int bar); + void doStartEngine(){ + doCommand(FT_SM_START); + doCommand(FT_SM_SET_PAR_FILTER, 0); + //doCommand(FT_SM_SHOW_CAM); + } void loadSettings(); private: // // global variables // - PortableLockedShm lck_shm; + PortableLockedShm shm; SMMemMap *pMemData; QProcess *faceAPI; @@ -64,6 +70,7 @@ private: bool bEnableX; bool bEnableY; bool bEnableZ; + bool started; }; // Widget that has controls for SMoIR protocol client-settings. @@ -76,59 +83,28 @@ public: 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; - 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; - } - public slots: - void stateChanged(int newState) { + void stateChanged(int) { settingsDirty = true; } - + void settingChanged(int) { + settingsDirty = true; + } }; //******************************************************************************************************* -- cgit v1.2.3 From 2c3b50b297bb89d84fa0f928d7d01f7ff9b93512 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 24 Oct 2013 17:23:32 +0200 Subject: aruco: fix missing config var Signed-off-by: Stanislaw Halik --- ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp b/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp index b0999070..559b9d4d 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp @@ -199,12 +199,13 @@ 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" ); + double rot, trans, zoom; + + iniFile.beginGroup ( "Accela" ); iniFile.setValue("rotation-alpha", rot = ui.rotation_alpha->value()); iniFile.setValue("translation-alpha", trans = ui.translation_alpha->value()); + iniFile.setValue("zoom-slowness", zoom = ui.spinZoom->value()); iniFile.endGroup (); iniFile.beginGroup("Accela-Scaling"); -- cgit v1.2.3 From 3b64a76d62d22c120945e31b9592366c52cb5f70 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 24 Oct 2013 17:36:58 +0200 Subject: cmake: appease automoc :( --- CMakeLists.txt | 52 ++++++++++++++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 93a43dae..15b75b45 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -316,7 +316,7 @@ 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}) + add_library(opentrack-compat SHARED ${opentrack-compat-c} ${opentrack-compat-h}) if(NOT WIN32) target_link_libraries(opentrack-compat rt) endif() @@ -328,15 +328,15 @@ endif() endif() 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}) + add_library(opentrack-csv SHARED ${opentrack-csv-c} ${opentrack-csv-h}) target_link_libraries(opentrack-csv ${MY_QT_LIBS}) - add_library(opentrack-pose-widget SHARED ${opentrack-pose-widget-c} ${opentrack-pose-widget-moc} ${opentrack-pose-widget-rcc}) + add_library(opentrack-pose-widget SHARED ${opentrack-pose-widget-c} ${opentrack-pose-widget-h} ${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}) + add_library(opentrack-spline-widget SHARED ${opentrack-spline-widget-c} ${opentrack-spline-widget-h} ${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}) + add_library(opentrack-filter-accela SHARED ${opentrack-filter-accela-c} ${opentrack-filter-accela-h} ${opentrack-filter-accela-moc} ${opentrack-filter-accela-uih} ${opentrack-filter-accela-rcc}) target_link_libraries(opentrack-filter-accela ${MY_QT_LIBS}) if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) @@ -344,7 +344,7 @@ endif() PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt") endif() - add_library(opentrack-filter-ewma SHARED ${opentrack-filter-ewma-uih} ${opentrack-filter-ewma-c} ${opentrack-filter-ewma-moc} ${opentrack-filter-ewma-rcc}) + add_library(opentrack-filter-ewma SHARED ${opentrack-filter-ewma-uih} ${opentrack-filter-ewma-c} ${opentrack-filter-ewma-h} ${opentrack-filter-ewma-moc} ${opentrack-filter-ewma-rcc}) target_link_libraries(opentrack-filter-ewma ${MY_QT_LIBS}) if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) @@ -352,7 +352,7 @@ endif() PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt") endif() - add_library(opentrack-proto-fgfs SHARED ${opentrack-proto-fgfs-c} ${opentrack-proto-fgfs-moc} ${opentrack-proto-fgfs-uih} ${opentrack-proto-fgfs-rcc}) + add_library(opentrack-proto-fgfs SHARED ${opentrack-proto-fgfs-c} ${opentrack-proto-fgfs-h} ${opentrack-proto-fgfs-moc} ${opentrack-proto-fgfs-uih} ${opentrack-proto-fgfs-rcc}) target_link_libraries(opentrack-proto-fgfs ${MY_QT_LIBS}) if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) SET_TARGET_PROPERTIES(opentrack-proto-fgfs @@ -361,7 +361,7 @@ endif() if(WIN32 AND SDK_VJOY) include_directories(${SDK_VJOY}) - add_library(opentrack-proto-vjoy SHARED ${opentrack-proto-vjoy-c} ${opentrack-proto-vjoy-moc} ${opentrack-proto-vjoy-uih} ${opentrack-proto-vjoy-rcc}) + add_library(opentrack-proto-vjoy SHARED ${opentrack-proto-vjoy-c} ${opentrack-proto-vjoy-h} ${opentrack-proto-vjoy-moc} ${opentrack-proto-vjoy-uih} ${opentrack-proto-vjoy-rcc}) if(MSVC) target_link_libraries(opentrack-proto-vjoy ${MY_QT_LIBS} "${SDK_VJOY}/VJoy.lib") else() @@ -374,7 +374,7 @@ endif() endif() if(UNIX AND SDK_ENABLE_LIBEVDEV) - add_library(opentrack-proto-libevdev SHARED ${opentrack-proto-libevdev-c} ${opentrack-proto-libevdev-moc} ${opentrack-proto-libevdev-uih} ${opentrack-proto-libevdev-rcc}) + add_library(opentrack-proto-libevdev SHARED ${opentrack-proto-libevdev-c} ${opentrack-proto-libevdev-h} ${opentrack-proto-libevdev-moc} ${opentrack-proto-libevdev-uih} ${opentrack-proto-libevdev-rcc}) target_link_libraries(opentrack-proto-libevdev ${MY_QT_LIBS} evdev) if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) SET_TARGET_PROPERTIES(opentrack-proto-libevdev @@ -385,7 +385,7 @@ endif() if(WIN32) if(SDK_FSUIPC) - add_library(opentrack-proto-fsuipc SHARED ${opentrack-proto-fsuipc-c} ${opentrack-proto-fsuipc-moc} ${opentrack-proto-fsuipc-uih} ${opentrack-proto-fsuipc-rcc}) + add_library(opentrack-proto-fsuipc SHARED ${opentrack-proto-fsuipc-c} ${opentrack-proto-fsuipc-h} ${opentrack-proto-fsuipc-moc} ${opentrack-proto-fsuipc-uih} ${opentrack-proto-fsuipc-rcc}) target_link_libraries(opentrack-proto-fsuipc ${MY_QT_LIBS} "${SDK_FSUIPC}/FSUIPC_User.lib") if(MSVC) set_target_properties(opentrack-proto-fsuipc PROPERTIES LINK_FLAGS "/NODEFAULTLIB:libc") @@ -393,26 +393,26 @@ endif() endif() if(SDK_SIMCONNECT) - add_library(opentrack-proto-simconnect SHARED ${opentrack-proto-simconnect-c} ${opentrack-proto-simconnect-moc} ${opentrack-proto-simconnect-uih} ${opentrack-proto-simconnect-rcc}) + add_library(opentrack-proto-simconnect SHARED ${opentrack-proto-simconnect-c} ${opentrack-proto-simconnect-h} ${opentrack-proto-simconnect-moc} ${opentrack-proto-simconnect-uih} ${opentrack-proto-simconnect-rcc}) target_link_libraries(opentrack-proto-simconnect ${MY_QT_LIBS}) include_directories("${SDK_SIMCONNECT}/inc") target_link_libraries(opentrack-proto-simconnect "${SDK_SIMCONNECT}/lib/SimConnect.lib") endif() - add_library(opentrack-proto-freetrack SHARED ${opentrack-proto-freetrack-c} ${opentrack-proto-freetrack-moc} ${opentrack-proto-freetrack-uih} ${opentrack-proto-freetrack-rcc}) + add_library(opentrack-proto-freetrack SHARED ${opentrack-proto-freetrack-c} ${opentrack-proto-freetrack-h} ${opentrack-proto-freetrack-moc} ${opentrack-proto-freetrack-uih} ${opentrack-proto-freetrack-rcc}) target_link_libraries(opentrack-proto-freetrack opentrack-csv ${MY_QT_LIBS} opentrack-compat) - add_library(opentrack-proto-win32-mouse SHARED ${opentrack-proto-win32-mouse-c} ${opentrack-proto-win32-mouse-moc} ${opentrack-proto-win32-mouse-uih} ${opentrack-proto-win32-mouse-rcc}) + add_library(opentrack-proto-win32-mouse SHARED ${opentrack-proto-win32-mouse-c} ${opentrack-proto-win32-mouse-h} ${opentrack-proto-win32-mouse-moc} ${opentrack-proto-win32-mouse-uih} ${opentrack-proto-win32-mouse-rcc}) target_link_libraries(opentrack-proto-win32-mouse ${MY_QT_LIBS}) if(CMAKE_COMPILER_IS_GNUCC) - add_library(freetrackclient SHARED ${opentrack-freetrack-c} "${CMAKE_SOURCE_DIR}/freetrackclient/freetrackclient.def") + add_library(freetrackclient SHARED ${opentrack-freetrack-c} ${opentrack-freetrack-h} "${CMAKE_SOURCE_DIR}/freetrackclient/freetrackclient.def") set_target_properties(freetrackclient PROPERTIES LINK_FLAGS "-Wl,--enable-stdcall-fixup") else() - add_library(freetrackclient SHARED ${opentrack-freetrack-c}) + add_library(freetrackclient SHARED ${opentrack-freetrack-c} ${opentrack-freetrack-h}) endif() endif() - add_library(opentrack-proto-udp SHARED ${opentrack-proto-udp-c} ${opentrack-proto-udp-moc} ${opentrack-proto-udp-uih} ${opentrack-proto-udp-rcc}) + add_library(opentrack-proto-udp SHARED ${opentrack-proto-udp-c} ${opentrack-proto-udp-h} ${opentrack-proto-udp-moc} ${opentrack-proto-udp-uih} ${opentrack-proto-udp-rcc}) target_link_libraries(opentrack-proto-udp ${MY_QT_LIBS}) if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) SET_TARGET_PROPERTIES(opentrack-proto-udp @@ -420,7 +420,7 @@ endif() endif() if(NOT WIN32 AND SDK_WINE_PREFIX) - add_library(opentrack-proto-wine SHARED ${opentrack-proto-wine-c} ${opentrack-proto-wine-moc} ${opentrack-proto-wine-uih} ${opentrack-proto-wine-rcc}) + add_library(opentrack-proto-wine SHARED ${opentrack-proto-wine-c} ${opentrack-proto-wine-h} ${opentrack-proto-wine-moc} ${opentrack-proto-wine-uih} ${opentrack-proto-wine-rcc}) target_link_libraries(opentrack-proto-wine ${MY_QT_LIBS} opentrack-compat opentrack-csv) if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) SET_TARGET_PROPERTIES(opentrack-proto-wine @@ -448,7 +448,7 @@ endif() PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt") endif() - add_library(opentrack-tracker-ht SHARED ${opentrack-tracker-ht-c} ${opentrack-tracker-ht-moc} ${opentrack-tracker-ht-uih} ${opentrack-tracker-ht-rcc}) + add_library(opentrack-tracker-ht SHARED ${opentrack-tracker-ht-c} ${opentrack-tracker-ht-h} ${opentrack-tracker-ht-moc} ${opentrack-tracker-ht-uih} ${opentrack-tracker-ht-rcc}) target_link_libraries(opentrack-tracker-ht ${MY_QT_LIBS} opentrack-compat) if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) SET_TARGET_PROPERTIES(opentrack-tracker-ht @@ -457,7 +457,7 @@ endif() if(SDK_ARUCO_LIBPATH) include_directories(${CMAKE_SOURCE_DIR}/ftnoir_tracker_aruco/include) - add_library(opentrack-tracker-aruco SHARED ${opentrack-tracker-aruco-c} ${opentrack-tracker-aruco-moc} ${opentrack-tracker-aruco-uih} ${opentrack-tracker-aruco-rcc}) + add_library(opentrack-tracker-aruco SHARED ${opentrack-tracker-aruco-c} ${opentrack-tracker-aruco-h} ${opentrack-tracker-aruco-moc} ${opentrack-tracker-aruco-uih} ${opentrack-tracker-aruco-rcc}) target_link_libraries(opentrack-tracker-aruco ${MY_QT_LIBS} ${SDK_ARUCO_LIBPATH} ${OpenCV_LIBS}) if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) SET_TARGET_PROPERTIES(opentrack-tracker-aruco @@ -479,7 +479,7 @@ endif() endif() if(OpenCV_FOUND) - add_library(opentrack-tracker-pt SHARED ${opentrack-tracker-pt-c} ${opentrack-tracker-pt-moc} ${opentrack-tracker-pt-uih} ${opentrack-tracker-pt-rcc}) + add_library(opentrack-tracker-pt SHARED ${opentrack-tracker-pt-c} ${opentrack-tracker-pt-h} ${opentrack-tracker-pt-moc} ${opentrack-tracker-pt-uih} ${opentrack-tracker-pt-rcc}) target_link_libraries(opentrack-tracker-pt ${MY_QT_LIBS} ${OpenCV_LIBS}) if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) SET_TARGET_PROPERTIES(opentrack-tracker-pt @@ -494,7 +494,7 @@ endif() endif() endif() - add_library(opentrack-tracker-udp SHARED ${opentrack-tracker-udp-c} ${opentrack-tracker-udp-moc} ${opentrack-tracker-udp-uih} ${opentrack-tracker-udp-rcc}) + add_library(opentrack-tracker-udp SHARED ${opentrack-tracker-udp-c} ${opentrack-tracker-udp-h} ${opentrack-tracker-udp-moc} ${opentrack-tracker-udp-uih} ${opentrack-tracker-udp-rcc}) target_link_libraries(opentrack-tracker-udp ${MY_QT_LIBS}) if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) SET_TARGET_PROPERTIES(opentrack-tracker-udp @@ -504,7 +504,7 @@ endif() if(SDK_RIFT) include_directories("${SDK_RIFT}/Include") include_directories("${SDK_RIFT}/Src") - add_library(opentrack-tracker-rift SHARED ${opentrack-tracker-rift-c} ${opentrack-tracker-rift-moc} ${opentrack-tracker-rift-uih} ${opentrack-tracker-rift-rcc}) + add_library(opentrack-tracker-rift SHARED ${opentrack-tracker-rift-c} ${opentrack-tracker-rift-h} ${opentrack-tracker-rift-moc} ${opentrack-tracker-rift-uih} ${opentrack-tracker-rift-rcc}) target_link_libraries(opentrack-tracker-rift ${MY_QT_LIBS}) if(MSVC) target_link_libraries(opentrack-tracker-rift "${SDK_RIFT}/Lib/Win32/libovr.lib" winmm.lib) @@ -527,7 +527,7 @@ endif() if(SDK_HYDRA) include_directories("${SDK_HYDRA}/include") include_directories("${SDK_HYDRA}/include/sixense_utils") - add_library(opentrack-tracker-hydra SHARED ${opentrack-tracker-hydra-c} ${opentrack-tracker-hydra-moc} ${opentrack-tracker-hydra-uih} ${opentrack-tracker-hydra-rcc}) + add_library(opentrack-tracker-hydra SHARED ${opentrack-tracker-hydra-c} ${opentrack-tracker-hydra-h} ${opentrack-tracker-hydra-moc} ${opentrack-tracker-hydra-uih} ${opentrack-tracker-hydra-rcc}) target_link_libraries(opentrack-tracker-hydra ${MY_QT_LIBS}) if(WIN32) target_link_libraries(opentrack-tracker-hydra @@ -571,7 +571,7 @@ endif() 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}) endif() - add_executable(opentrack ${opentrack-win32-executable} ${opentrack-bin-c} ${opentrack-bin-moc} ${opentrack-bin-uih} ${opentrack-bin-rcc}) + 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}\") if(UNIX) target_link_libraries(opentrack opentrack-qxt-mini) @@ -614,11 +614,11 @@ endif() if(SDK_SM_FACEAPI_PATH) include_directories("${SDK_SM_FACEAPI_PATH}/include") if(WIN32 AND NOT SDK_FACEAPI_ONLY) - add_library(opentrack-tracker-faceapi SHARED ${opentrack-tracker-faceapi-c} ${opentrack-tracker-faceapi-moc} ${opentrack-tracker-faceapi-uih} ${opentrack-tracker-faceapi-rcc}) + add_library(opentrack-tracker-faceapi SHARED ${opentrack-tracker-faceapi-c} ${opentrack-tracker-faceapi-h} ${opentrack-tracker-faceapi-moc} ${opentrack-tracker-faceapi-uih} ${opentrack-tracker-faceapi-rcc}) target_link_libraries(opentrack-tracker-faceapi ${MY_QT_LIBS} opentrack-compat) endif() if(MSVC80 OR MINGW) - add_executable(opentrack-faceapi-wrapper ${opentrack-faceapi-wrapper-c}) + add_executable(opentrack-faceapi-wrapper ${opentrack-faceapi-wrapper-c} ${opentrack-faceapi-wrapper-h}) target_link_libraries(opentrack-faceapi-wrapper "${SDK_SM_FACEAPI_PATH}/bin/smft32.lib") endif() endif() -- 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(-) 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 0a09ee52d3f22201819234ea15d2d50f3dd0e48e Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 24 Oct 2013 17:37:35 +0200 Subject: faceapi: stuff --- ftnoir_tracker_sm/ftnoir_sm_controls.ui | 19 +++++++++---- ftnoir_tracker_sm/ftnoir_tracker_faceapi.cpp | 2 +- .../ftnoir_tracker_faceapi_dialog.cpp | 20 +++++++------- ftnoir_tracker_sm/ftnoir_tracker_sm.h | 32 ++++++++-------------- 4 files changed, 37 insertions(+), 36 deletions(-) diff --git a/ftnoir_tracker_sm/ftnoir_sm_controls.ui b/ftnoir_tracker_sm/ftnoir_sm_controls.ui index 732f0598..ecc252f1 100644 --- a/ftnoir_tracker_sm/ftnoir_sm_controls.ui +++ b/ftnoir_tracker_sm/ftnoir_sm_controls.ui @@ -9,8 +9,8 @@ 0 0 - 172 - 220 + 174 + 188 @@ -27,10 +27,13 @@ false + + QLayout::SetMaximumSize + - + 0 0 @@ -38,12 +41,18 @@ Axis enablement + + Qt::AlignCenter + - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + Qt::AlignHCenter|Qt::AlignTop + + + 10 diff --git a/ftnoir_tracker_sm/ftnoir_tracker_faceapi.cpp b/ftnoir_tracker_sm/ftnoir_tracker_faceapi.cpp index b867c60a..77fcd6fc 100644 --- a/ftnoir_tracker_sm/ftnoir_tracker_faceapi.cpp +++ b/ftnoir_tracker_sm/ftnoir_tracker_faceapi.cpp @@ -22,11 +22,11 @@ * with this program; if not, see . * * * ********************************************************************************/ -#include "ftnoir_tracker_sm.h" #include #include #include "facetracknoir/global-settings.h" #include +#include "ftnoir_tracker_sm/ftnoir_tracker_sm.h" FTNoIR_Tracker::FTNoIR_Tracker() : shm(SM_MM_DATA, SM_MUTEX, sizeof(SMMemMap)), started(false) { diff --git a/ftnoir_tracker_sm/ftnoir_tracker_faceapi_dialog.cpp b/ftnoir_tracker_sm/ftnoir_tracker_faceapi_dialog.cpp index 1dbdd67f..3510f3e9 100644 --- a/ftnoir_tracker_sm/ftnoir_tracker_faceapi_dialog.cpp +++ b/ftnoir_tracker_sm/ftnoir_tracker_faceapi_dialog.cpp @@ -22,8 +22,8 @@ * with this program; if not, see . * * * ********************************************************************************/ -#include "ftnoir_tracker_sm.h" #include +#include "ftnoir_tracker_sm/ftnoir_tracker_sm.h" #include "facetracknoir/global-settings.h" //******************************************************************************************************* @@ -33,24 +33,24 @@ // // Constructor for server-settings-dialog // -TrackerControls::TrackerControls() : QWidget() +TrackerControls::TrackerControls() : settingsDirty(false) { ui.setupUi( this ); //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. - connect(this, SIGNAL(stateChanged( int )), this, SLOT(showSettings( int ))); connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); - 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))); + connect(ui.chkEnableRoll, SIGNAL(setChecked(int)), this, SLOT(settingChanged(int))); + connect(ui.chkEnablePitch, SIGNAL(setChecked(int)), this, SLOT(settingChanged(int))); + connect(ui.chkEnableYaw, SIGNAL(setChecked(int)), this, SLOT(settingChanged(int))); + connect(ui.chkEnableX, SIGNAL(setChecked(int)), this, SLOT(settingChanged(int))); + connect(ui.chkEnableY, SIGNAL(setChecked(int)), this, SLOT(settingChanged(int))); + connect(ui.chkEnableZ, SIGNAL(setChecked(int)), this, SLOT(settingChanged(int))); + connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOk())); + connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doOCancel())); } // diff --git a/ftnoir_tracker_sm/ftnoir_tracker_sm.h b/ftnoir_tracker_sm/ftnoir_tracker_sm.h index 4f38a045..4089983d 100644 --- a/ftnoir_tracker_sm/ftnoir_tracker_sm.h +++ b/ftnoir_tracker_sm/ftnoir_tracker_sm.h @@ -22,10 +22,8 @@ * with this program; if not, see . * * * ********************************************************************************/ -#include "ftnoir_tracker_base/ftnoir_tracker_base.h" -#include "ftnoir_tracker_sm/ftnoir_tracker_sm_types.h" -#include "ui_ftnoir_sm_controls.h" - +#include +#include #include #include #include @@ -34,6 +32,9 @@ #include "facetracknoir/global-settings.h" #include "compat/compat.h" #include +#include "ftnoir_tracker_base/ftnoir_tracker_base.h" +#include "ftnoir_tracker_sm/ftnoir_tracker_sm_types.h" +#include "ui_ftnoir_sm_controls.h" using namespace std; @@ -73,9 +74,9 @@ private: bool started; }; -// Widget that has controls for SMoIR protocol client-settings. class TrackerControls: public QWidget, public ITrackerDialog { + Q_OBJECT public: explicit TrackerControls(); virtual ~TrackerControls(); @@ -86,25 +87,16 @@ public: } void unRegisterTracker() { } - -private: - Ui::UICSMClientControls ui; - void loadSettings(); - bool settingsDirty; - -private slots: +protected slots: void doOK(); void doCancel(); void save(); void settingChanged() { settingsDirty = true; } - void showSettings( int newState ); -public slots: - void stateChanged(int) { - settingsDirty = true; - } - void settingChanged(int) { - settingsDirty = true; - } + void settingChanged(int) { settingsDirty = true; } +private: + Ui::UICSMClientControls ui; + void loadSettings(); + bool settingsDirty; }; //******************************************************************************************************* -- cgit v1.2.3 -- cgit v1.2.3 From 406c810b370828106637d497005357d1ae9d50a4 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 24 Oct 2013 17:48:09 +0200 Subject: Reword deprecation message --- ftnoir_tracker_sm/ftnoir_tracker_faceapi.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ftnoir_tracker_sm/ftnoir_tracker_faceapi.cpp b/ftnoir_tracker_sm/ftnoir_tracker_faceapi.cpp index 77fcd6fc..18182153 100644 --- a/ftnoir_tracker_sm/ftnoir_tracker_faceapi.cpp +++ b/ftnoir_tracker_sm/ftnoir_tracker_faceapi.cpp @@ -89,9 +89,10 @@ void FTNoIR_Tracker::StartTracker(QFrame *videoframe ) { qDebug() << "FTNoIR_Tracker::Initialize says: Starting "; QMessageBox::warning(videoframe, - "Tracker deprecation", - "Non-free SM FaceAPI is deprecated, hence this annoying message.\n" - "It'll be removed for 2.0-final.", + "Non-free software deprecation", + "SM FaceAPI is deprecated, hence this annoying message.\n" + "It'll be removed for 2.0-final.\n" + "The goal is to have only open-source software available.", QMessageBox::Ok, QMessageBox::NoButton); loadSettings(); -- cgit v1.2.3 From 25ac2117ec6b9f4b48e53c7d3dbc512d739830af Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 24 Oct 2013 18:03:19 +0200 Subject: add a 3rdparty notice Signed-off-by: Stanislaw Halik --- 3rdparty-notices/NFAILCLIENT-CREDIT.txt | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 3rdparty-notices/NFAILCLIENT-CREDIT.txt diff --git a/3rdparty-notices/NFAILCLIENT-CREDIT.txt b/3rdparty-notices/NFAILCLIENT-CREDIT.txt new file mode 100644 index 00000000..7a69b0ae --- /dev/null +++ b/3rdparty-notices/NFAILCLIENT-CREDIT.txt @@ -0,0 +1,4 @@ +NFailClient is a clean-room implementation of NFail LLC NFailClient. + +Completed as an operation spanning the whole Europe, NFailClient was +written by gnomes, halflings and rakshasa. \ No newline at end of file -- cgit v1.2.3 From 4bde5b3cfc82348d822bcd99a0ca6bab022b2933 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 24 Oct 2013 18:12:24 +0200 Subject: improve wine wrapper subprocess handling Signed-off-by: Stanislaw Halik --- ftnoir_protocol_wine/ftnoir_protocol_wine.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ftnoir_protocol_wine/ftnoir_protocol_wine.cpp b/ftnoir_protocol_wine/ftnoir_protocol_wine.cpp index c5d0754f..d9c3f1e0 100644 --- a/ftnoir_protocol_wine/ftnoir_protocol_wine.cpp +++ b/ftnoir_protocol_wine/ftnoir_protocol_wine.cpp @@ -19,9 +19,14 @@ FTNoIR_Protocol::~FTNoIR_Protocol() { if (shm) { shm->stop = true; - wrapper.waitForFinished(2000); + wrapper.waitForFinished(100); + } + wrapper.terminate(); + if (!wrapper.waitForFinished(100)) + { + wrapper.kill(); + wrapper.waitForFinished(42); } - wrapper.kill(); shm_unlink("/" WINE_SHM_NAME); } -- cgit v1.2.3 From dacb7f69ca1bb9e5d06c2fa9aa4f781fbcc17851 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 24 Oct 2013 18:31:07 +0200 Subject: joystick tracker: skeleton only --- .../ftnoir_tracker_joystick.cpp | 59 +++++++++++ ftnoir_tracker_joystick/ftnoir_tracker_joystick.h | 76 +++++++++++++ .../ftnoir_tracker_joystick_dialog.cpp | 118 +++++++++++++++++++++ .../ftnoir_tracker_joystick_dll.cpp | 73 +++++++++++++ 4 files changed, 326 insertions(+) create mode 100644 ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp create mode 100644 ftnoir_tracker_joystick/ftnoir_tracker_joystick.h create mode 100644 ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp create mode 100644 ftnoir_tracker_joystick/ftnoir_tracker_joystick_dll.cpp diff --git a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp new file mode 100644 index 00000000..62462288 --- /dev/null +++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp @@ -0,0 +1,59 @@ +#include "ftnoir_tracker_joystick.h" +#include "facetracknoir/global-settings.h" + +FTNoIR_Tracker::FTNoIR_Tracker() +{ + bEnableRoll = true; + bEnablePitch = true; + bEnableYaw = true; + bEnableX = true; + bEnableY = true; + bEnableZ = true; +} + +FTNoIR_Tracker::~FTNoIR_Tracker() +{ +} + +void FTNoIR_Tracker::StartTracker(QFrame*) +{ + loadSettings(); +} + +bool FTNoIR_Tracker::GiveHeadPoseData(double *data) +{ + return true; +} + +// +// Load the current Settings from the currently 'active' INI-file. +// +void FTNoIR_Tracker::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 ( "tracker-joy" ); + 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_joystick/ftnoir_tracker_joystick.h b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h new file mode 100644 index 00000000..0769a51c --- /dev/null +++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h @@ -0,0 +1,76 @@ +#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: + FTNoIR_Tracker(); + ~FTNoIR_Tracker(); + + void StartTracker(QFrame *); + bool GiveHeadPoseData(double *data); + void loadSettings(); +private: + bool bEnableRoll; + bool bEnablePitch; + bool bEnableYaw; + bool bEnableX; + bool bEnableY; + bool bEnableZ; +}; + +// Widget that has controls for FTNoIR protocol client-settings. +class TrackerControls: public QWidget, public ITrackerDialog +{ + Q_OBJECT +public: + + explicit TrackerControls(); + ~TrackerControls(); + void showEvent (QShowEvent *); + + void Initialize(QWidget *parent); + void registerTracker(ITracker *) {} + void unRegisterTracker() {} + +private: + Ui::UICFTNClientControls ui; + void loadSettings(); + void save(); + 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_joystick/ftnoir_tracker_joystick_dialog.cpp b/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp new file mode 100644 index 00000000..87d89a1f --- /dev/null +++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp @@ -0,0 +1,118 @@ +#include "ftnoir_tracker_joystick.h" +#include "facetracknoir/global-settings.h" + +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.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))); + loadSettings(); +} + +// +// Destructor for server-dialog +// +TrackerControls::~TrackerControls() { +} + +void TrackerControls::Initialize(QWidget *parent) { + QPoint offsetpos(100, 100); + if (parent) { + this->move(parent->pos() + offsetpos); + } + show(); +} + +void TrackerControls::doOK() { + save(); + this->close(); +} + +void TrackerControls::showEvent ( QShowEvent * ) { + loadSettings(); +} + +void TrackerControls::doCancel() { + 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 ); + + 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 TrackerControls::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 ( "tracker-joy" ); + 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; +} + +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 ( "tracker-joy" ); + 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 (); + + 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_joystick/ftnoir_tracker_joystick_dll.cpp b/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dll.cpp new file mode 100644 index 00000000..cc099403 --- /dev/null +++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dll.cpp @@ -0,0 +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_joystick.h" +#include +#include "facetracknoir/global-settings.h" + +FTNoIR_TrackerDll::FTNoIR_TrackerDll() { + //populate the description strings + trackerFullName = "Joystick"; + trackerShortName = "Joystick"; + trackerDescription = "joystick"; +} + +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; +} -- cgit v1.2.3 From 032ab045327e7c442732938818e5ca4bce217406 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 24 Oct 2013 20:11:22 +0200 Subject: initial UNTESTED implementation of joystick tracker --- CMakeLists.txt | 27 +- .../ftnoir_tracker_joystick.cpp | 195 ++++++++-- ftnoir_tracker_joystick/ftnoir_tracker_joystick.h | 63 ++- .../ftnoir_tracker_joystick_controls.ui | 429 +++++++++++++++++++++ .../ftnoir_tracker_joystick_dialog.cpp | 92 ++++- .../ftnoir_tracker_joystick_dll.cpp | 24 -- 6 files changed, 739 insertions(+), 91 deletions(-) create mode 100644 ftnoir_tracker_joystick/ftnoir_tracker_joystick_controls.ui diff --git a/CMakeLists.txt b/CMakeLists.txt index 15b75b45..885e9a96 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -239,7 +239,7 @@ if(NOT SDK_FACEAPI_ONLY) file(GLOB opentrack-tracker-aruco-h "ftnoir_tracker_aruco/*.h") file(GLOB opentrack-tracker-aruco-ui "ftnoir_tracker_aruco/*.ui") file(GLOB opentrack-tracker-aruco-rc "ftnoir_tracker_aruco/*.qrc") - QT5_WRAP_UI(opentrack-tracker-aruco-uih ${opentrack-tracker-aruco-ui}) + QT5_WRAP_UI(opentracktracker-aruco-uih ${opentrack-tracker-aruco-ui}) QT5_ADD_RESOURCES(opentrack-tracker-aruco-rcc ${opentrack-tracker-aruco-rc}) file(GLOB opentrack-tracker-pt-c "FTNoIR_Tracker_PT/*.cpp") @@ -255,6 +255,13 @@ if(NOT SDK_FACEAPI_ONLY) file(GLOB opentrack-tracker-udp-rc "ftnoir_tracker_udp/*.qrc") QT5_WRAP_UI(opentrack-tracker-udp-uih ${opentrack-tracker-udp-ui}) QT5_ADD_RESOURCES(opentrack-tracker-udp-rcc ${opentrack-tracker-udp-rc}) + + file(GLOB opentrack-tracker-joystick-c "ftnoir_tracker_joystick/*.cpp") + file(GLOB opentrack-tracker-joystick-h "ftnoir_tracker_joystick/*.h") + file(GLOB opentrack-tracker-joystick-ui "ftnoir_tracker_joystick/*.ui") + file(GLOB opentrack-tracker-joystick-rc "ftnoir_tracker_joystick/*.qrc") + QT5_WRAP_UI(opentrack-tracker-joystick-uih ${opentrack-tracker-joystick-ui}) + QT5_ADD_RESOURCES(opentrack-tracker-joystick-rcc ${opentrack-tracker-joystick-rc}) file(GLOB opentrack-tracker-rift-c "ftnoir_tracker_rift/*.cpp") file(GLOB opentrack-tracker-rift-h "ftnoir_tracker_rift/*.h") @@ -419,6 +426,15 @@ endif() PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt") endif() + if(WIN32) + add_library(opentrack-tracker-joystick SHARED ${opentrack-tracker-joystick-c} ${opentrack-tracker-joystick-h} ${opentrack-tracker-joystick-moc} ${opentrack-tracker-joystick-uih} ${opentrack-tracker-joystick-rcc}) + target_link_libraries(opentrack-tracker-joystick ${MY_QT_LIBS}) + if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) + SET_TARGET_PROPERTIES(opentrack-tracker-joystick + PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt") + endif() + endif() + if(NOT WIN32 AND SDK_WINE_PREFIX) add_library(opentrack-proto-wine SHARED ${opentrack-proto-wine-c} ${opentrack-proto-wine-h} ${opentrack-proto-wine-moc} ${opentrack-proto-wine-uih} ${opentrack-proto-wine-rcc}) target_link_libraries(opentrack-proto-wine ${MY_QT_LIBS} opentrack-compat opentrack-csv) @@ -470,6 +486,11 @@ endif() "${CMAKE_SOURCE_DIR}/dinput/dxguid.lib" "${CMAKE_SOURCE_DIR}/dinput/strmiids.lib" uuid) + target_link_libraries(opentrack-tracker-joystick + "${CMAKE_SOURCE_DIR}/dinput/dinput8.lib" + "${CMAKE_SOURCE_DIR}/dinput/dxguid.lib" + "${CMAKE_SOURCE_DIR}/dinput/strmiids.lib" + uuid) endif() if(OpenCV_FOUND) @@ -669,6 +690,10 @@ if(NOT SDK_FACEAPI_ONLY) NAMELINK_SKIP ) + if(WIN32) + install(TARGETS opentrack-tracker-joystick RUNTIME DESTINATION . LIBRARY DESTINATION . NAMELINK_SKIP) + endif() + if(WIN32 AND SDK_VJOY) install(TARGETS opentrack-proto-vjoy RUNTIME DESTINATION . diff --git a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp index 62462288..68ae1e91 100644 --- a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp +++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp @@ -1,58 +1,197 @@ #include "ftnoir_tracker_joystick.h" #include "facetracknoir/global-settings.h" +#undef NDEBUG +#include +#include -FTNoIR_Tracker::FTNoIR_Tracker() +FTNoIR_Tracker::FTNoIR_Tracker() : + g_pDI(nullptr), + g_pJoystick(nullptr), + joyid(-1) { - bEnableRoll = true; - bEnablePitch = true; - bEnableYaw = true; - bEnableX = true; - bEnableY = true; - bEnableZ = true; + for (int i = 0; i < 6; i++) + axes[i] = -1; + GUID foo = {0}; + preferred = foo; +} + +void FTNoIR_Tracker::reload() +{ + QMutexLocker foo(&mtx); + if (g_pJoystick) + { + g_pJoystick->Unacquire(); + g_pJoystick->Release(); + } + if (g_pDI) + g_pDI->Release(); + + StartTracker(frame); } FTNoIR_Tracker::~FTNoIR_Tracker() { + if (g_pJoystick) + { + g_pJoystick->Unacquire(); + g_pJoystick->Release(); + } + if (g_pDI) + g_pDI->Release(); } -void FTNoIR_Tracker::StartTracker(QFrame*) +static BOOL CALLBACK EnumObjectsCallback( const DIDEVICEOBJECTINSTANCE* pdidoi, + VOID* pContext ) { + auto self = (FTNoIR_Tracker*) pContext; + + // For axes that are returned, set the DIPROP_RANGE property for the + // enumerated axis in order to scale min/max values. + if( pdidoi->dwType & DIDFT_AXIS ) + { + DIPROPRANGE diprg = {0}; + diprg.diph.dwSize = sizeof( DIPROPRANGE ); + diprg.diph.dwHeaderSize = sizeof( DIPROPHEADER ); + diprg.diph.dwHow = DIPH_BYID; + diprg.diph.dwObj = pdidoi->dwType; + diprg.lMin = -AXIS_MAX; + diprg.lMax = AXIS_MAX; + + // Set the range for the axis + if( FAILED( self->g_pJoystick->SetProperty( DIPROP_RANGE, &diprg.diph ) ) ) + return DIENUM_STOP; + } + + return DIENUM_CONTINUE; +} + +static BOOL CALLBACK EnumJoysticksCallback( const DIDEVICEINSTANCE* pdidInstance, VOID* pContext ) +{ + DI_ENUM_CONTEXT* pEnumContext = ( DI_ENUM_CONTEXT* )pContext; + + if (!IsEqualGUID(pEnumContext->preferred_instance, pdidInstance->guidInstance)) + return DIENUM_CONTINUE; + + if (SUCCEEDED(pEnumContext->g_pDI->CreateDevice( pdidInstance->guidInstance, + pEnumContext->g_pJoystick, NULL ))) + pEnumContext->bPreferredJoyCfgValid = true; + + return DIENUM_STOP; +} + +void FTNoIR_Tracker::StartTracker(QFrame* win) +{ + QMutexLocker foo(&mtx); + frame = win; loadSettings(); + auto hr = CoInitialize( nullptr ); + IDirectInputJoyConfig8* pJoyConfig = nullptr; + DIJOYCONFIG PreferredJoyCfg = {0}; + DI_ENUM_CONTEXT enumContext = {0}; + enumContext.pPreferredJoyCfg = &PreferredJoyCfg; + enumContext.bPreferredJoyCfgValid = false; + enumContext.g_pJoystick = &g_pJoystick; + + if( FAILED( hr = DirectInput8Create( GetModuleHandle( NULL ), DIRECTINPUT_VERSION, + IID_IDirectInput8, ( VOID** )&g_pDI, NULL ) ) ) + goto fail; + + if( FAILED( hr = g_pDI->EnumDevices( DI8DEVCLASS_GAMECTRL, + EnumJoysticksCallback, + &enumContext, DIEDFL_ATTACHEDONLY ) ) ) + goto fail; + + PreferredJoyCfg.dwSize = sizeof( PreferredJoyCfg ); + if( SUCCEEDED( pJoyConfig->GetConfig( 0, &PreferredJoyCfg, DIJC_GUIDINSTANCE ) ) ) + enumContext.bPreferredJoyCfgValid = true; + if (pJoyConfig) + { + pJoyConfig->Release(); + pJoyConfig = nullptr; + } + + assert((!!enumContext.bPreferredJoyCfgValid) == !!(g_pJoystick != nullptr)); + + if (FAILED(g_pJoystick->SetDataFormat(&c_dfDIJoystick2))) + goto fail; + + if (FAILED(g_pJoystick->SetCooperativeLevel((HWND) win->winId(), DISCL_NONEXCLUSIVE | DISCL_BACKGROUND))) + goto fail; + + if( FAILED( hr = g_pJoystick->EnumObjects( EnumObjectsCallback, + ( VOID* )this, DIDFT_ALL ) ) ) + goto fail; + + return; + +fail: + if (g_pJoystick) + g_pJoystick->Release(); + if (g_pDI) + g_pDI->Release(); + g_pJoystick = nullptr; + g_pDI = nullptr; } bool FTNoIR_Tracker::GiveHeadPoseData(double *data) { + QMutexLocker foo(&mtx); + DIJOYSTATE2 js; + + if( !g_pJoystick) + return false; + +start: + auto hr = g_pJoystick->Poll(); + if( FAILED( hr ) ) + { + hr = g_pJoystick->Acquire(); + while( hr == DIERR_INPUTLOST ) + hr = g_pJoystick->Acquire(); + goto start; + } + + if( FAILED( hr = g_pJoystick->GetDeviceState( sizeof( DIJOYSTATE2 ), &js ) ) ) + return false; + + const LONG values[] = { + js.lX, + js.lY, + js.lZ, + js.lRx, + js.lRy, + js.lRz, + js.rglSlider[0], + js.rglSlider[1] + }; + + for (int i = 0; i < 6; i++) + { + auto idx = axes[i] - 1; + if (idx < 0 || idx > 7) + { + data[i] = 0; + } + else { + data[i] = values[i] / (double) AXIS_MAX; + } + } + return true; } -// -// Load the current Settings from the currently 'active' INI-file. -// void FTNoIR_Tracker::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 ( "tracker-joy" ); - 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 (); + joyid = iniFile.value("joyid", -1).toInt(); + for (int i = 0; i < 6; i++) + axes[i] = iniFile.value(QString("axis-%1").arg(i), 0).toInt() - 1; + 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_joystick/ftnoir_tracker_joystick.h b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h index 0769a51c..c1157cba 100644 --- a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h +++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h @@ -1,13 +1,37 @@ +#pragma once #include "ftnoir_tracker_base/ftnoir_tracker_base.h" -#include "ui_ftnoir_ftnclientcontrols.h" -#include -#include +#include "ui_ftnoir_tracker_joystick_controls.h" +#include +#include +#include #include #include +#include #include -#include +#include #include #include "facetracknoir/global-settings.h" +#ifndef DIRECTINPUT_VERSION +# define DIRECTINPUT_VERSION 0x800 +#endif +#include +#include +#include +#include +#include +#include +#include + +#define AXIS_MAX 8192 + +struct DI_ENUM_CONTEXT +{ + DIJOYCONFIG* pPreferredJoyCfg; + bool bPreferredJoyCfgValid; + GUID preferred_instance; + LPDIRECTINPUTDEVICE8* g_pJoystick; + LPDIRECTINPUT8 g_pDI; +}; class FTNoIR_Tracker : public ITracker { @@ -15,16 +39,17 @@ public: FTNoIR_Tracker(); ~FTNoIR_Tracker(); - void StartTracker(QFrame *); + void StartTracker(QFrame *win); bool GiveHeadPoseData(double *data); void loadSettings(); -private: - bool bEnableRoll; - bool bEnablePitch; - bool bEnableYaw; - bool bEnableX; - bool bEnableY; - bool bEnableZ; + LPDIRECTINPUT8 g_pDI; + LPDIRECTINPUTDEVICE8 g_pJoystick; + int axes[6]; + GUID preferred; + int joyid; + QMutex mtx; + QFrame* frame; + void reload(); }; // Widget that has controls for FTNoIR protocol client-settings. @@ -32,20 +57,24 @@ class TrackerControls: public QWidget, public ITrackerDialog { Q_OBJECT public: - explicit TrackerControls(); ~TrackerControls(); void showEvent (QShowEvent *); void Initialize(QWidget *parent); - void registerTracker(ITracker *) {} - void unRegisterTracker() {} - + void registerTracker(ITracker *foo) { + tracker = dynamic_cast(foo); + } + void unRegisterTracker() { + tracker = NULL; + } + QList guids; private: - Ui::UICFTNClientControls ui; + Ui::UIJoystickControls ui; void loadSettings(); void save(); bool settingsDirty; + FTNoIR_Tracker* tracker; private slots: void doOK(); diff --git a/ftnoir_tracker_joystick/ftnoir_tracker_joystick_controls.ui b/ftnoir_tracker_joystick/ftnoir_tracker_joystick_controls.ui new file mode 100644 index 00000000..038e5925 --- /dev/null +++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick_controls.ui @@ -0,0 +1,429 @@ + + + UIJoystickControls + + + Qt::ApplicationModal + + + + 0 + 0 + 188 + 259 + + + + + 0 + 0 + + + + FTNoIR tracker settings FaceTrackNoIR + + + + images/FaceTrackNoIR.pngimages/FaceTrackNoIR.png + + + Qt::LeftToRight + + + false + + + + + + + 0 + 0 + + + + + 0 + 85 + + + + Axis enablement + + + Qt::AlignCenter + + + + + + Yaw + + + + + + + Pitch + + + + + + + Z + + + + + + + + + + + + + #1 + + + + + #2 + + + + + #3 + + + + + #4 + + + + + #5 + + + + + #6 + + + + + #7 + + + + + #8 + + + + + + + + + + + + + + #1 + + + + + #2 + + + + + #3 + + + + + #4 + + + + + #5 + + + + + #6 + + + + + #7 + + + + + #8 + + + + + + + + + + + + + + #1 + + + + + #2 + + + + + #3 + + + + + #4 + + + + + #5 + + + + + #6 + + + + + #7 + + + + + #8 + + + + + + + + + + + + + + #1 + + + + + #2 + + + + + #3 + + + + + #4 + + + + + #5 + + + + + #6 + + + + + #7 + + + + + #8 + + + + + + + + + + + + + + #1 + + + + + #2 + + + + + #3 + + + + + #4 + + + + + #5 + + + + + #6 + + + + + #7 + + + + + #8 + + + + + + + + X + + + + + + + + + + + + + #1 + + + + + #2 + + + + + #3 + + + + + #4 + + + + + #5 + + + + + #6 + + + + + #7 + + + + + #8 + + + + + + + + Roll + + + + + + + Y + + + + + + + Joy Id + + + + + + + Joy + + + 32 + + + + + + + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + startEngineClicked() + stopEngineClicked() + cameraSettingsClicked() + + diff --git a/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp b/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp index 87d89a1f..5be36879 100644 --- a/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp +++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp @@ -1,21 +1,51 @@ #include "ftnoir_tracker_joystick.h" #include "facetracknoir/global-settings.h" +static BOOL CALLBACK EnumJoysticksCallback( const DIDEVICEINSTANCE* pdidInstance, VOID* pContext ) +{ + auto self = ( TrackerControls* )pContext; + + self->guids.push_back(pdidInstance->guidInstance); + + return DIENUM_CONTINUE; +} + 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.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))); + connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); + connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); + + connect(ui.spinBox, SIGNAL(valueChanged(int)), this, SLOT(settingChanged(int))); + connect(ui.comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged(int))); + connect(ui.comboBox_2, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged(int))); + connect(ui.comboBox_3, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged(int))); + connect(ui.comboBox_4, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged(int))); + connect(ui.comboBox_5, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged(int))); + connect(ui.comboBox_6, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged(int))); + + { + auto hr = CoInitialize( nullptr ); + LPDIRECTINPUT8 g_pDI = nullptr; + + if( FAILED( hr = DirectInput8Create( GetModuleHandle( NULL ), DIRECTINPUT_VERSION, + IID_IDirectInput8, ( VOID** )&g_pDI, NULL ) ) ) + goto fin; + + if( FAILED( hr = g_pDI->EnumDevices( DI8DEVCLASS_GAMECTRL, + EnumJoysticksCallback, + this, + DIEDFL_ATTACHEDONLY ))) + goto fin; + +fin: + if (g_pDI) + g_pDI->Release(); + } + loadSettings(); } @@ -74,13 +104,21 @@ void TrackerControls::loadSettings() { QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) + QComboBox* boxen[] = { + ui.comboBox, + ui.comboBox_2, + ui.comboBox_3, + ui.comboBox_4, + ui.comboBox_5, + ui.comboBox_6, + }; + iniFile.beginGroup ( "tracker-joy" ); - 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()); + for (int i = 0; i < 6; i++) + { + boxen[i]->setCurrentIndex(iniFile.value(QString("axis-%1").arg(i), 0).toInt()); + } + ui.spinBox->setValue(iniFile.value("joyid", -1).toInt()); iniFile.endGroup (); settingsDirty = false; @@ -92,15 +130,27 @@ void TrackerControls::save() { QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) + QComboBox* boxen[] = { + ui.comboBox, + ui.comboBox_2, + ui.comboBox_3, + ui.comboBox_4, + ui.comboBox_5, + ui.comboBox_6, + }; + iniFile.beginGroup ( "tracker-joy" ); - 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() ); + for (int i = 0; i < 6; i++) + { + iniFile.setValue(QString("axis-%1").arg(i), boxen[i]->currentIndex()); + } iniFile.endGroup (); + if(tracker) + { + tracker->reload(); + } + settingsDirty = false; } //////////////////////////////////////////////////////////////////////////////// diff --git a/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dll.cpp b/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dll.cpp index cc099403..c5ee4e5f 100644 --- a/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dll.cpp +++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dll.cpp @@ -1,27 +1,3 @@ -/******************************************************************************** -* 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_joystick.h" #include #include "facetracknoir/global-settings.h" -- 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(-) 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(-) 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 a19d4fc2ec4ef759cae00505038c02c684c4106b Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 24 Oct 2013 21:16:06 +0200 Subject: finish joystick impl --- .../ftnoir_tracker_joystick.cpp | 80 +++++++++++++++------- ftnoir_tracker_joystick/ftnoir_tracker_joystick.h | 7 +- 2 files changed, 61 insertions(+), 26 deletions(-) diff --git a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp index 68ae1e91..73993999 100644 --- a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp +++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp @@ -4,10 +4,21 @@ #include #include +static BOOL CALLBACK EnumJoysticksCallback2( const DIDEVICEINSTANCE* pdidInstance, VOID* pContext ) +{ + auto self = ( FTNoIR_Tracker* )pContext; + + self->def = *pdidInstance; + + return self->iter++ == self->joyid ? DIENUM_STOP : DIENUM_CONTINUE; +} + FTNoIR_Tracker::FTNoIR_Tracker() : g_pDI(nullptr), g_pJoystick(nullptr), - joyid(-1) + joyid(-1), + iter(-1), + mtx(QMutex::Recursive) { for (int i = 0; i < 6; i++) axes[i] = -1; @@ -72,55 +83,75 @@ static BOOL CALLBACK EnumJoysticksCallback( const DIDEVICEINSTANCE* pdidInstance if (!IsEqualGUID(pEnumContext->preferred_instance, pdidInstance->guidInstance)) return DIENUM_CONTINUE; - if (SUCCEEDED(pEnumContext->g_pDI->CreateDevice( pdidInstance->guidInstance, - pEnumContext->g_pJoystick, NULL ))) - pEnumContext->bPreferredJoyCfgValid = true; + (void) pEnumContext->g_pDI->CreateDevice( pdidInstance->guidInstance, pEnumContext->g_pJoystick, NULL); return DIENUM_STOP; } -void FTNoIR_Tracker::StartTracker(QFrame* win) +void FTNoIR_Tracker::StartTracker(QFrame* frame) { QMutexLocker foo(&mtx); - frame = win; + iter = 0; loadSettings(); auto hr = CoInitialize( nullptr ); - IDirectInputJoyConfig8* pJoyConfig = nullptr; - DIJOYCONFIG PreferredJoyCfg = {0}; DI_ENUM_CONTEXT enumContext = {0}; - enumContext.pPreferredJoyCfg = &PreferredJoyCfg; - enumContext.bPreferredJoyCfgValid = false; - enumContext.g_pJoystick = &g_pJoystick; if( FAILED( hr = DirectInput8Create( GetModuleHandle( NULL ), DIRECTINPUT_VERSION, IID_IDirectInput8, ( VOID** )&g_pDI, NULL ) ) ) + { + qDebug() << "create"; goto fail; + } if( FAILED( hr = g_pDI->EnumDevices( DI8DEVCLASS_GAMECTRL, - EnumJoysticksCallback, - &enumContext, DIEDFL_ATTACHEDONLY ) ) ) + EnumJoysticksCallback2, + this, + DIEDFL_ATTACHEDONLY))) + { + qDebug() << "enum2"; goto fail; + } - PreferredJoyCfg.dwSize = sizeof( PreferredJoyCfg ); - if( SUCCEEDED( pJoyConfig->GetConfig( 0, &PreferredJoyCfg, DIJC_GUIDINSTANCE ) ) ) - enumContext.bPreferredJoyCfgValid = true; - if (pJoyConfig) + enumContext.pPreferredJoyCfg = &def; + enumContext.g_pDI = g_pDI; + enumContext.g_pJoystick = &g_pJoystick; + enumContext.preferred_instance = def.guidInstance; + + if( FAILED( hr = g_pDI->EnumDevices( DI8DEVCLASS_GAMECTRL, + EnumJoysticksCallback, + &enumContext, + DIEDFL_ATTACHEDONLY))) { - pJoyConfig->Release(); - pJoyConfig = nullptr; + qDebug() << "enum1"; + goto fail; } - assert((!!enumContext.bPreferredJoyCfgValid) == !!(g_pJoystick != nullptr)); + if (!g_pJoystick) + { + qDebug() << "ENODEV"; + goto fail; + } if (FAILED(g_pJoystick->SetDataFormat(&c_dfDIJoystick2))) + { + qDebug() << "format"; goto fail; + } - if (FAILED(g_pJoystick->SetCooperativeLevel((HWND) win->winId(), DISCL_NONEXCLUSIVE | DISCL_BACKGROUND))) + if (FAILED(g_pJoystick->SetCooperativeLevel((HWND) frame->window()->winId(), DISCL_NONEXCLUSIVE | DISCL_BACKGROUND))) + { + qDebug() << "coop"; goto fail; + } if( FAILED( hr = g_pJoystick->EnumObjects( EnumObjectsCallback, - ( VOID* )this, DIDFT_ALL ) ) ) + ( VOID* )this, DIDFT_ALL ))) + { + qDebug() << "enum axes"; goto fail; + } + + qDebug() << "joy init success"; return; @@ -131,6 +162,8 @@ fail: g_pDI->Release(); g_pJoystick = nullptr; g_pDI = nullptr; + + qDebug() << "joy init failure"; } bool FTNoIR_Tracker::GiveHeadPoseData(double *data) @@ -143,7 +176,7 @@ bool FTNoIR_Tracker::GiveHeadPoseData(double *data) start: auto hr = g_pJoystick->Poll(); - if( FAILED( hr ) ) + if( FAILED( hr )) { hr = g_pJoystick->Acquire(); while( hr == DIERR_INPUTLOST ) @@ -182,6 +215,7 @@ start: void FTNoIR_Tracker::loadSettings() { + QMutexLocker foo(&mtx); 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) diff --git a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h index c1157cba..0d27a752 100644 --- a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h +++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h @@ -26,8 +26,7 @@ struct DI_ENUM_CONTEXT { - DIJOYCONFIG* pPreferredJoyCfg; - bool bPreferredJoyCfgValid; + DIDEVICEINSTANCE* pPreferredJoyCfg; GUID preferred_instance; LPDIRECTINPUTDEVICE8* g_pJoystick; LPDIRECTINPUT8 g_pDI; @@ -39,7 +38,7 @@ public: FTNoIR_Tracker(); ~FTNoIR_Tracker(); - void StartTracker(QFrame *win); + void StartTracker(QFrame *frame); bool GiveHeadPoseData(double *data); void loadSettings(); LPDIRECTINPUT8 g_pDI; @@ -49,7 +48,9 @@ public: int joyid; QMutex mtx; QFrame* frame; + DIDEVICEINSTANCE def; void reload(); + int iter; // XXX bad style }; // Widget that has controls for FTNoIR protocol client-settings. -- cgit v1.2.3 From f40d7a58d0032289e6c122bbd57bc8b6bed8ebcd Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 24 Oct 2013 21:28:34 +0200 Subject: actually finish the joystick impl --- ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp | 11 ++++++++++- ftnoir_tracker_joystick/ftnoir_tracker_joystick.h | 5 ++--- .../ftnoir_tracker_joystick_controls.ui | 14 +++++++------- ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp | 8 +++++--- 4 files changed, 24 insertions(+), 14 deletions(-) diff --git a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp index 73993999..35d3927f 100644 --- a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp +++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp @@ -198,6 +198,15 @@ start: js.rglSlider[1] }; + const double max[] = { + 100, + 100, + 100, + 180, + 90, + 180 + }; + for (int i = 0; i < 6; i++) { auto idx = axes[i] - 1; @@ -206,7 +215,7 @@ start: data[i] = 0; } else { - data[i] = values[i] / (double) AXIS_MAX; + data[i] = values[i] * max[i] / (double) AXIS_MAX; } } diff --git a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h index 0d27a752..72471f3f 100644 --- a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h +++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h @@ -70,11 +70,10 @@ public: tracker = NULL; } QList guids; -private: Ui::UIJoystickControls ui; - void loadSettings(); + void loadSettings(); void save(); - bool settingsDirty; + bool settingsDirty; FTNoIR_Tracker* tracker; private slots: diff --git a/ftnoir_tracker_joystick/ftnoir_tracker_joystick_controls.ui b/ftnoir_tracker_joystick/ftnoir_tracker_joystick_controls.ui index 038e5925..a19a3cad 100644 --- a/ftnoir_tracker_joystick/ftnoir_tracker_joystick_controls.ui +++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick_controls.ui @@ -9,7 +9,7 @@ 0 0 - 188 + 216 259 @@ -398,12 +398,12 @@ - - - Joy - - - 32 + + + + 0 + 0 + diff --git a/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp b/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp index 5be36879..80431b99 100644 --- a/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp +++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp @@ -6,12 +6,13 @@ static BOOL CALLBACK EnumJoysticksCallback( const DIDEVICEINSTANCE* pdidInstance auto self = ( TrackerControls* )pContext; self->guids.push_back(pdidInstance->guidInstance); + self->ui.joylist->addItem(QString(pdidInstance->tszInstanceName)); return DIENUM_CONTINUE; } TrackerControls::TrackerControls() : -QWidget() + QWidget(), tracker(nullptr), settingsDirty(false) { ui.setupUi( this ); @@ -19,7 +20,7 @@ QWidget() connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); - connect(ui.spinBox, SIGNAL(valueChanged(int)), this, SLOT(settingChanged(int))); + connect(ui.joylist, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged(int))); connect(ui.comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged(int))); connect(ui.comboBox_2, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged(int))); connect(ui.comboBox_3, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged(int))); @@ -118,7 +119,7 @@ void TrackerControls::loadSettings() { { boxen[i]->setCurrentIndex(iniFile.value(QString("axis-%1").arg(i), 0).toInt()); } - ui.spinBox->setValue(iniFile.value("joyid", -1).toInt()); + ui.joylist->setCurrentIndex(iniFile.value("joyid", -1).toInt()); iniFile.endGroup (); settingsDirty = false; @@ -144,6 +145,7 @@ void TrackerControls::save() { { iniFile.setValue(QString("axis-%1").arg(i), boxen[i]->currentIndex()); } + iniFile.setValue("joyid", ui.joylist->currentIndex()); iniFile.endGroup (); if(tracker) -- cgit v1.2.3 From fa825e6a5df757224d747062b0b49ef584daa95a Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 24 Oct 2013 21:33:18 +0200 Subject: joy tracker: double discretization resolution --- ftnoir_tracker_joystick/ftnoir_tracker_joystick.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h index 72471f3f..4d8094e5 100644 --- a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h +++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h @@ -22,7 +22,7 @@ #include #include -#define AXIS_MAX 8192 +#define AXIS_MAX 16383 struct DI_ENUM_CONTEXT { -- cgit v1.2.3 From a5b6e3759dbb4c1b6c25f30317f8a6c341dceb2c Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 24 Oct 2013 21:35:07 +0200 Subject: add joystick tracker copyright info --- ftnoir_tracker_joystick/ftnoir_tracker_joystick.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h index 4d8094e5..d304d0fd 100644 --- a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h +++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h @@ -1,3 +1,9 @@ +/* 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 "ftnoir_tracker_base/ftnoir_tracker_base.h" #include "ui_ftnoir_tracker_joystick_controls.h" -- cgit v1.2.3 From 387e9729f29cd09ea6e3390f1177886de560de98 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 24 Oct 2013 21:35:52 +0200 Subject: use CXX header style --- ftnoir_tracker_joystick/ftnoir_tracker_joystick.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h index d304d0fd..2a390228 100644 --- a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h +++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include "facetracknoir/global-settings.h" #ifndef DIRECTINPUT_VERSION # define DIRECTINPUT_VERSION 0x800 -- cgit v1.2.3 From 949fa1b35acdd9d9ebfca66fb3e893dbd98376e6 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 24 Oct 2013 22:06:46 +0200 Subject: fix CRT hell Signed-off-by: Stanislaw Halik --- CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 885e9a96..4b524310 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -598,6 +598,10 @@ endif() target_link_libraries(opentrack opentrack-qxt-mini) endif() + if(MSVC) + SET_TARGET_PROPERTIES(opentrack PROPERTIES LINK_FLAGS "/NODEFAULTLIB:LIBCMT") + endif() + if(UNIX) install(TARGETS opentrack-qxt-mini DESTINATION .) endif() -- cgit v1.2.3 From ce35044b97c187a800202b36d4653091b334121e Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 24 Oct 2013 22:16:21 +0200 Subject: more robust PDB install handling --- CMakeLists.txt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4b524310..5238c1e1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -599,7 +599,7 @@ endif() endif() if(MSVC) - SET_TARGET_PROPERTIES(opentrack PROPERTIES LINK_FLAGS "/NODEFAULTLIB:LIBCMT") + SET_TARGET_PROPERTIES(opentrack PROPERTIES LINK_FLAGS "/NODEFAULTLIB:LIBCMT.lib") endif() if(UNIX) @@ -787,8 +787,9 @@ if(SDK_SM_FACEAPI_PATH AND NOT SDK_FACEAPI_ONLY) endif() if(MSVC) - file(GLOB pdbs "${CMAKE_BINARY_DIR}/Release/*.pdb") - install(FILES ${pdbs} DESTINATION .) + file(GLOB pdbs1 "${CMAKE_BINARY_DIR}/Release/*.pdb") + file(GLOB pdbs2 "${CMAKE_BINARY_DIR}/*.pdb") + install(FILES ${pdbs} ${pdbs2} DESTINATION .) endif() if(SDK_SM_FACEAPI_PATH AND (MSVC80 OR MINGW)) -- cgit v1.2.3 From 7860d01c4e823307fadb33e8a8904b73b5b738b4 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 24 Oct 2013 22:19:54 +0200 Subject: fix the link error again, now --- CMakeLists.txt | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5238c1e1..74765995 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -598,10 +598,6 @@ endif() target_link_libraries(opentrack opentrack-qxt-mini) endif() - if(MSVC) - SET_TARGET_PROPERTIES(opentrack PROPERTIES LINK_FLAGS "/NODEFAULTLIB:LIBCMT.lib") - endif() - if(UNIX) install(TARGETS opentrack-qxt-mini DESTINATION .) endif() @@ -615,7 +611,7 @@ endif() ) endif() if(MSVC) - SET_TARGET_PROPERTIES(opentrack PROPERTIES LINK_FLAGS "/ENTRY:mainCRTStartup") + SET_TARGET_PROPERTIES(opentrack PROPERTIES LINK_FLAGS "/ENTRY:mainCRTStartup /NODEFAULTLIB:LIBCMT.LIB") endif() target_link_libraries(opentrack opentrack-pose-widget opentrack-spline-widget ${MY_QT_LIBS} ${QXT_QXTCORE_LIB_RELEASE} ${QXT_QXTWIDGETS_LIB_RELEASE}) if(NOT WIN32) -- cgit v1.2.3 From 929845cce8fddc3ea958aced758472fae450f0aa Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 24 Oct 2013 22:21:31 +0200 Subject: cmake: whitespace --- CMakeLists.txt | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 74765995..fbeeca41 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -618,15 +618,16 @@ endif() target_link_libraries(opentrack dl) endif() 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") + 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() - endif() set_target_properties(opentrack PROPERTIES COMPILE_FLAGS -DOPENTRACK_MAIN) endif() @@ -642,7 +643,7 @@ if(SDK_SM_FACEAPI_PATH) add_executable(opentrack-faceapi-wrapper ${opentrack-faceapi-wrapper-c} ${opentrack-faceapi-wrapper-h}) target_link_libraries(opentrack-faceapi-wrapper "${SDK_SM_FACEAPI_PATH}/bin/smft32.lib") endif() -endif() +endif() install(FILES "${CMAKE_SOURCE_DIR}/README.md" DESTINATION .) @@ -652,9 +653,9 @@ if(NOT SDK_FACEAPI_ONLY) endif() if(WIN32) install(DIRECTORY "${CMAKE_SOURCE_DIR}/bin/tracker-ht" DESTINATION .) - install(TARGETS freetrackclient RUNTIME DESTINATION .) + install(TARGETS freetrackclient RUNTIME DESTINATION .) endif() - install(DIRECTORY "${CMAKE_SOURCE_DIR}/3rdparty-notices" DESTINATION .) + install(DIRECTORY "${CMAKE_SOURCE_DIR}/3rdparty-notices" DESTINATION .) install(FILES "${CMAKE_SOURCE_DIR}/bin/NPClient.dll" "${CMAKE_SOURCE_DIR}/bin/NPClient64.dll" "${CMAKE_SOURCE_DIR}/bin/TrackIR.exe" DESTINATION .) install(DIRECTORY "${CMAKE_SOURCE_DIR}/bin/settings" "${CMAKE_SOURCE_DIR}/facetracknoir/clientfiles" DESTINATION .) @@ -751,7 +752,7 @@ if(NOT SDK_FACEAPI_ONLY) install(FILES "${qt-dirname}/Qt5Core.dll" "${qt-dirname}/Qt5Gui.dll" - "${qt-dirname}/Qt5Widgets.dll" + "${qt-dirname}/Qt5Widgets.dll" "${qt-dirname}/Qt5Network.dll" "${qt-dirname}/Qt5Xml.dll" DESTINATION . -- cgit v1.2.3 From bd7b99f34b8ae19231684eefea6285af1bfb735d Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 24 Oct 2013 22:26:38 +0200 Subject: fix pdb install (it's real late now) Signed-off-by: Stanislaw Halik --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fbeeca41..dd5c0317 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -786,7 +786,7 @@ endif() if(MSVC) file(GLOB pdbs1 "${CMAKE_BINARY_DIR}/Release/*.pdb") file(GLOB pdbs2 "${CMAKE_BINARY_DIR}/*.pdb") - install(FILES ${pdbs} ${pdbs2} DESTINATION .) + install(FILES ${pdbs1} ${pdbs2} DESTINATION .) endif() if(SDK_SM_FACEAPI_PATH AND (MSVC80 OR MINGW)) -- cgit v1.2.3 From 6f53683ca4ab35a9957c82df4d0195d4dcda60dd Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 24 Oct 2013 22:30:17 +0200 Subject: be extra paranoid about dinput stale pointers Signed-off-by: Stanislaw Halik --- ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp index 35d3927f..c591fc36 100644 --- a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp +++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp @@ -37,6 +37,9 @@ void FTNoIR_Tracker::reload() if (g_pDI) g_pDI->Release(); + g_pJoystick = nullptr; + g_pDI = nullptr; + StartTracker(frame); } -- cgit v1.2.3 From 2a6f6f39462948569ecc3d685b2b0344c80b37dc Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 24 Oct 2013 22:32:00 +0200 Subject: remove dead code Signed-off-by: Stanislaw Halik --- ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp | 1 - ftnoir_tracker_joystick/ftnoir_tracker_joystick.h | 1 - 2 files changed, 2 deletions(-) diff --git a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp index c591fc36..97ac77e9 100644 --- a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp +++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp @@ -115,7 +115,6 @@ void FTNoIR_Tracker::StartTracker(QFrame* frame) goto fail; } - enumContext.pPreferredJoyCfg = &def; enumContext.g_pDI = g_pDI; enumContext.g_pJoystick = &g_pJoystick; enumContext.preferred_instance = def.guidInstance; diff --git a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h index 2a390228..813640d3 100644 --- a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h +++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h @@ -32,7 +32,6 @@ struct DI_ENUM_CONTEXT { - DIDEVICEINSTANCE* pPreferredJoyCfg; GUID preferred_instance; LPDIRECTINPUTDEVICE8* g_pJoystick; LPDIRECTINPUT8 g_pDI; -- cgit v1.2.3 From 4e3366194dad626247063b1505f7223836355377 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 25 Oct 2013 00:13:42 +0200 Subject: multiply EZCA-mode pitch by 2 Signed-off-by: Stanislaw Halik --- ftnoir_protocol_ft/ftnoir_protocol_ft.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp b/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp index 4410b7a5..84d1d20b 100644 --- a/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp +++ b/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp @@ -112,7 +112,7 @@ void FTNoIR_Protocol::sendHeadposeToGame(const double* headpose) { float headRotX; float headRotY; float headRotZ; - headRotX = virtRotX = getRadsFromDegrees(headpose[Pitch]); + headRotX = virtRotX = getRadsFromDegrees(headpose[Pitch]) * (useDummyExe ? 2.0 : 1.0); headRotY = virtRotY = getRadsFromDegrees(headpose[Yaw]); headRotZ = virtRotZ = getRadsFromDegrees(headpose[Roll]); headPosX = virtPosX = headpose[TX] * 10; -- cgit v1.2.3 From 136a710a7fe94b9f55a2c297dea266ed2bd60367 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 25 Oct 2013 00:14:01 +0200 Subject: hopefully joy works, at least for me it does Signed-off-by: Stanislaw Halik --- .../ftnoir_tracker_joystick.cpp | 44 +++++++++++------- ftnoir_tracker_joystick/ftnoir_tracker_joystick.h | 3 +- .../ftnoir_tracker_joystick_dialog.cpp | 54 +++++++++++----------- 3 files changed, 57 insertions(+), 44 deletions(-) diff --git a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp index 97ac77e9..a132f472 100644 --- a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp +++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp @@ -21,9 +21,9 @@ FTNoIR_Tracker::FTNoIR_Tracker() : mtx(QMutex::Recursive) { for (int i = 0; i < 6; i++) - axes[i] = -1; - GUID foo = {0}; - preferred = foo; + axes[i] = min_[i] = max_[i] = 0; + GUID bar = {0}; + preferred = bar; } void FTNoIR_Tracker::reload() @@ -68,15 +68,19 @@ static BOOL CALLBACK EnumObjectsCallback( const DIDEVICEOBJECTINSTANCE* pdidoi, diprg.diph.dwHeaderSize = sizeof( DIPROPHEADER ); diprg.diph.dwHow = DIPH_BYID; diprg.diph.dwObj = pdidoi->dwType; - diprg.lMin = -AXIS_MAX; - diprg.lMax = AXIS_MAX; // Set the range for the axis - if( FAILED( self->g_pJoystick->SetProperty( DIPROP_RANGE, &diprg.diph ) ) ) + + if( FAILED( self->g_pJoystick->GetProperty( DIPROP_RANGE, &diprg.diph ) ) ) return DIENUM_STOP; + + self->min_[self->iter] = diprg.lMin; + self->max_[self->iter] = diprg.lMax; + qDebug() << "axis" << self->iter << diprg.lMin << diprg.lMax; + self->iter++; } - return DIENUM_CONTINUE; + return self->iter == 8 ? DIENUM_STOP : DIENUM_CONTINUE; } static BOOL CALLBACK EnumJoysticksCallback( const DIDEVICEINSTANCE* pdidInstance, VOID* pContext ) @@ -94,6 +98,7 @@ static BOOL CALLBACK EnumJoysticksCallback( const DIDEVICEINSTANCE* pdidInstance void FTNoIR_Tracker::StartTracker(QFrame* frame) { QMutexLocker foo(&mtx); + this->frame = frame; iter = 0; loadSettings(); auto hr = CoInitialize( nullptr ); @@ -134,7 +139,7 @@ void FTNoIR_Tracker::StartTracker(QFrame* frame) goto fail; } - if (FAILED(g_pJoystick->SetDataFormat(&c_dfDIJoystick2))) + if (FAILED(g_pJoystick->SetDataFormat(&c_dfDIJoystick))) { qDebug() << "format"; goto fail; @@ -146,6 +151,8 @@ void FTNoIR_Tracker::StartTracker(QFrame* frame) goto fail; } + iter = 0; + if( FAILED( hr = g_pJoystick->EnumObjects( EnumObjectsCallback, ( VOID* )this, DIDFT_ALL ))) { @@ -171,9 +178,9 @@ fail: bool FTNoIR_Tracker::GiveHeadPoseData(double *data) { QMutexLocker foo(&mtx); - DIJOYSTATE2 js; + DIJOYSTATE js = {0}; - if( !g_pJoystick) + if( !g_pDI || !g_pJoystick) return false; start: @@ -186,21 +193,21 @@ start: goto start; } - if( FAILED( hr = g_pJoystick->GetDeviceState( sizeof( DIJOYSTATE2 ), &js ) ) ) + if( FAILED( hr = g_pJoystick->GetDeviceState( sizeof( js ), &js ) ) ) return false; const LONG values[] = { - js.lX, - js.lY, - js.lZ, js.lRx, js.lRy, js.lRz, + js.lX, + js.lY, + js.lZ, js.rglSlider[0], js.rglSlider[1] }; - const double max[] = { + const double limits[] = { 100, 100, 100, @@ -217,7 +224,12 @@ start: data[i] = 0; } else { - data[i] = values[i] * max[i] / (double) AXIS_MAX; + auto mid = (min_[idx] + max_[idx]) / 2; + auto val = values[idx] - mid; + + auto max = (max_[idx] - min_[idx]) / 2; + auto min = (min_[idx] - max_[idx]) / -2; + data[i] = val * limits[i] / (double) (val >= 0 ? max : min); } } diff --git a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h index 813640d3..9dd335cd 100644 --- a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h +++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h @@ -28,8 +28,6 @@ #include #include -#define AXIS_MAX 16383 - struct DI_ENUM_CONTEXT { GUID preferred_instance; @@ -49,6 +47,7 @@ public: LPDIRECTINPUT8 g_pDI; LPDIRECTINPUTDEVICE8 g_pJoystick; int axes[6]; + int min_[8], max_[8]; GUID preferred; int joyid; QMutex mtx; diff --git a/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp b/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp index 80431b99..af3613d9 100644 --- a/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp +++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp @@ -100,18 +100,18 @@ void TrackerControls::doCancel() { void TrackerControls::loadSettings() { - QSettings settings("opentrack"); // Registry settings (in HK_USER) + 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) + QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); + QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) QComboBox* boxen[] = { - ui.comboBox, - ui.comboBox_2, - ui.comboBox_3, ui.comboBox_4, ui.comboBox_5, ui.comboBox_6, + ui.comboBox, + ui.comboBox_2, + ui.comboBox_3, }; iniFile.beginGroup ( "tracker-joy" ); @@ -120,33 +120,35 @@ void TrackerControls::loadSettings() { boxen[i]->setCurrentIndex(iniFile.value(QString("axis-%1").arg(i), 0).toInt()); } ui.joylist->setCurrentIndex(iniFile.value("joyid", -1).toInt()); - iniFile.endGroup (); + iniFile.endGroup (); - settingsDirty = false; + settingsDirty = false; } 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) + QSettings settings("opentrack"); // Registry settings (in HK_USER) - QComboBox* boxen[] = { - ui.comboBox, - ui.comboBox_2, - ui.comboBox_3, - ui.comboBox_4, - ui.comboBox_5, - ui.comboBox_6, - }; - - iniFile.beginGroup ( "tracker-joy" ); - for (int i = 0; i < 6; i++) + QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); { - iniFile.setValue(QString("axis-%1").arg(i), boxen[i]->currentIndex()); + QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) + + QComboBox* boxen[] = { + ui.comboBox_4, + ui.comboBox_5, + ui.comboBox_6, + ui.comboBox, + ui.comboBox_2, + ui.comboBox_3, + }; + + iniFile.beginGroup ( "tracker-joy" ); + for (int i = 0; i < 6; i++) + { + iniFile.setValue(QString("axis-%1").arg(i), boxen[i]->currentIndex()); + } + iniFile.setValue("joyid", ui.joylist->currentIndex()); + iniFile.endGroup (); } - iniFile.setValue("joyid", ui.joylist->currentIndex()); - iniFile.endGroup (); if(tracker) { -- cgit v1.2.3 From 8769b18f24c7866d6e7c59494acd7f4369dbe18d Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 25 Oct 2013 00:31:27 +0200 Subject: ht: senseless tweaks inbound Signed-off-by: Stanislaw Halik --- ftnoir_tracker_ht/ftnoir_tracker_ht.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp index 010741c6..db0ef6d6 100644 --- a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp +++ b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp @@ -99,8 +99,8 @@ static void load_settings(ht_config_t* config, Tracker* tracker) config->field_of_view = iniFile.value("fov", 52).toFloat(); config->pyrlk_pyramids = 2; config->pyrlk_win_size_w = config->pyrlk_win_size_h = 21; - config->max_keypoints = 250; - config->keypoint_distance = 4.2; + config->max_keypoints = 300; + config->keypoint_distance = 4.3; //config->force_width = 640; //config->force_height = 480; config->force_fps = iniFile.value("fps", 0).toInt(); @@ -111,7 +111,7 @@ static void load_settings(ht_config_t* config, Tracker* tracker) config->ransac_abs_max_mean_error = 15; config->ransac_max_mean_error = 4.5; config->debug = 0; - config->ransac_min_features = 0.78; + config->ransac_min_features = 0.76; int res = iniFile.value("resolution", 0).toInt(); if (res < 0 || res >= (int)(sizeof(resolution_choices) / sizeof(resolution_tuple))) res = 0; -- cgit v1.2.3 From e4d69fcaaca33952ed0c807500a4e93bbc0a365b Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 25 Oct 2013 04:15:00 +0200 Subject: remove faceapi Signed-off-by: Stanislaw Halik --- 3rdparty-notices/SM-FACEAPI-COPYING.txt | 9 - CMakeLists.txt | 1111 +++++++++----------- faceapi/build_options.h | 8 - faceapi/ftnoir-faceapi-wrapper.exe.manifest | 15 - faceapi/ftnoir-faceapi-wrapper.rc | 2 - faceapi/lock.h | 35 - faceapi/lockfree.h | 65 -- faceapi/main.cpp | 529 ---------- faceapi/mutex.h | 46 - faceapi/stdafx.cpp | 8 - faceapi/stdafx.h | 36 - faceapi/utils.h | 349 ------ ftnoir_tracker_sm/ftnoir_sm_controls.ui | 223 ---- ftnoir_tracker_sm/ftnoir_tracker_faceapi.cpp | 220 ---- .../ftnoir_tracker_faceapi_dialog.cpp | 188 ---- ftnoir_tracker_sm/ftnoir_tracker_faceapi_dll.cpp | 72 -- ftnoir_tracker_sm/ftnoir_tracker_sm.h | 120 --- ftnoir_tracker_sm/ftnoir_tracker_sm_types.h | 36 - ftnoir_tracker_sm/images/sm.png | Bin 1263 -> 0 bytes ftnoir_tracker_sm/sm-tracker.qrc | 5 - 20 files changed, 523 insertions(+), 2554 deletions(-) delete mode 100644 3rdparty-notices/SM-FACEAPI-COPYING.txt delete mode 100644 faceapi/build_options.h delete mode 100644 faceapi/ftnoir-faceapi-wrapper.exe.manifest delete mode 100644 faceapi/ftnoir-faceapi-wrapper.rc delete mode 100644 faceapi/lock.h delete mode 100644 faceapi/lockfree.h delete mode 100644 faceapi/main.cpp delete mode 100644 faceapi/mutex.h delete mode 100644 faceapi/stdafx.cpp delete mode 100644 faceapi/stdafx.h delete mode 100644 faceapi/utils.h delete mode 100644 ftnoir_tracker_sm/ftnoir_sm_controls.ui delete mode 100644 ftnoir_tracker_sm/ftnoir_tracker_faceapi.cpp delete mode 100644 ftnoir_tracker_sm/ftnoir_tracker_faceapi_dialog.cpp delete mode 100644 ftnoir_tracker_sm/ftnoir_tracker_faceapi_dll.cpp delete mode 100644 ftnoir_tracker_sm/ftnoir_tracker_sm.h delete mode 100644 ftnoir_tracker_sm/ftnoir_tracker_sm_types.h delete mode 100644 ftnoir_tracker_sm/images/sm.png delete mode 100644 ftnoir_tracker_sm/sm-tracker.qrc diff --git a/3rdparty-notices/SM-FACEAPI-COPYING.txt b/3rdparty-notices/SM-FACEAPI-COPYING.txt deleted file mode 100644 index b317bb76..00000000 --- a/3rdparty-notices/SM-FACEAPI-COPYING.txt +++ /dev/null @@ -1,9 +0,0 @@ --------------------------------------------------------------------------------- -FaceTrackingAPI Version 3.2.6 - August 2010 -Copyright (C) 2010 Seeing Machines Limited --------------------------------------------------------------------------------- - -The use of this API is strictly governed by the terms of a mandatory -prior license agreement between the user and Seeing Machines Ltd. - --------------------------------------------------------------------------------- \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index dd5c0317..46931cac 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,15 +44,11 @@ endif() if(UNIX) set(SDK_ENABLE_LIBEVDEV FALSE CACHE BOOL "libevdev virtual joystick protocol support (probably Linux only)") endif() -if(WIN32) - SET(SDK_FACEAPI_ONLY FALSE CACHE BOOL "FaceAPI only (MSVC 2005)") -endif() if(WIN32) SET(SDK_CONSOLE_DEBUG FALSE CACHE BOOL "Console build") endif() IF(WIN32) - SET(SDK_SM_FACEAPI_PATH "" CACHE PATH "SeeingMachines FaceAPI SDK path") SET(SDK_VJOY "" CACHE PATH "VJoy SDK path") ENDIF() SET(SDK_HYDRA "" CACHE PATH "libSixense path") @@ -60,10 +56,8 @@ SET(SDK_HYDRA_AMD64 FALSE CACHE BOOL "whether target is amd64 (else ia-32)") SET(SDK_RIFT "" CACHE PATH "libOVR path") -file(GLOB opentrack-faceapi-wrapper-c "faceapi/*.cpp") include_directories(${CMAKE_SOURCE_DIR}) -if(NOT SDK_FACEAPI_ONLY) find_package(OpenCV) find_package(Qt5 REQUIRED COMPONENTS Core Xml Network Widgets Gui QUIET) cmake_policy(SET CMP0020 NEW) @@ -80,7 +74,6 @@ if(NOT SDK_FACEAPI_ONLY) SET(SDK_OPENCV_STATIC FALSE CACHE BOOL "Whether OpenCV is statically linked") if(WIN32) - SET(SDK_SM_FACEAPI_PATH "" CACHE PATH "SeeingMachines FaceAPI SDK path") set(SDK_SIMCONNECT "" CACHE PATH "Path to SimConnect SDK") set(SDK_DIRECTX "" CACHE PATH "Path to DirectX SDK") set(SDK_FSUIPC "" CACHE PATH "Path to FSUIPC") @@ -117,702 +110,644 @@ if(SDK_FSUIPC AND WIN32) link_directories("${SDK_FSUIPC}") endif() -if(NOT SDK_FACEAPI_ONLY) # Qxt bundled :: sorry for this, but gentoo ebuild is broken - if(APPLE) - set(qxt-mini-c qxt-mini/plat/qxtglobalshortcut_mac.cpp qxt-mini/qxtglobalshortcut.cpp) +if(APPLE) + set(qxt-mini-c qxt-mini/plat/qxtglobalshortcut_mac.cpp qxt-mini/qxtglobalshortcut.cpp) + include_directories("qxt-mini/") +else() + if(UNIX) + set(qxt-mini-c qxt-mini/plat/qxtglobalshortcut_x11.cpp qxt-mini/qxtglobalshortcut.cpp) include_directories("qxt-mini/") - else() - if(UNIX) - set(qxt-mini-c qxt-mini/plat/qxtglobalshortcut_x11.cpp qxt-mini/qxtglobalshortcut.cpp) - include_directories("qxt-mini/") - endif() endif() +endif() # main app - file(GLOB opentrack-bin-c "facetracknoir/*.cpp" "facetracknoir/*.rc") - file(GLOB opentrack-bin-h "facetracknoir/*.h") - file(GLOB opentrack-bin-ui "facetracknoir/*.ui") - file(GLOB opentrack-bin-rc "facetracknoir/*.qrc") - QT5_WRAP_UI(opentrack-bin-uih ${opentrack-bin-ui}) - QT5_ADD_RESOURCES(opentrack-bin-rcc ${opentrack-bin-rc}) +file(GLOB opentrack-bin-c "facetracknoir/*.cpp" "facetracknoir/*.rc") +file(GLOB opentrack-bin-h "facetracknoir/*.h") +file(GLOB opentrack-bin-ui "facetracknoir/*.ui") +file(GLOB opentrack-bin-rc "facetracknoir/*.qrc") +QT5_WRAP_UI(opentrack-bin-uih ${opentrack-bin-ui}) +QT5_ADD_RESOURCES(opentrack-bin-rcc ${opentrack-bin-rc}) - file(GLOB opentrack-pose-widget-c "ftnoir_posewidget/*.cpp") - file(GLOB opentrack-pose-widget-h "ftnoir_posewidget/*.h") - file(GLOB opentrack-pose-widget-rc "ftnoir_posewidget/*.qrc") - QT5_ADD_RESOURCES(opentrack-pose-widget-rcc ${opentrack-pose-widget-rc}) +file(GLOB opentrack-pose-widget-c "ftnoir_posewidget/*.cpp") +file(GLOB opentrack-pose-widget-h "ftnoir_posewidget/*.h") +file(GLOB opentrack-pose-widget-rc "ftnoir_posewidget/*.qrc") +QT5_ADD_RESOURCES(opentrack-pose-widget-rcc ${opentrack-pose-widget-rc}) - file(GLOB opentrack-spline-widget-c "qfunctionconfigurator/*.cpp") - file(GLOB opentrack-spline-widget-h "qfunctionconfigurator/*.h") +file(GLOB opentrack-spline-widget-c "qfunctionconfigurator/*.cpp") +file(GLOB opentrack-spline-widget-h "qfunctionconfigurator/*.h") # filters - file(GLOB opentrack-filter-accela-c "ftnoir_filter_accela/*.cpp") - file(GLOB opentrack-filter-accela-h "ftnoir_filter_accela/*.h") - file(GLOB opentrack-filter-accela-ui "ftnoir_filter_accela/*.ui") - file(GLOB opentrack-filter-accela-rc "ftnoir_filter_accela/*.qrc") - QT5_WRAP_UI(opentrack-filter-accela-uih ${opentrack-filter-accela-ui}) - QT5_ADD_RESOURCES(opentrack-filter-accela-rcc ${opentrack-filter-accela-rc}) +file(GLOB opentrack-filter-accela-c "ftnoir_filter_accela/*.cpp") +file(GLOB opentrack-filter-accela-h "ftnoir_filter_accela/*.h") +file(GLOB opentrack-filter-accela-ui "ftnoir_filter_accela/*.ui") +file(GLOB opentrack-filter-accela-rc "ftnoir_filter_accela/*.qrc") +QT5_WRAP_UI(opentrack-filter-accela-uih ${opentrack-filter-accela-ui}) +QT5_ADD_RESOURCES(opentrack-filter-accela-rcc ${opentrack-filter-accela-rc}) - file(GLOB opentrack-filter-ewma-c "ftnoir_filter_ewma2/*.cpp") - file(GLOB opentrack-filter-ewma-h "ftnoir_filter_ewma2/*.h") - file(GLOB opentrack-filter-ewma-ui "ftnoir_filter_ewma2/*.ui") - file(GLOB opentrack-filter-ewma-rc "ftnoir_filter_ewma2/*.qrc") - QT5_WRAP_UI(opentrack-filter-ewma-uih ${opentrack-filter-ewma-ui}) - QT5_ADD_RESOURCES(opentrack-filter-ewma-rcc ${opentrack-filter-ewma-rc}) +file(GLOB opentrack-filter-ewma-c "ftnoir_filter_ewma2/*.cpp") +file(GLOB opentrack-filter-ewma-h "ftnoir_filter_ewma2/*.h") +file(GLOB opentrack-filter-ewma-ui "ftnoir_filter_ewma2/*.ui") +file(GLOB opentrack-filter-ewma-rc "ftnoir_filter_ewma2/*.qrc") +QT5_WRAP_UI(opentrack-filter-ewma-uih ${opentrack-filter-ewma-ui}) +QT5_ADD_RESOURCES(opentrack-filter-ewma-rcc ${opentrack-filter-ewma-rc}) # protocols - file(GLOB opentrack-proto-fgfs-c "ftnoir_protocol_fg/*.cpp") - file(GLOB opentrack-proto-fgfs-h "ftnoir_protocol_fg/*.h") - file(GLOB opentrack-proto-fgfs-ui "ftnoir_protocol_fg/*.ui") - file(GLOB opentrack-proto-fgfs-rc "ftnoir_protocol_fg/*.qrc") - QT5_WRAP_UI(opentrack-proto-fgfs-uih ${opentrack-proto-fgfs-ui}) - QT5_ADD_RESOURCES(opentrack-proto-fgfs-rcc ${opentrack-proto-fgfs-rc}) - - file(GLOB opentrack-proto-fsuipc-c "ftnoir_protocol_fsuipc/*.cpp") - file(GLOB opentrack-proto-fsuipc-h "ftnoir_protocol_fsuipc/*.h") - file(GLOB opentrack-proto-fsuipc-ui "ftnoir_protocol_fsuipc/*.ui") - file(GLOB opentrack-proto-fsuipc-rc "ftnoir_protocol_fsuipc/*.qrc") - QT5_WRAP_UI(opentrack-proto-fsuipc-uih ${opentrack-proto-fsuipc-ui}) - QT5_ADD_RESOURCES(opentrack-proto-fsuipc-rcc ${opentrack-proto-fsuipc-rc}) - - file(GLOB opentrack-proto-freetrack-c "ftnoir_protocol_ft/*.cpp") - file(GLOB opentrack-proto-freetrack-h "ftnoir_protocol_ft/*.h") - file(GLOB opentrack-proto-freetrack-ui "ftnoir_protocol_ft/*.ui") - file(GLOB opentrack-proto-freetrack-rc "ftnoir_protocol_ft/*.qrc") - QT5_WRAP_UI(opentrack-proto-freetrack-uih ${opentrack-proto-freetrack-ui}) - QT5_ADD_RESOURCES(opentrack-proto-freetrack-rcc ${opentrack-proto-freetrack-rc}) - - file(GLOB opentrack-proto-udp-c "ftnoir_protocol_ftn/*.cpp") - file(GLOB opentrack-proto-udp-h "ftnoir_protocol_ftn/*.h") - file(GLOB opentrack-proto-udp-ui "ftnoir_protocol_ftn/*.ui") - file(GLOB opentrack-proto-udp-rc "ftnoir_protocol_ftn/*.qrc") - QT5_WRAP_UI(opentrack-proto-udp-uih ${opentrack-proto-udp-ui}) - QT5_ADD_RESOURCES(opentrack-proto-udp-rcc ${opentrack-proto-udp-rc}) - - file(GLOB opentrack-proto-wine-c "ftnoir_protocol_wine/*.cpp") - file(GLOB opentrack-proto-wine-h "ftnoir_protocol_wine/*.h") - file(GLOB opentrack-proto-wine-ui "ftnoir_protocol_wine/*.ui") - file(GLOB opentrack-proto-wine-rc "ftnoir_protocol_wine/*.qrc") - QT5_WRAP_UI(opentrack-proto-wine-uih ${opentrack-proto-wine-ui}) - QT5_ADD_RESOURCES(opentrack-proto-wine-rcc ${opentrack-proto-wine-rc}) - - file(GLOB opentrack-proto-win32-mouse-c "ftnoir_protocol_mouse/*.cpp") - file(GLOB opentrack-proto-win32-mouse-h "ftnoir_protocol_mouse/*.h") - file(GLOB opentrack-proto-win32-mouse-ui "ftnoir_protocol_mouse/*.ui") - file(GLOB opentrack-proto-win32-mouse-rc "ftnoir_protocol_mouse/*.qrc") - QT5_WRAP_UI(opentrack-proto-win32-mouse-uih ${opentrack-proto-win32-mouse-ui}) - QT5_ADD_RESOURCES(opentrack-proto-win32-mouse-rcc ${opentrack-proto-win32-mouse-rc}) - - file(GLOB opentrack-proto-simconnect-c "ftnoir_protocol_sc/*.cpp" "ftnoir_protocol_sc/ftnoir-protocol-sc.rc") - file(GLOB opentrack-proto-simconnect-h "ftnoir_protocol_sc/*.h") - file(GLOB opentrack-proto-simconnect-ui "ftnoir_protocol_sc/*.ui") - file(GLOB opentrack-proto-simconnect-rc "ftnoir_protocol_sc/*.qrc") - QT5_WRAP_UI(opentrack-proto-simconnect-uih ${opentrack-proto-simconnect-ui}) - QT5_ADD_RESOURCES(opentrack-proto-simconnect-rcc ${opentrack-proto-simconnect-rc}) - - file(GLOB opentrack-proto-vjoy-c "ftnoir_protocol_vjoy/*.cpp") - file(GLOB opentrack-proto-vjoy-h "ftnoir_protocol_vjoy/*.h") - file(GLOB opentrack-proto-vjoy-ui "ftnoir_protocol_vjoy/*.ui") - file(GLOB opentrack-proto-vjoy-rc "ftnoir_protocol_vjoy/*.qrc") - QT5_WRAP_UI(opentrack-proto-vjoy-uih ${opentrack-proto-vjoy-ui}) - QT5_ADD_RESOURCES(opentrack-proto-vjoy-rcc ${opentrack-proto-vjoy-rc}) - - file(GLOB opentrack-proto-libevdev-c "ftnoir_protocol_libevdev/*.cpp") - file(GLOB opentrack-proto-libevdev-h "ftnoir_protocol_libevdev/*.h") - file(GLOB opentrack-proto-libevdev-ui "ftnoir_protocol_libevdev/*.ui") - file(GLOB opentrack-proto-libevdev-rc "ftnoir_protocol_libevdev/*.qrc") - QT5_WRAP_UI(opentrack-proto-libevdev-uih ${opentrack-proto-libevdev-ui}) - QT5_ADD_RESOURCES(opentrack-proto-libevdev-rcc ${opentrack-proto-libevdev-rc}) +file(GLOB opentrack-proto-fgfs-c "ftnoir_protocol_fg/*.cpp") +file(GLOB opentrack-proto-fgfs-h "ftnoir_protocol_fg/*.h") +file(GLOB opentrack-proto-fgfs-ui "ftnoir_protocol_fg/*.ui") +file(GLOB opentrack-proto-fgfs-rc "ftnoir_protocol_fg/*.qrc") +QT5_WRAP_UI(opentrack-proto-fgfs-uih ${opentrack-proto-fgfs-ui}) +QT5_ADD_RESOURCES(opentrack-proto-fgfs-rcc ${opentrack-proto-fgfs-rc}) + +file(GLOB opentrack-proto-fsuipc-c "ftnoir_protocol_fsuipc/*.cpp") +file(GLOB opentrack-proto-fsuipc-h "ftnoir_protocol_fsuipc/*.h") +file(GLOB opentrack-proto-fsuipc-ui "ftnoir_protocol_fsuipc/*.ui") +file(GLOB opentrack-proto-fsuipc-rc "ftnoir_protocol_fsuipc/*.qrc") +QT5_WRAP_UI(opentrack-proto-fsuipc-uih ${opentrack-proto-fsuipc-ui}) +QT5_ADD_RESOURCES(opentrack-proto-fsuipc-rcc ${opentrack-proto-fsuipc-rc}) + +file(GLOB opentrack-proto-freetrack-c "ftnoir_protocol_ft/*.cpp") +file(GLOB opentrack-proto-freetrack-h "ftnoir_protocol_ft/*.h") +file(GLOB opentrack-proto-freetrack-ui "ftnoir_protocol_ft/*.ui") +file(GLOB opentrack-proto-freetrack-rc "ftnoir_protocol_ft/*.qrc") +QT5_WRAP_UI(opentrack-proto-freetrack-uih ${opentrack-proto-freetrack-ui}) +QT5_ADD_RESOURCES(opentrack-proto-freetrack-rcc ${opentrack-proto-freetrack-rc}) + +file(GLOB opentrack-proto-udp-c "ftnoir_protocol_ftn/*.cpp") +file(GLOB opentrack-proto-udp-h "ftnoir_protocol_ftn/*.h") +file(GLOB opentrack-proto-udp-ui "ftnoir_protocol_ftn/*.ui") +file(GLOB opentrack-proto-udp-rc "ftnoir_protocol_ftn/*.qrc") +QT5_WRAP_UI(opentrack-proto-udp-uih ${opentrack-proto-udp-ui}) +QT5_ADD_RESOURCES(opentrack-proto-udp-rcc ${opentrack-proto-udp-rc}) + +file(GLOB opentrack-proto-wine-c "ftnoir_protocol_wine/*.cpp") +file(GLOB opentrack-proto-wine-h "ftnoir_protocol_wine/*.h") +file(GLOB opentrack-proto-wine-ui "ftnoir_protocol_wine/*.ui") +file(GLOB opentrack-proto-wine-rc "ftnoir_protocol_wine/*.qrc") +QT5_WRAP_UI(opentrack-proto-wine-uih ${opentrack-proto-wine-ui}) +QT5_ADD_RESOURCES(opentrack-proto-wine-rcc ${opentrack-proto-wine-rc}) + +file(GLOB opentrack-proto-win32-mouse-c "ftnoir_protocol_mouse/*.cpp") +file(GLOB opentrack-proto-win32-mouse-h "ftnoir_protocol_mouse/*.h") +file(GLOB opentrack-proto-win32-mouse-ui "ftnoir_protocol_mouse/*.ui") +file(GLOB opentrack-proto-win32-mouse-rc "ftnoir_protocol_mouse/*.qrc") +QT5_WRAP_UI(opentrack-proto-win32-mouse-uih ${opentrack-proto-win32-mouse-ui}) +QT5_ADD_RESOURCES(opentrack-proto-win32-mouse-rcc ${opentrack-proto-win32-mouse-rc}) + +file(GLOB opentrack-proto-simconnect-c "ftnoir_protocol_sc/*.cpp" "ftnoir_protocol_sc/ftnoir-protocol-sc.rc") +file(GLOB opentrack-proto-simconnect-h "ftnoir_protocol_sc/*.h") +file(GLOB opentrack-proto-simconnect-ui "ftnoir_protocol_sc/*.ui") +file(GLOB opentrack-proto-simconnect-rc "ftnoir_protocol_sc/*.qrc") +QT5_WRAP_UI(opentrack-proto-simconnect-uih ${opentrack-proto-simconnect-ui}) +QT5_ADD_RESOURCES(opentrack-proto-simconnect-rcc ${opentrack-proto-simconnect-rc}) + +file(GLOB opentrack-proto-vjoy-c "ftnoir_protocol_vjoy/*.cpp") +file(GLOB opentrack-proto-vjoy-h "ftnoir_protocol_vjoy/*.h") +file(GLOB opentrack-proto-vjoy-ui "ftnoir_protocol_vjoy/*.ui") +file(GLOB opentrack-proto-vjoy-rc "ftnoir_protocol_vjoy/*.qrc") +QT5_WRAP_UI(opentrack-proto-vjoy-uih ${opentrack-proto-vjoy-ui}) +QT5_ADD_RESOURCES(opentrack-proto-vjoy-rcc ${opentrack-proto-vjoy-rc}) + +file(GLOB opentrack-proto-libevdev-c "ftnoir_protocol_libevdev/*.cpp") +file(GLOB opentrack-proto-libevdev-h "ftnoir_protocol_libevdev/*.h") +file(GLOB opentrack-proto-libevdev-ui "ftnoir_protocol_libevdev/*.ui") +file(GLOB opentrack-proto-libevdev-rc "ftnoir_protocol_libevdev/*.qrc") +QT5_WRAP_UI(opentrack-proto-libevdev-uih ${opentrack-proto-libevdev-ui}) +QT5_ADD_RESOURCES(opentrack-proto-libevdev-rcc ${opentrack-proto-libevdev-rc}) # trackers - file(GLOB opentrack-tracker-ht-c "ftnoir_tracker_ht/*.cpp") - file(GLOB opentrack-tracker-ht-h "ftnoir_tracker_ht/*.h") - file(GLOB opentrack-tracker-ht-ui "ftnoir_tracker_ht/*.ui") - file(GLOB opentrack-tracker-ht-rc "ftnoir_tracker_ht/*.qrc") - QT5_WRAP_UI(opentrack-tracker-ht-uih ${opentrack-tracker-ht-ui}) - QT5_ADD_RESOURCES(opentrack-tracker-ht-rcc ${opentrack-tracker-ht-rc}) - - file(GLOB opentrack-tracker-aruco-c "ftnoir_tracker_aruco/*.cpp") - file(GLOB opentrack-tracker-aruco-h "ftnoir_tracker_aruco/*.h") - file(GLOB opentrack-tracker-aruco-ui "ftnoir_tracker_aruco/*.ui") - file(GLOB opentrack-tracker-aruco-rc "ftnoir_tracker_aruco/*.qrc") - QT5_WRAP_UI(opentracktracker-aruco-uih ${opentrack-tracker-aruco-ui}) - QT5_ADD_RESOURCES(opentrack-tracker-aruco-rcc ${opentrack-tracker-aruco-rc}) - - file(GLOB opentrack-tracker-pt-c "FTNoIR_Tracker_PT/*.cpp") - file(GLOB opentrack-tracker-pt-h "FTNoIR_Tracker_PT/*.h") - file(GLOB opentrack-tracker-pt-ui "FTNoIR_Tracker_PT/*.ui") - file(GLOB opentrack-tracker-pt-rc "FTNoIR_Tracker_PT/*.qrc") - QT5_WRAP_UI(opentrack-tracker-pt-uih ${opentrack-tracker-pt-ui}) - QT5_ADD_RESOURCES(opentrack-tracker-pt-rcc ${opentrack-tracker-pt-rc}) - - file(GLOB opentrack-tracker-udp-c "ftnoir_tracker_udp/*.cpp") - file(GLOB opentrack-tracker-udp-h "ftnoir_tracker_udp/*.h") - file(GLOB opentrack-tracker-udp-ui "ftnoir_tracker_udp/*.ui") - file(GLOB opentrack-tracker-udp-rc "ftnoir_tracker_udp/*.qrc") - QT5_WRAP_UI(opentrack-tracker-udp-uih ${opentrack-tracker-udp-ui}) - QT5_ADD_RESOURCES(opentrack-tracker-udp-rcc ${opentrack-tracker-udp-rc}) - - file(GLOB opentrack-tracker-joystick-c "ftnoir_tracker_joystick/*.cpp") - file(GLOB opentrack-tracker-joystick-h "ftnoir_tracker_joystick/*.h") - file(GLOB opentrack-tracker-joystick-ui "ftnoir_tracker_joystick/*.ui") - file(GLOB opentrack-tracker-joystick-rc "ftnoir_tracker_joystick/*.qrc") - QT5_WRAP_UI(opentrack-tracker-joystick-uih ${opentrack-tracker-joystick-ui}) - QT5_ADD_RESOURCES(opentrack-tracker-joystick-rcc ${opentrack-tracker-joystick-rc}) - - file(GLOB opentrack-tracker-rift-c "ftnoir_tracker_rift/*.cpp") - file(GLOB opentrack-tracker-rift-h "ftnoir_tracker_rift/*.h") - file(GLOB opentrack-tracker-rift-ui "ftnoir_tracker_rift/*.ui") - file(GLOB opentrack-tracker-rift-rc "ftnoir_tracker_rift/*.qrc") - QT5_WRAP_UI(opentrack-tracker-rift-uih ${opentrack-tracker-rift-ui}) - QT5_ADD_RESOURCES(opentrack-tracker-rift-rcc ${opentrack-tracker-rift-rc}) - - file(GLOB opentrack-tracker-hydra-c "ftnoir_tracker_hydra/*.cpp") - file(GLOB opentrack-tracker-hydra-h "ftnoir_tracker_hydra/*.h") - file(GLOB opentrack-tracker-hydra-ui "ftnoir_tracker_hydra/*.ui") - 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-faceapi-c "ftnoir_tracker_sm/*.cpp") - file(GLOB opentrack-tracker-faceapi-h "ftnoir_tracker_sm/*.h") - file(GLOB opentrack-tracker-faceapi-ui "ftnoir_tracker_sm/*.ui") - file(GLOB opentrack-tracker-faceapi-rc "ftnoir_tracker_sm/*.qrc") - QT5_WRAP_UI(opentrack-tracker-faceapi-uih ${opentrack-tracker-faceapi-ui}) - QT5_ADD_RESOURCES(opentrack-tracker-faceapi-rcc ${opentrack-tracker-faceapi-rc}) - - file(GLOB opentrack-csv-c "ftnoir_csv/*.cpp") +file(GLOB opentrack-tracker-ht-c "ftnoir_tracker_ht/*.cpp") +file(GLOB opentrack-tracker-ht-h "ftnoir_tracker_ht/*.h") +file(GLOB opentrack-tracker-ht-ui "ftnoir_tracker_ht/*.ui") +file(GLOB opentrack-tracker-ht-rc "ftnoir_tracker_ht/*.qrc") +QT5_WRAP_UI(opentrack-tracker-ht-uih ${opentrack-tracker-ht-ui}) +QT5_ADD_RESOURCES(opentrack-tracker-ht-rcc ${opentrack-tracker-ht-rc}) + +file(GLOB opentrack-tracker-aruco-c "ftnoir_tracker_aruco/*.cpp") +file(GLOB opentrack-tracker-aruco-h "ftnoir_tracker_aruco/*.h") +file(GLOB opentrack-tracker-aruco-ui "ftnoir_tracker_aruco/*.ui") +file(GLOB opentrack-tracker-aruco-rc "ftnoir_tracker_aruco/*.qrc") +QT5_WRAP_UI(opentracktracker-aruco-uih ${opentrack-tracker-aruco-ui}) +QT5_ADD_RESOURCES(opentrack-tracker-aruco-rcc ${opentrack-tracker-aruco-rc}) + +file(GLOB opentrack-tracker-pt-c "FTNoIR_Tracker_PT/*.cpp") +file(GLOB opentrack-tracker-pt-h "FTNoIR_Tracker_PT/*.h") +file(GLOB opentrack-tracker-pt-ui "FTNoIR_Tracker_PT/*.ui") +file(GLOB opentrack-tracker-pt-rc "FTNoIR_Tracker_PT/*.qrc") +QT5_WRAP_UI(opentrack-tracker-pt-uih ${opentrack-tracker-pt-ui}) +QT5_ADD_RESOURCES(opentrack-tracker-pt-rcc ${opentrack-tracker-pt-rc}) + +file(GLOB opentrack-tracker-udp-c "ftnoir_tracker_udp/*.cpp") +file(GLOB opentrack-tracker-udp-h "ftnoir_tracker_udp/*.h") +file(GLOB opentrack-tracker-udp-ui "ftnoir_tracker_udp/*.ui") +file(GLOB opentrack-tracker-udp-rc "ftnoir_tracker_udp/*.qrc") +QT5_WRAP_UI(opentrack-tracker-udp-uih ${opentrack-tracker-udp-ui}) +QT5_ADD_RESOURCES(opentrack-tracker-udp-rcc ${opentrack-tracker-udp-rc}) + +file(GLOB opentrack-tracker-joystick-c "ftnoir_tracker_joystick/*.cpp") +file(GLOB opentrack-tracker-joystick-h "ftnoir_tracker_joystick/*.h") +file(GLOB opentrack-tracker-joystick-ui "ftnoir_tracker_joystick/*.ui") +file(GLOB opentrack-tracker-joystick-rc "ftnoir_tracker_joystick/*.qrc") +QT5_WRAP_UI(opentrack-tracker-joystick-uih ${opentrack-tracker-joystick-ui}) +QT5_ADD_RESOURCES(opentrack-tracker-joystick-rcc ${opentrack-tracker-joystick-rc}) + +file(GLOB opentrack-tracker-rift-c "ftnoir_tracker_rift/*.cpp") +file(GLOB opentrack-tracker-rift-h "ftnoir_tracker_rift/*.h") +file(GLOB opentrack-tracker-rift-ui "ftnoir_tracker_rift/*.ui") +file(GLOB opentrack-tracker-rift-rc "ftnoir_tracker_rift/*.qrc") +QT5_WRAP_UI(opentrack-tracker-rift-uih ${opentrack-tracker-rift-ui}) +QT5_ADD_RESOURCES(opentrack-tracker-rift-rcc ${opentrack-tracker-rift-rc}) + +file(GLOB opentrack-tracker-hydra-c "ftnoir_tracker_hydra/*.cpp") +file(GLOB opentrack-tracker-hydra-h "ftnoir_tracker_hydra/*.h") +file(GLOB opentrack-tracker-hydra-ui "ftnoir_tracker_hydra/*.ui") +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-csv-c "ftnoir_csv/*.cpp") # compat lib for POSIX/win32 - file(GLOB opentrack-compat-c "compat/*.cpp") +file(GLOB opentrack-compat-c "compat/*.cpp") # x-plane plugin - file(GLOB opentrack-xplane-plugin-c "x-plane-plugin/*.c") - +file(GLOB opentrack-xplane-plugin-c "x-plane-plugin/*.c") + # freetrack - file(GLOB opentrack-freetrack-c "freetrackclient/*.cpp") +file(GLOB opentrack-freetrack-c "freetrackclient/*.cpp") - if(SDK_XPLANE) - # probably librt already included - add_library(opentrack-xplane-plugin SHARED ${opentrack-xplane-plugin-c}) - if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) - SET_TARGET_PROPERTIES(opentrack-xplane-plugin - PROPERTIES LINK_FLAGS - "-Wl,--version-script=${CMAKE_SOURCE_DIR}/x-plane-plugin/version-script.txt -shared -rdynamic -nodefaultlibs -undefined_warning -fPIC" - COMPILE_FLAGS "-Wall -O2 -pipe -fPIC -DLIN -DXPLM210" - LIBRARY_OUTPUT_NAME "facetracknoir.xpl" - PREFIX "" SUFFIX "") - endif() +if(SDK_XPLANE) + # probably librt already included + add_library(opentrack-xplane-plugin SHARED ${opentrack-xplane-plugin-c}) + if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) + SET_TARGET_PROPERTIES(opentrack-xplane-plugin + PROPERTIES LINK_FLAGS + "-Wl,--version-script=${CMAKE_SOURCE_DIR}/x-plane-plugin/version-script.txt -shared -rdynamic -nodefaultlibs -undefined_warning -fPIC" + COMPILE_FLAGS "-Wall -O2 -pipe -fPIC -DLIN -DXPLM210" + LIBRARY_OUTPUT_NAME "facetracknoir.xpl" + PREFIX "" SUFFIX "") endif() endif() # some boilerplate - if(QT_USE_FILE) - INCLUDE(${QT_USE_FILE}) - endif() +if(QT_USE_FILE) + INCLUDE(${QT_USE_FILE}) +endif() - if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) - SET (CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS_INIT} -rdynamic CACHE STRING "Flags used by the linker during the creation of dll's.") - SET (CMAKE_MODULE_LINKER_FLAGS ${CMAKE_MODULE_LINKER_FLAGS_INIT} -rdynamic CACHE STRING "Flags used by the linker during the creation of modules.") - SET (CMAKE_MODULE_LINKER_FLAGS ${CMAKE_MODULE_LINKER_FLAGS_INIT} -rdynamic CACHE STRING "Flags used by the linker during the creation of modules.") - endif() +if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) + SET (CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS_INIT} -rdynamic CACHE STRING "Flags used by the linker during the creation of dll's.") + SET (CMAKE_MODULE_LINKER_FLAGS ${CMAKE_MODULE_LINKER_FLAGS_INIT} -rdynamic CACHE STRING "Flags used by the linker during the creation of modules.") + 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} ${opentrack-compat-h}) - if(NOT WIN32) - target_link_libraries(opentrack-compat rt) +add_library(opentrack-compat SHARED ${opentrack-compat-c} ${opentrack-compat-h}) +if(NOT WIN32) + target_link_libraries(opentrack-compat rt) +endif() + + # hack to avoid breakage on buildbot + set(my-qt-deps) + 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}) - # hack to avoid breakage on buildbot - set(my-qt-deps) - 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}) +add_library(opentrack-csv SHARED ${opentrack-csv-c} ${opentrack-csv-h}) +target_link_libraries(opentrack-csv ${MY_QT_LIBS}) - add_library(opentrack-csv SHARED ${opentrack-csv-c} ${opentrack-csv-h}) - target_link_libraries(opentrack-csv ${MY_QT_LIBS}) +add_library(opentrack-pose-widget SHARED ${opentrack-pose-widget-c} ${opentrack-pose-widget-h} ${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-h} ${opentrack-spline-widget-moc}) +target_link_libraries(opentrack-spline-widget ${MY_QT_LIBS} ${QT_QTDESIGNER_LIBRARY_RELEASE}) - add_library(opentrack-pose-widget SHARED ${opentrack-pose-widget-c} ${opentrack-pose-widget-h} ${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-h} ${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-h} ${opentrack-filter-accela-moc} ${opentrack-filter-accela-uih} ${opentrack-filter-accela-rcc}) +target_link_libraries(opentrack-filter-accela ${MY_QT_LIBS}) - add_library(opentrack-filter-accela SHARED ${opentrack-filter-accela-c} ${opentrack-filter-accela-h} ${opentrack-filter-accela-moc} ${opentrack-filter-accela-uih} ${opentrack-filter-accela-rcc}) - target_link_libraries(opentrack-filter-accela ${MY_QT_LIBS}) +if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) + SET_TARGET_PROPERTIES(opentrack-filter-accela + PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt") +endif() - if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) - SET_TARGET_PROPERTIES(opentrack-filter-accela - PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt") - endif() +add_library(opentrack-filter-ewma SHARED ${opentrack-filter-ewma-uih} ${opentrack-filter-ewma-c} ${opentrack-filter-ewma-h} ${opentrack-filter-ewma-moc} ${opentrack-filter-ewma-rcc}) +target_link_libraries(opentrack-filter-ewma ${MY_QT_LIBS}) + +if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) + SET_TARGET_PROPERTIES(opentrack-filter-ewma + PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt") +endif() - add_library(opentrack-filter-ewma SHARED ${opentrack-filter-ewma-uih} ${opentrack-filter-ewma-c} ${opentrack-filter-ewma-h} ${opentrack-filter-ewma-moc} ${opentrack-filter-ewma-rcc}) - target_link_libraries(opentrack-filter-ewma ${MY_QT_LIBS}) +add_library(opentrack-proto-fgfs SHARED ${opentrack-proto-fgfs-c} ${opentrack-proto-fgfs-h} ${opentrack-proto-fgfs-moc} ${opentrack-proto-fgfs-uih} ${opentrack-proto-fgfs-rcc}) +target_link_libraries(opentrack-proto-fgfs ${MY_QT_LIBS}) +if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) + SET_TARGET_PROPERTIES(opentrack-proto-fgfs + PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt") +endif() +if(WIN32 AND SDK_VJOY) + include_directories(${SDK_VJOY}) + add_library(opentrack-proto-vjoy SHARED ${opentrack-proto-vjoy-c} ${opentrack-proto-vjoy-h} ${opentrack-proto-vjoy-moc} ${opentrack-proto-vjoy-uih} ${opentrack-proto-vjoy-rcc}) + if(MSVC) + target_link_libraries(opentrack-proto-vjoy ${MY_QT_LIBS} "${SDK_VJOY}/VJoy.lib") + else() + target_link_libraries(opentrack-proto-vjoy ${MY_QT_LIBS} "${SDK_VJOY}/VJoy.dll") + endif() if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) - SET_TARGET_PROPERTIES(opentrack-filter-ewma - PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt") + SET_TARGET_PROPERTIES(opentrack-proto-vjoy + PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt -Wl,--enable-stdcall-fixup") endif() +endif() - add_library(opentrack-proto-fgfs SHARED ${opentrack-proto-fgfs-c} ${opentrack-proto-fgfs-h} ${opentrack-proto-fgfs-moc} ${opentrack-proto-fgfs-uih} ${opentrack-proto-fgfs-rcc}) - target_link_libraries(opentrack-proto-fgfs ${MY_QT_LIBS}) +if(UNIX AND SDK_ENABLE_LIBEVDEV) + add_library(opentrack-proto-libevdev SHARED ${opentrack-proto-libevdev-c} ${opentrack-proto-libevdev-h} ${opentrack-proto-libevdev-moc} ${opentrack-proto-libevdev-uih} ${opentrack-proto-libevdev-rcc}) + target_link_libraries(opentrack-proto-libevdev ${MY_QT_LIBS} evdev) if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) - SET_TARGET_PROPERTIES(opentrack-proto-fgfs + SET_TARGET_PROPERTIES(opentrack-proto-libevdev PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt") endif() + install(TARGETS opentrack-proto-libevdev DESTINATION .) +endif() - if(WIN32 AND SDK_VJOY) - include_directories(${SDK_VJOY}) - add_library(opentrack-proto-vjoy SHARED ${opentrack-proto-vjoy-c} ${opentrack-proto-vjoy-h} ${opentrack-proto-vjoy-moc} ${opentrack-proto-vjoy-uih} ${opentrack-proto-vjoy-rcc}) +if(WIN32) + if(SDK_FSUIPC) + add_library(opentrack-proto-fsuipc SHARED ${opentrack-proto-fsuipc-c} ${opentrack-proto-fsuipc-h} ${opentrack-proto-fsuipc-moc} ${opentrack-proto-fsuipc-uih} ${opentrack-proto-fsuipc-rcc}) + target_link_libraries(opentrack-proto-fsuipc ${MY_QT_LIBS} "${SDK_FSUIPC}/FSUIPC_User.lib") if(MSVC) - target_link_libraries(opentrack-proto-vjoy ${MY_QT_LIBS} "${SDK_VJOY}/VJoy.lib") - else() - target_link_libraries(opentrack-proto-vjoy ${MY_QT_LIBS} "${SDK_VJOY}/VJoy.dll") - endif() - if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) - SET_TARGET_PROPERTIES(opentrack-proto-vjoy - PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt -Wl,--enable-stdcall-fixup") + set_target_properties(opentrack-proto-fsuipc PROPERTIES LINK_FLAGS "/NODEFAULTLIB:libc") endif() endif() - if(UNIX AND SDK_ENABLE_LIBEVDEV) - add_library(opentrack-proto-libevdev SHARED ${opentrack-proto-libevdev-c} ${opentrack-proto-libevdev-h} ${opentrack-proto-libevdev-moc} ${opentrack-proto-libevdev-uih} ${opentrack-proto-libevdev-rcc}) - target_link_libraries(opentrack-proto-libevdev ${MY_QT_LIBS} evdev) - if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) - SET_TARGET_PROPERTIES(opentrack-proto-libevdev - PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt") - endif() - install(TARGETS opentrack-proto-libevdev DESTINATION .) + if(SDK_SIMCONNECT) + add_library(opentrack-proto-simconnect SHARED ${opentrack-proto-simconnect-c} ${opentrack-proto-simconnect-h} ${opentrack-proto-simconnect-moc} ${opentrack-proto-simconnect-uih} ${opentrack-proto-simconnect-rcc}) + target_link_libraries(opentrack-proto-simconnect ${MY_QT_LIBS}) + include_directories("${SDK_SIMCONNECT}/inc") + target_link_libraries(opentrack-proto-simconnect "${SDK_SIMCONNECT}/lib/SimConnect.lib") endif() - if(WIN32) - if(SDK_FSUIPC) - add_library(opentrack-proto-fsuipc SHARED ${opentrack-proto-fsuipc-c} ${opentrack-proto-fsuipc-h} ${opentrack-proto-fsuipc-moc} ${opentrack-proto-fsuipc-uih} ${opentrack-proto-fsuipc-rcc}) - target_link_libraries(opentrack-proto-fsuipc ${MY_QT_LIBS} "${SDK_FSUIPC}/FSUIPC_User.lib") - if(MSVC) - set_target_properties(opentrack-proto-fsuipc PROPERTIES LINK_FLAGS "/NODEFAULTLIB:libc") - endif() - endif() - - if(SDK_SIMCONNECT) - add_library(opentrack-proto-simconnect SHARED ${opentrack-proto-simconnect-c} ${opentrack-proto-simconnect-h} ${opentrack-proto-simconnect-moc} ${opentrack-proto-simconnect-uih} ${opentrack-proto-simconnect-rcc}) - target_link_libraries(opentrack-proto-simconnect ${MY_QT_LIBS}) - include_directories("${SDK_SIMCONNECT}/inc") - target_link_libraries(opentrack-proto-simconnect "${SDK_SIMCONNECT}/lib/SimConnect.lib") - endif() - - add_library(opentrack-proto-freetrack SHARED ${opentrack-proto-freetrack-c} ${opentrack-proto-freetrack-h} ${opentrack-proto-freetrack-moc} ${opentrack-proto-freetrack-uih} ${opentrack-proto-freetrack-rcc}) - target_link_libraries(opentrack-proto-freetrack opentrack-csv ${MY_QT_LIBS} opentrack-compat) + add_library(opentrack-proto-freetrack SHARED ${opentrack-proto-freetrack-c} ${opentrack-proto-freetrack-h} ${opentrack-proto-freetrack-moc} ${opentrack-proto-freetrack-uih} ${opentrack-proto-freetrack-rcc}) + target_link_libraries(opentrack-proto-freetrack opentrack-csv ${MY_QT_LIBS} opentrack-compat) - add_library(opentrack-proto-win32-mouse SHARED ${opentrack-proto-win32-mouse-c} ${opentrack-proto-win32-mouse-h} ${opentrack-proto-win32-mouse-moc} ${opentrack-proto-win32-mouse-uih} ${opentrack-proto-win32-mouse-rcc}) - target_link_libraries(opentrack-proto-win32-mouse ${MY_QT_LIBS}) - if(CMAKE_COMPILER_IS_GNUCC) - add_library(freetrackclient SHARED ${opentrack-freetrack-c} ${opentrack-freetrack-h} "${CMAKE_SOURCE_DIR}/freetrackclient/freetrackclient.def") - set_target_properties(freetrackclient PROPERTIES LINK_FLAGS "-Wl,--enable-stdcall-fixup") - else() - add_library(freetrackclient SHARED ${opentrack-freetrack-c} ${opentrack-freetrack-h}) - endif() + add_library(opentrack-proto-win32-mouse SHARED ${opentrack-proto-win32-mouse-c} ${opentrack-proto-win32-mouse-h} ${opentrack-proto-win32-mouse-moc} ${opentrack-proto-win32-mouse-uih} ${opentrack-proto-win32-mouse-rcc}) + target_link_libraries(opentrack-proto-win32-mouse ${MY_QT_LIBS}) + if(CMAKE_COMPILER_IS_GNUCC) + add_library(freetrackclient SHARED ${opentrack-freetrack-c} ${opentrack-freetrack-h} "${CMAKE_SOURCE_DIR}/freetrackclient/freetrackclient.def") + set_target_properties(freetrackclient PROPERTIES LINK_FLAGS "-Wl,--enable-stdcall-fixup") + else() + add_library(freetrackclient SHARED ${opentrack-freetrack-c} ${opentrack-freetrack-h}) endif() +endif() + +add_library(opentrack-proto-udp SHARED ${opentrack-proto-udp-c} ${opentrack-proto-udp-h} ${opentrack-proto-udp-moc} ${opentrack-proto-udp-uih} ${opentrack-proto-udp-rcc}) +target_link_libraries(opentrack-proto-udp ${MY_QT_LIBS}) +if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) + SET_TARGET_PROPERTIES(opentrack-proto-udp + PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt") +endif() - add_library(opentrack-proto-udp SHARED ${opentrack-proto-udp-c} ${opentrack-proto-udp-h} ${opentrack-proto-udp-moc} ${opentrack-proto-udp-uih} ${opentrack-proto-udp-rcc}) - target_link_libraries(opentrack-proto-udp ${MY_QT_LIBS}) +if(WIN32) + add_library(opentrack-tracker-joystick SHARED ${opentrack-tracker-joystick-c} ${opentrack-tracker-joystick-h} ${opentrack-tracker-joystick-moc} ${opentrack-tracker-joystick-uih} ${opentrack-tracker-joystick-rcc}) + target_link_libraries(opentrack-tracker-joystick ${MY_QT_LIBS}) if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) - SET_TARGET_PROPERTIES(opentrack-proto-udp + SET_TARGET_PROPERTIES(opentrack-tracker-joystick PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt") endif() +endif() - if(WIN32) - add_library(opentrack-tracker-joystick SHARED ${opentrack-tracker-joystick-c} ${opentrack-tracker-joystick-h} ${opentrack-tracker-joystick-moc} ${opentrack-tracker-joystick-uih} ${opentrack-tracker-joystick-rcc}) - target_link_libraries(opentrack-tracker-joystick ${MY_QT_LIBS}) - if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) - SET_TARGET_PROPERTIES(opentrack-tracker-joystick - PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt") - endif() +if(NOT WIN32 AND SDK_WINE_PREFIX) + add_library(opentrack-proto-wine SHARED ${opentrack-proto-wine-c} ${opentrack-proto-wine-h} ${opentrack-proto-wine-moc} ${opentrack-proto-wine-uih} ${opentrack-proto-wine-rcc}) + target_link_libraries(opentrack-proto-wine ${MY_QT_LIBS} opentrack-compat opentrack-csv) + if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) + SET_TARGET_PROPERTIES(opentrack-proto-wine + PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt") endif() - - if(NOT WIN32 AND SDK_WINE_PREFIX) - add_library(opentrack-proto-wine SHARED ${opentrack-proto-wine-c} ${opentrack-proto-wine-h} ${opentrack-proto-wine-moc} ${opentrack-proto-wine-uih} ${opentrack-proto-wine-rcc}) - target_link_libraries(opentrack-proto-wine ${MY_QT_LIBS} opentrack-compat opentrack-csv) - if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) - SET_TARGET_PROPERTIES(opentrack-proto-wine - PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt") - endif() - if(NOT SDK_WINE_NO_WRAPPER) - add_custom_command( - OUTPUT opentrack-wrapper-wine.exe.so - DEPENDS "${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" - COMMAND "${SDK_WINE_PREFIX}/bin/wineg++" -g -O2 -m32 -o - opentrack-wrapper-wine.exe -I "${CMAKE_SOURCE_DIR}" - "${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) - add_custom_target(wine-wrapper ALL DEPENDS opentrack-wrapper-wine.exe.so) - add_dependencies(wine-wrapper opentrack-compat opentrack-proto-wine) - endif() + if(NOT SDK_WINE_NO_WRAPPER) + add_custom_command( + OUTPUT opentrack-wrapper-wine.exe.so + DEPENDS "${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" + COMMAND "${SDK_WINE_PREFIX}/bin/wineg++" -g -O2 -m32 -o + opentrack-wrapper-wine.exe -I "${CMAKE_SOURCE_DIR}" + "${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) + add_custom_target(wine-wrapper ALL DEPENDS opentrack-wrapper-wine.exe.so) + add_dependencies(wine-wrapper opentrack-compat opentrack-proto-wine) endif() +endif() - if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) - SET_TARGET_PROPERTIES(opentrack-proto-fgfs - PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt") - endif() +if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) + SET_TARGET_PROPERTIES(opentrack-proto-fgfs + PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt") +endif() - add_library(opentrack-tracker-ht SHARED ${opentrack-tracker-ht-c} ${opentrack-tracker-ht-h} ${opentrack-tracker-ht-moc} ${opentrack-tracker-ht-uih} ${opentrack-tracker-ht-rcc}) - target_link_libraries(opentrack-tracker-ht ${MY_QT_LIBS} opentrack-compat) +add_library(opentrack-tracker-ht SHARED ${opentrack-tracker-ht-c} ${opentrack-tracker-ht-h} ${opentrack-tracker-ht-moc} ${opentrack-tracker-ht-uih} ${opentrack-tracker-ht-rcc}) +target_link_libraries(opentrack-tracker-ht ${MY_QT_LIBS} opentrack-compat) +if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) + SET_TARGET_PROPERTIES(opentrack-tracker-ht + PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt") +endif() + +if(SDK_ARUCO_LIBPATH) + include_directories(${CMAKE_SOURCE_DIR}/ftnoir_tracker_aruco/include) + add_library(opentrack-tracker-aruco SHARED ${opentrack-tracker-aruco-c} ${opentrack-tracker-aruco-h} ${opentrack-tracker-aruco-moc} ${opentrack-tracker-aruco-uih} ${opentrack-tracker-aruco-rcc}) + target_link_libraries(opentrack-tracker-aruco ${MY_QT_LIBS} ${SDK_ARUCO_LIBPATH} ${OpenCV_LIBS}) if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) - SET_TARGET_PROPERTIES(opentrack-tracker-ht + SET_TARGET_PROPERTIES(opentrack-tracker-aruco PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt") endif() +endif() - if(SDK_ARUCO_LIBPATH) - include_directories(${CMAKE_SOURCE_DIR}/ftnoir_tracker_aruco/include) - add_library(opentrack-tracker-aruco SHARED ${opentrack-tracker-aruco-c} ${opentrack-tracker-aruco-h} ${opentrack-tracker-aruco-moc} ${opentrack-tracker-aruco-uih} ${opentrack-tracker-aruco-rcc}) - target_link_libraries(opentrack-tracker-aruco ${MY_QT_LIBS} ${SDK_ARUCO_LIBPATH} ${OpenCV_LIBS}) - if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) - SET_TARGET_PROPERTIES(opentrack-tracker-aruco - 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" + "${CMAKE_SOURCE_DIR}/dinput/strmiids.lib" + uuid) + target_link_libraries(opentrack-tracker-joystick + "${CMAKE_SOURCE_DIR}/dinput/dinput8.lib" + "${CMAKE_SOURCE_DIR}/dinput/dxguid.lib" + "${CMAKE_SOURCE_DIR}/dinput/strmiids.lib" + uuid) +endif() + +if(OpenCV_FOUND) + include_directories(${OpenCV_INCLUDE_DIRS}) + include_directories(${OpenCV_DIR}/include) + include_directories(${OpenCV_CONFIG_PATH}/include) +endif() + +if(OpenCV_FOUND) + add_library(opentrack-tracker-pt SHARED ${opentrack-tracker-pt-c} ${opentrack-tracker-pt-h} ${opentrack-tracker-pt-moc} ${opentrack-tracker-pt-uih} ${opentrack-tracker-pt-rcc}) + target_link_libraries(opentrack-tracker-pt ${MY_QT_LIBS} ${OpenCV_LIBS}) + if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) + SET_TARGET_PROPERTIES(opentrack-tracker-pt + 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" - "${CMAKE_SOURCE_DIR}/dinput/strmiids.lib" - uuid) - target_link_libraries(opentrack-tracker-joystick - "${CMAKE_SOURCE_DIR}/dinput/dinput8.lib" + target_link_libraries(opentrack-tracker-pt "${CMAKE_SOURCE_DIR}/dinput/dxguid.lib" "${CMAKE_SOURCE_DIR}/dinput/strmiids.lib" uuid) endif() +endif() - if(OpenCV_FOUND) - include_directories(${OpenCV_INCLUDE_DIRS}) - include_directories(${OpenCV_DIR}/include) - include_directories(${OpenCV_CONFIG_PATH}/include) - endif() - - if(OpenCV_FOUND) - add_library(opentrack-tracker-pt SHARED ${opentrack-tracker-pt-c} ${opentrack-tracker-pt-h} ${opentrack-tracker-pt-moc} ${opentrack-tracker-pt-uih} ${opentrack-tracker-pt-rcc}) - target_link_libraries(opentrack-tracker-pt ${MY_QT_LIBS} ${OpenCV_LIBS}) - if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) - SET_TARGET_PROPERTIES(opentrack-tracker-pt - PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt") - endif() - - if(WIN32) - target_link_libraries(opentrack-tracker-pt - "${CMAKE_SOURCE_DIR}/dinput/dxguid.lib" - "${CMAKE_SOURCE_DIR}/dinput/strmiids.lib" - uuid) - endif() - endif() +add_library(opentrack-tracker-udp SHARED ${opentrack-tracker-udp-c} ${opentrack-tracker-udp-h} ${opentrack-tracker-udp-moc} ${opentrack-tracker-udp-uih} ${opentrack-tracker-udp-rcc}) +target_link_libraries(opentrack-tracker-udp ${MY_QT_LIBS}) +if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) + SET_TARGET_PROPERTIES(opentrack-tracker-udp + PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt") +endif() - add_library(opentrack-tracker-udp SHARED ${opentrack-tracker-udp-c} ${opentrack-tracker-udp-h} ${opentrack-tracker-udp-moc} ${opentrack-tracker-udp-uih} ${opentrack-tracker-udp-rcc}) - target_link_libraries(opentrack-tracker-udp ${MY_QT_LIBS}) - if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) - SET_TARGET_PROPERTIES(opentrack-tracker-udp - PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt") - endif() - - if(SDK_RIFT) - include_directories("${SDK_RIFT}/Include") - include_directories("${SDK_RIFT}/Src") - add_library(opentrack-tracker-rift SHARED ${opentrack-tracker-rift-c} ${opentrack-tracker-rift-h} ${opentrack-tracker-rift-moc} ${opentrack-tracker-rift-uih} ${opentrack-tracker-rift-rcc}) - target_link_libraries(opentrack-tracker-rift ${MY_QT_LIBS}) - if(MSVC) - target_link_libraries(opentrack-tracker-rift "${SDK_RIFT}/Lib/Win32/libovr.lib" winmm.lib) +if(SDK_RIFT) + include_directories("${SDK_RIFT}/Include") + include_directories("${SDK_RIFT}/Src") + add_library(opentrack-tracker-rift SHARED ${opentrack-tracker-rift-c} ${opentrack-tracker-rift-h} ${opentrack-tracker-rift-moc} ${opentrack-tracker-rift-uih} ${opentrack-tracker-rift-rcc}) + target_link_libraries(opentrack-tracker-rift ${MY_QT_LIBS}) + if(MSVC) + target_link_libraries(opentrack-tracker-rift "${SDK_RIFT}/Lib/Win32/libovr.lib" winmm.lib) + else() + if(WIN32) + target_link_libraries(opentrack-tracker-rift "${SDK_RIFT}/LibOVR.a" winmm.lib setupapi.lib) else() - if(WIN32) - target_link_libraries(opentrack-tracker-rift "${SDK_RIFT}/LibOVR.a" winmm.lib setupapi.lib) - else() - target_link_libraries(opentrack-tracker-rift "${SDK_RIFT}/LibOVR.a" udev Xinerama) - endif() + target_link_libraries(opentrack-tracker-rift "${SDK_RIFT}/LibOVR.a" udev Xinerama) endif() - if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) - SET_TARGET_PROPERTIES(opentrack-tracker-rift - PROPERTIES - LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt" - COMPILE_FLAGS "-fno-strict-aliasing" - ) - endif() - endif() - - if(SDK_HYDRA) - include_directories("${SDK_HYDRA}/include") - include_directories("${SDK_HYDRA}/include/sixense_utils") - add_library(opentrack-tracker-hydra SHARED ${opentrack-tracker-hydra-c} ${opentrack-tracker-hydra-h} ${opentrack-tracker-hydra-moc} ${opentrack-tracker-hydra-uih} ${opentrack-tracker-hydra-rcc}) - target_link_libraries(opentrack-tracker-hydra ${MY_QT_LIBS}) - if(WIN32) - target_link_libraries(opentrack-tracker-hydra - "${SDK_HYDRA}/lib/win32/release_dll/sixense.lib" - "${SDK_HYDRA}/lib/win32/release_dll/sixense_utils.lib") - install(FILES "${SDK_HYDRA}/bin/win32/release_dll/sixense.dll" "${SDK_HYDRA}/bin/win32/release_dll/sixense_utils.dll" DESTINATION .) - else() - if(SDK_HYDRA_AMD64) - set(underscore-sixtyfour _x64) - else() - set(underscore-sixtyfour) - endif() - if(APPLE) - set(underscore-dll _dll) - set(soext dylib) - set(sixense-plat osx) - else() - set(underscore-dll) - set(soext so) - set(sixense-plat linux) - endif() - install(FILES - "${SDK_HYDRA}/lib/${sixense-plat}${underscore-sixtyfour}/release${underscore-dll}/libsixense${underscore-sixtyfour}.${soext}" - "${SDK_HYDRA}/lib/${sixense-plat}${underscore-sixtyfour}/release${underscore-dll}/libsixense_utils${underscore-sixtyfour}.${soext}" - DESTINATION .) - target_link_libraries(opentrack-tracker-hydra "${SDK_HYDRA}/lib/${sixense-plat}${underscore-sixtyfour}/release${underscore-dll}/libsixense${underscore-sixtyfour}.${soext}" "${SDK_HYDRA}/lib/${sixense-plat}${underscore-sixtyfour}/release${underscore-dll}/libsixense_utils${underscore-sixtyfour}.${soext}") - endif() - if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) - SET_TARGET_PROPERTIES(opentrack-tracker-hydra - PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt") - endif() - endif() - - if(WIN32 AND NOT SDK_CONSOLE_DEBUG) - set(opentrack-win32-executable WIN32) - else() - set(opentrack-win32-executable "") - endif() - if(UNIX) - 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}) - 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}\") - if(UNIX) - target_link_libraries(opentrack opentrack-qxt-mini) + endif() + if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) + SET_TARGET_PROPERTIES(opentrack-tracker-rift + PROPERTIES + LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt" + COMPILE_FLAGS "-fno-strict-aliasing" + ) endif() - - if(UNIX) - install(TARGETS opentrack-qxt-mini DESTINATION .) endif() +if(SDK_HYDRA) + include_directories("${SDK_HYDRA}/include") + include_directories("${SDK_HYDRA}/include/sixense_utils") + add_library(opentrack-tracker-hydra SHARED ${opentrack-tracker-hydra-c} ${opentrack-tracker-hydra-h} ${opentrack-tracker-hydra-moc} ${opentrack-tracker-hydra-uih} ${opentrack-tracker-hydra-rcc}) + target_link_libraries(opentrack-tracker-hydra ${MY_QT_LIBS}) 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 - uuid - ) - endif() - if(MSVC) - SET_TARGET_PROPERTIES(opentrack PROPERTIES LINK_FLAGS "/ENTRY:mainCRTStartup /NODEFAULTLIB:LIBCMT.LIB") - endif() - target_link_libraries(opentrack opentrack-pose-widget opentrack-spline-widget ${MY_QT_LIBS} ${QXT_QXTCORE_LIB_RELEASE} ${QXT_QXTWIDGETS_LIB_RELEASE}) - if(NOT WIN32) - target_link_libraries(opentrack dl) - endif() - 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") + target_link_libraries(opentrack-tracker-hydra + "${SDK_HYDRA}/lib/win32/release_dll/sixense.lib" + "${SDK_HYDRA}/lib/win32/release_dll/sixense_utils.lib") + install(FILES "${SDK_HYDRA}/bin/win32/release_dll/sixense.dll" "${SDK_HYDRA}/bin/win32/release_dll/sixense_utils.dll" DESTINATION .) else() - target_link_libraries(opentrack "${SDK_GOOGLE_BREAKPAD}/lib/libbreakpad_client.a" - "${SDK_GOOGLE_BREAKPAD}/lib/libbreakpad.a") + if(SDK_HYDRA_AMD64) + set(underscore-sixtyfour _x64) + else() + set(underscore-sixtyfour) + endif() + if(APPLE) + set(underscore-dll _dll) + set(soext dylib) + set(sixense-plat osx) + else() + set(underscore-dll) + set(soext so) + set(sixense-plat linux) + endif() + install(FILES + "${SDK_HYDRA}/lib/${sixense-plat}${underscore-sixtyfour}/release${underscore-dll}/libsixense${underscore-sixtyfour}.${soext}" + "${SDK_HYDRA}/lib/${sixense-plat}${underscore-sixtyfour}/release${underscore-dll}/libsixense_utils${underscore-sixtyfour}.${soext}" + DESTINATION .) + target_link_libraries(opentrack-tracker-hydra "${SDK_HYDRA}/lib/${sixense-plat}${underscore-sixtyfour}/release${underscore-dll}/libsixense${underscore-sixtyfour}.${soext}" "${SDK_HYDRA}/lib/${sixense-plat}${underscore-sixtyfour}/release${underscore-dll}/libsixense_utils${underscore-sixtyfour}.${soext}") + endif() + if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) + SET_TARGET_PROPERTIES(opentrack-tracker-hydra + PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt") endif() - endif() - set_target_properties(opentrack PROPERTIES COMPILE_FLAGS -DOPENTRACK_MAIN) endif() -# make install +if(WIN32 AND NOT SDK_CONSOLE_DEBUG) + set(opentrack-win32-executable WIN32) +else() + set(opentrack-win32-executable "") +endif() +if(UNIX) + 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}) +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}\") +if(UNIX) + target_link_libraries(opentrack opentrack-qxt-mini) +endif() -if(SDK_SM_FACEAPI_PATH) - include_directories("${SDK_SM_FACEAPI_PATH}/include") - if(WIN32 AND NOT SDK_FACEAPI_ONLY) - add_library(opentrack-tracker-faceapi SHARED ${opentrack-tracker-faceapi-c} ${opentrack-tracker-faceapi-h} ${opentrack-tracker-faceapi-moc} ${opentrack-tracker-faceapi-uih} ${opentrack-tracker-faceapi-rcc}) - target_link_libraries(opentrack-tracker-faceapi ${MY_QT_LIBS} opentrack-compat) - endif() - if(MSVC80 OR MINGW) - add_executable(opentrack-faceapi-wrapper ${opentrack-faceapi-wrapper-c} ${opentrack-faceapi-wrapper-h}) - target_link_libraries(opentrack-faceapi-wrapper "${SDK_SM_FACEAPI_PATH}/bin/smft32.lib") - endif() +if(UNIX) + install(TARGETS opentrack-qxt-mini DESTINATION .) +endif() + +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 + uuid + ) +endif() +if(MSVC) + SET_TARGET_PROPERTIES(opentrack PROPERTIES LINK_FLAGS "/ENTRY:mainCRTStartup /NODEFAULTLIB:LIBCMT.LIB") +endif() +target_link_libraries(opentrack opentrack-pose-widget opentrack-spline-widget ${MY_QT_LIBS} ${QXT_QXTCORE_LIB_RELEASE} ${QXT_QXTWIDGETS_LIB_RELEASE}) +if(NOT WIN32) + target_link_libraries(opentrack dl) endif() + 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) + +# make install install(FILES "${CMAKE_SOURCE_DIR}/README.md" DESTINATION .) -if(NOT SDK_FACEAPI_ONLY) - if(SDK_XPLANE) - install(TARGETS opentrack-xplane-plugin LIBRARY DESTINATION . NAMELINK_SKIP) - endif() - if(WIN32) - install(DIRECTORY "${CMAKE_SOURCE_DIR}/bin/tracker-ht" DESTINATION .) - install(TARGETS freetrackclient RUNTIME DESTINATION .) - endif() - install(DIRECTORY "${CMAKE_SOURCE_DIR}/3rdparty-notices" DESTINATION .) +if(SDK_XPLANE) + install(TARGETS opentrack-xplane-plugin LIBRARY DESTINATION . NAMELINK_SKIP) +endif() +if(WIN32) + install(DIRECTORY "${CMAKE_SOURCE_DIR}/bin/tracker-ht" DESTINATION .) + install(TARGETS freetrackclient RUNTIME DESTINATION .) +endif() + install(DIRECTORY "${CMAKE_SOURCE_DIR}/3rdparty-notices" DESTINATION .) - install(FILES "${CMAKE_SOURCE_DIR}/bin/NPClient.dll" "${CMAKE_SOURCE_DIR}/bin/NPClient64.dll" "${CMAKE_SOURCE_DIR}/bin/TrackIR.exe" DESTINATION .) - install(DIRECTORY "${CMAKE_SOURCE_DIR}/bin/settings" "${CMAKE_SOURCE_DIR}/facetracknoir/clientfiles" DESTINATION .) +install(FILES "${CMAKE_SOURCE_DIR}/bin/NPClient.dll" "${CMAKE_SOURCE_DIR}/bin/NPClient64.dll" "${CMAKE_SOURCE_DIR}/bin/TrackIR.exe" DESTINATION .) +install(DIRECTORY "${CMAKE_SOURCE_DIR}/bin/settings" "${CMAKE_SOURCE_DIR}/facetracknoir/clientfiles" DESTINATION .) - if(NOT WIN32 AND SDK_WINE_PREFIX) - install(FILES "${CMAKE_BINARY_DIR}/opentrack-wrapper-wine.exe.so" - DESTINATION .) - install(TARGETS opentrack-proto-wine DESTINATION .) - endif() +if(NOT WIN32 AND SDK_WINE_PREFIX) + install(FILES "${CMAKE_BINARY_DIR}/opentrack-wrapper-wine.exe.so" + DESTINATION .) + install(TARGETS opentrack-proto-wine DESTINATION .) +endif() - if(OpenCV_FOUND) - install(TARGETS opentrack-tracker-pt RUNTIME DESTINATION . LIBRARY DESTINATION .) - endif() +if(OpenCV_FOUND) + install(TARGETS opentrack-tracker-pt RUNTIME DESTINATION . LIBRARY DESTINATION .) +endif() - if(SDK_ARUCO_LIBPATH) - install(TARGETS opentrack-tracker-aruco RUNTIME DESTINATION . LIBRARY DESTINATION .) - endif() +if(SDK_ARUCO_LIBPATH) + install(TARGETS opentrack-tracker-aruco RUNTIME DESTINATION . LIBRARY DESTINATION .) +endif() - install(TARGETS - opentrack-compat - opentrack-csv - opentrack-pose-widget - opentrack-spline-widget - opentrack-filter-accela - opentrack-filter-ewma - opentrack-proto-fgfs - opentrack-proto-udp - opentrack-tracker-ht - opentrack-tracker-udp - opentrack - RUNTIME DESTINATION . - LIBRARY DESTINATION . - NAMELINK_SKIP +install(TARGETS + opentrack-compat + opentrack-csv + opentrack-pose-widget + opentrack-spline-widget + opentrack-filter-accela + opentrack-filter-ewma + opentrack-proto-fgfs + opentrack-proto-udp + opentrack-tracker-ht + opentrack-tracker-udp + opentrack + RUNTIME DESTINATION . + LIBRARY DESTINATION . + NAMELINK_SKIP +) + +if(WIN32) + install(TARGETS opentrack-tracker-joystick RUNTIME DESTINATION . LIBRARY DESTINATION . NAMELINK_SKIP) +endif() + +if(WIN32 AND SDK_VJOY) + install(TARGETS opentrack-proto-vjoy + RUNTIME DESTINATION . + LIBRARY DESTINATION . + NAMELINK_SKIP) + install(FILES "${SDK_VJOY}/VJoy.dll" DESTINATION .) +endif() + +if(SDK_RIFT) + install( + TARGETS opentrack-tracker-rift + RUNTIME DESTINATION . + LIBRARY DESTINATION . + NAMELINK_SKIP ) +endif() - if(WIN32) - install(TARGETS opentrack-tracker-joystick RUNTIME DESTINATION . LIBRARY DESTINATION . NAMELINK_SKIP) - endif() +if(SDK_HYDRA) + install( + TARGETS opentrack-tracker-hydra + RUNTIME DESTINATION . + LIBRARY DESTINATION . + NAMELINK_SKIP + ) +endif() - if(WIN32 AND SDK_VJOY) - install(TARGETS opentrack-proto-vjoy +if(WIN32) + install(FILES "${CMAKE_SOURCE_DIR}/bin/cleye.config" DESTINATION .) + if(SDK_SIMCONNECT) + install(TARGETS opentrack-proto-simconnect RUNTIME DESTINATION . LIBRARY DESTINATION . NAMELINK_SKIP) - install(FILES "${SDK_VJOY}/VJoy.dll" DESTINATION .) endif() - - if(SDK_RIFT) - install( - TARGETS opentrack-tracker-rift - RUNTIME DESTINATION . - LIBRARY DESTINATION . - NAMELINK_SKIP + if(OpenCV_FOUND AND NOT SDK_OPENCV_STATIC) + get_filename_component(opentrack-opencv-dir "${OpenCV_LIB_DIR_OPT}" PATH) + if(WIN32 AND NOT CMAKE_COMPILER_IS_GNUCC) + set(LIB-PREFIX "../bin/Release/") + else() + set(LIB-PREFIX "lib") + endif() + file(GLOB opentrack-opencv-files + "${opentrack-opencv-dir}/${LIB-PREFIX}opencv_calib3d*.dll" + "${opentrack-opencv-dir}/${LIB-PREFIX}opencv_core*.dll" + "${opentrack-opencv-dir}/${LIB-PREFIX}opencv_highgui*.dll" + "${opentrack-opencv-dir}/${LIB-PREFIX}opencv_imgproc*.dll" + "${opentrack-opencv-dir}/${LIB-PREFIX}opencv_flann*.dll" + "${opentrack-opencv-dir}/${LIB-PREFIX}opencv_features2d*.dll" + ) + install(FILES ${opentrack-opencv-files} DESTINATION .) + endif() + if(WIN32 AND NOT CMAKE_COMPILER_IS_GNUCC) + GET_FILENAME_COMPONENT(qt-dirname "${Qt5Core_DIR}" PATH) + SET(qt-dirname "${qt-dirname}/../../bin") + install(FILES + "${qt-dirname}/Qt5Core.dll" + "${qt-dirname}/Qt5Gui.dll" + "${qt-dirname}/Qt5Widgets.dll" + "${qt-dirname}/Qt5Network.dll" + "${qt-dirname}/Qt5Xml.dll" + DESTINATION . ) endif() - - if(SDK_HYDRA) - install( - TARGETS opentrack-tracker-hydra + install(TARGETS + opentrack-proto-freetrack + opentrack-proto-win32-mouse + #opentrack-proto-simconnect RUNTIME DESTINATION . LIBRARY DESTINATION . NAMELINK_SKIP - ) - endif() - - if(WIN32) - install(FILES "${CMAKE_SOURCE_DIR}/bin/cleye.config" DESTINATION .) - if(SDK_SIMCONNECT) - install(TARGETS opentrack-proto-simconnect + ) + if(SDK_FSUIPC) + install(TARGETS opentrack-proto-fsuipc RUNTIME DESTINATION . LIBRARY DESTINATION . NAMELINK_SKIP) - endif() - if(OpenCV_FOUND AND NOT SDK_OPENCV_STATIC) - get_filename_component(opentrack-opencv-dir "${OpenCV_LIB_DIR_OPT}" PATH) - if(WIN32 AND NOT CMAKE_COMPILER_IS_GNUCC) - set(LIB-PREFIX "../bin/Release/") - else() - set(LIB-PREFIX "lib") - endif() - file(GLOB opentrack-opencv-files - "${opentrack-opencv-dir}/${LIB-PREFIX}opencv_calib3d*.dll" - "${opentrack-opencv-dir}/${LIB-PREFIX}opencv_core*.dll" - "${opentrack-opencv-dir}/${LIB-PREFIX}opencv_highgui*.dll" - "${opentrack-opencv-dir}/${LIB-PREFIX}opencv_imgproc*.dll" - "${opentrack-opencv-dir}/${LIB-PREFIX}opencv_flann*.dll" - "${opentrack-opencv-dir}/${LIB-PREFIX}opencv_features2d*.dll" - ) - install(FILES ${opentrack-opencv-files} DESTINATION .) - endif() - if(WIN32 AND NOT CMAKE_COMPILER_IS_GNUCC) - GET_FILENAME_COMPONENT(qt-dirname "${Qt5Core_DIR}" PATH) - SET(qt-dirname "${qt-dirname}/../../bin") - install(FILES - "${qt-dirname}/Qt5Core.dll" - "${qt-dirname}/Qt5Gui.dll" - "${qt-dirname}/Qt5Widgets.dll" - "${qt-dirname}/Qt5Network.dll" - "${qt-dirname}/Qt5Xml.dll" - DESTINATION . - ) - endif() - install(TARGETS - opentrack-proto-freetrack - opentrack-proto-win32-mouse - #opentrack-proto-simconnect - RUNTIME DESTINATION . - LIBRARY DESTINATION . - NAMELINK_SKIP - ) - if(SDK_FSUIPC) - install(TARGETS opentrack-proto-fsuipc - RUNTIME DESTINATION . - LIBRARY DESTINATION . - NAMELINK_SKIP) - endif() - endif() -endif() -if(SDK_SM_FACEAPI_PATH AND NOT SDK_FACEAPI_ONLY) - install(TARGETS opentrack-tracker-faceapi - RUNTIME DESTINATION . - LIBRARY DESTINATION . - NAMELINK_SKIP - ) + endif() if(MSVC) - file(GLOB pdbs1 "${CMAKE_BINARY_DIR}/Release/*.pdb") - file(GLOB pdbs2 "${CMAKE_BINARY_DIR}/*.pdb") - install(FILES ${pdbs1} ${pdbs2} DESTINATION .) +file(GLOB pdbs1 "${CMAKE_BINARY_DIR}/Release/*.pdb") +file(GLOB pdbs2 "${CMAKE_BINARY_DIR}/*.pdb") +install(FILES ${pdbs1} ${pdbs2} DESTINATION .) endif() -if(SDK_SM_FACEAPI_PATH AND (MSVC80 OR MINGW)) - install(TARGETS opentrack-faceapi-wrapper - RUNTIME DESTINATION faceapi - LIBRARY DESTINATION faceapi - NAMELINK_SKIP - ) - install(FILES "${CMAKE_SOURCE_DIR}/bin/cleye.config" DESTINATION faceapi) - install(FILES - "${SDK_SM_FACEAPI_PATH}/bin/computation6.0.dll" - "${SDK_SM_FACEAPI_PATH}/bin/foundation6.0.dll" - "${SDK_SM_FACEAPI_PATH}/bin/image6.0.dll" - "${SDK_SM_FACEAPI_PATH}/bin/libpng13.dll" - "${SDK_SM_FACEAPI_PATH}/bin/pgrflycapturegui.dll" - "${SDK_SM_FACEAPI_PATH}/bin/QtCore0.dll" - "${SDK_SM_FACEAPI_PATH}/bin/qt-mt334.dll" - "${SDK_SM_FACEAPI_PATH}/bin/QtXml4.dll" - "${SDK_SM_FACEAPI_PATH}/bin/smft32.dll" - "${SDK_SM_FACEAPI_PATH}/bin/zlib1.dll" - "${SDK_SM_FACEAPI_PATH}/doc/RELEASE NOTES.txt" - DESTINATION faceapi - ) - install(DIRECTORY - "${SDK_SM_FACEAPI_PATH}/bin/cal" - "${SDK_SM_FACEAPI_PATH}/bin/resources" - DESTINATION faceapi - ) -endif() diff --git a/faceapi/build_options.h b/faceapi/build_options.h deleted file mode 100644 index e298686e..00000000 --- a/faceapi/build_options.h +++ /dev/null @@ -1,8 +0,0 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// -// Build Options -// -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -//controls whether or not FaceAPI should use the callback or poll -#define USE_HEADPOSE_CALLBACK 1 diff --git a/faceapi/ftnoir-faceapi-wrapper.exe.manifest b/faceapi/ftnoir-faceapi-wrapper.exe.manifest deleted file mode 100644 index b6c98376..00000000 --- a/faceapi/ftnoir-faceapi-wrapper.exe.manifest +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/faceapi/ftnoir-faceapi-wrapper.rc b/faceapi/ftnoir-faceapi-wrapper.rc deleted file mode 100644 index 54cbb863..00000000 --- a/faceapi/ftnoir-faceapi-wrapper.rc +++ /dev/null @@ -1,2 +0,0 @@ -#include "winuser.h" -2 RT_MANIFEST ftnoir-faceapi-wrapper.exe.manifest \ No newline at end of file diff --git a/faceapi/lock.h b/faceapi/lock.h deleted file mode 100644 index bb095675..00000000 --- a/faceapi/lock.h +++ /dev/null @@ -1,35 +0,0 @@ -#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 deleted file mode 100644 index 47b810fa..00000000 --- a/faceapi/lockfree.h +++ /dev/null @@ -1,65 +0,0 @@ -//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 deleted file mode 100644 index fb7d3f0a..00000000 --- a/faceapi/main.cpp +++ /dev/null @@ -1,529 +0,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) 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_sm/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 deleted file mode 100644 index b1a013e8..00000000 --- a/faceapi/mutex.h +++ /dev/null @@ -1,46 +0,0 @@ -#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 deleted file mode 100644 index 981c9e33..00000000 --- a/faceapi/stdafx.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// 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 deleted file mode 100644 index 92e24b3e..00000000 --- a/faceapi/stdafx.h +++ /dev/null @@ -1,36 +0,0 @@ -#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 deleted file mode 100644 index 80555d22..00000000 --- a/faceapi/utils.h +++ /dev/null @@ -1,349 +0,0 @@ -#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 - - UICSMClientControls - - - Qt::ApplicationModal - - - - 0 - 0 - 174 - 188 - - - - faceAPI tracker settings FaceTrackNoIR - - - - images/sm.pngimages/sm.png - - - Qt::LeftToRight - - - false - - - - QLayout::SetMaximumSize - - - - - - 0 - 0 - - - - Axis enablement - - - Qt::AlignCenter - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - Qt::AlignHCenter|Qt::AlignTop - - - 10 - - - - - Roll: - - - - - - - - 20 - 16777215 - - - - Qt::LeftToRight - - - - - - - - - - - - - Pitch: - - - - - - - - 20 - 16777215 - - - - Qt::LeftToRight - - - - - - - - - - Yaw: - - - - - - - - 20 - 16777215 - - - - Qt::LeftToRight - - - - - - - - - - X: - - - - - - - - 20 - 16777215 - - - - Qt::LeftToRight - - - - - - - - - - Y: - - - - - - - - 20 - 16777215 - - - - Qt::LeftToRight - - - - - - - - - - Z: - - - - - - - - 20 - 16777215 - - - - Qt::LeftToRight - - - - - - - - - - - - - - 0 - 0 - - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - - startEngineClicked() - stopEngineClicked() - cameraSettingsClicked() - - diff --git a/ftnoir_tracker_sm/ftnoir_tracker_faceapi.cpp b/ftnoir_tracker_sm/ftnoir_tracker_faceapi.cpp deleted file mode 100644 index 18182153..00000000 --- a/ftnoir_tracker_sm/ftnoir_tracker_faceapi.cpp +++ /dev/null @@ -1,220 +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 * -* * -* 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 "facetracknoir/global-settings.h" -#include -#include "ftnoir_tracker_sm/ftnoir_tracker_sm.h" - -FTNoIR_Tracker::FTNoIR_Tracker() : shm(SM_MM_DATA, SM_MUTEX, sizeof(SMMemMap)), started(false) -{ - pMemData = (SMMemMap*) shm.mem; -} - -static void wait_for_cmd(SMMemMap *pMemData, PortableLockedShm& shm) { - qDebug() << "faceapi: waiting for cmd"; - for (int _ = 0; _ < 3000; _++) - { - bool br = false; - shm.lock(); - if (pMemData->command == 0) - { - br = true; - } - shm.unlock(); - if (br) - break; - QThread::msleep(1); - } - qDebug() << "faceapi: done waiting for cmd"; -} - -// Send a command without parameter-value to the tracking Engine. -// -void FTNoIR_Tracker::doCommand(int command) -{ - shm.lock(); - pMemData->command = command; - shm.unlock(); - wait_for_cmd(pMemData, shm); -} - -// -// Send a command with integer parameter-value to the tracking Engine. -// -void FTNoIR_Tracker::doCommand(int command, int value) -{ - shm.lock(); - pMemData->command = command; // Send command - pMemData->par_val_int = value; - shm.unlock(); - wait_for_cmd(pMemData, shm); -} - -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 "; - QMessageBox::warning(videoframe, - "Non-free software deprecation", - "SM FaceAPI is deprecated, hence this annoying message.\n" - "It'll be removed for 2.0-final.\n" - "The goal is to have only open-source software available.", - QMessageBox::Ok, QMessageBox::NoButton); - - loadSettings(); - - if ( pMemData != NULL ) { - pMemData->command = 0; // Reset any and all commands - if (videoframe != NULL) { - pMemData->handle = (HWND) 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(); - } -} - -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) -{ - if (!started) - doStartEngine(); - started = true; - // - // Check if the pointer is OK and wait for the Mutex. - // - 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; - 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 deleted file mode 100644 index 3510f3e9..00000000 --- a/ftnoir_tracker_sm/ftnoir_tracker_faceapi_dialog.cpp +++ /dev/null @@ -1,188 +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 * -* * -* 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 "ftnoir_tracker_sm/ftnoir_tracker_sm.h" -#include "facetracknoir/global-settings.h" - -//******************************************************************************************************* -// faceAPI Client Settings-dialog. -//******************************************************************************************************* - -// -// Constructor for server-settings-dialog -// -TrackerControls::TrackerControls() : settingsDirty(false) -{ - ui.setupUi( this ); - - //connect(ui.cbxFilterSetting, SIGNAL(currentIndexChanged(int)), this, SLOT(doSetFilter( int ))); - //connect(ui.btnCameraSettings, SIGNAL(clicked()), this, SLOT(doShowCam())); - - connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); - connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); - - connect(ui.chkEnableRoll, SIGNAL(setChecked(int)), this, SLOT(settingChanged(int))); - connect(ui.chkEnablePitch, SIGNAL(setChecked(int)), this, SLOT(settingChanged(int))); - connect(ui.chkEnableYaw, SIGNAL(setChecked(int)), this, SLOT(settingChanged(int))); - connect(ui.chkEnableX, SIGNAL(setChecked(int)), this, SLOT(settingChanged(int))); - connect(ui.chkEnableY, SIGNAL(setChecked(int)), this, SLOT(settingChanged(int))); - connect(ui.chkEnableZ, SIGNAL(setChecked(int)), this, SLOT(settingChanged(int))); - connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOk())); - connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doOCancel())); -} - -// -// 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 ) { - 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.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 ( "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 (); - - 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_sm/ftnoir_tracker_faceapi_dll.cpp b/ftnoir_tracker_sm/ftnoir_tracker_faceapi_dll.cpp deleted file mode 100644 index b1ab1d75..00000000 --- a/ftnoir_tracker_sm/ftnoir_tracker_faceapi_dll.cpp +++ /dev/null @@ -1,72 +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 * -* * -* 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 deleted file mode 100644 index 4089983d..00000000 --- a/ftnoir_tracker_sm/ftnoir_tracker_sm.h +++ /dev/null @@ -1,120 +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 * -* * -* 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 -#include -#include -#include -#include "math.h" -#include "facetracknoir/global-settings.h" -#include "compat/compat.h" -#include -#include "ftnoir_tracker_base/ftnoir_tracker_base.h" -#include "ftnoir_tracker_sm/ftnoir_tracker_sm_types.h" -#include "ui_ftnoir_sm_controls.h" - -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 doCommand(int foo); - void doCommand(int foo, int bar); - void doStartEngine(){ - doCommand(FT_SM_START); - doCommand(FT_SM_SET_PAR_FILTER, 0); - //doCommand(FT_SM_SHOW_CAM); - } - void loadSettings(); - -private: - // - // global variables - // - PortableLockedShm shm; - SMMemMap *pMemData; - QProcess *faceAPI; - - bool bEnableRoll; - bool bEnablePitch; - bool bEnableYaw; - bool bEnableX; - bool bEnableY; - bool bEnableZ; - bool started; -}; - -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) { - } - void unRegisterTracker() { - } -protected slots: - void doOK(); - void doCancel(); - void save(); - void settingChanged() { settingsDirty = true; } - void settingChanged(int) { settingsDirty = true; } -private: - Ui::UICSMClientControls ui; - void loadSettings(); - bool settingsDirty; -}; - -//******************************************************************************************************* -// 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_sm/ftnoir_tracker_sm_types.h b/ftnoir_tracker_sm/ftnoir_tracker_sm_types.h deleted file mode 100644 index 526f8cdc..00000000 --- a/ftnoir_tracker_sm/ftnoir_tracker_sm_types.h +++ /dev/null @@ -1,36 +0,0 @@ -// -// 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_sm/images/sm.png b/ftnoir_tracker_sm/images/sm.png deleted file mode 100644 index 4910d1f0..00000000 Binary files a/ftnoir_tracker_sm/images/sm.png and /dev/null differ diff --git a/ftnoir_tracker_sm/sm-tracker.qrc b/ftnoir_tracker_sm/sm-tracker.qrc deleted file mode 100644 index d17d0899..00000000 --- a/ftnoir_tracker_sm/sm-tracker.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - images/sm.png - - -- cgit v1.2.3 From c69134007bc02aefa40e2ff62f8ede0ddcc794fe Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 25 Oct 2013 04:19:18 +0200 Subject: remove faceapi from installer Signed-off-by: Stanislaw Halik --- installer/opentrack-installer.iss | 1 - 1 file changed, 1 deletion(-) diff --git a/installer/opentrack-installer.iss b/installer/opentrack-installer.iss index 3c97fe46..ca04af71 100644 --- a/installer/opentrack-installer.iss +++ b/installer/opentrack-installer.iss @@ -49,5 +49,4 @@ Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}" Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon [Run] -Filename: "{app}\redist\vc80redist_x86.exe"; Parameters: "/q:a"; Flags: waituntilterminated; Description: "Install MSVC 8.0 runtime for FaceAPI" Filename: "{app}\{#MyAppExeName}"; Flags: nowait postinstall skipifsilent; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}" -- cgit v1.2.3 From 44e74d4eb0a76070417819c2b5e326e354cf3705 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 25 Oct 2013 05:31:35 +0200 Subject: remove faceapi from readme --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index e6215546..2c76605e 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,6 @@ Not to be confused with railway planning software <> # Tracking sources -- SeeingMachines FaceAPI (Windows) - PointTracker by Patrick Ruoff, freetrack-like light sources - Oculus Rift (Windows; Linux testers welcome!) - AR marker support via the ArUco library -- 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(-) 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 9305fd709aca679a96784f304cc5103178301125 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 25 Oct 2013 12:03:24 +0200 Subject: hydra: add ui layouts Signed-off-by: Stanislaw Halik --- .../ftnoir_hydra_clientcontrols.ui | 414 ++++++++------------- .../ftnoir_tracker_hydra_dialog.cpp | 4 +- 2 files changed, 154 insertions(+), 264 deletions(-) diff --git a/ftnoir_tracker_hydra/ftnoir_hydra_clientcontrols.ui b/ftnoir_tracker_hydra/ftnoir_hydra_clientcontrols.ui index 94d22cb5..1acbf93f 100644 --- a/ftnoir_tracker_hydra/ftnoir_hydra_clientcontrols.ui +++ b/ftnoir_tracker_hydra/ftnoir_hydra_clientcontrols.ui @@ -9,7 +9,7 @@ 0 0 - 411 + 172 145 @@ -26,7 +26,7 @@ false - + @@ -38,273 +38,163 @@ Enable Axis - - - - 10 - 20 - 143 - 60 - - - - - - - Pitch: - - - - - - - - 20 - 16777215 - - - - Qt::LeftToRight - - - - - - - - - - - - - Yaw: - - - - - - - - 20 - 16777215 - - - - Qt::LeftToRight - - - - - - - - - - Roll: - - - - - - - - 20 - 16777215 - - - - Qt::LeftToRight - - - - - - - - - - X: - - - - - - - - 20 - 16777215 - - - - Qt::LeftToRight - - - - - - - - - - - - - Y: - - - - - - - - 20 - 16777215 - - - - Qt::LeftToRight - - - - - - - - - - Z: - - - - - - - - 20 - 16777215 - - - - Qt::LeftToRight - - - - - - - - + + + + + Pitch: + + + + + + + + 20 + 16777215 + + + + Qt::LeftToRight + + + + + + + + + + + + + X: + + + + + + + + 20 + 16777215 + + + + Qt::LeftToRight + + + + + + + + + + + + + Yaw: + + + + + + + + 20 + 16777215 + + + + Qt::LeftToRight + + + + + + + + + + Y: + + + + + + + + 20 + 16777215 + + + + Qt::LeftToRight + + + + + + + + + + Roll: + + + + + + + + 20 + 16777215 + + + + Qt::LeftToRight + + + + + + + + + + Z: + + + + + + + + 20 + 16777215 + + + + Qt::LeftToRight + + + + + + + - - - Qt::Vertical + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - 20 - 40 - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - QLayout::SetDefaultConstraint - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - OK - - - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - Cancel - - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 10 - 20 - - - - - + - - btnOK - btnCancel - diff --git a/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dialog.cpp b/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dialog.cpp index 165f8573..fa674662 100644 --- a/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dialog.cpp +++ b/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dialog.cpp @@ -38,8 +38,8 @@ 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.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); + connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); connect(ui.chkEnableRoll, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); connect(ui.chkEnablePitch, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); -- cgit v1.2.3 From 01eb9ad09055c7add1ef29726f985325bb3f489b Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 25 Oct 2013 12:48:52 +0200 Subject: js: don't spin forever in bg thread on detach --- ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp index a132f472..66138e90 100644 --- a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp +++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp @@ -183,14 +183,14 @@ bool FTNoIR_Tracker::GiveHeadPoseData(double *data) if( !g_pDI || !g_pJoystick) return false; -start: auto hr = g_pJoystick->Poll(); if( FAILED( hr )) { hr = g_pJoystick->Acquire(); - while( hr == DIERR_INPUTLOST ) + for (int i = 0; hr == DIERR_INPUTLOST && i < 200; i++) hr = g_pJoystick->Acquire(); - goto start; + if (hr != DI_OK) + return false; } if( FAILED( hr = g_pJoystick->GetDeviceState( sizeof( js ), &js ) ) ) -- cgit v1.2.3 From e9927542ae68402ee13828c8d90d7965a2dd99cb Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 25 Oct 2013 14:08:08 +0200 Subject: cmake: make opencv required :( Signed-off-by: Stanislaw Halik --- CMakeLists.txt | 41 ++++++++++++++++++----------------------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 46931cac..08d1f64a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -58,7 +58,7 @@ SET(SDK_RIFT "" CACHE PATH "libOVR path") include_directories(${CMAKE_SOURCE_DIR}) - find_package(OpenCV) + find_package(OpenCV REQUIRED) find_package(Qt5 REQUIRED COMPONENTS Core Xml Network Widgets Gui QUIET) cmake_policy(SET CMP0020 NEW) include_directories(${Qt5Core_INCLUDE_DIRS} ${Qt5Xml_INCLUDE_DIRS} ${Qt5Gui_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS} ${Qt5Network_INCLUDE_DIRS}) @@ -477,26 +477,22 @@ if(WIN32) uuid) endif() -if(OpenCV_FOUND) - include_directories(${OpenCV_INCLUDE_DIRS}) - include_directories(${OpenCV_DIR}/include) - include_directories(${OpenCV_CONFIG_PATH}/include) -endif() +include_directories(${OpenCV_INCLUDE_DIRS}) +include_directories(${OpenCV_DIR}/include) +include_directories(${OpenCV_CONFIG_PATH}/include) -if(OpenCV_FOUND) - add_library(opentrack-tracker-pt SHARED ${opentrack-tracker-pt-c} ${opentrack-tracker-pt-h} ${opentrack-tracker-pt-moc} ${opentrack-tracker-pt-uih} ${opentrack-tracker-pt-rcc}) - target_link_libraries(opentrack-tracker-pt ${MY_QT_LIBS} ${OpenCV_LIBS}) - if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) - SET_TARGET_PROPERTIES(opentrack-tracker-pt - PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt") - endif() +add_library(opentrack-tracker-pt SHARED ${opentrack-tracker-pt-c} ${opentrack-tracker-pt-h} ${opentrack-tracker-pt-moc} ${opentrack-tracker-pt-uih} ${opentrack-tracker-pt-rcc}) +target_link_libraries(opentrack-tracker-pt ${MY_QT_LIBS} ${OpenCV_LIBS}) +if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) +SET_TARGET_PROPERTIES(opentrack-tracker-pt + PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt") +endif() - if(WIN32) - target_link_libraries(opentrack-tracker-pt - "${CMAKE_SOURCE_DIR}/dinput/dxguid.lib" - "${CMAKE_SOURCE_DIR}/dinput/strmiids.lib" - uuid) - endif() +if(WIN32) + target_link_libraries(opentrack-tracker-pt + "${CMAKE_SOURCE_DIR}/dinput/dxguid.lib" + "${CMAKE_SOURCE_DIR}/dinput/strmiids.lib" + uuid) endif() add_library(opentrack-tracker-udp SHARED ${opentrack-tracker-udp-c} ${opentrack-tracker-udp-h} ${opentrack-tracker-udp-moc} ${opentrack-tracker-udp-uih} ${opentrack-tracker-udp-rcc}) @@ -581,6 +577,7 @@ set_target_properties(opentrack PROPERTIES COMPILE_DEFINITIONS OPENTRACK_VERSION if(UNIX) target_link_libraries(opentrack opentrack-qxt-mini) endif() +target_link_libraries(opentrack ${OpenCV_LIBS}) if(UNIX) install(TARGETS opentrack-qxt-mini DESTINATION .) @@ -636,9 +633,7 @@ if(NOT WIN32 AND SDK_WINE_PREFIX) install(TARGETS opentrack-proto-wine DESTINATION .) endif() -if(OpenCV_FOUND) - install(TARGETS opentrack-tracker-pt RUNTIME DESTINATION . LIBRARY DESTINATION .) -endif() +install(TARGETS opentrack-tracker-pt RUNTIME DESTINATION . LIBRARY DESTINATION .) if(SDK_ARUCO_LIBPATH) install(TARGETS opentrack-tracker-aruco RUNTIME DESTINATION . LIBRARY DESTINATION .) @@ -699,7 +694,7 @@ if(WIN32) LIBRARY DESTINATION . NAMELINK_SKIP) endif() - if(OpenCV_FOUND AND NOT SDK_OPENCV_STATIC) + if(NOT SDK_OPENCV_STATIC) get_filename_component(opentrack-opencv-dir "${OpenCV_LIB_DIR_OPT}" PATH) if(WIN32 AND NOT CMAKE_COMPILER_IS_GNUCC) set(LIB-PREFIX "../bin/Release/") -- 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(-) 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(-) 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 1a51dff438a5a5ec14b3d31ab081f818c422266f Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 25 Oct 2013 14:09:11 +0200 Subject: remove kludgy compensation Signed-off-by: Stanislaw Halik --- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index 25273f35..43ffc717 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -254,7 +254,7 @@ void Tracker::run() cv::Rodrigues(rvec, rotation_matrix); cv::Vec3d foo = cv::RQDecomp3x3(rotation_matrix, junk1, junk2); - + QMutexLocker lck(&mtx); for (int i = 0; i < 3; i++) @@ -264,8 +264,8 @@ void Tracker::run() pose[Pitch] = -foo[0]; pose[Roll] = foo[2]; - pose[Yaw] -= atan(pose[TX] / pose[TZ]) * 180 / HT_PI; - pose[Pitch] -= atan(pose[TY] / pose[TZ]) * 180 / HT_PI; + //pose[Yaw] -= atan(pose[TX] / pose[TZ]) * 180 / HT_PI; + //pose[Pitch] -= atan(pose[TY] / pose[TZ]) * 180 / HT_PI; } } } -- 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(-) 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 f5d310a7da41456582e85e67376bcda99321a169 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 25 Oct 2013 14:44:15 +0200 Subject: Fix installer version --- CMakeLists.txt | 2 ++ installer/opentrack-installer.iss | 2 +- opentrack-version.h | 6 +++++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 08d1f64a..2f999144 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -574,6 +574,8 @@ if(UNIX) 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(UNIX) target_link_libraries(opentrack opentrack-qxt-mini) endif() diff --git a/installer/opentrack-installer.iss b/installer/opentrack-installer.iss index ca04af71..5e3a547d 100644 --- a/installer/opentrack-installer.iss +++ b/installer/opentrack-installer.iss @@ -1,7 +1,7 @@ ; Script generated by the Inno Setup Script Wizard. ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! -#include "../opentrack-version.h" +#include "../build/opentrack-version.h" #define MyAppName "opentrack" #define MyAppVersion OPENTRACK_VERSION #define MyAppPublisher "opentrack" diff --git a/opentrack-version.h b/opentrack-version.h index 1b941000..f31d5edf 100644 --- a/opentrack-version.h +++ b/opentrack-version.h @@ -1,3 +1,7 @@ #ifndef OPENTRACK_VERSION -# define OPENTRACK_VERSION "Mourns-For-Trees" +# define OPENTRACK_VERSION @OPENTRACK_COMMIT_VERSION@ +#else +# ifndef OPENTRACK_VERSION +# define OPENTRACK_VERSION "Mourns-For-Trees" +# endif #endif -- 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(-) 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(-) 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 dd41b87d6029d2accd3c32ea71873beefaebb149 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 25 Oct 2013 15:29:53 +0200 Subject: don't flood stderr with each and every qfc Signed-off-by: Stanislaw Halik --- qfunctionconfigurator/functionconfig.cpp | 3 --- qfunctionconfigurator/qfunctionconfigurator.cpp | 5 ----- 2 files changed, 8 deletions(-) diff --git a/qfunctionconfigurator/functionconfig.cpp b/qfunctionconfigurator/functionconfig.cpp index f9c9957e..b937d95e 100644 --- a/qfunctionconfigurator/functionconfig.cpp +++ b/qfunctionconfigurator/functionconfig.cpp @@ -16,7 +16,6 @@ #include #include #include -#include // // Constructor with List of Points in argument. @@ -235,8 +234,6 @@ void FunctionConfig::loadSettings(QSettings& settings) { 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()); diff --git a/qfunctionconfigurator/qfunctionconfigurator.cpp b/qfunctionconfigurator/qfunctionconfigurator.cpp index 1d401ddd..afd6561b 100644 --- a/qfunctionconfigurator/qfunctionconfigurator.cpp +++ b/qfunctionconfigurator/qfunctionconfigurator.cpp @@ -69,7 +69,6 @@ void QFunctionConfigurator::setConfig(FunctionConfig* config, QString settingsFi strSettingsFile = settingsFile; // Remember for Reset() - qDebug() << "QFunctionConfigurator::setConfig" << config->getTitle(); setCaption(config->getTitle()); _draw_function = _draw_background = true; @@ -83,7 +82,6 @@ void QFunctionConfigurator::loadSettings(QString settingsFile) { QSettings iniFile( settingsFile, QSettings::IniFormat ); // Application settings (in INI-file) strSettingsFile = settingsFile; // Remember for Reset() - qDebug() << "QFunctionConfigurator::loadSettings = " << settingsFile; if (_config) { _config->loadSettings(iniFile); } @@ -95,7 +93,6 @@ void QFunctionConfigurator::loadSettings(QString settingsFile) { void QFunctionConfigurator::saveSettings(QString settingsFile) { QSettings iniFile( settingsFile, QSettings::IniFormat ); // Application settings (in INI-file) strSettingsFile = settingsFile; // Remember for Reset() - qDebug() << "QFunctionConfigurator::saveSettings = " << settingsFile; if (_config) { _config->saveSettings(iniFile); @@ -617,8 +614,6 @@ void QFunctionConfigurator::resizeEvent(QResizeEvent *) { range = QRectF(40, 20, MaxInput * pPerEGU_Input, MaxOutput * pPerEGU_Output); - qDebug() << "QFunctionConfigurator::resizeEvent, name = " << strCaption << ",range = " << range; - _draw_background = true; _draw_function = true; repaint(); -- cgit v1.2.3 From e078be0f0739b51a968b30fe3df60f464840eb25 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 25 Oct 2013 16:24:54 +0200 Subject: add libqxt notice --- 3rdparty-notices/LIBQXT-COPYING.txt | 40 +++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 3rdparty-notices/LIBQXT-COPYING.txt diff --git a/3rdparty-notices/LIBQXT-COPYING.txt b/3rdparty-notices/LIBQXT-COPYING.txt new file mode 100644 index 00000000..252b76ba --- /dev/null +++ b/3rdparty-notices/LIBQXT-COPYING.txt @@ -0,0 +1,40 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ -- 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(-) 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(-) 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 b2a9a536f11a5723764d44c0c1517670048d046c Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 25 Oct 2013 17:14:23 +0200 Subject: update readme --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2c76605e..68442dc1 100644 --- a/README.md +++ b/README.md @@ -15,8 +15,9 @@ Not to be confused with railway planning software <> - Oculus Rift (Windows; Linux testers welcome!) - AR marker support via the ArUco library - HT tracker -- Razer Hydra (Windows only) +- Razer Hydra (Windows; Linux testers welcome!) - Relaying via UDP from a different computer +- Joystick analog axes (Windows only) # Output -- cgit v1.2.3 From e5f2a0407077e1352d6633c5b7f6fbe3b5c5b250 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 25 Oct 2013 22:32:18 +0200 Subject: PT: possibly fix applying settings Signed-off-by: Stanislaw Halik --- FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp index b1392953..e3bcafc0 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp @@ -206,7 +206,6 @@ void Tracker::Initialize(QFrame *video_frame) settings.load_ini(); apply(settings); camera.start(); - apply(settings); start(); } -- cgit v1.2.3 From aba4019cb6c33dce5ed1b2b637c8a1e8df76508b Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 25 Oct 2013 22:40:37 +0200 Subject: PT: don't loop forever on camera unplug --- FTNoIR_Tracker_PT/camera.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FTNoIR_Tracker_PT/camera.cpp b/FTNoIR_Tracker_PT/camera.cpp index 0ef617c3..d360a819 100644 --- a/FTNoIR_Tracker_PT/camera.cpp +++ b/FTNoIR_Tracker_PT/camera.cpp @@ -185,7 +185,7 @@ bool CVCamera::_get_frame(Mat* frame) * frames and then some every once in a while * -sh */ - while (!cap->read(img)) + for (int i = 0; i < 100 && !cap->read(img); i++) ;; if (img.empty()) -- cgit v1.2.3 From 1538a796e1202dc9769565a6f7556adcea877478 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 25 Oct 2013 23:00:25 +0200 Subject: PT: fix for Windows framerate display Signed-off-by: Stanislaw Halik --- FTNoIR_Tracker_PT/timer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/FTNoIR_Tracker_PT/timer.cpp b/FTNoIR_Tracker_PT/timer.cpp index a3141113..080dd713 100644 --- a/FTNoIR_Tracker_PT/timer.cpp +++ b/FTNoIR_Tracker_PT/timer.cpp @@ -54,13 +54,13 @@ double Timer::elapsed() startTime = startCount.QuadPart * (1e3 / frequency.QuadPart); endTime = endCount.QuadPart * (1e3 / frequency.QuadPart); + return endTime - startTime; #else if(running) gettimeofday(&endCount, NULL); startTime = (startCount.tv_sec) + startCount.tv_usec * 1e-6; endTime = (endCount.tv_sec) + endCount.tv_usec * 1e-6; -#endif - return (endTime - startTime) * 1e3; +#endif } -- cgit v1.2.3 From 3c383b2b8215fec0b25244e34a7072bef0482bc9 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 25 Oct 2013 23:06:11 +0200 Subject: Fix installer name Signed-off-by: Stanislaw Halik --- installer/opentrack-installer.iss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/installer/opentrack-installer.iss b/installer/opentrack-installer.iss index 5e3a547d..dda574eb 100644 --- a/installer/opentrack-installer.iss +++ b/installer/opentrack-installer.iss @@ -23,7 +23,7 @@ AppUpdatesURL={#MyAppURL} DefaultDirName={pf}\{#MyAppName} DefaultGroupName={#MyAppName} AllowNoIcons=yes -OutputBaseFilename=opentrack-setup-{#MyAppVersion} +OutputBaseFilename={#MyAppVersion}-setup.exe SetupIconFile=d:\opentrack-win32-sdk\opentrack\facetracknoir\facetracknoir.ico Compression=lzma2/ultra64 SolidCompression=yes -- cgit v1.2.3 From 6d08b08d1e3ed9e020ea165b50a9bef1488eb1c4 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 25 Oct 2013 23:37:28 +0200 Subject: aruco: show FPS and spacing Signed-off-by: Stanislaw Halik --- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 30 ++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index 43ffc717..ad4643d0 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -185,6 +185,12 @@ void Tracker::run() fprintf(stderr, "aruco tracker: can't open camera\n"); return; } + + auto freq = cv::getTickFrequency(); + auto last_time = cv::getTickCount(); + auto prev_time = last_time; + int fps = 0; + int last_fps = 0; while (!stop) { @@ -204,7 +210,7 @@ void Tracker::run() intrinsics.at (1, 1) = focal_length_h; intrinsics.at (0, 2) = grayscale.cols/2; intrinsics.at (1, 2) = grayscale.rows/2; - + cv::Mat dist_coeffs = cv::Mat::zeros(5, 1, CV_32FC1); for (int i = 0; i < 5; i++) @@ -219,9 +225,27 @@ void Tracker::run() for (int i = 0; i < 4; i++) cv::line(color, m[i], m[(i+1)%4], cv::Scalar(0, 0, 255), 4); } - + + auto time = cv::getTickCount(); + + if ((long) (time / freq) != (long) (last_time / freq)) + { + last_fps = fps; + fps = 0; + last_time = time; + } + + fps++; + + char buf[128]; + + std::sprintf(buf, "Hz: %ld", last_fps); + cv::putText(frame, buf, cv::Point(10, 30), cv::FONT_HERSHEY_PLAIN, 2.0, cv::Scalar(0, 255, 0), 2); + std::sprintf(buf, "Delay: %ld ms", (long) (1000 * (time - prev_time) / freq)); + cv::putText(frame, buf, cv::Point(10, 50), cv::FONT_HERSHEY_PLAIN, 2.0, cv::Scalar(0, 255, 0), 2); + prev_time = time; + frame = color; - if (frame.rows > 0) { videoWidget->update_image(frame.data, frame.cols, frame.rows); -- cgit v1.2.3 From a430e297d011295131a24419fda4a9b28f22c539 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 25 Oct 2013 23:53:00 +0200 Subject: aruco: show reprojection Signed-off-by: Stanislaw Halik --- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index ad4643d0..2bb3ad77 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -191,6 +191,7 @@ void Tracker::run() auto prev_time = last_time; int fps = 0; int last_fps = 0; + std::vector reprojection; while (!stop) { @@ -223,7 +224,16 @@ void Tracker::run() if (markers.size() == 1 && markers[0].size() == 4) { const aruco::Marker& m = markers.at(0); for (int i = 0; i < 4; i++) - cv::line(color, m[i], m[(i+1)%4], cv::Scalar(0, 0, 255), 4); + cv::line(color, m[i], m[(i+1)%4], cv::Scalar(0, 0, 255), 3); + } + + for (int i = 0; i < reprojection.size(); i++) + { + cv::circle(frame, + reprojection[i], + 6, + cv::Scalar(0, 255, 128), + 3); } auto time = cv::getTickCount(); @@ -287,7 +297,11 @@ void Tracker::run() pose[Yaw] = foo[1]; pose[Pitch] = -foo[0]; pose[Roll] = foo[2]; - + + reprojection.clear(); + reprojection.resize(4); + cv::projectPoints(obj_points, rvec, tvec, intrinsics, dist_coeffs, reprojection); + //pose[Yaw] -= atan(pose[TX] / pose[TZ]) * 180 / HT_PI; //pose[Pitch] -= atan(pose[TY] / pose[TZ]) * 180 / HT_PI; } -- cgit v1.2.3 From 9195c580050947c845ff29f79a3854acfe41b387 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 25 Oct 2013 23:58:34 +0200 Subject: aruco: show reprojection error Signed-off-by: Stanislaw Halik --- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index 2bb3ad77..5de62176 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -191,6 +191,7 @@ void Tracker::run() auto prev_time = last_time; int fps = 0; int last_fps = 0; + double error = 0; std::vector reprojection; while (!stop) @@ -250,9 +251,11 @@ void Tracker::run() char buf[128]; std::sprintf(buf, "Hz: %ld", last_fps); - cv::putText(frame, buf, cv::Point(10, 30), cv::FONT_HERSHEY_PLAIN, 2.0, cv::Scalar(0, 255, 0), 2); + cv::putText(frame, buf, cv::Point(10, 32), cv::FONT_HERSHEY_PLAIN, 2.0, cv::Scalar(0, 255, 0), 2); std::sprintf(buf, "Delay: %ld ms", (long) (1000 * (time - prev_time) / freq)); - cv::putText(frame, buf, cv::Point(10, 50), cv::FONT_HERSHEY_PLAIN, 2.0, cv::Scalar(0, 255, 0), 2); + cv::putText(frame, buf, cv::Point(10, 54), cv::FONT_HERSHEY_PLAIN, 2.0, cv::Scalar(80, 255, 0), 2); + std::sprintf(buf, "Error: %f px", error); + cv::putText(frame, buf, cv::Point(10, 76), cv::FONT_HERSHEY_PLAIN, 2.0, cv::Scalar(80, 255, 0), 2); prev_time = time; frame = color; @@ -302,6 +305,14 @@ void Tracker::run() reprojection.resize(4); cv::projectPoints(obj_points, rvec, tvec, intrinsics, dist_coeffs, reprojection); + error = 0; + for (int i = 0; i < 4; i++) + { + double x = reprojection[i].x - m[i].x; + double y = reprojection[i].y - m[i].y; + error += std::sqrt(x * x + y * y); + } + //pose[Yaw] -= atan(pose[TX] / pose[TZ]) * 180 / HT_PI; //pose[Pitch] -= atan(pose[TY] / pose[TZ]) * 180 / HT_PI; } -- cgit v1.2.3 From 4c0ecfa917bc0a26c29a6b33ad998e1711966107 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 26 Oct 2013 00:04:05 +0200 Subject: ar: gauss kernel 7 -> 5 (callgrind) Signed-off-by: Stanislaw Halik --- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index 5de62176..ecfec7d3 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -200,7 +200,7 @@ void Tracker::run() continue; color_.copyTo(color); cv::cvtColor(color, grayscale2, cv::COLOR_BGR2GRAY); - const int kernel = grayscale2.cols > 480 ? 7 : 5; + const int kernel = grayscale2.cols > 480 ? 5 : 3; int kernel2 = kernel * grayscale2.rows / grayscale2.cols - 1; if ((kernel2 % 2) == 0) kernel2++; -- cgit v1.2.3 From d69f0da66b7ad9eb78174acf1c6844de61b34962 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 26 Oct 2013 01:37:14 +0200 Subject: accela: ui broke with runtime dpi changes. fix it. Signed-off-by: Stanislaw Halik --- .../ftnoir_accela_filtercontrols.ui | 54 ++++++---------------- 1 file changed, 15 insertions(+), 39 deletions(-) diff --git a/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui b/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui index 324acdf9..c7bd2808 100644 --- a/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui +++ b/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui @@ -14,15 +14,15 @@ - + 0 0 - 0 - 0 + 347 + 268 @@ -47,26 +47,20 @@ - - - QFormLayout::ExpandingFieldsGrow - - - 4 - - - 4 - + 6 + + 4 + true - + 0 0 @@ -84,24 +78,6 @@ Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - QFormLayout::ExpandingFieldsGrow - - - QFormLayout::DontWrapRows - - - Qt::AlignRight|Qt::AlignTop|Qt::AlignTrailing - - - Qt::AlignRight|Qt::AlignTop|Qt::AlignTrailing - - - 6 - - - 2 - @@ -121,7 +97,7 @@ - + 0 0 @@ -162,7 +138,7 @@ - + 0 0 @@ -216,14 +192,14 @@ background:none; - + 0 0 - 96 + 20 22 @@ -259,7 +235,7 @@ background:none; - + 0 0 @@ -529,7 +505,7 @@ background:none; - + @@ -574,7 +550,7 @@ background:none; - + QDialogButtonBox::Cancel|QDialogButtonBox::Ok -- cgit v1.2.3 From ff2599f783cc556991e51ef68f260f0773bb50b7 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 26 Oct 2013 01:37:25 +0200 Subject: accela: sadly, change scaling coefficient Signed-off-by: Stanislaw Halik --- ftnoir_filter_accela/ftnoir_filter_accela.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.cpp b/ftnoir_filter_accela/ftnoir_filter_accela.cpp index abde4d46..29fe9067 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela.cpp @@ -64,7 +64,7 @@ void FTNoIR_Filter::receiveSettings(double rot, double trans, double zoom_fac) static inline double parabola(const double a, const double x) { const double a1 = 1./a; - return a1 * x * x; + return a1 * pow(x, 2.2); } void FTNoIR_Filter::FilterHeadPoseData(const double* target_camera_position, -- cgit v1.2.3 From 518a33b62dba0f068c34aef3dc52070e0867019a Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 26 Oct 2013 01:37:47 +0200 Subject: ar: use pre-computed gaussian kernel for 20% speed increase Signed-off-by: Stanislaw Halik --- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index ecfec7d3..b532ac9c 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -193,18 +193,20 @@ void Tracker::run() int last_fps = 0; double error = 0; std::vector reprojection; - + auto kernel = cv::createGaussianFilter(CV_8U, cv::Size(5, 5), 0); while (!stop) { if (!camera.read(color_)) continue; color_.copyTo(color); cv::cvtColor(color, grayscale2, cv::COLOR_BGR2GRAY); - const int kernel = grayscale2.cols > 480 ? 5 : 3; - int kernel2 = kernel * grayscale2.rows / grayscale2.cols - 1; - if ((kernel2 % 2) == 0) - kernel2++; - cv::GaussianBlur(grayscale2, grayscale, cv::Size(kernel, kernel2), 0, 0); + if (grayscale.empty()) + grayscale = grayscale2.clone(); + + kernel->apply(grayscale2, grayscale); + + const int scale = frame.cols > 480 ? 2 : 1; + const float focal_length_w = 0.5 * grayscale.cols / tan(0.5 * fov * HT_PI / 180); const float focal_length_h = 0.5 * grayscale.rows / tan(0.5 * fov * grayscale.rows / grayscale.cols * HT_PI / 180.0); cv::Mat intrinsics = cv::Mat::eye(3, 3, CV_32FC1); @@ -225,7 +227,7 @@ void Tracker::run() if (markers.size() == 1 && markers[0].size() == 4) { const aruco::Marker& m = markers.at(0); for (int i = 0; i < 4; i++) - cv::line(color, m[i], m[(i+1)%4], cv::Scalar(0, 0, 255), 3); + cv::line(color, m[i], m[(i+1)%4], cv::Scalar(0, 0, 255), scale); } for (int i = 0; i < reprojection.size(); i++) @@ -251,11 +253,11 @@ void Tracker::run() char buf[128]; std::sprintf(buf, "Hz: %ld", last_fps); - cv::putText(frame, buf, cv::Point(10, 32), cv::FONT_HERSHEY_PLAIN, 2.0, cv::Scalar(0, 255, 0), 2); + cv::putText(frame, buf, cv::Point(10, 32), cv::FONT_HERSHEY_PLAIN, scale, cv::Scalar(0, 255, 0), scale); std::sprintf(buf, "Delay: %ld ms", (long) (1000 * (time - prev_time) / freq)); - cv::putText(frame, buf, cv::Point(10, 54), cv::FONT_HERSHEY_PLAIN, 2.0, cv::Scalar(80, 255, 0), 2); + cv::putText(frame, buf, cv::Point(10, 54), cv::FONT_HERSHEY_PLAIN, scale, cv::Scalar(80, 255, 0), scale); std::sprintf(buf, "Error: %f px", error); - cv::putText(frame, buf, cv::Point(10, 76), cv::FONT_HERSHEY_PLAIN, 2.0, cv::Scalar(80, 255, 0), 2); + cv::putText(frame, buf, cv::Point(10, 76), cv::FONT_HERSHEY_PLAIN, scale, cv::Scalar(80, 255, 0), scale); prev_time = time; frame = color; -- cgit v1.2.3 From 2ef588a212334ea88a00b8579af7a4b7d134a13c Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 26 Oct 2013 15:51:22 +0200 Subject: Hopefully fix PT fps now Signed-off-by: Stanislaw Halik --- FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp index e3bcafc0..f13021a9 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp @@ -204,8 +204,8 @@ void Tracker::Initialize(QFrame *video_frame) update_show_video_widget(); TrackerSettings settings; settings.load_ini(); - apply(settings); - camera.start(); + camera.start(); + apply(settings); start(); } -- cgit v1.2.3 From fe020b5b69549ef652b41c2deca0c2dedde3c13c Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 26 Oct 2013 16:09:48 +0200 Subject: fix one more PT edge case Signed-off-by: Stanislaw Halik --- FTNoIR_Tracker_PT/camera.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/FTNoIR_Tracker_PT/camera.cpp b/FTNoIR_Tracker_PT/camera.cpp index d360a819..e5ecdc99 100644 --- a/FTNoIR_Tracker_PT/camera.cpp +++ b/FTNoIR_Tracker_PT/camera.cpp @@ -132,6 +132,7 @@ void Camera::set_res(int x_res, int y_res) cam_desired.res_x = x_res; cam_desired.res_y = y_res; _set_res(); + _set_fps(); } } -- cgit v1.2.3 From ef7bba81d346e86e92428b75f41ff6ef148e4928 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 26 Oct 2013 16:26:27 +0200 Subject: pt: decruft following c++11 requirement Signed-off-by: Stanislaw Halik --- FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp index f13021a9..9aed5a1f 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp @@ -115,11 +115,7 @@ void Tracker::apply(const TrackerSettings& settings) point_extractor.threshold_val = settings.threshold; point_extractor.min_size = settings.min_point_size; 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; -- cgit v1.2.3 From a3885f8346920a8238d890361e417585d67ed1eb Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 26 Oct 2013 16:31:40 +0200 Subject: PT: use full frame size Signed-off-by: Stanislaw Halik --- FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp index 9aed5a1f..5cb7bdf3 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp @@ -177,8 +177,8 @@ void Tracker::update_show_video_widget() } else if (video_frame && show_video_widget && !video_widget) { - const int VIDEO_FRAME_WIDTH = 252; - const int VIDEO_FRAME_HEIGHT = 189; + const int VIDEO_FRAME_WIDTH = 320; + const int VIDEO_FRAME_HEIGHT = 240; video_widget = new PTVideoWidget(video_frame, this); QHBoxLayout* video_layout = new QHBoxLayout(); video_layout->setContentsMargins(0, 0, 0, 0); -- 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 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 01e54dcfea418c474a3a52503286aa68b6097845 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 26 Oct 2013 19:42:15 +0200 Subject: Project Evil: pezzo di merda, figlio di puttana Tested-by: Tomasz Listwam --- bin/NPClient.dll | Bin 51139 -> 20591 bytes bin/NPClient64.dll | Bin 21161 -> 20487 bytes 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/bin/NPClient.dll b/bin/NPClient.dll index 5000c898..9d6d2691 100755 Binary files a/bin/NPClient.dll and b/bin/NPClient.dll differ diff --git a/bin/NPClient64.dll b/bin/NPClient64.dll index 34da48c6..8d78e94f 100755 Binary files a/bin/NPClient64.dll and b/bin/NPClient64.dll differ -- cgit v1.2.3 From 5aba827a1d3dec8a74afe2190fe71ea602fb1c4b Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 26 Oct 2013 19:42:15 +0200 Subject: Project Evil: pezzo di merda, figlio di puttana Tested-by: Tomasz Listwam --- bin/NPClient.dll | Bin 51139 -> 20591 bytes bin/NPClient64.dll | Bin 21161 -> 20487 bytes 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/bin/NPClient.dll b/bin/NPClient.dll index 5000c898..9d6d2691 100755 Binary files a/bin/NPClient.dll and b/bin/NPClient.dll differ diff --git a/bin/NPClient64.dll b/bin/NPClient64.dll index 34da48c6..8d78e94f 100755 Binary files a/bin/NPClient64.dll and b/bin/NPClient64.dll differ -- cgit v1.2.3 From 12f74077aa7099c87aed623a241619893a6bf304 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 26 Oct 2013 21:00:01 +0200 Subject: File already present in 3rdparty-notices/ --- bin/licence.rtf | 361 -------------------------------------------------------- 1 file changed, 361 deletions(-) delete mode 100644 bin/licence.rtf diff --git a/bin/licence.rtf b/bin/licence.rtf deleted file mode 100644 index c0337ab4..00000000 --- a/bin/licence.rtf +++ /dev/null @@ -1,361 +0,0 @@ -{\rtf1\ansi\deff1\adeflang1025 -{\fonttbl{\f0\froman\fprq2\fcharset0 Times New Roman;}{\f1\fmodern\fprq1\fcharset0 Nimbus Mono L{\*\falt Courier New};}{\f2\fswiss\fprq2\fcharset0 Arial;}{\f3\fmodern\fprq1\fcharset0 Nimbus Mono L{\*\falt Courier New};}{\f4\froman\fprq2\fcharset0 Nimbus Roman No9 L{\*\falt Times New Roman};}{\f5\fnil\fprq2\fcharset0 SimSun;}{\f6\fnil\fprq2\fcharset0 Tahoma;}{\f7\fnil\fprq0\fcharset0 Tahoma;}} -{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green0\blue128;\red128\green128\blue128;} -{\stylesheet{\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031\snext1 Normal;} -{\s2\sb240\sa120\keepn\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af6\afs28\lang1081\ltrch\dbch\af5\langfe2052\hich\f2\fs28\lang1031\loch\f2\fs28\lang1031\sbasedon1\snext3 Heading;} -{\s3\sa120\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031\sbasedon1\snext3 Body Text;} -{\s4\sa120\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af7\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031\sbasedon3\snext4 List;} -{\s5\sb120\sa120\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af7\afs24\lang1081\ai\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\i\loch\f1\fs24\lang1031\i\sbasedon1\snext5 caption;} -{\s6\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af7\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031\sbasedon1\snext6 Index;} -{\*\cs8\cf3\ul\ulc0\rtlch\af1\afs24\lang255\ltrch\dbch\af1\langfe255\hich\f1\fs24\lang255\loch\f1\fs24\lang255 Internet link;} -} -{\info{\creatim\yr0\mo0\dy0\hr0\min0}{\revtim\yr0\mo0\dy0\hr0\min0}{\printim\yr0\mo0\dy0\hr0\min0}{\comment StarWriter}{\vern3200}}\deftab709 -{\*\pgdsctbl -{\pgdsc0\pgdscuse195\pgwsxn12240\pghsxn18720\marglsxn1134\margrsxn1134\margtsxn1134\margbsxn1134\pgdscnxt0 Standard;}} -{\*\pgdscno0}\paperh18720\paperw12240\margl1134\margr1134\margt1134\margb1134\sectd\sbknone\pgwsxn12240\pghsxn18720\marglsxn1134\margrsxn1134\margtsxn1134\margbsxn1134\ftnbj\ftnstart1\ftnrstcont\ftnnar\aenddoc\aftnrstcont\aftnstart1\aftnnrlc -\pard\plain \ltrpar\s1\cf0\qc{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs40\lang1081\ab\ltrch\dbch\af1\langfe2052\hich\f1\fs40\lang9226\b\loch\f1\fs40\lang9226\b {\rtlch \ltrch\loch\f1\fs40\lang9226\i0\b GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007} -\par \pard\plain \ltrpar\s1\cf0\qc{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs36\lang1081\ab\ltrch\dbch\af1\langfe2052\hich\f1\fs36\lang9226\b\loch\f1\fs36\lang9226\b -\par \pard\plain \ltrpar\s1\cf0\qc{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs20\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs20\lang9226\loch\f1\fs20\lang9226 -\par \pard\plain \ltrpar\s1\cf0\qj{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031{\rtlch \ltrch\loch\f1\fs24\lang1031\i0\b0{\rtlch\ltrch\dbch\hich\f4\lang9226\loch\f4\lang9226 Copyright (C) 2007 Free Software Foundation, Inc. <}}{\rtlch \ltrch\loch\f1\fs24\lang1031\i0\b0{\cf2\ul\ulc0\rtlch\ltrch\dbch\hich\f4\lang9226\loch\f4\lang9226{\field{\*\fldinst HYPERLINK "http://fsf.org/" }{\fldrslt \*\cs8\cf3\ul\ulc0\rtlch\ltrch\dbch\hich\f1\fs24\lang255\loch\f1\fs24\lang255 http://fsf.org/}{\rtlch\ltrch\dbch\hich\f4\lang9226\loch\f4\lang9226}} >}} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang9226\loch\f1\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 Preamble} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang9226\loch\f1\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 The GNU General Public License is a free, copyleft license for software and other kinds of works.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang9226\loch\f1\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program- --to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031 {\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 your programs, too.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang9226\loch\f1\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code o -r can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031 -\par \pard\plain \ltrpar\s1\cf0\qj{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect -the freedom of others.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0\qj{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them th -ese terms so they know their rights.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0\qj{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 Developers that use the GNU GPL protect your rights with two steps:} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031 -\par \pard\plain \ltrpar\s1\cf0\qj{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be att -ributed erroneously to authors of previous versions.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0\qj{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The -systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems ar -ise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang9226\loch\f1\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents appli -ed to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031 -\par \pard\plain \ltrpar\s1\cf0\qj{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 The precise terms and conditions for copying, distribution and modification follow.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0\qc{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 TERMS AND CONDITIONS} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0\qj{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 0. Definitions.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang9226\loch\f1\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 "This License" refers to version 3 of the GNU General Public License.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang9226\loch\f1\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang9226\loch\f1\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang9226\loch\f1\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the ear -lier work.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031 -\par \pard\plain \ltrpar\s1\cf0\qj{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 A "covered work" means either the unmodified Program or a work based on the Program.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031 {\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes - copying, distribution (with or without modification), making available to the} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031 {\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 public, and in some countries other activities as well.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang9226\loch\f1\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang9226\loch\f1\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0\qj{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work -(except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list -meets this criterion.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang9226\loch\f1\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031{\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f1\fs24\lang1031\i0\b0\rtlch\ltrch\dbch\hich\f4\lang9226\loch\f4\lang9226 1. Source Code.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang9226\loch\f1\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031{\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f1\fs24\lang1031\i0\b0\rtlch\ltrch\dbch\hich\f4\lang9226\loch\f4\lang9226 The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang9226\loch\f1\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031{\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f1\fs24\lang1031\i0\b0\rtlch\ltrch\dbch\hich\f4\lang9226\loch\f4\lang9226 A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that -language.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang9226\loch\f1\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031{\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f1\fs24\lang1031\i0\b0\rtlch\ltrch\dbch\hich\f4\lang9226\loch\f4\lang9226 The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the - work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of - the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang9226\loch\f1\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031{\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f1\fs24\lang1031\i0\b0\rtlch\ltrch\dbch\hich\f4\lang9226\loch\f4\lang9226 The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not - include the work's System Libraries, or general-purpose tools or generally available free} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries - and dynamically linked subprograms that the work is specifically designed to require,} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031 {\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 such as by intimate data communication or control flow between those subprograms and other parts of the work.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang9226\loch\f1\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031{\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f1\fs24\lang1031\i0\b0\rtlch\ltrch\dbch\hich\f4\lang9226\loch\f4\lang9226 The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang9226\loch\f1\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031{\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f1\fs24\lang1031\i0\b0\rtlch\ltrch\dbch\hich\f4\lang9226\loch\f4\lang9226 The Corresponding Source for a work in source code form is that same work.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang9226\loch\f1\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031{\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f1\fs24\lang1031\i0\b0\rtlch\ltrch\dbch\hich\f4\lang9226\loch\f4\lang9226 2. Basic Permissions.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang9226\loch\f1\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031{\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f1\fs24\lang1031\i0\b0\rtlch\ltrch\dbch\hich\f4\lang9226\loch\f4\lang9226 All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output -from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 rights of fair use or other equivalent, as provided by copyright law.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang9226\loch\f1\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031{\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f1\fs24\lang1031\i0\b0\rtlch\ltrch\dbch\hich\f4\lang9226\loch\f4\lang9226 You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for yo -u, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031 -\par \pard\plain \ltrpar\s1\cf0\qj{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang9226\loch\f1\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031{\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f1\fs24\lang1031\i0\b0\rtlch\ltrch\dbch\hich\f4\lang9226\loch\f4\lang9226 3. Protecting Users' Legal Rights From Anti-Circumvention Law.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang9226\loch\f1\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031{\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f1\fs24\lang1031\i0\b0\rtlch\ltrch\dbch\hich\f4\lang9226\loch\f4\lang9226 No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention - of such measures.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang9226\loch\f1\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031{\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f1\fs24\lang1031\i0\b0\rtlch\ltrch\dbch\hich\f4\lang9226\loch\f4\lang9226 When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intent -ion to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031{\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f1\fs24\lang1031\i0\b0\rtlch\ltrch\dbch\hich\f4\lang9226\loch\f4\lang9226 4. Conveying Verbatim Copies.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang9226\loch\f1\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0\qj{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and an -y non-permissive terms added in accord with section 7 apply to the code;} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang9226\loch\f1\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031{\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f1\fs24\lang1031\i0\b0\rtlch\ltrch\dbch\hich\f4\lang9226\loch\f4\lang9226 You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031{\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f1\fs24\lang1031\i0\b0\rtlch\ltrch\dbch\hich\f4\lang9226\loch\f4\lang9226 5. Conveying Modified Source Versions.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang9226\loch\f1\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031{\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f1\fs24\lang1031\i0\b0\rtlch\ltrch\dbch\hich\f4\lang9226\loch\f4\lang9226 You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions:} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang9226\loch\f1\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0\qj{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 a) The work must carry prominent notices stating that you modified} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031{\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f1\fs24\lang1031\i0\b0\rtlch\ltrch\dbch\hich\f4\lang9226\loch\f4\lang9226 it, and giving a relevant date.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang9226\loch\f1\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031{\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f1\fs24\lang1031\i0\b0\rtlch\ltrch\dbch\hich\f4\lang9226\loch\f4\lang9226 b) The work must carry prominent notices stating that it is released under this License and any conditions added under section } -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031{\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f1\fs24\lang1031\i0\b0\rtlch\ltrch\dbch\hich\f4\lang9226\loch\f4\lang9226 7. This requirement modifies the requirement in section 4 to "keep intact all notices".} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang9226\loch\f1\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031{\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f1\fs24\lang1031\i0\b0\rtlch\ltrch\dbch\hich\f4\lang9226\loch\f4\lang9226 c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0\qj{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0\qj{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution m -edium, is called an "aggregate" if the compilation and its resulting copyright are not} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031 -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031{\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f1\fs24\lang1031\i0\b0\rtlch\ltrch\dbch\hich\f4\lang9226\loch\f4\lang9226 6. Conveying Non-Source Forms.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang9226\loch\f1\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031{\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f1\fs24\lang1031\i0\b0\rtlch\ltrch\dbch\hich\f4\lang9226\loch\f4\lang9226 You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways:} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang9226\loch\f1\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0\qj{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang9226\loch\f1\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031{\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f1\fs24\lang1031\i0\b0\rtlch\ltrch\dbch\hich\f4\lang9226\loch\f4\lang9226 b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that prod -uct model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price -no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0\qj{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in a -ccord with subsection 6b.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang9226\loch\f1\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031{\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f1\fs24\lang1031\i0\b0\rtlch\ltrch\dbch\hich\f4\lang9226\loch\f4\lang9226 d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy - the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided - you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requ -irements.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang9226\loch\f1\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031{\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f1\fs24\lang1031\i0\b0\rtlch\ltrch\dbch\hich\f4\lang9226\loch\f4\lang9226 e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0\qj{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang9226\loch\f1\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031{\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f1\fs24\lang1031\i0\b0\rtlch\ltrch\dbch\hich\f4\lang9226\loch\f4\lang9226 A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whethe -r a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the p -articular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless s -uch uses represent the only significant mode of use of the product.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0\qj{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding So -urce. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0\qj{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient i -n perpetuity or for a fixed term (regardless of how the transaction is characterized), the} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for examp -le, the work has been installed in ROM).} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031 -\par \pard\plain \ltrpar\s1\cf0\qj{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been -modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0\qj{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special passwo -rd or key for unpacking, reading or copying.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang9226\loch\f1\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 7. Additional Terms.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang9226\loch\f1\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0\qj{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this L -icense, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 under those permissions, but the entire Program remains governed by this License without regard to the additional permissions.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang9226\loch\f1\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031{\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f1\fs24\lang1031\i0\b0\rtlch\ltrch\dbch\hich\f4\lang9226\loch\f4\lang9226 When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) -You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang9226\loch\f1\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031{\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f1\fs24\lang1031\i0\b0\rtlch\ltrch\dbch\hich\f4\lang9226\loch\f4\lang9226 Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms:} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang9226\loch\f1\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031{\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f1\fs24\lang1031\i0\b0\rtlch\ltrch\dbch\hich\f4\lang9226\loch\f4\lang9226 a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang9226\loch\f1\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031{\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f1\fs24\lang1031\i0\b0\rtlch\ltrch\dbch\hich\f4\lang9226\loch\f4\lang9226 b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang9226\loch\f1\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031{\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f1\fs24\lang1031\i0\b0\rtlch\ltrch\dbch\hich\f4\lang9226\loch\f4\lang9226 c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0\qj{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 d) Limiting the use for publicity purposes of names of licensors or authors of the material; or} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang9226\loch\f1\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031{\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f1\fs24\lang1031\i0\b0\rtlch\ltrch\dbch\hich\f4\lang9226\loch\f4\lang9226 e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0\qj{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions dire -ctly impose on those licensors and authors.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0\qj{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that -is a further restriction, you may remove that term. If a license document contains} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang9226\loch\f1\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031{\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f1\fs24\lang1031\i0\b0\rtlch\ltrch\dbch\hich\f4\lang9226\loch\f4\lang9226 If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang9226\loch\f1\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031{\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f1\fs24\lang1031\i0\b0\rtlch\ltrch\dbch\hich\f4\lang9226\loch\f4\lang9226 Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031{\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f1\fs24\lang1031\i0\b0\rtlch\ltrch\dbch\hich\f4\lang9226\loch\f4\lang9226 8. Termination.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang9226\loch\f1\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0\qj{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses grant -ed under the third paragraph of section 11).} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0\qj{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the c -opyright holder fails to notify you of the violation by some reasonable means} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 prior to 60 days after the cessation.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031 -\par \pard\plain \ltrpar\s1\cf0\qj{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work -) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0\qj{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive ne -w licenses for the same material under section 10.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031{\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f1\fs24\lang1031\i0\b0\rtlch\ltrch\dbch\hich\f4\lang9226\loch\f4\lang9226 9. Acceptance Not Required for Having Copies.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang9226\loch\f1\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0\qj{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require accept -ance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang9226\loch\f1\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 10. Automatic Licensing of Downstream Recipients.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang9226\loch\f1\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0\qj{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this - License.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0\qj{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each pa -rty to that transaction who receives a copy of the work also receives whatever} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reaso -nable efforts.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031 -\par \pard\plain \ltrpar\s1\cf0\qj{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not -initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031 -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031{\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f1\fs24\lang1031\i0\b0\rtlch\ltrch\dbch\hich\f4\lang9226\loch\f4\lang9226 11. Patents.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang9226\loch\f1\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0\qj{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version".} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang9226\loch\f1\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031{\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f1\fs24\lang1031\i0\b0\rtlch\ltrch\dbch\hich\f4\lang9226\loch\f4\lang9226 A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its co -ntributor version, but do not include claims that would be infringed only as a} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031 -\par \pard\plain \ltrpar\s1\cf0\qj{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor versio -n.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0\qj{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" su -ch a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang9226\loch\f1\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031{\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f1\fs24\lang1031\i0\b0\rtlch\ltrch\dbch\hich\f4\lang9226\loch\f4\lang9226 If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other re -adily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent lice -nse, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031 {\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 country that you have reason to believe are valid.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031 -\par \pard\plain \ltrpar\s1\cf0\qj{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagat -e, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 work and works based on it.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031 -\par \pard\plain \ltrpar\s1\cf0\qj{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not con -vey a covered work if you are a party to an arrangement with a third party that is} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, - a discriminatory patent license (a) in connection with copies of the covered work} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031 {\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March - 2007.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031 -\par \pard\plain \ltrpar\s1\cf0\qj{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031{\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f1\fs24\lang1031\i0\b0\rtlch\ltrch\dbch\hich\f4\lang9226\loch\f4\lang9226 12. No Surrender of Others' Freedom.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang9226\loch\f1\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0\qj{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneo -usly your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you conve -y the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang9226\loch\f1\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 13. Use with the GNU Affero General Public License.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang9226\loch\f1\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0\qj{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The - terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 combination as such.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031 -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031{\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f1\fs24\lang1031\i0\b0\rtlch\ltrch\dbch\hich\f4\lang9226\loch\f4\lang9226 14. Revised Versions of this License.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang9226\loch\f1\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0\qj{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0\qj{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of t -hat numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0\qj{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0\qj{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031{\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f1\fs24\lang1031\i0\b0\rtlch\ltrch\dbch\hich\f4\lang9226\loch\f4\lang9226 15. Disclaimer of Warranty.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang9226\loch\f1\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0\qj{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, I -NCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NE -CESSARY SERVICING, REPAIR OR CORRECTION.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang9226\loch\f1\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 16. Limitation of Liability.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang9226\loch\f1\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0\qj{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CO -NSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRA -MS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031{\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f1\fs24\lang1031\i0\b0\rtlch\ltrch\dbch\hich\f4\lang9226\loch\f4\lang9226 17. Interpretation of Sections 15 and 16.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang9226\loch\f1\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0\qj{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in conne -ction with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031{\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f1\fs24\lang1031\i0\b0\rtlch\ltrch\dbch\hich\f4\lang9226\loch\f4\lang9226 END OF TERMS AND CONDITIONS} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang9226\loch\f1\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031{\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f1\fs24\lang1031\i0\b0\rtlch\ltrch\dbch\hich\f4\lang9226\loch\f4\lang9226 How to Apply These Terms to Your New Programs} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang9226\loch\f1\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0\qj{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang9226\loch\f1\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031{\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f1\fs24\lang1031\i0\b0\rtlch\ltrch\dbch\hich\f4\lang9226\loch\f4\lang9226 To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the f -ull notice is found.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang9226\loch\f1\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031{\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f1\fs24\lang1031\i0\b0\rtlch\ltrch\dbch\hich\f4\lang9226\loch\f4\lang9226 } -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031{\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f1\fs24\lang1031\i0\b0\rtlch\ltrch\dbch\hich\f4\lang9226\loch\f4\lang9226 Copyright (C) } -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang9226\loch\f1\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031{\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f1\fs24\lang1031\i0\b0\rtlch\ltrch\dbch\hich\f4\lang9226\loch\f4\lang9226 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.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang9226\loch\f1\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031{\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f1\fs24\lang1031\i0\b0\rtlch\ltrch\dbch\hich\f4\lang9226\loch\f4\lang9226 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.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0\qj{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031{\rtlch\ltrch\dbch\hich\loch{\rtlch \ltrch\loch }}{{\rtlch \ltrch\loch\f1\fs24\lang1031\i0\b0 You should have received a copy of the GNU General Public License along with this program. If not, see <}}{\rtlch \ltrch\loch\f1\fs24\lang1031\i0\b0{\cf2\ul\ulc0\rtlch\ltrch\dbch\hich\f4\lang9226\loch\f4\lang9226{\field{\*\fldinst HYPERLINK "http://www.gnu.org/licenses/" }{\fldrslt \*\cs8\cf3\ul\ulc0\rtlch\ltrch\dbch\hich\f1\fs24\lang255\loch\f1\fs24\lang255 http://www.gnu.org/licenses/}{\rtlch\ltrch\dbch\hich\f4\lang9226\loch\f4\lang9226}} >.}} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang9226\loch\f1\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 Also add information on how to contact you by electronic and paper mail.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031 -\par \pard\plain \ltrpar\s1\cf0\qj{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode:} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang9226\loch\f1\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 Copyright (C) } -\par \pard\plain \ltrpar\s1\cf0\qj{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031{\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f1\fs24\lang1031\i0\b0\rtlch\ltrch\dbch\hich\f4\lang9226\loch\f4\lang9226 This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang9226\loch\f1\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 {\rtlch \ltrch\loch\f4\fs24\lang9226\i0\b0 The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box".} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang9226\loch\f1\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031{\rtlch \ltrch\loch }{\rtlch \ltrch\loch\f1\fs24\lang1031\i0\b0\rtlch\ltrch\dbch\hich\f4\lang9226\loch\f4\lang9226 You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary.} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031{\rtlch \ltrch\loch\f1\fs24\lang1031\i0\b0{\rtlch\ltrch\dbch\hich\f4\lang9226\loch\f4\lang9226 For more information on this, and how to apply and follow the GNU GPL, see <}}{\rtlch \ltrch\loch\f1\fs24\lang1031\i0\b0{\cf2\ul\ulc0\rtlch\ltrch\dbch\hich\f4\lang9226\loch\f4\lang9226{\field{\*\fldinst HYPERLINK "http://www.gnu.org/licenses/" }{\fldrslt \*\cs8\cf3\ul\ulc0\rtlch\ltrch\dbch\hich\f1\fs24\lang255\loch\f1\fs24\lang255 http://www.gnu.org/licenses/}{\rtlch\ltrch\dbch\hich\f4\lang9226\loch\f4\lang9226}} >.}} -\par \pard\plain \ltrpar\s1\cf0{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af4\afs24\lang1081\ltrch\dbch\af4\langfe2052\hich\f4\fs24\lang9226\loch\f4\fs24\lang9226 -\par \pard\plain \ltrpar\s1\cf0\qj{\*\hyphen2\hyphlead2\hyphtrail2\hyphmax0}\rtlch\af1\afs24\lang1081\ltrch\dbch\af1\langfe2052\hich\f1\fs24\lang1031\loch\f1\fs24\lang1031{\rtlch\ltrch\dbch\hich\loch{\rtlch \ltrch\loch }}{{\rtlch \ltrch\loch\f1\fs24\lang1031\i0\b0 The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what y -ou want to do, use the GNU Lesser General Public License instead of this License. But first, please read <}}{\rtlch \ltrch\loch\f1\fs24\lang1031\i0\b0{\cf2\ul\ulc0\rtlch\ltrch\dbch\hich\f4\lang9226\loch\f4\lang9226{\field{\*\fldinst HYPERLINK "http://www.gnu.org/philosophy/why-not-lgpl.html" }{\fldrslt \*\cs8\cf3\ul\ulc0\rtlch\ltrch\dbch\hich\f1\fs24\lang255\loch\f1\fs24\lang255 http://www.gnu.org/philosophy/why-not-lgpl.html}{\rtlch\ltrch\dbch\hich\f4\lang9226\loch\f4\lang9226}} >.}} -\par } \ No newline at end of file -- 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(-) 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(-) 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(-) 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 512e16316ec8080a712d89dea8d4bc9847220764 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 26 Oct 2013 22:20:29 +0200 Subject: fix typo preventing ui compilation Signed-off-by: Stanislaw Halik --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2f999144..58fbfc60 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -231,7 +231,7 @@ file(GLOB opentrack-tracker-aruco-c "ftnoir_tracker_aruco/*.cpp") file(GLOB opentrack-tracker-aruco-h "ftnoir_tracker_aruco/*.h") file(GLOB opentrack-tracker-aruco-ui "ftnoir_tracker_aruco/*.ui") file(GLOB opentrack-tracker-aruco-rc "ftnoir_tracker_aruco/*.qrc") -QT5_WRAP_UI(opentracktracker-aruco-uih ${opentrack-tracker-aruco-ui}) +QT5_WRAP_UI(opentrack-tracker-aruco-uih ${opentrack-tracker-aruco-ui}) QT5_ADD_RESOURCES(opentrack-tracker-aruco-rcc ${opentrack-tracker-aruco-rc}) file(GLOB opentrack-tracker-pt-c "FTNoIR_Tracker_PT/*.cpp") -- cgit v1.2.3 From a2a32cda8e2ed8931a04a20d7422a45538c6c8b3 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 26 Oct 2013 23:02:42 +0200 Subject: implement head centroid for aruco Signed-off-by: Stanislaw Halik --- ftnoir_tracker_aruco/aruco-trackercontrols.ui | 217 ++++++++------------------ ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 84 ++++++---- ftnoir_tracker_aruco/ftnoir_tracker_aruco.h | 2 +- 3 files changed, 124 insertions(+), 179 deletions(-) diff --git a/ftnoir_tracker_aruco/aruco-trackercontrols.ui b/ftnoir_tracker_aruco/aruco-trackercontrols.ui index c007e93b..76d750af 100644 --- a/ftnoir_tracker_aruco/aruco-trackercontrols.ui +++ b/ftnoir_tracker_aruco/aruco-trackercontrols.ui @@ -32,154 +32,7 @@ -1 - - - - Distortion coefficients - - - - - - - - 0 - 0 - - - - true - - - QAbstractSpinBox::NoButtons - - - 11 - - - -1000.000000000000000 - - - 1000.000000000000000 - - - 0.000000000000000 - - - - - - - - 0 - 0 - - - - true - - - QAbstractSpinBox::NoButtons - - - 11 - - - -1000.000000000000000 - - - 1000.000000000000000 - - - 0.000000000000000 - - - - - - - - 0 - 0 - - - - true - - - QAbstractSpinBox::NoButtons - - - 11 - - - -1000.000000000000000 - - - 1000.000000000000000 - - - 0.000000000000000 - - - - - - - - 0 - 0 - - - - true - - - QAbstractSpinBox::NoButtons - - - 11 - - - -1000.000000000000000 - - - 1000.000000000000000 - - - 0.000000000000000 - - - - - - - - 0 - 0 - - - - true - - - QAbstractSpinBox::NoButtons - - - 11 - - - -1000.000000000000000 - - - 1000.000000000000000 - - - 0.000000000000000 - - - - + @@ -267,7 +120,7 @@ - + QDialogButtonBox::Cancel|QDialogButtonBox::Ok @@ -378,6 +231,72 @@ + + + + Head centroid position + + + Qt::AlignCenter + + + + Qt::AlignHCenter|Qt::AlignTop + + + + + TX + + + + + + + -200.000000000000000 + + + 200.000000000000000 + + + + + + + TY + + + + + + + -200.000000000000000 + + + 200.000000000000000 + + + + + + + TZ + + + + + + + -200.000000000000000 + + + 200.000000000000000 + + + + + + diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index b532ac9c..7ad80b46 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -120,8 +120,11 @@ void Tracker::load_settings() enableTX = iniFile.value("enable-tx", true).toBool(); enableTY = iniFile.value("enable-ty", true).toBool(); enableTZ = iniFile.value("enable-tz", true).toBool(); - for (int i = 0; i < 5; i++) - dc[i] = iniFile.value(QString("dc%1").arg(i), 0).toFloat(); + + for (int i = 0; i < 3; i++) + { + headpos[i] = iniFile.value(QString("headpos-%1").arg(i), 0).toDouble(); + } iniFile.endGroup(); } @@ -194,6 +197,7 @@ void Tracker::run() double error = 0; std::vector reprojection; auto kernel = cv::createGaussianFilter(CV_8U, cv::Size(5, 5), 0); + cv::Point2f last_centroid; while (!stop) { if (!camera.read(color_)) @@ -218,7 +222,7 @@ void Tracker::run() cv::Mat dist_coeffs = cv::Mat::zeros(5, 1, CV_32FC1); for (int i = 0; i < 5; i++) - dist_coeffs.at(i) = dc[i]; + dist_coeffs.at(i) = 0; std::vector< aruco::Marker > markers; @@ -239,6 +243,8 @@ void Tracker::run() 3); } + cv::circle(frame, last_centroid, 4, cv::Scalar(0, 0, 0), -1); + auto time = cv::getTickCount(); if ((long) (time / freq) != (long) (last_time / freq)) @@ -271,18 +277,18 @@ void Tracker::run() const float size = 7; cv::Mat obj_points(4,3,CV_32FC1); - obj_points.at(1,0)=-size; - obj_points.at(1,1)=-size; - obj_points.at(1,2)=0; - obj_points.at(2,0)=size; - obj_points.at(2,1)=-size; - obj_points.at(2,2)=0; - obj_points.at(3,0)=size; - obj_points.at(3,1)=size; - obj_points.at(3,2)=0; - obj_points.at(0,0)=-size; - obj_points.at(0,1)=size; - obj_points.at(0,2)=0; + obj_points.at(1,0)=-size + headpos[0]; + obj_points.at(1,1)=-size + headpos[1]; + obj_points.at(1,2)=0 + headpos[2]; + obj_points.at(2,0)=size + headpos[0]; + obj_points.at(2,1)=-size + headpos[1]; + obj_points.at(2,2)=0 + headpos[2]; + obj_points.at(3,0)=size + headpos[0]; + obj_points.at(3,1)=size + headpos[1]; + obj_points.at(3,2)=0 + headpos[2]; + obj_points.at(0,0)=-size + headpos[0]; + obj_points.at(0,1)=size + headpos[1]; + obj_points.at(0,2)=0 + headpos[2]; cv::solvePnP(obj_points, m, intrinsics, dist_coeffs, rvec, tvec, false, cv::ITERATIVE); @@ -315,6 +321,14 @@ void Tracker::run() error += std::sqrt(x * x + y * y); } + reprojection.clear(); + reprojection.resize(1); + std::vector centroid; + centroid.push_back(cv::Point3f(0, 0, 0)); + cv::projectPoints(centroid, rvec, tvec, intrinsics, dist_coeffs, reprojection); + + last_centroid = reprojection[0]; + //pose[Yaw] -= atan(pose[TX] / pose[TZ]) * 180 / HT_PI; //pose[Pitch] -= atan(pose[TY] / pose[TZ]) * 180 / HT_PI; } @@ -414,6 +428,9 @@ TrackerControls::TrackerControls() 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.cx, SIGNAL(valueChanged(double)), this, SLOT(settingChanged(double))); + connect(ui.cy, SIGNAL(valueChanged(double)), this, SLOT(settingChanged(double))); + connect(ui.cz, SIGNAL(valueChanged(double)), this, SLOT(settingChanged(double))); //connect(ui.buttonCancel, SIGNAL(clicked()), this, SLOT(doCancel())); //connect(ui.buttonOK, SIGNAL(clicked()), this, SLOT(doOK())); //connect(ui.buttonSettings, SIGNAL(clicked()), this, SLOT(cameraSettings())); @@ -474,13 +491,18 @@ void TrackerControls::loadSettings() ui.ty->setCheckState(iniFile.value("enable-ty", true).toBool() ? Qt::Checked : Qt::Unchecked); ui.tz->setCheckState(iniFile.value("enable-tz", true).toBool() ? Qt::Checked : Qt::Unchecked); ui.resolution->setCurrentIndex(iniFile.value("resolution", 0).toInt()); - - ui.doubleSpinBox->setValue(iniFile.value("dc0").toDouble()); - ui.doubleSpinBox_2->setValue(iniFile.value("dc1").toDouble()); - ui.doubleSpinBox_3->setValue(iniFile.value("dc2").toDouble()); - ui.doubleSpinBox_4->setValue(iniFile.value("dc3").toDouble()); - ui.doubleSpinBox_5->setValue(iniFile.value("dc4").toDouble()); - + + QDoubleSpinBox* headpos[] = { + ui.cx, + ui.cy, + ui.cz + }; + + for (int i = 0; i < 3; i++) + { + headpos[i]->setValue(iniFile.value(QString("headpos-%1").arg(i)).toDouble()); + } + iniFile.endGroup(); settingsDirty = false; } @@ -519,13 +541,17 @@ void TrackerControls::save() iniFile.setValue("enable-ty", ui.ty->checkState() != Qt::Unchecked ? true : false); iniFile.setValue("enable-tz", ui.tz->checkState() != Qt::Unchecked ? true : false); iniFile.setValue("resolution", ui.resolution->currentIndex()); - - iniFile.setValue("dc0", ui.doubleSpinBox->value()); - iniFile.setValue("dc1", ui.doubleSpinBox_2->value()); - iniFile.setValue("dc2", ui.doubleSpinBox_3->value()); - iniFile.setValue("dc3", ui.doubleSpinBox_4->value()); - iniFile.setValue("dc4", ui.doubleSpinBox_5->value()); - + + QDoubleSpinBox* headpos[] = { + ui.cx, + ui.cy, + ui.cz + }; + + for (int i = 0; i < 3; i++) + { + iniFile.setValue(QString("headpos-%1").arg(i), headpos[i]->value()); + } iniFile.endGroup(); settingsDirty = false; } diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h index 8d532b4c..5d3d4ed6 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h @@ -35,11 +35,11 @@ private: volatile bool stop; float fov; int camera_index; - float dc[5]; int force_fps, force_width, force_height; void load_settings(); double pose[6]; cv::Mat frame; + double headpos[3]; }; // Widget that has controls for FTNoIR protocol client-settings. -- cgit v1.2.3 From f1362d67a6c8c845b4ecdfe4bef3bb2ab18f4898 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 26 Oct 2013 23:11:53 +0200 Subject: following hz change, choose different accela factor --- ftnoir_filter_accela/ftnoir_filter_accela.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.cpp b/ftnoir_filter_accela/ftnoir_filter_accela.cpp index 29fe9067..781b3ba0 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela.cpp @@ -49,6 +49,7 @@ void FTNoIR_Filter::loadSettings() { { scaling[i] = iniFile.value(QString("axis-%1").arg(QString::number(i)), init_scaling[i]).toDouble(); } + iniFile.endGroup(); } @@ -64,7 +65,7 @@ void FTNoIR_Filter::receiveSettings(double rot, double trans, double zoom_fac) static inline double parabola(const double a, const double x) { const double a1 = 1./a; - return a1 * pow(x, 2.2); + return a1 * pow(x, 2.025); } void FTNoIR_Filter::FilterHeadPoseData(const double* target_camera_position, -- 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(+) 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(+) 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 e5712bbc76b2f970169a7778edd0d8c9e84bae9e Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 26 Oct 2013 23:25:39 +0200 Subject: aruco fix reprojection not showing Signed-off-by: Stanislaw Halik --- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index 7ad80b46..1a638198 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -243,7 +243,7 @@ void Tracker::run() 3); } - cv::circle(frame, last_centroid, 4, cv::Scalar(0, 0, 0), -1); + cv::circle(frame, last_centroid, 7, cv::Scalar(255, 255, 0), -1); auto time = cv::getTickCount(); @@ -321,13 +321,12 @@ void Tracker::run() error += std::sqrt(x * x + y * y); } - reprojection.clear(); - reprojection.resize(1); + std::vector repr2; std::vector centroid; centroid.push_back(cv::Point3f(0, 0, 0)); - cv::projectPoints(centroid, rvec, tvec, intrinsics, dist_coeffs, reprojection); + cv::projectPoints(centroid, rvec, tvec, intrinsics, dist_coeffs, repr2); - last_centroid = reprojection[0]; + last_centroid = repr2[0]; //pose[Yaw] -= atan(pose[TX] / pose[TZ]) * 180 / HT_PI; //pose[Pitch] -= atan(pose[TY] / pose[TZ]) * 180 / HT_PI; -- cgit v1.2.3 From b327eb866272272f2669cca4ea78c4cb489f7298 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 26 Oct 2013 23:56:59 +0200 Subject: auto-reset camera on settings exit. avoid bugs in cv::videocapture Signed-off-by: Stanislaw Halik --- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 31 +++++++++++++++++++++------ ftnoir_tracker_aruco/ftnoir_tracker_aruco.h | 12 ++++++++--- 2 files changed, 34 insertions(+), 9 deletions(-) diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index 1a638198..d068564d 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #if defined(_WIN32) #include @@ -100,6 +101,7 @@ static resolution_tuple resolution_choices[] = { void Tracker::load_settings() { + QMutexLocker foo(&mtx); QSettings settings("opentrack"); QString currentFile = settings.value( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); QSettings iniFile( currentFile, QSettings::IniFormat ); @@ -126,6 +128,8 @@ void Tracker::load_settings() headpos[i] = iniFile.value(QString("headpos-%1").arg(i), 0).toDouble(); } iniFile.endGroup(); + + reset = true; } Tracker::Tracker() @@ -149,6 +153,7 @@ Tracker::~Tracker() void Tracker::StartTracker(QFrame* videoframe) { + reset = false; videoframe->show(); videoWidget = new ArucoVideoWidget(videoframe); QHBoxLayout* layout = new QHBoxLayout(); @@ -169,26 +174,32 @@ void Tracker::StartTracker(QFrame* videoframe) void Tracker::run() { - cv::VideoCapture camera(camera_index); +start: + reset = false; + std::unique_ptr camera(new cv::VideoCapture(camera_index)); if (force_width) - camera.set(CV_CAP_PROP_FRAME_WIDTH, force_width); + camera->set(CV_CAP_PROP_FRAME_WIDTH, force_width); if (force_height) - camera.set(CV_CAP_PROP_FRAME_HEIGHT, force_height); + camera->set(CV_CAP_PROP_FRAME_HEIGHT, force_height); if (force_fps) - camera.set(CV_CAP_PROP_FPS, force_fps); + camera->set(CV_CAP_PROP_FPS, force_fps); aruco::MarkerDetector detector; detector.setDesiredSpeed(3); detector.setThresholdParams(11, 5); cv::Mat color, color_, grayscale, grayscale2, rvec, tvec; - if (!camera.isOpened()) + if (!camera->isOpened()) { fprintf(stderr, "aruco tracker: can't open camera\n"); return; } + while (!stop) + if(camera->read(color_)) + break; + auto freq = cv::getTickFrequency(); auto last_time = cv::getTickCount(); auto prev_time = last_time; @@ -200,7 +211,12 @@ void Tracker::run() cv::Point2f last_centroid; while (!stop) { - if (!camera.read(color_)) + if (reset) + { + camera.reset(nullptr); + goto start; + } + if (!camera->read(color_)) continue; color_.copyTo(color); cv::cvtColor(color, grayscale2, cv::COLOR_BGR2GRAY); @@ -416,6 +432,7 @@ extern "C" FTNOIR_TRACKER_BASE_EXPORT ITrackerDialog* CALLING_CONVENTION GetDial TrackerControls::TrackerControls() { + tracker = nullptr; ui.setupUi(this); setAttribute(Qt::WA_NativeWindow, true); connect(ui.cameraName, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged(int))); @@ -553,6 +570,8 @@ void TrackerControls::save() } iniFile.endGroup(); settingsDirty = false; + if (tracker) + tracker->load_settings(); } void TrackerControls::doOK() diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h index 5d3d4ed6..61eec096 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h @@ -28,6 +28,7 @@ public: bool GiveHeadPoseData(double *data); bool enableTX, enableTY, enableTZ, enableRX, enableRY, enableRZ; void run(); + void load_settings(); private: QMutex mtx; ArucoVideoWidget* videoWidget; @@ -36,10 +37,10 @@ private: float fov; int camera_index; int force_fps, force_width, force_height; - void load_settings(); double pose[6]; cv::Mat frame; double headpos[3]; + volatile bool reset; }; // Widget that has controls for FTNoIR protocol client-settings. @@ -53,14 +54,19 @@ public: void showEvent (QShowEvent *); void Initialize(QWidget *); - void registerTracker(ITracker *) {} - void unRegisterTracker() {} + void registerTracker(ITracker * x) { + tracker = dynamic_cast(x); + } + void unRegisterTracker() { + tracker = nullptr; + } private: Ui::Form ui; void loadSettings(); void save(); bool settingsDirty; + Tracker* tracker; private slots: void doOK(); -- 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(-) 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(-) 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 bc0bcee05ec795ba27c699ad2b2bb2ef0a213148 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 27 Oct 2013 02:55:05 +0200 Subject: add Accela deadzone, Patrick was right! Signed-off-by: Stanislaw Halik --- ftnoir_filter_accela/ftnoir_filter_accela.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.cpp b/ftnoir_filter_accela/ftnoir_filter_accela.cpp index 781b3ba0..1168004f 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela.cpp @@ -5,6 +5,7 @@ * copyright notice and this permission notice appear in all copies. */ #include "ftnoir_filter_accela/ftnoir_filter_accela.h" +#include #include #include #include @@ -65,7 +66,7 @@ void FTNoIR_Filter::receiveSettings(double rot, double trans, double zoom_fac) static inline double parabola(const double a, const double x) { const double a1 = 1./a; - return a1 * pow(x, 2.025); + return a1 * pow(std::max(x - 0.175, 1e-5), 2.2); } void FTNoIR_Filter::FilterHeadPoseData(const double* target_camera_position, -- cgit v1.2.3 From 627ab974ba07f1f0cbe12249d5c5fd7648be0c62 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 27 Oct 2013 02:58:21 +0200 Subject: Project Evil probably-final version --- bin/NPClient.dll | Bin 20591 -> 15872 bytes bin/NPClient64.dll | Bin 20487 -> 20992 bytes 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/bin/NPClient.dll b/bin/NPClient.dll index 9d6d2691..b291cb24 100755 Binary files a/bin/NPClient.dll and b/bin/NPClient.dll differ diff --git a/bin/NPClient64.dll b/bin/NPClient64.dll index 8d78e94f..8521ca03 100755 Binary files a/bin/NPClient64.dll and b/bin/NPClient64.dll differ -- cgit v1.2.3 From 264838ec1913425333accc9039931299a0a83ec7 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 27 Oct 2013 02:58:21 +0200 Subject: Project Evil probably-final version --- bin/NPClient.dll | Bin 20591 -> 15872 bytes bin/NPClient64.dll | Bin 20487 -> 20480 bytes 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/bin/NPClient.dll b/bin/NPClient.dll index 9d6d2691..b9c801a1 100755 Binary files a/bin/NPClient.dll and b/bin/NPClient.dll differ diff --git a/bin/NPClient64.dll b/bin/NPClient64.dll index 8d78e94f..aac8a5c6 100755 Binary files a/bin/NPClient64.dll and b/bin/NPClient64.dll differ -- cgit v1.2.3 From aaed9e3cdc4f3e7bb2a6d9b039d05bf395e1e046 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 27 Oct 2013 03:12:48 +0100 Subject: aruco: detection time in jiffies, better thresholding Signed-off-by: Stanislaw Halik --- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index d068564d..b05e5b98 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -187,7 +187,9 @@ start: aruco::MarkerDetector detector; detector.setDesiredSpeed(3); - detector.setThresholdParams(11, 5); + detector.setMinMaxSize(0.06, 0.4); + detector.setThresholdParams(11, 7); + cv::Mat color, color_, grayscale, grayscale2, rvec, tvec; if (!camera->isOpened()) @@ -203,11 +205,12 @@ start: auto freq = cv::getTickFrequency(); auto last_time = cv::getTickCount(); auto prev_time = last_time; + double last_delay = -1; int fps = 0; int last_fps = 0; double error = 0; std::vector reprojection; - auto kernel = cv::createGaussianFilter(CV_8U, cv::Size(5, 5), 0); + auto kernel = cv::createGaussianFilter(CV_8U, cv::Size(3, 3), 0); cv::Point2f last_centroid; while (!stop) { @@ -218,6 +221,7 @@ start: } if (!camera->read(color_)) continue; + auto tm = cv::getTickCount(); color_.copyTo(color); cv::cvtColor(color, grayscale2, cv::COLOR_BGR2GRAY); if (grayscale.empty()) @@ -276,7 +280,7 @@ start: std::sprintf(buf, "Hz: %ld", last_fps); cv::putText(frame, buf, cv::Point(10, 32), cv::FONT_HERSHEY_PLAIN, scale, cv::Scalar(0, 255, 0), scale); - std::sprintf(buf, "Delay: %ld ms", (long) (1000 * (time - prev_time) / freq)); + std::sprintf(buf, "Jiffies: %ld", (long) (10000 * (time - tm) / freq)); cv::putText(frame, buf, cv::Point(10, 54), cv::FONT_HERSHEY_PLAIN, scale, cv::Scalar(80, 255, 0), scale); std::sprintf(buf, "Error: %f px", error); cv::putText(frame, buf, cv::Point(10, 76), cv::FONT_HERSHEY_PLAIN, scale, cv::Scalar(80, 255, 0), scale); -- cgit v1.2.3 From ab38255154ec19b2167511911c703337edbc6b06 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 27 Oct 2013 08:06:47 +0100 Subject: Accela: customizable deadzone Signed-off-by: Stanislaw Halik --- .../ftnoir_accela_filtercontrols.ui | 57 ++++++++++++++++++++++ ftnoir_filter_accela/ftnoir_filter_accela.cpp | 13 +++-- ftnoir_filter_accela/ftnoir_filter_accela.h | 3 +- .../ftnoir_filter_accela_dialog.cpp | 12 ++--- 4 files changed, 70 insertions(+), 15 deletions(-) diff --git a/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui b/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui index c7bd2808..1d3e95ef 100644 --- a/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui +++ b/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui @@ -229,6 +229,63 @@ background:none; + + + + + 0 + 0 + + + + + 25 + 0 + + + + + 150 + 16777215 + + + + color:#0; +background:none; + + + Deadzone + + + + + + + + 0 + 0 + + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + 3 + + + 0.000000000000000 + + + 3.000000000000000 + + + 0.050000000000000 + + + 0.000000000000000 + + + diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.cpp b/ftnoir_filter_accela/ftnoir_filter_accela.cpp index 1168004f..63c82722 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela.cpp @@ -34,9 +34,8 @@ void FTNoIR_Filter::loadSettings() { 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(); - iniFile.endGroup (); - iniFile.beginGroup("Accela-Scaling"); + deadzone = iniFile.value("deadzone", 0.0).toDouble(); // bigger means less filtering static const double init_scaling[] = { 1.5, // X @@ -50,23 +49,23 @@ void FTNoIR_Filter::loadSettings() { { scaling[i] = iniFile.value(QString("axis-%1").arg(QString::number(i)), init_scaling[i]).toDouble(); } - iniFile.endGroup(); } -void FTNoIR_Filter::receiveSettings(double rot, double trans, double zoom_fac) +void FTNoIR_Filter::receiveSettings(double rot, double trans, double zoom_fac, double dz) { QMutexLocker foo(&mutex); rotation_alpha = rot; translation_alpha = trans; zoom_factor = zoom_fac; + deadzone = dz; } -static inline double parabola(const double a, const double x) +static inline double parabola(const double a, const double x, const double dz) { const double a1 = 1./a; - return a1 * pow(std::max(x - 0.175, 1e-5), 2.2); + return a1 * pow(std::max(x - dz, 1e-3), 1.975); } void FTNoIR_Filter::FilterHeadPoseData(const double* target_camera_position, @@ -94,7 +93,7 @@ void FTNoIR_Filter::FilterHeadPoseData(const double* target_camera_position, 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 * scaling[i]) * reduction; + const double velocity = parabola(a, x * scaling[i], deadzone) * 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; diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.h b/ftnoir_filter_accela/ftnoir_filter_accela.h index 512b4576..1808e026 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.h +++ b/ftnoir_filter_accela/ftnoir_filter_accela.h @@ -47,7 +47,7 @@ public: void Initialize() { first_run = true; } - void receiveSettings(double rot, double trans, double zoom_fac); + void receiveSettings(double rot, double trans, double zoom_fac, double deadzone); private: QMutex mutex; void loadSettings(); @@ -55,6 +55,7 @@ private: double rotation_alpha, translation_alpha, zoom_factor; double current_camera_position[6]; 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 559b9d4d..ca3377e1 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp @@ -158,9 +158,8 @@ void FilterControls::loadSettings() { 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()); - iniFile.endGroup (); + ui.deadzone->setValue(iniFile.value("deadzone", 0).toDouble()); - iniFile.beginGroup("Accela-Scaling"); // bigger means less filtering static const double init_scaling[] = { 1.5, // X @@ -184,6 +183,7 @@ void FilterControls::loadSettings() { { boxen[i]->setValue(iniFile.value(QString("axis-%1").arg(QString::number(i)), init_scaling[i]).toDouble()); } + iniFile.endGroup(); settingsDirty = false; @@ -200,15 +200,13 @@ void FilterControls::save() { qDebug() << "FTNoIR_Filter::save() says: iniFile = " << currentFile; - double rot, trans, zoom; + double rot, trans, zoom, deadzone; iniFile.beginGroup ( "Accela" ); iniFile.setValue("rotation-alpha", rot = ui.rotation_alpha->value()); iniFile.setValue("translation-alpha", trans = ui.translation_alpha->value()); iniFile.setValue("zoom-slowness", zoom = ui.spinZoom->value()); - iniFile.endGroup (); - - iniFile.beginGroup("Accela-Scaling"); + iniFile.setValue("deadzone", deadzone = ui.deadzone->value()); QDoubleSpinBox* boxen[] = { ui.doubleSpinBox, @@ -228,7 +226,7 @@ void FilterControls::save() { settingsDirty = false; if (accela_filter) - accela_filter->receiveSettings(rot, trans, zoom); + accela_filter->receiveSettings(rot, trans, zoom, deadzone); } //////////////////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From 494514581de9ec415acc25ac6b03fc42801d79e8 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 27 Oct 2013 08:09:06 +0100 Subject: aruco: get rid of blur for idempotence Signed-off-by: Stanislaw Halik --- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index b05e5b98..d5ed9071 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -190,7 +190,7 @@ start: detector.setMinMaxSize(0.06, 0.4); detector.setThresholdParams(11, 7); - cv::Mat color, color_, grayscale, grayscale2, rvec, tvec; + cv::Mat color, color_, grayscale, rvec, tvec; if (!camera->isOpened()) { @@ -210,7 +210,6 @@ start: int last_fps = 0; double error = 0; std::vector reprojection; - auto kernel = cv::createGaussianFilter(CV_8U, cv::Size(3, 3), 0); cv::Point2f last_centroid; while (!stop) { @@ -223,11 +222,7 @@ start: continue; auto tm = cv::getTickCount(); color_.copyTo(color); - cv::cvtColor(color, grayscale2, cv::COLOR_BGR2GRAY); - if (grayscale.empty()) - grayscale = grayscale2.clone(); - - kernel->apply(grayscale2, grayscale); + cv::cvtColor(color, grayscale, cv::COLOR_BGR2GRAY); const int scale = frame.cols > 480 ? 2 : 1; -- cgit v1.2.3 From 29c1db253c315fd2fc14114d500e4281a50ff180 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 27 Oct 2013 10:27:58 +0100 Subject: Project Evil: DCS bug at fault here, backout changes Signed-off-by: Stanislaw Halik --- bin/NPClient.dll | Bin 15872 -> 15872 bytes bin/NPClient64.dll | Bin 20480 -> 19968 bytes 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/bin/NPClient.dll b/bin/NPClient.dll index 19c54d63..bf971c03 100755 Binary files a/bin/NPClient.dll and b/bin/NPClient.dll differ diff --git a/bin/NPClient64.dll b/bin/NPClient64.dll index fb614039..fd3164e5 100755 Binary files a/bin/NPClient64.dll and b/bin/NPClient64.dll differ -- 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(-) 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 0038b0435334c56070bff84a2ec6c7ccfff7d062 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 27 Oct 2013 10:41:33 +0100 Subject: accela: implement variable exponent Signed-off-by: Stanislaw Halik --- .../ftnoir_accela_filtercontrols.ui | 29 ++++++++++++++++++++++ ftnoir_filter_accela/ftnoir_filter_accela.cpp | 21 +++++++++------- ftnoir_filter_accela/ftnoir_filter_accela.h | 3 ++- .../ftnoir_filter_accela_dialog.cpp | 9 +++++-- 4 files changed, 50 insertions(+), 12 deletions(-) diff --git a/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui b/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui index 1d3e95ef..5ba33614 100644 --- a/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui +++ b/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui @@ -286,6 +286,35 @@ background:none; + + + + Exponent + + + + + + + + 0 + 0 + + + + 3 + + + 0.050000000000000 + + + 100.000000000000000 + + + 0.050000000000000 + + + diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.cpp b/ftnoir_filter_accela/ftnoir_filter_accela.cpp index 63c82722..73a9dd8f 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela.cpp @@ -38,21 +38,23 @@ void FTNoIR_Filter::loadSettings() { deadzone = iniFile.value("deadzone", 0.0).toDouble(); // bigger means less filtering static const double init_scaling[] = { - 1.5, // X - 1.5, // Y + 1, // X + 1, // Y 1, // Z - 0.8, // Yaw - 0.9, // Pitch - 1.25 // Roll + 1, // Yaw + 1, // Pitch + 1 // Roll }; for (int i = 0; i < 6; i++) { scaling[i] = iniFile.value(QString("axis-%1").arg(QString::number(i)), init_scaling[i]).toDouble(); } + expt = iniFile.value("exponent", 2.0).toDouble(); + iniFile.endGroup(); } -void FTNoIR_Filter::receiveSettings(double rot, double trans, double zoom_fac, double dz) +void FTNoIR_Filter::receiveSettings(double rot, double trans, double zoom_fac, double dz, double exponent) { QMutexLocker foo(&mutex); @@ -60,12 +62,13 @@ void FTNoIR_Filter::receiveSettings(double rot, double trans, double zoom_fac, d translation_alpha = trans; zoom_factor = zoom_fac; deadzone = dz; + expt = exponent; } -static inline double parabola(const double a, const double x, const double dz) +static inline double parabola(const double a, const double x, const double dz, const double expt) { const double a1 = 1./a; - return a1 * pow(std::max(x - dz, 1e-3), 1.975); + return a1 * pow(std::max(x - dz, 1e-3), expt); } void FTNoIR_Filter::FilterHeadPoseData(const double* target_camera_position, @@ -93,7 +96,7 @@ void FTNoIR_Filter::FilterHeadPoseData(const double* target_camera_position, 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 * scaling[i], deadzone) * reduction; + const double velocity = parabola(a, x * scaling[i], deadzone, expt) * 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; diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.h b/ftnoir_filter_accela/ftnoir_filter_accela.h index 1808e026..8c770df9 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.h +++ b/ftnoir_filter_accela/ftnoir_filter_accela.h @@ -47,7 +47,7 @@ public: void Initialize() { first_run = true; } - void receiveSettings(double rot, double trans, double zoom_fac, double deadzone); + void receiveSettings(double rot, double trans, double zoom_fac, double deadzone, double expt); private: QMutex mutex; void loadSettings(); @@ -56,6 +56,7 @@ private: double current_camera_position[6]; double scaling[6]; double deadzone; + double expt; }; //******************************************************************************************************* diff --git a/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp b/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp index ca3377e1..88c0a794 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp @@ -63,6 +63,8 @@ FilterControls::FilterControls() : connect(boxen[i], SIGNAL(valueChanged(double)), this, SLOT(settingChanged(double))); } + connect(ui.expt, SIGNAL(valueChanged(double)), this, SLOT(settingChanged(double))); + qDebug() << "FilterControls() says: started"; } @@ -184,6 +186,8 @@ void FilterControls::loadSettings() { boxen[i]->setValue(iniFile.value(QString("axis-%1").arg(QString::number(i)), init_scaling[i]).toDouble()); } + ui.expt->setValue(iniFile.value("exponent", 2.0).toDouble()); + iniFile.endGroup(); settingsDirty = false; @@ -200,13 +204,14 @@ void FilterControls::save() { qDebug() << "FTNoIR_Filter::save() says: iniFile = " << currentFile; - double rot, trans, zoom, deadzone; + double rot, trans, zoom, deadzone, expt; iniFile.beginGroup ( "Accela" ); iniFile.setValue("rotation-alpha", rot = ui.rotation_alpha->value()); iniFile.setValue("translation-alpha", trans = ui.translation_alpha->value()); iniFile.setValue("zoom-slowness", zoom = ui.spinZoom->value()); iniFile.setValue("deadzone", deadzone = ui.deadzone->value()); + iniFile.setValue("exponent", expt = ui.expt->value()); QDoubleSpinBox* boxen[] = { ui.doubleSpinBox, @@ -226,7 +231,7 @@ void FilterControls::save() { settingsDirty = false; if (accela_filter) - accela_filter->receiveSettings(rot, trans, zoom, deadzone); + accela_filter->receiveSettings(rot, trans, zoom, deadzone, expt); } //////////////////////////////////////////////////////////////////////////////// -- 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(-) 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(-) 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(-) 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(-) 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 fbb15a3b322727370ed1d52ef4e2b28ffed8ddae Mon Sep 17 00:00:00 2001 From: Ryan Spicer Date: Sun, 27 Oct 2013 20:43:13 -0700 Subject: Fix MSVC2012 build. 1) Look for Windows Kit (Platform SDK) -- provides opengl3 for QT5. 2) Specify link with SAFESEH:NO if using MSVC2012, since older directinput lib (dx8?) fails to link with this enabled. --- CMakeLists.txt | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 58fbfc60..76a917a0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,6 +41,27 @@ if(SDK_GOOGLE_BREAKPAD AND WIN32) include_directories("${SDK_GOOGLE_BREAKPAD}/src/") endif() +if (WIN32 AND DEFINED MSVC_VERSION AND NOT ${MSVC_VERSION} LESS 1700) + find_path (WIN8_SDK_ROOT_DIR + Include/um/windows.h + PATHS + "$ENV{ProgramFiles}/Windows Kits/8.0" + "$ENV{ProgramFiles(x86)}/Windows Kits/8.0" + DOC "Windows 8 SDK root directory" + ) + + if (WIN8_SDK_ROOT_DIR) + SET(CMAKE_LIBRARY_PATH "${WIN8_SDK_ROOT_DIR}/Lib/win8/um/x86") + endif () + endif () +endif() + +if(WIN32 AND DEFINED MSVC_VERSION AND NOT ${MSVC_VERSION} LESS 1700) + SET (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH:NO") + SET (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SAFESEH:NO") + SET (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /SAFESEH:NO") +endif() + if(UNIX) set(SDK_ENABLE_LIBEVDEV FALSE CACHE BOOL "libevdev virtual joystick protocol support (probably Linux only)") endif() -- cgit v1.2.3 From 8342cffaaf496021c452b0a3166428fb3beb4316 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 28 Oct 2013 04:55:16 +0100 Subject: fix build Signed-off-by: Stanislaw Halik --- CMakeLists.txt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 76a917a0..ae7a7faa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,7 +41,7 @@ if(SDK_GOOGLE_BREAKPAD AND WIN32) include_directories("${SDK_GOOGLE_BREAKPAD}/src/") endif() -if (WIN32 AND DEFINED MSVC_VERSION AND NOT ${MSVC_VERSION} LESS 1700) +if(WIN32 AND DEFINED MSVC_VERSION AND NOT ${MSVC_VERSION} LESS 1700) find_path (WIN8_SDK_ROOT_DIR Include/um/windows.h PATHS @@ -50,10 +50,9 @@ if (WIN32 AND DEFINED MSVC_VERSION AND NOT ${MSVC_VERSION} LESS 1700) DOC "Windows 8 SDK root directory" ) - if (WIN8_SDK_ROOT_DIR) + if(WIN8_SDK_ROOT_DIR) SET(CMAKE_LIBRARY_PATH "${WIN8_SDK_ROOT_DIR}/Lib/win8/um/x86") - endif () - endif () + endif() endif() if(WIN32 AND DEFINED MSVC_VERSION AND NOT ${MSVC_VERSION} LESS 1700) -- 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(-) 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 7249e4cce3281547948100eafbf1ef73fc235a00 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 29 Oct 2013 00:09:37 +0100 Subject: cmake: annual mingw-w64 update Signed-off-by: Stanislaw Halik --- CMakeLists.txt | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ae7a7faa..0a3e3ecc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,7 +31,7 @@ if(CMAKE_COMPILER_IS_GNUCXX) add_definitions(-std=c++11) endif() -if(WIN32) +if(WIN32 AND MSVC) set(SDK_GOOGLE_BREAKPAD "" CACHE PATH "google-breakpad for crash reporting") endif() @@ -117,8 +117,8 @@ include_directories(${CMAKE_SOURCE_DIR}) if(WIN32) if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) - #set(CMAKE_RC_COMPILER_INIT windres) - SET(CMAKE_RC_COMPILE_OBJECT " -O coff -i -o ") + set(CMAKE_RC_COMPILER_INIT i686-w64-mingw32-windres) + SET(CMAKE_RC_COMPILE_OBJECT " -O coff -i -o ") else() #set(CMAKE_RC_COMPILER_INIT rc) endif() @@ -626,9 +626,6 @@ endif() "${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) -- cgit v1.2.3 From 2a25e74721d0e014d8386f5c23e7d882ed47aa52 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 29 Oct 2013 00:09:46 +0100 Subject: don't use .ico, doesn't work on mingw qt Signed-off-by: Stanislaw Halik --- FTNoIR_Tracker_PT/ftnoir_tracker_pt_dll.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dll.cpp b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dll.cpp index be1705c0..f3fbbef7 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dll.cpp +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dll.cpp @@ -26,7 +26,7 @@ void TrackerDll::getDescription(QString *strToBeFilled) void TrackerDll::getIcon(QIcon *icon) { - *icon = QIcon(":/Resources/icon.ico"); + *icon = QIcon(":/Resources/Logo_IR.png"); } -- 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(-) 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 5e3891cc4d608813acc08626b38c5e5a4f123faf Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 29 Oct 2013 00:10:21 +0100 Subject: fix mingw build Signed-off-by: Stanislaw Halik --- ftnoir_tracker_joystick/ftnoir_tracker_joystick.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h index 9dd335cd..cdf4fc7b 100644 --- a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h +++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h @@ -24,7 +24,7 @@ #include #include #include -#include +//#include #include #include -- 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(-) 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(-) 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 fea2abeb7040bacdc90964e216e5170faeb8052d Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 29 Oct 2013 00:46:12 +0100 Subject: fix build Signed-off-by: Stanislaw Halik --- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index d5ed9071..906e2654 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -19,9 +19,10 @@ #include #if defined(_WIN32) -#include +# define NO_DSHOW_STRSAFE +# include #else -#include +# include #endif // delicious copypasta @@ -273,11 +274,11 @@ start: char buf[128]; - std::sprintf(buf, "Hz: %ld", last_fps); + ::sprintf(buf, "Hz: %d", last_fps); cv::putText(frame, buf, cv::Point(10, 32), cv::FONT_HERSHEY_PLAIN, scale, cv::Scalar(0, 255, 0), scale); - std::sprintf(buf, "Jiffies: %ld", (long) (10000 * (time - tm) / freq)); + ::sprintf(buf, "Jiffies: %ld", (long) (10000 * (time - tm) / freq)); cv::putText(frame, buf, cv::Point(10, 54), cv::FONT_HERSHEY_PLAIN, scale, cv::Scalar(80, 255, 0), scale); - std::sprintf(buf, "Error: %f px", error); + ::sprintf(buf, "Error: %f px", error); cv::putText(frame, buf, cv::Point(10, 76), cv::FONT_HERSHEY_PLAIN, scale, cv::Scalar(80, 255, 0), scale); prev_time = time; -- cgit v1.2.3 From f879a8eeed54cb09929235a9a60fe335ee256eff Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 29 Oct 2013 00:52:57 +0100 Subject: fix qt5 cmake build scripts brain damage Signed-off-by: Stanislaw Halik --- CMakeLists.txt | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0a3e3ecc..0a4daad1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,6 +35,10 @@ if(WIN32 AND MSVC) set(SDK_GOOGLE_BREAKPAD "" CACHE PATH "google-breakpad for crash reporting") endif() +if(MINGW) + set(SDK_MINGW_PREFIX "" CACHE PATH "mingw prefix") +endif() + if(SDK_GOOGLE_BREAKPAD AND WIN32) add_definitions(-DOPENTRACK_BREAKPAD) include_directories("${SDK_GOOGLE_BREAKPAD}/src/client/windows/handler") @@ -78,6 +82,14 @@ SET(SDK_RIFT "" CACHE PATH "libOVR path") include_directories(${CMAKE_SOURCE_DIR}) +if(MINGW) + # qt scripts are broken + set(Qt5Gui_user32_LIBRARY ${SDK_MINGW_PREFIX}/mingw/lib/libuser32.a) + set(Qt5Gui_opengl32_LIBRARY ${SDK_MINGW_PREFIX}/mingw/lib/libopengl32.a) + set(Qt5Gui_glu32_LIBRARY ${SDK_MINGW_PREFIX}/mingw/lib/libglu32.a) + set(Qt5Gui_gdi32_LIBRARY ${SDK_MINGW_PREFIX}/mingw/lib/libgdi32.a) +endif() + find_package(OpenCV REQUIRED) find_package(Qt5 REQUIRED COMPONENTS Core Xml Network Widgets Gui QUIET) cmake_policy(SET CMP0020 NEW) @@ -760,8 +772,8 @@ if(WIN32) endif() if(MSVC) -file(GLOB pdbs1 "${CMAKE_BINARY_DIR}/Release/*.pdb") -file(GLOB pdbs2 "${CMAKE_BINARY_DIR}/*.pdb") -install(FILES ${pdbs1} ${pdbs2} DESTINATION .) + file(GLOB pdbs1 "${CMAKE_BINARY_DIR}/Release/*.pdb") + file(GLOB pdbs2 "${CMAKE_BINARY_DIR}/*.pdb") + install(FILES ${pdbs1} ${pdbs2} DESTINATION .) endif() -- 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(-) 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(-) 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(-) 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(-) 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 38a46daa809f78489b6099afd78319bb6da5e6e4 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 29 Oct 2013 07:43:50 +0100 Subject: update copyright date Signed-off-by: Stanislaw Halik --- ftnoir_filter_accela/ftnoir_filter_accela.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.cpp b/ftnoir_filter_accela/ftnoir_filter_accela.cpp index 73a9dd8f..9189ec8a 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2012 Stanislaw Halik +/* 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 -- 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(+) 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(-) 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(-) 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 ea2660dd167a853e704f167410037da162eccc6f Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 29 Oct 2013 08:18:32 +0100 Subject: remove dead code Signed-off-by: Stanislaw Halik --- ftnoir_protocol_sc/ftnoir_protocol_sc.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp b/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp index 8a60f8fb..6b68047f 100644 --- a/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp +++ b/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp @@ -83,9 +83,6 @@ void FTNoIR_Protocol::loadSettings() { // Update Headpose in Game. // void FTNoIR_Protocol::sendHeadposeToGame( const double *headpose ) { -PDWORD_PTR MsgResult = 0; - - virtSCRotX = -headpose[Pitch]; // degrees virtSCRotY = -headpose[Yaw]; virtSCRotZ = headpose[Roll]; -- cgit v1.2.3 From 2af0ddbcf5cf32e4f6e8e1e3993a1aca0c409c90 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 30 Oct 2013 17:22:02 +0100 Subject: add initial, untested opentrack-api.dll Signed-off-by: Stanislaw Halik --- CMakeLists.txt | 26 +++++++--- opentrack-api/context.cpp | 108 ++++++++++++++++++++++++++++++++++++++++ opentrack-api/opentrack-api.cpp | 13 +++++ opentrack-api/opentrack-guts.h | 40 +++++++++++++++ opentrack-api/opentrack.h | 57 +++++++++++++++++++++ opentrack-api/trackers.cpp | 38 ++++++++++++++ 6 files changed, 274 insertions(+), 8 deletions(-) create mode 100644 opentrack-api/context.cpp create mode 100644 opentrack-api/opentrack-api.cpp create mode 100644 opentrack-api/opentrack-guts.h create mode 100644 opentrack-api/opentrack.h create mode 100644 opentrack-api/trackers.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 0a4daad1..0eb1b3c7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,7 +17,7 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_AUTOMOC ON) set(CMAKE_POSITION_INDEPENDENT_CODE ON) -add_definitions(-DOPENTRACK_API) +add_definitions(-DOPENTRACK_API -DIN_OPENTRACK) if(MSVC) add_definitions(-DNOMINMAX) @@ -154,6 +154,9 @@ else() endif() # main app +file(GLOB opentrack-lib-c "opentrack-api/*.cpp") +file(GLOB opentrack-lib-h "opentrack-api/*.h") + file(GLOB opentrack-bin-c "facetracknoir/*.cpp" "facetracknoir/*.rc") file(GLOB opentrack-bin-h "facetracknoir/*.h") file(GLOB opentrack-bin-ui "facetracknoir/*.ui") @@ -608,6 +611,12 @@ add_executable(opentrack ${opentrack-win32-executable} ${opentrack-bin-c} ${open 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) + +add_library(opentrack-api ${opentrack-lib-c} ${opentrack-lib-h} ${opentrack-lib-moc}) +target_link_libraries(opentrack-api ${MY_QT_LIBS}) + +set_target_properties(opentrack PROPERTIES COMPILE_DEFINITIONS OPENTRACK_VERSION=\"${OPENTRACK__COMMIT}\") + if(UNIX) target_link_libraries(opentrack opentrack-qxt-mini) endif() @@ -631,15 +640,16 @@ endif() target_link_libraries(opentrack opentrack-pose-widget opentrack-spline-widget ${MY_QT_LIBS} ${QXT_QXTCORE_LIB_RELEASE} ${QXT_QXTWIDGETS_LIB_RELEASE}) if(NOT WIN32) target_link_libraries(opentrack dl) + target_link_libraries(opentrack-api dl) endif() - 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") - endif() +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") endif() +endif() set_target_properties(opentrack PROPERTIES COMPILE_FLAGS -DOPENTRACK_MAIN) # make install diff --git a/opentrack-api/context.cpp b/opentrack-api/context.cpp new file mode 100644 index 00000000..100acf5c --- /dev/null +++ b/opentrack-api/context.cpp @@ -0,0 +1,108 @@ +#include "opentrack-guts.h" +#include "opentrack.h" + +#if defined(__APPLE__) +# define SONAME "dylib" +#elif defined(_WIN32) +# define SONAME "dll" +#else +# define SONAME "so" +#endif + +#include + +#ifdef _MSC_VER +# define LIB_PREFIX "" +#else +# define LIB_PREFIX "lib" +#endif + +// shamelessly copied from core +static Metadata* get_metadata(DynamicLibrary* lib, QString& longName, QIcon& icon) +{ + Metadata* meta; + if (!lib->Metadata || ((meta = lib->Metadata()), !meta)) + return NULL; + meta->getFullName(&longName); + meta->getIcon(&icon); + return meta; +} + +static QList list_files(QDir& dir, QString filter) +{ + QList ret; + QStringList filenames = dir.entryList( QStringList() << (LIB_PREFIX + filter + ("*." SONAME)), QDir::Files, QDir::Name ); + for ( int i = 0; i < filenames.size(); i++) { + QIcon icon; + QString long_name; + QString str = filenames.at(i); + DynamicLibrary* lib = new DynamicLibrary(str); + qDebug() << "Loading" << str; + std::cout.flush(); + Metadata* meta; + if (!(meta = get_metadata(lib, long_name, icon))) + { + delete lib; + continue; + } + QString prefix(LIB_PREFIX + filter); + QString suffix("*." SONAME); + if (str.size() > prefix.size() + suffix.size() && str.startsWith(prefix) && str.endsWith(suffix)) + { + auto str2 = str.mid(prefix.size(), str.size() - prefix.size() - suffix.size()); + opentrack_meta item(meta, str2, lib); + ret.push_back(item); + } + } + + return ret; +} + +opentrack_ctx::opentrack_ctx(QDir& dir) : + dir(dir), + meta_list(list_files(dir, "opentrack-tracker-")) +{ + const int count = meta_list.size(); + list = new char*[count + 1]; + for (int i = 0; i < count; i++) + { + QByteArray tmp = meta_list.at(i).path.toUtf8(); + int len = tmp.size(); + auto foo = new char[len+1]; + for (int j = 0; j < len; j++) + foo[j] = tmp.at(j); + foo[len] = '\0'; + list[i] = foo; + } + list[count] = NULL; +} + +opentrack_ctx::~opentrack_ctx() +{ + for (int i = 0; list[i]; i++) + { + delete list[i]; + } + delete list; +} + +extern "C" +{ + +const char** OPENTRACK_EXPORT opentrack_enum_trackers(opentrack ctx) +{ + return const_cast(ctx->list); +} + +opentrack OPENTRACK_EXPORT opentrack_make_ctx(const char *dir) +{ + QDir d(dir); + return new opentrack_ctx(d); +} + +void OPENTRACK_EXPORT opentrack_finalize_ctx(opentrack foo) +{ + delete foo; +} + +} diff --git a/opentrack-api/opentrack-api.cpp b/opentrack-api/opentrack-api.cpp new file mode 100644 index 00000000..acb6d823 --- /dev/null +++ b/opentrack-api/opentrack-api.cpp @@ -0,0 +1,13 @@ +#include "opentrack-guts.h" +#include "opentrack.h" + +opentrack opentrack_make_ctx(const char *dir) +{ + QDir d(dir); + return new opentrack_ctx(d); +} + +void opentrack_finalize_ctx(opentrack bye_bye) +{ + delete bye_bye; +} diff --git a/opentrack-api/opentrack-guts.h b/opentrack-api/opentrack-guts.h new file mode 100644 index 00000000..1061d75d --- /dev/null +++ b/opentrack-api/opentrack-guts.h @@ -0,0 +1,40 @@ +#pragma once + +#include "ftnoir_tracker_base/ftnoir_tracker_base.h" +#include "facetracknoir/global-settings.h" +#include +#include +#include +#include +#include +#include +#include +#include + +typedef ITracker* opentrack_tracker; + +class opentrack_meta { +public: + Metadata* meta; + QString path; + DynamicLibrary* lib; + + opentrack_meta(Metadata* meta, QString& path, DynamicLibrary* lib) : + meta(meta), path(path), lib(lib) + {} + ~opentrack_meta() + { + delete meta; + delete lib; + } +}; + +typedef class opentrack_ctx { +public: + QDir dir; + char** list; + QList meta_list; + QFrame fake_frame; + opentrack_ctx(QDir& dir); + ~opentrack_ctx(); +} *opentrack; diff --git a/opentrack-api/opentrack.h b/opentrack-api/opentrack.h new file mode 100644 index 00000000..afd5506b --- /dev/null +++ b/opentrack-api/opentrack.h @@ -0,0 +1,57 @@ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif +#ifndef IN_OPENTRACK + /* opaque pointers, forward definitions */ + struct opentrack_opaque_ctx; + typedef opentrack_opaque_ctx* opentrack; + struct opentrack_opaque_tracker; + typedef opentrack_opaque_tracker* opentrack_tracker; +#endif + +#ifdef IN_OPENTRACK +# ifdef _WIN32 +# define OPENTRACK_EXPORT __declspec(dllexport) +# else +# define OPENTRACK_EXPORT +# endif +#else +# ifdef _WIN32 +# define OPENTRACK_EXPORT __declspec(dllimport) +# else +# define OPENTRACK_EXPORT +# endif +#endif + + /* for `opentrack_tracker_tick', individual headpose elts */ +#ifndef IN_OPENTRACK + enum opentrack_dof { + TX = 0, + TY, + TZ, + Yaw, + Pitch, + Roll, + DOF_count + }; +#endif + + opentrack opentrack_make_ctx(const char* dir); + void opentrack_finalize_ctx(opentrack self); + + /* no need to free the return value; invalid to modify it */ + const char** opentrack_enum_trackers(opentrack self); + + /* + * don't `opentrack_tracker_tick an unstarted tracker, it's invalid to do so + * it's also invalid to start a finalized tracker + */ + opentrack_tracker opentrack_make_tracker(opentrack ctx, const char* name); + void opentrack_tracker_start(opentrack self, opentrack_tracker tracker); + int opentrack_tracker_tick(opentrack_tracker tracker, double* headpose); + void opentrack_finalize_tracker(opentrack_tracker tracker); +#ifdef __cplusplus +} +#endif diff --git a/opentrack-api/trackers.cpp b/opentrack-api/trackers.cpp new file mode 100644 index 00000000..2527017b --- /dev/null +++ b/opentrack-api/trackers.cpp @@ -0,0 +1,38 @@ +#include "opentrack-guts.h" +#include "opentrack.h" + +extern "C" { + +opentrack_tracker OPENTRACK_EXPORT opentrack_make_tracker(opentrack ctx, const char* name) +{ + QString n(name); + for (int i = 0; i < ctx->meta_list.size(); i++) + { + auto meta = ctx->meta_list[i]; + if (ctx->meta_list.at(i).path == name) + { + ITracker* foo = reinterpret_cast(meta.lib->Constructor()); + return foo; + } + } + return NULL; +} + +void OPENTRACK_EXPORT opentrack_finalize_tracker(opentrack_tracker tracker) +{ + delete tracker; +} + +void OPENTRACK_EXPORT opentrack_tracker_start(opentrack self, opentrack_tracker tracker) +{ + // hot damn, this is problematic! + // need to pass QFrame from somewhere + return tracker->StartTracker(&self->fake_frame); +} + +int OPENTRACK_EXPORT opentrack_tracker_tick(opentrack_tracker tracker, double* headpose) +{ + return tracker->GiveHeadPoseData(headpose); +} + +} -- cgit v1.2.3 From c253222d41e372e434c6e086189808c9b0ee2463 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 30 Oct 2013 17:22:46 +0100 Subject: remove unused typedef --- ftnoir_tracker_base/ftnoir_tracker_base.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/ftnoir_tracker_base/ftnoir_tracker_base.h b/ftnoir_tracker_base/ftnoir_tracker_base.h index cb83aea3..070c8c33 100644 --- a/ftnoir_tracker_base/ftnoir_tracker_base.h +++ b/ftnoir_tracker_base/ftnoir_tracker_base.h @@ -48,8 +48,6 @@ struct ITracker inline ITracker::~ITracker() { } -typedef ITracker* ITrackerPtr; - //////////////////////////////////////////////////////////////////////////////// // COM-Like abstract interface. // This interface doesn't require __declspec(dllexport/dllimport) specifier. -- cgit v1.2.3 From ff7a9978ad9c1e804d7f51f6055d3ca540efa57d Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 30 Oct 2013 17:23:15 +0100 Subject: reindent Signed-off-by: Stanislaw Halik --- opentrack-api/opentrack.h | 48 +++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/opentrack-api/opentrack.h b/opentrack-api/opentrack.h index afd5506b..494f0de2 100644 --- a/opentrack-api/opentrack.h +++ b/opentrack-api/opentrack.h @@ -4,11 +4,11 @@ extern "C" { #endif #ifndef IN_OPENTRACK - /* opaque pointers, forward definitions */ - struct opentrack_opaque_ctx; - typedef opentrack_opaque_ctx* opentrack; - struct opentrack_opaque_tracker; - typedef opentrack_opaque_tracker* opentrack_tracker; +/* opaque pointers, forward definitions */ +struct opentrack_opaque_ctx; +typedef opentrack_opaque_ctx* opentrack; +struct opentrack_opaque_tracker; +typedef opentrack_opaque_tracker* opentrack_tracker; #endif #ifdef IN_OPENTRACK @@ -25,33 +25,33 @@ extern "C" { # endif #endif - /* for `opentrack_tracker_tick', individual headpose elts */ +/* for `opentrack_tracker_tick', individual headpose elts */ #ifndef IN_OPENTRACK - enum opentrack_dof { - TX = 0, - TY, - TZ, - Yaw, - Pitch, - Roll, - DOF_count - }; +enum opentrack_dof { + TX = 0, + TY, + TZ, + Yaw, + Pitch, + Roll, + DOF_count +}; #endif - opentrack opentrack_make_ctx(const char* dir); - void opentrack_finalize_ctx(opentrack self); +opentrack opentrack_make_ctx(const char* dir); +void opentrack_finalize_ctx(opentrack self); - /* no need to free the return value; invalid to modify it */ - const char** opentrack_enum_trackers(opentrack self); +/* no need to free the return value; invalid to modify it */ +const char** opentrack_enum_trackers(opentrack self); - /* +/* * don't `opentrack_tracker_tick an unstarted tracker, it's invalid to do so * it's also invalid to start a finalized tracker */ - opentrack_tracker opentrack_make_tracker(opentrack ctx, const char* name); - void opentrack_tracker_start(opentrack self, opentrack_tracker tracker); - int opentrack_tracker_tick(opentrack_tracker tracker, double* headpose); - void opentrack_finalize_tracker(opentrack_tracker tracker); +opentrack_tracker opentrack_make_tracker(opentrack ctx, const char* name); +void opentrack_tracker_start(opentrack self, opentrack_tracker tracker); +int opentrack_tracker_tick(opentrack_tracker tracker, double* headpose); +void opentrack_finalize_tracker(opentrack_tracker tracker); #ifdef __cplusplus } #endif -- cgit v1.2.3 From bcce813bf2fd537ee5c1582f58dcc5dbe8575711 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 30 Oct 2013 17:26:38 +0100 Subject: install opentrack-api Signed-off-by: Stanislaw Halik --- CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0eb1b3c7..3084bdfd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -612,7 +612,7 @@ set_target_properties(opentrack PROPERTIES COMPILE_DEFINITIONS OPENTRACK_VERSION set(OPENTRACK_COMMIT_VERSION \"${OPENTRACK__COMMIT}\") configure_file("${CMAKE_SOURCE_DIR}/opentrack-version.h" "${CMAKE_BINARY_DIR}/opentrack-version.h" @ONLY NEWLINE_STYLE UNIX) -add_library(opentrack-api ${opentrack-lib-c} ${opentrack-lib-h} ${opentrack-lib-moc}) +add_library(opentrack-api SHARED ${opentrack-lib-c} ${opentrack-lib-h} ${opentrack-lib-moc}) target_link_libraries(opentrack-api ${MY_QT_LIBS}) set_target_properties(opentrack PROPERTIES COMPILE_DEFINITIONS OPENTRACK_VERSION=\"${OPENTRACK__COMMIT}\") @@ -692,6 +692,7 @@ install(TARGETS opentrack-tracker-ht opentrack-tracker-udp opentrack + opentrack-api RUNTIME DESTINATION . LIBRARY DESTINATION . NAMELINK_SKIP -- cgit v1.2.3 From 4d67352d570d0ca6b13226328513c76b5f690342 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 30 Oct 2013 17:28:38 +0100 Subject: decruft Signed-off-by: Stanislaw Halik --- opentrack-api/opentrack-api.cpp | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 opentrack-api/opentrack-api.cpp diff --git a/opentrack-api/opentrack-api.cpp b/opentrack-api/opentrack-api.cpp deleted file mode 100644 index acb6d823..00000000 --- a/opentrack-api/opentrack-api.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include "opentrack-guts.h" -#include "opentrack.h" - -opentrack opentrack_make_ctx(const char *dir) -{ - QDir d(dir); - return new opentrack_ctx(d); -} - -void opentrack_finalize_ctx(opentrack bye_bye) -{ - delete bye_bye; -} -- cgit v1.2.3 From d239f7977df736183c442c7dbd6da19a3ca9c968 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 30 Oct 2013 17:30:51 +0100 Subject: reindent Signed-off-by: Stanislaw Halik --- opentrack-api/opentrack.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/opentrack-api/opentrack.h b/opentrack-api/opentrack.h index 494f0de2..8d28b5b8 100644 --- a/opentrack-api/opentrack.h +++ b/opentrack-api/opentrack.h @@ -45,9 +45,9 @@ void opentrack_finalize_ctx(opentrack self); const char** opentrack_enum_trackers(opentrack self); /* - * don't `opentrack_tracker_tick an unstarted tracker, it's invalid to do so - * it's also invalid to start a finalized tracker - */ + * don't `opentrack_tracker_tick an unstarted tracker, it's invalid to do so + * it's also invalid to start a finalized tracker + */ opentrack_tracker opentrack_make_tracker(opentrack ctx, const char* name); void opentrack_tracker_start(opentrack self, opentrack_tracker tracker); int opentrack_tracker_tick(opentrack_tracker tracker, double* headpose); -- cgit v1.2.3 From 677af1c2c3ec44766764d6c72e16d319c02de6ff Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 30 Oct 2013 17:33:03 +0100 Subject: remove incorrect copyright assignment Signed-off-by: Stanislaw Halik --- ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp | 24 ---------------------- 1 file changed, 24 deletions(-) diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp b/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp index 90d4cb68..e609db70 100644 --- a/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp +++ b/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp @@ -1,27 +1,3 @@ -/******************************************************************************** -* 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_rift.h" #include "facetracknoir/global-settings.h" -- cgit v1.2.3 From 6775efddecffc2be4a9eaeea2d844183d9271f99 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 30 Oct 2013 17:33:32 +0100 Subject: pass -Wall -Wextra -pedantic, add #pragma once --- ftnoir_tracker_rift/ftnoir_tracker_rift.cpp | 2 +- ftnoir_tracker_rift/ftnoir_tracker_rift.h | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp b/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp index 965e849b..7d567ca3 100644 --- a/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp +++ b/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp @@ -38,7 +38,7 @@ Rift_Tracker::~Rift_Tracker() -void Rift_Tracker::StartTracker(QFrame* videoFrame) +void Rift_Tracker::StartTracker(QFrame*) { loadSettings(); // diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift.h b/ftnoir_tracker_rift/ftnoir_tracker_rift.h index 970a64a2..6be18d0b 100644 --- a/ftnoir_tracker_rift/ftnoir_tracker_rift.h +++ b/ftnoir_tracker_rift/ftnoir_tracker_rift.h @@ -1,9 +1,10 @@ +#pragma once #include "ftnoir_tracker_base/ftnoir_tracker_base.h" #include "ui_ftnoir_rift_clientcontrols.h" #include #include #include -#include +#include #include "facetracknoir/global-settings.h" #include "OVR.h" #include @@ -13,7 +14,7 @@ public: Rift_Tracker(); virtual ~Rift_Tracker(); - void StartTracker( QFrame *videoframe ); + void StartTracker(QFrame *); bool GiveHeadPoseData(double *data); void loadSettings(); volatile bool should_quit; @@ -48,7 +49,7 @@ public: void showEvent ( QShowEvent * event ); void Initialize(QWidget *parent); - void registerTracker(ITracker *tracker) {} + void registerTracker(ITracker *) {} void unRegisterTracker() {} private: -- 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(-) 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 edc645a113c58a4a7c063f1b6fcaae7b1b046f51 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 30 Oct 2013 17:35:37 +0100 Subject: pass warns --- ftnoir_tracker_rift/ftnoir_tracker_rift.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift.h b/ftnoir_tracker_rift/ftnoir_tracker_rift.h index 6be18d0b..55fa99e3 100644 --- a/ftnoir_tracker_rift/ftnoir_tracker_rift.h +++ b/ftnoir_tracker_rift/ftnoir_tracker_rift.h @@ -46,7 +46,7 @@ public: explicit TrackerControls(); ~TrackerControls(); - void showEvent ( QShowEvent * event ); + void showEvent (QShowEvent *); void Initialize(QWidget *parent); void registerTracker(ITracker *) {} -- cgit v1.2.3 From 5d8e37f8cb37e6c583f51f188dbd00576d5f77ba Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 30 Oct 2013 17:47:25 +0100 Subject: pass warns harder --- ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp b/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp index e609db70..6b1a559d 100644 --- a/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp +++ b/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp @@ -57,7 +57,7 @@ void TrackerControls::doOK() { } // override show event -void TrackerControls::showEvent ( QShowEvent * event ) { +void TrackerControls::showEvent ( QShowEvent * ) { loadSettings(); } -- cgit v1.2.3 From 4501ea093dadd3c44e88da9901eff683b0a91614 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 30 Oct 2013 17:47:38 +0100 Subject: add visibility modifiers for GNU C --- opentrack-api/opentrack-guts.h | 10 ++++++++-- opentrack-api/opentrack.h | 20 +++++++++++++------- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/opentrack-api/opentrack-guts.h b/opentrack-api/opentrack-guts.h index 1061d75d..3f8806cc 100644 --- a/opentrack-api/opentrack-guts.h +++ b/opentrack-api/opentrack-guts.h @@ -11,9 +11,15 @@ #include #include +#ifdef __GNUC__ +# define OPENTRACK_HIDDEN __attribute__((visibility ("hidden"))) +#else +# define OPENTRACK_HIDDEN +#endif + typedef ITracker* opentrack_tracker; -class opentrack_meta { +class OPENTRACK_HIDDEN opentrack_meta { public: Metadata* meta; QString path; @@ -29,7 +35,7 @@ public: } }; -typedef class opentrack_ctx { +typedef class OPENTRACK_HIDDEN opentrack_ctx { public: QDir dir; char** list; diff --git a/opentrack-api/opentrack.h b/opentrack-api/opentrack.h index 8d28b5b8..95339d08 100644 --- a/opentrack-api/opentrack.h +++ b/opentrack-api/opentrack.h @@ -25,6 +25,12 @@ typedef opentrack_opaque_tracker* opentrack_tracker; # endif #endif +#ifdef __GNUC__ +# define OPENTRACK_VISIBLE __attribute__((visibility ("default"))) +#else +# define OPENTRACK_VISIBLE +#endif + /* for `opentrack_tracker_tick', individual headpose elts */ #ifndef IN_OPENTRACK enum opentrack_dof { @@ -38,20 +44,20 @@ enum opentrack_dof { }; #endif -opentrack opentrack_make_ctx(const char* dir); -void opentrack_finalize_ctx(opentrack self); +opentrack OPENTRACK_VISIBLE opentrack_make_ctx(const char* dir); +void OPENTRACK_VISIBLE opentrack_finalize_ctx(opentrack self); /* no need to free the return value; invalid to modify it */ -const char** opentrack_enum_trackers(opentrack self); +const char** OPENTRACK_VISIBLE opentrack_enum_trackers(opentrack self); /* * don't `opentrack_tracker_tick an unstarted tracker, it's invalid to do so * it's also invalid to start a finalized tracker */ -opentrack_tracker opentrack_make_tracker(opentrack ctx, const char* name); -void opentrack_tracker_start(opentrack self, opentrack_tracker tracker); -int opentrack_tracker_tick(opentrack_tracker tracker, double* headpose); -void opentrack_finalize_tracker(opentrack_tracker tracker); +opentrack_tracker OPENTRACK_VISIBLE opentrack_make_tracker(opentrack ctx, const char* name); +void OPENTRACK_VISIBLE opentrack_tracker_start(opentrack self, opentrack_tracker tracker); +int OPENTRACK_VISIBLE opentrack_tracker_tick(opentrack_tracker tracker, double* headpose); +void OPENTRACK_VISIBLE opentrack_finalize_tracker(opentrack_tracker tracker); #ifdef __cplusplus } #endif -- cgit v1.2.3 From 181875f3385391aed537c7e5fcff8fda199d39e6 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 30 Oct 2013 17:54:51 +0100 Subject: use version script Signed-off-by: Stanislaw Halik --- CMakeLists.txt | 4 ++++ opentrack-api/gnuc-version-script.txt | 12 ++++++++++++ opentrack-api/opentrack.h | 20 +++++++------------- 3 files changed, 23 insertions(+), 13 deletions(-) create mode 100644 opentrack-api/gnuc-version-script.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 3084bdfd..239cafb5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -614,6 +614,10 @@ 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") +endif() set_target_properties(opentrack PROPERTIES COMPILE_DEFINITIONS OPENTRACK_VERSION=\"${OPENTRACK__COMMIT}\") diff --git a/opentrack-api/gnuc-version-script.txt b/opentrack-api/gnuc-version-script.txt new file mode 100644 index 00000000..cd3a568d --- /dev/null +++ b/opentrack-api/gnuc-version-script.txt @@ -0,0 +1,12 @@ +{ + global: + opentrack_make_ctx; + opentrack_finalize_ctx; + opentrack_enum_trackers; + opentrack_make_tracker; + opentrack_tracker_start; + opentrack_tracker_tick; + opentrack_finalize_tracker; + local: + *; +}; diff --git a/opentrack-api/opentrack.h b/opentrack-api/opentrack.h index 95339d08..8d28b5b8 100644 --- a/opentrack-api/opentrack.h +++ b/opentrack-api/opentrack.h @@ -25,12 +25,6 @@ typedef opentrack_opaque_tracker* opentrack_tracker; # endif #endif -#ifdef __GNUC__ -# define OPENTRACK_VISIBLE __attribute__((visibility ("default"))) -#else -# define OPENTRACK_VISIBLE -#endif - /* for `opentrack_tracker_tick', individual headpose elts */ #ifndef IN_OPENTRACK enum opentrack_dof { @@ -44,20 +38,20 @@ enum opentrack_dof { }; #endif -opentrack OPENTRACK_VISIBLE opentrack_make_ctx(const char* dir); -void OPENTRACK_VISIBLE opentrack_finalize_ctx(opentrack self); +opentrack opentrack_make_ctx(const char* dir); +void opentrack_finalize_ctx(opentrack self); /* no need to free the return value; invalid to modify it */ -const char** OPENTRACK_VISIBLE opentrack_enum_trackers(opentrack self); +const char** opentrack_enum_trackers(opentrack self); /* * don't `opentrack_tracker_tick an unstarted tracker, it's invalid to do so * it's also invalid to start a finalized tracker */ -opentrack_tracker OPENTRACK_VISIBLE opentrack_make_tracker(opentrack ctx, const char* name); -void OPENTRACK_VISIBLE opentrack_tracker_start(opentrack self, opentrack_tracker tracker); -int OPENTRACK_VISIBLE opentrack_tracker_tick(opentrack_tracker tracker, double* headpose); -void OPENTRACK_VISIBLE opentrack_finalize_tracker(opentrack_tracker tracker); +opentrack_tracker opentrack_make_tracker(opentrack ctx, const char* name); +void opentrack_tracker_start(opentrack self, opentrack_tracker tracker); +int opentrack_tracker_tick(opentrack_tracker tracker, double* headpose); +void opentrack_finalize_tracker(opentrack_tracker tracker); #ifdef __cplusplus } #endif -- 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(-) 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(-) 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 8114e519a15d0f915e8b9e7dfe7e57688bbd198d Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 30 Oct 2013 18:37:55 +0100 Subject: pass warns except ovr.h includes Signed-off-by: Stanislaw Halik --- ftnoir_tracker_rift/ftnoir_tracker_rift_dll.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift_dll.cpp b/ftnoir_tracker_rift/ftnoir_tracker_rift_dll.cpp index 775eedfc..a05587f7 100644 --- a/ftnoir_tracker_rift/ftnoir_tracker_rift_dll.cpp +++ b/ftnoir_tracker_rift/ftnoir_tracker_rift_dll.cpp @@ -18,22 +18,22 @@ 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. -- 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(-) 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 4aed930154638707e5e6cd37abfda2f8c369d444 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 30 Oct 2013 18:42:59 +0100 Subject: fix braino Signed-off-by: Stanislaw Halik --- opentrack-api/context.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opentrack-api/context.cpp b/opentrack-api/context.cpp index 003377ce..9b8aa718 100644 --- a/opentrack-api/context.cpp +++ b/opentrack-api/context.cpp @@ -45,7 +45,7 @@ static QList list_files(QDir& dir, QString filter) continue; } QString prefix(LIB_PREFIX + filter); - QString suffix("*." SONAME); + QString suffix("." SONAME); if (str.size() > prefix.size() + suffix.size() && str.startsWith(prefix) && str.endsWith(suffix)) { auto str2 = str.mid(prefix.size(), str.size() - prefix.size() - suffix.size()); -- 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(-) 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 5d1aec6a36bbfb3af3465b34096a5b4e49ce487f Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 30 Oct 2013 21:10:38 +0100 Subject: fix x-plane 9 librt Signed-off-by: Stanislaw Halik --- CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1aafaa16..233e22c4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -328,6 +328,9 @@ if(SDK_XPLANE) LIBRARY_OUTPUT_NAME "facetracknoir.xpl" PREFIX "" SUFFIX "") endif() + if(UNIX) + target_link_libraries(opentrack-xplane-plugin rt) + endif() endif() # some boilerplate -- cgit v1.2.3 From dea1031c422c1402bd05765c33e2dd4bdaf4f6ac Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 30 Oct 2013 21:35:32 +0100 Subject: update plugin. now using radians in shm Signed-off-by: Stanislaw Halik --- x-plane-plugin/plugin.c | 44 ++++++++++++++++++++------------------------ 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/x-plane-plugin/plugin.c b/x-plane-plugin/plugin.c index 38e1e7bf..ec0e1871 100644 --- a/x-plane-plugin/plugin.c +++ b/x-plane-plugin/plugin.c @@ -40,6 +40,12 @@ static WineSHM* shm_posix = NULL; static void *view_x, *view_y, *view_z, *view_heading, *view_pitch; static float offset_x, offset_y, offset_z; +static void reinit_offset() { + offset_x = XPLMGetDataf(view_x); + offset_y = XPLMGetDataf(view_y); + offset_z = XPLMGetDataf(view_z); +} + #ifdef __GNUC__ # define OT_UNUSED(varname) varname __attribute__((__unused__)) #else @@ -82,33 +88,27 @@ void PortableLockedShm_unlock(PortableLockedShm* self) flock(self->fd, LOCK_UN); } -static void reinit_offset() { - offset_x = XPLMGetDataf(view_x); - offset_y = XPLMGetDataf(view_y); - offset_z = XPLMGetDataf(view_z); -} - int write_head_position( - XPLMDrawingPhase OT_UNUSED(inPhase), - int OT_UNUSED(inIsBefore), - void * OT_UNUSED(inRefcon)) + XPLMDrawingPhase OT_UNUSED(inPhase), + int OT_UNUSED(inIsBefore), + void * OT_UNUSED(inRefcon)) { if (lck_posix != NULL && shm_posix != NULL) { PortableLockedShm_lock(lck_posix); - XPLMSetDataf(view_x, shm_posix->data[TX] * 1e-2 + offset_x); - XPLMSetDataf(view_y, shm_posix->data[TY] * 1e-2 + offset_y); - XPLMSetDataf(view_z, shm_posix->data[TZ] * 1e-2 + offset_z); - XPLMSetDataf(view_heading, shm_posix->data[Yaw]); - XPLMSetDataf(view_pitch, shm_posix->data[Pitch]); + XPLMSetDataf(view_x, shm_posix->data[TX] * 1e-3); + XPLMSetDataf(view_y, shm_posix->data[TY] * 1e-3); + XPLMSetDataf(view_z, shm_posix->data[TZ] * 1e-3); + XPLMSetDataf(view_heading, shm_posix->data[Yaw] * 180 / 3.141592654); + XPLMSetDataf(view_pitch, shm_posix->data[Pitch] * 180 / 3.141592654); PortableLockedShm_unlock(lck_posix); } return 1; } PLUGIN_API int XPluginStart ( char * outName, char * outSignature, char * outDescription ) { - view_x = XPLMFindDataRef("sim/aircraft/view/acf_peX"); - view_y = XPLMFindDataRef("sim/aircraft/view/acf_peY"); - view_z = XPLMFindDataRef("sim/aircraft/view/acf_peZ"); + view_x = XPLMFindDataRef("sim/graphics/view/pilots_head_x"); + view_y = XPLMFindDataRef("sim/graphics/view/pilots_head_y"); + view_z = XPLMFindDataRef("sim/graphics/view/pilots_head_z"); view_heading = XPLMFindDataRef("sim/graphics/view/pilots_head_psi"); view_pitch = XPLMFindDataRef("sim/graphics/view/pilots_head_the"); if (view_x && view_y && view_z && view_heading && view_pitch) { @@ -134,21 +134,17 @@ PLUGIN_API void XPluginStop ( void ) { } PLUGIN_API void XPluginEnable ( void ) { - reinit_offset(); XPLMRegisterDrawCallback(write_head_position, xplm_Phase_LastScene, 1, NULL); } PLUGIN_API void XPluginDisable ( void ) { XPLMUnregisterDrawCallback(write_head_position, xplm_Phase_LastScene, 1, NULL); - XPLMSetDataf(view_x, offset_x); - XPLMSetDataf(view_y, offset_y); - XPLMSetDataf(view_z, offset_z); } PLUGIN_API void XPluginReceiveMessage( - XPLMPluginID OT_UNUSED(inFromWho), - int OT_UNUSED(inMessage), - void * OT_UNUSED(inParam)) + XPLMPluginID OT_UNUSED(inFromWho), + int OT_UNUSED(inMessage), + void * OT_UNUSED(inParam)) { if (inMessage == XPLM_MSG_AIRPORT_LOADED) reinit_offset(); -- cgit v1.2.3 From 598ccf7316a44b5a31eb3c0c1850123985c1c5a6 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 30 Oct 2013 21:45:52 +0100 Subject: use proper origin Signed-off-by: Stanislaw Halik --- x-plane-plugin/plugin.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/x-plane-plugin/plugin.c b/x-plane-plugin/plugin.c index ec0e1871..2c43b98d 100644 --- a/x-plane-plugin/plugin.c +++ b/x-plane-plugin/plugin.c @@ -95,9 +95,9 @@ int write_head_position( { if (lck_posix != NULL && shm_posix != NULL) { PortableLockedShm_lock(lck_posix); - XPLMSetDataf(view_x, shm_posix->data[TX] * 1e-3); - XPLMSetDataf(view_y, shm_posix->data[TY] * 1e-3); - XPLMSetDataf(view_z, shm_posix->data[TZ] * 1e-3); + XPLMSetDataf(view_x, shm_posix->data[TX] * 1e-3 + offset_x); + XPLMSetDataf(view_y, shm_posix->data[TY] * 1e-3 + offset_y); + XPLMSetDataf(view_z, shm_posix->data[TZ] * 1e-3 + offset_z); XPLMSetDataf(view_heading, shm_posix->data[Yaw] * 180 / 3.141592654); XPLMSetDataf(view_pitch, shm_posix->data[Pitch] * 180 / 3.141592654); PortableLockedShm_unlock(lck_posix); @@ -106,9 +106,9 @@ int write_head_position( } PLUGIN_API int XPluginStart ( char * outName, char * outSignature, char * outDescription ) { - view_x = XPLMFindDataRef("sim/graphics/view/pilots_head_x"); - view_y = XPLMFindDataRef("sim/graphics/view/pilots_head_y"); - view_z = XPLMFindDataRef("sim/graphics/view/pilots_head_z"); + view_x = XPLMFindDataRef("sim/aircraft/view/acf_peX"); + view_y = XPLMFindDataRef("sim/aircraft/view/acf_peY"); + view_z = XPLMFindDataRef("sim/aircraft/view/acf_peZ"); view_heading = XPLMFindDataRef("sim/graphics/view/pilots_head_psi"); view_pitch = XPLMFindDataRef("sim/graphics/view/pilots_head_the"); if (view_x && view_y && view_z && view_heading && view_pitch) { -- cgit v1.2.3 From fde903fda58eb715147150c8dbc2e16970ab1761 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 30 Oct 2013 21:59:37 +0100 Subject: rename x-plane plugin Signed-off-by: Stanislaw Halik --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 233e22c4..d1e42fc2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -325,7 +325,7 @@ if(SDK_XPLANE) PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/x-plane-plugin/version-script.txt -shared -rdynamic -nodefaultlibs -undefined_warning -fPIC" COMPILE_FLAGS "-Wall -O2 -pipe -fPIC -DLIN -DXPLM210" - LIBRARY_OUTPUT_NAME "facetracknoir.xpl" + LIBRARY_OUTPUT_NAME "opentrack.xpl" PREFIX "" SUFFIX "") endif() if(UNIX) -- cgit v1.2.3 From 657cf32cb57257556c26f702e9e09b0edb15f350 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 30 Oct 2013 23:09:36 +0100 Subject: make standalone libopentrack-api.so work --- opentrack-api/context.cpp | 20 +++++++++++--------- opentrack-api/opentrack-guts.h | 27 +++++++++++++++++---------- opentrack-api/opentrack.h | 6 +++--- opentrack-api/trackers.cpp | 9 +++++---- 4 files changed, 36 insertions(+), 26 deletions(-) diff --git a/opentrack-api/context.cpp b/opentrack-api/context.cpp index 9b8aa718..e0fd5357 100644 --- a/opentrack-api/context.cpp +++ b/opentrack-api/context.cpp @@ -27,10 +27,12 @@ static Metadata* get_metadata(DynamicLibrary* lib, QString& longName, QIcon& ico return meta; } -static QList list_files(QDir& dir, QString filter) +static QList list_files(QString filter) { QList ret; - QStringList filenames = dir.entryList( QStringList() << (LIB_PREFIX + filter + ("*." SONAME)), QDir::Files, QDir::Name ); + QStringList filenames = QDir((qApp->applicationDirPath())).entryList( + QStringList() << (LIB_PREFIX + filter + ("*." SONAME)), + QDir::Files, QDir::Name ); for ( int i = 0; i < filenames.size(); i++) { QIcon icon; QString long_name; @@ -49,7 +51,7 @@ static QList list_files(QDir& dir, QString filter) if (str.size() > prefix.size() + suffix.size() && str.startsWith(prefix) && str.endsWith(suffix)) { auto str2 = str.mid(prefix.size(), str.size() - prefix.size() - suffix.size()); - opentrack_meta item(meta, str2, lib); + opentrack_meta item(str2, lib); ret.push_back(item); } } @@ -57,9 +59,10 @@ static QList list_files(QDir& dir, QString filter) return ret; } -opentrack_ctx::opentrack_ctx(QDir& dir) : - dir(dir), - meta_list(list_files(dir, "opentrack-tracker-")) +opentrack_ctx::opentrack_ctx(int argc, char** argv, void* window_parent) : + app(argc, argv), + meta_list(list_files("opentrack-tracker-")), + fake_frame(window_parent) { const int count = meta_list.size(); list = new char*[count + 1]; @@ -93,10 +96,9 @@ const char** opentrack_enum_trackers(opentrack ctx) return const_cast(ctx->list); } -opentrack opentrack_make_ctx(const char *dir) +opentrack opentrack_make_ctx(int argc, char** argv, void* window_parent) { - QDir d(dir); - return new opentrack_ctx(d); + return new opentrack_ctx(argc, argv, window_parent); } void opentrack_finalize_ctx(opentrack foo) diff --git a/opentrack-api/opentrack-guts.h b/opentrack-api/opentrack-guts.h index b9c3878b..fd94ea34 100644 --- a/opentrack-api/opentrack-guts.h +++ b/opentrack-api/opentrack-guts.h @@ -1,5 +1,6 @@ #pragma once +#include #include #include #include @@ -8,33 +9,39 @@ #include #include #include +#include #include "ftnoir_tracker_base/ftnoir_tracker_base.h" #include "facetracknoir/global-settings.h" +#include typedef ITracker* opentrack_tracker; class opentrack_meta { public: - Metadata* meta; QString path; - DynamicLibrary* lib; + std::shared_ptr lib; - opentrack_meta(Metadata* meta, QString& path, DynamicLibrary* lib) : - meta(meta), path(path), lib(lib) + opentrack_meta(QString& path, DynamicLibrary* lib) : + path(path), lib(lib) {} - ~opentrack_meta() +}; + +class MyFrame : public QFrame { + Q_OBJECT +public: + MyFrame(void* parent) { - delete meta; - delete lib; + create((WId) parent); } + explicit MyFrame() {} }; typedef class opentrack_ctx { public: - QDir dir; + QApplication app; char** list; QList meta_list; - QFrame fake_frame; - opentrack_ctx(QDir& dir); + MyFrame fake_frame; + opentrack_ctx(int argc, char** argv, void* window_parent); ~opentrack_ctx(); } *opentrack; diff --git a/opentrack-api/opentrack.h b/opentrack-api/opentrack.h index 1c8fcee5..63136abc 100644 --- a/opentrack-api/opentrack.h +++ b/opentrack-api/opentrack.h @@ -6,9 +6,9 @@ extern "C" { #ifndef IN_OPENTRACK /* opaque pointers, forward definitions */ struct opentrack_opaque_ctx; -typedef opentrack_opaque_ctx* opentrack; +typedef struct opentrack_opaque_ctx* opentrack; struct opentrack_opaque_tracker; -typedef opentrack_opaque_tracker* opentrack_tracker; +typedef struct opentrack_opaque_tracker* opentrack_tracker; #endif #ifdef IN_OPENTRACK @@ -42,7 +42,7 @@ enum opentrack_dof { }; #endif -opentrack opentrack_make_ctx(const char* dir); +opentrack opentrack_make_ctx(int argc, char** argv, void* window_parent); void opentrack_finalize_ctx(opentrack self); /* no need to free the return value; invalid to modify it */ diff --git a/opentrack-api/trackers.cpp b/opentrack-api/trackers.cpp index 2527017b..0f698e4c 100644 --- a/opentrack-api/trackers.cpp +++ b/opentrack-api/trackers.cpp @@ -5,13 +5,12 @@ extern "C" { opentrack_tracker OPENTRACK_EXPORT opentrack_make_tracker(opentrack ctx, const char* name) { - QString n(name); for (int i = 0; i < ctx->meta_list.size(); i++) { - auto meta = ctx->meta_list[i]; + auto meta = ctx->meta_list.at(i); if (ctx->meta_list.at(i).path == name) { - ITracker* foo = reinterpret_cast(meta.lib->Constructor()); + ITracker* foo = static_cast(meta.lib->Constructor()); return foo; } } @@ -32,7 +31,9 @@ void OPENTRACK_EXPORT opentrack_tracker_start(opentrack self, opentrack_tracker int OPENTRACK_EXPORT opentrack_tracker_tick(opentrack_tracker tracker, double* headpose) { - return tracker->GiveHeadPoseData(headpose); + int ret = tracker->GiveHeadPoseData(headpose); + QApplication::processEvents(0, 5); + return ret; } } -- cgit v1.2.3 From e7f264c09a2d1f4f1f6c6a3144fd5993e72a408d Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 30 Oct 2013 23:22:13 +0100 Subject: mismatched delete/delete[] Signed-off-by: Stanislaw Halik --- opentrack-api/context.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/opentrack-api/context.cpp b/opentrack-api/context.cpp index e0fd5357..84089c43 100644 --- a/opentrack-api/context.cpp +++ b/opentrack-api/context.cpp @@ -83,9 +83,9 @@ opentrack_ctx::~opentrack_ctx() { for (int i = 0; list[i]; i++) { - delete list[i]; + delete[] list[i]; } - delete list; + delete[] list; } extern "C" -- cgit v1.2.3 From 50a101da6278f40e2c3a13234078b4404a99d718 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 30 Oct 2013 23:24:27 +0100 Subject: plug in memleak in api Signed-off-by: Stanislaw Halik --- opentrack-api/context.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/opentrack-api/context.cpp b/opentrack-api/context.cpp index 84089c43..eb5b8a58 100644 --- a/opentrack-api/context.cpp +++ b/opentrack-api/context.cpp @@ -46,6 +46,8 @@ static QList list_files(QString filter) delete lib; continue; } + /* TODO perhaps return full name and somesuch */ + delete meta; QString prefix(LIB_PREFIX + filter); QString suffix("." SONAME); if (str.size() > prefix.size() + suffix.size() && str.startsWith(prefix) && str.endsWith(suffix)) -- 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(+) 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 ecbb8c37edd201115ebc4a0d1cc272f1c56933c2 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 31 Oct 2013 07:56:30 +0100 Subject: aid MSVC symbol exportitude Signed-off-by: Stanislaw Halik --- opentrack-api/context.cpp | 6 +++--- opentrack-api/opentrack.h | 20 ++++++++------------ 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/opentrack-api/context.cpp b/opentrack-api/context.cpp index eb5b8a58..5b218f93 100644 --- a/opentrack-api/context.cpp +++ b/opentrack-api/context.cpp @@ -93,17 +93,17 @@ opentrack_ctx::~opentrack_ctx() extern "C" { -const char** opentrack_enum_trackers(opentrack ctx) +const char** OPENTRACK_EXPORT opentrack_enum_trackers(opentrack ctx) { return const_cast(ctx->list); } -opentrack opentrack_make_ctx(int argc, char** argv, void* window_parent) +opentrack OPENTRACK_EXPORT opentrack_make_ctx(int argc, char** argv, void* window_parent) { return new opentrack_ctx(argc, argv, window_parent); } -void opentrack_finalize_ctx(opentrack foo) +void OPENTRACK_EXPORT opentrack_finalize_ctx(opentrack foo) { delete foo; } diff --git a/opentrack-api/opentrack.h b/opentrack-api/opentrack.h index 63136abc..b0883d50 100644 --- a/opentrack-api/opentrack.h +++ b/opentrack-api/opentrack.h @@ -15,11 +15,7 @@ typedef struct opentrack_opaque_tracker* opentrack_tracker; # ifdef _WIN32 # define OPENTRACK_EXPORT __declspec(dllexport) # else -# ifdef __GNUC__ -# define OPENTRACK_EXPORT __attribute__((visibility ("default"))) -# else -# define OPENTRACK_EXPORT -# endif +# define OPENTRACK_EXPORT # endif #else # ifdef _WIN32 @@ -42,20 +38,20 @@ enum opentrack_dof { }; #endif -opentrack opentrack_make_ctx(int argc, char** argv, void* window_parent); -void opentrack_finalize_ctx(opentrack self); +opentrack OPENTRACK_EXPORT opentrack_make_ctx(int argc, char** argv, void* window_parent); +void OPENTRACK_EXPORT opentrack_finalize_ctx(opentrack self); /* no need to free the return value; invalid to modify it */ -const char** opentrack_enum_trackers(opentrack self); +const char** OPENTRACK_EXPORT opentrack_enum_trackers(opentrack self); /* * don't `opentrack_tracker_tick an unstarted tracker, it's invalid to do so * it's also invalid to start a finalized tracker */ -opentrack_tracker opentrack_make_tracker(opentrack ctx, const char* name); -void opentrack_tracker_start(opentrack self, opentrack_tracker tracker); -int opentrack_tracker_tick(opentrack_tracker tracker, double* headpose); -void opentrack_finalize_tracker(opentrack_tracker tracker); +opentrack_tracker OPENTRACK_EXPORT opentrack_make_tracker(opentrack ctx, const char* name); +void OPENTRACK_EXPORT opentrack_tracker_start(opentrack self, opentrack_tracker tracker); +int OPENTRACK_EXPORT opentrack_tracker_tick(opentrack_tracker tracker, double* headpose); +void OPENTRACK_EXPORT opentrack_finalize_tracker(opentrack_tracker tracker); #ifdef __cplusplus } #endif -- cgit v1.2.3 From 1882ed8c0dfacf9994201e6ca99635d067d32e46 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 31 Oct 2013 17:10:11 +0100 Subject: api: add a mode where video frame isn't visible at all Signed-off-by: Stanislaw Halik --- opentrack-api/opentrack-guts.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/opentrack-api/opentrack-guts.h b/opentrack-api/opentrack-guts.h index fd94ea34..db897edc 100644 --- a/opentrack-api/opentrack-guts.h +++ b/opentrack-api/opentrack-guts.h @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -31,7 +32,15 @@ class MyFrame : public QFrame { public: MyFrame(void* parent) { - create((WId) parent); + if (parent == (void*) -1) + { + show(); + setVisible(false); + } + else + { + create((WId) parent); + } } explicit MyFrame() {} }; -- cgit v1.2.3 From 4e8de273fe765a8a3fedaebd654cb74752bc4663 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 31 Oct 2013 17:18:36 +0100 Subject: api: prevent focus lossage, hopefully --- opentrack-api/opentrack-guts.h | 1 + 1 file changed, 1 insertion(+) diff --git a/opentrack-api/opentrack-guts.h b/opentrack-api/opentrack-guts.h index db897edc..c8e3309a 100644 --- a/opentrack-api/opentrack-guts.h +++ b/opentrack-api/opentrack-guts.h @@ -36,6 +36,7 @@ public: { show(); setVisible(false); + hide(); } else { -- cgit v1.2.3 From 47a1ba1edea5ae2e1b58e58503ed970d48b9bb5a Mon Sep 17 00:00:00 2001 From: mm0zct Date: Fri, 1 Nov 2013 21:36:06 +0000 Subject: Fixed CMakeList.txt to build gainst LibOVR on linux/GNU toolchain --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d1e42fc2..21e8a640 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -549,9 +549,9 @@ if(SDK_RIFT) target_link_libraries(opentrack-tracker-rift "${SDK_RIFT}/Lib/Win32/libovr.lib" winmm.lib) else() if(WIN32) - target_link_libraries(opentrack-tracker-rift "${SDK_RIFT}/LibOVR.a" winmm.lib setupapi.lib) + target_link_libraries(opentrack-tracker-rift "${SDK_RIFT}/libLibOVR.a" winmm.lib setupapi.lib) else() - target_link_libraries(opentrack-tracker-rift "${SDK_RIFT}/LibOVR.a" udev Xinerama) + target_link_libraries(opentrack-tracker-rift "${SDK_RIFT}/libLibOVR.a" udev Xinerama) endif() endif() if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) -- cgit v1.2.3 From 92d2d05bd439f8b76eb4bf5822167b463e227807 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 1 Nov 2013 23:15:19 +0100 Subject: disable qt designer Signed-off-by: Stanislaw Halik --- CMakeLists.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 21e8a640..c7b0ca8e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -96,7 +96,6 @@ endif() 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}) - INCLUDE_DIRECTORIES(${QT_QTDESIGNER_INCLUDE_DIR}) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/qfunctionconfigurator) @@ -363,7 +362,7 @@ target_link_libraries(opentrack-csv ${MY_QT_LIBS}) add_library(opentrack-pose-widget SHARED ${opentrack-pose-widget-c} ${opentrack-pose-widget-h} ${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-h} ${opentrack-spline-widget-moc}) -target_link_libraries(opentrack-spline-widget ${MY_QT_LIBS} ${QT_QTDESIGNER_LIBRARY_RELEASE}) +target_link_libraries(opentrack-spline-widget ${MY_QT_LIBS}) add_library(opentrack-filter-accela SHARED ${opentrack-filter-accela-c} ${opentrack-filter-accela-h} ${opentrack-filter-accela-moc} ${opentrack-filter-accela-uih} ${opentrack-filter-accela-rcc}) target_link_libraries(opentrack-filter-accela ${MY_QT_LIBS}) -- cgit v1.2.3 From 513f93b01ac22842746f493c23bb48eb36071dc5 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 1 Nov 2013 23:16:11 +0100 Subject: spring v2: magic nums -> ui, squash uninit mem access -sthalik&mm0zct --- ftnoir_tracker_rift/ftnoir_rift_clientcontrols.ui | 110 +++++++++++++++++---- ftnoir_tracker_rift/ftnoir_tracker_rift.cpp | 17 +++- ftnoir_tracker_rift/ftnoir_tracker_rift.h | 3 +- ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp | 8 ++ 4 files changed, 118 insertions(+), 20 deletions(-) diff --git a/ftnoir_tracker_rift/ftnoir_rift_clientcontrols.ui b/ftnoir_tracker_rift/ftnoir_rift_clientcontrols.ui index 9c3ec53a..38e745c9 100644 --- a/ftnoir_tracker_rift/ftnoir_rift_clientcontrols.ui +++ b/ftnoir_tracker_rift/ftnoir_rift_clientcontrols.ui @@ -9,10 +9,16 @@ 0 0 - 176 - 145 + 195 + 265 + + + 0 + 0 + + Oculus Rift tracker settings FaceTrackNoIR @@ -26,21 +32,9 @@ false - - + + - - - 0 - 0 - - - - - 0 - 0 - - Enable Axis @@ -159,7 +153,89 @@ - + + + + Yaw spring + + + + + + Enable + + + + + + + Persistence + + + + + + + 5 + + + 0.900000000000000 + + + 1.000000000000000 + + + 0.001000000000000 + + + + + + + Constant drift + + + + + + + 5 + + + 0.000100000000000 + + + 0.100000000000000 + + + 0.001000000000000 + + + + + + + Deadzone + + + + + + + 5 + + + 0.100000000000000 + + + 0.010000000000000 + + + + + + + diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp b/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp index 7d567ca3..dc0892fe 100644 --- a/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp +++ b/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp @@ -21,6 +21,7 @@ Rift_Tracker::Rift_Tracker() pHMD = NULL; pSensor = NULL; pSFusion = NULL; + old_yaw = 0; } Rift_Tracker::~Rift_Tracker() @@ -87,9 +88,17 @@ bool Rift_Tracker::GiveHeadPoseData(double *data) float pitch = 0.0f; float roll = 0.0f; hmdOrient.GetEulerAngles(&yaw, &pitch , &roll); - newHeadPose[Yaw] = yaw; - newHeadPose[Pitch] =pitch; + newHeadPose[Pitch] = pitch; newHeadPose[Roll] = roll; + newHeadPose[Yaw] = yaw; + if (useYawSpring) + { + newHeadPose[Yaw] = newHeadPose[Yaw]*persistence + (yaw-old_yaw); + if(newHeadPose[Yaw]>deadzone)newHeadPose[Yaw]-= constant_drift; + if(newHeadPose[Yaw]<-deadzone)newHeadPose[Yaw]+= constant_drift; + old_yaw=yaw; + } + else #if 0 newHeadPose[TX] = acd.controllers[0].pos[0]/50.0f; @@ -142,6 +151,10 @@ void Rift_Tracker::loadSettings() { bEnableY = iniFile.value ( "EnableY", 1 ).toBool(); bEnableZ = iniFile.value ( "EnableZ", 1 ).toBool(); #endif + useYawSpring = iniFile.value("yaw-spring", false).toBool(); + constant_drift = iniFile.value("constant-drift", 0.000005).toDouble(); + persistence = iniFile.value("persistence", 0.99999).toDouble(); + deadzone = iniFile.value("deadzone", 0.02).toDouble(); iniFile.endGroup (); } diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift.h b/ftnoir_tracker_rift/ftnoir_tracker_rift.h index 55fa99e3..bd295838 100644 --- a/ftnoir_tracker_rift/ftnoir_tracker_rift.h +++ b/ftnoir_tracker_rift/ftnoir_tracker_rift.h @@ -35,7 +35,8 @@ private: bool bEnableY; bool bEnableZ; #endif - + bool useYawSpring; + double old_yaw, constant_drift, persistence, deadzone; }; // Widget that has controls for FTNoIR protocol client-settings. diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp b/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp index 6b1a559d..2efefbb3 100644 --- a/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp +++ b/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp @@ -117,6 +117,10 @@ void TrackerControls::loadSettings() { ui.chkEnableY->setChecked(iniFile.value ( "EnableY", 1 ).toBool()); ui.chkEnableZ->setChecked(iniFile.value ( "EnableZ", 1 ).toBool()); #endif + ui.yawSpring->setChecked(iniFile.value("yaw-spring", true).toBool()); + ui.deadzone->setValue(iniFile.value("deadzone", 0.02).toDouble()); + ui.constantDrift->setValue(iniFile.value("constant-drift", 0.000005).toDouble()); + ui.persistence->setValue(iniFile.value("persistence", 0.9999).toDouble()); iniFile.endGroup (); settingsDirty = false; @@ -140,6 +144,10 @@ void TrackerControls::save() { iniFile.setValue ( "EnableY", ui.chkEnableY->isChecked() ); iniFile.setValue ( "EnableZ", ui.chkEnableZ->isChecked() ); #endif + iniFile.setValue("yaw-spring", ui.yawSpring->isChecked()); + iniFile.setValue("deadzone", ui.deadzone->value()); + iniFile.setValue("constant-drift", ui.constantDrift->value()); + iniFile.setValue("persistence", ui.persistence->value()); iniFile.endGroup (); settingsDirty = false; -- cgit v1.2.3 From 99ac22f1ecadfa5da3ef5c9078e553d50d9dc06f Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 1 Nov 2013 23:22:38 +0100 Subject: alias variable, fix braino --- ftnoir_tracker_rift/ftnoir_tracker_rift.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp b/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp index dc0892fe..db0b1290 100644 --- a/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp +++ b/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp @@ -93,13 +93,11 @@ bool Rift_Tracker::GiveHeadPoseData(double *data) newHeadPose[Yaw] = yaw; if (useYawSpring) { - newHeadPose[Yaw] = newHeadPose[Yaw]*persistence + (yaw-old_yaw); + newHeadPose[Yaw] = yaw*persistence + (yaw-old_yaw); if(newHeadPose[Yaw]>deadzone)newHeadPose[Yaw]-= constant_drift; if(newHeadPose[Yaw]<-deadzone)newHeadPose[Yaw]+= constant_drift; old_yaw=yaw; } - else - #if 0 newHeadPose[TX] = acd.controllers[0].pos[0]/50.0f; newHeadPose[TY] = acd.controllers[0].pos[1]/50.0f; -- cgit v1.2.3 From c98535e65783adcbf80af03725fa3c4a0a277064 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 1 Nov 2013 23:22:45 +0100 Subject: adjust ui size Signed-off-by: Stanislaw Halik --- ftnoir_tracker_rift/ftnoir_rift_clientcontrols.ui | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/ftnoir_tracker_rift/ftnoir_rift_clientcontrols.ui b/ftnoir_tracker_rift/ftnoir_rift_clientcontrols.ui index 38e745c9..7f10db99 100644 --- a/ftnoir_tracker_rift/ftnoir_rift_clientcontrols.ui +++ b/ftnoir_tracker_rift/ftnoir_rift_clientcontrols.ui @@ -175,6 +175,12 @@ + + + 0 + 0 + + 5 @@ -198,6 +204,12 @@ + + + 0 + 0 + + 5 @@ -221,6 +233,12 @@ + + + 0 + 0 + + 5 -- cgit v1.2.3 From 35145c4b10fc8e300bbd02d2ebdba0ba71760022 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 1 Nov 2013 23:28:11 +0100 Subject: use doubles; denormals are flushed to zero Signed-off-by: Stanislaw Halik --- ftnoir_tracker_rift/ftnoir_tracker_rift.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp b/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp index db0b1290..0b7673d2 100644 --- a/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp +++ b/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp @@ -82,7 +82,7 @@ bool Rift_Tracker::GiveHeadPoseData(double *data) { if (pSFusion != NULL) { Quatf hmdOrient = pSFusion->GetOrientation(); - float newHeadPose[6]; + double newHeadPose[6]; float yaw = 0.0f; float pitch = 0.0f; -- cgit v1.2.3 From 35b5ee9af506179745bea1faea49f5c44d230430 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 1 Nov 2013 23:28:28 +0100 Subject: finish resize Signed-off-by: Stanislaw Halik --- ftnoir_tracker_rift/ftnoir_rift_clientcontrols.ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ftnoir_tracker_rift/ftnoir_rift_clientcontrols.ui b/ftnoir_tracker_rift/ftnoir_rift_clientcontrols.ui index 7f10db99..c3485a17 100644 --- a/ftnoir_tracker_rift/ftnoir_rift_clientcontrols.ui +++ b/ftnoir_tracker_rift/ftnoir_rift_clientcontrols.ui @@ -10,7 +10,7 @@ 0 0 195 - 265 + 292 -- cgit v1.2.3 From dbc732f5187397caba95df6a19e22f086f12f7c5 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 1 Nov 2013 23:30:05 +0100 Subject: remove done Signed-off-by: Stanislaw Halik --- TODO.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/TODO.txt b/TODO.txt index c5fbf58d..e9eb232a 100644 --- a/TODO.txt +++ b/TODO.txt @@ -10,8 +10,6 @@ ini files. Use metadata props in order to get class name for ini section. Required here are also arrays of settings. Use QList for template specialization. -20131019 sh - Add a joystick tracker source, with selectable axes. 20131019 mm0zct Ship more then one profile for configuring the curves etc. There are two main user bases, HMD and traditional monitor+webcam users, -- cgit v1.2.3 From 1489b987a09b1de3cb6317d8765e802647c709fc Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 1 Nov 2013 23:48:22 +0100 Subject: fix spring -mm0zct --- ftnoir_tracker_rift/ftnoir_tracker_rift.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp b/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp index 0b7673d2..accd41d3 100644 --- a/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp +++ b/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp @@ -93,7 +93,7 @@ bool Rift_Tracker::GiveHeadPoseData(double *data) newHeadPose[Yaw] = yaw; if (useYawSpring) { - newHeadPose[Yaw] = yaw*persistence + (yaw-old_yaw); + newHeadPose[Yaw] = old_yaw*persistence + (yaw-old_yaw); if(newHeadPose[Yaw]>deadzone)newHeadPose[Yaw]-= constant_drift; if(newHeadPose[Yaw]<-deadzone)newHeadPose[Yaw]+= constant_drift; old_yaw=yaw; -- cgit v1.2.3 From aabf7a26355e25a93283c774095cca4b31c87fb1 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 1 Nov 2013 23:53:37 +0100 Subject: resize checkbox (mm0zct reported-by) --- ftnoir_tracker_rift/ftnoir_rift_clientcontrols.ui | 38 +++++++++++++++++------ 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/ftnoir_tracker_rift/ftnoir_rift_clientcontrols.ui b/ftnoir_tracker_rift/ftnoir_rift_clientcontrols.ui index c3485a17..e868a9c3 100644 --- a/ftnoir_tracker_rift/ftnoir_rift_clientcontrols.ui +++ b/ftnoir_tracker_rift/ftnoir_rift_clientcontrols.ui @@ -9,8 +9,8 @@ 0 0 - 195 - 292 + 209 + 288 @@ -32,8 +32,8 @@ false - - + + Enable Axis @@ -153,12 +153,12 @@ - + Yaw spring - + @@ -176,11 +176,17 @@ - + 0 0 + + + 0 + 23 + + 5 @@ -205,11 +211,17 @@ - + 0 0 + + + 0 + 23 + + 5 @@ -234,11 +246,17 @@ - + 0 0 + + + 0 + 23 + + 5 @@ -253,7 +271,7 @@ - + -- cgit v1.2.3 From b7418c2d7f554c91cd158ce4733433a271ad96ec Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 1 Nov 2013 23:56:52 +0100 Subject: fix Qxt-mini linkage Signed-off-by: Stanislaw Halik --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c7b0ca8e..c1cc757e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -607,7 +607,7 @@ endif() if(UNIX) 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}) + target_link_libraries(opentrack-qxt-mini ${MY_QT_LIBS} X11) 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}\") -- cgit v1.2.3 From a047a476bbb5ce1bab49f779d3f25e9d21ff1345 Mon Sep 17 00:00:00 2001 From: mm0zct Date: Fri, 1 Nov 2013 23:39:38 +0000 Subject: We now just enumerate on the sensor, rather than finding the HMD, this means we don't need it attached to the display and it also works better on linux now -mm0zct --- ftnoir_tracker_rift/ftnoir_tracker_rift.cpp | 22 ++++++---------------- ftnoir_tracker_rift/ftnoir_tracker_rift.h | 1 - 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp b/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp index accd41d3..dd78bf9f 100644 --- a/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp +++ b/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp @@ -18,7 +18,6 @@ Rift_Tracker::Rift_Tracker() #endif should_quit = false; pManager = NULL; - pHMD = NULL; pSensor = NULL; pSFusion = NULL; old_yaw = 0; @@ -30,8 +29,6 @@ Rift_Tracker::~Rift_Tracker() pSensor->Release(); if (pSFusion) delete pSFusion; - if (pHMD) - pHMD->Release(); if (pManager) pManager->Release(); System::Destroy(); @@ -49,20 +46,13 @@ void Rift_Tracker::StartTracker(QFrame*) pManager = DeviceManager::Create(); if (pManager != NULL) { - DeviceEnumerator enumerator = pManager->EnumerateDevices(); + DeviceEnumerator enumerator = pManager->EnumerateDevices(); if (enumerator.IsAvailable()) { - pHMD = enumerator.CreateDevice(); - - if (pHMD != NULL) - { - pSensor = pHMD->GetSensor(); - }else{ - QMessageBox::warning(0,"FaceTrackNoIR Error", "Unable to find Rift tracker",QMessageBox::Ok,QMessageBox::NoButton); - } - + pSensor = enumerator.CreateDevice(); + if (pSensor){ - pSFusion = new OVR::SensorFusion(); + pSFusion = new OVR::SensorFusion(); pSFusion->Reset(); pSFusion->AttachToSensor(pSensor); }else{ @@ -70,7 +60,7 @@ void Rift_Tracker::StartTracker(QFrame*) } }else{ - QMessageBox::warning(0,"FaceTrackNoIR Error", "Unable to find Rift tracker",QMessageBox::Ok,QMessageBox::NoButton); + QMessageBox::warning(0,"FaceTrackNoIR Error", "Unable to enumerate Rift tracker",QMessageBox::Ok,QMessageBox::NoButton); } }else{ QMessageBox::warning(0,"FaceTrackNoIR Error", "Unable to start Rift tracker",QMessageBox::Ok,QMessageBox::NoButton); @@ -123,7 +113,7 @@ bool Rift_Tracker::GiveHeadPoseData(double *data) data[Roll] = newHeadPose[Roll] * 57.295781f; } } - return pHMD != NULL; + return pSensor != NULL; } diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift.h b/ftnoir_tracker_rift/ftnoir_tracker_rift.h index bd295838..b76d8d09 100644 --- a/ftnoir_tracker_rift/ftnoir_tracker_rift.h +++ b/ftnoir_tracker_rift/ftnoir_tracker_rift.h @@ -24,7 +24,6 @@ protected: private: static bool isInitialised; OVR::DeviceManager* pManager; - OVR::HMDDevice* pHMD; OVR::SensorDevice* pSensor; OVR::SensorFusion* pSFusion; bool bEnableRoll; -- cgit v1.2.3 From 37fc65d7ef126f26b54193e65a649cd3e730c635 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 2 Nov 2013 01:02:31 +0100 Subject: Rift works on Linux now --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 68442dc1..30f0dcbf 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Not to be confused with railway planning software <> # Tracking sources - PointTracker by Patrick Ruoff, freetrack-like light sources -- Oculus Rift (Windows; Linux testers welcome!) +- Oculus Rift (Linux, Windows) - AR marker support via the ArUco library - HT tracker - Razer Hydra (Windows; Linux testers welcome!) -- cgit v1.2.3 From bb416dbd61c626f6656d9c79aa851a6b3fa6b5d9 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 2 Nov 2013 04:51:45 +0100 Subject: Accomodate new build box --- installer/opentrack-installer.iss | 104 +++++++++++++++++++------------------- 1 file changed, 52 insertions(+), 52 deletions(-) diff --git a/installer/opentrack-installer.iss b/installer/opentrack-installer.iss index dda574eb..fc0fcc40 100644 --- a/installer/opentrack-installer.iss +++ b/installer/opentrack-installer.iss @@ -1,52 +1,52 @@ -; Script generated by the Inno Setup Script Wizard. -; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! - -#include "../build/opentrack-version.h" -#define MyAppName "opentrack" -#define MyAppVersion OPENTRACK_VERSION -#define MyAppPublisher "opentrack" -#define MyAppURL "http://github.com/opentrack/opentrack" -#define MyAppExeName "opentrack.exe" - -[Setup] -; NOTE: The value of AppId uniquely identifies this application. -; Do not use the same AppId value in installers for other applications. -; (To generate a new GUID, click Tools | Generate GUID inside the IDE.) -AppId={{E454805B-11A6-469F-9FA9-865BEAD787D0} -AppName={#MyAppName} -AppVersion={#MyAppVersion} -;AppVerName={#MyAppName} {#MyAppVersion} -AppPublisher={#MyAppPublisher} -AppPublisherURL={#MyAppURL} -AppSupportURL={#MyAppURL} -AppUpdatesURL={#MyAppURL} -DefaultDirName={pf}\{#MyAppName} -DefaultGroupName={#MyAppName} -AllowNoIcons=yes -OutputBaseFilename={#MyAppVersion}-setup.exe -SetupIconFile=d:\opentrack-win32-sdk\opentrack\facetracknoir\facetracknoir.ico -Compression=lzma2/ultra64 -SolidCompression=yes -DisableWelcomePage=True -DisableReadyPage=True -DisableReadyMemo=True -RestartIfNeededByRun=False -InternalCompressLevel=ultra -CompressionThreads=2 -MinVersion=0,5.01sp2 - -[Languages] -Name: "english"; MessagesFile: "compiler:Default.isl" - -[Tasks] -Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked - -[Files] -Source: "d:\opentrack-win32-sdk\opentrack\build\install\*"; DestDir: "{app}"; Flags: ignoreversion createallsubdirs recursesubdirs - -[Icons] -Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}" -Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon - -[Run] -Filename: "{app}\{#MyAppExeName}"; Flags: nowait postinstall skipifsilent; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}" +; Script generated by the Inno Setup Script Wizard. +; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! + +#include "../build/opentrack-version.h" +#define MyAppName "opentrack" +#define MyAppVersion OPENTRACK_VERSION +#define MyAppPublisher "opentrack" +#define MyAppURL "http://github.com/opentrack/opentrack" +#define MyAppExeName "opentrack.exe" + +[Setup] +; NOTE: The value of AppId uniquely identifies this application. +; Do not use the same AppId value in installers for other applications. +; (To generate a new GUID, click Tools | Generate GUID inside the IDE.) +AppId={{E454805B-11A6-469F-9FA9-865BEAD787D0} +AppName={#MyAppName} +AppVersion={#MyAppVersion} +;AppVerName={#MyAppName} {#MyAppVersion} +AppPublisher={#MyAppPublisher} +AppPublisherURL={#MyAppURL} +AppSupportURL={#MyAppURL} +AppUpdatesURL={#MyAppURL} +DefaultDirName={pf}\{#MyAppName} +DefaultGroupName={#MyAppName} +AllowNoIcons=yes +OutputBaseFilename={#MyAppVersion}-setup +SetupIconFile=d:\opentrack\facetracknoir\facetracknoir.ico +Compression=lzma2/ultra64 +SolidCompression=yes +DisableWelcomePage=True +DisableReadyPage=True +DisableReadyMemo=True +RestartIfNeededByRun=False +InternalCompressLevel=ultra +CompressionThreads=2 +MinVersion=0,5.01sp2 + +[Languages] +Name: "english"; MessagesFile: "compiler:Default.isl" + +[Tasks] +Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked + +[Files] +Source: "d:\opentrack\build-mingw-w64\install\*"; DestDir: "{app}"; Flags: ignoreversion createallsubdirs recursesubdirs + +[Icons] +Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}" +Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon + +[Run] +Filename: "{app}\{#MyAppExeName}"; Flags: nowait postinstall skipifsilent; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}" -- 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(-) 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 f4e3f4361c3658aee408a6fc02bff03c422fd266 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 3 Nov 2013 17:14:47 +0100 Subject: fix Crapple --- CMakeLists.txt | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 952584e4..d17279c2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -118,7 +118,7 @@ endif() set(SDK_WINE_PREFIX "" CACHE PATH "Path where Wine is installed") set(SDK_WINE_NO_WRAPPER FALSE CACHE BOOL "Don't build wrapper, for instance X-Plane is native Linux app") endif() - IF("${CMAKE_SYSTEM}" MATCHES "Linux") + IF("${CMAKE_SYSTEM}" MATCHES "Linux" OR APPLE) set(SDK_XPLANE "" CACHE PATH "Path to X-Plane SDK") endif() @@ -319,7 +319,7 @@ file(GLOB opentrack-freetrack-c "freetrackclient/*.cpp") if(SDK_XPLANE) # probably librt already included add_library(opentrack-xplane-plugin SHARED ${opentrack-xplane-plugin-c}) - if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) + if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC AND NOT APPLE) SET_TARGET_PROPERTIES(opentrack-xplane-plugin PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/x-plane-plugin/version-script.txt -shared -rdynamic -nodefaultlibs -undefined_warning -fPIC" @@ -327,6 +327,11 @@ if(SDK_XPLANE) LIBRARY_OUTPUT_NAME "opentrack.xpl" 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") + endif() if(UNIX AND NOT APPLE) target_link_libraries(opentrack-xplane-plugin rt) endif() @@ -349,18 +354,14 @@ if(NOT WIN32 AND NOT APPLE) target_link_libraries(opentrack-compat rt) endif() - # hack to avoid breakage on buildbot - set(my-qt-deps) - if(WIN32) - set(my-qt-deps ws2_32) - endif() -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}) +# hack to avoid breakage on buildbot +set(my-qt-deps) +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}) + add_library(opentrack-csv SHARED ${opentrack-csv-c} ${opentrack-csv-h}) target_link_libraries(opentrack-csv ${MY_QT_LIBS}) @@ -817,3 +818,10 @@ if(MSVC) install(FILES ${pdbs1} ${pdbs2} DESTINATION .) endif() +if(APPLE) + set(apple-frameworks "-stdlib=libc++ -framework Cocoa -framework CoreFoundation -lobjc -lz -framework Carbon") + set(CMAKE_SHARED_LINKER_FLAGS " ${apple-frameworks} ${CMAKE_SHARED_LINKER_FLAGS}") + set(CMAKE_STATIC_LINKER_FLAGS " ${apple-frameworks} ${CMAKE_STATIC_LINKER_FLAGS}") + set(CMAKE_EXE_LINKER_FLAGS " ${apple-frameworks} ${CMAKE_EXE_LINKER_FLAGS}") + set(CMAKE_MODULE_LINKER_FLAGS " ${apple-frameworks} ${CMAKE_MODULE_LINKER_FLAGS}") +endif() -- cgit v1.2.3 From 4be56b29b1480457b64298ea2e1e7a01a4943adb Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 2 Nov 2013 06:51:45 +0100 Subject: pt: downcase settings/ dirname Signed-off-by: Stanislaw Halik --- FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.cpp b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.cpp index 13ef49ec..db908465 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("Abbequerque Inc.", "FaceTrackNoIR"); // 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" ); @@ -60,7 +60,7 @@ 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(); + QString currentFile = settings.value( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) iniFile.beginGroup ( "PointTracker" ); @@ -106,7 +106,7 @@ void TrackerDialogSettings::load_ini() qDebug("TrackerDialogSettings::load_ini()"); QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // 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" ); @@ -132,7 +132,7 @@ void TrackerDialogSettings::save_ini() const qDebug("TrackerDialogSettings::save_ini()"); QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // 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" ); @@ -151,4 +151,4 @@ void TrackerDialogSettings::save_ini() const iniFile.setValue("CapHalfWidth", cap_x); iniFile.setValue("CapHeight", cap_y); iniFile.setValue("CapLength", cap_z); -} \ No newline at end of file +} -- cgit v1.2.3 From 1284ea867254229e008d2b7bfea37194334036f5 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 3 Nov 2013 16:20:20 +0100 Subject: compat: specify MAP_ANON Signed-off-by: Stanislaw Halik --- compat/compat.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compat/compat.cpp b/compat/compat.cpp index 808a8645..1b530890 100644 --- a/compat/compat.cpp +++ b/compat/compat.cpp @@ -56,7 +56,7 @@ PortableLockedShm::PortableLockedShm(const char *shmName, const char* /*mutexNam fd = shm_open(shm_filename, O_RDWR | O_CREAT, 0600); if (ftruncate(fd, mapSize) == 0) - mem = mmap(NULL, mapSize, PROT_READ|PROT_WRITE, MAP_SHARED, fd, (off_t)0); + mem = mmap(NULL, mapSize, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_ANON, fd, (off_t)0); else mem = (void*) -1; } @@ -88,4 +88,4 @@ bool PortableLockedShm::success() #else return (void*) mem != NULL; #endif -} \ No newline at end of file +} -- cgit v1.2.3 From 7e06aaff52974d2dc8035bfb986c42bc8ee9cfa2 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 3 Nov 2013 16:25:06 +0100 Subject: fix compat on macosx Signed-off-by: Stanislaw Halik --- compat/compat.cpp | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/compat/compat.cpp b/compat/compat.cpp index 1b530890..8ac872d1 100644 --- a/compat/compat.cpp +++ b/compat/compat.cpp @@ -6,6 +6,8 @@ */ #define IN_FTNOIR_COMPAT #include "compat.h" +#include +#include #if defined(_WIN32) @@ -46,19 +48,18 @@ void PortableLockedShm::unlock() #else PortableLockedShm::PortableLockedShm(const char *shmName, const char* /*mutexName*/, int mapSize) : size(mapSize) { - char shm_filename[NAME_MAX]; - shm_filename[0] = '/'; - strncpy(shm_filename+1, shmName, NAME_MAX-2); - sprintf(shm_filename + strlen(shm_filename), "%ld\n", (long) getuid()); - shm_filename[NAME_MAX-1] = '\0'; - + std::string filename; + filename.append("/"); + filename.append(shmName); //(void) shm_unlink(shm_filename); - fd = shm_open(shm_filename, O_RDWR | O_CREAT, 0600); - if (ftruncate(fd, mapSize) == 0) - mem = mmap(NULL, mapSize, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_ANON, fd, (off_t)0); - else - mem = (void*) -1; + 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; + } + mem = mmap(NULL, mapSize, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_ANON, fd, (off_t)0); } PortableLockedShm::~PortableLockedShm() -- cgit v1.2.3 From 9e145b2b92d0f2d8b76599608746bb377af6bd91 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 3 Nov 2013 16:25:28 +0100 Subject: implement ROI for speed Signed-off-by: Stanislaw Halik --- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 110 +++++++++++++++----------- 1 file changed, 63 insertions(+), 47 deletions(-) diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index 906e2654..a918d020 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -188,10 +188,13 @@ start: aruco::MarkerDetector detector; detector.setDesiredSpeed(3); - detector.setMinMaxSize(0.06, 0.4); - detector.setThresholdParams(11, 7); + detector.setThresholdParams(11, 6); + + cv::Rect last_roi(65535, 65535, 0, 0); cv::Mat color, color_, grayscale, rvec, tvec; + + const double stateful_coeff = 0.81; if (!camera->isOpened()) { @@ -205,12 +208,8 @@ start: auto freq = cv::getTickFrequency(); auto last_time = cv::getTickCount(); - auto prev_time = last_time; - double last_delay = -1; int fps = 0; int last_fps = 0; - double error = 0; - std::vector reprojection; cv::Point2f last_centroid; while (!stop) { @@ -241,25 +240,32 @@ start: dist_coeffs.at(i) = 0; std::vector< aruco::Marker > markers; - - detector.detect(grayscale, markers, cv::Mat(), cv::Mat(), -1, false); - - if (markers.size() == 1 && markers[0].size() == 4) { - const aruco::Marker& m = markers.at(0); + + if (last_roi.width > 0 && + (detector.detect(grayscale(last_roi), markers, cv::Mat(), cv::Mat(), -1, false), + markers.size() == 1 && markers[0].size() == 4)) + { + detector.setMinMaxSize(std::max(0.2, 0.08 * grayscale.cols / last_roi.width), + std::min(1.0, 0.39 * grayscale.cols / last_roi.width)); + auto& m = markers.at(0); for (int i = 0; i < 4; i++) - cv::line(color, m[i], m[(i+1)%4], cv::Scalar(0, 0, 255), scale); + { + auto& p = m.at(i); + p.x += last_roi.x; + p.y += last_roi.y; + } } - - for (int i = 0; i < reprojection.size(); i++) + else { - cv::circle(frame, - reprojection[i], - 6, - cv::Scalar(0, 255, 128), - 3); + detector.setMinMaxSize(0.09, 0.4); + detector.detect(grayscale, markers, cv::Mat(), cv::Mat(), -1, false); } - cv::circle(frame, last_centroid, 7, cv::Scalar(255, 255, 0), -1); + if (markers.size() == 1 && markers[0].size() == 4) { + const aruco::Marker& m = markers.at(0); + for (int i = 0; i < 4; i++) + cv::line(color, m[i], m[(i+1)%4], cv::Scalar(0, 0, 255), scale, 8); + } auto time = cv::getTickCount(); @@ -278,15 +284,8 @@ start: cv::putText(frame, buf, cv::Point(10, 32), cv::FONT_HERSHEY_PLAIN, scale, cv::Scalar(0, 255, 0), scale); ::sprintf(buf, "Jiffies: %ld", (long) (10000 * (time - tm) / freq)); cv::putText(frame, buf, cv::Point(10, 54), cv::FONT_HERSHEY_PLAIN, scale, cv::Scalar(80, 255, 0), scale); - ::sprintf(buf, "Error: %f px", error); - cv::putText(frame, buf, cv::Point(10, 76), cv::FONT_HERSHEY_PLAIN, scale, cv::Scalar(80, 255, 0), scale); - prev_time = time; frame = color; - if (frame.rows > 0) - { - videoWidget->update_image(frame.data, frame.cols, frame.rows); - } if (markers.size() == 1 && markers[0].size() == 4) { const aruco::Marker& m = markers.at(0); @@ -305,6 +304,29 @@ start: obj_points.at(0,0)=-size + headpos[0]; obj_points.at(0,1)=size + headpos[1]; obj_points.at(0,2)=0 + headpos[2]; + + last_roi = cv::Rect(65535, 65535, 0, 0); + + for (int i = 0; i < 4; i++) + { + auto foo = m.at(i); + last_roi.x = std::min(foo.x, last_roi.x); + last_roi.y = std::min(foo.y, last_roi.y); + last_roi.width = std::max(foo.x, last_roi.width); + last_roi.height = std::max(foo.y, last_roi.height); + } + { + last_roi.width -= last_roi.x; + last_roi.height -= last_roi.y; + last_roi.x -= last_roi.width * stateful_coeff; + last_roi.y -= last_roi.height * stateful_coeff; + last_roi.width *= stateful_coeff * 3; + last_roi.height *= stateful_coeff * 3; + last_roi.x = std::max(0, last_roi.x); + last_roi.y = std::max(0, last_roi.y); + last_roi.width = std::min(grayscale.cols - last_roi.x, last_roi.width); + last_roi.height = std::min(grayscale.rows - last_roi.y, last_roi.height); + } cv::solvePnP(obj_points, m, intrinsics, dist_coeffs, rvec, tvec, false, cv::ITERATIVE); @@ -316,25 +338,15 @@ start: cv::Vec3d foo = cv::RQDecomp3x3(rotation_matrix, junk1, junk2); - QMutexLocker lck(&mtx); - - for (int i = 0; i < 3; i++) - pose[i] = tvec.at(i); - - pose[Yaw] = foo[1]; - pose[Pitch] = -foo[0]; - pose[Roll] = foo[2]; + { + QMutexLocker lck(&mtx); - reprojection.clear(); - reprojection.resize(4); - cv::projectPoints(obj_points, rvec, tvec, intrinsics, dist_coeffs, reprojection); + for (int i = 0; i < 3; i++) + pose[i] = tvec.at(i); - error = 0; - for (int i = 0; i < 4; i++) - { - double x = reprojection[i].x - m[i].x; - double y = reprojection[i].y - m[i].y; - error += std::sqrt(x * x + y * y); + pose[Yaw] = foo[1]; + pose[Pitch] = -foo[0]; + pose[Roll] = foo[2]; } std::vector repr2; @@ -343,10 +355,14 @@ start: cv::projectPoints(centroid, rvec, tvec, intrinsics, dist_coeffs, repr2); last_centroid = repr2[0]; - - //pose[Yaw] -= atan(pose[TX] / pose[TZ]) * 180 / HT_PI; - //pose[Pitch] -= atan(pose[TY] / pose[TZ]) * 180 / HT_PI; } + else + { + last_roi = cv::Rect(65535, 65535, 0, 0); + } + + if (frame.rows > 0) + videoWidget->update_image(frame.data, frame.cols, frame.rows); } } -- cgit v1.2.3 From 76aa43c9c4b9339fafae1b987da29d21d846a7e1 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 3 Nov 2013 16:31:17 +0100 Subject: really fix mac this time Signed-off-by: Stanislaw Halik --- compat/compat.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compat/compat.cpp b/compat/compat.cpp index 8ac872d1..bcdbd17f 100644 --- a/compat/compat.cpp +++ b/compat/compat.cpp @@ -59,7 +59,7 @@ PortableLockedShm::PortableLockedShm(const char *shmName, const char* /*mutexNam fprintf(stderr, "oh, bother, ftruncate: %s\n", strerror(errno)); //mem = (void*) -1; } - mem = mmap(NULL, mapSize, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_ANON, fd, (off_t)0); + mem = mmap(NULL, mapSize, PROT_READ|PROT_WRITE, MAP_SHARED, fd, (off_t)0); } PortableLockedShm::~PortableLockedShm() -- cgit v1.2.3 From cc9b496e2de68b983dbc5fde27a1379cc9602a35 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 3 Nov 2013 17:16:46 +0100 Subject: appease -Wreorder Signed-off-by: Stanislaw Halik --- ftnoir_tracker_aruco/ar_video_widget.h | 4 ++-- ftnoir_tracker_ht/ht_video_widget.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ftnoir_tracker_aruco/ar_video_widget.h b/ftnoir_tracker_aruco/ar_video_widget.h index d16cb017..e1c7cff8 100644 --- a/ftnoir_tracker_aruco/ar_video_widget.h +++ b/ftnoir_tracker_aruco/ar_video_widget.h @@ -8,7 +8,7 @@ #ifndef VIDEOWIDGET_H #define VIDEOWIDGET_H -#include +#include #include #include #include @@ -23,7 +23,7 @@ class ArucoVideoWidget : public QWidget Q_OBJECT public: - ArucoVideoWidget(QWidget *parent) : QWidget(parent), width(0), height(0), fb() { + ArucoVideoWidget(QWidget *parent) : QWidget(parent), fb(), width(0), height(0) { connect(&timer, SIGNAL(timeout()), this, SLOT(update_and_repaint())); timer.start(60); } diff --git a/ftnoir_tracker_ht/ht_video_widget.h b/ftnoir_tracker_ht/ht_video_widget.h index 33f21226..3fff395e 100644 --- a/ftnoir_tracker_ht/ht_video_widget.h +++ b/ftnoir_tracker_ht/ht_video_widget.h @@ -23,7 +23,7 @@ class HTVideoWidget : public QWidget Q_OBJECT public: - HTVideoWidget(QWidget *parent) : QWidget(parent), width(0), height(0), fb() { + HTVideoWidget(QWidget *parent) : QWidget(parent), fb(), width(0), height(0) { connect(&timer, SIGNAL(timeout()), this, SLOT(update_and_repaint())); timer.start(60); } -- cgit v1.2.3 From a36b0c4fb8cfd3d28710f0cb7534e8a0d86cc3cb Mon Sep 17 00:00:00 2001 From: Ryan Spicer Date: Sun, 3 Nov 2013 12:06:54 -0800 Subject: MSVC 11 expects __declspec(dllexport) before return type. --- opentrack-api/context.cpp | 6 +++--- opentrack-api/opentrack.h | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/opentrack-api/context.cpp b/opentrack-api/context.cpp index 5b218f93..04fa5ac2 100644 --- a/opentrack-api/context.cpp +++ b/opentrack-api/context.cpp @@ -93,17 +93,17 @@ opentrack_ctx::~opentrack_ctx() extern "C" { -const char** OPENTRACK_EXPORT opentrack_enum_trackers(opentrack ctx) +OPENTRACK_EXPORT const char** opentrack_enum_trackers(opentrack ctx) { return const_cast(ctx->list); } -opentrack OPENTRACK_EXPORT opentrack_make_ctx(int argc, char** argv, void* window_parent) +OPENTRACK_EXPORT opentrack opentrack_make_ctx(int argc, char** argv, void* window_parent) { return new opentrack_ctx(argc, argv, window_parent); } -void OPENTRACK_EXPORT opentrack_finalize_ctx(opentrack foo) +OPENTRACK_EXPORT void opentrack_finalize_ctx(opentrack foo) { delete foo; } diff --git a/opentrack-api/opentrack.h b/opentrack-api/opentrack.h index b0883d50..990b6aa4 100644 --- a/opentrack-api/opentrack.h +++ b/opentrack-api/opentrack.h @@ -38,20 +38,20 @@ enum opentrack_dof { }; #endif -opentrack OPENTRACK_EXPORT opentrack_make_ctx(int argc, char** argv, void* window_parent); -void OPENTRACK_EXPORT opentrack_finalize_ctx(opentrack self); +OPENTRACK_EXPORT opentrack opentrack_make_ctx(int argc, char** argv, void* window_parent); +OPENTRACK_EXPORT void opentrack_finalize_ctx(opentrack self); /* no need to free the return value; invalid to modify it */ -const char** OPENTRACK_EXPORT opentrack_enum_trackers(opentrack self); +OPENTRACK_EXPORT const char** opentrack_enum_trackers(opentrack self); /* * don't `opentrack_tracker_tick an unstarted tracker, it's invalid to do so * it's also invalid to start a finalized tracker */ -opentrack_tracker OPENTRACK_EXPORT opentrack_make_tracker(opentrack ctx, const char* name); -void OPENTRACK_EXPORT opentrack_tracker_start(opentrack self, opentrack_tracker tracker); -int OPENTRACK_EXPORT opentrack_tracker_tick(opentrack_tracker tracker, double* headpose); -void OPENTRACK_EXPORT opentrack_finalize_tracker(opentrack_tracker tracker); +OPENTRACK_EXPORT opentrack_tracker opentrack_make_tracker(opentrack ctx, const char* name); +OPENTRACK_EXPORT void opentrack_tracker_start(opentrack self, opentrack_tracker tracker); +OPENTRACK_EXPORT int opentrack_tracker_tick(opentrack_tracker tracker, double* headpose); +OPENTRACK_EXPORT void opentrack_finalize_tracker(opentrack_tracker tracker); #ifdef __cplusplus } #endif -- 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(-) 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(+) 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(-) 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 760a596a513474c6f26f64086dea9d378c9b6c54 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 3 Nov 2013 23:07:03 +0100 Subject: fix wrong qt signals --- ftnoir_tracker_ht/ftnoir_tracker_ht.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp index 77eede52..c34acadd 100644 --- a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp +++ b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp @@ -281,15 +281,15 @@ TrackerControls::TrackerControls() { ui.setupUi(this); setAttribute(Qt::WA_NativeWindow, true); - connect(ui.cameraName, SIGNAL(valueChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.cameraFPS, SIGNAL(valueChanged(int)), this, SLOT(settingChanged(int))); + connect(ui.cameraName, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged(int))); + connect(ui.cameraFPS, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged(int))); connect(ui.cameraFOV, SIGNAL(valueChanged(double)), this, SLOT(settingChanged(double))); - 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.rx, SIGNAL(clicked()), this, SLOT(settingChanged())); + connect(ui.ry, SIGNAL(clicked()), this, SLOT(settingChanged())); + connect(ui.rz, SIGNAL(clicked()), this, SLOT(settingChanged())); + connect(ui.tx, SIGNAL(clicked()), this, SLOT(settingChanged())); + connect(ui.ty, SIGNAL(clicked()), this, SLOT(settingChanged())); + connect(ui.tz, SIGNAL(clicked()), this, SLOT(settingChanged())); 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 5e022e6d9117bfcaa24dc0ffaafed78031bcd1a7 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 3 Nov 2013 23:07:20 +0100 Subject: fix crapple &()_ --- CMakeLists.txt | 40 ++++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 242d200d..17fb0145 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,6 +8,15 @@ if(GIT_FOUND) git_describe(OPENTRACK__COMMIT --tags --always) endif() +if(APPLE) + set(apple-frameworks "-stdlib=libc++ -framework Cocoa -framework CoreFoundation -lobjc -lz -framework Carbon") + set(CMAKE_SHARED_LINKER_FLAGS " ${apple-frameworks} ${CMAKE_SHARED_LINKER_FLAGS}") + set(CMAKE_STATIC_LINKER_FLAGS " ${apple-frameworks} ${CMAKE_STATIC_LINKER_FLAGS}") + set(CMAKE_EXE_LINKER_FLAGS " ${apple-frameworks} ${CMAKE_EXE_LINKER_FLAGS}") + set(CMAKE_MODULE_LINKER_FLAGS " ${apple-frameworks} ${CMAKE_MODULE_LINKER_FLAGS}") + set(CMAKE_CXX_FLAGS " -stdlib=libc++ -std=c++11 ${CMAKE_CXX_FLAGS}") +endif() + SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) SET(CMAKE_SKIP_INSTALL_RPATH FALSE) @@ -23,14 +32,6 @@ if(MSVC) add_definitions(-DNOMINMAX) endif() -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) add_definitions(-std=c++11) endif() @@ -533,17 +534,19 @@ if(WIN32) uuid) endif() -include_directories(${OpenCV_INCLUDE_DIRS}) -include_directories(${OpenCV_DIR}/include) -include_directories(${OpenCV_CONFIG_PATH}/include) - add_library(opentrack-tracker-pt SHARED ${opentrack-tracker-pt-c} ${opentrack-tracker-pt-h} ${opentrack-tracker-pt-moc} ${opentrack-tracker-pt-uih} ${opentrack-tracker-pt-rcc}) target_link_libraries(opentrack-tracker-pt ${MY_QT_LIBS} ${OpenCV_LIBS}) + +if(APPLE) + SET_TARGET_PROPERTIES(opentrack-tracker-pt PROPERTIES COMPILE_FLAGS "-std=c++11") +endif() + if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) -SET_TARGET_PROPERTIES(opentrack-tracker-pt - PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt") + SET_TARGET_PROPERTIES(opentrack-tracker-pt + PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt") endif() + if(WIN32) target_link_libraries(opentrack-tracker-pt "${CMAKE_SOURCE_DIR}/dinput/dxguid.lib" @@ -664,6 +667,7 @@ if(UNIX) target_link_libraries(opentrack opentrack-qxt-mini) endif() target_link_libraries(opentrack ${OpenCV_LIBS}) +include_directories(${OpenCV_INCLUDE_DIRS}) if(UNIX) install(TARGETS opentrack-qxt-mini DESTINATION .) @@ -830,11 +834,3 @@ if(MSVC) file(GLOB pdbs2 "${CMAKE_BINARY_DIR}/*.pdb") install(FILES ${pdbs1} ${pdbs2} DESTINATION .) endif() - -if(APPLE) - set(apple-frameworks "-stdlib=libc++ -framework Cocoa -framework CoreFoundation -lobjc -lz -framework Carbon") - set(CMAKE_SHARED_LINKER_FLAGS " ${apple-frameworks} ${CMAKE_SHARED_LINKER_FLAGS}") - set(CMAKE_STATIC_LINKER_FLAGS " ${apple-frameworks} ${CMAKE_STATIC_LINKER_FLAGS}") - set(CMAKE_EXE_LINKER_FLAGS " ${apple-frameworks} ${CMAKE_EXE_LINKER_FLAGS}") - set(CMAKE_MODULE_LINKER_FLAGS " ${apple-frameworks} ${CMAKE_MODULE_LINKER_FLAGS}") -endif() -- cgit v1.2.3 From ef0d7dcf585a7a6b807d2a287dfbdc59657a30cc Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 5 Nov 2013 08:59:40 +0100 Subject: fix potential crash Signed-off-by: Stanislaw Halik --- qfunctionconfigurator/qfunctionconfigurator.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/qfunctionconfigurator/qfunctionconfigurator.cpp b/qfunctionconfigurator/qfunctionconfigurator.cpp index afd6561b..a80e3b6b 100644 --- a/qfunctionconfigurator/qfunctionconfigurator.cpp +++ b/qfunctionconfigurator/qfunctionconfigurator.cpp @@ -337,6 +337,8 @@ void QFunctionConfigurator::drawLine(QPainter *painter, const QPointF &start, co // void QFunctionConfigurator::mousePressEvent(QMouseEvent *e) { + if (!_config) + return; QList points = _config->getPoints(); // @@ -409,6 +411,8 @@ void QFunctionConfigurator::mousePressEvent(QMouseEvent *e) // void QFunctionConfigurator::mouseMoveEvent(QMouseEvent *e) { + if (!_config) + return; QList points = _config->getPoints(); const int refresh_delay = 50; @@ -452,6 +456,8 @@ void QFunctionConfigurator::mouseMoveEvent(QMouseEvent *e) void QFunctionConfigurator::mouseReleaseEvent(QMouseEvent *e) { + if (!_config) + return; QList points = _config->getPoints(); if (e->button() == Qt::LeftButton) { -- 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(-) 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(-) 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(-) 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(+) 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 4630c59e40361ccb500d1384c1c611648462f93c Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 5 Nov 2013 18:19:05 +0100 Subject: fix mingw-w64 build --- compat/compat.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/compat/compat.h b/compat/compat.h index 60395830..8c307b14 100644 --- a/compat/compat.h +++ b/compat/compat.h @@ -7,8 +7,7 @@ #pragma once #if defined(_WIN32) -#include -#include +#include #else #include #include -- cgit v1.2.3 From a22928d2ab49770ee778125ae4d4cf9c60cc81da Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 5 Nov 2013 18:23:59 +0100 Subject: bah, stupido --- ftnoir_tracker_ht/ftnoir_tracker_ht.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp index c34acadd..ab726aa1 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(); -#elsif !defined(__APPLE__) +#elif !defined(__APPLE__) for (int i = 0; i < 16; i++) { char buf[128]; sprintf(buf, "/dev/video%d", i); -- cgit v1.2.3 From 167e1517c64974ca0a7de6ea07de53df57e2b4b7 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 7 Nov 2013 17:20:44 +0100 Subject: (hopefully) fix pitch issues on Mac Signed-off-by: Stanislaw Halik --- FTNoIR_Tracker_PT/pt_video_widget.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/FTNoIR_Tracker_PT/pt_video_widget.cpp b/FTNoIR_Tracker_PT/pt_video_widget.cpp index 35a2c42b..122ab4fd 100644 --- a/FTNoIR_Tracker_PT/pt_video_widget.cpp +++ b/FTNoIR_Tracker_PT/pt_video_widget.cpp @@ -50,10 +50,11 @@ void PTVideoWidget::update_and_repaint() 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]; + const auto& elt = _frame.at(y, x); + const CvScalar elt2 = elt; + data[y * pitch + x * 3 + 0] = elt2.val[2]; + data[y * pitch + x * 3 + 1] = elt2.val[1]; + data[y * pitch + x * 3 + 2] = elt2.val[0]; } qframe = qframe.scaled(size(), Qt::IgnoreAspectRatio, Qt::FastTransformation); pixmap = QPixmap::fromImage(qframe); -- cgit v1.2.3 From ee82f14d1f2bbdc8fd7c0898e0c47494e4e7362d Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 7 Nov 2013 17:21:27 +0100 Subject: fix flicker, hopefully fix pitch Signed-off-by: Stanislaw Halik --- ftnoir_tracker_aruco/ar_video_widget.cpp | 24 +++++++++++------------- ftnoir_tracker_aruco/ar_video_widget.h | 8 ++++---- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 6 +++--- 3 files changed, 18 insertions(+), 20 deletions(-) diff --git a/ftnoir_tracker_aruco/ar_video_widget.cpp b/ftnoir_tracker_aruco/ar_video_widget.cpp index b727679b..149a19ee 100644 --- a/ftnoir_tracker_aruco/ar_video_widget.cpp +++ b/ftnoir_tracker_aruco/ar_video_widget.cpp @@ -11,31 +11,29 @@ using namespace std; -void ArucoVideoWidget::update_image(unsigned char *frame, int width, int height) +void ArucoVideoWidget::update_image(const cv::Mat& frame) { QMutexLocker foo(&mtx); - memcpy(fb, frame, width * height * 3); - this->width = width; - this->height = height; + _frame = frame; } void ArucoVideoWidget::update_and_repaint() { QMutexLocker foo(&mtx); - if (width*height <= 0) + if (_frame.cols*_frame.rows <= 0) return; - QImage qframe = QImage(width, height, QImage::Format_RGB888); + QImage qframe = QImage(_frame.cols, _frame.rows, QImage::Format_RGB888); uchar* data = qframe.bits(); const int pitch = qframe.bytesPerLine(); - for (int y = 0; y < height; y++) + for (int y = 0; y < _frame.rows; y++) { - const int part = y*width; - for (int x = 0; x < width; x++) + for (int x = 0; x < _frame.cols; x++) { - const int pos = 3 * (part + x); - data[y * pitch + x * 3 + 0] = fb[pos + 2]; - data[y * pitch + x * 3 + 1] = fb[pos + 1]; - data[y * pitch + x * 3 + 2] = fb[pos + 0]; + const auto& elt = _frame.at(y, x); + const CvScalar elt2 = elt; + data[y * pitch + x * 3 + 0] = elt2.val[2]; + data[y * pitch + x * 3 + 1] = elt2.val[1]; + data[y * pitch + x * 3 + 2] = elt2.val[0]; } } auto qframe2 = qframe.scaled(size(), Qt::IgnoreAspectRatio, Qt::FastTransformation); diff --git a/ftnoir_tracker_aruco/ar_video_widget.h b/ftnoir_tracker_aruco/ar_video_widget.h index e1c7cff8..b95d1873 100644 --- a/ftnoir_tracker_aruco/ar_video_widget.h +++ b/ftnoir_tracker_aruco/ar_video_widget.h @@ -16,6 +16,7 @@ #include #include #include +#include // ---------------------------------------------------------------------------- class ArucoVideoWidget : public QWidget @@ -23,11 +24,11 @@ class ArucoVideoWidget : public QWidget Q_OBJECT public: - ArucoVideoWidget(QWidget *parent) : QWidget(parent), fb(), width(0), height(0) { + ArucoVideoWidget(QWidget *parent) : QWidget(parent) { connect(&timer, SIGNAL(timeout()), this, SLOT(update_and_repaint())); timer.start(60); } - void update_image(unsigned char* frame, int width, int height); + void update_image(const cv::Mat& frame); protected slots: void paintEvent( QPaintEvent* e ) { QMutexLocker foo(&mtx); @@ -40,8 +41,7 @@ private: QMutex mtx; QPixmap pixmap; QTimer timer; - char fb[2048*2048*3]; - int width,height; + cv::Mat _frame; }; #endif // VIDEOWIDGET_H diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index a918d020..e063be62 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -280,12 +280,12 @@ start: char buf[128]; + frame = color.clone(); + ::sprintf(buf, "Hz: %d", last_fps); cv::putText(frame, buf, cv::Point(10, 32), cv::FONT_HERSHEY_PLAIN, scale, cv::Scalar(0, 255, 0), scale); ::sprintf(buf, "Jiffies: %ld", (long) (10000 * (time - tm) / freq)); cv::putText(frame, buf, cv::Point(10, 54), cv::FONT_HERSHEY_PLAIN, scale, cv::Scalar(80, 255, 0), scale); - - frame = color; if (markers.size() == 1 && markers[0].size() == 4) { const aruco::Marker& m = markers.at(0); @@ -362,7 +362,7 @@ start: } if (frame.rows > 0) - videoWidget->update_image(frame.data, frame.cols, frame.rows); + videoWidget->update_image(frame); } } -- cgit v1.2.3 From 4b3064c63cd9fa112c3700d9e97d6571ff5ad044 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 7 Nov 2013 17:21:33 +0100 Subject: update ht-api.h Signed-off-by: Stanislaw Halik --- ftnoir_tracker_ht/ht-api.h | 35 ++--------------------------------- 1 file changed, 2 insertions(+), 33 deletions(-) diff --git a/ftnoir_tracker_ht/ht-api.h b/ftnoir_tracker_ht/ht-api.h index e6960206..66b87211 100644 --- a/ftnoir_tracker_ht/ht-api.h +++ b/ftnoir_tracker_ht/ht-api.h @@ -14,7 +14,7 @@ #if !defined(_WIN32) && !defined(_isnan) # define _isnan isnan #endif -#include +#include struct ht_context; typedef struct ht_context headtracker_t; @@ -47,39 +47,8 @@ typedef struct { bool filled; } ht_result_t; -typedef enum { - cfg_type_float = 0, - cfg_type_int = 1, - cfg_type_bool = 2, - cfg_type_double = 3 -} ht_cfg_type_t; - -typedef union -{ - double d; - float f; - int i; -} ht_cfg_value_t; - -typedef struct { - const char* name; - int offset; - ht_cfg_type_t type; - ht_cfg_value_t default_value; - ht_cfg_value_t min; - ht_cfg_value_t max; - const char* docstring; -} ht_reflection_t; - -typedef struct { - int rows, cols, channels; - unsigned char* data; -} ht_frame_t; - HT_API(headtracker_t*) ht_make_context(const ht_config_t* config, const char* filename); -HT_API(void) ht_load_config(FILE* stream, ht_config_t* cfg); HT_API(void) ht_free_context(headtracker_t* ctx); -HT_API(void) ht_get_bgr_frame(headtracker_t* ctx, ht_frame_t* ret); -HT_API(void) ht_make_config(ht_config_t* cfg); +HT_API(const cv::Mat) ht_get_bgr_frame(headtracker_t* ctx); HT_API(bool) ht_cycle(headtracker_t* ctx, ht_result_t* euler); HT_API(void) ht_reset(headtracker_t* ctx); -- cgit v1.2.3 From e72d2694f613344022b1e548e5d5564d11833173 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 7 Nov 2013 22:57:11 +0100 Subject: fix build error on ocv 2.4 branch --- FTNoIR_Tracker_PT/pt_video_widget.cpp | 2 +- ftnoir_tracker_aruco/ar_video_widget.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/FTNoIR_Tracker_PT/pt_video_widget.cpp b/FTNoIR_Tracker_PT/pt_video_widget.cpp index 122ab4fd..c73fa780 100644 --- a/FTNoIR_Tracker_PT/pt_video_widget.cpp +++ b/FTNoIR_Tracker_PT/pt_video_widget.cpp @@ -51,7 +51,7 @@ void PTVideoWidget::update_and_repaint() for (int x = 0; x < _frame.cols; x++) { const auto& elt = _frame.at(y, x); - const CvScalar elt2 = elt; + const cv::Scalar elt2 = elt; data[y * pitch + x * 3 + 0] = elt2.val[2]; data[y * pitch + x * 3 + 1] = elt2.val[1]; data[y * pitch + x * 3 + 2] = elt2.val[0]; diff --git a/ftnoir_tracker_aruco/ar_video_widget.cpp b/ftnoir_tracker_aruco/ar_video_widget.cpp index 149a19ee..b0d78fe2 100644 --- a/ftnoir_tracker_aruco/ar_video_widget.cpp +++ b/ftnoir_tracker_aruco/ar_video_widget.cpp @@ -30,7 +30,7 @@ void ArucoVideoWidget::update_and_repaint() for (int x = 0; x < _frame.cols; x++) { const auto& elt = _frame.at(y, x); - const CvScalar elt2 = elt; + const cv::Scalar elt2 = elt; data[y * pitch + x * 3 + 0] = elt2.val[2]; data[y * pitch + x * 3 + 1] = elt2.val[1]; data[y * pitch + x * 3 + 2] = elt2.val[0]; -- cgit v1.2.3 From 4ac10163398f1cd402c7f8461ff478aadab5fe8e Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 10 Nov 2013 16:05:50 +0100 Subject: aruco: explicitly release camera to aid macosx brain damage Signed-off-by: Stanislaw Halik --- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index e063be62..b1b58dec 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -364,6 +364,10 @@ start: if (frame.rows > 0) videoWidget->update_image(frame); } + + camera->release(); + camera.release(); + camera = nullptr; } bool Tracker::GiveHeadPoseData(double *data) -- cgit v1.2.3 From 095f910986d787b2732b093c862bc24502704198 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 10 Nov 2013 16:05:58 +0100 Subject: fix warning Signed-off-by: Stanislaw Halik --- ftnoir_protocol_sc/ftnoir_protocol_sc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp b/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp index 6b68047f..e5d427dd 100644 --- a/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp +++ b/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp @@ -145,7 +145,7 @@ class ActivationContext { public: ActivationContext(const int resid) { hactctx = INVALID_HANDLE_VALUE; - actctx_cookie = NULL; + actctx_cookie = 0; ACTCTXA actx = {0}; actx.cbSize = sizeof(ACTCTXA); actx.lpResourceName = MAKEINTRESOURCEA(resid); -- cgit v1.2.3 From 30658e31df61825c862dc4b5400f9124dd3b6c2b Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 10 Nov 2013 16:20:39 +0100 Subject: fix build Signed-off-by: Stanislaw Halik --- FTNoIR_Tracker_PT/pt_video_widget.cpp | 2 +- ftnoir_tracker_aruco/ar_video_widget.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/FTNoIR_Tracker_PT/pt_video_widget.cpp b/FTNoIR_Tracker_PT/pt_video_widget.cpp index c73fa780..d0fc8d42 100644 --- a/FTNoIR_Tracker_PT/pt_video_widget.cpp +++ b/FTNoIR_Tracker_PT/pt_video_widget.cpp @@ -51,7 +51,7 @@ void PTVideoWidget::update_and_repaint() for (int x = 0; x < _frame.cols; x++) { const auto& elt = _frame.at(y, x); - const cv::Scalar elt2 = elt; + const cv::Scalar elt2 = static_cast(elt); data[y * pitch + x * 3 + 0] = elt2.val[2]; data[y * pitch + x * 3 + 1] = elt2.val[1]; data[y * pitch + x * 3 + 2] = elt2.val[0]; diff --git a/ftnoir_tracker_aruco/ar_video_widget.cpp b/ftnoir_tracker_aruco/ar_video_widget.cpp index b0d78fe2..645ea3a9 100644 --- a/ftnoir_tracker_aruco/ar_video_widget.cpp +++ b/ftnoir_tracker_aruco/ar_video_widget.cpp @@ -30,7 +30,7 @@ void ArucoVideoWidget::update_and_repaint() for (int x = 0; x < _frame.cols; x++) { const auto& elt = _frame.at(y, x); - const cv::Scalar elt2 = elt; + const cv::Scalar elt2 = static_cast(elt); data[y * pitch + x * 3 + 0] = elt2.val[2]; data[y * pitch + x * 3 + 1] = elt2.val[1]; data[y * pitch + x * 3 + 2] = elt2.val[0]; -- 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(-) 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 5aa211aa60f9e83290ecba889548b73f3d01e287 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 10 Nov 2013 22:14:51 +0100 Subject: add credit for alterscape Signed-off-by: Stanislaw Halik --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 30f0dcbf..c5406ea9 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,7 @@ Don't be afraid to submit an issue/feature request if the need arises. - StanisÅ‚aw Halik - Chris Thompson (aka mm0zct) - Donovan Baarda +- Ryan Spicer (OSX tester, contributor) - Patrick Ruoff (merging) - Wim Vriend (historically) - Ron Hendriks (historically) -- cgit v1.2.3 From 340194f133dfd6988188234c3be14bf5ec53923e Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 10 Nov 2013 22:23:52 +0100 Subject: hopefully fix apple Signed-off-by: Stanislaw Halik --- CMakeLists.txt | 2 +- ftnoir_filter_base/ftnoir_filter_base_global.h | 6 +++++- ftnoir_protocol_base/ftnoir_protocol_base_global.h | 6 +++++- ftnoir_tracker_base/ftnoir_tracker_base_global.h | 6 +++++- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 17fb0145..1b0975ae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,7 @@ if(APPLE) set(CMAKE_STATIC_LINKER_FLAGS " ${apple-frameworks} ${CMAKE_STATIC_LINKER_FLAGS}") set(CMAKE_EXE_LINKER_FLAGS " ${apple-frameworks} ${CMAKE_EXE_LINKER_FLAGS}") set(CMAKE_MODULE_LINKER_FLAGS " ${apple-frameworks} ${CMAKE_MODULE_LINKER_FLAGS}") - set(CMAKE_CXX_FLAGS " -stdlib=libc++ -std=c++11 ${CMAKE_CXX_FLAGS}") + set(CMAKE_CXX_FLAGS " -stdlib=libc++ -std=c++11 ${CMAKE_CXX_FLAGS} -fvisibility=hidden") endif() SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) diff --git a/ftnoir_filter_base/ftnoir_filter_base_global.h b/ftnoir_filter_base/ftnoir_filter_base_global.h index ce112411..a1a13315 100644 --- a/ftnoir_filter_base/ftnoir_filter_base_global.h +++ b/ftnoir_filter_base/ftnoir_filter_base_global.h @@ -4,7 +4,11 @@ #include #ifndef OPENTRACK_MAIN -# define FTNOIR_FILTER_BASE_EXPORT Q_DECL_EXPORT +# if !defined(_MSC_VER) +# define FTNOIR_FILTER_BASE_EXPORT __attribute__ ((visibility ("default"))) +# else +# define FTNOIR_FILTER_BASE_EXPORT Q_DECL_EXPORT +#endif #else # define FTNOIR_FILTER_BASE_EXPORT Q_DECL_IMPORT #endif diff --git a/ftnoir_protocol_base/ftnoir_protocol_base_global.h b/ftnoir_protocol_base/ftnoir_protocol_base_global.h index bed874c4..06386c7f 100644 --- a/ftnoir_protocol_base/ftnoir_protocol_base_global.h +++ b/ftnoir_protocol_base/ftnoir_protocol_base_global.h @@ -4,7 +4,11 @@ #include #ifndef OPENTRACK_MAIN -# define FTNOIR_PROTOCOL_BASE_EXPORT Q_DECL_EXPORT +# if !defined(_MSC_VER) +# define FTNOIR_PROTOCOL_BASE_EXPORT __attribute__ ((visibility ("default"))) +# else +# define FTNOIR_PROTOCOL_BASE_EXPORT Q_DECL_EXPORT +#endif #else # define FTNOIR_PROTOCOL_BASE_EXPORT Q_DECL_IMPORT #endif diff --git a/ftnoir_tracker_base/ftnoir_tracker_base_global.h b/ftnoir_tracker_base/ftnoir_tracker_base_global.h index 30fb95e9..a529da78 100644 --- a/ftnoir_tracker_base/ftnoir_tracker_base_global.h +++ b/ftnoir_tracker_base/ftnoir_tracker_base_global.h @@ -4,7 +4,11 @@ #include #ifndef OPENTRACK_MAIN -# define FTNOIR_TRACKER_BASE_EXPORT Q_DECL_EXPORT +# if !defined(_MSC_VER) +# define FTNOIR_TRACKER_BASE_EXPORT __attribute__ ((visibility ("default"))) +# else +# define FTNOIR_TRACKER_BASE_EXPORT Q_DECL_EXPORT +#endif #else # define FTNOIR_TRACKER_BASE_EXPORT Q_DECL_IMPORT #endif -- cgit v1.2.3 From ffb0893dc2ccf937c8414f4df88426308c822324 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 10 Nov 2013 22:23:59 +0100 Subject: fix possible race Signed-off-by: Stanislaw Halik --- ftnoir_tracker_aruco/ar_video_widget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ftnoir_tracker_aruco/ar_video_widget.cpp b/ftnoir_tracker_aruco/ar_video_widget.cpp index 645ea3a9..c452a638 100644 --- a/ftnoir_tracker_aruco/ar_video_widget.cpp +++ b/ftnoir_tracker_aruco/ar_video_widget.cpp @@ -14,7 +14,7 @@ using namespace std; void ArucoVideoWidget::update_image(const cv::Mat& frame) { QMutexLocker foo(&mtx); - _frame = frame; + _frame = frame.clone(); } void ArucoVideoWidget::update_and_repaint() -- cgit v1.2.3 From 5ef8fc93c4aa76d10f70b3406262eb7177c7b106 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 10 Nov 2013 22:24:11 +0100 Subject: hopefully fix aruco Signed-off-by: Stanislaw Halik --- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index b1b58dec..ab27d7c6 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -144,6 +144,7 @@ Tracker::Tracker() Tracker::~Tracker() { + QMutexLocker foo(&mtx); stop = true; wait(); if (layout) @@ -364,10 +365,6 @@ start: if (frame.rows > 0) videoWidget->update_image(frame); } - - camera->release(); - camera.release(); - camera = nullptr; } bool Tracker::GiveHeadPoseData(double *data) -- cgit v1.2.3 From 1388eaa16c8717eb3cc5309bb49aee1c1ab860a1 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 10 Nov 2013 22:24:21 +0100 Subject: make qthread protected Signed-off-by: Stanislaw Halik --- ftnoir_tracker_aruco/ftnoir_tracker_aruco.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h index 61eec096..9b9ff19d 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h @@ -18,7 +18,7 @@ #include #include -class Tracker : public QThread, public ITracker +class Tracker : protected QThread, public ITracker { Q_OBJECT public: -- cgit v1.2.3 From 693e922e82914f6ea5e2184c5487af1e1b4881b8 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 10 Nov 2013 22:38:53 +0100 Subject: fix build Signed-off-by: Stanislaw Halik --- compat/compat.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compat/compat.h b/compat/compat.h index 8c307b14..0e488752 100644 --- a/compat/compat.h +++ b/compat/compat.h @@ -25,7 +25,7 @@ # elif defined(_WIN32) # define COMPAT_EXPORT __declspec(dllimport) # else -# define COMPAT_EXPORT +# define COMPAT_EXPORT __attribute__ ((visibility ("default"))) # endif #else # define COMPAT_EXPORT -- cgit v1.2.3 From 3dbd4228b5823b72dd095ceaeada878a2b9a5dac Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 10 Nov 2013 22:49:36 +0100 Subject: hopefully fix macosx aruco freeze now Signed-off-by: Stanislaw Halik --- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index ab27d7c6..a4c521d0 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -135,9 +135,9 @@ void Tracker::load_settings() Tracker::Tracker() { + layout = nullptr; stop = false; videoWidget = NULL; - layout = NULL; enableRX = enableRY = enableRZ = enableTX = enableTY = enableTZ = true; load_settings(); } @@ -147,10 +147,10 @@ Tracker::~Tracker() QMutexLocker foo(&mtx); stop = true; wait(); - if (layout) - delete layout; if (videoWidget) delete videoWidget; + if(layout) + delete layout; } void Tracker::StartTracker(QFrame* videoframe) @@ -165,11 +165,11 @@ void Tracker::StartTracker(QFrame* videoframe) delete videoframe->layout(); videoframe->setLayout(layout); videoWidget->show(); - this->layout = layout; load_settings(); start(); for (int i = 0; i < 6; i++) pose[i] = 0; + this->layout = layout; } #define HT_PI 3.1415926535 -- cgit v1.2.3 From 8373c6cd439e4cf393d03f603e8e914cc7dfabf6 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 17 Nov 2013 19:27:19 +0100 Subject: Try to fix mac keybindings --- qxt-mini/plat/qxtglobalshortcut_mac.cpp | 456 ++++++++++++++++---------------- qxt-mini/qxtglobalshortcut_p.h | 185 +++++++------ 2 files changed, 327 insertions(+), 314 deletions(-) diff --git a/qxt-mini/plat/qxtglobalshortcut_mac.cpp b/qxt-mini/plat/qxtglobalshortcut_mac.cpp index 58b9a904..be2e632d 100644 --- a/qxt-mini/plat/qxtglobalshortcut_mac.cpp +++ b/qxt-mini/plat/qxtglobalshortcut_mac.cpp @@ -1,4 +1,4 @@ -#include +#include /**************************************************************************** ** Copyright (c) 2006 - 2011, the LibQxt project. ** See the Qxt AUTHORS file for a list of authors and copyright holders. @@ -29,230 +29,230 @@ ** *****************************************************************************/ -#include "qxtglobalshortcut_p.h" -#include -#include -#include -#include - -typedef QPair Identifier; -static QMap keyRefs; -static QHash keyIDs; -static quint32 hotKeySerial = 0; -static bool qxt_mac_handler_installed = false; - -OSStatus qxt_mac_handle_hot_key(EventHandlerCallRef nextHandler, EventRef event, void* data) -{ - Q_UNUSED(nextHandler); - Q_UNUSED(data); - if (GetEventClass(event) == kEventClassKeyboard && GetEventKind(event) == kEventHotKeyPressed) - { - EventHotKeyID keyID; - GetEventParameter(event, kEventParamDirectObject, typeEventHotKeyID, NULL, sizeof(keyID), NULL, &keyID); - Identifier id = keyIDs.key(keyID.id); - QxtGlobalShortcutPrivate::activateShortcut(id.second, id.first); - } - return noErr; -} - -quint32 QxtGlobalShortcutPrivate::nativeModifiers(Qt::KeyboardModifiers modifiers) -{ - quint32 native = 0; - if (modifiers & Qt::ShiftModifier) - native |= shiftKey; - if (modifiers & Qt::ControlModifier) - native |= cmdKey; - if (modifiers & Qt::AltModifier) - native |= optionKey; - if (modifiers & Qt::MetaModifier) - native |= controlKey; - if (modifiers & Qt::KeypadModifier) - native |= kEventKeyModifierNumLockMask; - return native; -} - -quint32 QxtGlobalShortcutPrivate::nativeKeycode(Qt::Key key) -{ - UTF16Char ch; - // Constants found in NSEvent.h from AppKit.framework - switch (key) - { - case Qt::Key_Return: - return kVK_Return; - case Qt::Key_Enter: - return kVK_ANSI_KeypadEnter; - case Qt::Key_Tab: - return kVK_Tab; - case Qt::Key_Space: - return kVK_Space; - case Qt::Key_Backspace: - return kVK_Delete; - case Qt::Key_Control: - return kVK_Command; - case Qt::Key_Shift: - return kVK_Shift; - case Qt::Key_CapsLock: - return kVK_CapsLock; - case Qt::Key_Option: - return kVK_Option; - case Qt::Key_Meta: - return kVK_Control; - case Qt::Key_F17: - return kVK_F17; - case Qt::Key_VolumeUp: - return kVK_VolumeUp; - case Qt::Key_VolumeDown: - return kVK_VolumeDown; - case Qt::Key_F18: - return kVK_F18; - case Qt::Key_F19: - return kVK_F19; - case Qt::Key_F20: - return kVK_F20; - case Qt::Key_F5: - return kVK_F5; - case Qt::Key_F6: - return kVK_F6; - case Qt::Key_F7: - return kVK_F7; - case Qt::Key_F3: - return kVK_F3; - case Qt::Key_F8: - return kVK_F8; - case Qt::Key_F9: - return kVK_F9; - case Qt::Key_F11: - return kVK_F11; - case Qt::Key_F13: - return kVK_F13; - case Qt::Key_F16: - return kVK_F16; - case Qt::Key_F14: - return kVK_F14; - case Qt::Key_F10: - return kVK_F10; - case Qt::Key_F12: - return kVK_F12; - case Qt::Key_F15: - return kVK_F15; - case Qt::Key_Help: - return kVK_Help; - case Qt::Key_Home: - return kVK_Home; - case Qt::Key_PageUp: - return kVK_PageUp; - case Qt::Key_Delete: - return kVK_ForwardDelete; - case Qt::Key_F4: - return kVK_F4; - case Qt::Key_End: - return kVK_End; - case Qt::Key_F2: - return kVK_F2; - case Qt::Key_PageDown: - return kVK_PageDown; - case Qt::Key_F1: - return kVK_F1; - case Qt::Key_Left: - return kVK_LeftArrow; - case Qt::Key_Right: - return kVK_RightArrow; - case Qt::Key_Down: - return kVK_DownArrow; - case Qt::Key_Up: - return kVK_UpArrow; - default: - ; - } - - if (key == Qt::Key_Escape) ch = 27; - else if (key == Qt::Key_Return) ch = 13; - else if (key == Qt::Key_Enter) ch = 3; - else if (key == Qt::Key_Tab) ch = 9; - else ch = key; - - CFDataRef currentLayoutData; - TISInputSourceRef currentKeyboard = TISCopyCurrentKeyboardInputSource(); - - if (currentKeyboard == NULL) - return 0; - - currentLayoutData = (CFDataRef)TISGetInputSourceProperty(currentKeyboard, kTISPropertyUnicodeKeyLayoutData); - CFRelease(currentKeyboard); - if (currentLayoutData == NULL) - return 0; - - UCKeyboardLayout* header = (UCKeyboardLayout*)CFDataGetBytePtr(currentLayoutData); - UCKeyboardTypeHeader* table = header->keyboardTypeList; - - uint8_t *data = (uint8_t*)header; - // God, would a little documentation for this shit kill you... - for (quint32 i=0; i < header->keyboardTypeCount; i++) - { - UCKeyStateRecordsIndex* stateRec = 0; - if (table[i].keyStateRecordsIndexOffset != 0) - { - stateRec = reinterpret_cast(data + table[i].keyStateRecordsIndexOffset); - if (stateRec->keyStateRecordsIndexFormat != kUCKeyStateRecordsIndexFormat) stateRec = 0; - } - - UCKeyToCharTableIndex* charTable = reinterpret_cast(data + table[i].keyToCharTableIndexOffset); - if (charTable->keyToCharTableIndexFormat != kUCKeyToCharTableIndexFormat) continue; - - for (quint32 j=0; j < charTable->keyToCharTableCount; j++) - { - UCKeyOutput* keyToChar = reinterpret_cast(data + charTable->keyToCharTableOffsets[j]); - for (quint32 k=0; k < charTable->keyToCharTableSize; k++) - { - if (keyToChar[k] & kUCKeyOutputTestForIndexMask) - { - long idx = keyToChar[k] & kUCKeyOutputGetIndexMask; - if (stateRec && idx < stateRec->keyStateRecordCount) - { - UCKeyStateRecord* rec = reinterpret_cast(data + stateRec->keyStateRecordOffsets[idx]); - if (rec->stateZeroCharData == ch) return k; - } - } - else if (!(keyToChar[k] & kUCKeyOutputSequenceIndexMask) && keyToChar[k] < 0xFFFE) - { - if (keyToChar[k] == ch) return k; - } - } // for k - } // for j - } // for i - return 0; -} - -bool QxtGlobalShortcutPrivate::registerShortcut(quint32 nativeKey, quint32 nativeMods) -{ - if (!qxt_mac_handler_installed) - { - EventTypeSpec t; - t.eventClass = kEventClassKeyboard; - t.eventKind = kEventHotKeyPressed; - InstallApplicationEventHandler(&qxt_mac_handle_hot_key, 1, &t, NULL, NULL); - } - - EventHotKeyID keyID; - keyID.signature = 'cute'; - keyID.id = ++hotKeySerial; - - EventHotKeyRef ref = 0; - bool rv = !RegisterEventHotKey(nativeKey, nativeMods, keyID, GetApplicationEventTarget(), 0, &ref); - if (rv) - { - keyIDs.insert(Identifier(nativeMods, nativeKey), keyID.id); - keyRefs.insert(keyID.id, ref); - } - return rv; -} - -bool QxtGlobalShortcutPrivate::unregisterShortcut(quint32 nativeKey, quint32 nativeMods) -{ - Identifier id(nativeMods, nativeKey); - if (!keyIDs.contains(id)) return false; - - EventHotKeyRef ref = keyRefs.take(keyIDs[id]); - keyIDs.remove(id); - return !UnregisterEventHotKey(ref); -} +#include "qxtglobalshortcut_p.h" +#include +#include +#include +#include + +typedef QPair Identifier; +static QMap keyRefs; +static QHash keyIDs; +static quint32 hotKeySerial = 0; +static bool qxt_mac_handler_installed = false; + +OSStatus qxt_mac_handle_hot_key(EventHandlerCallRef nextHandler, EventRef event, void* data) +{ + Q_UNUSED(nextHandler); + Q_UNUSED(data); + if (GetEventClass(event) == kEventClassKeyboard && GetEventKind(event) == kEventHotKeyPressed) + { + EventHotKeyID keyID; + GetEventParameter(event, kEventParamDirectObject, typeEventHotKeyID, NULL, sizeof(keyID), NULL, &keyID); + Identifier id = keyIDs.key(keyID.id); + QxtGlobalShortcutPrivate::activateShortcut(id.second, id.first); + } + return noErr; +} + +quint32 QxtGlobalShortcutPrivate::nativeModifiers(Qt::KeyboardModifiers modifiers) +{ + quint32 native = 0; + if (modifiers & Qt::ShiftModifier) + native |= shiftKey; + if (modifiers & Qt::ControlModifier) + native |= cmdKey; + if (modifiers & Qt::AltModifier) + native |= optionKey; + if (modifiers & Qt::MetaModifier) + native |= controlKey; + if (modifiers & Qt::KeypadModifier) + native |= kEventKeyModifierNumLockMask; + return native; +} + +quint32 QxtGlobalShortcutPrivate::nativeKeycode(Qt::Key key) +{ + UTF16Char ch; + // Constants found in NSEvent.h from AppKit.framework + switch (key) + { + case Qt::Key_Return: + return kVK_Return; + case Qt::Key_Enter: + return kVK_ANSI_KeypadEnter; + case Qt::Key_Tab: + return kVK_Tab; + case Qt::Key_Space: + return kVK_Space; + case Qt::Key_Backspace: + return kVK_Delete; + case Qt::Key_Control: + return kVK_Command; + case Qt::Key_Shift: + return kVK_Shift; + case Qt::Key_CapsLock: + return kVK_CapsLock; + case Qt::Key_Option: + return kVK_Option; + case Qt::Key_Meta: + return kVK_Control; + case Qt::Key_F17: + return kVK_F17; + case Qt::Key_VolumeUp: + return kVK_VolumeUp; + case Qt::Key_VolumeDown: + return kVK_VolumeDown; + case Qt::Key_F18: + return kVK_F18; + case Qt::Key_F19: + return kVK_F19; + case Qt::Key_F20: + return kVK_F20; + case Qt::Key_F5: + return kVK_F5; + case Qt::Key_F6: + return kVK_F6; + case Qt::Key_F7: + return kVK_F7; + case Qt::Key_F3: + return kVK_F3; + case Qt::Key_F8: + return kVK_F8; + case Qt::Key_F9: + return kVK_F9; + case Qt::Key_F11: + return kVK_F11; + case Qt::Key_F13: + return kVK_F13; + case Qt::Key_F16: + return kVK_F16; + case Qt::Key_F14: + return kVK_F14; + case Qt::Key_F10: + return kVK_F10; + case Qt::Key_F12: + return kVK_F12; + case Qt::Key_F15: + return kVK_F15; + case Qt::Key_Help: + return kVK_Help; + case Qt::Key_Home: + return kVK_Home; + case Qt::Key_PageUp: + return kVK_PageUp; + case Qt::Key_Delete: + return kVK_ForwardDelete; + case Qt::Key_F4: + return kVK_F4; + case Qt::Key_End: + return kVK_End; + case Qt::Key_F2: + return kVK_F2; + case Qt::Key_PageDown: + return kVK_PageDown; + case Qt::Key_F1: + return kVK_F1; + case Qt::Key_Left: + return kVK_LeftArrow; + case Qt::Key_Right: + return kVK_RightArrow; + case Qt::Key_Down: + return kVK_DownArrow; + case Qt::Key_Up: + return kVK_UpArrow; + default: + ; + } + + if (key == Qt::Key_Escape) ch = 27; + else if (key == Qt::Key_Return) ch = 13; + else if (key == Qt::Key_Enter) ch = 3; + else if (key == Qt::Key_Tab) ch = 9; + else ch = key; + + CFDataRef currentLayoutData; + TISInputSourceRef currentKeyboard = TISCopyCurrentKeyboardInputSource(); + + if (currentKeyboard == NULL) + return 0; + + currentLayoutData = (CFDataRef)TISGetInputSourceProperty(currentKeyboard, kTISPropertyUnicodeKeyLayoutData); + CFRelease(currentKeyboard); + if (currentLayoutData == NULL) + return 0; + + UCKeyboardLayout* header = (UCKeyboardLayout*)CFDataGetBytePtr(currentLayoutData); + UCKeyboardTypeHeader* table = header->keyboardTypeList; + + uint8_t *data = (uint8_t*)header; + // God, would a little documentation for this shit kill you... + for (quint32 i=0; i < header->keyboardTypeCount; i++) + { + UCKeyStateRecordsIndex* stateRec = 0; + if (table[i].keyStateRecordsIndexOffset != 0) + { + stateRec = reinterpret_cast(data + table[i].keyStateRecordsIndexOffset); + if (stateRec->keyStateRecordsIndexFormat != kUCKeyStateRecordsIndexFormat) stateRec = 0; + } + + UCKeyToCharTableIndex* charTable = reinterpret_cast(data + table[i].keyToCharTableIndexOffset); + if (charTable->keyToCharTableIndexFormat != kUCKeyToCharTableIndexFormat) continue; + + for (quint32 j=0; j < charTable->keyToCharTableCount; j++) + { + UCKeyOutput* keyToChar = reinterpret_cast(data + charTable->keyToCharTableOffsets[j]); + for (quint32 k=0; k < charTable->keyToCharTableSize; k++) + { + if (keyToChar[k] & kUCKeyOutputTestForIndexMask) + { + long idx = keyToChar[k] & kUCKeyOutputGetIndexMask; + if (stateRec && idx < stateRec->keyStateRecordCount) + { + UCKeyStateRecord* rec = reinterpret_cast(data + stateRec->keyStateRecordOffsets[idx]); + if (rec->stateZeroCharData == ch) return k; + } + } + else if (!(keyToChar[k] & kUCKeyOutputSequenceIndexMask) && keyToChar[k] < 0xFFFE) + { + if (keyToChar[k] == ch) return k; + } + } // for k + } // for j + } // for i + return 0; +} + +bool QxtGlobalShortcutPrivate::registerShortcut(quint32 nativeKey, quint32 nativeMods) +{ + if (!qxt_mac_handler_installed) + { + EventTypeSpec t; + t.eventClass = kEventClassKeyboard; + t.eventKind = kEventHotKeyPressed; + InstallApplicationEventHandler(&qxt_mac_handle_hot_key, 1, &t, NULL, NULL); + } + + EventHotKeyID keyID; + keyID.signature = 'cute'; + keyID.id = ++hotKeySerial; + + EventHotKeyRef ref = 0; + bool rv = !RegisterEventHotKey(nativeKey, nativeMods, keyID, GetApplicationEventTarget(), 0, &ref); + if (rv) + { + keyIDs.insert(Identifier(nativeMods, nativeKey), keyID.id); + keyRefs.insert(keyID.id, ref); + } + return rv; +} + +bool QxtGlobalShortcutPrivate::unregisterShortcut(quint32 nativeKey, quint32 nativeMods) +{ + Identifier id(nativeMods, nativeKey); + if (!keyIDs.contains(id)) return false; + + EventHotKeyRef ref = keyRefs.take(keyIDs[id]); + keyIDs.remove(id); + return !UnregisterEventHotKey(ref); +} diff --git a/qxt-mini/qxtglobalshortcut_p.h b/qxt-mini/qxtglobalshortcut_p.h index 0d88b354..e3f3ddd3 100644 --- a/qxt-mini/qxtglobalshortcut_p.h +++ b/qxt-mini/qxtglobalshortcut_p.h @@ -1,86 +1,99 @@ -#ifndef QXTGLOBALSHORTCUT_P_H -/**************************************************************************** -** Copyright (c) 2006 - 2011, the LibQxt project. -** See the Qxt AUTHORS file for a list of authors and copyright holders. -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** * Neither the name of the LibQxt project nor the -** names of its contributors may be used to endorse or promote products -** derived from this software without specific prior written permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -** DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY -** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -** -** -*****************************************************************************/ - -#define QXTGLOBALSHORTCUT_P_H - -#include "qxtglobalshortcut.h" -#include -#include -#include - -#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) -#include -#endif - - -class QxtGlobalShortcutPrivate : public QxtPrivate -#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) - ,public QAbstractNativeEventFilter -#endif -{ -public: - QXT_DECLARE_PUBLIC(QxtGlobalShortcut) - QxtGlobalShortcutPrivate(); - ~QxtGlobalShortcutPrivate(); - - bool enabled; - Qt::Key key; - Qt::KeyboardModifiers mods; - - bool setShortcut(const QKeySequence& shortcut); - bool unsetShortcut(); - - static bool error; -#ifndef Q_OS_DARWIN - static int ref; -# if QT_VERSION < QT_VERSION_CHECK(5,0,0) - static QAbstractEventDispatcher::EventFilter prevEventFilter; - static bool eventFilter(void* message); -# else - virtual bool nativeEventFilter(const QByteArray & eventType, void * message, long * result); -# 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); - -private: - static quint32 nativeKeycode(Qt::Key keycode); - static quint32 nativeModifiers(Qt::KeyboardModifiers modifiers); - - static bool registerShortcut(quint32 nativeKey, quint32 nativeMods); - static bool unregisterShortcut(quint32 nativeKey, quint32 nativeMods); - - static QHash, QxtGlobalShortcut*> shortcuts; -}; - -#endif // QXTGLOBALSHORTCUT_P_H +#ifndef QXTGLOBALSHORTCUT_P_H +/**************************************************************************** +** Copyright (c) 2006 - 2011, the LibQxt project. +** See the Qxt AUTHORS file for a list of authors and copyright holders. +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** * Neither the name of the LibQxt project nor the +** names of its contributors may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +** DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +** +*****************************************************************************/ + +#define QXTGLOBALSHORTCUT_P_H + +#include "qxtglobalshortcut.h" +#include +#include +#include + +#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) +#include +#endif + +#ifdef Q_OS_DARWIN +# include +#endif + +class QxtGlobalShortcutPrivate : public QxtPrivate +#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) + ,public QAbstractNativeEventFilter +#endif +{ +public: + QXT_DECLARE_PUBLIC(QxtGlobalShortcut) + QxtGlobalShortcutPrivate(); + ~QxtGlobalShortcutPrivate(); + + bool enabled; + Qt::Key key; + Qt::KeyboardModifiers mods; + + bool setShortcut(const QKeySequence& shortcut); + bool unsetShortcut(); + + static bool error; +#ifndef Q_OS_DARWIN + static int ref; +# if QT_VERSION < QT_VERSION_CHECK(5,0,0) + static QAbstractEventDispatcher::EventFilter prevEventFilter; + static bool eventFilter(void* message); +# else + virtual bool nativeEventFilter(const QByteArray & eventType, void * message, long * result); +# endif // QT_VERSION < QT_VERSION_CHECK(5,0,0) +# else + virtual bool nativeEventFilter(const QByteArray & eventType, void * message, long * result) { + EventRef Event = reinterpret_cast(message); + UInt32 EventClass = GetEventClass (Event); + UInt32 EventKind = GetEventKind (Event); + if (kEventClassKeyboard && EventKind == kEventRawKeyDown) + { + UInt32 keyPressed; + GetEventParameter(Event, kEventParamKeyCode, typeUInt32, NULL, sizeof(UInt32), NULL, &keyPressed); + return keyPressed == nativeKeycode(key); + } + } +#endif // Q_WS_MAC + + static void activateShortcut(quint32 nativeKey, quint32 nativeMods); + +private: + static quint32 nativeKeycode(Qt::Key keycode); + static quint32 nativeModifiers(Qt::KeyboardModifiers modifiers); + + static bool registerShortcut(quint32 nativeKey, quint32 nativeMods); + static bool unregisterShortcut(quint32 nativeKey, quint32 nativeMods); + + static QHash, QxtGlobalShortcut*> shortcuts; +}; + +#endif // QXTGLOBALSHORTCUT_P_H -- cgit v1.2.3 From 8a3e9c35142c115188b03aa4d73117a8f12e3175 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 17 Nov 2013 19:32:07 +0100 Subject: Try to implement darwin modifier keys --- qxt-mini/qxtglobalshortcut_p.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/qxt-mini/qxtglobalshortcut_p.h b/qxt-mini/qxtglobalshortcut_p.h index e3f3ddd3..5b10d089 100644 --- a/qxt-mini/qxtglobalshortcut_p.h +++ b/qxt-mini/qxtglobalshortcut_p.h @@ -75,11 +75,19 @@ public: EventRef Event = reinterpret_cast(message); UInt32 EventClass = GetEventClass (Event); UInt32 EventKind = GetEventKind (Event); + UInt32 eventModifiers = 0; + GetEventParameter(Event, + kEventParamKeyModifiers, + typeUInt32, + NULL, + sizeof(UInt32), + NULL, + &eventModifiers); if (kEventClassKeyboard && EventKind == kEventRawKeyDown) { - UInt32 keyPressed; + UInt32 keyPressed = -1; GetEventParameter(Event, kEventParamKeyCode, typeUInt32, NULL, sizeof(UInt32), NULL, &keyPressed); - return keyPressed == nativeKeycode(key); + return keyPressed == nativeKeycode(key) && nativeModifiers(mods) == eventModifiers; } } #endif // Q_WS_MAC -- cgit v1.2.3 From 8c762f5143efe2cc3437ae5b3d8d5159c6593957 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 22 Nov 2013 02:55:16 +0100 Subject: hopefully fix aruco crash on exit Signed-off-by: Stanislaw Halik --- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index a4c521d0..2fdd1014 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -178,14 +178,14 @@ void Tracker::run() { start: reset = false; - std::unique_ptr camera(new cv::VideoCapture(camera_index)); + cv::VideoCapture camera(camera_index); if (force_width) - camera->set(CV_CAP_PROP_FRAME_WIDTH, force_width); + camera.set(CV_CAP_PROP_FRAME_WIDTH, force_width); if (force_height) - camera->set(CV_CAP_PROP_FRAME_HEIGHT, force_height); + camera.set(CV_CAP_PROP_FRAME_HEIGHT, force_height); if (force_fps) - camera->set(CV_CAP_PROP_FPS, force_fps); + camera.set(CV_CAP_PROP_FPS, force_fps); aruco::MarkerDetector detector; detector.setDesiredSpeed(3); @@ -197,14 +197,14 @@ start: const double stateful_coeff = 0.81; - if (!camera->isOpened()) + if (!camera.isOpened()) { fprintf(stderr, "aruco tracker: can't open camera\n"); return; } while (!stop) - if(camera->read(color_)) + if(camera.read(color_)) break; auto freq = cv::getTickFrequency(); @@ -216,10 +216,9 @@ start: { if (reset) { - camera.reset(nullptr); goto start; } - if (!camera->read(color_)) + if (!camera.read(color_)) continue; auto tm = cv::getTickCount(); color_.copyTo(color); -- 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(-) 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(-) 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 104f23670b7c3c5a1091a45d513b32bf72040a19 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 22 Nov 2013 15:23:06 +0100 Subject: revert qxt changes --- qxt-mini/plat/qxtglobalshortcut_mac.cpp | 459 ++++++++++++++++---------------- qxt-mini/qxtglobalshortcut.cpp | 1 + qxt-mini/qxtglobalshortcut_p.h | 28 +- 3 files changed, 235 insertions(+), 253 deletions(-) diff --git a/qxt-mini/plat/qxtglobalshortcut_mac.cpp b/qxt-mini/plat/qxtglobalshortcut_mac.cpp index be2e632d..f43c773a 100644 --- a/qxt-mini/plat/qxtglobalshortcut_mac.cpp +++ b/qxt-mini/plat/qxtglobalshortcut_mac.cpp @@ -1,4 +1,4 @@ -#include +#include /**************************************************************************** ** Copyright (c) 2006 - 2011, the LibQxt project. ** See the Qxt AUTHORS file for a list of authors and copyright holders. @@ -29,230 +29,237 @@ ** *****************************************************************************/ -#include "qxtglobalshortcut_p.h" -#include -#include -#include -#include - -typedef QPair Identifier; -static QMap keyRefs; -static QHash keyIDs; -static quint32 hotKeySerial = 0; -static bool qxt_mac_handler_installed = false; - -OSStatus qxt_mac_handle_hot_key(EventHandlerCallRef nextHandler, EventRef event, void* data) +#include "qxtglobalshortcut_p.h" +#include +#include +#include +#include + +typedef QPair Identifier; +static QMap keyRefs; +static QHash keyIDs; +static quint32 hotKeySerial = 0; +static bool qxt_mac_handler_installed = false; + +OSStatus qxt_mac_handle_hot_key(EventHandlerCallRef nextHandler, EventRef event, void* data) +{ + Q_UNUSED(nextHandler); + Q_UNUSED(data); + if (GetEventClass(event) == kEventClassKeyboard && GetEventKind(event) == kEventHotKeyPressed) + { + EventHotKeyID keyID; + GetEventParameter(event, kEventParamDirectObject, typeEventHotKeyID, NULL, sizeof(keyID), NULL, &keyID); + Identifier id = keyIDs.key(keyID.id); + if(id != Identifier()) + QxtGlobalShortcutPrivate::activateShortcut(id.second, id.first); + } + return noErr; +} + +quint32 QxtGlobalShortcutPrivate::nativeModifiers(Qt::KeyboardModifiers modifiers) +{ + quint32 native = 0; + if (modifiers & Qt::ShiftModifier) + native |= shiftKey; + if (modifiers & Qt::ControlModifier) + native |= cmdKey; + if (modifiers & Qt::AltModifier) + native |= optionKey; + if (modifiers & Qt::MetaModifier) + native |= controlKey; + if (modifiers & Qt::KeypadModifier) + native |= kEventKeyModifierNumLockMask; + return native; +} + +quint32 QxtGlobalShortcutPrivate::nativeKeycode(Qt::Key key) +{ + UTF16Char ch; + // Constants found in NSEvent.h from AppKit.framework + switch (key) + { + case Qt::Key_Return: + return kVK_Return; + case Qt::Key_Enter: + return kVK_ANSI_KeypadEnter; + case Qt::Key_Tab: + return kVK_Tab; + case Qt::Key_Space: + return kVK_Space; + case Qt::Key_Backspace: + return kVK_Delete; + case Qt::Key_Control: + return kVK_Command; + case Qt::Key_Shift: + return kVK_Shift; + case Qt::Key_CapsLock: + return kVK_CapsLock; + case Qt::Key_Option: + return kVK_Option; + case Qt::Key_Meta: + return kVK_Control; + case Qt::Key_F17: + return kVK_F17; + case Qt::Key_VolumeUp: + return kVK_VolumeUp; + case Qt::Key_VolumeDown: + return kVK_VolumeDown; + case Qt::Key_F18: + return kVK_F18; + case Qt::Key_F19: + return kVK_F19; + case Qt::Key_F20: + return kVK_F20; + case Qt::Key_F5: + return kVK_F5; + case Qt::Key_F6: + return kVK_F6; + case Qt::Key_F7: + return kVK_F7; + case Qt::Key_F3: + return kVK_F3; + case Qt::Key_F8: + return kVK_F8; + case Qt::Key_F9: + return kVK_F9; + case Qt::Key_F11: + return kVK_F11; + case Qt::Key_F13: + return kVK_F13; + case Qt::Key_F16: + return kVK_F16; + case Qt::Key_F14: + return kVK_F14; + case Qt::Key_F10: + return kVK_F10; + case Qt::Key_F12: + return kVK_F12; + case Qt::Key_F15: + return kVK_F15; + case Qt::Key_Help: + return kVK_Help; + case Qt::Key_Home: + return kVK_Home; + case Qt::Key_PageUp: + return kVK_PageUp; + case Qt::Key_Delete: + return kVK_ForwardDelete; + case Qt::Key_F4: + return kVK_F4; + case Qt::Key_End: + return kVK_End; + case Qt::Key_F2: + return kVK_F2; + case Qt::Key_PageDown: + return kVK_PageDown; + case Qt::Key_F1: + return kVK_F1; + case Qt::Key_Left: + return kVK_LeftArrow; + case Qt::Key_Right: + return kVK_RightArrow; + case Qt::Key_Down: + return kVK_DownArrow; + case Qt::Key_Up: + return kVK_UpArrow; + default: + ; + } + + if (key == Qt::Key_Escape) ch = 27; + else if (key == Qt::Key_Return) ch = 13; + else if (key == Qt::Key_Enter) ch = 3; + else if (key == Qt::Key_Tab) ch = 9; + else ch = key; + + CFDataRef currentLayoutData; + TISInputSourceRef currentKeyboard = TISCopyCurrentKeyboardInputSource(); + + if (currentKeyboard == NULL) + return 0; + + currentLayoutData = (CFDataRef)TISGetInputSourceProperty(currentKeyboard, kTISPropertyUnicodeKeyLayoutData); + CFRelease(currentKeyboard); + if (currentLayoutData == NULL) + return 0; + + UCKeyboardLayout* header = (UCKeyboardLayout*)CFDataGetBytePtr(currentLayoutData); + UCKeyboardTypeHeader* table = header->keyboardTypeList; + + uint8_t *data = (uint8_t*)header; + // God, would a little documentation for this shit kill you... + for (quint32 i=0; i < header->keyboardTypeCount; i++) + { + UCKeyStateRecordsIndex* stateRec = 0; + if (table[i].keyStateRecordsIndexOffset != 0) + { + stateRec = reinterpret_cast(data + table[i].keyStateRecordsIndexOffset); + if (stateRec->keyStateRecordsIndexFormat != kUCKeyStateRecordsIndexFormat) stateRec = 0; + } + + UCKeyToCharTableIndex* charTable = reinterpret_cast(data + table[i].keyToCharTableIndexOffset); + if (charTable->keyToCharTableIndexFormat != kUCKeyToCharTableIndexFormat) continue; + + for (quint32 j=0; j < charTable->keyToCharTableCount; j++) + { + UCKeyOutput* keyToChar = reinterpret_cast(data + charTable->keyToCharTableOffsets[j]); + for (quint32 k=0; k < charTable->keyToCharTableSize; k++) + { + if (keyToChar[k] & kUCKeyOutputTestForIndexMask) + { + long idx = keyToChar[k] & kUCKeyOutputGetIndexMask; + if (stateRec && idx < stateRec->keyStateRecordCount) + { + UCKeyStateRecord* rec = reinterpret_cast(data + stateRec->keyStateRecordOffsets[idx]); + if (rec->stateZeroCharData == ch) return k; + } + } + else if (!(keyToChar[k] & kUCKeyOutputSequenceIndexMask) && keyToChar[k] < 0xFFFE) + { + if (keyToChar[k] == ch) return k; + } + } // for k + } // for j + } // for i + return 0; +} + +bool QxtGlobalShortcutPrivate::registerShortcut(quint32 nativeKey, quint32 nativeMods) +{ + if (!qxt_mac_handler_installed) + { + qxt_mac_handler_installed = true; + EventTypeSpec t; + t.eventClass = kEventClassKeyboard; + t.eventKind = kEventHotKeyPressed; + InstallApplicationEventHandler(&qxt_mac_handle_hot_key, 1, &t, NULL, NULL); + } + + EventHotKeyID keyID; + keyID.signature = 'cute'; + keyID.id = ++hotKeySerial; + + EventHotKeyRef ref = 0; + bool rv = !RegisterEventHotKey(nativeKey, nativeMods, keyID, GetApplicationEventTarget(), 0, &ref); + if (rv) + { + keyIDs.insert(Identifier(nativeMods, nativeKey), keyID.id); + keyRefs.insert(keyID.id, ref); + } + return rv; +} + +bool QxtGlobalShortcutPrivate::unregisterShortcut(quint32 nativeKey, quint32 nativeMods) +{ + Identifier id(nativeMods, nativeKey); + if (!keyIDs.contains(id)) return false; + + EventHotKeyRef ref = keyRefs.take(keyIDs[id]); + keyIDs.remove(id); + return !UnregisterEventHotKey(ref); +} +bool QxtGlobalShortcutPrivate::nativeEventFilter(const QByteArray & eventType, + void *message, long *result) { - Q_UNUSED(nextHandler); - Q_UNUSED(data); - if (GetEventClass(event) == kEventClassKeyboard && GetEventKind(event) == kEventHotKeyPressed) - { - EventHotKeyID keyID; - GetEventParameter(event, kEventParamDirectObject, typeEventHotKeyID, NULL, sizeof(keyID), NULL, &keyID); - Identifier id = keyIDs.key(keyID.id); - QxtGlobalShortcutPrivate::activateShortcut(id.second, id.first); - } - return noErr; -} - -quint32 QxtGlobalShortcutPrivate::nativeModifiers(Qt::KeyboardModifiers modifiers) -{ - quint32 native = 0; - if (modifiers & Qt::ShiftModifier) - native |= shiftKey; - if (modifiers & Qt::ControlModifier) - native |= cmdKey; - if (modifiers & Qt::AltModifier) - native |= optionKey; - if (modifiers & Qt::MetaModifier) - native |= controlKey; - if (modifiers & Qt::KeypadModifier) - native |= kEventKeyModifierNumLockMask; - return native; -} - -quint32 QxtGlobalShortcutPrivate::nativeKeycode(Qt::Key key) -{ - UTF16Char ch; - // Constants found in NSEvent.h from AppKit.framework - switch (key) - { - case Qt::Key_Return: - return kVK_Return; - case Qt::Key_Enter: - return kVK_ANSI_KeypadEnter; - case Qt::Key_Tab: - return kVK_Tab; - case Qt::Key_Space: - return kVK_Space; - case Qt::Key_Backspace: - return kVK_Delete; - case Qt::Key_Control: - return kVK_Command; - case Qt::Key_Shift: - return kVK_Shift; - case Qt::Key_CapsLock: - return kVK_CapsLock; - case Qt::Key_Option: - return kVK_Option; - case Qt::Key_Meta: - return kVK_Control; - case Qt::Key_F17: - return kVK_F17; - case Qt::Key_VolumeUp: - return kVK_VolumeUp; - case Qt::Key_VolumeDown: - return kVK_VolumeDown; - case Qt::Key_F18: - return kVK_F18; - case Qt::Key_F19: - return kVK_F19; - case Qt::Key_F20: - return kVK_F20; - case Qt::Key_F5: - return kVK_F5; - case Qt::Key_F6: - return kVK_F6; - case Qt::Key_F7: - return kVK_F7; - case Qt::Key_F3: - return kVK_F3; - case Qt::Key_F8: - return kVK_F8; - case Qt::Key_F9: - return kVK_F9; - case Qt::Key_F11: - return kVK_F11; - case Qt::Key_F13: - return kVK_F13; - case Qt::Key_F16: - return kVK_F16; - case Qt::Key_F14: - return kVK_F14; - case Qt::Key_F10: - return kVK_F10; - case Qt::Key_F12: - return kVK_F12; - case Qt::Key_F15: - return kVK_F15; - case Qt::Key_Help: - return kVK_Help; - case Qt::Key_Home: - return kVK_Home; - case Qt::Key_PageUp: - return kVK_PageUp; - case Qt::Key_Delete: - return kVK_ForwardDelete; - case Qt::Key_F4: - return kVK_F4; - case Qt::Key_End: - return kVK_End; - case Qt::Key_F2: - return kVK_F2; - case Qt::Key_PageDown: - return kVK_PageDown; - case Qt::Key_F1: - return kVK_F1; - case Qt::Key_Left: - return kVK_LeftArrow; - case Qt::Key_Right: - return kVK_RightArrow; - case Qt::Key_Down: - return kVK_DownArrow; - case Qt::Key_Up: - return kVK_UpArrow; - default: - ; - } - - if (key == Qt::Key_Escape) ch = 27; - else if (key == Qt::Key_Return) ch = 13; - else if (key == Qt::Key_Enter) ch = 3; - else if (key == Qt::Key_Tab) ch = 9; - else ch = key; - - CFDataRef currentLayoutData; - TISInputSourceRef currentKeyboard = TISCopyCurrentKeyboardInputSource(); - - if (currentKeyboard == NULL) - return 0; - - currentLayoutData = (CFDataRef)TISGetInputSourceProperty(currentKeyboard, kTISPropertyUnicodeKeyLayoutData); - CFRelease(currentKeyboard); - if (currentLayoutData == NULL) - return 0; - - UCKeyboardLayout* header = (UCKeyboardLayout*)CFDataGetBytePtr(currentLayoutData); - UCKeyboardTypeHeader* table = header->keyboardTypeList; - - uint8_t *data = (uint8_t*)header; - // God, would a little documentation for this shit kill you... - for (quint32 i=0; i < header->keyboardTypeCount; i++) - { - UCKeyStateRecordsIndex* stateRec = 0; - if (table[i].keyStateRecordsIndexOffset != 0) - { - stateRec = reinterpret_cast(data + table[i].keyStateRecordsIndexOffset); - if (stateRec->keyStateRecordsIndexFormat != kUCKeyStateRecordsIndexFormat) stateRec = 0; - } - - UCKeyToCharTableIndex* charTable = reinterpret_cast(data + table[i].keyToCharTableIndexOffset); - if (charTable->keyToCharTableIndexFormat != kUCKeyToCharTableIndexFormat) continue; - - for (quint32 j=0; j < charTable->keyToCharTableCount; j++) - { - UCKeyOutput* keyToChar = reinterpret_cast(data + charTable->keyToCharTableOffsets[j]); - for (quint32 k=0; k < charTable->keyToCharTableSize; k++) - { - if (keyToChar[k] & kUCKeyOutputTestForIndexMask) - { - long idx = keyToChar[k] & kUCKeyOutputGetIndexMask; - if (stateRec && idx < stateRec->keyStateRecordCount) - { - UCKeyStateRecord* rec = reinterpret_cast(data + stateRec->keyStateRecordOffsets[idx]); - if (rec->stateZeroCharData == ch) return k; - } - } - else if (!(keyToChar[k] & kUCKeyOutputSequenceIndexMask) && keyToChar[k] < 0xFFFE) - { - if (keyToChar[k] == ch) return k; - } - } // for k - } // for j - } // for i - return 0; -} - -bool QxtGlobalShortcutPrivate::registerShortcut(quint32 nativeKey, quint32 nativeMods) -{ - if (!qxt_mac_handler_installed) - { - EventTypeSpec t; - t.eventClass = kEventClassKeyboard; - t.eventKind = kEventHotKeyPressed; - InstallApplicationEventHandler(&qxt_mac_handle_hot_key, 1, &t, NULL, NULL); - } - - EventHotKeyID keyID; - keyID.signature = 'cute'; - keyID.id = ++hotKeySerial; - - EventHotKeyRef ref = 0; - bool rv = !RegisterEventHotKey(nativeKey, nativeMods, keyID, GetApplicationEventTarget(), 0, &ref); - if (rv) - { - keyIDs.insert(Identifier(nativeMods, nativeKey), keyID.id); - keyRefs.insert(keyID.id, ref); - } - return rv; -} - -bool QxtGlobalShortcutPrivate::unregisterShortcut(quint32 nativeKey, quint32 nativeMods) -{ - Identifier id(nativeMods, nativeKey); - if (!keyIDs.contains(id)) return false; - - EventHotKeyRef ref = keyRefs.take(keyIDs[id]); - keyIDs.remove(id); - return !UnregisterEventHotKey(ref); + return false; } diff --git a/qxt-mini/qxtglobalshortcut.cpp b/qxt-mini/qxtglobalshortcut.cpp index 44b9f917..8515a6b2 100644 --- a/qxt-mini/qxtglobalshortcut.cpp +++ b/qxt-mini/qxtglobalshortcut.cpp @@ -74,6 +74,7 @@ QxtGlobalShortcutPrivate::~QxtGlobalShortcutPrivate() bool QxtGlobalShortcutPrivate::setShortcut(const QKeySequence& shortcut) { + if (shortcut.toString() == "") return false; Qt::KeyboardModifiers allMods = Qt::ShiftModifier | Qt::ControlModifier | Qt::AltModifier | Qt::MetaModifier; key = shortcut.isEmpty() ? Qt::Key(0) : Qt::Key((shortcut[0] ^ allMods) & shortcut[0]); mods = shortcut.isEmpty() ? Qt::KeyboardModifiers(0) : Qt::KeyboardModifiers(shortcut[0] & allMods); diff --git a/qxt-mini/qxtglobalshortcut_p.h b/qxt-mini/qxtglobalshortcut_p.h index 5b10d089..407f968e 100644 --- a/qxt-mini/qxtglobalshortcut_p.h +++ b/qxt-mini/qxtglobalshortcut_p.h @@ -40,10 +40,6 @@ #include #endif -#ifdef Q_OS_DARWIN -# include -#endif - class QxtGlobalShortcutPrivate : public QxtPrivate #if QT_VERSION >= QT_VERSION_CHECK(5,0,0) ,public QAbstractNativeEventFilter @@ -62,35 +58,13 @@ public: bool unsetShortcut(); static bool error; -#ifndef Q_OS_DARWIN static int ref; # if QT_VERSION < QT_VERSION_CHECK(5,0,0) static QAbstractEventDispatcher::EventFilter prevEventFilter; - static bool eventFilter(void* message); # else + static bool eventFilter(void* message); virtual bool nativeEventFilter(const QByteArray & eventType, void * message, long * result); # endif // QT_VERSION < QT_VERSION_CHECK(5,0,0) -# else - virtual bool nativeEventFilter(const QByteArray & eventType, void * message, long * result) { - EventRef Event = reinterpret_cast(message); - UInt32 EventClass = GetEventClass (Event); - UInt32 EventKind = GetEventKind (Event); - UInt32 eventModifiers = 0; - GetEventParameter(Event, - kEventParamKeyModifiers, - typeUInt32, - NULL, - sizeof(UInt32), - NULL, - &eventModifiers); - if (kEventClassKeyboard && EventKind == kEventRawKeyDown) - { - UInt32 keyPressed = -1; - GetEventParameter(Event, kEventParamKeyCode, typeUInt32, NULL, sizeof(UInt32), NULL, &keyPressed); - return keyPressed == nativeKeycode(key) && nativeModifiers(mods) == eventModifiers; - } - } -#endif // Q_WS_MAC static void activateShortcut(quint32 nativeKey, quint32 nativeMods); -- cgit v1.2.3 From e058bd379f452ba7ecce64625c4438279a668ba4 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 23 Nov 2013 15:24:37 +0100 Subject: remove goto, hopefully fix osx Signed-off-by: Stanislaw Halik --- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 13 +++---------- ftnoir_tracker_aruco/ftnoir_tracker_aruco.h | 1 - 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index 2fdd1014..0d93dba5 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -129,8 +129,6 @@ void Tracker::load_settings() headpos[i] = iniFile.value(QString("headpos-%1").arg(i), 0).toDouble(); } iniFile.endGroup(); - - reset = true; } Tracker::Tracker() @@ -144,7 +142,6 @@ Tracker::Tracker() Tracker::~Tracker() { - QMutexLocker foo(&mtx); stop = true; wait(); if (videoWidget) @@ -155,7 +152,6 @@ Tracker::~Tracker() void Tracker::StartTracker(QFrame* videoframe) { - reset = false; videoframe->show(); videoWidget = new ArucoVideoWidget(videoframe); QHBoxLayout* layout = new QHBoxLayout(); @@ -176,8 +172,6 @@ void Tracker::StartTracker(QFrame* videoframe) void Tracker::run() { -start: - reset = false; cv::VideoCapture camera(camera_index); if (force_width) @@ -214,10 +208,6 @@ start: cv::Point2f last_centroid; while (!stop) { - if (reset) - { - goto start; - } if (!camera.read(color_)) continue; auto tm = cv::getTickCount(); @@ -364,6 +354,9 @@ start: if (frame.rows > 0) videoWidget->update_image(frame); } + qDebug() << "releasing camera, brace for impact"; + camera.release(); + qDebug() << "all done!"; } bool Tracker::GiveHeadPoseData(double *data) diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h index 9b9ff19d..097c91e1 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h @@ -40,7 +40,6 @@ private: double pose[6]; cv::Mat frame; double headpos[3]; - volatile bool reset; }; // Widget that has controls for FTNoIR protocol client-settings. -- 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(-) 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(-) 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 9490813ba7283a5f4caf178808907177357cd5c8 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 24 Nov 2013 05:58:23 +0100 Subject: initial version of the rpath fixer for osx --- install-fail-tool | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100755 install-fail-tool diff --git a/install-fail-tool b/install-fail-tool new file mode 100755 index 00000000..910d9cc4 --- /dev/null +++ b/install-fail-tool @@ -0,0 +1,19 @@ +#!/bin/sh + +test -n "$1" || exit 1 + +dir="$1" + +for i in "$dir"/*.dylib; do + echo ---- $i ---- + + install_name_tool -id "@executable_path/$(basename -- "$i")" "$i" + + otool -L "$i" | awk '$1 ~ /\.dylib$/ { print $1 }' | + while read l; do + j="$(basename -- "$l")" + if test -e "$dir/$j"; then + install_name_tool -change "$l" "@executable_path/$j" "$i" + fi + done +done -- cgit v1.2.3 From c21a454b0ffea54283cc8b1f4f9e5be761d2f8f4 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 24 Nov 2013 06:06:24 +0100 Subject: install-fail-tool: also process main executable --- install-fail-tool | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install-fail-tool b/install-fail-tool index 910d9cc4..be80dd12 100755 --- a/install-fail-tool +++ b/install-fail-tool @@ -4,7 +4,7 @@ test -n "$1" || exit 1 dir="$1" -for i in "$dir"/*.dylib; do +for i in "$dir"/*.dylib "$dir"/opentrack; do echo ---- $i ---- install_name_tool -id "@executable_path/$(basename -- "$i")" "$i" -- 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(-) 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 6cd2332a806013108322776d696fe34429dcd815 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 24 Nov 2013 06:54:00 +0100 Subject: fix osx brain damage by moving camera close to gui thread --- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 9 ++++----- ftnoir_tracker_aruco/ftnoir_tracker_aruco.h | 2 ++ 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index 0d93dba5..41bf0edd 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -148,6 +148,9 @@ Tracker::~Tracker() delete videoWidget; if(layout) delete layout; + qDebug() << "releasing camera, brace for impact"; + camera.release(); + qDebug() << "all done!"; } void Tracker::StartTracker(QFrame* videoframe) @@ -172,8 +175,7 @@ void Tracker::StartTracker(QFrame* videoframe) void Tracker::run() { - cv::VideoCapture camera(camera_index); - + camera = cv::VideoCapture(camera_index); if (force_width) camera.set(CV_CAP_PROP_FRAME_WIDTH, force_width); if (force_height) @@ -354,9 +356,6 @@ void Tracker::run() if (frame.rows > 0) videoWidget->update_image(frame); } - qDebug() << "releasing camera, brace for impact"; - camera.release(); - qDebug() << "all done!"; } bool Tracker::GiveHeadPoseData(double *data) diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h index 097c91e1..3a2ebeea 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h @@ -17,6 +17,7 @@ #include #include #include +#include class Tracker : protected QThread, public ITracker { @@ -40,6 +41,7 @@ private: double pose[6]; cv::Mat frame; double headpos[3]; + cv::VideoCapture camera; }; // Widget that has controls for FTNoIR protocol client-settings. -- cgit v1.2.3 From d86ae694c29b6652ff51986a02e549be077a8dbc Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 24 Nov 2013 07:05:13 +0100 Subject: Disable auto-export to fix FSUIPC --- CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1b0975ae..12c4cee0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -433,6 +433,8 @@ if(WIN32) target_link_libraries(opentrack-proto-fsuipc ${MY_QT_LIBS} "${SDK_FSUIPC}/FSUIPC_User.lib") if(MSVC) set_target_properties(opentrack-proto-fsuipc PROPERTIES LINK_FLAGS "/NODEFAULTLIB:libc") + else() + set_target_properties(opentrack-proto-fsuipc PROPERTIES LINK_FLAGS "-Wl,--exclude-all-symbols") endif() endif() -- cgit v1.2.3 From b9f44bae6b8364b0d0bd9b965a44a7fa0a8bcb08 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 24 Nov 2013 07:12:07 +0100 Subject: fix installer paths --- installer/opentrack-installer.iss | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/installer/opentrack-installer.iss b/installer/opentrack-installer.iss index fc0fcc40..9021caf9 100644 --- a/installer/opentrack-installer.iss +++ b/installer/opentrack-installer.iss @@ -24,7 +24,7 @@ DefaultDirName={pf}\{#MyAppName} DefaultGroupName={#MyAppName} AllowNoIcons=yes OutputBaseFilename={#MyAppVersion}-setup -SetupIconFile=d:\opentrack\facetracknoir\facetracknoir.ico +SetupIconFile=..\facetracknoir\facetracknoir.ico Compression=lzma2/ultra64 SolidCompression=yes DisableWelcomePage=True @@ -42,7 +42,7 @@ Name: "english"; MessagesFile: "compiler:Default.isl" Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked [Files] -Source: "d:\opentrack\build-mingw-w64\install\*"; DestDir: "{app}"; Flags: ignoreversion createallsubdirs recursesubdirs +Source: "..\build-mingw-w64\install\*"; DestDir: "{app}"; Flags: ignoreversion createallsubdirs recursesubdirs [Icons] Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}" -- cgit v1.2.3 From 215ad26cf5d58c208277dc68eec463e59a3eff9c Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 24 Nov 2013 07:48:47 +0100 Subject: Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index c5406ea9..9274a336 100644 --- a/README.md +++ b/README.md @@ -12,10 +12,10 @@ Not to be confused with railway planning software <> # Tracking sources - PointTracker by Patrick Ruoff, freetrack-like light sources -- Oculus Rift (Linux, Windows) +- Oculus Rift - AR marker support via the ArUco library - HT tracker -- Razer Hydra (Windows; Linux testers welcome!) +- Razer Hydra - Relaying via UDP from a different computer - Joystick analog axes (Windows only) @@ -28,7 +28,7 @@ Not to be confused with railway planning software <> - Relaying udp to another computer - Joystick support via freedesktop.org libevdev (Linux) - Joystick support via VJoy (Windows) -- Wine freetrack glue protocol (Linux) +- Wine freetrack glue protocol (Linux, OSX) - Tablet-like coordinate output (Windows) # Configuration -- cgit v1.2.3 From 78b570ca271f7e494615538f2c4fac618e79b015 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 24 Nov 2013 08:00:57 +0100 Subject: New game support --- bin/settings/facetracknoir supported games.csv | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bin/settings/facetracknoir supported games.csv b/bin/settings/facetracknoir supported games.csv index 05e17605..b623ae91 100644 --- a/bin/settings/facetracknoir supported games.csv +++ b/bin/settings/facetracknoir supported games.csv @@ -109,6 +109,7 @@ No;Game Name;Game protocol;Supported since;Verified;By;INTERNATIONAL_ID;FTN_ID 102;Dungeons and Dragons Online;FreeTrack20;V170;;;1575;0066BD4D4DDC6BB6818800 103;DY Demo;FreeTrack20;V160;;;20345;006727D5047A15540F9D00 104;EADS Testing;FreeTrack20;V160;;;20303;00680288709760D5512900 +504;EAFIT;FreeTrack20;V160;;;20810;01F8D2675ABC163E99B000 105;Eagle Lander 3D;FreeTrack20;V160;;;11901;00697686E5A7B209C27900 106;EasyVR;FreeTrack20;V160;;;20220;006A68292872FAC4588100 107;ECA-Sindel;FreeTrack20;V160;;;20590;006BC5BEE479FD75FB8500 @@ -164,6 +165,7 @@ No;Game Name;Game protocol;Supported since;Verified;By;INTERNATIONAL_ID;FTN_ID 152;GameLab;FreeTrack20;V160;;;20555;00985485D891DB23092200 472;Games Farm;FreeTrack20;V160;;;3250;01D875C0981E627E5C7600 153;Gamma;FreeTrack20;V160;;;1050;009921007D1B9D38A76F00 +503;Garry's Mod;FreeTrack20;V160;;;12503;01F74EEB71FA7F37856900 483;Generic Robotics;FreeTrack20;V160;;;20750;01E3FE7B4F05872A415400 475;Glider Sim;FreeTrack20;V160;;;20720;01DB42130C4B0620871C00 154;Global Ground Support Deicing Simulation;FreeTrack20;V160;;;20330;009ACFE709237A3AA11F00 @@ -179,6 +181,7 @@ No;Game Name;Game protocol;Supported since;Verified;By;INTERNATIONAL_ID;FTN_ID 164;Gun Commander;FreeTrack20;V160;;;2675;00A4E2D1D77E319FEE8600 165;Half Life 2;FreeTrack20;V160;;;7806;00A556BA018130AF365500 166;Halo;FreeTrack20;V160;;;3801;00A656BA018130AF3F9C00 +502;hapTEL;FreeTrack20;V160;;;20805;01F63ADE510A20446B6A00 167;Hardware Control Simulator, Railway Electronics;FreeTrack20;V160;;;20705;00A7F3E85B1A8930B42F00 168;Harrier Attack II;FreeTrack20;V160;;;1175;00A8F2F27A57D20A940900 499;Harry's Hard Choices Interactive;FreeTrack20;V160;;;20800;01F33A21BAE3DB6D48A000 -- cgit v1.2.3 From 3895beb6bbc6aaaaf167f1db99b7078506a83622 Mon Sep 17 00:00:00 2001 From: mm0zct Date: Tue, 26 Nov 2013 04:08:23 +0000 Subject: Added positional tracking?! perhaps, perhaps not.. to be tested -mm0zct --- ftnoir_tracker_rift/ftnoir_rift_clientcontrols.ui | 127 +++++++++++++++++++++ ftnoir_tracker_rift/ftnoir_tracker_rift.cpp | 22 +++- ftnoir_tracker_rift/ftnoir_tracker_rift.h | 4 +- ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp | 4 +- 4 files changed, 148 insertions(+), 9 deletions(-) diff --git a/ftnoir_tracker_rift/ftnoir_rift_clientcontrols.ui b/ftnoir_tracker_rift/ftnoir_rift_clientcontrols.ui index e868a9c3..8250580d 100644 --- a/ftnoir_tracker_rift/ftnoir_rift_clientcontrols.ui +++ b/ftnoir_tracker_rift/ftnoir_rift_clientcontrols.ui @@ -150,9 +150,136 @@ + + + + + + + + + Enable Translation Axis + + + false + + + + + + + 0 + 0 + + + + TX: + + + + + + + + 0 + 0 + + + + + 20 + 16777215 + + + + Qt::LeftToRight + + + + + + + + + + + + + + 0 + 0 + + + + TY: + + + + + + + + 0 + 0 + + + + + 20 + 16777215 + + + + Qt::LeftToRight + + + + + + + + + + + 0 + 0 + + + + TZ: + + + + + + + + 0 + 0 + + + + + 20 + 16777215 + + + + Qt::LeftToRight + + + + + + + + + + + diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp b/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp index dd78bf9f..45c02cfb 100644 --- a/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp +++ b/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp @@ -88,11 +88,23 @@ bool Rift_Tracker::GiveHeadPoseData(double *data) if(newHeadPose[Yaw]<-deadzone)newHeadPose[Yaw]+= constant_drift; old_yaw=yaw; } -#if 0 - newHeadPose[TX] = acd.controllers[0].pos[0]/50.0f; - newHeadPose[TY] = acd.controllers[0].pos[1]/50.0f; - newHeadPose[TZ] = acd.controllers[0].pos[2]/50.0f; - +#if 1 + + double dt = 0.015; + + OVR::Vector3f acc = pSFusion->GetAcceleration(); + old_x = old_x*persistence + vx*dt + 0.5*(acc.x*acc.x); + vx = vx*persistence + acc.x*dt; + newHeadPose[TX] = old_x; + + old_y = old_y*persistence + vy*dt + 0.5*(acc.y*acc.y); + vy = vy*persistence + acc.y*dt; + newHeadPose[TY] = old_y; + + old_z = old_z*persistence + vz*dt + 0.5*(acc.z*acc.z); + vz = vz*persistence + acc.z*dt; + newHeadPose[TZ] = old_z; + if (bEnableX) { data[TX] = newHeadPose[TX]; } diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift.h b/ftnoir_tracker_rift/ftnoir_tracker_rift.h index b76d8d09..787f16b9 100644 --- a/ftnoir_tracker_rift/ftnoir_tracker_rift.h +++ b/ftnoir_tracker_rift/ftnoir_tracker_rift.h @@ -29,13 +29,13 @@ private: bool bEnableRoll; bool bEnablePitch; bool bEnableYaw; -#if 0 +#if 1 bool bEnableX; bool bEnableY; bool bEnableZ; #endif bool useYawSpring; - double old_yaw, constant_drift, persistence, deadzone; + double old_yaw, constant_drift, persistence, deadzone, old_x, old_y, old_z, vx, vy, vz; }; // Widget that has controls for FTNoIR protocol client-settings. diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp b/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp index 2efefbb3..901a0192 100644 --- a/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp +++ b/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp @@ -112,7 +112,7 @@ void TrackerControls::loadSettings() { ui.chkEnableRoll->setChecked(iniFile.value ( "EnableRoll", 1 ).toBool()); ui.chkEnablePitch->setChecked(iniFile.value ( "EnablePitch", 1 ).toBool()); ui.chkEnableYaw->setChecked(iniFile.value ( "EnableYaw", 1 ).toBool()); -#if 0 +#if 1 ui.chkEnableX->setChecked(iniFile.value ( "EnableX", 1 ).toBool()); ui.chkEnableY->setChecked(iniFile.value ( "EnableY", 1 ).toBool()); ui.chkEnableZ->setChecked(iniFile.value ( "EnableZ", 1 ).toBool()); @@ -139,7 +139,7 @@ void TrackerControls::save() { iniFile.setValue ( "EnableRoll", ui.chkEnableRoll->isChecked() ); iniFile.setValue ( "EnablePitch", ui.chkEnablePitch->isChecked() ); iniFile.setValue ( "EnableYaw", ui.chkEnableYaw->isChecked() ); -#if 0 +#if 1 iniFile.setValue ( "EnableX", ui.chkEnableX->isChecked() ); iniFile.setValue ( "EnableY", ui.chkEnableY->isChecked() ); iniFile.setValue ( "EnableZ", ui.chkEnableZ->isChecked() ); -- 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(+) 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 56c199090d3b84a187a788e0ce47ac5965e06484 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 26 Nov 2013 19:42:54 +0100 Subject: declare tracker hz to prevent deconvergence of IHT --- ftnoir_tracker_base/ftnoir_tracker_base.h | 1 + ftnoir_tracker_hydra/ftnoir_tracker_hydra.h | 14 ++++++++------ ftnoir_tracker_rift/ftnoir_tracker_rift.h | 9 +++++---- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/ftnoir_tracker_base/ftnoir_tracker_base.h b/ftnoir_tracker_base/ftnoir_tracker_base.h index 070c8c33..38c24afe 100644 --- a/ftnoir_tracker_base/ftnoir_tracker_base.h +++ b/ftnoir_tracker_base/ftnoir_tracker_base.h @@ -44,6 +44,7 @@ struct ITracker virtual ~ITracker() = 0; virtual void StartTracker( QFrame* frame ) = 0; virtual bool GiveHeadPoseData(double *data) = 0; + virtual int preferredHz() { return 66; } }; inline ITracker::~ITracker() { } diff --git a/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h b/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h index 2601ac55..3daaf239 100644 --- a/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h +++ b/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h @@ -9,11 +9,11 @@ class Hydra_Tracker : public ITracker { public: Hydra_Tracker(); - ~Hydra_Tracker(); + ~Hydra_Tracker(); - void StartTracker(QFrame *); - bool GiveHeadPoseData(double *data); - void loadSettings(); + void StartTracker(QFrame *) virt_override; + bool GiveHeadPoseData(double *data) virt_override; + void loadSettings(); volatile bool should_quit; protected: void run(); // qthread override run method @@ -31,6 +31,8 @@ private: bool bEnableZ; QMutex mutex; + + virtual int preferredHz() virt_override { return 250; } }; // Widget that has controls for FTNoIR protocol client-settings. @@ -58,8 +60,8 @@ private: 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_tracker_rift/ftnoir_tracker_rift.h b/ftnoir_tracker_rift/ftnoir_tracker_rift.h index 787f16b9..93b03b97 100644 --- a/ftnoir_tracker_rift/ftnoir_tracker_rift.h +++ b/ftnoir_tracker_rift/ftnoir_tracker_rift.h @@ -12,11 +12,12 @@ class Rift_Tracker : public ITracker { public: Rift_Tracker(); - virtual ~Rift_Tracker(); + virtual ~Rift_Tracker() virt_override; - void StartTracker(QFrame *); - bool GiveHeadPoseData(double *data); - void loadSettings(); + void StartTracker(QFrame *) virt_override; + bool GiveHeadPoseData(double *data) virt_override; + void loadSettings(); + virtual int preferredHz() virt_override { return 250; } volatile bool should_quit; protected: void run(); // qthread override run method -- 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(-) 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 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 8e00d5a1599cc60a823191ed5351d68066682b16 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 27 Nov 2013 02:31:33 +0100 Subject: install hatire Signed-off-by: Stanislaw Halik --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 307aeac4..0aaf4f01 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -537,6 +537,7 @@ 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() +install(TARGETS opentrack-tracker-hatire RUNTIME DESTINATION . LIBRARY DESTINATION .) if(WIN32) target_link_libraries(opentrack-tracker-ht -- cgit v1.2.3 From 09aeee333b807be87f456fa226fc0442d5a37364 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 27 Nov 2013 02:32:24 +0100 Subject: make hatire actually buildable Remove 'captain obvious' comments, references to , fix spelling errors, use UI layouts, and so on Signed-off-by: Stanislaw Halik --- ftnoir_tracker_hatire/ftnoir_arduino_type.h | 21 +- ftnoir_tracker_hatire/ftnoir_hatcontrols.ui | 1675 +++++++++----------- ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp | 251 +-- ftnoir_tracker_hatire/ftnoir_tracker_hat.h | 59 +- .../ftnoir_tracker_hat_dialog.cpp | 121 +- ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.h | 37 +- ftnoir_tracker_hatire/ftnoir_tracker_hat_dll.cpp | 57 +- .../ftnoir_tracker_hat_settings.cpp | 48 +- .../ftnoir_tracker_hat_settings.h | 16 +- 9 files changed, 887 insertions(+), 1398 deletions(-) diff --git a/ftnoir_tracker_hatire/ftnoir_arduino_type.h b/ftnoir_tracker_hatire/ftnoir_arduino_type.h index 4d19043b..7f550579 100644 --- a/ftnoir_tracker_hatire/ftnoir_arduino_type.h +++ b/ftnoir_tracker_hatire/ftnoir_arduino_type.h @@ -1,31 +1,30 @@ #ifndef FTNOIR_TARDUINO_TYPE_H #define FTNOIR_TARDUINO_TYPE_H -// Arduino trame structure +#include + +// Arduino frame 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 + quint16 Code; // 0->999 Num Frame >=2000 Info >=3000 Init >=5000 Start Command >=9000 Error float Gyro[3]; float Acc[3]; - quint16 End; // End trame 0x5555; + quint16 End; // End frame 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; + in >> out.Begin >> out.Code + >> out.Gyro[0] >> out.Gyro[1] >> out.Gyro[2] + >> out.Acc[0] >> out.Acc[1] >> out.Acc[2] + >> out.End; return in; } - - -#endif \ No newline at end of file +#endif diff --git a/ftnoir_tracker_hatire/ftnoir_hatcontrols.ui b/ftnoir_tracker_hatire/ftnoir_hatcontrols.ui index 86f9e48a..8882fffb 100644 --- a/ftnoir_tracker_hatire/ftnoir_hatcontrols.ui +++ b/ftnoir_tracker_hatire/ftnoir_hatcontrols.ui @@ -41,1015 +41,784 @@ 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 + 360 + 470 - - Axis Configuration + + + 360 + 470 + - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + 1 - - - - 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 - - - - - + + true + + + + + :/images/hat.ico:/images/hat.ico + + + General + + + + + + + + + + + 80 + 20 + + + + Center + + + + + + + + 80 + 20 + + + + Reset + + + + + + + + 0 + 0 + + + + + 100 + 16777215 + + + + false + + + QComboBox::AdjustToMinimumContentsLength + + + 0 + + + + + + + Arduino serial port + + + true + + + + - - - - Enable - - - - - - - Axis - - - - - - - Invert - - - - - - - X: - - - - - - + + + - 20 - 16777215 + 0 + 106 - - Enable Axis - - - Qt::LeftToRight - - - - + + Axis selection + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + 20 + 16777215 + + + + Enable Axis + + + Qt::LeftToRight + + + + + + + + + + + 20 + 16777215 + + + + Invert Axis + + + Qt::LeftToRight + + + + + + + + + + + + + Associate Axis + + + + X + + + + + Y + + + + + Z + + + + + + + + + 20 + 16777215 + + + + Enable Axis + + + Qt::LeftToRight + + + + + + + + + + X + + + + + + + Pitch + + + + + + + Z + + + + + + + + 20 + 16777215 + + + + Invert Axis + + + Qt::LeftToRight + + + + + + + + + + + + + Associate Axis + + + + Yaw + + + + + Pitch + + + + + Roll + + + + + + + + + 20 + 16777215 + + + + Enable Axis + + + Qt::LeftToRight + + + + + + + + + + Associate Axis + + + + X + + + + + Y + + + + + Z + + + + + + + + + 20 + 16777215 + + + + Invert Axis + + + Qt::LeftToRight + + + + + + + + + + + + + + 20 + 16777215 + + + + Enable Axis + + + Qt::LeftToRight + + + + + + + + + + + 20 + 16777215 + + + + Invert Axis + + + Qt::LeftToRight + + + + + + + + + + + + + Associate Axis + + + + Yaw + + + + + Pitch + + + + + Roll + + + + + + + + + 20 + 16777215 + + + + Enable Axis + + + Qt::LeftToRight + + + + + + + + + + Input + + + + + + + Invert + + + + + + + Yaw + + + + + + + + 20 + 16777215 + + + + Enable Axis + + + Qt::LeftToRight + + + + + + + + + + + + + Associate Axis + + + + X + + + + + Y + + + + + Z + + + + + + + + Associate Axis + + + + Yaw + + + + + Pitch + + + + + Roll + + + + + + + + + 20 + 16777215 + + + + Invert Axis + + + Qt::LeftToRight + + + + + + + + + + + + + Y + + + + + + + + 20 + 16777215 + + + + Invert Axis + + + Qt::LeftToRight + + + + + + + + + + + + + Roll + + + + + + + Enable + + + + + + + Output + + + + - - - - Associate Axis - - - - X - - - - - Y - - - - - Z - - + + + + Information + + + + + + + 31 + 0 + + + + + 60 + 13 + + + + Trame per seconde + + + tps : + + + + + + + + 170 + 0 + + + + + 60 + 16777215 + + + + + + + + + + + + 31 + 0 + + + + + 60 + 13 + + + + 00 + + + + + + + + 60 + 16777215 + + + + Status : + + + + - - - - - 20 - 16777215 - - - - Invert Axis - - - Qt::LeftToRight - - - - + + + + + About + + + + - + <!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> - - - - - - Y: + + true - - - - - 20 - 16777215 - - - - Enable Axis - - - Qt::LeftToRight - + + - - - - - - Associate Axis + + :/images/hat_logo.png - - - X - - - - - Y - - - - - Z - - - - - - - 20 - 16777215 - - - - Invert Axis - - - Qt::LeftToRight - - - - - - - - + + - - - - Z: + + + + true - - - - - - - 20 - 16777215 - - - - Enable Axis - - - Qt::LeftToRight - - - + + 800 - - - - Associate Axis - - - - X - - - - - Y - - - - - Z - - - - - - - - - 20 - 16777215 - - - - Invert Axis - - - Qt::LeftToRight - - - - + + - + Send - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 20 - 16 - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 20 - 16 - - - - - - - - 10 - 90 - 331 - 31 - + + + + + + 0 + 0 + - - - - - 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 - + + + 80 + 25 + - - - 7 - - - - - Choose the Serial Com port where is connected ARDUINO. - - - true - - - - - - - - - About - - - - - 10 - 20 - 111 - 111 - + + + 80 + 25 + - <!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 + OK - - - - 200 - 20 - 128 - 128 - + + + + + + 80 + 25 + - - + + + 80 + 25 + - - :/images/hat_logo.png + + Save - - - - 10 - 190 - 331 - 251 - - - - true + + + + + + 0 + 0 + - - 800 - - - - - - 10 - 160 - 241 - 20 - + + + 80 + 25 + - - - - - 260 - 160 - 75 - 23 - + + + 80 + 25 + - Send + Cancel - - + + btnCancel diff --git a/ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp b/ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp index e961a10f..99baf75b 100644 --- a/ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp +++ b/ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp @@ -1,67 +1,45 @@ -/******************************************************************************** -* 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 . * -* * -********************************************************************************/ - +/* code by Furax49, awaiting copyright information */ #include "ftnoir_tracker_hat.h" +#include "facetracknoir/global-settings.h" #include #include -#include -FTNoIR_Tracker::FTNoIR_Tracker() +FTNoIR_Tracker::FTNoIR_Tracker() : + SerialPort(nullptr), + stop(false) { - SerialPort = NULL; - waitTimeout = 1000; TrackerSettings settings; settings.load_ini(); applysettings(settings); + //ListErrInf = new QList(); - // 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); + qDebug() << "FTNoIR_Tracker::Initialize() Open SerialPort"; + SerialPort = new QSerialPort(sSerialPortName); + if (SerialPort->open(QIODevice::ReadWrite | QIODevice::Unbuffered ) == true) { + SerialPort->flush(); + SerialPort->setBaudRate(115200); + SerialPort->setParity(QSerialPort::NoParity); + SerialPort->setDataBits(QSerialPort::Data8); + SerialPort->setStopBits(QSerialPort::OneStop); + SerialPort->setFlowControl(QSerialPort::NoFlowControl); + //SerialPort->setTimeout(waitTimeout); + //SerialPort->setQueryMode(QextSerialPort::EventDriven); //Polling + SerialPort->putChar('S'); + } + else { + QMessageBox::warning(0,"FaceTrackNoIR Error", "Unable to open SerialPort",QMessageBox::Ok,QMessageBox::NoButton); + delete SerialPort; + SerialPort = NULL; + } } 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); - + stop = true; + wait(); if (SerialPort!=NULL) { if (SerialPort->isOpen() ) { SerialPort->putChar('s'); //Send STOP to Arduino @@ -104,163 +82,92 @@ void FTNoIR_Tracker::reset() { //send command to Arduino void FTNoIR_Tracker::sendcmd(QString* cmd) { - QReadLocker locker(&rwlock); + QMutexLocker locker(&lock); QByteArray bytes; if (SerialPort!=NULL) { if (SerialPort->isOpen() ) { - bytes.append(cmd->toAscii()); - SerialPort->write(bytes); + bytes.append(cmd->toLatin1()); + SerialPort->write(bytes); } } } // return FPS and last status -void FTNoIR_Tracker::get_info(QString* info, int* tps ){ - QReadLocker locker(&rwlock); +void FTNoIR_Tracker::get_info(QString*, int* tps ){ + QMutexLocker locker(&lock); *tps=HAT.Code; +#if 0 if (ListErrInf->size()>0) { *info=ListErrInf->takeFirst(); } else { *info= QString(); } +#endif } /** 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); + if (!SerialPort) + return; + while (!stop) + { + if (SerialPort->bytesAvailable()>=30) + { + QMutexLocker locker(&lock); datagram.clear(); datagram=SerialPort->read(30); - QDataStream datastream(datagram); - datastream>>ArduinoData; - - if (ArduinoData.Begin==0xAAAA && ArduinoData.End==0x5555 ) { - if (ArduinoData.Code <= 1000) { + 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 ) +void FTNoIR_Tracker::StartTracker( QFrame* ) { start( QThread::TimeCriticalPriority ); return; } -void FTNoIR_Tracker::StopTracker( bool exit ) +bool FTNoIR_Tracker::GiveHeadPoseData(double* data) { - // - // OK, the thread is not stopped, doing this. That might be dangerous anyway... - // - if (exit || !exit) return; - return; -} + QMutexLocker locker(&lock); -// -// Return 6DOF info -// -bool FTNoIR_Tracker::GiveHeadPoseData(THeadPoseData *data) -{ - QReadLocker locker(&rwlock); - data->frame_number = HAT.Code; + const bool inversions[] = { + bInvertX, bInvertY, bInvertZ, bInvertYaw, bInvertPitch, bInvertRoll + }; - 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]; - } + const bool enablement[] = { + bEnableX, bEnableY, bEnableZ, bEnableYaw, bEnablePitch, bEnableRoll + }; - if (bEnableY) { - if (bInvertY) data->y = HAT.Acc[iYAxe]* -1.0f; - else data->y = HAT.Acc[iYAxe]; - } + const int axes[] = { + iXAxis, iYAxis, iZAxis, iYawAxis, iPitchAxis, iRollAxis + }; - if (bEnableZ) { - if (bInvertZ) data->z = HAT.Acc[iZAxe]* -1.0f; - else data->z = HAT.Acc[iZAxe]; - } + for (int i = 0; i < 6; i++) + { + if (enablement[i]) + data[i] = HAT.Gyro[axes[i]] * (inversions[i] ? -1 : 1); + } - return true; + return true; } - - -// -// Apply modification Settings -// void FTNoIR_Tracker::applysettings(const TrackerSettings& settings){ qDebug()<<"Tracker:: Applying settings"; - QReadLocker locker(&rwlock); + QMutexLocker locker(&lock); sSerialPortName= settings.SerialPortName; bEnableRoll = settings.EnableRoll; @@ -278,27 +185,15 @@ void FTNoIR_Tracker::applysettings(const TrackerSettings& settings){ bInvertZ = settings.InvertZ; - iRollAxe= settings.RollAxe; - iPitchAxe= settings.PitchAxe; - iYawAxe= settings.YawAxe; - iXAxe= settings.XAxe; - iYAxe= settings.YAxe; - iZAxe= settings.ZAxe; + iRollAxis= settings.RollAxis; + iPitchAxis= settings.PitchAxis; + iYawAxis= settings.YawAxis; + iXAxis= settings.XAxis; + iYAxis= settings.YAxis; + iZAxis= settings.ZAxis; } - - - -//////////////////////////////////////////////////////////////////////////////// -// 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() +extern "C" FTNOIR_TRACKER_BASE_EXPORT ITracker* CALLING_CONVENTION GetConstructor() { return new FTNoIR_Tracker; } diff --git a/ftnoir_tracker_hatire/ftnoir_tracker_hat.h b/ftnoir_tracker_hatire/ftnoir_tracker_hat.h index 54e67f48..af583d11 100644 --- a/ftnoir_tracker_hatire/ftnoir_tracker_hat.h +++ b/ftnoir_tracker_hatire/ftnoir_tracker_hat.h @@ -1,33 +1,28 @@ #ifndef FTNOIR_TRACKER_HAT_H #define FTNOIR_TRACKER_HAT_H -#include "..\ftnoir_tracker_base\ftnoir_tracker_base.h" +#include "facetracknoir/global-settings.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 -#include "Windows.h" -#include "math.h" - -class QextSerialPort; -class QExtSerialEnumerator; +#include +#include +#include class FTNoIR_Tracker : public ITracker, QThread { public: FTNoIR_Tracker(); - ~FTNoIR_Tracker(); + virtual ~FTNoIR_Tracker() virt_override; - void Initialize( QFrame *videoframe ); - void StartTracker( HWND parent_window ); - void StopTracker( bool exit ); - bool GiveHeadPoseData(THeadPoseData *data); + virtual void StartTracker( QFrame* frame ) virt_override; + virtual bool GiveHeadPoseData(double *data) virt_override; void applysettings(const TrackerSettings& settings); void notifyCenter(); @@ -39,18 +34,12 @@ public: 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; + QSerialPort* SerialPort; + volatile bool stop; + QMutex lock; QString sSerialPortName; // Port serial name bool bEnableRoll; bool bEnablePitch; @@ -67,28 +56,22 @@ private: bool bInvertZ; - int iRollAxe; - int iPitchAxe; - int iYawAxe; - int iXAxe; - int iYAxe; - int iZAxe; + int iRollAxis; + int iPitchAxis; + int iYawAxis; + int iXAxis; + int iYAxis; + int iZAxis; }; - -//******************************************************************************************************* -// FaceTrackNoIR Tracker DLL. Functions used to get general info on the Tracker -//******************************************************************************************************* -class FTNoIR_TrackerDll : public ITrackerDll +class FTNoIR_TrackerDll : public Metadata { public: FTNoIR_TrackerDll(); ~FTNoIR_TrackerDll(); - void Initialize(); - - void getFullName(QString *strToBeFilled); + void getFullName(QString *strToBeFilled); void getShortName(QString *strToBeFilled); void getDescription(QString *strToBeFilled); void getIcon(QIcon *icon); @@ -99,4 +82,4 @@ private: QString trackerDescription; }; -#endif // FTNOIR_TRACKER_HAT_H \ No newline at end of file +#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 index b889341f..1fa482c7 100644 --- a/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.cpp +++ b/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.cpp @@ -1,32 +1,9 @@ -/******************************************************************************** -* 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 +#include //******************************************************************************************************* // FaceTrackNoIR Client Settings-dialog. @@ -35,21 +12,16 @@ // // Constructor for server-settings-dialog // -TrackerControls::TrackerControls() : settingsDirty(false), theTracker(NULL), timer(this), -QWidget() +TrackerControls::TrackerControls() : pre_frame(0), theTracker(NULL), settingsDirty(false), timer(this) { - 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); + 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 { @@ -77,21 +49,18 @@ QWidget() 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); - + ui.cb_roll->setCurrentIndex(settings.RollAxis); + ui.cb_pitch->setCurrentIndex(settings.PitchAxis); + ui.cb_yaw->setCurrentIndex(settings.YawAxis); + ui.cb_x->setCurrentIndex(settings.XAxis); + ui.cb_y->setCurrentIndex(settings.YAxis); + ui.cb_z->setCurrentIndex(settings.ZAxis); // 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)) ); @@ -108,7 +77,6 @@ QWidget() 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))); @@ -127,13 +95,8 @@ QWidget() // Destructor for server-dialog // TrackerControls::~TrackerControls() { - delete this; } - -// -// Initialize tracker-client-dialog -// void TrackerControls::Initialize(QWidget *parent) { QPoint offsetpos(100, 100); if (parent) { @@ -142,35 +105,20 @@ void TrackerControls::Initialize(QWidget *parent) { 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()) { @@ -182,10 +130,6 @@ void TrackerControls::doSend() { } } - -// -// Display FPS and Status of Arduino. -// void TrackerControls::poll_tracker_info() { if (theTracker) @@ -202,13 +146,13 @@ void TrackerControls::poll_tracker_info() } - if (pre_tramesetText(QString::number(nb_trame*(1000/timer.interval()))); - pre_trame=num_trame; + pre_frame=num_trame; } } @@ -219,28 +163,15 @@ void TrackerControls::doSave() { 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) { + 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(); @@ -250,10 +181,8 @@ void TrackerControls::doCancel() { close(); break; case QMessageBox::Cancel: - // Cancel was clicked break; default: - // should never be reached break; } } @@ -264,15 +193,13 @@ void TrackerControls::doCancel() { void TrackerControls::registerTracker(ITracker *tracker) { -// theTracker = (FTNoIR_Tracker *) tracker; - theTracker = static_cast(tracker); + theTracker = dynamic_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); @@ -281,19 +208,7 @@ void TrackerControls::unRegisterTracker() { 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( ) +extern "C" FTNOIR_TRACKER_BASE_EXPORT ITrackerDialog* CALLING_CONVENTION GetDialog() { return new TrackerControls; } diff --git a/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.h b/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.h index c463f361..25bd839c 100644 --- a/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.h +++ b/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.h @@ -1,7 +1,7 @@ #ifndef FTNOIR_TRACKER_HAT_DIALOG_H #define FTNOIR_TRACKER_HAT_DIALOG_H -#include "..\ftnoir_tracker_base\ftnoir_tracker_base.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" @@ -9,32 +9,25 @@ #include #include -// Widget that has controls for FTNoIR protocol client-settings. -class TrackerControls: public QWidget, Ui::UIHATControls, public ITrackerDialog +class TrackerControls: public QWidget, public ITrackerDialog { Q_OBJECT public: explicit TrackerControls(); - virtual ~TrackerControls(); + virtual ~TrackerControls() virt_override; - void Initialize(QWidget *parent); - void registerTracker(ITracker *tracker); - void unRegisterTracker() ; + void Initialize(QWidget *parent) virt_override; + void registerTracker(ITracker *tracker) virt_override; + void unRegisterTracker() virt_override; private: Ui::UIHATControls ui; - int pre_trame; + int pre_frame; 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; + 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(); } @@ -52,12 +45,12 @@ protected slots: 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 set_rot_roll(int val) { settings.RollAxis = val; settings_changed(); } + void set_rot_pitch(int val) { settings.PitchAxis = val; settings_changed(); } + void set_rot_yaw(int val) { settings.YawAxis = val; settings_changed(); } + void set_acc_x(int val) { settings.XAxis = val; settings_changed(); } + void set_acc_y(int val) { settings.YAxis = val; settings_changed(); } + void set_acc_z(int val) { settings.ZAxis = val; settings_changed(); } void doOK(); void doCancel(); @@ -75,4 +68,4 @@ protected: }; -#endif //FTNOIR_TRACKER_HAT_DIALOG_H \ No newline at end of file +#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 index 246eb397..c19f68d3 100644 --- a/ftnoir_tracker_hatire/ftnoir_tracker_hat_dll.cpp +++ b/ftnoir_tracker_hatire/ftnoir_tracker_hat_dll.cpp @@ -1,79 +1,38 @@ -/******************************************************************************** -* 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_TrackerDll::FTNoIR_TrackerDll() { - //populate the description strings - trackerFullName = "Head Arduino Tracker"; + trackerFullName = "Hatire Arduino"; trackerShortName = "HAT"; - trackerDescription = "FaceTrackNoIR HAT"; + trackerDescription = "Hatire Arduino"; } 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() +extern "C" FTNOIR_TRACKER_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata() { return new FTNoIR_TrackerDll; } diff --git a/ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.cpp b/ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.cpp index f8b342cc..1d2643ee 100644 --- a/ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.cpp +++ b/ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.cpp @@ -1,27 +1,3 @@ -/******************************************************************************** -* 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 @@ -54,12 +30,12 @@ void TrackerSettings::load_ini() 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(); + RollAxis=iniFile.value("RollAxis",1).toInt(); + PitchAxis=iniFile.value("PitchAxis",2).toInt(); + YawAxis=iniFile.value("YawAxis",0).toInt(); + XAxis=iniFile.value("XAxis",1).toInt(); + YAxis=iniFile.value("YAxis",2).toInt(); + ZAxis=iniFile.value("ZAxis",0).toInt(); iniFile.endGroup(); } @@ -91,12 +67,12 @@ void TrackerSettings::save_ini() const 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.setValue ( "RollAxis", RollAxis ); + iniFile.setValue ( "PitchAxis", PitchAxis ); + iniFile.setValue ( "YawAxis",YawAxis ); + iniFile.setValue ( "XAxis", XAxis ); + iniFile.setValue ( "YAxis", YAxis ); + iniFile.setValue ( "ZAxis", ZAxis ); iniFile.endGroup(); } diff --git a/ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.h b/ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.h index a29fed6b..d6cf4fd9 100644 --- a/ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.h +++ b/ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.h @@ -8,6 +8,7 @@ #ifndef FTNOIR_TRACKER_HAT_SETTINGS_H #define FTNOIR_TRACKER_HAT_SETTINGS_H +#include //----------------------------------------------------------------------------- struct TrackerSettings @@ -29,16 +30,15 @@ struct TrackerSettings bool InvertZ; - int RollAxe; - int PitchAxe; - int YawAxe; - int XAxe; - int YAxe; - int ZAxe; + int RollAxis; + int PitchAxis; + int YawAxis; + int XAxis; + int YAxis; + int ZAxis; void load_ini(); void save_ini() const; }; - -#endif //FTNOIR_TRACKER_HAT_SETTINGS_H \ No newline at end of file +#endif //FTNOIR_TRACKER_HAT_SETTINGS_H -- cgit v1.2.3 From a8c711c6b828c8eefb947ba60ef8c5c8233c5756 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 27 Nov 2013 03:03:24 +0100 Subject: Link against qt5serialport properly --- CMakeLists.txt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0aaf4f01..7ff5268e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -374,9 +374,10 @@ endif() if(APPLE) link_directories(${CMAKE_INSTALL_PREFIX}) - set(MY_QT_LIBS Qt5Widgets Qt5Gui Qt5Network Qt5Xml Qt5Core ${my-qt-deps}) + set(MY_QT_LIBS Qt5Widgets Qt5Gui Qt5Network Qt5Xml Qt5Core Qt5SerialPort ${my-qt-deps}) else() - SET(MY_QT_LIBS ${Qt5Widgets_LIBRARIES} ${Qt5Gui_LIBRARIES} ${Qt5Network_LIBRARIES} ${Qt5Xml_LIBRARIES} ${Qt5Core_LIBRARIES} ${my-qt-deps}) + SET(MY_QT_LIBS ${Qt5Widgets_LIBRARIES} ${Qt5Gui_LIBRARIES} + ${Qt5Network_LIBRARIES} ${Qt5Xml_LIBRARIES} ${Qt5Core_LIBRARIES} ${Qt5SerialPort_LIBRARIES} ${my-qt-deps}) endif() add_library(opentrack-csv SHARED ${opentrack-csv-c} ${opentrack-csv-h}) @@ -532,7 +533,7 @@ if(SDK_ARUCO_LIBPATH) 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) +target_link_libraries(opentrack-tracker-hatire ${MY_QT_LIBS}) 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") -- cgit v1.2.3 From 7f4488ae5337c7e943140ed5dd1e7a8536e41508 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 27 Nov 2013 03:22:16 +0100 Subject: cmake cleanup --- CMakeLists.txt | 61 +++++++++++++++------------------------------------------- 1 file changed, 15 insertions(+), 46 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7ff5268e..e48c02de 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -432,7 +432,7 @@ if(UNIX AND SDK_ENABLE_LIBEVDEV) SET_TARGET_PROPERTIES(opentrack-proto-libevdev PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt") endif() - install(TARGETS opentrack-proto-libevdev DESTINATION .) + install(TARGETS opentrack-proto-libevdev RUNTIME DESTINATION .) endif() if(WIN32) @@ -534,11 +534,11 @@ 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}) +install(TARGETS opentrack-tracker-hatire RUNTIME DESTINATION .) 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() -install(TARGETS opentrack-tracker-hatire RUNTIME DESTINATION . LIBRARY DESTINATION .) if(WIN32) target_link_libraries(opentrack-tracker-ht @@ -636,9 +636,10 @@ if(SDK_HYDRA) set(sixense-plat linux) endif() install(FILES - "${SDK_HYDRA}/lib/${sixense-plat}${underscore-sixtyfour}/release${underscore-dll}/libsixense${underscore-sixtyfour}.${soext}" - "${SDK_HYDRA}/lib/${sixense-plat}${underscore-sixtyfour}/release${underscore-dll}/libsixense_utils${underscore-sixtyfour}.${soext}" - DESTINATION .) + "${SDK_HYDRA}/lib/${sixense-plat}${underscore-sixtyfour}/release${underscore-dll}/libsixense${underscore-sixtyfour}.${soext}" + "${SDK_HYDRA}/lib/${sixense-plat}${underscore-sixtyfour}/release${underscore-dll}/libsixense_utils${underscore-sixtyfour}.${soext}" + DESTINATION . + ) target_link_libraries(opentrack-tracker-hydra "${SDK_HYDRA}/lib/${sixense-plat}${underscore-sixtyfour}/release${underscore-dll}/libsixense${underscore-sixtyfour}.${soext}" "${SDK_HYDRA}/lib/${sixense-plat}${underscore-sixtyfour}/release${underscore-dll}/libsixense_utils${underscore-sixtyfour}.${soext}") endif() if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) @@ -688,7 +689,7 @@ target_link_libraries(opentrack ${OpenCV_LIBS}) include_directories(${OpenCV_INCLUDE_DIRS}) if(UNIX) - install(TARGETS opentrack-qxt-mini DESTINATION .) + install(TARGETS opentrack-qxt-mini RUNTIME DESTINATION .) endif() if(WIN32) @@ -722,11 +723,11 @@ set_target_properties(opentrack PROPERTIES COMPILE_FLAGS -DOPENTRACK_MAIN) install(FILES "${CMAKE_SOURCE_DIR}/README.md" DESTINATION .) if(SDK_XPLANE) - install(TARGETS opentrack-xplane-plugin LIBRARY DESTINATION . NAMELINK_SKIP) + install(TARGETS opentrack-xplane-plugin RUNTIME DESTINATION .) endif() if(WIN32) install(DIRECTORY "${CMAKE_SOURCE_DIR}/bin/tracker-ht" DESTINATION .) - install(TARGETS freetrackclient RUNTIME DESTINATION .) + install(TARGETS freetrackclient RUNTIME DESTINATION .) endif() install(DIRECTORY "${CMAKE_SOURCE_DIR}/3rdparty-notices" DESTINATION .) @@ -736,7 +737,7 @@ install(DIRECTORY "${CMAKE_SOURCE_DIR}/bin/settings" "${CMAKE_SOURCE_DIR}/facetr if(NOT WIN32 AND SDK_WINE_PREFIX) install(FILES "${CMAKE_BINARY_DIR}/opentrack-wrapper-wine.exe.so" DESTINATION .) - install(TARGETS opentrack-proto-wine DESTINATION .) + install(TARGETS opentrack-proto-wine RUNTIME DESTINATION .) endif() install(TARGETS opentrack-tracker-pt RUNTIME DESTINATION . LIBRARY DESTINATION .) @@ -759,47 +760,32 @@ install(TARGETS opentrack opentrack-api RUNTIME DESTINATION . - LIBRARY DESTINATION . - NAMELINK_SKIP ) if(WIN32) - install(TARGETS opentrack-tracker-joystick RUNTIME DESTINATION . LIBRARY DESTINATION . NAMELINK_SKIP) + install(TARGETS opentrack-tracker-joystick RUNTIME DESTINATION .) endif() if(WIN32 AND SDK_VJOY) - install(TARGETS opentrack-proto-vjoy - RUNTIME DESTINATION . - LIBRARY DESTINATION . - NAMELINK_SKIP) + install(TARGETS opentrack-proto-vjoy RUNTIME DESTINATION .) install(FILES "${SDK_VJOY}/VJoy.dll" DESTINATION .) endif() if(SDK_RIFT) - install( - TARGETS opentrack-tracker-rift - RUNTIME DESTINATION . - LIBRARY DESTINATION . - NAMELINK_SKIP - ) + install(TARGETS opentrack-tracker-rift RUNTIME DESTINATION .) endif() if(SDK_HYDRA) install( TARGETS opentrack-tracker-hydra RUNTIME DESTINATION . - LIBRARY DESTINATION . - NAMELINK_SKIP ) endif() if(WIN32) install(FILES "${CMAKE_SOURCE_DIR}/bin/cleye.config" DESTINATION .) if(SDK_SIMCONNECT) - install(TARGETS opentrack-proto-simconnect - RUNTIME DESTINATION . - LIBRARY DESTINATION . - NAMELINK_SKIP) + install(TARGETS opentrack-proto-simconnect RUNTIME DESTINATION .) endif() if(NOT SDK_OPENCV_STATIC) get_filename_component(opentrack-opencv-dir "${OpenCV_LIB_DIR_OPT}" PATH) @@ -818,31 +804,14 @@ if(WIN32) ) install(FILES ${opentrack-opencv-files} DESTINATION .) endif() - if(WIN32 AND NOT CMAKE_COMPILER_IS_GNUCC) - GET_FILENAME_COMPONENT(qt-dirname "${Qt5Core_DIR}" PATH) - SET(qt-dirname "${qt-dirname}/../../bin") - install(FILES - "${qt-dirname}/Qt5Core.dll" - "${qt-dirname}/Qt5Gui.dll" - "${qt-dirname}/Qt5Widgets.dll" - "${qt-dirname}/Qt5Network.dll" - "${qt-dirname}/Qt5Xml.dll" - DESTINATION . - ) - endif() install(TARGETS opentrack-proto-freetrack opentrack-proto-win32-mouse #opentrack-proto-simconnect RUNTIME DESTINATION . - LIBRARY DESTINATION . - NAMELINK_SKIP ) if(SDK_FSUIPC) - install(TARGETS opentrack-proto-fsuipc - RUNTIME DESTINATION . - LIBRARY DESTINATION . - NAMELINK_SKIP) + install(TARGETS opentrack-proto-fsuipc RUNTIME DESTINATION .) endif() endif() -- cgit v1.2.3 From 72aac33d3f6e9697b0183f51eaacf8fd454a259f Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 27 Nov 2013 04:15:58 +0100 Subject: convert icon to .png, doesn't work on win32 ironically --- ftnoir_tracker_hatire/ftnoir_hat.qrc | 8 ++++---- ftnoir_tracker_hatire/ftnoir_hatcontrols.ui | 8 ++++---- ftnoir_tracker_hatire/ftnoir_tracker_hat_dll.cpp | 2 +- ftnoir_tracker_hatire/images/hat.ico | Bin 1150 -> 0 bytes ftnoir_tracker_hatire/images/hat.png | Bin 0 -> 376 bytes 5 files changed, 9 insertions(+), 9 deletions(-) delete mode 100644 ftnoir_tracker_hatire/images/hat.ico create mode 100644 ftnoir_tracker_hatire/images/hat.png diff --git a/ftnoir_tracker_hatire/ftnoir_hat.qrc b/ftnoir_tracker_hatire/ftnoir_hat.qrc index 4c606f92..ad67b862 100644 --- a/ftnoir_tracker_hatire/ftnoir_hat.qrc +++ b/ftnoir_tracker_hatire/ftnoir_hat.qrc @@ -1,6 +1,6 @@ - - images/hat.ico - images/hat_logo.png - + + images/hat_logo.png + images/hat.png + diff --git a/ftnoir_tracker_hatire/ftnoir_hatcontrols.ui b/ftnoir_tracker_hatire/ftnoir_hatcontrols.ui index 8882fffb..97db404f 100644 --- a/ftnoir_tracker_hatire/ftnoir_hatcontrols.ui +++ b/ftnoir_tracker_hatire/ftnoir_hatcontrols.ui @@ -30,7 +30,7 @@ - images/hat.icoimages/hat.ico + images/hat.pngimages/hat.png 1.000000000000000 @@ -57,15 +57,15 @@ - 1 + 0 true - - :/images/hat.ico:/images/hat.ico + + :/images/hat.png:/images/hat.png General diff --git a/ftnoir_tracker_hatire/ftnoir_tracker_hat_dll.cpp b/ftnoir_tracker_hatire/ftnoir_tracker_hat_dll.cpp index c19f68d3..cd1475f8 100644 --- a/ftnoir_tracker_hatire/ftnoir_tracker_hat_dll.cpp +++ b/ftnoir_tracker_hatire/ftnoir_tracker_hat_dll.cpp @@ -29,7 +29,7 @@ void FTNoIR_TrackerDll::getDescription(QString *strToBeFilled) void FTNoIR_TrackerDll::getIcon(QIcon *icon) { - *icon = QIcon(":/images/hat.ico"); + *icon = QIcon(":/images/hat.png"); } extern "C" FTNOIR_TRACKER_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata() diff --git a/ftnoir_tracker_hatire/images/hat.ico b/ftnoir_tracker_hatire/images/hat.ico deleted file mode 100644 index d8f5aac4..00000000 Binary files a/ftnoir_tracker_hatire/images/hat.ico and /dev/null differ diff --git a/ftnoir_tracker_hatire/images/hat.png b/ftnoir_tracker_hatire/images/hat.png new file mode 100644 index 00000000..46a6e442 Binary files /dev/null and b/ftnoir_tracker_hatire/images/hat.png differ -- cgit v1.2.3 From 994777d9c56ce7f8e57f0cf8e29e1eeb3b028dfc Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 27 Nov 2013 04:16:28 +0100 Subject: do NOT use linker scripts on win32, breaks with stdcall prefix! --- CMakeLists.txt | 81 +++++++++++++++++++++++----------------------------------- 1 file changed, 32 insertions(+), 49 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e48c02de..e9cdbd3b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -391,7 +391,7 @@ target_link_libraries(opentrack-spline-widget ${MY_QT_LIBS}) add_library(opentrack-filter-accela SHARED ${opentrack-filter-accela-c} ${opentrack-filter-accela-h} ${opentrack-filter-accela-moc} ${opentrack-filter-accela-uih} ${opentrack-filter-accela-rcc}) target_link_libraries(opentrack-filter-accela ${MY_QT_LIBS}) -if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) +if(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32) SET_TARGET_PROPERTIES(opentrack-filter-accela PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt") endif() @@ -399,14 +399,14 @@ endif() add_library(opentrack-filter-ewma SHARED ${opentrack-filter-ewma-uih} ${opentrack-filter-ewma-c} ${opentrack-filter-ewma-h} ${opentrack-filter-ewma-moc} ${opentrack-filter-ewma-rcc}) target_link_libraries(opentrack-filter-ewma ${MY_QT_LIBS}) -if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) +if(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32) SET_TARGET_PROPERTIES(opentrack-filter-ewma PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt") endif() add_library(opentrack-proto-fgfs SHARED ${opentrack-proto-fgfs-c} ${opentrack-proto-fgfs-h} ${opentrack-proto-fgfs-moc} ${opentrack-proto-fgfs-uih} ${opentrack-proto-fgfs-rcc}) target_link_libraries(opentrack-proto-fgfs ${MY_QT_LIBS}) -if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) +if(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32) SET_TARGET_PROPERTIES(opentrack-proto-fgfs PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt") endif() @@ -419,7 +419,7 @@ if(WIN32 AND SDK_VJOY) else() target_link_libraries(opentrack-proto-vjoy ${MY_QT_LIBS} "${SDK_VJOY}/VJoy.dll") endif() - if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) + if(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32) SET_TARGET_PROPERTIES(opentrack-proto-vjoy PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt -Wl,--enable-stdcall-fixup") endif() @@ -428,11 +428,11 @@ endif() if(UNIX AND SDK_ENABLE_LIBEVDEV) add_library(opentrack-proto-libevdev SHARED ${opentrack-proto-libevdev-c} ${opentrack-proto-libevdev-h} ${opentrack-proto-libevdev-moc} ${opentrack-proto-libevdev-uih} ${opentrack-proto-libevdev-rcc}) target_link_libraries(opentrack-proto-libevdev ${MY_QT_LIBS} evdev) - if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) + if(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32) SET_TARGET_PROPERTIES(opentrack-proto-libevdev PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt") endif() - install(TARGETS opentrack-proto-libevdev RUNTIME DESTINATION .) + install(TARGETS opentrack-proto-libevdev DESTINATION .) endif() if(WIN32) @@ -468,7 +468,7 @@ endif() add_library(opentrack-proto-udp SHARED ${opentrack-proto-udp-c} ${opentrack-proto-udp-h} ${opentrack-proto-udp-moc} ${opentrack-proto-udp-uih} ${opentrack-proto-udp-rcc}) target_link_libraries(opentrack-proto-udp ${MY_QT_LIBS}) -if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) +if(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32) SET_TARGET_PROPERTIES(opentrack-proto-udp PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt") endif() @@ -476,7 +476,7 @@ endif() if(WIN32) add_library(opentrack-tracker-joystick SHARED ${opentrack-tracker-joystick-c} ${opentrack-tracker-joystick-h} ${opentrack-tracker-joystick-moc} ${opentrack-tracker-joystick-uih} ${opentrack-tracker-joystick-rcc}) target_link_libraries(opentrack-tracker-joystick ${MY_QT_LIBS}) - if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) + if(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32) SET_TARGET_PROPERTIES(opentrack-tracker-joystick PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt") endif() @@ -485,7 +485,7 @@ endif() if(NOT WIN32 AND SDK_WINE_PREFIX) add_library(opentrack-proto-wine SHARED ${opentrack-proto-wine-c} ${opentrack-proto-wine-h} ${opentrack-proto-wine-moc} ${opentrack-proto-wine-uih} ${opentrack-proto-wine-rcc}) target_link_libraries(opentrack-proto-wine ${MY_QT_LIBS} opentrack-compat opentrack-csv) - if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) + if(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32) SET_TARGET_PROPERTIES(opentrack-proto-wine PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt") endif() @@ -510,14 +510,14 @@ if(NOT WIN32 AND SDK_WINE_PREFIX) endif() endif() -if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) +if(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32) SET_TARGET_PROPERTIES(opentrack-proto-fgfs PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt") endif() add_library(opentrack-tracker-ht SHARED ${opentrack-tracker-ht-c} ${opentrack-tracker-ht-h} ${opentrack-tracker-ht-moc} ${opentrack-tracker-ht-uih} ${opentrack-tracker-ht-rcc}) target_link_libraries(opentrack-tracker-ht ${MY_QT_LIBS} opentrack-compat) -if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) +if(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32) SET_TARGET_PROPERTIES(opentrack-tracker-ht PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt") endif() @@ -526,7 +526,7 @@ if(SDK_ARUCO_LIBPATH) include_directories(${CMAKE_SOURCE_DIR}/ftnoir_tracker_aruco/include) add_library(opentrack-tracker-aruco SHARED ${opentrack-tracker-aruco-c} ${opentrack-tracker-aruco-h} ${opentrack-tracker-aruco-moc} ${opentrack-tracker-aruco-uih} ${opentrack-tracker-aruco-rcc}) target_link_libraries(opentrack-tracker-aruco ${MY_QT_LIBS} ${SDK_ARUCO_LIBPATH} ${OpenCV_LIBS}) - if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) + if(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32) SET_TARGET_PROPERTIES(opentrack-tracker-aruco PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt") endif() @@ -534,8 +534,8 @@ 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}) -install(TARGETS opentrack-tracker-hatire RUNTIME DESTINATION .) -if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) +install(TARGETS opentrack-tracker-hatire DESTINATION .) +if(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32) SET_TARGET_PROPERTIES(opentrack-tracker-hatire PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt") endif() @@ -559,7 +559,7 @@ if(APPLE) SET_TARGET_PROPERTIES(opentrack-tracker-pt PROPERTIES COMPILE_FLAGS "-std=c++11") endif() -if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) +if(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32) SET_TARGET_PROPERTIES(opentrack-tracker-pt PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt") endif() @@ -574,7 +574,7 @@ endif() add_library(opentrack-tracker-udp SHARED ${opentrack-tracker-udp-c} ${opentrack-tracker-udp-h} ${opentrack-tracker-udp-moc} ${opentrack-tracker-udp-uih} ${opentrack-tracker-udp-rcc}) target_link_libraries(opentrack-tracker-udp ${MY_QT_LIBS}) -if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) +if(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32) SET_TARGET_PROPERTIES(opentrack-tracker-udp PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt") endif() @@ -597,7 +597,7 @@ if(SDK_RIFT) endif() endif() endif() - if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) + if(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32) SET_TARGET_PROPERTIES(opentrack-tracker-rift PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt" @@ -642,7 +642,7 @@ if(SDK_HYDRA) ) target_link_libraries(opentrack-tracker-hydra "${SDK_HYDRA}/lib/${sixense-plat}${underscore-sixtyfour}/release${underscore-dll}/libsixense${underscore-sixtyfour}.${soext}" "${SDK_HYDRA}/lib/${sixense-plat}${underscore-sixtyfour}/release${underscore-dll}/libsixense_utils${underscore-sixtyfour}.${soext}") endif() - if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) + if(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32) SET_TARGET_PROPERTIES(opentrack-tracker-hydra PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt") endif() @@ -689,7 +689,7 @@ target_link_libraries(opentrack ${OpenCV_LIBS}) include_directories(${OpenCV_INCLUDE_DIRS}) if(UNIX) - install(TARGETS opentrack-qxt-mini RUNTIME DESTINATION .) + install(TARGETS opentrack-qxt-mini DESTINATION .) endif() if(WIN32) @@ -723,11 +723,11 @@ set_target_properties(opentrack PROPERTIES COMPILE_FLAGS -DOPENTRACK_MAIN) install(FILES "${CMAKE_SOURCE_DIR}/README.md" DESTINATION .) if(SDK_XPLANE) - install(TARGETS opentrack-xplane-plugin RUNTIME DESTINATION .) + install(TARGETS opentrack-xplane-plugin DESTINATION .) endif() if(WIN32) install(DIRECTORY "${CMAKE_SOURCE_DIR}/bin/tracker-ht" DESTINATION .) - install(TARGETS freetrackclient RUNTIME DESTINATION .) + install(TARGETS freetrackclient DESTINATION .) endif() install(DIRECTORY "${CMAKE_SOURCE_DIR}/3rdparty-notices" DESTINATION .) @@ -737,13 +737,13 @@ install(DIRECTORY "${CMAKE_SOURCE_DIR}/bin/settings" "${CMAKE_SOURCE_DIR}/facetr if(NOT WIN32 AND SDK_WINE_PREFIX) install(FILES "${CMAKE_BINARY_DIR}/opentrack-wrapper-wine.exe.so" DESTINATION .) - install(TARGETS opentrack-proto-wine RUNTIME DESTINATION .) + install(TARGETS opentrack-proto-wine DESTINATION .) endif() -install(TARGETS opentrack-tracker-pt RUNTIME DESTINATION . LIBRARY DESTINATION .) +install(TARGETS opentrack-tracker-pt DESTINATION .) if(SDK_ARUCO_LIBPATH) - install(TARGETS opentrack-tracker-aruco RUNTIME DESTINATION . LIBRARY DESTINATION .) + install(TARGETS opentrack-tracker-aruco DESTINATION .) endif() install(TARGETS @@ -759,59 +759,42 @@ install(TARGETS opentrack-tracker-udp opentrack opentrack-api - RUNTIME DESTINATION . + DESTINATION . ) if(WIN32) - install(TARGETS opentrack-tracker-joystick RUNTIME DESTINATION .) + install(TARGETS opentrack-tracker-joystick DESTINATION .) endif() if(WIN32 AND SDK_VJOY) - install(TARGETS opentrack-proto-vjoy RUNTIME DESTINATION .) + install(TARGETS opentrack-proto-vjoy DESTINATION .) install(FILES "${SDK_VJOY}/VJoy.dll" DESTINATION .) endif() if(SDK_RIFT) - install(TARGETS opentrack-tracker-rift RUNTIME DESTINATION .) + install(TARGETS opentrack-tracker-rift DESTINATION .) endif() if(SDK_HYDRA) install( TARGETS opentrack-tracker-hydra - RUNTIME DESTINATION . + DESTINATION . ) endif() if(WIN32) install(FILES "${CMAKE_SOURCE_DIR}/bin/cleye.config" DESTINATION .) if(SDK_SIMCONNECT) - install(TARGETS opentrack-proto-simconnect RUNTIME DESTINATION .) - endif() - if(NOT SDK_OPENCV_STATIC) - get_filename_component(opentrack-opencv-dir "${OpenCV_LIB_DIR_OPT}" PATH) - if(WIN32 AND NOT CMAKE_COMPILER_IS_GNUCC) - set(LIB-PREFIX "../bin/Release/") - else() - set(LIB-PREFIX "lib") - endif() - file(GLOB opentrack-opencv-files - "${opentrack-opencv-dir}/${LIB-PREFIX}opencv_calib3d*.dll" - "${opentrack-opencv-dir}/${LIB-PREFIX}opencv_core*.dll" - "${opentrack-opencv-dir}/${LIB-PREFIX}opencv_highgui*.dll" - "${opentrack-opencv-dir}/${LIB-PREFIX}opencv_imgproc*.dll" - "${opentrack-opencv-dir}/${LIB-PREFIX}opencv_flann*.dll" - "${opentrack-opencv-dir}/${LIB-PREFIX}opencv_features2d*.dll" - ) - install(FILES ${opentrack-opencv-files} DESTINATION .) + install(TARGETS opentrack-proto-simconnect DESTINATION .) endif() install(TARGETS opentrack-proto-freetrack opentrack-proto-win32-mouse #opentrack-proto-simconnect - RUNTIME DESTINATION . + DESTINATION . ) if(SDK_FSUIPC) - install(TARGETS opentrack-proto-fsuipc RUNTIME DESTINATION .) + install(TARGETS opentrack-proto-fsuipc DESTINATION .) endif() endif() -- 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 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 ba8f910d7a59be2979e513f28f645571e5c95920 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 27 Nov 2013 19:13:41 +0100 Subject: hatire: use less-precise timers, for speed Signed-off-by: Stanislaw Halik --- ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp b/ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp index 99baf75b..d7bcffc1 100644 --- a/ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp +++ b/ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp @@ -129,7 +129,7 @@ void FTNoIR_Tracker::run() { SerialPort->read(1); } } - usleep(10000); + msleep(10); } } -- cgit v1.2.3 From aeac8a4b7199d0705b803f06bb2c1d443821d252 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 27 Nov 2013 19:18:54 +0100 Subject: pt, hatire: save settings in correct place Signed-off-by: Stanislaw Halik --- FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.cpp | 8 ++++---- ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.cpp | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.cpp b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.cpp index db908465..62ba1e3e 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.cpp +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.cpp @@ -14,7 +14,7 @@ void TrackerSettings::load_ini() { qDebug("TrackerSettings::load_ini()"); - QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // 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) @@ -59,7 +59,7 @@ void TrackerSettings::save_ini() const { qDebug("TrackerSettings::save_ini()"); - QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // 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) @@ -105,7 +105,7 @@ void TrackerDialogSettings::load_ini() { qDebug("TrackerDialogSettings::load_ini()"); - QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // 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) @@ -131,7 +131,7 @@ void TrackerDialogSettings::save_ini() const { qDebug("TrackerDialogSettings::save_ini()"); - QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // 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) diff --git a/ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.cpp b/ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.cpp index 1d2643ee..a9466304 100644 --- a/ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.cpp +++ b/ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.cpp @@ -6,7 +6,7 @@ void TrackerSettings::load_ini() { qDebug("TrackerSettings::load_ini()"); - QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // 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) @@ -45,7 +45,7 @@ void TrackerSettings::save_ini() const { qDebug("TrackerSettings::save_ini()"); - QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // 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) -- cgit v1.2.3 From 21dbb51ed05bffa69f036c6b82842aa0069b624f Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 27 Nov 2013 19:24:41 +0100 Subject: furax49's copyright https://sourceforge.net/p/hatire/code/ci/5f323520c47437079f559d0ff4f2c2de0ce81098/tree/ftnoir_tracker_hat.cpp#l11 Signed-off-by: Stanislaw Halik --- ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp | 146 +++++++++++++++------------ 1 file changed, 82 insertions(+), 64 deletions(-) diff --git a/ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp b/ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp index d7bcffc1..fbe97854 100644 --- a/ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp +++ b/ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp @@ -1,4 +1,22 @@ -/* code by Furax49, awaiting copyright information */ +/******************************************************************************** + * 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 "facetracknoir/global-settings.h" @@ -9,13 +27,13 @@ FTNoIR_Tracker::FTNoIR_Tracker() : SerialPort(nullptr), stop(false) { - TrackerSettings settings; - settings.load_ini(); - applysettings(settings); + TrackerSettings settings; + settings.load_ini(); + applysettings(settings); //ListErrInf = new QList(); - datagram.reserve(30); + datagram.reserve(30); qDebug() << "FTNoIR_Tracker::Initialize() Open SerialPort"; SerialPort = new QSerialPort(sSerialPortName); if (SerialPort->open(QIODevice::ReadWrite | QIODevice::Unbuffered ) == true) { @@ -40,68 +58,68 @@ FTNoIR_Tracker::~FTNoIR_Tracker() { stop = true; wait(); - if (SerialPort!=NULL) { - if (SerialPort->isOpen() ) { - SerialPort->putChar('s'); //Send STOP to Arduino - SerialPort->close(); - } - delete SerialPort; - SerialPort=NULL; - } + 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'); - } - } + 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'); - } - } + 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'); - } - } + if (SerialPort!=NULL) { + if (SerialPort->isOpen() ) { + SerialPort->putChar('R'); + } + } } //send command to Arduino void FTNoIR_Tracker::sendcmd(QString* cmd) { QMutexLocker locker(&lock); - QByteArray bytes; - if (SerialPort!=NULL) { - if (SerialPort->isOpen() ) { + QByteArray bytes; + if (SerialPort!=NULL) { + if (SerialPort->isOpen() ) { bytes.append(cmd->toLatin1()); SerialPort->write(bytes); - } - } + } + } } // return FPS and last status void FTNoIR_Tracker::get_info(QString*, int* tps ){ QMutexLocker locker(&lock); - *tps=HAT.Code; + *tps=HAT.Code; #if 0 - if (ListErrInf->size()>0) { - *info=ListErrInf->takeFirst(); - } else { - *info= QString(); - } + if (ListErrInf->size()>0) { + *info=ListErrInf->takeFirst(); + } else { + *info= QString(); + } #endif } @@ -115,28 +133,28 @@ void FTNoIR_Tracker::run() { if (SerialPort->bytesAvailable()>=30) { QMutexLocker locker(&lock); - datagram.clear(); - datagram=SerialPort->read(30); + datagram.clear(); + datagram=SerialPort->read(30); QDataStream datastream(datagram); datastream >> ArduinoData; if (ArduinoData.Begin==0xAAAA && ArduinoData.End==0x5555 ) { if (ArduinoData.Code <= 1000) { - HAT=ArduinoData; + HAT=ArduinoData; } - } else { - SerialPort->read(1); - } - } + } else { + SerialPort->read(1); + } + } msleep(10); - } + } } void FTNoIR_Tracker::StartTracker( QFrame* ) { - start( QThread::TimeCriticalPriority ); - return; + start( QThread::TimeCriticalPriority ); + return; } bool FTNoIR_Tracker::GiveHeadPoseData(double* data) @@ -165,24 +183,24 @@ bool FTNoIR_Tracker::GiveHeadPoseData(double* data) } void FTNoIR_Tracker::applysettings(const TrackerSettings& settings){ - qDebug()<<"Tracker:: Applying settings"; + qDebug()<<"Tracker:: Applying settings"; QMutexLocker locker(&lock); - sSerialPortName= settings.SerialPortName; + sSerialPortName= settings.SerialPortName; - bEnableRoll = settings.EnableRoll; - bEnablePitch = settings.EnablePitch; - bEnableYaw = settings.EnableYaw; - bEnableX = settings.EnableX; - bEnableY = settings.EnableY; - bEnableZ = settings.EnableZ; + 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; + bInvertRoll = settings.InvertRoll; + bInvertPitch = settings.InvertPitch; + bInvertYaw = settings.InvertYaw; + bInvertX = settings.InvertX; + bInvertY = settings.InvertY; + bInvertZ = settings.InvertZ; iRollAxis= settings.RollAxis; @@ -195,5 +213,5 @@ void FTNoIR_Tracker::applysettings(const TrackerSettings& settings){ extern "C" FTNOIR_TRACKER_BASE_EXPORT ITracker* CALLING_CONVENTION GetConstructor() { - return new FTNoIR_Tracker; + return new FTNoIR_Tracker; } -- cgit v1.2.3 From 9990b05efb6fcd806ec5d996310f4a945a0b0fac Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 27 Nov 2013 19:52:03 +0100 Subject: merge in the right hatire branch this time! Signed-off-by: Stanislaw Halik --- ftnoir_tracker_hatire/ftnoir_arduino_type.h | 22 +- ftnoir_tracker_hatire/ftnoir_hatcontrols.ui | 993 ++++++++++++++------- ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp | 622 +++++++++---- ftnoir_tracker_hatire/ftnoir_tracker_hat.h | 122 ++- .../ftnoir_tracker_hat_dialog.cpp | 260 +++++- ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.h | 56 +- ftnoir_tracker_hatire/ftnoir_tracker_hat_dll.cpp | 59 +- .../ftnoir_tracker_hat_settings.cpp | 99 +- .../ftnoir_tracker_hat_settings.h | 43 +- 9 files changed, 1650 insertions(+), 626 deletions(-) diff --git a/ftnoir_tracker_hatire/ftnoir_arduino_type.h b/ftnoir_tracker_hatire/ftnoir_arduino_type.h index 7f550579..bd5c4246 100644 --- a/ftnoir_tracker_hatire/ftnoir_arduino_type.h +++ b/ftnoir_tracker_hatire/ftnoir_arduino_type.h @@ -1,30 +1,30 @@ #ifndef FTNOIR_TARDUINO_TYPE_H #define FTNOIR_TARDUINO_TYPE_H -#include - -// Arduino frame structure +// Arduino trame structure #pragma pack(push,2) struct TArduinoData { quint16 Begin; // Header trame 0xAAAA; - quint16 Code; // 0->999 Num Frame >=2000 Info >=3000 Init >=5000 Start Command >=9000 Error - float Gyro[3]; - float Acc[3]; - quint16 End; // End frame 0x5555; + 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.setByteOrder(QDataStream::LittleEndian ); in.setFloatingPointPrecision(QDataStream::SinglePrecision ); - in >> out.Begin >> out.Code - >> out.Gyro[0] >> out.Gyro[1] >> out.Gyro[2] - >> out.Acc[0] >> out.Acc[1] >> out.Acc[2] + 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_hatcontrols.ui b/ftnoir_tracker_hatire/ftnoir_hatcontrols.ui index 97db404f..4446ca85 100644 --- a/ftnoir_tracker_hatire/ftnoir_hatcontrols.ui +++ b/ftnoir_tracker_hatire/ftnoir_hatcontrols.ui @@ -6,20 +6,20 @@ 0 0 - 370 - 520 + 307 + 509 - 370 - 520 + 0 + 0 - 370 - 520 + 65536 + 65536 @@ -30,7 +30,7 @@ - images/hat.pngimages/hat.png + :/images/hat.ico:/images/hat.ico 1.000000000000000 @@ -41,69 +41,111 @@ false - + + + + + + 0 + 0 + + + + + 80 + 25 + + + + + 80 + 25 + + + + Cancel + + + + + + + + 0 + 0 + + + + + 80 + 25 + + + + + 80 + 25 + + + + OK + + + - 360 - 470 + 0 + 0 - 360 - 470 + 65535 + 65535 0 - - true - - - - :/images/hat.png:/images/hat.png - General - - - + + + - - - - - - 80 - 20 - - - - Center + + true + + + + 4 + + + + + + 0 + 0 + - - - - - + - 80 - 20 + 65536 + 16777215 - Reset + Serial port - + @@ -113,7 +155,7 @@ - 100 + 65535 16777215 @@ -128,20 +170,49 @@ - - - - Arduino serial port - - - true - - - - + + + + + 80 + 20 + + + + Zero + + + + + + + + 80 + 20 + + + + Center + + + + + + + + 80 + 20 + + + + Reset + + + + @@ -150,14 +221,36 @@ - Axis selection + Axis Configuration Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - + + + + + Associate Axis + + + + RotX + + + + + RotY + + + + + RotZ + + + + + + 20 @@ -175,8 +268,8 @@ - - + + 20 @@ -184,43 +277,32 @@ - Invert Axis + Enable Axis Qt::LeftToRight - - - - - - - Associate Axis + + + + Pitch: - - - X - - - - - Y - - - - - Z - - - - + + + + Enable + + + + + 20 @@ -238,29 +320,29 @@ - - + + - X + Yaw: - - + + - Pitch + Invert - - + + - Z + Y: - - + + 20 @@ -281,30 +363,15 @@ - - - - Associate Axis + + + + X: - - - Yaw - - - - - Pitch - - - - - Roll - - - - + + 20 @@ -312,17 +379,42 @@ - Enable Axis + Invert Axis Qt::LeftToRight + + + + + + + 20 + 16777215 + + + + Invert Axis + + + Qt::LeftToRight + + + + + + + + + + Associate Axis @@ -344,8 +436,8 @@ - - + + 20 @@ -353,40 +445,47 @@ - Invert Axis + Enable Axis Qt::LeftToRight - - - - - - - 20 - 16777215 - - + - Enable Axis - - - Qt::LeftToRight + Associate Axis + + + X + + + + + Y + + + + + Z + + + + + + - + Roll: - - + + 20 @@ -407,70 +506,30 @@ - - + + Associate Axis - Yaw + X - Pitch + Y - Roll + Z - - - - - 20 - 16777215 - - - - Enable Axis - - - Qt::LeftToRight - - - - - - - - - - Input - - - - - - - Invert - - - - - - - Yaw - - - - - + + 20 @@ -478,7 +537,7 @@ - Enable Axis + Invert Axis Qt::LeftToRight @@ -491,52 +550,37 @@ - - - - Associate Axis + + + + Z: - - - X - - - - - Y - - - - - Z - - - - + + Associate Axis - Yaw + RotX - Pitch + RotY - Roll + RotZ - - + + 20 @@ -544,7 +588,7 @@ - Invert Axis + Enable Axis Qt::LeftToRight @@ -557,15 +601,27 @@ - - + + + + + 20 + 16777215 + + + + Enable Axis + + + Qt::LeftToRight + - Y + - - + + 20 @@ -586,48 +642,65 @@ - - - - Roll + + + + Associate Axis + + + RotX + + + + + RotY + + + + + RotZ + + - - - Enable - - - - - + - Output + Axis - + + + + 0 + 0 + + - Information + Status - + + false + + 31 - 0 + 20 60 - 13 + 20 @@ -638,37 +711,56 @@ - - + + - 170 - 0 + 31 + 20 60 - 16777215 + 20 - + 00 - - + + - 31 - 0 + 0 + 20 + + + + + 60 + 20 + + + + Info : + + + + + + + + 170 + 20 60 - 13 + 20 @@ -676,16 +768,255 @@ + + + + + + + + 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 - - Status : + + <!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 @@ -698,50 +1029,97 @@ About - + - + <!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> +<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 - - + + + + false + - - :/images/hat_logo.png + + + :/images/hat_logo.png + + + + + 128 + 128 + + + + true + + + + + + + + Arial Black + 10 + 75 + true + true + + + + Version 1.0.0 + + + Qt::PlainText + + + true - + + + + Send + + + + + + Qt::ActionsContextMenu + true + + + + + Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + 800 - - - - - - Send + + false @@ -749,31 +1127,6 @@ p, li { white-space: pre-wrap; } - - - - - 0 - 0 - - - - - 80 - 25 - - - - - 80 - 25 - - - - OK - - - @@ -793,39 +1146,41 @@ p, li { white-space: pre-wrap; } - - - - - 0 - 0 - - - - - 80 - 25 - - - - - 80 - 25 - - - - Cancel - - - + 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() diff --git a/ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp b/ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp index fbe97854..b933dd14 100644 --- a/ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp +++ b/ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp @@ -1,217 +1,501 @@ /******************************************************************************** - * 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 . * - * * - ********************************************************************************/ - +* 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 "facetracknoir/global-settings.h" -#include -#include -FTNoIR_Tracker::FTNoIR_Tracker() : - SerialPort(nullptr), - stop(false) +FTNoIR_Tracker::FTNoIR_Tracker() { - TrackerSettings settings; - settings.load_ini(); - applysettings(settings); - - //ListErrInf = new QList(); - - datagram.reserve(30); - qDebug() << "FTNoIR_Tracker::Initialize() Open SerialPort"; - SerialPort = new QSerialPort(sSerialPortName); - if (SerialPort->open(QIODevice::ReadWrite | QIODevice::Unbuffered ) == true) { - SerialPort->flush(); - SerialPort->setBaudRate(115200); - SerialPort->setParity(QSerialPort::NoParity); - SerialPort->setDataBits(QSerialPort::Data8); - SerialPort->setStopBits(QSerialPort::OneStop); - SerialPort->setFlowControl(QSerialPort::NoFlowControl); - //SerialPort->setTimeout(waitTimeout); - //SerialPort->setQueryMode(QextSerialPort::EventDriven); //Polling - SerialPort->putChar('S'); - } - else { - QMessageBox::warning(0,"FaceTrackNoIR Error", "Unable to open SerialPort",QMessageBox::Ok,QMessageBox::NoButton); - delete SerialPort; - SerialPort = NULL; - } + 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); + + settings.load_ini(); } FTNoIR_Tracker::~FTNoIR_Tracker() { - stop = true; - wait(); - if (SerialPort!=NULL) { - if (SerialPort->isOpen() ) { - SerialPort->putChar('s'); //Send STOP to Arduino - SerialPort->close(); - } - delete SerialPort; - SerialPort=NULL; - } - + if (ComPort!=NULL) { + if (ComPort->isOpen() ) { + ComPort->close(); + } + delete ComPort; + ComPort=NULL; + } } //send CENTER to Arduino void FTNoIR_Tracker::notifyCenter() { - if (SerialPort!=NULL) { - if (SerialPort->isOpen() ) { - SerialPort->putChar('C'); - } - } + sendcmd(sCmdCenter); } +//send ZERO to Arduino +bool FTNoIR_Tracker::notifyZeroed() { + sendcmd(sCmdZero); + return true; +} -//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'); - } - } + sendcmd(sCmdReset); +} + + +// 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(QString* cmd) { - QMutexLocker locker(&lock); - QByteArray bytes; - if (SerialPort!=NULL) { - if (SerialPort->isOpen() ) { - bytes.append(cmd->toLatin1()); - SerialPort->write(bytes); - } - } -} - -// return FPS and last status -void FTNoIR_Tracker::get_info(QString*, int* tps ){ - QMutexLocker locker(&lock); - *tps=HAT.Code; -#if 0 - if (ListErrInf->size()>0) { - *info=ListErrInf->takeFirst(); - } else { - *info= QString(); - } -#endif +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") ; + } + } } -/** QThread run @override **/ -void FTNoIR_Tracker::run() { - if (!SerialPort) - return; - while (!stop) - { - if (SerialPort->bytesAvailable()>=30) - { - QMutexLocker locker(&lock); - 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 { - SerialPort->read(1); - } - } - msleep(10); - } -} - -void FTNoIR_Tracker::StartTracker( QFrame* ) +// return FPS +void FTNoIR_Tracker::get_info( int *tps ){ + *tps=frame_cnt; + frame_cnt=0; +} + +void FTNoIR_Tracker::SerialRead() { - start( QThread::TimeCriticalPriority ); - return; + QMutexLocker lck(&mutex); + dataRead+=ComPort->readAll(); } -bool FTNoIR_Tracker::GiveHeadPoseData(double* data) +#ifndef OPENTRACK_API +void FTNoIR_Tracker::Initialize( QFrame *videoframe ) { - QMutexLocker locker(&lock); + 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; +} - const bool inversions[] = { - bInvertX, bInvertY, bInvertZ, bInvertYaw, bInvertPitch, bInvertRoll - }; - const bool enablement[] = { - bEnableX, bEnableY, bEnableZ, bEnableYaw, bEnablePitch, bEnableRoll - }; - const int axes[] = { - iXAxis, iYAxis, iZAxis, iYawAxis, iPitchAxis, iRollAxis - }; +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; +} - for (int i = 0; i < 6; i++) - { - if (enablement[i]) - data[i] = HAT.Gyro[axes[i]] * (inversions[i] ? -1 : 1); - } - return true; +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*) +{ + 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; + } + // Send START cmd to IMU + sendcmd(sCmdStart); + + // Wait start MPU sequence + for (int i = 1; i <=iDelaySeq; 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 + +bool FTNoIR_Tracker::GiveHeadPoseData(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 (bBigEndian) 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 false; + } +#ifdef OPENTRACK_API + data[frame_cnt] = (long) HAT.Code; + + if (bEnableYaw) { + if (bInvertYaw ) data[Yaw] = (double) HAT.Rot[iYawAxe] * -1.0f; + else data[Yaw] = (double) HAT.Rot[iYawAxe]; + } + + if (bEnablePitch) { + if (bInvertPitch) data[Pitch] = (double) HAT.Rot[iPitchAxe] * -1.0f; + else data[Pitch] = (double) HAT.Rot[iPitchAxe]; + } + + if (bEnableRoll) { + if (bInvertRoll) data[Roll] = (double) HAT.Rot[iRollAxe] * -1.0f; + else data[Roll] = (double) HAT.Rot[iRollAxe]; + } + + if (bEnableX) { + if (bInvertX) data[TX] =(double) HAT.Trans[iXAxe]* -1.0f; + else data[TX] = HAT.Trans[iXAxe]; + } + + if (bEnableY) { + if (bInvertY) data[TY] =(double) HAT.Trans[iYAxe]* -1.0f; + else data[TY] = HAT.Trans[iYAxe]; + } + + if (bEnableZ) { + if (bInvertZ) data[TZ] = HAT.Trans[iZAxe]* -1.0f; + else data[TZ] = HAT.Trans[iZAxe]; + } +#else + data->frame_number = (long) HAT.Code; + + if (bEnableYaw) { + if (bInvertYaw ) data->yaw = (double) HAT.Rot[iYawAxe] * -1.0f; + else data->yaw = (double) HAT.Rot[iYawAxe]; + } + + if (bEnablePitch) { + if (bInvertPitch)data->pitch = (double) HAT.Rot[iPitchAxe] * -1.0f; + else data->pitch = (double) HAT.Rot[iPitchAxe]; + } + + if (bEnableRoll) { + if (bInvertRoll) data->roll = (double) HAT.Rot[iRollAxe] * -1.0f; + else data->roll = (double) HAT.Rot[iRollAxe]; + } + + if (bEnableX) { + if (bInvertX) data->x = (double) HAT.Trans[iXAxe]* -1.0f; + else data->x = (double) HAT.Trans[iXAxe]; + } + + if (bEnableY) { + if (bInvertY) data->y = (double) HAT.Trans[iYAxe]* -1.0f; + else data->y = (double) HAT.Trans[iYAxe]; + } + + if (bEnableZ) { + if (bInvertZ) data->z = (double) HAT.Trans[iZAxe]* -1.0f; + else data->z = (double) HAT.Trans[iZAxe]; + } +#endif + + // For debug + //data->x=dataRead.length(); + //data->y=CptError; + + return true; + +} + + + +// +// Apply modification Settings +// void FTNoIR_Tracker::applysettings(const TrackerSettings& settings){ - qDebug()<<"Tracker:: Applying settings"; + QMutexLocker lck(&mutex); + sSerialPortName= settings.SerialPortName; + + bEnableRoll = settings.EnableRoll; + bEnablePitch = settings.EnablePitch; + bEnableYaw = settings.EnableYaw; + bEnableX = settings.EnableX; + bEnableY = settings.EnableY; + bEnableZ = settings.EnableZ; - QMutexLocker locker(&lock); - sSerialPortName= settings.SerialPortName; + bInvertRoll = settings.InvertRoll; + bInvertPitch = settings.InvertPitch; + bInvertYaw = settings.InvertYaw; + bInvertX = settings.InvertX; + bInvertY = settings.InvertY; + bInvertZ = settings.InvertZ; - bEnableRoll = settings.EnableRoll; - bEnablePitch = settings.EnablePitch; - bEnableYaw = settings.EnableYaw; - bEnableX = settings.EnableX; - bEnableY = settings.EnableY; - bEnableZ = settings.EnableZ; + iRollAxe= settings.RollAxe; + iPitchAxe= settings.PitchAxe; + iYawAxe= settings.YawAxe; + iXAxe= settings.XAxe; + iYAxe= settings.YAxe; + iZAxe= settings.ZAxe; - bInvertRoll = settings.InvertRoll; - bInvertPitch = settings.InvertPitch; - bInvertYaw = settings.InvertYaw; - bInvertX = settings.InvertX; - bInvertY = settings.InvertY; - bInvertZ = settings.InvertZ; + iBaudRate=settings.pBaudRate; + iDataBits=settings.pDataBits; + iParity=settings.pParity; + iStopBits=settings.pStopBits; + iFlowControl=settings.pFlowControl; + sCmdStart= settings.CmdStart.toLatin1(); + sCmdStop= settings.CmdStop.toLatin1(); + sCmdInit= settings.CmdInit.toLatin1(); + sCmdReset= settings.CmdReset.toLatin1(); + sCmdCenter= settings.CmdCenter.toLatin1(); + sCmdZero= settings.CmdZero.toLatin1(); - iRollAxis= settings.RollAxis; - iPitchAxis= settings.PitchAxis; - iYawAxis= settings.YawAxis; - iXAxis= settings.XAxis; - iYAxis= settings.YAxis; - iZAxis= settings.ZAxis; + iDelayInit=settings.DelayInit; + iDelayStart=settings.DelayStart; + iDelaySeq=settings.DelaySeq; + + bBigEndian=settings.BigEndian; } + + +//////////////////////////////////////////////////////////////////////////////// +// 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. +//////////////////////////////////////////////////////////////////////////////// +#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; + return new FTNoIR_Tracker; } diff --git a/ftnoir_tracker_hatire/ftnoir_tracker_hat.h b/ftnoir_tracker_hatire/ftnoir_tracker_hat.h index af583d11..a1b4ecda 100644 --- a/ftnoir_tracker_hatire/ftnoir_tracker_hat.h +++ b/ftnoir_tracker_hatire/ftnoir_tracker_hat.h @@ -1,46 +1,68 @@ #ifndef FTNOIR_TRACKER_HAT_H #define FTNOIR_TRACKER_HAT_H -#include "facetracknoir/global-settings.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" +#endif #include "ftnoir_tracker_hat_settings.h" #include "ftnoir_arduino_type.h" - +#include +#include +#include +#include +#include #include -#include -#include -#include +#include #include #include -#include +#include -class FTNoIR_Tracker : public ITracker, QThread -{ +#define VER_FILEVERSION_STR "Version 2.0.7\0" +class FTNoIR_Tracker : public QObject, public ITracker +{ + Q_OBJECT public: FTNoIR_Tracker(); - virtual ~FTNoIR_Tracker() virt_override; - - virtual void StartTracker( QFrame* frame ) virt_override; - virtual bool GiveHeadPoseData(double *data) virt_override; - + ~FTNoIR_Tracker(); + +#ifdef OPENTRACK_API + virtual void StartTracker(QFrame*); + virtual bool GiveHeadPoseData(double* data); +#else + void Initialize( QFrame *videoframe ); + virtual void StartTracker(HWND parent_window); + virtual void StopTracker(bool exit); + virtual bool GiveHeadPoseData(THeadPoseData *data); +#endif void applysettings(const TrackerSettings& settings); void notifyCenter(); - void center(); + bool notifyZeroed(); void reset(); - void sendcmd(QString* cmd); - void get_info(QString* info , int* tps ); + void SerialInfo(); + void sendcmd(const QByteArray &cmd); + void get_info( int *tps ); + +private Q_SLOTS: + void SerialRead(); + +signals: + void sendMsgInfo(const QByteArray &MsgInfo); -protected: - void run(); // qthread override run method private: + QSerialPort *ComPort; TArduinoData ArduinoData, HAT ; // Trame from Arduino - QByteArray datagram; - QSerialPort* SerialPort; - volatile bool stop; - QMutex lock; - QString sSerialPortName; // Port serial name + QByteArray dataRead; + QByteArray dataToSend; + QByteArray Begin; + QByteArray End; + QMutex mutex; + int frame_cnt; + + TrackerSettings settings; + bool bEnableRoll; bool bEnablePitch; bool bEnableYaw; @@ -55,23 +77,54 @@ private: bool bInvertY; bool bInvertZ; + int iRollAxe; + int iPitchAxe; + int iYawAxe; + int iXAxe; + int iYAxe; + int iZAxe; + + QByteArray sCmdStart; + QByteArray sCmdStop; + QByteArray sCmdInit; + QByteArray sCmdReset; + QByteArray sCmdCenter; + QByteArray sCmdZero; + + int iDelayInit; + int iDelayStart; + int iDelaySeq; + + bool bBigEndian; + + QString sSerialPortName; + QSerialPort::BaudRate iBaudRate; + QSerialPort::DataBits iDataBits; + QSerialPort::Parity iParity; + QSerialPort::StopBits iStopBits; + QSerialPort::FlowControl iFlowControl; + + int CptError; - int iRollAxis; - int iPitchAxis; - int iYawAxis; - int iXAxis; - int iYAxis; - int iZAxis; }; -class FTNoIR_TrackerDll : public Metadata + +//******************************************************************************************************* +// 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: - FTNoIR_TrackerDll(); - ~FTNoIR_TrackerDll(); + TrackerDll(); + ~TrackerDll(); - void getFullName(QString *strToBeFilled); + void getFullName(QString *strToBeFilled); void getShortName(QString *strToBeFilled); void getDescription(QString *strToBeFilled); void getIcon(QIcon *icon); @@ -82,4 +135,5 @@ private: 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 index 1fa482c7..14b6ef0d 100644 --- a/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.cpp +++ b/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.cpp @@ -1,9 +1,34 @@ +/******************************************************************************** +* 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 -#include -#include +#include //******************************************************************************************************* // FaceTrackNoIR Client Settings-dialog. @@ -12,16 +37,22 @@ // // Constructor for server-settings-dialog // -TrackerControls::TrackerControls() : pre_frame(0), theTracker(NULL), settingsDirty(false), timer(this) +TrackerControls::TrackerControls() : theTracker(NULL), settingsDirty(false), timer(this) { - + ui.setupUi( this ); settings.load_ini(); - foreach (QSerialPortInfo PortInfo , QSerialPortInfo::availablePorts() ) { - ui.cbSerialPort->addItem(PortInfo.portName()); + 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 { @@ -34,7 +65,44 @@ TrackerControls::TrackerControls() : pre_frame(0), theTracker(NULL), settingsDir ui.cbSerialPort-> setCurrentIndex(indxport); } } - + // 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_baudRate->setCurrentIndex(ui.QCB_Serial_baudRate->findData(settings.pBaudRate)); + + 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_dataBits->setCurrentIndex(ui.QCB_Serial_dataBits->findData(settings.pDataBits)); + + 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("Mark"), QSerialPort::MarkParity); + ui.QCB_Serial_parity->addItem(QLatin1String("Space"), QSerialPort::SpaceParity); + ui.QCB_Serial_parity->setCurrentIndex(ui.QCB_Serial_parity->findData(settings.pParity)); + + ui.QCB_Serial_stopBits->clear(); + ui.QCB_Serial_stopBits->addItem(QLatin1String("1"), QSerialPort::OneStop); + ui.QCB_Serial_stopBits->addItem(QLatin1String("1.5"), QSerialPort::OneAndHalfStop); + ui.QCB_Serial_stopBits->addItem(QLatin1String("2"), QSerialPort::TwoStop); + ui.QCB_Serial_stopBits->setCurrentIndex(ui.QCB_Serial_stopBits->findData(settings.pStopBits)); + + + ui.QCB_Serial_flowControl->clear(); + ui.QCB_Serial_flowControl->addItem(QLatin1String("None"), QSerialPort::NoFlowControl); + ui.QCB_Serial_flowControl->addItem(QLatin1String("RTS/CTS"), QSerialPort::HardwareControl); + ui.QCB_Serial_flowControl->addItem(QLatin1String("XON/XOFF"), QSerialPort::SoftwareControl); + ui.QCB_Serial_flowControl->setCurrentIndex(ui.QCB_Serial_flowControl->findData(settings.pFlowControl)); + + ui.chkEnableRoll->setChecked(settings.EnableRoll); ui.chkEnablePitch->setChecked(settings.EnablePitch); ui.chkEnableYaw->setChecked(settings.EnableYaw); @@ -49,18 +117,34 @@ TrackerControls::TrackerControls() : pre_frame(0), theTracker(NULL), settingsDir ui.chkInvertY->setChecked(settings.InvertY); ui.chkInvertZ->setChecked(settings.InvertZ); - ui.cb_roll->setCurrentIndex(settings.RollAxis); - ui.cb_pitch->setCurrentIndex(settings.PitchAxis); - ui.cb_yaw->setCurrentIndex(settings.YawAxis); - ui.cb_x->setCurrentIndex(settings.XAxis); - ui.cb_y->setCurrentIndex(settings.YAxis); - ui.cb_z->setCurrentIndex(settings.ZAxis); + + 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); + + ui.le_cmd_start->setText(settings.CmdStart); + ui.le_cmd_stop->setText(settings.CmdStop); + ui.le_cmd_init->setText(settings.CmdInit); + ui.le_cmd_reset->setText(settings.CmdReset); + ui.le_cmd_center->setText(settings.CmdCenter); + ui.le_cmd_zero->setText(settings.CmdZero); + + ui.spb_BeforeInit->setValue(settings.DelayInit); + ui.spb_BeforeStart->setValue(settings.DelayStart); + ui.spb_AfterStart->setValue(settings.DelaySeq); + + ui.cb_Endian->setChecked(settings.BigEndian); + // 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)) ); @@ -84,11 +168,35 @@ TrackerControls::TrackerControls() : pre_frame(0), theTracker(NULL), settingsDir 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.le_cmd_start, SIGNAL(textEdited (QString )), this,SLOT(set_cmd_start(QString))); + connect(ui.le_cmd_stop, SIGNAL(textEdited ( QString )), this,SLOT(set_cmd_stop(QString))); + connect(ui.le_cmd_init, SIGNAL(textChanged ( QString )), this,SLOT(set_cmd_init(QString))); + connect(ui.le_cmd_reset, SIGNAL(textChanged ( QString )), this,SLOT(set_cmd_reset(QString))); + connect(ui.le_cmd_center, SIGNAL(textChanged ( QString )),this,SLOT(set_cmd_center(QString))); + connect(ui.le_cmd_zero, SIGNAL(textChanged ( QString )),this,SLOT(set_cmd_zero(QString))); + + connect(ui.spb_BeforeInit, SIGNAL(valueChanged ( int )), this,SLOT(set_DelayInit(int))); + connect(ui.spb_BeforeStart, SIGNAL(valueChanged ( int )), this,SLOT(set_DelayStart(int))); + connect(ui.spb_AfterStart, SIGNAL(valueChanged ( int )), this,SLOT(set_DelaySeq(int))); + + connect( ui.cb_Endian,SIGNAL(toggled(bool)), this,SLOT(set_endian(bool)) ); + + + connect(ui.QCB_Serial_baudRate, SIGNAL(currentIndexChanged(int)), this,SLOT(set_mod_baud(int)) ); + connect(ui.QCB_Serial_dataBits, SIGNAL(currentIndexChanged(int)), this,SLOT(set_mod_dataBits(int)) ); + connect(ui.QCB_Serial_parity, SIGNAL(currentIndexChanged(int)), this,SLOT(set_mod_parity(int)) ); + connect(ui.QCB_Serial_stopBits, SIGNAL(currentIndexChanged(int)), this,SLOT(set_mod_stopBits(int)) ); + connect(ui.QCB_Serial_flowControl, SIGNAL(currentIndexChanged(int)), this,SLOT(set_mod_flowControl(int)) ); + 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())); + } // @@ -97,6 +205,9 @@ TrackerControls::TrackerControls() : pre_frame(0), theTracker(NULL), settingsDir TrackerControls::~TrackerControls() { } +// +// Initialize tracker-client-dialog +// void TrackerControls::Initialize(QWidget *parent) { QPoint offsetpos(100, 100); if (parent) { @@ -105,72 +216,111 @@ void TrackerControls::Initialize(QWidget *parent) { 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(); + 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()) { - QString cmd; - cmd=ui.lineSend->text(); - theTracker->sendcmd(&cmd); - ui.lineSend->clear(); + theTracker->sendcmd(ui.lineSend->text().toLatin1()); } } } + +// +// Display FPS 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); - } + theTracker->get_info(&nb_trame); + ui.lab_vtps->setText(QString::number(nb_trame*(1000/last_time.elapsed()))); + last_time.restart(); + } +} - if (pre_framesetText(QString::number(nb_trame*(1000/timer.interval()))); - pre_frame=num_trame; - } - +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() { settingsDirty=false; - settings.save_ini(); + settings.save_ini(); } + +// +// OK clicked on server-dialog +// void TrackerControls::doOK() { settingsDirty=false; - settings.save_ini(); + settings.save_ini(); this->close(); } +// +// Cancel clicked on server-dialog +// void TrackerControls::doCancel() { - if (settingsDirty) { + // + // 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 ); switch (ret) { case QMessageBox::Save: @@ -181,8 +331,10 @@ void TrackerControls::doCancel() { close(); break; case QMessageBox::Cancel: + // Cancel was clicked break; default: + // should never be reached break; } } @@ -193,22 +345,44 @@ void TrackerControls::doCancel() { void TrackerControls::registerTracker(ITracker *tracker) { - theTracker = dynamic_cast(tracker); + theTracker = static_cast(tracker); + connect(theTracker, SIGNAL(sendMsgInfo(QByteArray)),this , SLOT(WriteMsgInfo(QByteArray))); + if (isVisible() && settingsDirty) theTracker->applysettings(settings); + ui.cbSerialPort->setEnabled(false); - timer.start(250); + ui.pteINFO->clear(); ui.lab_vstatus->setText("HAT START"); + last_time.start(); + timer.start(250); + } + void TrackerControls::unRegisterTracker() { - theTracker = NULL; - ui.cbSerialPort->setEnabled(true); + theTracker=NULL; timer.stop(); + ui.cbSerialPort->setEnabled(true); ui.lab_vstatus->setText("HAT STOPPED"); ui.lab_vtps->setText(""); } -extern "C" FTNOIR_TRACKER_BASE_EXPORT ITrackerDialog* CALLING_CONVENTION GetDialog() + + + +//////////////////////////////////////////////////////////////////////////////// +// 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. +#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 index 25bd839c..e413ded6 100644 --- a/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.h +++ b/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.h @@ -1,35 +1,41 @@ #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(); - virtual ~TrackerControls() virt_override; - + virtual ~TrackerControls(); void Initialize(QWidget *parent) virt_override; void registerTracker(ITracker *tracker) virt_override; void unRegisterTracker() virt_override; private: Ui::UIHATControls ui; - int pre_frame; FTNoIR_Tracker *theTracker; + QTime last_time; + +public slots: + void WriteMsgInfo(const QByteArray &MsgInfo); protected slots: - void set_mod_port(const QString & val) { settings.SerialPortName =val; - QMessageBox::warning(this,"FaceTrackNoIR Error", settings.SerialPortName); - settings_changed(); } + void set_mod_port(const QString & val) { settings.SerialPortName =val; 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(); } @@ -45,20 +51,41 @@ protected slots: void set_inv_z(bool val) { settings.InvertZ = val; settings_changed(); } - void set_rot_roll(int val) { settings.RollAxis = val; settings_changed(); } - void set_rot_pitch(int val) { settings.PitchAxis = val; settings_changed(); } - void set_rot_yaw(int val) { settings.YawAxis = val; settings_changed(); } - void set_acc_x(int val) { settings.XAxis = val; settings_changed(); } - void set_acc_y(int val) { settings.YAxis = val; settings_changed(); } - void set_acc_z(int val) { settings.ZAxis = 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 set_cmd_start(const QString &val) { settings.CmdStart = val; settings_changed(); } + void set_cmd_stop(const QString &val) { settings.CmdStop = val; settings_changed(); } + void set_cmd_init(const QString &val) { settings.CmdInit = val; settings_changed(); } + void set_cmd_reset(const QString &val) { settings.CmdReset = val; settings_changed(); } + void set_cmd_center(const QString &val) { settings.CmdCenter = val; settings_changed(); } + void set_cmd_zero(const QString &val) { settings.CmdZero = val; settings_changed(); } + + void set_DelayInit(int val) { settings.DelayInit = val; settings_changed(); } + void set_DelayStart(int val) { settings.DelayStart = val; settings_changed(); } + void set_DelaySeq(int val) { settings.DelaySeq = val; settings_changed(); } + + void set_endian(bool val) { settings.BigEndian = val; settings_changed(); } + + void set_mod_baud(int val) { settings.pBaudRate = static_cast(ui.QCB_Serial_baudRate->itemData(val).toInt()) ; settings_changed(); } + void set_mod_dataBits(int val) { settings.pDataBits = static_cast(ui.QCB_Serial_dataBits->itemData(val).toInt()) ; settings_changed(); } + void set_mod_parity(int val) { settings.pParity = static_cast(ui.QCB_Serial_parity->itemData(val).toInt()) ; settings_changed(); } + void set_mod_stopBits(int val) { settings.pStopBits = static_cast(ui.QCB_Serial_stopBits->itemData(val).toInt()); settings_changed(); } + void set_mod_flowControl(int val) { settings.pFlowControl = static_cast(ui.QCB_Serial_flowControl->itemData(val).toInt()) ; settings_changed(); } void doOK(); void doCancel(); void doSave(); void doReset(); void doCenter(); + void doZero(); void doSend(); void poll_tracker_info(); + void doSerialInfo(); protected: bool settingsDirty; @@ -67,5 +94,4 @@ protected: 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 index cd1475f8..5f82d5a0 100644 --- a/ftnoir_tracker_hatire/ftnoir_tracker_hat_dll.cpp +++ b/ftnoir_tracker_hatire/ftnoir_tracker_hat_dll.cpp @@ -1,38 +1,81 @@ +/******************************************************************************** +* 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 -FTNoIR_TrackerDll::FTNoIR_TrackerDll() { +TrackerDll::TrackerDll() { + //populate the description strings trackerFullName = "Hatire Arduino"; trackerShortName = "HAT"; - trackerDescription = "Hatire Arduino"; + trackerDescription = "FaceTrackNoIR HAT"; } -FTNoIR_TrackerDll::~FTNoIR_TrackerDll() +TrackerDll::~TrackerDll() { + } -void FTNoIR_TrackerDll::getFullName(QString *strToBeFilled) +void TrackerDll::getFullName(QString *strToBeFilled) { *strToBeFilled = trackerFullName; } -void FTNoIR_TrackerDll::getShortName(QString *strToBeFilled) +void TrackerDll::getShortName(QString *strToBeFilled) { *strToBeFilled = trackerShortName; } -void FTNoIR_TrackerDll::getDescription(QString *strToBeFilled) +void TrackerDll::getDescription(QString *strToBeFilled) { *strToBeFilled = trackerDescription; } -void FTNoIR_TrackerDll::getIcon(QIcon *icon) +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 FTNoIR_TrackerDll; + return new TrackerDll; } diff --git a/ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.cpp b/ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.cpp index a9466304..0be912f2 100644 --- a/ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.cpp +++ b/ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.cpp @@ -1,12 +1,38 @@ +/******************************************************************************** +* 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 #include +#include #include "ftnoir_tracker_hat_settings.h" void TrackerSettings::load_ini() { - qDebug("TrackerSettings::load_ini()"); - QSettings settings("opentrack"); + 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) @@ -30,12 +56,33 @@ void TrackerSettings::load_ini() InvertZ = iniFile.value( "InvertZ", 0 ).toBool(); - RollAxis=iniFile.value("RollAxis",1).toInt(); - PitchAxis=iniFile.value("PitchAxis",2).toInt(); - YawAxis=iniFile.value("YawAxis",0).toInt(); - XAxis=iniFile.value("XAxis",1).toInt(); - YAxis=iniFile.value("YAxis",2).toInt(); - ZAxis=iniFile.value("ZAxis",0).toInt(); + 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(); + + + CmdStart=iniFile.value ( "CmdStart").toString(); + CmdStop=iniFile.value ( "CmdStop" ).toString(); + CmdInit=iniFile.value ( "CmdInit" ).toString(); + CmdReset=iniFile.value ( "CmdReset" ).toString(); + CmdCenter=iniFile.value ( "CmdCenter" ).toString(); + CmdZero=iniFile.value ( "CmdZero" ).toString(); + + DelayInit=iniFile.value("DelayInit",0).toInt(); + DelayStart=iniFile.value("DelayStart",0).toInt(); + DelaySeq=iniFile.value("DelaySeq",0).toInt(); + + BigEndian=iniFile.value("BigEndian",0).toBool(); + + + pBaudRate=static_cast(iniFile.value("BaudRate",QSerialPort::Baud115200).toInt()); + pDataBits=static_cast(iniFile.value("DataBits",QSerialPort::Data8).toInt()); + pParity=static_cast(iniFile.value("Parity",QSerialPort::NoParity).toInt()); + pStopBits=static_cast(iniFile.value("StopBits",QSerialPort::OneStop).toInt()); + pFlowControl=static_cast(iniFile.value("FlowControl",QSerialPort::HardwareControl).toInt()); iniFile.endGroup(); } @@ -43,9 +90,8 @@ void TrackerSettings::load_ini() void TrackerSettings::save_ini() const { - qDebug("TrackerSettings::save_ini()"); - QSettings settings("opentrack"); + 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) @@ -67,12 +113,33 @@ void TrackerSettings::save_ini() const iniFile.setValue( "InvertY", InvertY ); iniFile.setValue( "InvertZ", InvertZ ); - iniFile.setValue ( "RollAxis", RollAxis ); - iniFile.setValue ( "PitchAxis", PitchAxis ); - iniFile.setValue ( "YawAxis",YawAxis ); - iniFile.setValue ( "XAxis", XAxis ); - iniFile.setValue ( "YAxis", YAxis ); - iniFile.setValue ( "ZAxis", ZAxis ); + 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.setValue ( "CmdStart",CmdStart.toLatin1()); + iniFile.setValue ( "CmdStop",CmdStop.toLatin1()); + iniFile.setValue ( "CmdInit",CmdInit.toLatin1()); + iniFile.setValue ( "CmdReset",CmdReset.toLatin1()); + iniFile.setValue ( "CmdCenter",CmdCenter.toLatin1() ); + iniFile.setValue ( "CmdZero",CmdZero.toLatin1() ); + + iniFile.setValue ( "DelayInit",DelayInit); + iniFile.setValue ( "DelayStart",DelayStart); + iniFile.setValue ( "DelaySeq",DelaySeq); + + iniFile.setValue("BigEndian",BigEndian); + + iniFile.setValue("BaudRate",pBaudRate); + iniFile.setValue("DataBits",pDataBits); + iniFile.setValue("Parity",pParity); + iniFile.setValue("StopBits",pStopBits); + iniFile.setValue("FlowControl",pFlowControl); + iniFile.endGroup(); } + diff --git a/ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.h b/ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.h index d6cf4fd9..2e84bde8 100644 --- a/ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.h +++ b/ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.h @@ -8,13 +8,15 @@ #ifndef FTNOIR_TRACKER_HAT_SETTINGS_H #define FTNOIR_TRACKER_HAT_SETTINGS_H -#include +#include //----------------------------------------------------------------------------- struct TrackerSettings { - QString SerialPortName; + void load_ini(); + void save_ini() const; + bool EnableRoll; bool EnablePitch; bool EnableYaw; @@ -30,15 +32,34 @@ struct TrackerSettings bool InvertZ; - int RollAxis; - int PitchAxis; - int YawAxis; - int XAxis; - int YAxis; - int ZAxis; + int RollAxe; + int PitchAxe; + int YawAxe; + int XAxe; + int YAxe; + int ZAxe; + + QString CmdStart; + QString CmdStop; + QString CmdInit; + QString CmdReset; + QString CmdCenter; + QString CmdZero; + + int DelayInit; + int DelayStart; + int DelaySeq; + + bool BigEndian; + + QString SerialPortName; + QSerialPort::BaudRate pBaudRate; + QSerialPort::DataBits pDataBits; + QSerialPort::Parity pParity; + QSerialPort::StopBits pStopBits; + QSerialPort::FlowControl pFlowControl; - void load_ini(); - void save_ini() const; }; -#endif //FTNOIR_TRACKER_HAT_SETTINGS_H + +#endif //FTNOIR_TRACKER_HAT_SETTINGS_H \ No newline at end of file -- cgit v1.2.3 From 502daa65f45952893060a70f5f95d1626d53050a Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 27 Nov 2013 23:20:18 +0100 Subject: PT: don't crash on camera lackage (issue #9) Reported-by: runningman84 Signed-off-by: Stanislaw Halik --- FTNoIR_Tracker_PT/camera.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/FTNoIR_Tracker_PT/camera.cpp b/FTNoIR_Tracker_PT/camera.cpp index b4d2509f..5f6db57c 100644 --- a/FTNoIR_Tracker_PT/camera.cpp +++ b/FTNoIR_Tracker_PT/camera.cpp @@ -163,7 +163,10 @@ void CVCamera::start() 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); - } + } else { + delete cap; + cap = nullptr; + } } void CVCamera::stop() -- cgit v1.2.3 From 58989d52c2c0650611d26ab223ccd43f4891bb41 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 29 Nov 2013 10:07:56 +0100 Subject: Implement Aruco pitch change --- ftnoir_tracker_aruco/aruco-trackercontrols.ui | 28 ++++++++++++++++++++++++- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 30 ++++++++++++++++++++++----- ftnoir_tracker_aruco/ftnoir_tracker_aruco.h | 2 +- 3 files changed, 53 insertions(+), 7 deletions(-) diff --git a/ftnoir_tracker_aruco/aruco-trackercontrols.ui b/ftnoir_tracker_aruco/aruco-trackercontrols.ui index 76d750af..8cf28057 100644 --- a/ftnoir_tracker_aruco/aruco-trackercontrols.ui +++ b/ftnoir_tracker_aruco/aruco-trackercontrols.ui @@ -10,7 +10,7 @@ 0 0 704 - 273 + 308 @@ -294,6 +294,32 @@ + + + + Pitch + + + + + + + ° + + + 2 + + + -60.000000000000000 + + + 60.000000000000000 + + + 0.000000000000000 + + + diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index 41bf0edd..ddbdadb0 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -128,6 +128,8 @@ void Tracker::load_settings() { headpos[i] = iniFile.value(QString("headpos-%1").arg(i), 0).toDouble(); } + headpitch = iniFile.value("pitch", 0).toDouble(); + iniFile.endGroup(); } @@ -328,17 +330,27 @@ void Tracker::run() cv::Rodrigues(rvec, rotation_matrix); - cv::Vec3d foo = cv::RQDecomp3x3(rotation_matrix, junk1, junk2); - { + const double beta = headpitch * M_PI / 180; + double pitch[] = { + 1, 0, 0, + 0, cos(beta), -sin(beta), + 0, sin(beta), cos(beta) + }; + cv::Mat rot(3, 3, CV_64F, pitch); + tvec = rot * tvec; + rotation_matrix = rot * rotation_matrix; + + cv::Vec3d euler = cv::RQDecomp3x3(rotation_matrix, junk1, junk2); + QMutexLocker lck(&mtx); for (int i = 0; i < 3; i++) pose[i] = tvec.at(i); - pose[Yaw] = foo[1]; - pose[Pitch] = -foo[0]; - pose[Roll] = foo[2]; + pose[Yaw] = euler[1]; + pose[Pitch] = -euler[0]; + pose[Roll] = euler[2]; } std::vector repr2; @@ -346,6 +358,11 @@ void Tracker::run() centroid.push_back(cv::Point3f(0, 0, 0)); cv::projectPoints(centroid, rvec, tvec, intrinsics, dist_coeffs, repr2); + { + auto s = cv::Scalar(255, 0, 255); + cv::circle(frame, repr2.at(0), 4, s, -1); + } + last_centroid = repr2[0]; } else @@ -527,6 +544,8 @@ void TrackerControls::loadSettings() headpos[i]->setValue(iniFile.value(QString("headpos-%1").arg(i)).toDouble()); } + ui.pitch_deg->setValue(iniFile.value("pitch", 0).toDouble()); + iniFile.endGroup(); settingsDirty = false; } @@ -565,6 +584,7 @@ void TrackerControls::save() iniFile.setValue("enable-ty", ui.ty->checkState() != Qt::Unchecked ? true : false); iniFile.setValue("enable-tz", ui.tz->checkState() != Qt::Unchecked ? true : false); iniFile.setValue("resolution", ui.resolution->currentIndex()); + iniFile.setValue("pitch", ui.pitch_deg->value()); QDoubleSpinBox* headpos[] = { ui.cx, diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h index 3a2ebeea..1518ba4d 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h @@ -40,7 +40,7 @@ private: int force_fps, force_width, force_height; double pose[6]; cv::Mat frame; - double headpos[3]; + double headpos[3], headpitch; cv::VideoCapture camera; }; -- cgit v1.2.3 From c13e38e03b987fa2b46b6edb0ae5c56ba5e4e180 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 29 Nov 2013 10:09:48 +0100 Subject: Fix build --- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index ddbdadb0..218f2d30 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -331,7 +331,7 @@ void Tracker::run() cv::Rodrigues(rvec, rotation_matrix); { - const double beta = headpitch * M_PI / 180; + const double beta = headpitch * HT_PI / 180; double pitch[] = { 1, 0, 0, 0, cos(beta), -sin(beta), -- 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 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 a8cacd5518ff5339e51b92dfcfb55baf446eb799 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 29 Nov 2013 10:31:34 +0100 Subject: don't install convenience libraries --- CMakeLists.txt | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e9cdbd3b..f4c3e36e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -432,7 +432,7 @@ if(UNIX AND SDK_ENABLE_LIBEVDEV) SET_TARGET_PROPERTIES(opentrack-proto-libevdev PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt") endif() - install(TARGETS opentrack-proto-libevdev DESTINATION .) + install(TARGETS opentrack-proto-libevdev RUNTIME DESTINATION . LIBRARY DESTINATION . ) endif() if(WIN32) @@ -534,7 +534,7 @@ 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}) -install(TARGETS opentrack-tracker-hatire DESTINATION .) +install(TARGETS opentrack-tracker-hatire RUNTIME DESTINATION . LIBRARY DESTINATION . ) if(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32) SET_TARGET_PROPERTIES(opentrack-tracker-hatire PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt") @@ -689,7 +689,7 @@ target_link_libraries(opentrack ${OpenCV_LIBS}) include_directories(${OpenCV_INCLUDE_DIRS}) if(UNIX) - install(TARGETS opentrack-qxt-mini DESTINATION .) + install(TARGETS opentrack-qxt-mini RUNTIME DESTINATION . LIBRARY DESTINATION . ) endif() if(WIN32) @@ -723,11 +723,11 @@ set_target_properties(opentrack PROPERTIES COMPILE_FLAGS -DOPENTRACK_MAIN) install(FILES "${CMAKE_SOURCE_DIR}/README.md" DESTINATION .) if(SDK_XPLANE) - install(TARGETS opentrack-xplane-plugin DESTINATION .) + install(TARGETS opentrack-xplane-plugin RUNTIME DESTINATION . LIBRARY DESTINATION . ) endif() if(WIN32) install(DIRECTORY "${CMAKE_SOURCE_DIR}/bin/tracker-ht" DESTINATION .) - install(TARGETS freetrackclient DESTINATION .) + install(TARGETS freetrackclient RUNTIME DESTINATION . LIBRARY DESTINATION . ) endif() install(DIRECTORY "${CMAKE_SOURCE_DIR}/3rdparty-notices" DESTINATION .) @@ -737,64 +737,67 @@ install(DIRECTORY "${CMAKE_SOURCE_DIR}/bin/settings" "${CMAKE_SOURCE_DIR}/facetr if(NOT WIN32 AND SDK_WINE_PREFIX) install(FILES "${CMAKE_BINARY_DIR}/opentrack-wrapper-wine.exe.so" DESTINATION .) - install(TARGETS opentrack-proto-wine DESTINATION .) + install(TARGETS opentrack-proto-wine RUNTIME DESTINATION . LIBRARY DESTINATION . ) endif() -install(TARGETS opentrack-tracker-pt DESTINATION .) +install(TARGETS opentrack-tracker-pt RUNTIME DESTINATION . LIBRARY DESTINATION . ) if(SDK_ARUCO_LIBPATH) - install(TARGETS opentrack-tracker-aruco DESTINATION .) + install(TARGETS opentrack-tracker-aruco RUNTIME DESTINATION . LIBRARY DESTINATION . ) endif() install(TARGETS + opentrack-proto-fgfs + opentrack-proto-udp + opentrack-api opentrack-compat opentrack-csv opentrack-pose-widget opentrack-spline-widget opentrack-filter-accela opentrack-filter-ewma - opentrack-proto-fgfs - opentrack-proto-udp opentrack-tracker-ht opentrack-tracker-udp + RUNTIME DESTINATION . LIBRARY DESTINATION . ) + +install(TARGETS opentrack - opentrack-api DESTINATION . ) if(WIN32) - install(TARGETS opentrack-tracker-joystick DESTINATION .) + install(TARGETS opentrack-tracker-joystick RUNTIME DESTINATION . LIBRARY DESTINATION . ) endif() if(WIN32 AND SDK_VJOY) - install(TARGETS opentrack-proto-vjoy DESTINATION .) + install(TARGETS opentrack-proto-vjoy RUNTIME DESTINATION . LIBRARY DESTINATION . ) install(FILES "${SDK_VJOY}/VJoy.dll" DESTINATION .) endif() if(SDK_RIFT) - install(TARGETS opentrack-tracker-rift DESTINATION .) + install(TARGETS opentrack-tracker-rift RUNTIME DESTINATION . LIBRARY DESTINATION . ) endif() if(SDK_HYDRA) install( TARGETS opentrack-tracker-hydra - DESTINATION . + RUNTIME DESTINATION . LIBRARY DESTINATION . ) endif() if(WIN32) install(FILES "${CMAKE_SOURCE_DIR}/bin/cleye.config" DESTINATION .) if(SDK_SIMCONNECT) - install(TARGETS opentrack-proto-simconnect DESTINATION .) + install(TARGETS opentrack-proto-simconnect RUNTIME DESTINATION . LIBRARY DESTINATION . ) endif() install(TARGETS opentrack-proto-freetrack opentrack-proto-win32-mouse #opentrack-proto-simconnect - DESTINATION . + RUNTIME DESTINATION . LIBRARY DESTINATION . ) if(SDK_FSUIPC) - install(TARGETS opentrack-proto-fsuipc DESTINATION .) + install(TARGETS opentrack-proto-fsuipc RUNTIME DESTINATION . LIBRARY DESTINATION .) endif() endif() -- cgit v1.2.3 From 167d0d51dd0160cdae72e2434782eb6b9147f5d4 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 29 Nov 2013 10:32:46 +0100 Subject: delete captain obvious comments --- CMakeLists.txt | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f4c3e36e..c82b5e50 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -135,8 +135,6 @@ endif() if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) set(CMAKE_RC_COMPILER_INIT i686-w64-mingw32-windres) SET(CMAKE_RC_COMPILE_OBJECT " -O coff -i -o ") - else() - #set(CMAKE_RC_COMPILER_INIT rc) endif() ENABLE_LANGUAGE(RC) endif(WIN32) @@ -592,7 +590,7 @@ if(SDK_RIFT) else() if (NOT APPLE) target_link_libraries(opentrack-tracker-rift "${SDK_RIFT}/libLibOVR.a" udev Xinerama) - else() # crapintosh + else() target_link_libraries(opentrack-tracker-rift "${SDK_RIFT}/libLibOVR.a") endif() endif() @@ -793,7 +791,6 @@ if(WIN32) install(TARGETS opentrack-proto-freetrack opentrack-proto-win32-mouse - #opentrack-proto-simconnect RUNTIME DESTINATION . LIBRARY DESTINATION . ) if(SDK_FSUIPC) -- cgit v1.2.3 From 0f02e51f0b1be11c1a2eabb28d5513fba8e9dfdd Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 29 Nov 2013 18:37:05 +0100 Subject: workaround LTO build with using linker script --- CMakeLists.txt | 79 ++++++++++++++++++++++++++++++++++------------------------ 1 file changed, 46 insertions(+), 33 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c82b5e50..cd744a8f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,6 +8,19 @@ if(GIT_FOUND) git_describe(OPENTRACK__COMMIT --tags --always) endif() +if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + set(CMAKE_COMPILER_IS_GNUCC TRUE) + set(CMAKE_COMPILER_IS_GNUCXX TRUE) +endif() + +if(CMAKE_COMPILER_IS_GNUCXX) + if(MINGW32) + set(version-script mingw) + else() + set(version-script posix) + endif() +endif() + if(APPLE) set(apple-frameworks "-stdlib=libc++ -framework Cocoa -framework CoreFoundation -lobjc -lz -framework Carbon") set(CMAKE_SHARED_LINKER_FLAGS " ${apple-frameworks} ${CMAKE_SHARED_LINKER_FLAGS}") @@ -389,24 +402,24 @@ target_link_libraries(opentrack-spline-widget ${MY_QT_LIBS}) add_library(opentrack-filter-accela SHARED ${opentrack-filter-accela-c} ${opentrack-filter-accela-h} ${opentrack-filter-accela-moc} ${opentrack-filter-accela-uih} ${opentrack-filter-accela-rcc}) target_link_libraries(opentrack-filter-accela ${MY_QT_LIBS}) -if(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32) +if(CMAKE_COMPILER_IS_GNUCXX) SET_TARGET_PROPERTIES(opentrack-filter-accela - PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt") + PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt") endif() add_library(opentrack-filter-ewma SHARED ${opentrack-filter-ewma-uih} ${opentrack-filter-ewma-c} ${opentrack-filter-ewma-h} ${opentrack-filter-ewma-moc} ${opentrack-filter-ewma-rcc}) target_link_libraries(opentrack-filter-ewma ${MY_QT_LIBS}) -if(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32) +if(CMAKE_COMPILER_IS_GNUCXX) SET_TARGET_PROPERTIES(opentrack-filter-ewma - PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt") + PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt") endif() add_library(opentrack-proto-fgfs SHARED ${opentrack-proto-fgfs-c} ${opentrack-proto-fgfs-h} ${opentrack-proto-fgfs-moc} ${opentrack-proto-fgfs-uih} ${opentrack-proto-fgfs-rcc}) target_link_libraries(opentrack-proto-fgfs ${MY_QT_LIBS}) -if(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32) +if(CMAKE_COMPILER_IS_GNUCXX) SET_TARGET_PROPERTIES(opentrack-proto-fgfs - PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt") + PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt") endif() if(WIN32 AND SDK_VJOY) @@ -417,18 +430,18 @@ if(WIN32 AND SDK_VJOY) else() target_link_libraries(opentrack-proto-vjoy ${MY_QT_LIBS} "${SDK_VJOY}/VJoy.dll") endif() - if(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32) + if(CMAKE_COMPILER_IS_GNUCXX) SET_TARGET_PROPERTIES(opentrack-proto-vjoy - PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt -Wl,--enable-stdcall-fixup") + PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt -Wl,--enable-stdcall-fixup") endif() endif() if(UNIX AND SDK_ENABLE_LIBEVDEV) add_library(opentrack-proto-libevdev SHARED ${opentrack-proto-libevdev-c} ${opentrack-proto-libevdev-h} ${opentrack-proto-libevdev-moc} ${opentrack-proto-libevdev-uih} ${opentrack-proto-libevdev-rcc}) target_link_libraries(opentrack-proto-libevdev ${MY_QT_LIBS} evdev) - if(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32) + if(CMAKE_COMPILER_IS_GNUCXX) SET_TARGET_PROPERTIES(opentrack-proto-libevdev - PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt") + PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt") endif() install(TARGETS opentrack-proto-libevdev RUNTIME DESTINATION . LIBRARY DESTINATION . ) endif() @@ -466,26 +479,26 @@ endif() add_library(opentrack-proto-udp SHARED ${opentrack-proto-udp-c} ${opentrack-proto-udp-h} ${opentrack-proto-udp-moc} ${opentrack-proto-udp-uih} ${opentrack-proto-udp-rcc}) target_link_libraries(opentrack-proto-udp ${MY_QT_LIBS}) -if(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32) +if(CMAKE_COMPILER_IS_GNUCXX) SET_TARGET_PROPERTIES(opentrack-proto-udp - PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt") + PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt") endif() if(WIN32) add_library(opentrack-tracker-joystick SHARED ${opentrack-tracker-joystick-c} ${opentrack-tracker-joystick-h} ${opentrack-tracker-joystick-moc} ${opentrack-tracker-joystick-uih} ${opentrack-tracker-joystick-rcc}) target_link_libraries(opentrack-tracker-joystick ${MY_QT_LIBS}) - if(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32) + if(CMAKE_COMPILER_IS_GNUCXX) SET_TARGET_PROPERTIES(opentrack-tracker-joystick - PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt") + PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt") endif() endif() if(NOT WIN32 AND SDK_WINE_PREFIX) add_library(opentrack-proto-wine SHARED ${opentrack-proto-wine-c} ${opentrack-proto-wine-h} ${opentrack-proto-wine-moc} ${opentrack-proto-wine-uih} ${opentrack-proto-wine-rcc}) target_link_libraries(opentrack-proto-wine ${MY_QT_LIBS} opentrack-compat opentrack-csv) - if(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32) + if(CMAKE_COMPILER_IS_GNUCXX) SET_TARGET_PROPERTIES(opentrack-proto-wine - PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt") + PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt") endif() if(NOT SDK_WINE_NO_WRAPPER) set(my-rt -lrt) @@ -508,34 +521,34 @@ if(NOT WIN32 AND SDK_WINE_PREFIX) endif() endif() -if(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32) +if(CMAKE_COMPILER_IS_GNUCXX) SET_TARGET_PROPERTIES(opentrack-proto-fgfs - PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt") + PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt") endif() add_library(opentrack-tracker-ht SHARED ${opentrack-tracker-ht-c} ${opentrack-tracker-ht-h} ${opentrack-tracker-ht-moc} ${opentrack-tracker-ht-uih} ${opentrack-tracker-ht-rcc}) target_link_libraries(opentrack-tracker-ht ${MY_QT_LIBS} opentrack-compat) -if(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32) +if(CMAKE_COMPILER_IS_GNUCXX) SET_TARGET_PROPERTIES(opentrack-tracker-ht - PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt") + PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt") endif() if(SDK_ARUCO_LIBPATH) include_directories(${CMAKE_SOURCE_DIR}/ftnoir_tracker_aruco/include) add_library(opentrack-tracker-aruco SHARED ${opentrack-tracker-aruco-c} ${opentrack-tracker-aruco-h} ${opentrack-tracker-aruco-moc} ${opentrack-tracker-aruco-uih} ${opentrack-tracker-aruco-rcc}) target_link_libraries(opentrack-tracker-aruco ${MY_QT_LIBS} ${SDK_ARUCO_LIBPATH} ${OpenCV_LIBS}) - if(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32) + if(CMAKE_COMPILER_IS_GNUCXX) SET_TARGET_PROPERTIES(opentrack-tracker-aruco - PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt") + PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt") 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}) install(TARGETS opentrack-tracker-hatire RUNTIME DESTINATION . LIBRARY DESTINATION . ) -if(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32) +if(CMAKE_COMPILER_IS_GNUCXX) SET_TARGET_PROPERTIES(opentrack-tracker-hatire - PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt") + PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt") endif() if(WIN32) @@ -557,9 +570,9 @@ if(APPLE) SET_TARGET_PROPERTIES(opentrack-tracker-pt PROPERTIES COMPILE_FLAGS "-std=c++11") endif() -if(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32) +if(CMAKE_COMPILER_IS_GNUCXX) SET_TARGET_PROPERTIES(opentrack-tracker-pt - PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt") + PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt") endif() @@ -572,9 +585,9 @@ endif() add_library(opentrack-tracker-udp SHARED ${opentrack-tracker-udp-c} ${opentrack-tracker-udp-h} ${opentrack-tracker-udp-moc} ${opentrack-tracker-udp-uih} ${opentrack-tracker-udp-rcc}) target_link_libraries(opentrack-tracker-udp ${MY_QT_LIBS}) -if(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32) +if(CMAKE_COMPILER_IS_GNUCXX) SET_TARGET_PROPERTIES(opentrack-tracker-udp - PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt") + PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt") endif() if(SDK_RIFT) @@ -588,17 +601,17 @@ if(SDK_RIFT) if(WIN32) target_link_libraries(opentrack-tracker-rift "${SDK_RIFT}/libLibOVR.a" winmm.lib setupapi.lib) else() - if (NOT APPLE) + if(NOT APPLE) target_link_libraries(opentrack-tracker-rift "${SDK_RIFT}/libLibOVR.a" udev Xinerama) else() target_link_libraries(opentrack-tracker-rift "${SDK_RIFT}/libLibOVR.a") endif() endif() endif() - if(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32) + if(CMAKE_COMPILER_IS_GNUCXX) SET_TARGET_PROPERTIES(opentrack-tracker-rift PROPERTIES - LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt" + LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt" COMPILE_FLAGS "-fno-strict-aliasing" ) endif() @@ -640,9 +653,9 @@ if(SDK_HYDRA) ) target_link_libraries(opentrack-tracker-hydra "${SDK_HYDRA}/lib/${sixense-plat}${underscore-sixtyfour}/release${underscore-dll}/libsixense${underscore-sixtyfour}.${soext}" "${SDK_HYDRA}/lib/${sixense-plat}${underscore-sixtyfour}/release${underscore-dll}/libsixense_utils${underscore-sixtyfour}.${soext}") endif() - if(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32) + if(CMAKE_COMPILER_IS_GNUCXX) SET_TARGET_PROPERTIES(opentrack-tracker-hydra - PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/posix-version-script.txt") + PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt") endif() endif() -- cgit v1.2.3 From 9606a181c86e5b8c24ff9f843f8335d6fdb0ee7c Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 29 Nov 2013 18:58:40 +0100 Subject: fix problem in the last commit --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cd744a8f..420114bb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,7 @@ if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") endif() if(CMAKE_COMPILER_IS_GNUCXX) - if(MINGW32) + if(MINGW) set(version-script mingw) else() set(version-script posix) -- 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 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 2435ad93423ee3ce3b262000854666adc5f51386 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 30 Nov 2013 16:29:26 +0100 Subject: add credit for FuraX49 --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9274a336..fbbead33 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,8 @@ Don't be afraid to submit an issue/feature request if the need arises. - Chris Thompson (aka mm0zct) - Donovan Baarda - Ryan Spicer (OSX tester, contributor) -- Patrick Ruoff (merging) +- Patrick Ruoff (PT tracker) +- FuraX49 (hatire arduino tracker) - Wim Vriend (historically) - Ron Hendriks (historically) -- cgit v1.2.3 From 8b3838e6e744bd1dfff290bf56ee4543bc442526 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 30 Nov 2013 17:09:12 +0100 Subject: Revert "Added positional tracking?!" This reverts commit 8b3285917eeb228e9811df75568d927b763644cf. Requested-by: mm0zct --- ftnoir_tracker_rift/ftnoir_rift_clientcontrols.ui | 127 --------------------- ftnoir_tracker_rift/ftnoir_tracker_rift.cpp | 22 +--- ftnoir_tracker_rift/ftnoir_tracker_rift.h | 4 +- ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp | 4 +- 4 files changed, 9 insertions(+), 148 deletions(-) diff --git a/ftnoir_tracker_rift/ftnoir_rift_clientcontrols.ui b/ftnoir_tracker_rift/ftnoir_rift_clientcontrols.ui index 8250580d..e868a9c3 100644 --- a/ftnoir_tracker_rift/ftnoir_rift_clientcontrols.ui +++ b/ftnoir_tracker_rift/ftnoir_rift_clientcontrols.ui @@ -150,136 +150,9 @@ - - - - - - - - - Enable Translation Axis - - - false - - - - - - - 0 - 0 - - - - TX: - - - - - - - - 0 - 0 - - - - - 20 - 16777215 - - - - Qt::LeftToRight - - - - - - - - - - - - - - 0 - 0 - - - - TY: - - - - - - - - 0 - 0 - - - - - 20 - 16777215 - - - - Qt::LeftToRight - - - - - - - - - - - 0 - 0 - - - - TZ: - - - - - - - - 0 - 0 - - - - - 20 - 16777215 - - - - Qt::LeftToRight - - - - - - - - - - - diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp b/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp index 45c02cfb..dd78bf9f 100644 --- a/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp +++ b/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp @@ -88,23 +88,11 @@ bool Rift_Tracker::GiveHeadPoseData(double *data) if(newHeadPose[Yaw]<-deadzone)newHeadPose[Yaw]+= constant_drift; old_yaw=yaw; } -#if 1 - - double dt = 0.015; - - OVR::Vector3f acc = pSFusion->GetAcceleration(); - old_x = old_x*persistence + vx*dt + 0.5*(acc.x*acc.x); - vx = vx*persistence + acc.x*dt; - newHeadPose[TX] = old_x; - - old_y = old_y*persistence + vy*dt + 0.5*(acc.y*acc.y); - vy = vy*persistence + acc.y*dt; - newHeadPose[TY] = old_y; - - old_z = old_z*persistence + vz*dt + 0.5*(acc.z*acc.z); - vz = vz*persistence + acc.z*dt; - newHeadPose[TZ] = old_z; - +#if 0 + newHeadPose[TX] = acd.controllers[0].pos[0]/50.0f; + newHeadPose[TY] = acd.controllers[0].pos[1]/50.0f; + newHeadPose[TZ] = acd.controllers[0].pos[2]/50.0f; + if (bEnableX) { data[TX] = newHeadPose[TX]; } diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift.h b/ftnoir_tracker_rift/ftnoir_tracker_rift.h index 93b03b97..7a4533d3 100644 --- a/ftnoir_tracker_rift/ftnoir_tracker_rift.h +++ b/ftnoir_tracker_rift/ftnoir_tracker_rift.h @@ -30,13 +30,13 @@ private: bool bEnableRoll; bool bEnablePitch; bool bEnableYaw; -#if 1 +#if 0 bool bEnableX; bool bEnableY; bool bEnableZ; #endif bool useYawSpring; - double old_yaw, constant_drift, persistence, deadzone, old_x, old_y, old_z, vx, vy, vz; + double old_yaw, constant_drift, persistence, deadzone; }; // Widget that has controls for FTNoIR protocol client-settings. diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp b/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp index 901a0192..2efefbb3 100644 --- a/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp +++ b/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp @@ -112,7 +112,7 @@ void TrackerControls::loadSettings() { ui.chkEnableRoll->setChecked(iniFile.value ( "EnableRoll", 1 ).toBool()); ui.chkEnablePitch->setChecked(iniFile.value ( "EnablePitch", 1 ).toBool()); ui.chkEnableYaw->setChecked(iniFile.value ( "EnableYaw", 1 ).toBool()); -#if 1 +#if 0 ui.chkEnableX->setChecked(iniFile.value ( "EnableX", 1 ).toBool()); ui.chkEnableY->setChecked(iniFile.value ( "EnableY", 1 ).toBool()); ui.chkEnableZ->setChecked(iniFile.value ( "EnableZ", 1 ).toBool()); @@ -139,7 +139,7 @@ void TrackerControls::save() { iniFile.setValue ( "EnableRoll", ui.chkEnableRoll->isChecked() ); iniFile.setValue ( "EnablePitch", ui.chkEnablePitch->isChecked() ); iniFile.setValue ( "EnableYaw", ui.chkEnableYaw->isChecked() ); -#if 1 +#if 0 iniFile.setValue ( "EnableX", ui.chkEnableX->isChecked() ); iniFile.setValue ( "EnableY", ui.chkEnableY->isChecked() ); iniFile.setValue ( "EnableZ", ui.chkEnableZ->isChecked() ); -- cgit v1.2.3 From 1b49a5e35ee4ee488cab443c0e040a2e58a76af0 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 30 Nov 2013 17:57:08 +0100 Subject: fix bitrot shm name Reported-by: runningman84 Issue: github issue #10 Signed-off-by: Stanislaw Halik --- x-plane-plugin/plugin.c | 1 - 1 file changed, 1 deletion(-) diff --git a/x-plane-plugin/plugin.c b/x-plane-plugin/plugin.c index 2c43b98d..a8fd28d2 100644 --- a/x-plane-plugin/plugin.c +++ b/x-plane-plugin/plugin.c @@ -59,7 +59,6 @@ PortableLockedShm* PortableLockedShm_init(const char *shmName, const char *OT_UN shm_filename[0] = '/'; strncpy(shm_filename+1, shmName, NAME_MAX-2); shm_filename[NAME_MAX-1] = '\0'; - sprintf(shm_filename + strlen(shm_filename), "%ld\n", (long) getuid()); /* (void) shm_unlink(shm_filename); */ self->fd = shm_open(shm_filename, O_RDWR | O_CREAT, 0600); -- cgit v1.2.3 From f413502750855ea1394e12650395697bcab01498 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 30 Nov 2013 18:01:04 +0100 Subject: fix x-plane crashing on exit Signed-off-by: Stanislaw Halik --- x-plane-plugin/plugin.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/x-plane-plugin/plugin.c b/x-plane-plugin/plugin.c index a8fd28d2..ed6cdaff 100644 --- a/x-plane-plugin/plugin.c +++ b/x-plane-plugin/plugin.c @@ -129,7 +129,11 @@ PLUGIN_API int XPluginStart ( char * outName, char * outSignature, char * outDes PLUGIN_API void XPluginStop ( void ) { if (lck_posix) + { PortableLockedShm_free(lck_posix); + lck_posix = NULL; + shm_posix = NULL; + } } PLUGIN_API void XPluginEnable ( void ) { -- cgit v1.2.3 From 3004416b35dea148212d4aa881ae099d20f3e313 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 30 Nov 2013 18:05:40 +0100 Subject: untested merge from compat, hopefully fix osx Signed-off-by: Stanislaw Halik --- x-plane-plugin/plugin.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/x-plane-plugin/plugin.c b/x-plane-plugin/plugin.c index ed6cdaff..62c9d6f0 100644 --- a/x-plane-plugin/plugin.c +++ b/x-plane-plugin/plugin.c @@ -62,10 +62,8 @@ PortableLockedShm* PortableLockedShm_init(const char *shmName, const char *OT_UN /* (void) shm_unlink(shm_filename); */ self->fd = shm_open(shm_filename, O_RDWR | O_CREAT, 0600); - if (ftruncate(self->fd, mapSize) == 0) - self->mem = mmap(NULL, mapSize, PROT_READ|PROT_WRITE, MAP_SHARED, self->fd, (off_t)0); - else - self->mem = (void*) -1; + (void) ftruncate(self->fd, mapSize); + self->mem = mmap(NULL, mapSize, PROT_READ|PROT_WRITE, MAP_SHARED, self->fd, (off_t)0); return self; } -- cgit v1.2.3 From b66000f27178f515455a7a62f294062ef81d1ca4 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 30 Nov 2013 18:32:37 +0100 Subject: Don't unlink shm in wine proto Reported-by: runningman84 Issue: github issue #11 --- ftnoir_protocol_wine/ftnoir_protocol_wine.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ftnoir_protocol_wine/ftnoir_protocol_wine.cpp b/ftnoir_protocol_wine/ftnoir_protocol_wine.cpp index d9c3f1e0..58ffe974 100644 --- a/ftnoir_protocol_wine/ftnoir_protocol_wine.cpp +++ b/ftnoir_protocol_wine/ftnoir_protocol_wine.cpp @@ -27,7 +27,7 @@ FTNoIR_Protocol::~FTNoIR_Protocol() wrapper.kill(); wrapper.waitForFinished(42); } - shm_unlink("/" WINE_SHM_NAME); + //shm_unlink("/" WINE_SHM_NAME); } void FTNoIR_Protocol::sendHeadposeToGame( const double *headpose ) { -- cgit v1.2.3 From d7e7760a822e62d3f03f51c7b853ad27a998346b Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 1 Dec 2013 04:55:07 +0100 Subject: fix typo Signed-off-by: Stanislaw Halik --- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index 218f2d30..7581b77a 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -338,7 +338,7 @@ void Tracker::run() 0, sin(beta), cos(beta) }; cv::Mat rot(3, 3, CV_64F, pitch); - tvec = rot * tvec; + cv::Mat tvec2 = rot * tvec; rotation_matrix = rot * rotation_matrix; cv::Vec3d euler = cv::RQDecomp3x3(rotation_matrix, junk1, junk2); @@ -346,7 +346,7 @@ void Tracker::run() QMutexLocker lck(&mtx); for (int i = 0; i < 3; i++) - pose[i] = tvec.at(i); + pose[i] = tvec2.at(i); pose[Yaw] = euler[1]; pose[Pitch] = -euler[0]; -- cgit v1.2.3 From ee363beaf5a51b21c952cba14d818018b3855f18 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 1 Dec 2013 12:17:08 +0100 Subject: Revert "Remove Kalman filter again, unsuitable for nonlinear systems" This reverts commit d20c56f439c05528967b2bc408a6594a5605675e. With best regards to dbaarda :-) Conflicts: CMakeLists.txt Signed-off-by: Stanislaw Halik --- CMakeLists.txt | 16 ++ ftnoir_filter_kalman/ftnoir_filter_kalman.h | 87 +++++++++ .../ftnoir_kalman_filtercontrols.ui | 211 +++++++++++++++++++++ ftnoir_filter_kalman/images/filter-16-ac.png | Bin 0 -> 725 bytes ftnoir_filter_kalman/kalman-filter.qrc | 5 + ftnoir_filter_kalman/kalman.cpp | 156 +++++++++++++++ 6 files changed, 475 insertions(+) create mode 100644 ftnoir_filter_kalman/ftnoir_filter_kalman.h create mode 100644 ftnoir_filter_kalman/ftnoir_kalman_filtercontrols.ui create mode 100644 ftnoir_filter_kalman/images/filter-16-ac.png create mode 100644 ftnoir_filter_kalman/kalman-filter.qrc create mode 100644 ftnoir_filter_kalman/kalman.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 420114bb..e0b0f017 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -196,6 +196,13 @@ file(GLOB opentrack-filter-accela-rc "ftnoir_filter_accela/*.qrc") QT5_WRAP_UI(opentrack-filter-accela-uih ${opentrack-filter-accela-ui}) QT5_ADD_RESOURCES(opentrack-filter-accela-rcc ${opentrack-filter-accela-rc}) +file(GLOB opentrack-filter-kalman-c "ftnoir_filter_kalman/*.cpp") +file(GLOB opentrack-filter-kalman-h "ftnoir_filter_kalman/*.h") +file(GLOB opentrack-filter-kalman-ui "ftnoir_filter_kalman/*.ui") +file(GLOB opentrack-filter-kalman-rc "ftnoir_filter_kalman/*.qrc") +QT5_WRAP_UI(opentrack-filter-kalman-uih ${opentrack-filter-kalman-ui}) +QT5_ADD_RESOURCES(opentrack-filter-kalman-rcc ${opentrack-filter-kalman-rc}) + file(GLOB opentrack-filter-ewma-c "ftnoir_filter_ewma2/*.cpp") file(GLOB opentrack-filter-ewma-h "ftnoir_filter_ewma2/*.h") file(GLOB opentrack-filter-ewma-ui "ftnoir_filter_ewma2/*.ui") @@ -402,6 +409,14 @@ target_link_libraries(opentrack-spline-widget ${MY_QT_LIBS}) add_library(opentrack-filter-accela SHARED ${opentrack-filter-accela-c} ${opentrack-filter-accela-h} ${opentrack-filter-accela-moc} ${opentrack-filter-accela-uih} ${opentrack-filter-accela-rcc}) target_link_libraries(opentrack-filter-accela ${MY_QT_LIBS}) +add_library(opentrack-filter-kalman SHARED ${opentrack-filter-kalman-c} ${opentrack-filter-kalman-h} ${opentrack-filter-kalman-moc} ${opentrack-filter-kalman-uih} ${opentrack-filter-kalman-rcc}) +target_link_libraries(opentrack-filter-kalman ${MY_QT_LIBS} ${OpenCV_LIBS}) + +if(CMAKE_COMPILER_IS_GNUCXX) + SET_TARGET_PROPERTIES(opentrack-filter-kalman + PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt") +endif() + if(CMAKE_COMPILER_IS_GNUCXX) SET_TARGET_PROPERTIES(opentrack-filter-accela PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt") @@ -766,6 +781,7 @@ install(TARGETS opentrack-pose-widget opentrack-spline-widget opentrack-filter-accela + opentrack-filter-kalman opentrack-filter-ewma opentrack-tracker-ht opentrack-tracker-udp diff --git a/ftnoir_filter_kalman/ftnoir_filter_kalman.h b/ftnoir_filter_kalman/ftnoir_filter_kalman.h new file mode 100644 index 00000000..59169612 --- /dev/null +++ b/ftnoir_filter_kalman/ftnoir_filter_kalman.h @@ -0,0 +1,87 @@ +#pragma once +/* Copyright (c) 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. + */ +#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_kalman_filtercontrols.h" +#include "facetracknoir/global-settings.h" +#include +#include +#include +#include +#include +#include + +class FTNOIR_FILTER_BASE_EXPORT FTNoIR_Filter : public IFilter +{ +public: + FTNoIR_Filter(); + virtual ~FTNoIR_Filter() { + } + void Initialize(); + void FilterHeadPoseData(double *current_camera_position, + double *target_camera_position, + double *new_camera_position, + double *last_post_filter_values); + cv::KalmanFilter kalman; + double prev_position[6]; +}; + +void kalman_load_settings(FTNoIR_Filter& self); +void kalman_save_settings(FTNoIR_Filter& self); + +class FTNOIR_FILTER_BASE_EXPORT FTNoIR_FilterDll : public Metadata +{ +public: + void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("Kalman filter"); } + void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("Kalman filter"); } + void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("Kalman filter"); } + void getIcon(QIcon *icon){ *icon = QIcon(":/images/filter-16.png"); } +}; + +class FTNOIR_FILTER_BASE_EXPORT FilterControls: public QWidget, Ui::KalmanUICFilterControls, public IFilterDialog +{ + Q_OBJECT +public: + explicit FilterControls() : settingsDirty(false) { + ui.setupUi(this); + 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("ftnoir-filter-kalman"); + iniFile.endGroup(); + connect(ui.btnOk, SIGNAL(clicked()), this, SLOT(doOK())); + connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); + show(); + } + virtual ~FilterControls() {} + void showEvent ( QShowEvent * event ) { + show(); + } + + void Initialize(QWidget *parent, IFilter* ptr) { + } + + bool settingsDirty; + Ui::KalmanUICFilterControls ui; + +public slots: + void doOK(); + void doCancel(); + void settingsChanged(double unused) { + settingsDirty = true; + } +}; + +#endif diff --git a/ftnoir_filter_kalman/ftnoir_kalman_filtercontrols.ui b/ftnoir_filter_kalman/ftnoir_kalman_filtercontrols.ui new file mode 100644 index 00000000..7b71712a --- /dev/null +++ b/ftnoir_filter_kalman/ftnoir_kalman_filtercontrols.ui @@ -0,0 +1,211 @@ + + + KalmanUICFilterControls + + + Qt::ApplicationModal + + + + 0 + 0 + 334 + 100 + + + + + 0 + 0 + + + + Filter settings + + + + + images/facetracknoir.png + images/facetracknoir.png + + + Qt::LeftToRight + + + false + + + + + + + + 173 + 70 + 73 + 25 + + + + OK + + + + + + 250 + 70 + 73 + 25 + + + + Cancel + + + + + + 9 + 30 + 169 + 16 + + + + process-noise-covariance + + + + + + 180 + 26 + 150 + 22 + + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + 14 + + + 1.000000000000000 + + + 0.000001000000000 + + + 0.500000000000000 + + + + + + 180 + 6 + 150 + 22 + + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + 14 + + + 1.000000000000000 + + + 0.000001000000000 + + + 0.500000000000000 + + + + + + 9 + 10 + 165 + 16 + + + + post-error-matrix + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + 0 + + + + + + 9 + 55 + 109 + 16 + + + + accel-coefficient + + + + + + 181 + 47 + 150 + 22 + + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + 6 + + + 1000000000.000000000000000 + + + 0.000001000000000 + + + 1.000000000000000 + + + + + + + + 10 + + + 10 + + + false + + + false + + + true + + + + startEngineClicked() + stopEngineClicked() + cameraSettingsClicked() + + diff --git a/ftnoir_filter_kalman/images/filter-16-ac.png b/ftnoir_filter_kalman/images/filter-16-ac.png new file mode 100644 index 00000000..d263db2d Binary files /dev/null and b/ftnoir_filter_kalman/images/filter-16-ac.png differ diff --git a/ftnoir_filter_kalman/kalman-filter.qrc b/ftnoir_filter_kalman/kalman-filter.qrc new file mode 100644 index 00000000..9a7d75fa --- /dev/null +++ b/ftnoir_filter_kalman/kalman-filter.qrc @@ -0,0 +1,5 @@ + + + images/filter-16-ac.png + + diff --git a/ftnoir_filter_kalman/kalman.cpp b/ftnoir_filter_kalman/kalman.cpp new file mode 100644 index 00000000..51af35e1 --- /dev/null +++ b/ftnoir_filter_kalman/kalman.cpp @@ -0,0 +1,156 @@ +/* Copyright (c) 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 "ftnoir_filter_kalman.h" +#include "facetracknoir/global-settings.h" +#include +#include + +void kalman_load_settings(FTNoIR_Filter& self) { + 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("ftnoir-filter-kalman"); + iniFile.endGroup(); +} + +void kalman_save_settings(FilterControls& self) { + 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("ftnoir-filter-kalman"); + iniFile.endGroup(); +} + +FTNoIR_Filter::FTNoIR_Filter() { + kalman_load_settings(*this); + Initialize(); +} + +// the following was written by Donovan Baarda +// https://sourceforge.net/p/facetracknoir/discussion/1150909/thread/418615e1/?limit=25#af75/084b +void FTNoIR_Filter::Initialize() { + const double accel_variance = 1e-4; + const double noise_variance = 1e1; + kalman.init(12, 6, 0, CV_64F); + kalman.transitionMatrix = (cv::Mat_(12, 12) << + 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, + 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, + 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, + 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1); + double a = 0.25 * accel_variance; + double b = 0.5 * accel_variance; + double c = 1.0 * accel_variance; + kalman.processNoiseCov = (cv::Mat_(12, 12) << + a, 0, 0, 0, 0, 0, b, 0, 0, 0, 0, 0, + 0, a, 0, 0, 0, 0, 0, b, 0, 0, 0, 0, + 0, 0, a, 0, 0, 0, 0, 0, b, 0, 0, 0, + 0, 0, 0, a, 0, 0, 0, 0, 0, b, 0, 0, + 0, 0, 0, 0, a, 0, 0, 0, 0, 0, b, 0, + 0, 0, 0, 0, 0, a, 0, 0, 0, 0, 0, b, + b, 0, 0, 0, 0, 0, c, 0, 0, 0, 0, 0, + 0, b, 0, 0, 0, 0, 0, c, 0, 0, 0, 0, + 0, 0, b, 0, 0, 0, 0, 0, c, 0, 0, 0, + 0, 0, 0, b, 0, 0, 0, 0, 0, c, 0, 0, + 0, 0, 0, 0, b, 0, 0, 0, 0, 0, c, 0, + 0, 0, 0, 0, 0, b, 0, 0, 0, 0, 0, c); + cv::setIdentity(kalman.measurementMatrix); + cv::setIdentity(kalman.measurementNoiseCov, cv::Scalar::all(noise_variance)); + cv::setIdentity(kalman.errorCovPost, cv::Scalar::all(accel_variance * 1e4)); + for (int i = 0; i < 6; i++) + prev_position[i] = 0; +} + +void FTNoIR_Filter::FilterHeadPoseData(double *current_camera_position, + double *target_camera_position, + double *new_camera_position, + double *last_post_filter_values) +{ + bool new_target = false; + + for (int i = 0; i < 6; i++) + if (prev_position[i] != target_camera_position[i]) + { + new_target = true; + break; + } + + cv::Mat output = kalman.predict(); + + if (new_target) { + cv::Mat measurement(6, 1, CV_64F); + for (int i = 0; i < 3; i++) { + measurement.at(i) = target_camera_position[i+3]; + measurement.at(i+3) = target_camera_position[i]; + } + kalman.correct(measurement); + } + + for (int i = 0; i < 3; i++) { + new_camera_position[i] = output.at(i+3); + new_camera_position[i+3] = output.at(i); + prev_position[i] = target_camera_position[i]; + prev_position[i+3] = target_camera_position[i+3]; + } +} + +void FilterControls::doOK() { + kalman_save_settings(*this); + close(); +} + +void FilterControls::doCancel() { + 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: + kalman_save_settings(*this); + 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(); + } +} + +extern "C" FTNOIR_FILTER_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata() +{ + return new FTNoIR_FilterDll; +} + +extern "C" FTNOIR_FILTER_BASE_EXPORT IFilter* CALLING_CONVENTION GetConstructor() +{ + return new FTNoIR_Filter; +} + +extern "C" FTNOIR_FILTER_BASE_EXPORT IFilterDialog* CALLING_CONVENTION GetDialog() { + return new FilterControls; +} -- cgit v1.2.3 From b2bd39a926aa338796ceb2ef606fea70b5eb0333 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 1 Dec 2013 12:17:27 +0100 Subject: prevent redefinition warning Signed-off-by: Stanislaw Halik --- ftnoir_tracker_base/ftnoir_tracker_base_global.h | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/ftnoir_tracker_base/ftnoir_tracker_base_global.h b/ftnoir_tracker_base/ftnoir_tracker_base_global.h index a529da78..e717d845 100644 --- a/ftnoir_tracker_base/ftnoir_tracker_base_global.h +++ b/ftnoir_tracker_base/ftnoir_tracker_base_global.h @@ -3,14 +3,16 @@ #include -#ifndef OPENTRACK_MAIN -# if !defined(_MSC_VER) -# define FTNOIR_TRACKER_BASE_EXPORT __attribute__ ((visibility ("default"))) -# else -# define FTNOIR_TRACKER_BASE_EXPORT Q_DECL_EXPORT -#endif -#else -# define FTNOIR_TRACKER_BASE_EXPORT Q_DECL_IMPORT +#ifndef FTNOIR_TRACKER_BASE_EXPORT +# ifndef OPENTRACK_MAIN +# if !defined(_MSC_VER) +# define FTNOIR_TRACKER_BASE_EXPORT __attribute__ ((visibility ("default"))) +# else +# define FTNOIR_TRACKER_BASE_EXPORT Q_DECL_EXPORT +# endif +# else +# define FTNOIR_TRACKER_BASE_EXPORT Q_DECL_IMPORT +# endif #endif #endif // FTNOIR_TRACKER_BASE_GLOBAL_H -- cgit v1.2.3 From cb233e361a859bc3271cdccd701e1690af459592 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 1 Dec 2013 12:17:43 +0100 Subject: accela: implement a third-order highpass filter Signed-off-by: Stanislaw Halik --- .../ftnoir_accela_filtercontrols.ui | 88 +++++++++++++++++++--- ftnoir_filter_accela/ftnoir_filter_accela.cpp | 16 +++- ftnoir_filter_accela/ftnoir_filter_accela.h | 7 +- .../ftnoir_filter_accela_dialog.cpp | 4 + ftnoir_filter_kalman/ftnoir_filter_kalman.h | 33 ++++---- ftnoir_filter_kalman/kalman.cpp | 60 ++++++++++----- 6 files changed, 166 insertions(+), 42 deletions(-) diff --git a/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui b/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui index 5ba33614..b4b12061 100644 --- a/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui +++ b/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui @@ -10,7 +10,7 @@ 0 0 347 - 268 + 339 @@ -109,7 +109,7 @@ QAbstractSpinBox::CorrectToPreviousValue - 3 + 4 0.100000000000000 @@ -147,7 +147,7 @@ Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - 3 + 4 0.100000000000000 @@ -160,7 +160,7 @@ - + @@ -189,7 +189,7 @@ background:none; - + @@ -229,7 +229,7 @@ background:none; - + @@ -258,7 +258,7 @@ background:none; - + @@ -286,14 +286,14 @@ background:none; - + Exponent - + @@ -315,6 +315,76 @@ 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 + + + diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.cpp b/ftnoir_filter_accela/ftnoir_filter_accela.cpp index 9189ec8a..1f9b493f 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela.cpp @@ -34,7 +34,8 @@ void FTNoIR_Filter::loadSettings() { 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(); + third_order_alpha = iniFile.value("third-order-alpha", ACCELA_THIRD_ORDER_ALPHA).toDouble(); deadzone = iniFile.value("deadzone", 0.0).toDouble(); // bigger means less filtering static const double init_scaling[] = { @@ -81,6 +82,8 @@ void FTNoIR_Filter::FilterHeadPoseData(const double* target_camera_position, { new_camera_position[i] = target_camera_position[i]; current_camera_position[i] = target_camera_position[i]; + current_camera_position_2[i] = target_camera_position[i]; + current_camera_position_3[i] = target_camera_position[i]; } first_run = false; @@ -95,10 +98,19 @@ void FTNoIR_Filter::FilterHeadPoseData(const double* target_camera_position, const int sign = vec < 0 ? -1 : 1; const double x = fabs(vec); 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 x2 = fabs(target_camera_position[i] - current_camera_position_2[i]); + const double x3 = fabs(target_camera_position[i] - current_camera_position_3[i]); const double reduction = 1. / std::max(1., 1. + zoom_factor * -last_post_filter_values[TZ] / 1000); - const double velocity = parabola(a, x * scaling[i], deadzone, expt) * reduction; + const double velocity = + parabola(a, x * scaling[i], deadzone, expt) * reduction + + parabola(a2, x2 * scaling[i], deadzone, expt) * reduction + + parabola(a3, x3 * scaling[i], deadzone, expt) * 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]; + current_camera_position_3[i] = current_camera_position_2[i]; + current_camera_position_2[i] = current_camera_position[i]; new_camera_position[i] = current_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 8c770df9..eec97758 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.h +++ b/ftnoir_filter_accela/ftnoir_filter_accela.h @@ -33,7 +33,9 @@ #define ACCELA_SMOOTHING_ROTATION 60.0 #define ACCELA_SMOOTHING_TRANSLATION 40.0 -#define ACCELA_ZOOM_SLOWNESS 35 +#define ACCELA_ZOOM_SLOWNESS 0 +#define ACCELA_SECOND_ORDER_ALPHA 100.0 +#define ACCELA_THIRD_ORDER_ALPHA 180.0 //******************************************************************************************************* // FaceTrackNoIR Filter class. @@ -53,7 +55,10 @@ private: void loadSettings(); bool first_run; double rotation_alpha, translation_alpha, zoom_factor; + double second_order_alpha, third_order_alpha; double current_camera_position[6]; + double current_camera_position_2[6]; + double current_camera_position_3[6]; double scaling[6]; double deadzone; double expt; diff --git a/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp b/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp index 88c0a794..68484e77 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp @@ -160,6 +160,8 @@ void FilterControls::loadSettings() { 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()); + ui.order_3rd->setValue(iniFile.value("third-order-alpha", ACCELA_THIRD_ORDER_ALPHA).toDouble()); ui.deadzone->setValue(iniFile.value("deadzone", 0).toDouble()); // bigger means less filtering @@ -212,6 +214,8 @@ void FilterControls::save() { iniFile.setValue("zoom-slowness", zoom = ui.spinZoom->value()); iniFile.setValue("deadzone", deadzone = ui.deadzone->value()); iniFile.setValue("exponent", expt = ui.expt->value()); + iniFile.setValue("second-order-alpha", rot = ui.order_2nd->value()); + iniFile.setValue("third-order-alpha", rot = ui.order_3rd->value()); QDoubleSpinBox* boxen[] = { ui.doubleSpinBox, diff --git a/ftnoir_filter_kalman/ftnoir_filter_kalman.h b/ftnoir_filter_kalman/ftnoir_filter_kalman.h index 59169612..6c2cb6a9 100644 --- a/ftnoir_filter_kalman/ftnoir_filter_kalman.h +++ b/ftnoir_filter_kalman/ftnoir_filter_kalman.h @@ -19,25 +19,29 @@ #include #include #include +#include #include class FTNOIR_FILTER_BASE_EXPORT FTNoIR_Filter : public IFilter { public: FTNoIR_Filter(); - virtual ~FTNoIR_Filter() { + ~FTNoIR_Filter() virt_override { } - void Initialize(); - void FilterHeadPoseData(double *current_camera_position, - double *target_camera_position, + void Initialize() virt_override; + void FilterHeadPoseData(const double *target_camera_position, double *new_camera_position, - double *last_post_filter_values); + const double *) virt_override; cv::KalmanFilter kalman; double prev_position[6]; + double prev2_filter_pos[6]; + double prev_filter_pos[6]; + QElapsedTimer timer; + qint64 timedelta; }; -void kalman_load_settings(FTNoIR_Filter& self); -void kalman_save_settings(FTNoIR_Filter& self); +void kalman_load_settings(FTNoIR_Filter&); +void kalman_save_settings(FTNoIR_Filter&); class FTNOIR_FILTER_BASE_EXPORT FTNoIR_FilterDll : public Metadata { @@ -48,7 +52,7 @@ public: void getIcon(QIcon *icon){ *icon = QIcon(":/images/filter-16.png"); } }; -class FTNOIR_FILTER_BASE_EXPORT FilterControls: public QWidget, Ui::KalmanUICFilterControls, public IFilterDialog +class FTNOIR_FILTER_BASE_EXPORT FilterControls: public QWidget, public IFilterDialog { Q_OBJECT public: @@ -65,21 +69,24 @@ public: connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); show(); } - virtual ~FilterControls() {} - void showEvent ( QShowEvent * event ) { + ~FilterControls() {} + void showEvent ( QShowEvent * ) virt_override { show(); } - void Initialize(QWidget *parent, IFilter* ptr) { + void Initialize(QWidget *) virt_override { + show(); + raise(); } bool settingsDirty; Ui::KalmanUICFilterControls ui; - + virtual void registerFilter(IFilter*) virt_override {} + virtual void unregisterFilter() virt_override {} public slots: void doOK(); void doCancel(); - void settingsChanged(double unused) { + void settingsChanged(double) { settingsDirty = true; } }; diff --git a/ftnoir_filter_kalman/kalman.cpp b/ftnoir_filter_kalman/kalman.cpp index 51af35e1..5ecd417c 100644 --- a/ftnoir_filter_kalman/kalman.cpp +++ b/ftnoir_filter_kalman/kalman.cpp @@ -9,7 +9,7 @@ #include #include -void kalman_load_settings(FTNoIR_Filter& self) { +void kalman_load_settings(FTNoIR_Filter&) { QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // Registry settings (in HK_USER) QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); @@ -19,7 +19,7 @@ void kalman_load_settings(FTNoIR_Filter& self) { iniFile.endGroup(); } -void kalman_save_settings(FilterControls& self) { +void kalman_save_settings(FilterControls&) { QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // Registry settings (in HK_USER) QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); @@ -37,8 +37,8 @@ FTNoIR_Filter::FTNoIR_Filter() { // the following was written by Donovan Baarda // https://sourceforge.net/p/facetracknoir/discussion/1150909/thread/418615e1/?limit=25#af75/084b void FTNoIR_Filter::Initialize() { - const double accel_variance = 1e-4; - const double noise_variance = 1e1; + const double accel_variance = 1e-3; + const double noise_variance = 5e2; kalman.init(12, 6, 0, CV_64F); kalman.transitionMatrix = (cv::Mat_(12, 12) << 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, @@ -73,13 +73,28 @@ void FTNoIR_Filter::Initialize() { cv::setIdentity(kalman.measurementNoiseCov, cv::Scalar::all(noise_variance)); cv::setIdentity(kalman.errorCovPost, cv::Scalar::all(accel_variance * 1e4)); for (int i = 0; i < 6; i++) + { prev_position[i] = 0; + prev2_filter_pos[i] = 0; + prev_filter_pos[i] = 0; + timedelta = 1; + timer.invalidate(); + } +} + +template +static inline T clamp(const T min, const T max, const T value) +{ + if (value < min) + return min; + if (value > max) + return max; + return value; } -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 *) { bool new_target = false; @@ -89,23 +104,34 @@ void FTNoIR_Filter::FilterHeadPoseData(double *current_camera_position, new_target = true; break; } - - cv::Mat output = kalman.predict(); - + if (new_target) { + cv::Mat output = kalman.predict(); cv::Mat measurement(6, 1, CV_64F); for (int i = 0; i < 3; i++) { measurement.at(i) = target_camera_position[i+3]; measurement.at(i+3) = target_camera_position[i]; } kalman.correct(measurement); - } - - for (int i = 0; i < 3; i++) { - new_camera_position[i] = output.at(i+3); - new_camera_position[i+3] = output.at(i); - prev_position[i] = target_camera_position[i]; - prev_position[i+3] = target_camera_position[i+3]; + for (int i = 0; i < 6; i++) + { + prev_position[i] = target_camera_position[i]; + } + if (timer.isValid()) + timedelta = timer.elapsed(); + else + timedelta = 1; + for (int i = 0; i < 6; i++) + { + prev2_filter_pos[i] = prev_filter_pos[i]; + prev_filter_pos[i] = new_camera_position[i] = output.at((i + 3) % 6); + } + timer.start(); + } else { + auto d = timer.isValid() ? timer.elapsed() : 1; + auto c = clamp(0.0, 1.0, d / (double) timedelta); + for (int i = 0; i < 6; i++) + new_camera_position[i] = prev2_filter_pos[i] + (prev_filter_pos[i] - prev2_filter_pos[i]) * c; } } -- cgit v1.2.3 From 4f0c9ceba14efba6a91518ab3d4f0c84bdb5c5e1 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 1 Dec 2013 12:30:22 +0100 Subject: accela: bump version Signed-off-by: Stanislaw Halik --- ftnoir_filter_accela/ftnoir_filter_accela.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.h b/ftnoir_filter_accela/ftnoir_filter_accela.h index eec97758..f5c0b8bc 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.h +++ b/ftnoir_filter_accela/ftnoir_filter_accela.h @@ -102,9 +102,9 @@ 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 getFullName(QString *strToBeFilled) { *strToBeFilled = QString("Accela Filter Mk4"); } + void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("Accela Mk4"); } + void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("Accela filter Mk4"); } void getIcon(QIcon *icon){ *icon = QIcon(":/images/filter-16.png"); } }; -- 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(-) 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(-) 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 3f7f65c1bf67d0e1dc560ee6136ad9c6e82e73bb Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 1 Dec 2013 13:14:57 +0100 Subject: fix sign issues now that order > 1 Signed-off-by: Stanislaw Halik --- ftnoir_filter_accela/ftnoir_filter_accela.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.cpp b/ftnoir_filter_accela/ftnoir_filter_accela.cpp index 1f9b493f..e2fd7cc0 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela.cpp @@ -68,8 +68,9 @@ void FTNoIR_Filter::receiveSettings(double rot, double trans, double zoom_fac, d static inline double parabola(const double a, const double x, const double dz, const double expt) { + const double sign = x > 0 ? 1 : -1; const double a1 = 1./a; - return a1 * pow(std::max(x - dz, 1e-3), expt); + return a1 * pow(std::max(fabs(x) - dz, 1e-3), expt) * sign; } void FTNoIR_Filter::FilterHeadPoseData(const double* target_camera_position, @@ -95,19 +96,18 @@ void FTNoIR_Filter::FilterHeadPoseData(const double* target_camera_position, for (int i=0;i<6;i++) { const double vec = target_camera_position[i] - current_camera_position[i]; + const double vec2 = target_camera_position[i] - current_camera_position_2[i]; + const double vec3 = target_camera_position[i] - current_camera_position_3[i]; const int sign = vec < 0 ? -1 : 1; - const double x = fabs(vec); 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 x2 = fabs(target_camera_position[i] - current_camera_position_2[i]); - const double x3 = fabs(target_camera_position[i] - current_camera_position_3[i]); const double reduction = 1. / std::max(1., 1. + zoom_factor * -last_post_filter_values[TZ] / 1000); const double velocity = - parabola(a, x * scaling[i], deadzone, expt) * reduction + - parabola(a2, x2 * scaling[i], deadzone, expt) * reduction + - parabola(a3, x3 * scaling[i], deadzone, expt) * reduction; - const double result = current_camera_position[i] + velocity * sign; + parabola(a, vec * scaling[i], deadzone, expt) * reduction + + parabola(a2, vec2 * scaling[i], deadzone, expt) * reduction + + parabola(a3, vec3 * scaling[i], deadzone, expt) * reduction; + const double result = current_camera_position[i] + velocity; const bool done = sign > 0 ? result >= target_camera_position[i] : result <= target_camera_position[i]; current_camera_position_3[i] = current_camera_position_2[i]; current_camera_position_2[i] = current_camera_position[i]; -- cgit v1.2.3 From 16d0d632ea10f25845407b4fb483a5d8c83260d4 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 2 Dec 2013 09:30:19 +0100 Subject: accela: simplify, don't filter empty updates Signed-off-by: Stanislaw Halik --- ftnoir_filter_accela/ftnoir_filter_accela.cpp | 62 ++++++++++++++++++++++----- ftnoir_filter_accela/ftnoir_filter_accela.h | 8 ++-- 2 files changed, 56 insertions(+), 14 deletions(-) diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.cpp b/ftnoir_filter_accela/ftnoir_filter_accela.cpp index e2fd7cc0..fd47f18d 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela.cpp @@ -73,6 +73,16 @@ static inline double parabola(const double a, const double x, const double dz, c return a1 * pow(std::max(fabs(x) - dz, 1e-3), expt) * sign; } +template +static inline T clamp(const T min, const T max, const T value) +{ + if (value < min) + return min; + if (value > max) + return max; + return value; +} + void FTNoIR_Filter::FilterHeadPoseData(const double* target_camera_position, double *new_camera_position, const double* last_post_filter_values) @@ -82,22 +92,51 @@ void FTNoIR_Filter::FilterHeadPoseData(const double* target_camera_position, for (int i = 0; i < 6; i++) { new_camera_position[i] = target_camera_position[i]; - current_camera_position[i] = target_camera_position[i]; - current_camera_position_2[i] = target_camera_position[i]; - current_camera_position_3[i] = target_camera_position[i]; + last_input[i] = target_camera_position[i]; + for (int j = 0; j < 3; j++) + last_output[j][i] = target_camera_position[i]; } - first_run = false; + timer.start(); + frame_delta = 1; + first_run = false; return; } + + bool new_frame = false; + + for (int i = 0; i < 6; i++) + { + if (target_camera_position[i] != last_input[i]) + { + new_frame = true; + break; + } + } + + if (new_frame) + { + for (int i = 0; i < 6; i++) + last_input[i] = target_camera_position[i]; + frame_delta = timer.isValid() ? timer.elapsed() : 1; + timer.start(); + } else { + auto d = timer.elapsed(); + double c = clamp(0.0, 1.0, d / (double) frame_delta); + QMutexLocker foo(&mutex); + for (int i = 0; i < 6; i++) + new_camera_position[i] = + last_output[1][i] + (last_output[0][i] - last_output[1][i]) * c; + return; + } QMutexLocker foo(&mutex); for (int i=0;i<6;i++) { - const double vec = target_camera_position[i] - current_camera_position[i]; - const double vec2 = target_camera_position[i] - current_camera_position_2[i]; - const double vec3 = target_camera_position[i] - current_camera_position_3[i]; + const double vec = target_camera_position[i] - last_output[0][i]; + const double vec2 = target_camera_position[i] - last_output[1][i]; + const double vec3 = target_camera_position[i] - last_output[2][i]; const int sign = vec < 0 ? -1 : 1; const double a = i >= 3 ? rotation_alpha : translation_alpha; const double a2 = a * second_order_alpha; @@ -107,11 +146,12 @@ void FTNoIR_Filter::FilterHeadPoseData(const double* target_camera_position, parabola(a, vec * scaling[i], deadzone, expt) * reduction + parabola(a2, vec2 * scaling[i], deadzone, expt) * reduction + parabola(a3, vec3 * scaling[i], deadzone, expt) * reduction; - const double result = current_camera_position[i] + velocity; + const double result = last_output[0][i] + velocity; const bool done = sign > 0 ? result >= target_camera_position[i] : result <= target_camera_position[i]; - current_camera_position_3[i] = current_camera_position_2[i]; - current_camera_position_2[i] = current_camera_position[i]; - new_camera_position[i] = current_camera_position[i] = done ? target_camera_position[i] : result; + new_camera_position[i] = done ? target_camera_position[i] : result; + last_output[2][i] = last_output[1][i]; + last_output[1][i] = last_output[0][i]; + last_output[0][i] = new_camera_position[i]; } } diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.h b/ftnoir_filter_accela/ftnoir_filter_accela.h index f5c0b8bc..c92e28df 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.h +++ b/ftnoir_filter_accela/ftnoir_filter_accela.h @@ -30,6 +30,7 @@ #include "ui_ftnoir_accela_filtercontrols.h" #include "facetracknoir/global-settings.h" #include +#include #define ACCELA_SMOOTHING_ROTATION 60.0 #define ACCELA_SMOOTHING_TRANSLATION 40.0 @@ -56,12 +57,13 @@ private: bool first_run; double rotation_alpha, translation_alpha, zoom_factor; double second_order_alpha, third_order_alpha; - double current_camera_position[6]; - double current_camera_position_2[6]; - double current_camera_position_3[6]; double scaling[6]; double deadzone; double expt; + double last_input[6]; + double last_output[3][6]; + QElapsedTimer timer; + qint64 frame_delta; }; //******************************************************************************************************* -- cgit v1.2.3 From 5cd624a8ae93d0bb5f039daf6874f46cee443520 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 2 Dec 2013 10:28:08 +0100 Subject: accela: remove nonsense non-zero minimum Signed-off-by: Stanislaw Halik --- ftnoir_filter_accela/ftnoir_filter_accela.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.cpp b/ftnoir_filter_accela/ftnoir_filter_accela.cpp index fd47f18d..09f74e5a 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela.cpp @@ -70,7 +70,7 @@ static inline double parabola(const double a, const double x, const double dz, c { const double sign = x > 0 ? 1 : -1; const double a1 = 1./a; - return a1 * pow(std::max(fabs(x) - dz, 1e-3), expt) * sign; + return a1 * pow(std::max(fabs(x) - dz, 0), expt) * sign; } template -- cgit v1.2.3 From 020ca3f3d768fe353a802a125b45dcabd29b947e Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 2 Dec 2013 10:28:21 +0100 Subject: accela ui: rename deadzone to deadband Signed-off-by: Stanislaw Halik --- ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui b/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui index 536cf328..b48496bf 100644 --- a/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui +++ b/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui @@ -254,7 +254,7 @@ background:none; background:none; - Deadzone + Deadband
-- cgit v1.2.3 From 0d01d287f56584552eea650cb7b4c3a7912b5f6b Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 2 Dec 2013 10:36:31 +0100 Subject: remove redundant mutex acquisition Signed-off-by: Stanislaw Halik --- ftnoir_filter_accela/ftnoir_filter_accela.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.cpp b/ftnoir_filter_accela/ftnoir_filter_accela.cpp index 09f74e5a..08829e52 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela.cpp @@ -123,7 +123,6 @@ void FTNoIR_Filter::FilterHeadPoseData(const double* target_camera_position, } else { auto d = timer.elapsed(); double c = clamp(0.0, 1.0, d / (double) frame_delta); - QMutexLocker foo(&mutex); for (int i = 0; i < 6; i++) new_camera_position[i] = last_output[1][i] + (last_output[0][i] - last_output[1][i]) * c; -- 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 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 bb0b7ca45ca2091b52e969cf0948be2d908377c2 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 4 Dec 2013 18:45:39 +0100 Subject: fix msvc build --- CMakeLists.txt | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e0b0f017..bc9aaec3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -556,6 +556,12 @@ if(SDK_ARUCO_LIBPATH) SET_TARGET_PROPERTIES(opentrack-tracker-aruco PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt") endif() + if(WIN32 AND MSVC) + target_link_libraries(opentrack-tracker-aruco + "${CMAKE_SOURCE_DIR}/dinput/dxguid.lib" + "${CMAKE_SOURCE_DIR}/dinput/strmiids.lib" + uuid) + 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}) @@ -611,7 +617,8 @@ if(SDK_RIFT) add_library(opentrack-tracker-rift SHARED ${opentrack-tracker-rift-c} ${opentrack-tracker-rift-h} ${opentrack-tracker-rift-moc} ${opentrack-tracker-rift-uih} ${opentrack-tracker-rift-rcc}) target_link_libraries(opentrack-tracker-rift ${MY_QT_LIBS}) if(MSVC) - target_link_libraries(opentrack-tracker-rift "${SDK_RIFT}/Lib/Win32/libovr.lib" winmm.lib) + target_link_libraries(opentrack-tracker-rift "${SDK_RIFT}/Lib/Win32/libovr.lib" winmm.lib setupapi.lib) + set_target_properties(opentrack-tracker-rift PROPERTIES LINK_FLAGS "/NODEFAULTLIB:LIBCMT") else() if(WIN32) target_link_libraries(opentrack-tracker-rift "${SDK_RIFT}/libLibOVR.a" winmm.lib setupapi.lib) @@ -727,7 +734,7 @@ if(WIN32) ) endif() if(MSVC) - SET_TARGET_PROPERTIES(opentrack PROPERTIES LINK_FLAGS "/ENTRY:mainCRTStartup /NODEFAULTLIB:LIBCMT.LIB") + SET_TARGET_PROPERTIES(opentrack PROPERTIES LINK_FLAGS "/ENTRY:mainCRTStartup") endif() target_link_libraries(opentrack opentrack-pose-widget opentrack-spline-widget ${MY_QT_LIBS} ${QXT_QXTCORE_LIB_RELEASE} ${QXT_QXTWIDGETS_LIB_RELEASE}) if(NOT WIN32) -- cgit v1.2.3 From a6b1128a2d55720991513650cef4ceffa183a737 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 4 Dec 2013 18:45:57 +0100 Subject: update api, remove extern C --- ftnoir_tracker_ht/ht-api.h | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/ftnoir_tracker_ht/ht-api.h b/ftnoir_tracker_ht/ht-api.h index 66b87211..2ab2e840 100644 --- a/ftnoir_tracker_ht/ht-api.h +++ b/ftnoir_tracker_ht/ht-api.h @@ -1,14 +1,9 @@ #pragma once #ifndef HT_API -#ifndef __cplusplus -# define HT_EXTERN -#else -# define HT_EXTERN extern "C" -#endif # if defined(_WIN32) && !defined(MINGW) -# define HT_API(t) HT_EXTERN __declspec(dllexport) t __stdcall +# define HT_API(t) __declspec(dllexport) t __stdcall # else -# define HT_API(t) HT_EXTERN t +# define HT_API(t) t # endif #endif #if !defined(_WIN32) && !defined(_isnan) @@ -19,20 +14,20 @@ struct ht_context; typedef struct ht_context headtracker_t; typedef struct ht_config { - float field_of_view; - float classification_delay; - int pyrlk_pyramids; - int pyrlk_win_size_w; - int pyrlk_win_size_h; + float field_of_view; + float classification_delay; + int pyrlk_pyramids; + int pyrlk_win_size_w; + int pyrlk_win_size_h; float ransac_max_inlier_error; float ransac_max_reprojection_error; - int max_keypoints; - float keypoint_distance; + int max_keypoints; + float keypoint_distance; int force_width; - int force_height; - int force_fps; - int camera_index; - bool debug; + int force_height; + int force_fps; + int camera_index; + bool debug; int ransac_num_iters; float ransac_min_features; float ransac_max_mean_error; @@ -44,7 +39,7 @@ typedef struct ht_config { typedef struct { double rotx, roty, rotz; double tx, ty, tz; - bool filled; + bool filled; } ht_result_t; HT_API(headtracker_t*) ht_make_context(const ht_config_t* config, const char* filename); -- cgit v1.2.3 From 5d51487b70a07f1853f1cbcf84ac5eb635e38bbe Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 4 Dec 2013 18:46:15 +0100 Subject: fix crash with no rift --- ftnoir_tracker_rift/ftnoir_tracker_rift.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp b/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp index dd78bf9f..4816cea4 100644 --- a/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp +++ b/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp @@ -70,7 +70,7 @@ void Rift_Tracker::StartTracker(QFrame*) bool Rift_Tracker::GiveHeadPoseData(double *data) { - if (pSFusion != NULL) { + if (pSFusion != NULL && pSensor != NULL) { Quatf hmdOrient = pSFusion->GetOrientation(); double newHeadPose[6]; -- cgit v1.2.3 From 79119a08157aa954b3b2ecd18c8384b80a03970f Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 4 Dec 2013 18:46:27 +0100 Subject: draw images directly, without pixmaps --- FTNoIR_Tracker_PT/pt_video_widget.cpp | 2 +- FTNoIR_Tracker_PT/pt_video_widget.h | 4 ++-- ftnoir_posewidget/glwidget.cpp | 4 ++-- ftnoir_posewidget/glwidget.h | 2 +- ftnoir_tracker_aruco/ar_video_widget.cpp | 2 +- ftnoir_tracker_aruco/ar_video_widget.h | 4 ++-- ftnoir_tracker_ht/ht_video_widget.cpp | 2 +- ftnoir_tracker_ht/ht_video_widget.h | 4 ++-- 8 files changed, 12 insertions(+), 12 deletions(-) diff --git a/FTNoIR_Tracker_PT/pt_video_widget.cpp b/FTNoIR_Tracker_PT/pt_video_widget.cpp index d0fc8d42..5ac002f4 100644 --- a/FTNoIR_Tracker_PT/pt_video_widget.cpp +++ b/FTNoIR_Tracker_PT/pt_video_widget.cpp @@ -57,6 +57,6 @@ void PTVideoWidget::update_and_repaint() data[y * pitch + x * 3 + 2] = elt2.val[0]; } qframe = qframe.scaled(size(), Qt::IgnoreAspectRatio, Qt::FastTransformation); - pixmap = QPixmap::fromImage(qframe); + texture = qframe; update(); } diff --git a/FTNoIR_Tracker_PT/pt_video_widget.h b/FTNoIR_Tracker_PT/pt_video_widget.h index f5663e47..acff43fb 100644 --- a/FTNoIR_Tracker_PT/pt_video_widget.h +++ b/FTNoIR_Tracker_PT/pt_video_widget.h @@ -40,12 +40,12 @@ protected slots: void paintEvent( QPaintEvent* e ) { QMutexLocker foo(&mtx); QPainter painter(this); - painter.drawPixmap(e->rect(), pixmap, e->rect()); + painter.drawImage(e->rect(), texture); } void update_and_repaint(); private: QMutex mtx; - QPixmap pixmap; + QImage texture; QTimer timer; cv::Mat _frame; }; diff --git a/ftnoir_posewidget/glwidget.cpp b/ftnoir_posewidget/glwidget.cpp index 71af8a08..93c98c9c 100644 --- a/ftnoir_posewidget/glwidget.cpp +++ b/ftnoir_posewidget/glwidget.cpp @@ -26,7 +26,7 @@ void GLWidget::paintEvent ( QPaintEvent * event ) { QWidget::paintEvent(event); QPainter p(this); project_quad_texture(); - p.drawPixmap(event->rect(), pixmap, event->rect()); + p.drawImage(event->rect(), texture); } void GLWidget::rotateBy(double xAngle, double yAngle, double zAngle) @@ -226,5 +226,5 @@ void GLWidget::project_quad_texture() { } } } - pixmap = QPixmap::fromImage(texture); + this->texture = texture; } diff --git a/ftnoir_posewidget/glwidget.h b/ftnoir_posewidget/glwidget.h index 0bb693c8..c4b2e09d 100644 --- a/ftnoir_posewidget/glwidget.h +++ b/ftnoir_posewidget/glwidget.h @@ -91,7 +91,7 @@ private: double matrix[9]; QImage front; QImage back; - QPixmap pixmap; + QImage texture; }; #endif diff --git a/ftnoir_tracker_aruco/ar_video_widget.cpp b/ftnoir_tracker_aruco/ar_video_widget.cpp index c452a638..9a089213 100644 --- a/ftnoir_tracker_aruco/ar_video_widget.cpp +++ b/ftnoir_tracker_aruco/ar_video_widget.cpp @@ -37,6 +37,6 @@ void ArucoVideoWidget::update_and_repaint() } } auto qframe2 = qframe.scaled(size(), Qt::IgnoreAspectRatio, Qt::FastTransformation); - pixmap = QPixmap::fromImage(qframe2); + texture = qframe2; update(); } diff --git a/ftnoir_tracker_aruco/ar_video_widget.h b/ftnoir_tracker_aruco/ar_video_widget.h index b95d1873..e2cf4d9f 100644 --- a/ftnoir_tracker_aruco/ar_video_widget.h +++ b/ftnoir_tracker_aruco/ar_video_widget.h @@ -33,13 +33,13 @@ protected slots: void paintEvent( QPaintEvent* e ) { QMutexLocker foo(&mtx); QPainter painter(this); - painter.drawPixmap(e->rect(), pixmap, e->rect()); + painter.drawImage(e->rect(), texture); } void update_and_repaint(); private: QMutex mtx; - QPixmap pixmap; + QImage texture; QTimer timer; cv::Mat _frame; }; diff --git a/ftnoir_tracker_ht/ht_video_widget.cpp b/ftnoir_tracker_ht/ht_video_widget.cpp index 8ccec997..c6d59b34 100644 --- a/ftnoir_tracker_ht/ht_video_widget.cpp +++ b/ftnoir_tracker_ht/ht_video_widget.cpp @@ -39,6 +39,6 @@ void HTVideoWidget::update_and_repaint() } } auto qframe2 = qframe.scaled(size(), Qt::IgnoreAspectRatio, Qt::FastTransformation); - pixmap = QPixmap::fromImage(qframe2); + texture = qframe2; update(); } diff --git a/ftnoir_tracker_ht/ht_video_widget.h b/ftnoir_tracker_ht/ht_video_widget.h index 3fff395e..cbfe6ddc 100644 --- a/ftnoir_tracker_ht/ht_video_widget.h +++ b/ftnoir_tracker_ht/ht_video_widget.h @@ -32,13 +32,13 @@ protected slots: void paintEvent( QPaintEvent* e ) { QMutexLocker foo(&mtx); QPainter painter(this); - painter.drawPixmap(e->rect(), pixmap, e->rect()); + painter.drawImage(e->rect(), texture); } void update_and_repaint(); private: QMutex mtx; - QPixmap pixmap; + QImage texture; QTimer timer; char fb[2048*2048*3]; int width,height; -- cgit v1.2.3 From 1aef762d11a5db1182e0a52193cd9a69135ba2b7 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 5 Dec 2013 11:23:53 +0100 Subject: accela: fix change settings at runtime --- ftnoir_filter_accela/ftnoir_filter_accela.cpp | 8 +--- ftnoir_filter_accela/ftnoir_filter_accela.h | 2 +- .../ftnoir_filter_accela_dialog.cpp | 56 +++++++++++----------- 3 files changed, 31 insertions(+), 35 deletions(-) diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.cpp b/ftnoir_filter_accela/ftnoir_filter_accela.cpp index 08829e52..a78a38c5 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela.cpp @@ -55,15 +55,11 @@ void FTNoIR_Filter::loadSettings() { iniFile.endGroup(); } -void FTNoIR_Filter::receiveSettings(double rot, double trans, double zoom_fac, double dz, double exponent) +void FTNoIR_Filter::receiveSettings() { QMutexLocker foo(&mutex); - rotation_alpha = rot; - translation_alpha = trans; - zoom_factor = zoom_fac; - deadzone = dz; - expt = exponent; + loadSettings(); } static inline double parabola(const double a, const double x, const double dz, const double expt) diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.h b/ftnoir_filter_accela/ftnoir_filter_accela.h index c92e28df..0a550f0e 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.h +++ b/ftnoir_filter_accela/ftnoir_filter_accela.h @@ -50,7 +50,7 @@ public: void Initialize() { first_run = true; } - void receiveSettings(double rot, double trans, double zoom_fac, double deadzone, double expt); + void receiveSettings(); private: QMutex mutex; void loadSettings(); diff --git a/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp b/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp index 68484e77..be6836c2 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp @@ -202,40 +202,40 @@ 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, deadzone, expt; - - iniFile.beginGroup ( "Accela" ); - iniFile.setValue("rotation-alpha", rot = ui.rotation_alpha->value()); - iniFile.setValue("translation-alpha", trans = ui.translation_alpha->value()); - iniFile.setValue("zoom-slowness", zoom = ui.spinZoom->value()); - iniFile.setValue("deadzone", deadzone = ui.deadzone->value()); - iniFile.setValue("exponent", expt = ui.expt->value()); - iniFile.setValue("second-order-alpha", rot = ui.order_2nd->value()); - iniFile.setValue("third-order-alpha", rot = ui.order_3rd->value()); - - QDoubleSpinBox* boxen[] = { - ui.doubleSpinBox, - ui.doubleSpinBox_2, - ui.doubleSpinBox_3, - ui.doubleSpinBox_4, - ui.doubleSpinBox_5, - ui.doubleSpinBox_6, - }; - - for (int i = 0; i < 6; i++) { - iniFile.setValue(QString("axis-%1").arg(QString::number(i)), boxen[i]->value()); + QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) + + qDebug() << "FTNoIR_Filter::save() says: iniFile = " << currentFile; + + 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()); + iniFile.setValue("third-order-alpha", ui.order_3rd->value()); + + QDoubleSpinBox* boxen[] = { + ui.doubleSpinBox, + ui.doubleSpinBox_2, + ui.doubleSpinBox_3, + ui.doubleSpinBox_4, + ui.doubleSpinBox_5, + ui.doubleSpinBox_6, + }; + + for (int i = 0; i < 6; i++) + { + iniFile.setValue(QString("axis-%1").arg(QString::number(i)), boxen[i]->value()); + } + iniFile.endGroup(); } - iniFile.endGroup(); settingsDirty = false; if (accela_filter) - accela_filter->receiveSettings(rot, trans, zoom, deadzone, expt); + accela_filter->receiveSettings(); } //////////////////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From eb42ffe30d51aa44ac0bebe0d5a04a6a13bbd789 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 7 Dec 2013 21:28:51 +0100 Subject: minor game list change --- bin/settings/facetracknoir supported games.csv | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/bin/settings/facetracknoir supported games.csv b/bin/settings/facetracknoir supported games.csv index b623ae91..b540e2cb 100644 --- a/bin/settings/facetracknoir supported games.csv +++ b/bin/settings/facetracknoir supported games.csv @@ -24,10 +24,9 @@ No;Game Name;Game protocol;Supported since;Verified;By;INTERNATIONAL_ID;FTN_ID 22;Aprisoft Gartenplaner;FreeTrack20;V160;;;20014;0016F2F27A5762FA937A00 23;Aprisoft Traumhaus Designer;FreeTrack20;V160;;;20013;00174655E792BB825B9300 498;ARI;FreeTrack20;V160;;;20795;01F23FB9A61044E206E200 -24;ArmA;FreeTrack20;V160;V;EmBeES;10601;0018F2F27A57631A40F200 -25;ArmA 2;FreeTrack20;V170;V;V4Friend, Ronski;7502;0019EB3616B3A44F05B900 -26;ArmA 2 Operation Arrowhead;FreeTrack20;V160;V;vn88holden;0;001ABC224B7783DAF0D500 -27;ArmA 3;FreeTrack20;V170;;;7503;001BB69411ABD4E2B39900 +506;ArmA;FreeTrack20;V160;;;10601;01FAE645A8544EDC002000 +507;ArmA 2;FreeTrack20;V170;;;7502;1D4EEB3616B3A44F05B900 +508;Arma 3;FreeTrack20;V170;;;7503;1D4FB69411ABD4E2B39900 28;Armored Assault - Gold Edition;FreeTrack20;V170;;;1303;001CA7F7CAA00814ECA700 29;Arvoch Alliance;FreeTrack20;V160;;;14908;001D318F8773BAE29A9300 30;Arvoch Conflict;FreeTrack20;V160;;;14901;001E5C1FDE722DAE2BA900 @@ -456,8 +455,8 @@ No;Game Name;Game protocol;Supported since;Verified;By;INTERNATIONAL_ID;FTN_ID 422;UQO;FreeTrack20;V160;;;23085;01A67C822099A187FE3600 423;UVEG Machinery Simulator;FreeTrack20;V160;;;20024;01A73118585257A0F63100 424;VAR;FreeTrack20;V160;;;20460;01A8950F9A97FA96FD2E00 -425;VBS2;FreeTrack20;V160;;;7501;01A999BB5C990099FCBF00 -485;VBS2 2.0;FreeTrack20;V170;;;7505;1D51EB3616B3A44F05B900 +505;VBS2;FreeTrack20;V160;;;7501;01F98EF4FB1278538A7600 +509;VBS2 2.0;FreeTrack20;V170;;;7505;1D51EB3616B3A44F05B900 426;Vehicle Simulator (Quality Simulations);FreeTrack20;V160;;;5102;01AA0FC9FF9B1FA134A900 478;Vehicle Simulator Direction;FreeTrack20;V160;;;20735;01DEB88CF58E570F1CEF00 427;Vestibular Ocular Reflex;FreeTrack20;V160;;;20008;01AB3919C49B31A731A200 -- 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(-) 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 a225aac16f8ed9047792597c9993c24e0a20031b Mon Sep 17 00:00:00 2001 From: usrusr Date: Tue, 10 Dec 2013 01:59:06 +0100 Subject: fork info --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index fbbead33..8475ecfe 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ + Windows binary builds are available at Source code access available at @@ -56,3 +57,9 @@ compatible with it unless resides in separate address space. It's recommended to submit new code under ISC license, it's a shorter boilerplate header than MIT/X11 or new BSD. + +# this fork/branch: usrusr/opentrack feature/pt-hysteresis + +Per pixel hysteresis for point tracker: sacrifice some precision, cpu and sensitivity to minor movements for greatly reduced jitter from pixel noise at full responsivity (usable without postprocessing filters!) +-- Ulf Schreiber +Ulf Schreiber -- cgit v1.2.3 From 28fcbb913ed0969b22fd07c32c63c2a54568b6c6 Mon Sep 17 00:00:00 2001 From: usrusr Date: Tue, 10 Dec 2013 01:52:43 +0100 Subject: add an optional per-pixel hysteresis to remove pixel noise at the expense of a moderate movement threshold (but no lag) --- FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui | 32 ++++++++++ FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp | 1 + FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.cpp | 2 + FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.h | 1 + FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.cpp | 2 + FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.h | 2 + FTNoIR_Tracker_PT/point_extractor.cpp | 80 +++++++++++++++++++++--- FTNoIR_Tracker_PT/point_extractor.h | 6 ++ 8 files changed, 117 insertions(+), 9 deletions(-) diff --git a/FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui b/FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui index 1495249a..9ad4f83c 100644 --- a/FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui +++ b/FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui @@ -848,6 +848,38 @@
+ + + + + + + Hysteresis + + + threshold_secondary_slider + + + + + + + Per pixel hysteresis width (leave left if there is little difference between dot and non-dot, move right for increased stability against pixel noise) + + + 255 + + + 100 + + + Qt::Horizontal + + + + + + diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp index 5cb7bdf3..dcf28f04 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp @@ -113,6 +113,7 @@ void Tracker::apply(const TrackerSettings& settings) camera.set_f(settings.cam_f); frame_rotation.rotation = static_cast(settings.cam_roll); point_extractor.threshold_val = settings.threshold; + point_extractor.threshold_secondary_val = settings.threshold_secondary; 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)); diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.cpp b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.cpp index fe995163..f8afa790 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.cpp +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.cpp @@ -63,6 +63,7 @@ TrackerDialog::TrackerDialog() ui.campitch_spin->setValue(settings.cam_pitch); ui.camyaw_spin->setValue(settings.cam_yaw); ui.threshold_slider->setValue(settings.threshold); + ui.threshold_secondary_slider->setValue(settings.threshold_secondary); ui.chkEnableRoll->setChecked(settings.bEnableRoll); ui.chkEnablePitch->setChecked(settings.bEnablePitch); @@ -105,6 +106,7 @@ TrackerDialog::TrackerDialog() connect( ui.campitch_spin,SIGNAL(valueChanged(int)), this,SLOT(set_cam_pitch(int)) ); connect( ui.camyaw_spin,SIGNAL(valueChanged(int)), this,SLOT(set_cam_yaw(int)) ); connect( ui.threshold_slider,SIGNAL(sliderMoved(int)), this,SLOT(set_threshold(int)) ); + connect( ui.threshold_secondary_slider,SIGNAL(sliderMoved(int)), this,SLOT(set_threshold_secondary(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)) ); diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.h b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.h index 3e1af50a..de743ad8 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.h +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.h @@ -54,6 +54,7 @@ protected slots: 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_threshold_secondary(int val) { settings.threshold_secondary = 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(); } diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.cpp b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.cpp index 62ba1e3e..50835cb8 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.cpp +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.cpp @@ -29,6 +29,7 @@ void TrackerSettings::load_ini() cam_pitch = iniFile.value("CameraPitch", 0).toInt(); cam_yaw = iniFile.value("CameraYaw", 0).toInt(); threshold = iniFile.value("PointExtractThreshold", 128).toInt(); + threshold_secondary = iniFile.value("PointExtractThresholdSecondary", 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(); @@ -74,6 +75,7 @@ void TrackerSettings::save_ini() const iniFile.setValue("CameraPitch", cam_pitch); iniFile.setValue("CameraYaw", cam_yaw); iniFile.setValue("PointExtractThreshold", threshold); + iniFile.setValue("PointExtractThresholdSecondary", threshold_secondary); iniFile.setValue("PointExtractMinSize", min_point_size); iniFile.setValue("PointExtractMaxSize", max_point_size); iniFile.setValue("PointModelM01x", M01[0]); diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.h b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.h index 1cf60853..91a7a8d5 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.h +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.h @@ -28,6 +28,8 @@ struct TrackerSettings // point extraction int threshold; + int threshold_secondary; + int min_point_size; int max_point_size; diff --git a/FTNoIR_Tracker_PT/point_extractor.cpp b/FTNoIR_Tracker_PT/point_extractor.cpp index 261de60f..27a14713 100644 --- a/FTNoIR_Tracker_PT/point_extractor.cpp +++ b/FTNoIR_Tracker_PT/point_extractor.cpp @@ -8,15 +8,27 @@ #include "point_extractor.h" #include + using namespace cv; using namespace std; + +PointExtractor::PointExtractor(){ + first = true; + + + //if (!AllocConsole()){} + //else SetConsoleTitle("debug"); + //freopen("CON", "w", stdout); + //freopen("CON", "w", stderr); +} // ---------------------------------------------------------------------------- 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(); @@ -24,10 +36,41 @@ const vector& PointExtractor::extract_points(Mat frame, float dt, bool dr Mat frame_gray; cvtColor(frame, frame_gray, CV_RGB2GRAY); - // convert to binary + int secondary = threshold_secondary_val; + + // mask for everything that passes the threshold (or: the upper threshold of the hysteresis) Mat frame_bin; - threshold(frame_gray, frame_bin, threshold_val, 255, THRESH_BINARY); + // only used if draw_output + Mat frame_bin_copy; + // mask for everything that passes + Mat frame_bin_low; + // mask for lower-threshold && combined result of last, needs to remain in scope until drawing, but is only used if secondary != 0 + Mat frame_last_and_low; + if(secondary==0){ + threshold(frame_gray, frame_bin, threshold_val, 255, THRESH_BINARY); + }else{ + // we recombine a number of buffers, this might be slower than a single loop of per-pixel logic + // but it might as well be faster if openCV makes good use of SIMD + float t = threshold_val; + //float hyst = float(threshold_secondary_val)/512.; + //threshold(frame_gray, frame_bin, (t + ((255.-t)*hyst)), 255, THRESH_BINARY); + float hyst = float(threshold_secondary_val)/256.; + threshold(frame_gray, frame_bin, t, 255, THRESH_BINARY); + threshold(frame_gray, frame_bin_low,std::max(float(1), t - (t*hyst)), 255, THRESH_BINARY); + + if(draw_output) frame_bin.copyTo(frame_bin_copy); + if(first){ + frame_bin.copyTo(frame_last); + first = false; + }else{ + // keep pixels from last if they are above lower threshold + bitwise_and(frame_last, frame_bin_low, frame_last_and_low); + // union of pixels >= higher threshold and pixels >= lower threshold + bitwise_or(frame_bin, frame_last_and_low, frame_last); + frame_last.copyTo(frame_bin); + } + } unsigned int region_size_min = 3.14*min_size*min_size/4.0; unsigned int region_size_max = 3.14*max_size*max_size/4.0; @@ -42,6 +85,7 @@ const vector& PointExtractor::extract_points(Mat frame, float dt, bool dr // find connected components with floodfill if (frame_bin.at(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++; @@ -70,9 +114,17 @@ const vector& PointExtractor::extract_points(Mat frame, float dt, bool dr for (int j=rect.x; j < (rect.x+rect.width); j++) { if (frame_bin.at(i,j) != blob_index-1) continue; - float val = frame_gray.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) + float val; + + if(secondary==0){ + val = frame_gray.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) + }else{ + //hysteresis point detection gets stability from ignoring pixel noise so we decidedly leave the actual pixel values out of the picture + val = frame_last.at(i,j) / 256.; + } + m += val; mx += j * val; my += i * val; @@ -83,6 +135,7 @@ const vector& PointExtractor::extract_points(Mat frame, float dt, bool dr Vec2f c; c[0] = (mx/m - W/2)/W; c[1] = -(my/m - H/2)/W; + //qDebug()< "<& PointExtractor::extract_points(Mat frame, float dt, bool dr // draw output image if (draw_output) { vector channels; - frame_bin.setTo(170, frame_bin); - channels.push_back(frame_gray + frame_bin); - channels.push_back(frame_gray - frame_bin); - channels.push_back(frame_gray - frame_bin); + if(secondary==0){ + frame_bin.setTo(170, frame_bin); + channels.push_back(frame_gray + frame_bin); + channels.push_back(frame_gray - frame_bin); + channels.push_back(frame_gray - frame_bin); + }else{ + frame_bin_copy.setTo(120, frame_bin_copy); + frame_bin_low.setTo(90, frame_bin_low); + channels.push_back(frame_gray + frame_bin_copy); + channels.push_back(frame_gray + frame_last_and_low); + channels.push_back(frame_gray + frame_bin_low); + //channels.push_back(frame_gray + frame_bin); + } merge(channels, frame); } diff --git a/FTNoIR_Tracker_PT/point_extractor.h b/FTNoIR_Tracker_PT/point_extractor.h index c62d34f9..b9f46666 100644 --- a/FTNoIR_Tracker_PT/point_extractor.h +++ b/FTNoIR_Tracker_PT/point_extractor.h @@ -21,12 +21,18 @@ public: // 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; } + PointExtractor(); int threshold_val; + int threshold_secondary_val; int min_size, max_size; protected: std::vector points; + cv::Mat frame_last; + + + bool first; }; #endif //POINTEXTRACTOR_H -- cgit v1.2.3 From 2e5cd1daaf510bc74627a6776519c1e9ce50ab68 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 10 Dec 2013 03:25:18 +0100 Subject: adjust coeffs for the hundredth time Signed-off-by: Stanislaw Halik --- ftnoir_tracker_ht/ftnoir_tracker_ht.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp index ab726aa1..c08af00b 100644 --- a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp +++ b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp @@ -97,28 +97,28 @@ static void load_settings(ht_config_t* config, Tracker* tracker) iniFile.beginGroup( "HT-Tracker" ); config->classification_delay = 500; config->field_of_view = iniFile.value("fov", 52).toFloat(); - config->pyrlk_pyramids = 2; + config->pyrlk_pyramids = 0; config->pyrlk_win_size_w = config->pyrlk_win_size_h = 21; - config->max_keypoints = 300; - config->keypoint_distance = 4.3; + config->max_keypoints = 400; + config->keypoint_distance = 3.3; //config->force_width = 640; //config->force_height = 480; config->force_fps = iniFile.value("fps", 0).toInt(); config->camera_index = iniFile.value("camera-index", -1).toInt(); config->ransac_num_iters = 100; - config->ransac_max_reprojection_error = 6.5; - config->ransac_max_inlier_error = 6.5; + config->ransac_max_reprojection_error = 7.2; + config->ransac_max_inlier_error = 7.2; config->ransac_abs_max_mean_error = 15; - config->ransac_max_mean_error = 4.5; + config->ransac_max_mean_error = 5.0; config->debug = 0; - config->ransac_min_features = 0.76; + config->ransac_min_features = 0.78; int res = iniFile.value("resolution", 0).toInt(); if (res < 0 || res >= (int)(sizeof(resolution_choices) / sizeof(resolution_tuple))) res = 0; resolution_tuple r = resolution_choices[res]; config->force_width = r.width; config->force_height = r.height; - config->flandmark_delay = 250; + config->flandmark_delay = 325; qDebug() << "width" << r.width << "height" << r.height; if (tracker) { -- 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(-) 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(-) 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(-) 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(-) 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(-) 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 c298ec1126f1ec8fbf01e5619c5a4b0a30a222c2 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 10 Dec 2013 03:52:19 +0100 Subject: remove return value from GiveHeadPoseData --- FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp | 8 +++++--- FTNoIR_Tracker_PT/ftnoir_tracker_pt.h | 2 +- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 4 +--- ftnoir_tracker_aruco/ftnoir_tracker_aruco.h | 2 +- ftnoir_tracker_base/ftnoir_tracker_base.h | 2 +- ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp | 7 ++----- ftnoir_tracker_hatire/ftnoir_tracker_hat.h | 2 +- ftnoir_tracker_ht/ftnoir_tracker_ht.cpp | 7 +------ ftnoir_tracker_ht/ftnoir_tracker_ht.h | 2 +- ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp | 4 +--- ftnoir_tracker_hydra/ftnoir_tracker_hydra.h | 2 +- ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp | 10 ++++------ ftnoir_tracker_joystick/ftnoir_tracker_joystick.h | 2 +- ftnoir_tracker_rift/ftnoir_tracker_rift.cpp | 3 +-- ftnoir_tracker_rift/ftnoir_tracker_rift.h | 2 +- ftnoir_tracker_udp/ftnoir_tracker_udp.cpp | 3 +-- ftnoir_tracker_udp/ftnoir_tracker_udp.h | 2 +- opentrack-api/opentrack.h | 2 +- opentrack-api/trackers.cpp | 5 ++--- 19 files changed, 28 insertions(+), 43 deletions(-) diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp index 5cb7bdf3..a6aaa29c 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp @@ -233,12 +233,12 @@ void Tracker::StopTracker(bool exit) #define THeadPoseData double #endif -bool Tracker::GiveHeadPoseData(THeadPoseData *data) +void Tracker::GiveHeadPoseData(THeadPoseData *data) { { QMutexLocker lock(&mutex); - if (!tracking_valid) return false; + if (!tracking_valid) return; FrameTrafo X_CM = point_tracker.get_pose(); FrameTrafo X_MH(Matx33f::eye(), t_MH); @@ -280,7 +280,9 @@ bool Tracker::GiveHeadPoseData(THeadPoseData *data) if (bEnableRoll) data[Roll] = rad2deg * gamma; #endif } - return true; +#ifndef OPENTRACK_API + return true; +#endif } //----------------------------------------------------------------------------- diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h index 64f282b6..5c8d35d2 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h @@ -44,7 +44,7 @@ public: virtual void Initialize(QFrame *videoframe); #ifdef OPENTRACK_API virtual void StartTracker(QFrame* parent_window); - virtual bool GiveHeadPoseData(double* data); + virtual void GiveHeadPoseData(double* data); #else virtual void StartTracker(HWND parent_window); virtual void StopTracker(bool exit); diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index 7581b77a..11916df5 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -375,7 +375,7 @@ void Tracker::run() } } -bool Tracker::GiveHeadPoseData(double *data) +void Tracker::GiveHeadPoseData(double *data) { QMutexLocker lck(&mtx); @@ -391,8 +391,6 @@ bool Tracker::GiveHeadPoseData(double *data) data[TY] = pose[TY]; if (enableTZ) data[TZ] = pose[TZ]; - - return true; } class TrackerDll : public Metadata diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h index 1518ba4d..8a480d9f 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); - bool GiveHeadPoseData(double *data); + void GiveHeadPoseData(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 38c24afe..e6e770ed 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 bool GiveHeadPoseData(double *data) = 0; + virtual void GiveHeadPoseData(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 b933dd14..bcef6753 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 -bool FTNoIR_Tracker::GiveHeadPoseData(THeadPoseData *data) +void FTNoIR_Tracker::GiveHeadPoseData(THeadPoseData *data) { QMutexLocker lck(&mutex); while (dataRead.length()>=30) { @@ -354,7 +354,7 @@ bool FTNoIR_Tracker::GiveHeadPoseData(THeadPoseData *data) if (CptError>50) { emit sendMsgInfo("Can't find HAT frame") ; CptError=0; - return false; + return; } #ifdef OPENTRACK_API data[frame_cnt] = (long) HAT.Code; @@ -425,9 +425,6 @@ bool FTNoIR_Tracker::GiveHeadPoseData(THeadPoseData *data) // For debug //data->x=dataRead.length(); //data->y=CptError; - - return true; - } diff --git a/ftnoir_tracker_hatire/ftnoir_tracker_hat.h b/ftnoir_tracker_hatire/ftnoir_tracker_hat.h index a1b4ecda..04c5fb61 100644 --- a/ftnoir_tracker_hatire/ftnoir_tracker_hat.h +++ b/ftnoir_tracker_hatire/ftnoir_tracker_hat.h @@ -29,7 +29,7 @@ public: #ifdef OPENTRACK_API virtual void StartTracker(QFrame*); - virtual bool GiveHeadPoseData(double* data); + virtual void GiveHeadPoseData(double* data); #else void Initialize( QFrame *videoframe ); virtual void StartTracker(HWND parent_window); diff --git a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp index c08af00b..c3c12005 100644 --- a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp +++ b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp @@ -186,10 +186,8 @@ void Tracker::StartTracker(QFrame* videoframe) #endif } -bool Tracker::GiveHeadPoseData(double *data) +void Tracker::GiveHeadPoseData(double *data) { - bool ret = false; - lck_shm.lock(); shm->timer = 0; if (shm->frame.width > 0) @@ -213,7 +211,6 @@ bool Tracker::GiveHeadPoseData(double *data) data[TY] = shm->result.ty; if (enableTZ) data[TZ] = shm->result.tz; - ret = true; if (fabs(data[Yaw]) > 60 || fabs(data[Pitch]) > 50 || fabs(data[Roll]) > 40) { shm->pause = true; @@ -222,8 +219,6 @@ bool Tracker::GiveHeadPoseData(double *data) shm->pause = false; } lck_shm.unlock(); - - return ret; } //----------------------------------------------------------------------------- diff --git a/ftnoir_tracker_ht/ftnoir_tracker_ht.h b/ftnoir_tracker_ht/ftnoir_tracker_ht.h index c19e2d93..475d5a6c 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); - bool GiveHeadPoseData(double *data); + void GiveHeadPoseData(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 86ca8888..11a3e0fb 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*) } -bool Hydra_Tracker::GiveHeadPoseData(double *data) +void Hydra_Tracker::GiveHeadPoseData(double *data) { sixenseSetActiveBase(0); @@ -109,8 +109,6 @@ bool Hydra_Tracker::GiveHeadPoseData(double *data) if (bEnableRoll) { data[Roll] = newHeadPose[Roll] * 57.295781f; } - - return true; } diff --git a/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h b/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h index 3daaf239..6e40b710 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; - bool GiveHeadPoseData(double *data) virt_override; + void GiveHeadPoseData(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 66138e90..8f5ac162 100644 --- a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp +++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp @@ -175,13 +175,13 @@ fail: qDebug() << "joy init failure"; } -bool FTNoIR_Tracker::GiveHeadPoseData(double *data) +void FTNoIR_Tracker::GiveHeadPoseData(double *data) { QMutexLocker foo(&mtx); DIJOYSTATE js = {0}; if( !g_pDI || !g_pJoystick) - return false; + return; auto hr = g_pJoystick->Poll(); if( FAILED( hr )) @@ -190,11 +190,11 @@ bool FTNoIR_Tracker::GiveHeadPoseData(double *data) for (int i = 0; hr == DIERR_INPUTLOST && i < 200; i++) hr = g_pJoystick->Acquire(); if (hr != DI_OK) - return false; + return; } if( FAILED( hr = g_pJoystick->GetDeviceState( sizeof( js ), &js ) ) ) - return false; + return; const LONG values[] = { js.lRx, @@ -232,8 +232,6 @@ bool FTNoIR_Tracker::GiveHeadPoseData(double *data) data[i] = val * limits[i] / (double) (val >= 0 ? max : min); } } - - return true; } void FTNoIR_Tracker::loadSettings() { diff --git a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h index cdf4fc7b..809d8c73 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); - bool GiveHeadPoseData(double *data); + void GiveHeadPoseData(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 4816cea4..c3b313ca 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*) } -bool Rift_Tracker::GiveHeadPoseData(double *data) +void Rift_Tracker::GiveHeadPoseData(double *data) { if (pSFusion != NULL && pSensor != NULL) { Quatf hmdOrient = pSFusion->GetOrientation(); @@ -113,7 +113,6 @@ bool Rift_Tracker::GiveHeadPoseData(double *data) data[Roll] = newHeadPose[Roll] * 57.295781f; } } - return pSensor != NULL; } diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift.h b/ftnoir_tracker_rift/ftnoir_tracker_rift.h index 7a4533d3..33e6f5cd 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; - bool GiveHeadPoseData(double *data) virt_override; + void GiveHeadPoseData(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 1539707e..d58341a6 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; } -bool FTNoIR_Tracker::GiveHeadPoseData(double *data) +void FTNoIR_Tracker::GiveHeadPoseData(double *data) { mutex.lock(); if (bEnableX) { @@ -132,7 +132,6 @@ bool FTNoIR_Tracker::GiveHeadPoseData(double *data) data[Roll] = newHeadPose[Roll]; } mutex.unlock(); - return true; } // diff --git a/ftnoir_tracker_udp/ftnoir_tracker_udp.h b/ftnoir_tracker_udp/ftnoir_tracker_udp.h index d158630b..7b6c5328 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 *); - bool GiveHeadPoseData(double *data); + void GiveHeadPoseData(double *data); void loadSettings(); volatile bool should_quit; protected: diff --git a/opentrack-api/opentrack.h b/opentrack-api/opentrack.h index 990b6aa4..88ba6cf0 100644 --- a/opentrack-api/opentrack.h +++ b/opentrack-api/opentrack.h @@ -50,7 +50,7 @@ OPENTRACK_EXPORT const char** opentrack_enum_trackers(opentrack self); */ OPENTRACK_EXPORT opentrack_tracker opentrack_make_tracker(opentrack ctx, const char* name); OPENTRACK_EXPORT void opentrack_tracker_start(opentrack self, opentrack_tracker tracker); -OPENTRACK_EXPORT int opentrack_tracker_tick(opentrack_tracker tracker, double* headpose); +OPENTRACK_EXPORT void opentrack_tracker_tick(opentrack_tracker tracker, double* headpose); OPENTRACK_EXPORT void opentrack_finalize_tracker(opentrack_tracker tracker); #ifdef __cplusplus } diff --git a/opentrack-api/trackers.cpp b/opentrack-api/trackers.cpp index 0f698e4c..937f7084 100644 --- a/opentrack-api/trackers.cpp +++ b/opentrack-api/trackers.cpp @@ -29,11 +29,10 @@ void OPENTRACK_EXPORT opentrack_tracker_start(opentrack self, opentrack_tracker return tracker->StartTracker(&self->fake_frame); } -int OPENTRACK_EXPORT opentrack_tracker_tick(opentrack_tracker tracker, double* headpose) +void OPENTRACK_EXPORT opentrack_tracker_tick(opentrack_tracker tracker, double* headpose) { - int ret = tracker->GiveHeadPoseData(headpose); + tracker->GiveHeadPoseData(headpose); QApplication::processEvents(0, 5); - return ret; } } -- 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(-) 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 0c54288d05811ab1b5d7e2f4378189fb23da792c Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 10 Dec 2013 04:38:23 +0100 Subject: fix interpolation jaggies --- ftnoir_posewidget/glwidget.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ftnoir_posewidget/glwidget.cpp b/ftnoir_posewidget/glwidget.cpp index 93c98c9c..70667f06 100644 --- a/ftnoir_posewidget/glwidget.cpp +++ b/ftnoir_posewidget/glwidget.cpp @@ -181,10 +181,10 @@ void GLWidget::project_quad_texture() { 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)); + int qx1 = std::min(ow - 1, std::max(0, qx)); + int qy1 = std::min(oh - 1, std::max(0, qy)); + int qx2 = std::min(ow - 1, std::max(0, qx + 1.0)); + int qy2 = std::min(oh - 1, std::max(0, qy + 1.0)); double dx1 = qx1 - qx; double dy1 = qy1 - qy; -- 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(-) 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 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 db3636829d0c13da33438c910ce965016bc68f04 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 10 Dec 2013 06:13:33 +0100 Subject: fix OSX build. still requires care, though --- CMakeLists.txt | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bc9aaec3..13ec3ff4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,7 +13,7 @@ if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") set(CMAKE_COMPILER_IS_GNUCXX TRUE) endif() -if(CMAKE_COMPILER_IS_GNUCXX) +if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) if(MINGW) set(version-script mingw) else() @@ -45,7 +45,7 @@ if(MSVC) add_definitions(-DNOMINMAX) endif() -if(CMAKE_COMPILER_IS_GNUCXX) +if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) add_definitions(-std=c++11) endif() @@ -412,12 +412,12 @@ target_link_libraries(opentrack-filter-accela ${MY_QT_LIBS}) add_library(opentrack-filter-kalman SHARED ${opentrack-filter-kalman-c} ${opentrack-filter-kalman-h} ${opentrack-filter-kalman-moc} ${opentrack-filter-kalman-uih} ${opentrack-filter-kalman-rcc}) target_link_libraries(opentrack-filter-kalman ${MY_QT_LIBS} ${OpenCV_LIBS}) -if(CMAKE_COMPILER_IS_GNUCXX) +if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) SET_TARGET_PROPERTIES(opentrack-filter-kalman PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt") endif() -if(CMAKE_COMPILER_IS_GNUCXX) +if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) SET_TARGET_PROPERTIES(opentrack-filter-accela PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt") endif() @@ -425,14 +425,14 @@ endif() add_library(opentrack-filter-ewma SHARED ${opentrack-filter-ewma-uih} ${opentrack-filter-ewma-c} ${opentrack-filter-ewma-h} ${opentrack-filter-ewma-moc} ${opentrack-filter-ewma-rcc}) target_link_libraries(opentrack-filter-ewma ${MY_QT_LIBS}) -if(CMAKE_COMPILER_IS_GNUCXX) +if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) SET_TARGET_PROPERTIES(opentrack-filter-ewma PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt") endif() add_library(opentrack-proto-fgfs SHARED ${opentrack-proto-fgfs-c} ${opentrack-proto-fgfs-h} ${opentrack-proto-fgfs-moc} ${opentrack-proto-fgfs-uih} ${opentrack-proto-fgfs-rcc}) target_link_libraries(opentrack-proto-fgfs ${MY_QT_LIBS}) -if(CMAKE_COMPILER_IS_GNUCXX) +if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) SET_TARGET_PROPERTIES(opentrack-proto-fgfs PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt") endif() @@ -445,7 +445,7 @@ if(WIN32 AND SDK_VJOY) else() target_link_libraries(opentrack-proto-vjoy ${MY_QT_LIBS} "${SDK_VJOY}/VJoy.dll") endif() - if(CMAKE_COMPILER_IS_GNUCXX) + if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) SET_TARGET_PROPERTIES(opentrack-proto-vjoy PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt -Wl,--enable-stdcall-fixup") endif() @@ -454,7 +454,7 @@ endif() if(UNIX AND SDK_ENABLE_LIBEVDEV) add_library(opentrack-proto-libevdev SHARED ${opentrack-proto-libevdev-c} ${opentrack-proto-libevdev-h} ${opentrack-proto-libevdev-moc} ${opentrack-proto-libevdev-uih} ${opentrack-proto-libevdev-rcc}) target_link_libraries(opentrack-proto-libevdev ${MY_QT_LIBS} evdev) - if(CMAKE_COMPILER_IS_GNUCXX) + if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) SET_TARGET_PROPERTIES(opentrack-proto-libevdev PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt") endif() @@ -494,7 +494,7 @@ endif() add_library(opentrack-proto-udp SHARED ${opentrack-proto-udp-c} ${opentrack-proto-udp-h} ${opentrack-proto-udp-moc} ${opentrack-proto-udp-uih} ${opentrack-proto-udp-rcc}) target_link_libraries(opentrack-proto-udp ${MY_QT_LIBS}) -if(CMAKE_COMPILER_IS_GNUCXX) +if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) SET_TARGET_PROPERTIES(opentrack-proto-udp PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt") endif() @@ -502,7 +502,7 @@ endif() if(WIN32) add_library(opentrack-tracker-joystick SHARED ${opentrack-tracker-joystick-c} ${opentrack-tracker-joystick-h} ${opentrack-tracker-joystick-moc} ${opentrack-tracker-joystick-uih} ${opentrack-tracker-joystick-rcc}) target_link_libraries(opentrack-tracker-joystick ${MY_QT_LIBS}) - if(CMAKE_COMPILER_IS_GNUCXX) + if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) SET_TARGET_PROPERTIES(opentrack-tracker-joystick PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt") endif() @@ -511,7 +511,7 @@ endif() if(NOT WIN32 AND SDK_WINE_PREFIX) add_library(opentrack-proto-wine SHARED ${opentrack-proto-wine-c} ${opentrack-proto-wine-h} ${opentrack-proto-wine-moc} ${opentrack-proto-wine-uih} ${opentrack-proto-wine-rcc}) target_link_libraries(opentrack-proto-wine ${MY_QT_LIBS} opentrack-compat opentrack-csv) - if(CMAKE_COMPILER_IS_GNUCXX) + if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) SET_TARGET_PROPERTIES(opentrack-proto-wine PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt") endif() @@ -536,14 +536,14 @@ if(NOT WIN32 AND SDK_WINE_PREFIX) endif() endif() -if(CMAKE_COMPILER_IS_GNUCXX) +if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) SET_TARGET_PROPERTIES(opentrack-proto-fgfs PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt") endif() add_library(opentrack-tracker-ht SHARED ${opentrack-tracker-ht-c} ${opentrack-tracker-ht-h} ${opentrack-tracker-ht-moc} ${opentrack-tracker-ht-uih} ${opentrack-tracker-ht-rcc}) target_link_libraries(opentrack-tracker-ht ${MY_QT_LIBS} opentrack-compat) -if(CMAKE_COMPILER_IS_GNUCXX) +if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) SET_TARGET_PROPERTIES(opentrack-tracker-ht PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt") endif() @@ -552,7 +552,7 @@ if(SDK_ARUCO_LIBPATH) include_directories(${CMAKE_SOURCE_DIR}/ftnoir_tracker_aruco/include) add_library(opentrack-tracker-aruco SHARED ${opentrack-tracker-aruco-c} ${opentrack-tracker-aruco-h} ${opentrack-tracker-aruco-moc} ${opentrack-tracker-aruco-uih} ${opentrack-tracker-aruco-rcc}) target_link_libraries(opentrack-tracker-aruco ${MY_QT_LIBS} ${SDK_ARUCO_LIBPATH} ${OpenCV_LIBS}) - if(CMAKE_COMPILER_IS_GNUCXX) + if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) SET_TARGET_PROPERTIES(opentrack-tracker-aruco PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt") endif() @@ -567,7 +567,7 @@ 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}) install(TARGETS opentrack-tracker-hatire RUNTIME DESTINATION . LIBRARY DESTINATION . ) -if(CMAKE_COMPILER_IS_GNUCXX) +if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) SET_TARGET_PROPERTIES(opentrack-tracker-hatire PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt") endif() @@ -591,7 +591,7 @@ if(APPLE) SET_TARGET_PROPERTIES(opentrack-tracker-pt PROPERTIES COMPILE_FLAGS "-std=c++11") endif() -if(CMAKE_COMPILER_IS_GNUCXX) +if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) SET_TARGET_PROPERTIES(opentrack-tracker-pt PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt") endif() @@ -606,7 +606,7 @@ endif() add_library(opentrack-tracker-udp SHARED ${opentrack-tracker-udp-c} ${opentrack-tracker-udp-h} ${opentrack-tracker-udp-moc} ${opentrack-tracker-udp-uih} ${opentrack-tracker-udp-rcc}) target_link_libraries(opentrack-tracker-udp ${MY_QT_LIBS}) -if(CMAKE_COMPILER_IS_GNUCXX) +if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) SET_TARGET_PROPERTIES(opentrack-tracker-udp PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt") endif() @@ -630,7 +630,7 @@ if(SDK_RIFT) endif() endif() endif() - if(CMAKE_COMPILER_IS_GNUCXX) + if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) SET_TARGET_PROPERTIES(opentrack-tracker-rift PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt" @@ -675,7 +675,7 @@ if(SDK_HYDRA) ) target_link_libraries(opentrack-tracker-hydra "${SDK_HYDRA}/lib/${sixense-plat}${underscore-sixtyfour}/release${underscore-dll}/libsixense${underscore-sixtyfour}.${soext}" "${SDK_HYDRA}/lib/${sixense-plat}${underscore-sixtyfour}/release${underscore-dll}/libsixense_utils${underscore-sixtyfour}.${soext}") endif() - if(CMAKE_COMPILER_IS_GNUCXX) + if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) SET_TARGET_PROPERTIES(opentrack-tracker-hydra PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt") endif() @@ -705,7 +705,7 @@ 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) +if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) 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" @@ -715,7 +715,7 @@ endif() set_target_properties(opentrack PROPERTIES COMPILE_DEFINITIONS OPENTRACK_VERSION=\"${OPENTRACK__COMMIT}\") -if(UNIX) +if(UNIX OR APPLE) target_link_libraries(opentrack opentrack-qxt-mini) endif() target_link_libraries(opentrack ${OpenCV_LIBS}) -- cgit v1.2.3 From 55bbd09c1afe5ca0cd6aa705010ccb8e58adcd7c Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 10 Dec 2013 06:18:03 +0100 Subject: fix apple harder --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 13ec3ff4..d760937f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -721,7 +721,7 @@ endif() target_link_libraries(opentrack ${OpenCV_LIBS}) include_directories(${OpenCV_INCLUDE_DIRS}) -if(UNIX) +if(UNIX OR APPLE) install(TARGETS opentrack-qxt-mini RUNTIME DESTINATION . LIBRARY DESTINATION . ) endif() -- cgit v1.2.3 From 27d0ff6e03cce603c5dd47b3fa78581b6a6120d5 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 10 Dec 2013 06:23:38 +0100 Subject: fix installer's path to version --- installer/opentrack-installer.iss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/installer/opentrack-installer.iss b/installer/opentrack-installer.iss index 9021caf9..5f25c917 100644 --- a/installer/opentrack-installer.iss +++ b/installer/opentrack-installer.iss @@ -1,7 +1,7 @@ ; Script generated by the Inno Setup Script Wizard. ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! -#include "../build/opentrack-version.h" +#include "../build-mingw-w64/opentrack-version.h" #define MyAppName "opentrack" #define MyAppVersion OPENTRACK_VERSION #define MyAppPublisher "opentrack" -- cgit v1.2.3 From a202162dec69293dd0b56ff867e3ffa708b8a6d3 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 11 Dec 2013 01:37:25 +0100 Subject: fork info -> credits list --- README.md | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/README.md b/README.md index 8475ecfe..9b1fa53a 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,7 @@ Don't be afraid to submit an issue/feature request if the need arises. - Ryan Spicer (OSX tester, contributor) - Patrick Ruoff (PT tracker) - FuraX49 (hatire arduino tracker) +- Ulf Schreiber (PT tracker) - Wim Vriend (historically) - Ron Hendriks (historically) @@ -57,9 +58,3 @@ compatible with it unless resides in separate address space. It's recommended to submit new code under ISC license, it's a shorter boilerplate header than MIT/X11 or new BSD. - -# this fork/branch: usrusr/opentrack feature/pt-hysteresis - -Per pixel hysteresis for point tracker: sacrifice some precision, cpu and sensitivity to minor movements for greatly reduced jitter from pixel noise at full responsivity (usable without postprocessing filters!) --- Ulf Schreiber -Ulf Schreiber -- cgit v1.2.3 From 5f3126dd862c93e3a514dcf0910d24b840f7e90c Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 14 Dec 2013 15:24:29 +0100 Subject: pt: don't crash since hysteresis support Reported-by: runningman84 GitHub: issue #15 --- FTNoIR_Tracker_PT/point_extractor.cpp | 10 +++++----- FTNoIR_Tracker_PT/point_extractor.h | 3 --- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/FTNoIR_Tracker_PT/point_extractor.cpp b/FTNoIR_Tracker_PT/point_extractor.cpp index 27a14713..d9ff0a5b 100644 --- a/FTNoIR_Tracker_PT/point_extractor.cpp +++ b/FTNoIR_Tracker_PT/point_extractor.cpp @@ -14,9 +14,6 @@ using namespace std; PointExtractor::PointExtractor(){ - first = true; - - //if (!AllocConsole()){} //else SetConsoleTitle("debug"); //freopen("CON", "w", stdout); @@ -28,6 +25,10 @@ const vector& PointExtractor::extract_points(Mat frame, float dt, bool dr const int W = frame.cols; const int H = frame.rows; + if (frame_last.cols != W || frame_last.rows != H) + { + frame_last = cv::Mat(); + } // clear old points points.clear(); @@ -60,9 +61,8 @@ const vector& PointExtractor::extract_points(Mat frame, float dt, bool dr threshold(frame_gray, frame_bin_low,std::max(float(1), t - (t*hyst)), 255, THRESH_BINARY); if(draw_output) frame_bin.copyTo(frame_bin_copy); - if(first){ + if(frame_last.empty()){ frame_bin.copyTo(frame_last); - first = false; }else{ // keep pixels from last if they are above lower threshold bitwise_and(frame_last, frame_bin_low, frame_last_and_low); diff --git a/FTNoIR_Tracker_PT/point_extractor.h b/FTNoIR_Tracker_PT/point_extractor.h index b9f46666..ff36f3ce 100644 --- a/FTNoIR_Tracker_PT/point_extractor.h +++ b/FTNoIR_Tracker_PT/point_extractor.h @@ -30,9 +30,6 @@ public: protected: std::vector points; cv::Mat frame_last; - - - bool first; }; #endif //POINTEXTRACTOR_H -- cgit v1.2.3 From 982138ba2c308ee66e33bb67eea9d66f708e021e Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 14 Dec 2013 15:24:53 +0100 Subject: aruco: adjust coefficients basing on resolution Signed-off-by: Stanislaw Halik --- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index 6d06d4a8..d7d55f82 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -187,7 +187,6 @@ void Tracker::run() aruco::MarkerDetector detector; detector.setDesiredSpeed(3); - detector.setThresholdParams(11, 6); cv::Rect last_roi(65535, 65535, 0, 0); @@ -219,6 +218,7 @@ void Tracker::run() cv::cvtColor(color, grayscale, cv::COLOR_BGR2GRAY); const int scale = frame.cols > 480 ? 2 : 1; + detector.setThresholdParams(scale > 1 ? 11 : 7, 7); const float focal_length_w = 0.5 * grayscale.cols / tan(0.5 * fov * HT_PI / 180); const float focal_length_h = 0.5 * grayscale.rows / tan(0.5 * fov * grayscale.rows / grayscale.cols * HT_PI / 180.0); -- cgit v1.2.3 From b0b5db6bcf762928e1278488f14819cd2e9a0cd9 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 14 Dec 2013 15:46:54 +0100 Subject: hatire cache val; not every dist has qt5serialport Signed-off-by: Stanislaw Halik --- CMakeLists.txt | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d760937f..eff5edaf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,6 +30,8 @@ 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) @@ -109,7 +111,12 @@ if(MINGW) endif() find_package(OpenCV REQUIRED) - find_package(Qt5 REQUIRED COMPONENTS Core Xml Network Widgets Gui SerialPort QUIET) + 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) 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}) @@ -392,10 +399,18 @@ endif() if(APPLE) link_directories(${CMAKE_INSTALL_PREFIX}) - set(MY_QT_LIBS Qt5Widgets Qt5Gui Qt5Network Qt5Xml Qt5Core Qt5SerialPort ${my-qt-deps}) + set(maybe-hatire) + if(SDK_HATIRE) + set(maybe-hatire Qt5SerialPort) + endif() + set(MY_QT_LIBS Qt5Widgets Qt5Gui Qt5Network Qt5Xml Qt5Core ${maybe-hatire} ${my-qt-deps}) else() + 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} ${Qt5SerialPort_LIBRARIES} ${my-qt-deps}) + ${Qt5Network_LIBRARIES} ${Qt5Xml_LIBRARIES} ${Qt5Core_LIBRARIES} ${maybe-hatire} ${my-qt-deps}) endif() add_library(opentrack-csv SHARED ${opentrack-csv-c} ${opentrack-csv-h}) @@ -564,12 +579,14 @@ 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}) -install(TARGETS opentrack-tracker-hatire RUNTIME DESTINATION . LIBRARY DESTINATION . ) -if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) - SET_TARGET_PROPERTIES(opentrack-tracker-hatire - PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt") +if(SDK_HATIRE) + 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}) + install(TARGETS opentrack-tracker-hatire RUNTIME DESTINATION . LIBRARY DESTINATION . ) + if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) + SET_TARGET_PROPERTIES(opentrack-tracker-hatire + PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt") + endif() endif() if(WIN32) -- 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(-) 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 ae13ff3715e004bab7051ffb3512b3df0ac0dfc3 Mon Sep 17 00:00:00 2001 From: mm0zct Date: Sat, 14 Dec 2013 17:00:37 +0000 Subject: we now have an oculus logo --- ftnoir_tracker_rift/images/medium.png | Bin 0 -> 5764 bytes ftnoir_tracker_rift/images/rift_medium.png | Bin 0 -> 5764 bytes ftnoir_tracker_rift/images/rift_small.png | Bin 0 -> 1212 bytes ftnoir_tracker_rift/images/rift_tiny.png | Bin 0 -> 624 bytes ftnoir_tracker_rift/images/small.png | Bin 0 -> 1212 bytes ftnoir_tracker_rift/images/tiny.png | Bin 0 -> 624 bytes 6 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 ftnoir_tracker_rift/images/medium.png create mode 100644 ftnoir_tracker_rift/images/rift_medium.png create mode 100644 ftnoir_tracker_rift/images/rift_small.png create mode 100644 ftnoir_tracker_rift/images/rift_tiny.png create mode 100644 ftnoir_tracker_rift/images/small.png create mode 100644 ftnoir_tracker_rift/images/tiny.png diff --git a/ftnoir_tracker_rift/images/medium.png b/ftnoir_tracker_rift/images/medium.png new file mode 100644 index 00000000..a5ba49e7 Binary files /dev/null and b/ftnoir_tracker_rift/images/medium.png differ diff --git a/ftnoir_tracker_rift/images/rift_medium.png b/ftnoir_tracker_rift/images/rift_medium.png new file mode 100644 index 00000000..a5ba49e7 Binary files /dev/null and b/ftnoir_tracker_rift/images/rift_medium.png differ diff --git a/ftnoir_tracker_rift/images/rift_small.png b/ftnoir_tracker_rift/images/rift_small.png new file mode 100644 index 00000000..3f18080c Binary files /dev/null and b/ftnoir_tracker_rift/images/rift_small.png differ diff --git a/ftnoir_tracker_rift/images/rift_tiny.png b/ftnoir_tracker_rift/images/rift_tiny.png new file mode 100644 index 00000000..76fe0f58 Binary files /dev/null and b/ftnoir_tracker_rift/images/rift_tiny.png differ diff --git a/ftnoir_tracker_rift/images/small.png b/ftnoir_tracker_rift/images/small.png new file mode 100644 index 00000000..3f18080c Binary files /dev/null and b/ftnoir_tracker_rift/images/small.png differ diff --git a/ftnoir_tracker_rift/images/tiny.png b/ftnoir_tracker_rift/images/tiny.png new file mode 100644 index 00000000..76fe0f58 Binary files /dev/null and b/ftnoir_tracker_rift/images/tiny.png differ -- cgit v1.2.3 From 8ada7131d5e150266255765e833edf245c0d275e Mon Sep 17 00:00:00 2001 From: mm0zct Date: Sat, 14 Dec 2013 17:04:43 +0000 Subject: found a new file --- ftnoir_tracker_rift/ftnoir_rift.qrc | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 ftnoir_tracker_rift/ftnoir_rift.qrc diff --git a/ftnoir_tracker_rift/ftnoir_rift.qrc b/ftnoir_tracker_rift/ftnoir_rift.qrc new file mode 100644 index 00000000..cd174fc4 --- /dev/null +++ b/ftnoir_tracker_rift/ftnoir_rift.qrc @@ -0,0 +1,7 @@ + + + images/rift_medium.png + images/rift_small.png + images/rift_tiny.png + + -- cgit v1.2.3 From 1328c5d1649f35e856206dea4521cbaf9a152c95 Mon Sep 17 00:00:00 2001 From: mm0zct Date: Sat, 14 Dec 2013 17:20:23 +0000 Subject: sttupid git --- ftnoir_tracker_rift/ftnoir_tracker_rift_dll.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift_dll.cpp b/ftnoir_tracker_rift/ftnoir_tracker_rift_dll.cpp index a05587f7..3423ba05 100644 --- a/ftnoir_tracker_rift/ftnoir_tracker_rift_dll.cpp +++ b/ftnoir_tracker_rift/ftnoir_tracker_rift_dll.cpp @@ -32,7 +32,7 @@ void FTNoIR_TrackerDll::getDescription(QString *strToBeFilled) void FTNoIR_TrackerDll::getIcon(QIcon *icon) { - *icon = QIcon(":/images/facetracknoir.png"); + *icon = QIcon(":/images/rift_tiny.png"); } //////////////////////////////////////////////////////////////////////////////// -- 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(-) 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 03a3088a0e8fd14684044fb2f20072556e55712b Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 18 Dec 2013 09:14:58 +0100 Subject: adjust coeffs so that aruco actually works Signed-off-by: Stanislaw Halik --- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index d7d55f82..972dd1e1 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -192,7 +192,7 @@ void Tracker::run() cv::Mat color, color_, grayscale, rvec, tvec; - const double stateful_coeff = 0.81; + const double stateful_coeff = 0.86; if (!camera.isOpened()) { @@ -218,7 +218,7 @@ void Tracker::run() cv::cvtColor(color, grayscale, cv::COLOR_BGR2GRAY); const int scale = frame.cols > 480 ? 2 : 1; - detector.setThresholdParams(scale > 1 ? 11 : 7, 7); + detector.setThresholdParams(scale > 1 ? 11 : 7, 4); const float focal_length_w = 0.5 * grayscale.cols / tan(0.5 * fov * HT_PI / 180); const float focal_length_h = 0.5 * grayscale.rows / tan(0.5 * fov * grayscale.rows / grayscale.cols * HT_PI / 180.0); -- cgit v1.2.3 From e3d7246f63b30931d3b1d41a4b036bd0c661d06d Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 22 Dec 2013 17:24:59 +0100 Subject: append "win32" to installer filename --- installer/opentrack-installer.iss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/installer/opentrack-installer.iss b/installer/opentrack-installer.iss index 5f25c917..cf0ebec6 100644 --- a/installer/opentrack-installer.iss +++ b/installer/opentrack-installer.iss @@ -23,7 +23,7 @@ AppUpdatesURL={#MyAppURL} DefaultDirName={pf}\{#MyAppName} DefaultGroupName={#MyAppName} AllowNoIcons=yes -OutputBaseFilename={#MyAppVersion}-setup +OutputBaseFilename={#MyAppVersion}-win32-setup SetupIconFile=..\facetracknoir\facetracknoir.ico Compression=lzma2/ultra64 SolidCompression=yes -- cgit v1.2.3 From 51c93f8c6c7c9d84634c0e840281373bbe25a89c Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 26 Dec 2013 01:36:41 +0100 Subject: qfc: reenable mouse tracking all the time --- qfunctionconfigurator/qfunctionconfigurator.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/qfunctionconfigurator/qfunctionconfigurator.cpp b/qfunctionconfigurator/qfunctionconfigurator.cpp index a80e3b6b..4ad0a9a4 100644 --- a/qfunctionconfigurator/qfunctionconfigurator.cpp +++ b/qfunctionconfigurator/qfunctionconfigurator.cpp @@ -52,6 +52,8 @@ QFunctionConfigurator::QFunctionConfigurator(QWidget *parent) _draw_background = true; _draw_function = true; + setMouseTracking(true); + // qDebug() << "QFunctionConfigurator::QFunctionConfigurator object created."; } @@ -357,7 +359,6 @@ void QFunctionConfigurator::mousePressEvent(QMouseEvent *e) bTouchingPoint = true; movingPoint = i; timer.restart(); - setMouseTracking(true); break; } } @@ -398,7 +399,6 @@ void QFunctionConfigurator::mousePressEvent(QMouseEvent *e) emit CurveChanged( true ); } movingPoint = -1; - setMouseTracking(false); } } _draw_function = _draw_background = true; @@ -461,7 +461,6 @@ 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()) { @@ -489,7 +488,7 @@ bool QFunctionConfigurator::markContains(const QPointF &pos, const QPointF &coor { QRectF rect(pos.x() - pointSize, pos.y() - pointSize, - pointSize*3, pointSize*3); + pointSize*M_PI, pointSize*M_PI); QPainterPath path; path.addEllipse(rect); return path.contains(coord); -- cgit v1.2.3 From 4350b676bd4fd94dd5cfd10a664ac666d459ddbc Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 26 Dec 2013 01:38:12 +0100 Subject: while here, allow floats as qfc resolution --- qfunctionconfigurator/qfunctionconfigurator.h | 36 +++++++++++++-------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/qfunctionconfigurator/qfunctionconfigurator.h b/qfunctionconfigurator/qfunctionconfigurator.h index 35f06a0d..dccd4601 100644 --- a/qfunctionconfigurator/qfunctionconfigurator.h +++ b/qfunctionconfigurator/qfunctionconfigurator.h @@ -26,12 +26,12 @@ 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) - Q_PROPERTY(int pixPerEGU_Output READ pixPerEGU_Output WRITE setpixPerEGU_Output) - Q_PROPERTY(int gridDistEGU_Input READ gridDistEGU_Input WRITE setgridDistEGU_Input) - Q_PROPERTY(int gridDistEGU_Output READ gridDistEGU_Output WRITE setgridDistEGU_Output) + Q_PROPERTY(double maxInputEGU READ maxInputEGU WRITE setmaxInputEGU) + Q_PROPERTY(double maxOutputEGU READ maxOutputEGU WRITE setmaxOutputEGU) + Q_PROPERTY(double pixPerEGU_Input READ pixPerEGU_Input WRITE setpixPerEGU_Input) + Q_PROPERTY(double pixPerEGU_Output READ pixPerEGU_Output WRITE setpixPerEGU_Output) + Q_PROPERTY(double gridDistEGU_Input READ gridDistEGU_Input WRITE setgridDistEGU_Input) + Q_PROPERTY(double gridDistEGU_Output READ gridDistEGU_Output WRITE setgridDistEGU_Output) Q_PROPERTY(QColor colorBezier READ colorBezier WRITE setColorBezier) Q_PROPERTY(QString stringInputEGU READ stringInputEGU WRITE setInputEGU) @@ -39,27 +39,27 @@ class FTNOIR_TRACKER_BASE_EXPORT QFunctionConfigurator : public QWidget Q_PROPERTY(QString stringCaption READ stringCaption WRITE setCaption) // Return the current value to Designer - int maxInputEGU() const + double maxInputEGU() const { return MaxInput; } - int maxOutputEGU() const + double maxOutputEGU() const { return MaxOutput; } - int pixPerEGU_Input() const + double pixPerEGU_Input() const { return pPerEGU_Input; } - int pixPerEGU_Output() const + double pixPerEGU_Output() const { return pPerEGU_Output; } - int gridDistEGU_Input() const + double gridDistEGU_Input() const { return gDistEGU_Input; } - int gridDistEGU_Output() const + double gridDistEGU_Output() const { return gDistEGU_Output; } @@ -131,12 +131,12 @@ private: int movingPoint; QElapsedTimer timer; - int MaxInput; // Maximum input limit - int MaxOutput; // Maximum output limit - int pPerEGU_Input; // Number of pixels, per EGU of Input - int pPerEGU_Output; // Number of pixels, per EGU of Output - int gDistEGU_Input; // Distance of the grid, in EGU of Input - int gDistEGU_Output; // Distance of the grid, in EGU of Output + double MaxInput; // Maximum input limit + double MaxOutput; // Maximum output limit + double pPerEGU_Input; // Number of pixels, per EGU of Input + double pPerEGU_Output; // Number of pixels, per EGU of Output + double gDistEGU_Input; // Distance of the grid, in EGU of Input + double gDistEGU_Output; // Distance of the grid, in EGU of Output QColor colBezier; // Color of Bezier curve QString strInputEGU; // Engineering Units input (vertical axis) -- cgit v1.2.3 From 61b66d8689005dacf43d0ea42165b695e089fc28 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 26 Dec 2013 01:38:24 +0100 Subject: aruco: use less cpu for idempotent frames --- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index 972dd1e1..9a50a2b6 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -192,7 +192,7 @@ void Tracker::run() cv::Mat color, color_, grayscale, rvec, tvec; - const double stateful_coeff = 0.86; + const double stateful_coeff = 0.75; if (!camera.isOpened()) { -- cgit v1.2.3 From fd3d77ecd23a605822890cf049077114cda3368a Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 26 Dec 2013 01:41:17 +0100 Subject: qfc: prevent default to nonsense on broken config --- qfunctionconfigurator/functionconfig.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qfunctionconfigurator/functionconfig.cpp b/qfunctionconfigurator/functionconfig.cpp index b937d95e..97a6db24 100644 --- a/qfunctionconfigurator/functionconfig.cpp +++ b/qfunctionconfigurator/functionconfig.cpp @@ -235,8 +235,8 @@ void FunctionConfig::loadSettings(QSettings& settings) { int max = settings.value("point-count", 0).toInt(); 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()); + newPoint = QPointF(settings.value(QString("point-%1-x").arg(i), 0).toFloat(), + settings.value(QString("point-%1-y").arg(i), 0).toFloat()); // // Make sure the new Point fits in the Function Range. // Maybe this can be improved? -- cgit v1.2.3 From 84e82b6c56d74d75834328b9495e9c1d81510fed Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 26 Dec 2013 01:42:55 +0100 Subject: qfc: use saner sub-degree precision value --- qfunctionconfigurator/functionconfig.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qfunctionconfigurator/functionconfig.h b/qfunctionconfigurator/functionconfig.h index 4f48096a..a8bb3371 100644 --- a/qfunctionconfigurator/functionconfig.h +++ b/qfunctionconfigurator/functionconfig.h @@ -15,7 +15,7 @@ #include #include "ftnoir_tracker_base/ftnoir_tracker_base.h" -#define MEMOIZE_PRECISION 500 +#define MEMOIZE_PRECISION 100 class FTNOIR_TRACKER_BASE_EXPORT FunctionConfig { private: -- cgit v1.2.3 From 10010c9883b05ccac61c34fc993bea9c657b18aa Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 26 Dec 2013 01:43:54 +0100 Subject: more senseless coeff tweaks --- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index 9a50a2b6..47c83c12 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -192,7 +192,7 @@ void Tracker::run() cv::Mat color, color_, grayscale, rvec, tvec; - const double stateful_coeff = 0.75; + const double stateful_coeff = 0.9; if (!camera.isOpened()) { -- cgit v1.2.3 From 1aed2a2b1e74841ad76c51d136468da54d7cda4a Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 27 Dec 2013 17:59:31 +0100 Subject: regen csv --- bin/settings/facetracknoir supported games.csv | 998 ++++++++++++------------- 1 file changed, 495 insertions(+), 503 deletions(-) diff --git a/bin/settings/facetracknoir supported games.csv b/bin/settings/facetracknoir supported games.csv index b540e2cb..1f98beab 100644 --- a/bin/settings/facetracknoir supported games.csv +++ b/bin/settings/facetracknoir supported games.csv @@ -1,504 +1,496 @@ No;Game Name;Game protocol;Supported since;Verified;By;INTERNATIONAL_ID;FTN_ID -1;18 Wheels of Steel: Haulin';FreeTrack20;V160;V;doc-uk;13601;000121F172F35116A02100 -2;1944 D-Day;FreeTrack20;V160;;;15701;00022E542A6A0575F05200 -497;2KMarinNEXT;FreeTrack20;V170;;;3425;0D614F6A0820D1EA8EE800 -3;3D Instructor;FreeTrack20;V160;;;20490;00034B0FC367116611B100 -4;3D Interactive;FreeTrack20;V160;;;20425;0004C6371D77135815A600 -5;3d Nav;FreeTrack20;V160;;;20235;000579EC0E26932651EA00 -6;3D-Fahrschule Driving Simulator;FreeTrack20;V160;;;20020;000601075146E0E9625B00 -7;3ds Max;FreeTrack20;V160;;;8601;00077A32A1A7523A4DE700 -8;Aaaaa!;FreeTrack20;V160;;;1775;00085485D831DA62CA7E00 -9;Accessible Computer Games;FreeTrack20;V160;;;4301;000916BC07A2F9B35B6300 -10;Aces High II;FreeTrack20;V160;V;bash1;2701;000A4B798B7221A72E5800 -11;ADS;FreeTrack20;V160;;;20690;000BB25377780C8A894400 -12;Aerofly FS;FreeTrack20;V160;V;V4Friend;2025;000C3797169752CAB39A00 -13;Affineon;FreeTrack20;V160;;;20405;000D662B0374339635A000 -14;Air Battles: Sky Defender;FreeTrack20;V160;;;7003;000E7C822098630A2ED700 -15;Air Phobia;FreeTrack20;V160;;;20100;000F0108339B3E78525B00 -16;Air Traffic Control Tower;FreeTrack20;V160;;;3601;0010432C28637A8EF97400 -17;AirBook;FreeTrack20;V160;;;15201;0011D615A9C8430A201A00 -18;America's Army;FreeTrack20;V160;;;4101;00120BCF5753D98399E200 -19;America's Army 3;FreeTrack20;V170;;;14203;00133F3206BCEA252BB700 -20;ANAG 3D;FreeTrack20;V160;;;20250;0014E2D1D7780A72166300 -21;Apache: Air Assault;FreeTrack20;V160;V;paleta77;1875;001591D997A2D912AAA200 -22;Aprisoft Gartenplaner;FreeTrack20;V160;;;20014;0016F2F27A5762FA937A00 -23;Aprisoft Traumhaus Designer;FreeTrack20;V160;;;20013;00174655E792BB825B9300 -498;ARI;FreeTrack20;V160;;;20795;01F23FB9A61044E206E200 -506;ArmA;FreeTrack20;V160;;;10601;01FAE645A8544EDC002000 -507;ArmA 2;FreeTrack20;V170;;;7502;1D4EEB3616B3A44F05B900 -508;Arma 3;FreeTrack20;V170;;;7503;1D4FB69411ABD4E2B39900 -28;Armored Assault - Gold Edition;FreeTrack20;V170;;;1303;001CA7F7CAA00814ECA700 -29;Arvoch Alliance;FreeTrack20;V160;;;14908;001D318F8773BAE29A9300 -30;Arvoch Conflict;FreeTrack20;V160;;;14901;001E5C1FDE722DAE2BA900 -31;Auditory Displays for the blind;FreeTrack20;V160;;;20035;001F0FC9FF862F9D34BA00 -486;Autodesk;FreeTrack20;V160;;;20755;01E6953FA7F759AF33AC00 -32;AV Core Technology;FreeTrack20;V160;;;20016;00204655E791166FEB5300 -33;AVRS;FreeTrack20;V160;;;20340;0021231517525830F41D00 -482;B.O.M.B.;FreeTrack20;V160;;;3325;01E248ECCB81191AD49F00 -34;BAE Systems HILAS cockpit;FreeTrack20;V160;;;20019;00220D9C887FD88E98B300 -35;Battle of Britain (iENT);FreeTrack20;V170;;;1305;00230BA119195B701AED00 -36;Battle of Britain II - Wings of Victory;FreeTrack20;V160;V;Normalguy;7001;002452135882CA6419E200 -37;Battlecruiser;FreeTrack20;V160;;;6101;00257C822098728A442900 -38;Battlefield 2;FreeTrack20;V170;;;9601;0026B1560A2A7327659200 -39;Battlefield 2 Trauma Studios;FreeTrack20;V160;;;6501;002720C7529B733AE2EA00 -40;Battlefield 2142;FreeTrack20;V170;;;9602;00281C739AD3817FD43300 -41;Battleground Europe : World War II Online;FreeTrack20;V160;;;3301;0029F07957792CAD3DAF00 -42;Battleground Europe : WWII Online;FreeTrack20;V160;;;11201;002A985017330A844A1200 -43;Beckman Institute UIUC;FreeTrack20;V160;;;20012;002BB59DEFA8322A926A00 -44;Beyond The Red Line;FreeTrack20;V160;;;13301;002CE7A7FAA27424BA2A00 -45;BF2 (Unsupported Demo);FreeTrack20;V160;;;9651;002DC6371D86156AEB6000 -46;Big Scale Racing;FreeTrack20;V160;;;8301;002E4655E7A24ADDB99200 -47;Birds of Prey;FreeTrack20;V160;;;1601;002FBF8C4EAA57730B3200 -48;Birds of Steel;FreeTrack20;V160;;;1878;0030D7690F607233A21E00 -49;Boeing;FreeTrack20;V160;;;20351;0031044872BA630A033E00 -50;Boeing Demo;FreeTrack20;V160;;;20350;003228C57B369A37B13600 -51;Bomber Squadron;FreeTrack20;V160;;;1850;00338481733B9E32A83A00 -52;Brain-IT Group;FreeTrack20;V160;;;20050;0034E482F5772C9330B100 -53;Brothers In Arms;FreeTrack20;V160;;;13501;003503FB872CA8439D1F00 -82;C-Spine;FreeTrack20;V160;;;4901;00525FD692C188FB8B2D00 -54;C.A.R.S.;FreeTrack20;V170;;;2825;003698EFE2EB6EE8E11300 -55;C.U.B.;FreeTrack20;V160;;;20505;0037848174F986FD85F500 -56;CameraGripTools;FreeTrack20;V160;;;20150;003870A8B761FA524A4200 -57;Caterpillar Simulators;FreeTrack20;V160;;;23080;0039F52E4221742FA63100 -58;CCG Metamedia;FreeTrack20;V160;;;20009;003A6FA8A8DD86FE8BDB00 -59;CEWIT Immersive Cabin;FreeTrack20;V160;;;20370;003B90B5780C90078DEE00 -60;Chopper;FreeTrack20;V160;;;3150;003CC166C8632A32EA2300 -61;Clearbox;FreeTrack20;V160;;;20565;003D5C1FDE74279D1DB800 -62;CNKFsoft;FreeTrack20;V160;;;20495;003ED7690F6073187B0000 -487;Cognitics;FreeTrack20;V160;;;20760;01E715A96D19515BFC1500 -63;Colin McRae DiRT 2;FreeTrack20;V170;V;V4Friend;8107;003F7815C5379491C73300 -64;Colin McRae Rally 04;FreeTrack20;V160;;;8103;0040D13C2A843DA526A610 -65;Comanche;FreeTrack20;V160;;;2275;00414097C36A12BA32BA00 -66;Combat Flight Simulator 3;FreeTrack20;V160;V;V4Friend;2304;00420EC5F763AB21CA7310 -67;Combat Helo;FreeTrack20;V160;;;2001;004329DFA863FAE1EA7300 -68;Commandos Strike Force;FreeTrack20;V160;;;8801;0044C1BBF892DB037A7200 -69;Concept RS;FreeTrack20;V160;;;10701;004537971697736A72DA00 -70;Condor: The Competitive Soaring Simulator;FreeTrack20;V160;V;MicheleF;5901;004670A8B762DA623A1300 -71;Conflict Taiwan;FreeTrack20;V160;;;1950;0047D7690F6073399E2000 -72;Corys;FreeTrack20;V160;;;20550;0048157D78738A342A8D00 -73;Counter Strike;FreeTrack20;V160;;;12501;004953FE1E862AB73DA600 -74;Crane Simulator;FreeTrack20;V160;;;20048;004A6B62C6A7931972DA00 -75;Crashday;FreeTrack20;V160;;;5601;004BD6E585F893D933BA00 -76;Creanex Training Simulator;FreeTrack20;V160;;;20205;004CF478D277A40A929A00 -77;Creative Labs headset;FreeTrack20;V160;;;20018;004D348B1743E961FA6300 -78;Cross Racing Championship;FreeTrack20;V160;;;4801;004E20C763AB232B5E8900 -79;Crysis Mod;FreeTrack20;V160;;;1625;004F90B57839B231A24200 -80;Crystal Growth Simulation;FreeTrack20;V160;;;20029;005026F79742FB241A6200 -81;Crytek;FreeTrack20;V170;;;2775;0051D5F1EBBAD81C714600 -83;D2x-XL;FreeTrack20;V160;;;16001;00532E20237BEDABEB8A00 -84;Dark Horizons Lore;FreeTrack20;V160;;;7901;005487801A852AA7385200 -85;Dawn of Aces - Gold Edition;FreeTrack20;V170;;;1304;0055A9ED7700814190DE00 -86;Dawn of Aces II;FreeTrack20;V160;;;1302;00566925967C2BB0285500 -87;DBS WalkAndFollow;FreeTrack20;V160;;;2525;005770A8B77008BDE89200 -88;DCS: Black Shark;FreeTrack20;V170;V;EmBeES;1006;0058F688FC9B0556868F00 -89;DCS: A-10C Warthog (32 and 64 bit);FreeTrack20;V170;V;fabri91, Shadow;1003;0059B6DCD15F5A572F6500 -90;Dead Reckoning;FreeTrack20;V160;;;10401;005A4C2F6752F912D66200 -91;Delivery;FreeTrack20;V160;;;15901;005BF3E85B1A8534AE3400 -471;Demon Core;FreeTrack20;V160;;;3225;01D7D1DC6052A165A7AC00 -92;DiRT;FreeTrack20;V160;;;8104;005C72456F7523881F1800 -93;DiRT 3;FreeTrack20;V170;;;8108;005DABA016ED2DFBDF6F00 -94;Door3;FreeTrack20;V160;;;20665;005ED13C2A853DA82F6B00 -95;Down In Flames;FreeTrack20;V160;;;1025;005F29DFA873FB82A66000 -96;Driver Test;FreeTrack20;V160;;;20265;00609343487C3FAA429D00 -97;Driver's Republic;FreeTrack20;V160;;;14001;0061D24C3F8A3F9C33AB00 -98;DriveSim;FreeTrack20;V160;;;5001;0062DD7CC2B47830A14400 -99;Driving Simulator;FreeTrack20;V160;;;13001;00630AC67539AC3F9F3A00 -100;dSphere TBA;FreeTrack20;V160;;;2425;0064A2AE4981FB5389A300 -101;DTS;FreeTrack20;V160;;;20625;006505B37C12868B3E8500 -102;Dungeons and Dragons Online;FreeTrack20;V170;;;1575;0066BD4D4DDC6BB6818800 -103;DY Demo;FreeTrack20;V160;;;20345;006727D5047A15540F9D00 -104;EADS Testing;FreeTrack20;V160;;;20303;00680288709760D5512900 -504;EAFIT;FreeTrack20;V160;;;20810;01F8D2675ABC163E99B000 -105;Eagle Lander 3D;FreeTrack20;V160;;;11901;00697686E5A7B209C27900 -106;EasyVR;FreeTrack20;V160;;;20220;006A68292872FAC4588100 -107;ECA-Sindel;FreeTrack20;V160;;;20590;006BC5BEE479FD75FB8500 -481;Embers of Caerus;FreeTrack20;V170;;;3275;0CCB4134258D7E10119E00 -108;EMS Simulations;FreeTrack20;V160;;;20390;006CA59E687D1589DE8500 -109;Enemy Engaged 2;FreeTrack20;V160;;;2102;006D010873EA635AEDC800 -110;Enemy Engaged: Commanche vs Hokum;FreeTrack20;V160;;;2101;006E157D789379636AED00 -111;Envision TE;FreeTrack20;V160;;;20320;006FD13C2A863CAF26AB00 -112;EON Reality;FreeTrack20;V160;;;20410;0070B6C6142771F82EE900 -113;eSigma;FreeTrack20;V160;;;20700;0071950F9AA60DAD2E9F00 -114;Euro Truck Simulator;FreeTrack20;V160;V;mamsa;13602;00721B4BFF8B3EA3296600 -115;EVE Online;FreeTrack20;V160;;;11801;0073F47CC377C2388DC900 -116;Eventology;FreeTrack20;V160;;;12201;0074849F8B469C2BAC3600 -117;EVOC-101 Training;FreeTrack20;V160;;;20038;00756925967D2088FC6200 -118;Evochron Alliance 2.0;FreeTrack20;V160;;;14904;00767A32A1A8735A022900 -119;Evochron Legends;FreeTrack20;V160;;;14906;0077D6E585F8B41A12BA00 -120;Evochron Mercenary;FreeTrack20;V160;V;Scavenger4711 ;14907;00783752FBC7B42B221A00 -121;Evochron Renegades;FreeTrack20;V160;;;14905;0079621E7763FB421A1300 -122;EZCA;FreeTrack20;V160;V;dennison ;2475;007A6DBB52F7B147510601 -125;F-22 Total Air War;FreeTrack20;V160;;;1750;007D20C79F475F0621DB00 -126;F-35 PTA;FreeTrack20;V160;;;20185;007E26F7977E96C0352100 -148;F-Trainer;FreeTrack20;V160;;;20615;0094C6371D8AFB8C3E9900 -123;F1 2011/2012;FreeTrack20;V170;;;8109;007B265ECD74893EA12900 -124;F1 Challenge 99-02;FreeTrack20;V160;;;4401;007CA15F278FB660C9D210 -127;FAAC;FreeTrack20;V160;;;20500;007F0F00F489118300C000 -128;Farmer Simulator 2009;FreeTrack20;V160;;;1725;0080926ED8A1EB628AB300 -129;Faros Driving Simulator;FreeTrack20;V160;;;8001;0081B1C6647A1EA839A800 -130;Faubert Lab Car Simulator;FreeTrack20;V160;;;20480;00822E542A7F2DB61F9700 -131;Ferrari Virtual Academy;FreeTrack20;V160;V;sosna1983 ;0;0083C0AF8C24B62D974000 -132;FIFA 09;FreeTrack20;V170;;;9002;0084288979C65B0DAA0D00 -133;Fighter Ace;FreeTrack20;V160;;;8401;0085E2D1D77D259837B700 -134;Fighter Ops;FreeTrack20;V160;;;9301;00860FC9FF8B23A033BA00 -135;Fighter Squadron: Screamin Demons Over Europe;FreeTrack20;V160;;;1675;00872E20237D259A27A600 -136;First Eagles, Wings Over Europe, Strike Fighters;FreeTrack20;V160;;;1101;0088311857638A73BB7E00 -469;Flight Gear;FreeTrack20;V160;;;12901;01D5D896C66B030606E000 -466;Flight Simulator 2002;FreeTrack20;V160;;;2302;01D21F7650E254B4514B00 -467;Flight Simulator 2004;FreeTrack20;V160;;;2303;01D3E91BAAB385B2362E00 -468;Flight Simulator X;FreeTrack20;V160;;;2305;01D41C31F42FAF32603600 -137;FlightGear;FlightGear;V110;V;V4Friend;0;0089054E8839A02FAB2F00 -138;Flyboys / Warbirds;FreeTrack20;V160;;;1301;008ABB5BF72C8934AB2B00 -139;Flyer;FreeTrack20;V160;;;1650;008BD1C9F27826AE2CA500 -140;Flying Tigers;FreeTrack20;V160;;;7002;008C91D997F29A930B0200 -141;FlyingGuns;FreeTrack20;V160;;;14801;008D7A32A1A882BAA28A00 -142;Ford Racing 3;FreeTrack20;V160;;;6901;008E27D5047C2BA62F5800 -143;Free Falcon 4.0;FreeTrack20;V160;;;1901;008F157D78A3B962E55000 -144;Free Falcon 4.0: Allied Force;FreeTrack20;V160;;;8901;0090656DD6793CA9325900 -145;Free Falcon 5;FreeTrack20;V160;V;V4Friend;1902;00911038C3AAB32590E900 -146;FreeSpace2;FreeTrack20;V160;;;13302;0092C8CDF8C2EA63496300 -147;FTAlpha;FreeTrack20;V160;;;20270;00936C69677F1D772AA900 -149;Full Out;FreeTrack20;V160;;;1701;009527D5047C31A0375800 -150;Future Pinball;FreeTrack20;V160;V;V4Friend;13101;00969343487E42B541AA00 -151;Game VR;FreeTrack20;V160;;;20325;009756BA018030B0355500 -152;GameLab;FreeTrack20;V160;;;20555;00985485D891DB23092200 -472;Games Farm;FreeTrack20;V160;;;3250;01D875C0981E627E5C7600 -153;Gamma;FreeTrack20;V160;;;1050;009921007D1B9D38A76F00 -503;Garry's Mod;FreeTrack20;V160;;;12503;01F74EEB71FA7F37856900 -483;Generic Robotics;FreeTrack20;V160;;;20750;01E3FE7B4F05872A415400 -475;Glider Sim;FreeTrack20;V160;;;20720;01DB42130C4B0620871C00 -154;Global Ground Support Deicing Simulation;FreeTrack20;V160;;;20330;009ACFE709237A3AA11F00 -155;GosNIIAS Sim Trainer;FreeTrack20;V160;;;20355;009BB78B06EC8A2DB81800 -156;Gothic 3;FreeTrack20;V160;;;14401;009C37971697B36AD32A00 -157;Grand Prix Legends;FreeTrack20;V160;;;6701;009D521358D3D933B96E01 -158;Grand Theft Auto: San Andreas;FreeTrack20;V160;;;7808;009E5F3D95777D3BA23700 -159;GRID;FreeTrack20;V160;V;LeapoEclipse ;8105;009FD8175F8D1D7C0D3800 -160;GSE Power Plant Simulation;FreeTrack20;V160;;;20044;00A0432C28C217BEF93300 -161;GT Legends;FreeTrack20;V160;V;TrickyDee ;3902;00A116BC08020581CA8200 -162;GTR;FreeTrack20;V160;;;3901;00A2FD6BFE39A881B85B00 -163;GTR2 EVO;FreeTrack20;V160;V;zild1221 ;0;00A34B0FC37B2198F96300 -164;Gun Commander;FreeTrack20;V160;;;2675;00A4E2D1D77E319FEE8600 -165;Half Life 2;FreeTrack20;V160;;;7806;00A556BA018130AF365500 -166;Halo;FreeTrack20;V160;;;3801;00A656BA018130AF3F9C00 -502;hapTEL;FreeTrack20;V160;;;20805;01F63ADE510A20446B6A00 -167;Hardware Control Simulator, Railway Electronics;FreeTrack20;V160;;;20705;00A7F3E85B1A8930B42F00 -168;Harrier Attack II;FreeTrack20;V160;;;1175;00A8F2F27A57D20A940900 -499;Harry's Hard Choices Interactive;FreeTrack20;V160;;;20800;01F33A21BAE3DB6D48A000 -169;HAWX;FreeTrack20;V160;V;EmBeES ;0;00A9D615A9C8B088717000 -170;Herissons (Paris France);FreeTrack20;V160;;;20001;00AAEA1CBED8C20B430B00 -171;HOBI;FreeTrack20;V160;;;20335;00ABB253777F1779168900 -172;HoverAssault;FreeTrack20;V160;;;5303;00AC521358E3AA832A4000 -173;HPC;FreeTrack20;V160;;;20600;00AD0FC9FF8D0A7CEF9500 -174;HPG Tracking;FreeTrack20;V160;;;20255;00AE0288A1879D98930900 -175;HTW;FreeTrack20;V160;;;20630;00AF26F797911901C22C00 -176;Huawei Software;FreeTrack20;V160;;;20660;00B04655E8030A733AB300 -177;HueSpace;FreeTrack20;V160;;;20510;00B1231517C44960FB6300 -178;Hyper Vision;FreeTrack20;V160;;;15101;00B2DB242B657D43B32300 -179;iAmFootball;FreeTrack20;V160;;;1250;00B3B59DEFAAAFDB301A00 -180;id Research;FreeTrack20;V170;;;2950;00B4E723B873D7FC87D700 -181;IESA;FreeTrack20;V160;;;20037;00B5157D78D0E840AD7100 -182;IL-2 Cliffs of Dover;FreeTrack20;V160;V;V4Friend;0;00B6282282095F00521000 -183;IL-2 Forgotten Battles, ACE, Pacific Fighters;FreeTrack20;V160;V;Glenn;1001;00B722FD79137100621100 -484;IL-2 Sturmovik: Battle of Stalingrad;FreeTrack20;V170;;;1008;03F04D5368D1FD2DF2AE00 -184;Illumina;FreeTrack20;V160;;;1350;00B8054E8B39A33DB02400 -185;ILP;FreeTrack20;V160;;;20310;00B9F07957801789C9A600 -186;Imagine 3D ATC Tower Simulation;FreeTrack20;V160;;;20032;00BAEF7A8F4B8812B95300 -187;In Touch Technologies Inc.;FreeTrack20;V160;;;20006;00BB84817A3A5124B23D00 -188;Inglobe;FreeTrack20;V160;;;20360;00BCE7A7FAA27B2DA82700 -189;Innovatec Simulator;FreeTrack20;V160;;;20036;00BD22FD7935B23DB82C00 -190;Insurgency;FreeTrack20;V160;;;9401;00BEB6C61427B3EA744B00 -191;Intific;FreeTrack20;V160;;;20655;00BF2BCA747F2AA8309D00 -192;iRacing;FreeTrack20;V160;V;vn88holden ;14101;00C0103AF1AA730A236900 -193;IREQ Robotic Camera Control;FreeTrack20;V160;;;20027;00C10448E0E8618521EB00 -194;ISIC;FreeTrack20;V160;;;20680;00C2DEE3582F8F217E0B00 -195;IVD Online;FreeTrack20;V160;;;20535;00C390B57E1D7DDD883D00 -196;J.J. Keller and Associates;FreeTrack20;V160;;;20002;00C4E482F57FE77CF46300 -197;Janes F18;FreeTrack20;V160;;;9001;00C55F3D9577802AAF2E00 -198;Javal Ent.;FreeTrack20;V160;;;2650;00C622FD7A28BA2FAEEA00 -199;JC Demo;FreeTrack20;V160;;;20470;00C70AC67B0A630D9B3900 -200;Jet Thunder;FreeTrack20;V160;;;4501;00C82100801FA4EA9A3500 -201;Jetfighter V;FreeTrack20;V160;;;2501;00C9F52E42217B33A63200 -202;JFIST;FreeTrack20;V160;;;20560;00CAC932727C0F8D208600 -203;John Deere Vehicle Simulator;FreeTrack20;V160;;;20175;00CB29DFA8D3FA92A66000 -204;Jump to Lightspeed;FreeTrack20;V160;;;6001;00CCC166C8D3FA12E52400 -205;Jumpgate;FreeTrack20;V160;;;15001;00CD26F797B32A63E99200 -206;Jumpgate Evolution;FreeTrack20;V170;;;15002;00CE5936D4F93DCE0CE700 -207;KAF Keymapper;FreeTrack20;V160;;;3101;00CF934348830E87EB8300 -476;KAI FLight Simulator;FreeTrack20;V160;;;20725;01DCC522132A5C01EDE500 -208;Key Macro View;FreeTrack20;V160;;;12001;00D016BC08431B1EF90100 -209;kiwi.vg;FreeTrack20;V160;;;20395;00D1409A430AB33633E900 -210;L-3;FreeTrack20;V160;;;20465;00D2F885EFA8DE67878B00 -211;L-3 Communications;FreeTrack20;V160;;;20051;00D3D6E585F92F765E7800 -212;Lionhead MGS Game Research;FreeTrack20;V160;;;15301;00D4C1BBF9227B238AE200 -213;Live For Speed;FreeTrack20;V160;V;zild1221 ;7101;00D528228526A833521300 -214;Live for Speed S2;FreeTrack20;V160;;;11601;00D63752FBC8235B923500 -218;Lock-On: Modern Air Combat;FreeTrack20;V160;;;1002;00DAAC156D903C993B6200 -215;Lockheed Martin Littoral Combat Ship simulator;FreeTrack20;V160;;;20025;00D771ED5E802A9827A000 -216;Lockheed Martin Prepar3D;SimConnect;V130;V;elelbe ;0;00D8D615A9C8F36932AA00 -217;LockOn: Flaming Cliffs 2;FreeTrack20;V170;V;EmBeES ;1005;00D9AFB0D279F3A6F72200 -219;London NHS;FreeTrack20;V160;;;20640;00DB2E2023832BA123A100 -220;Lore (Dark Horizons);FreeTrack20;V160;;;5302;00DCF478D27833DB62D500 -221;Love;FreeTrack20;V160;;;3125;00DD71ED5E802AAB214800 -222;Lucid Engine;FreeTrack20;V160;;;10501;00DE71ED5E803098259C00 -223;M4 Tank Platoon;FreeTrack20;V160;;;1306;00DFDCC441A8E036320900 -224;Mach 1;FreeTrack20;V160;;;2575;00E0231518130942466000 -225;ManuVAR;FreeTrack20;V160;;;20455;00E153FE1E901CB0448800 -226;MaqSIM4;FreeTrack20;V160;;;20026;00E28F54A207D29B611700 -227;Mech Tactical Sim;FreeTrack20;V160;;;9501;00E3F3E85B1A8E34A53300 -228;Mechwarrior Online;FreeTrack20;V170;;;3025;00E414954226DB5D8CE200 -229;Medical Image Visualization;FreeTrack20;V160;;;20295;00E59343488532A5359B00 -230;Meggitt Defense Systems;FreeTrack20;V160;;;20045;00E6926ED9122AB22AF300 -231;MetaVR;FreeTrack20;V160;;;20545;00E7C5BEE48120A8308800 -232;Meteoroid Maze;FreeTrack20;V160;;;13003;00E8F079578430AD2EB200 -233;MeVEA;FreeTrack20;V160;;;2250;00E9D24C3F933289028700 -234;Micro Flight;FreeTrack20;V160;V;V4Friend;5101;00EABA89D078439932EA00 -235;Microsoft ESP;FreeTrack20;V160;;;2306;00EB0AC67E30A63BA53F00 -236;Microsoft Flight;FreeTrack20;V170;V;V4Friend;2307;00ECAFBC54959539C51500 -237;Microsoft Flight Simulator 3;FreeTrack20;V160;V;V4Friend;0;00ED5909437D36963EA810 -238;Microsoft FS2002/2004;FSUIPC;V130;V;V4Friend;0;00EE44958F34992CB43A00 -239;Microsoft FSX;SimConnect;V130;V;V4Friend;0;00EFF478D278437A73AA00 -240;Microsoft Train Simulator;FreeTrack20;V160;;;7805;00F00449225A439A13FB00 -494;MiddleVR;FreeTrack20;V160;;;20785;01EE1227DF43CA90C26100 -241;Mig Alley;FreeTrack20;V160;;;1501;00F17686E5A83289CDA700 -242;Mimik Vehicle Simulator;FreeTrack20;V160;;;20585;00F2AB1D58A8E35A531A00 -243;Miner Wars;FreeTrack20;V160;;;2550;00F3C5BEE48124A234A400 -244;MKMapper Keymapper;FreeTrack20;V160;;;2201;00F487801A8E14822EA200 -245;ModelSim;FreeTrack20;V160;;;20540;00F544958F3A9A1FB11A00 -246;Morgan State University;FreeTrack20;V160;;;20010;00F65909437D3CA5339A00 -247;Motor Company;FreeTrack20;V160;;;11501;00F70288F37A629A7DD700 -248;Motorsport Simulators;FreeTrack20;V160;;;4201;00F8F52E42217E3DA63B00 -249;Mouse Emulation;FreeTrack20;V160;;;8501;00F9950F9A8E29B93A9700 -250;MS World Tour Kart 2004;FreeTrack20;V160;;;6601;00FA9F819CA27F10591600 -251;MSN Virtual Earth;FreeTrack20;V160;;;2309;00FBF47CC37842091DC900 -252;mTBI Balance;FreeTrack20;V160;;;20420;00FC72456F9E0E78145800 -253;NASA Crew Exploration Vehicle;FreeTrack20;V160;;;20017;00FD028900985FA5501A00 -254;NASCAR Heat;FreeTrack20;V160;;;2602;00FE311857E10880B84100 -255;NASCAR Racing 2003 season;FreeTrack20;V160;;;7804;00FFDE661F6D920B87FC10 -256;NASCAR SimRacing;FreeTrack20;V160;;;6201;01004098708870D761A500 -257;NecroVisioN;FreeTrack20;V160;;;15601;0101621E77F2EA830A8100 -258;NetKar Pro;FreeTrack20;V160;V;sosna1983 ;10901;01028C3958334A5169A300 -259;Nitro Stunt Racing;FreeTrack20;V160;;;13901;0103C0AF9428B82DA5ED00 -260;North Eastern University;FreeTrack20;V160;;;20003;0104A2AE4823BB7449DE00 -261;Novint;FreeTrack20;V160;;;2725;01051C76F8137B823A4300 -262;NVH Sound Simulator;FreeTrack20;V160;;;20695;010655A2AA93158DDE9500 -479;OHJCH;FreeTrack20;V160;;;20740;01DF992E6C0DA43A703600 -263;OMSI Bus Simulator;FreeTrack20;V160;V;Thiago ;2225;0107F47CC37861A9606600 -264;Onadime - Realtime Animation;FreeTrack20;V160;;;20049;010853FE1E9229A3339B00 -265;Open Falcon 4.5;FreeTrack20;V160;V;muplex ;0;0109B1C664832D9B385500 -266;Operation Air Assault 2;FreeTrack20;V160;;;5401;010ABB5BF72C9238973B00 -267;Operation Flashpoint 2 (inactive);FreeTrack20;V160;;;7601;010BD1C9F2812A9A399400 -268;Operation Flashpoint(r): Dragon Rising(tm);FreeTrack20;V170;;;8106;010C3328780E1322676100 -269;OptiMetrics;FreeTrack20;V160;;;20011;010D55A2AA942FB9288F00 -270;OpusFSX;FreeTrack20;V160;;;3175;010E1C76F8238B72D7C100 -271;Orbiter 2005 Plug-In;FreeTrack20;V160;;;10301;010F87801A903B9736A600 -272;Orbiter 2006;FreeTrack20;V160;V;Ripley;10303;0110D24C3F953F9526BA00 -273;Orbiter 2006 Plug-In;FreeTrack20;V160;;;10302;0111054E913F9931B72000 -274;Oryx Vehicle Simulators;FreeTrack20;V160;;;20028;0112C8CDF952EBA4763100 -275;Outer Conflict: Frontiers;FreeTrack20;V160;;;1900;01136C6967883EAA23AB00 -276;Over Flanders Fields;FreeTrack20;V160;V;Summelar ;2325;0114A59E68873E9B315210 -277;PanoPro;FreeTrack20;V160;;;20525;0115B6C61428231A23E900 -278;Paraworld;FreeTrack20;V160;;;14501;0116656DD6832BB62EB000 -279;Phoenix R/C;FreeTrack20;V160;;;3075;0117B6C61428238A334B00 -280;Pivot Maritime;FreeTrack20;V160;;;20365;01187686E5A8628AB2AA00 -281;PlanetSide 2;FreeTrack20;V170;;;6002;0119BB34B53FDC5C5AAF00 -474;PlanetSide 2 M.E.;FreeTrack20;V160;;;6003;01DA321EF31DA48C159A00 -282;Pointman;FreeTrack20;V160;;;7525;011ACFE70923833D9B2B00 -283;Power Driving Simulator;FreeTrack20;V160;;;20675;011BB78B06EC932DBC2F00 -470;Prepar3D;FreeTrack20;V160;;;20440;01D6DA768CE8AA43D8DC00 -284;Priston Tale;FreeTrack20;V160;;;9701;011C849F9642A030AC3600 -285;Project Reality (BF2 Mod);FreeTrack20;V160;;;9201;011D3C2C1C922CB239A800 -286;Project Torque (Invictus);FreeTrack20;V160;;;4802;011E612F28540B52797100 -287;Project X;FreeTrack20;V160;;;20022;011FE9D85E4842DA439900 -288;Quanser;FreeTrack20;V160;;;20435;0120950F9A922FA535A500 -289;QuantaDyn;FreeTrack20;V160;;;20575;012199BB5C9433A739B600 -290;Quest 3D Xframe Plugin;FreeTrack20;V160;;;20043;0122FD6BFE39A923C98200 -291;Quest3D;FreeTrack20;V160;;;1425;01234B0FC38542AB3BB700 -292;Quest3D - CINEACT integration;FreeTrack20;V160;;;20040;0124A15F28340AB3CA9000 -303;R-concept X (AdrenalinStorm);FreeTrack20;V160;;;9101;012F72456F83E6993AA600 -293;R.U.D.O. Tools;FreeTrack20;V160;;;20039;0125612F287FB9BEA76E00 -294;RACE (the WTCC game);FreeTrack20;V160;;;3904;01263C2C1C94FA86146300 -295;RACE 07, RACE, GTR 2;FreeTrack20;V160;V;zild1221, TrickyDee ;3903;0127C0AF9800870056FD00 -296;RaceOn;FreeTrack20;V160;V;zild1221 ;0;0128621E7832AA82388200 -297;Racer;FreeTrack20;V160;;;2401;01296D2D103862E932EA00 -298;Racer S;FreeTrack20;V160;;;20030;012AEA1CBED961CA52CB00 -490;RaceRoom Racing Experience;FreeTrack20;V160;;;3905;01EA9124F663AF03BBC500 -299;Rail Simulator 1;FreeTrack20;V160;;;1550;012BB253778929A0395900 -300;Railway Work Simulator;FreeTrack20;V160;;;20225;012C91D998B1E9933B9100 -301;RailWorks 2;FreeTrack20;V160;;;2750;012D3919C4972D9D299000 -302;Raydon Driving Simulator;FreeTrack20;V160;;;3701;012E5485D941DBE2FB5300 -304;Real Time Visual;FreeTrack20;V160;;;9901;0130B1C664862297365500 -305;RealFlight;FreeTrack20;V160;;;4001;0131AC6E87892E993A8B00 -306;Reality Manager;FreeTrack20;V160;;;20046;0132DB242B65872FA42A00 -307;RealWorld;FreeTrack20;V160;;;20215;0133B59DEFA9322A727800 -308;Red Baron 3D;FreeTrack20;V160;;;1125;0134C6371D96349CEB7A00 -309;Red Orchestra: Heroes of Stalingrad;FreeTrack20;V170;;;12602;013521F9121056CD997300 -310;Red Orchestra: Ostfront;FreeTrack20;V170;;;12601;01369A9A2BE97252BB9000 -311;Redline Monitor;FreeTrack20;V160;;;20210;01373752FBC8831A72AA00 -312;REFLEX XTR;FreeTrack20;V160;;;2150;0138054E94127D14881300 -313;Remote Presence;FreeTrack20;V160;;;20710;01399BC3BDA93229D2BB00 -314;rFactor;FreeTrack20;V160;V;V4Friend;7401;013AEF7A8F4B8AA0495200 -315;rFactor Pro;FreeTrack20;V170;;;7403;013B175198D74BE8E89600 -316;rFactor2;FreeTrack20;V170;;;7402;013CBFF3A86D34DA24C000 -317;Richard Burns Rally;FreeTrack20;V160;V;zild1221;3401;013D42868B339A31A73C10 -318;RidingStar;FreeTrack20;V160;;;1475;013E3919C497359826A700 -319;Rig N Roll;FreeTrack20;V160;;;9801;013FD1C9F284239CE68100 -320;Rio Tinto Resource Development;FreeTrack20;V160;;;20033;01401039831B5EC8D31900 -321;Rise of Flight;FreeTrack20;V160;V;Seborgarsen ;11401;0141AA71218335A51F5100 -322;Rise: The Vieneo Province;FreeTrack20;V160;;;6301;0142DEE3582F9837A82D00 -323;Rising Conflicts;FreeTrack20;V160;;;12101;014384818335A439B12F00 -492;RITS;FreeTrack20;V160;;;20775;01ECEE745B83DD3A0DBE00 -324;Road Legends;FreeTrack20;V160;;;1876;0144379716986369A2E600 -325;Rogue Space;FreeTrack20;V160;;;3050;014588F5872C9C30ABE900 -326;Rogue Warrior;FreeTrack20;V160;;;14202;0146432C2973D9D45A8E00 -327;ROV Sim;FreeTrack20;V160;;;20530;0147FA04BD27891D9ADD00 -328;Rowan's Battle Of Britain;FreeTrack20;V160;;;1502;014821008829A72CB4F300 -329;RSD Demo;FreeTrack20;V160;;;2050;0149BF8C4EAA5871A85D00 -330;RTMS Crane Sim;FreeTrack20;V160;;;20400;014AC93272841D91205200 -331;RTT DeltaGen Plugin;FreeTrack20;V160;;;20195;014B90B5871B8DDD7D3400 -332;Sail Simulator 5;FreeTrack20;V160;;;1975;014CE2D1D78A1D9A3B6300 -333;Sailors of the Sky;FreeTrack20;V160;;;10201;014D17BE02961FAF3AB100 -334;Santa Cruz Watermill;FreeTrack20;V160;;;20290;014E88F5881EA32FA7E900 -335;SCANeR Studio Plugin;FreeTrack20;V160;;;20445;014FA2AE4870F861E9A100 -336;SEGA Demo;FreeTrack20;V160;;;2075;015016BC08C117F1163000 -337;Seven-G;FreeTrack20;V160;;;2350;01510F00F49635B822A200 -338;SFSPC;FreeTrack20;V160;;;2801;0152F885EFA9400981B700 -339;Ship Simulator 2006;FreeTrack20;V160;;;5002;015329DFA9638AA2C66100 -340;Ship Simulator 2008;FreeTrack20;V160;V;djj3ff ;5003;01545213599339B3D52100 -341;Shiphandling Simulator;FreeTrack20;V160;;;20570;01553FD0FC9D8B37AD3700 -342;Shooting Simulator;FreeTrack20;V160;;;20047;0156F2F27A58827A63DA00 -343;SIA Games;FreeTrack20;V160;;;20015;0157926ED970685DA8D200 -344;Silent Wings;FreeTrack20;V160;;;8701;0158D615A9C96309C24A00 -345;SilverHat;FreeTrack20;V160;;;12401;0159D8175F99349F3F9600 -346;Simax Simulator;FreeTrack20;V160;;;20021;015AAC156D9736A331AD00 -347;Simball 4D;FreeTrack20;V160;;;20315;015BD6E585F99349F2AA00 -348;Simbionix;FreeTrack20;V160;;;20485;015CE7A7FAA28528AE1D00 -349;SimCreator;FreeTrack20;V160;;;20520;015D3752FBC8935B001A00 -350;Simlog Personal Simulator;FreeTrack20;V160;;;20635;015E42868C33A435B53100 -351;SimQuest immersion system;FreeTrack20;V160;;;20023;015F6C69678C32A30FAE00 -352;SimSol;FreeTrack20;V160;;;20034;01602315187389E0FB5300 -491;Simumak;FreeTrack20;V160;;;20770;01EB119629980784DCE600 -353;Sirocco Racing;FreeTrack20;V160;;;5801;01612BCA748925A6369A00 -354;Sky God: Military Freefall;FreeTrack20;V170;;;1526;01622C0104385FD1C44400 -355;Soft fx Demo;FreeTrack20;V160;;;2125;01632E20238A2B99335200 -356;Source Engine (Half-Life 2);FreeTrack20;V160;;;12502;0164E482F58829A739A600 -357;Space Shuttle Mission 2007;FreeTrack20;V160;V;purewhitewings ;1225;0165662B03863D912F9700 -358;SRI;FreeTrack20;V160;;;20620;01663FD0FC9D8B218D8100 -359;Stanford University;FreeTrack20;V160;;;20004;0167CE35BAF9933A62AA00 -500;Star Citizen;FreeTrack20;V170;;;3450;0D7AF4CE4E343EC6B4A200 -360;Starshatter;FreeTrack20;V160;;;6401;0168F079578A3F9A3BB600 -361;Steel Beasts 2;FreeTrack20;V160;;;11703;0169DCC441A9443A831A00 -362;Steel Beasts Pro;FreeTrack20;V160;;;11701;016A8F54A20833CAA23900 -363;Steel Beasts Pro Personal;FreeTrack20;V160;;;11702;016BF3E85B1A9443A73000 -364;Stoked Rider;FreeTrack20;V160;;;14701;016CC166C963EA32997300 -365;Storm of War: the Battle of Britain;FreeTrack20;V170;;;11001;016D8F54A68B71F25D0200 -495;STRAFT;FreeTrack20;V160;;;3375;01EF1329E014ADF98D6B00 -366;Stride;FreeTrack20;V170;;;2310;016EC784B21E4B21984400 -367;STS Driving Simulator;FreeTrack20;V160;;;20300;016FA59E688B1C89DE7600 -368;Sunaerosys;FreeTrack20;V160;;;20475;01700449831AF28973EB00 -369;Superkarting;FreeTrack20;V160;;;14903;0171DE661F6D973FA41F00 -370;SuperX Research;FreeTrack20;V160;;;15401;0172BA89D078A45A021A00 -371;SWRI Demo;FreeTrack20;V160;;;20230;01730AC6841E9512561000 -372;Syncon Robot Control;FreeTrack20;V160;;;20415;0174C1BBF9937B12DB5200 -373;Synergy Simulation;FreeTrack20;V160;;;20595;0175926ED9736B220B8200 -374;T and TS Corp.;FreeTrack20;V160;;;20005;017617BE0297DDA73CA600 -375;Take On Helicopters;FreeTrack20;V170;;;7504;0177513CB40C0623B96A00 -376;Target: Korea;FreeTrack20;V160;;;1201;0178F52E4221852FA43300 -377;Target: Rabaul;FreeTrack20;V160;;;1202;0179E9D85E4881CA736900 -378;Targeting Demo;FreeTrack20;V160;;;13002;017AAB1D58A952DAA2F900 -379;TD Demo;FreeTrack20;V160;;;1925;017BC5BEE488FE54139700 -489;TeachLive;FreeTrack20;V160;;;20765;01E905245B5AC5484FC100 -380;Telepresence;FreeTrack20;V160;;;20450;017CF478D278B33B02DA00 -381;Tenstar Simulator;FreeTrack20;V160;;;20605;017D318F88A2EA62DBA200 -382;Test Drive Unlimited;FreeTrack20;V160;;;13201;017E6F2699559730A84000 -501;The Crew;FreeTrack20;V170;;;1009;03F1F534E94F4834D9B100 -488;The Gallery;FreeTrack20;V160;;;3350;01E8CE152EDE5FFD267700 -383;The Sky Gods;FreeTrack20;V170;;;1525;017FDFF782DCCEEA27C200 -384;theHunter;FreeTrack20;V170;;;2375;0180BFF3A86D34DA24C000 -385;thriXXX HII 3D;FreeTrack20;V160;;;13403;0181FA04BD27AB36B62700 -386;thriXXX Jenna;FreeTrack20;V160;;;13401;01829F819CA2A625AB2800 -387;ThriXXX Technology;FreeTrack20;V160;;;13402;0183F47CC378B35B526900 -388;tir2joy;FreeTrack20;V160;;;2202;018487801AB532A7FE9C00 -389;TIRF4;FreeTrack20;V160;;;2203;0185311858418870E77000 -390;TNO;FreeTrack20;V160;;;20285;01861AAF6870A853D64900 -391;ToCA Race Driver 2;FreeTrack20;V160;;;8102;0187FFE9E886F286297910 -392;Toca Race Driver 3;FreeTrack20;V160;;;8101;01884098D36972B551A900 -393;Tom Clancy's H.A.W.X.;FreeTrack20;V170;V;EmBeES ;1004;0189AA4D48E85966FBAA00 -394;Tom Clancy's H.A.W.X. 2;FreeTrack20;V170;;;1007;018A1B7583521C12406F00 -395;Torque Game Engine;FreeTrack20;V160;;;5301;018BC0AF9A2EB62CAB3300 -396;Total War;FreeTrack20;V160;;;1375;018C72456F8529AA2CA400 -397;Tower Crane Simulator;FreeTrack20;V160;;;20670;018D03FB9929B034A7D900 -398;Tower I;FreeTrack20;V160;;;1325;018E662B03873CA731A400 -399;TPL Testing;FreeTrack20;V160;;;20260;018F849F9A2083DC8C2C00 -400;trackd;FreeTrack20;V160;;;20580;019053FE1EB72DA3329D00 -401;TrackMapper2;FreeTrack20;V160;;;2175;0191CE35BAF9A31A61FA00 -402;TrainMaster;FreeTrack20;V160;;;20042;01925C1FDE852D9925B400 -403;Trainz;FreeTrack20;V160;;;4701;0193D1C9F2862C9630A100 -404;TraumTek;FreeTrack20;V160;;;20650;0194A2AE4883EA645A2100 -405;Turismo Carretera;FreeTrack20;V160;;;15801;01956F2699559740A73500 -406;UK Rally Champion;FreeTrack20;V160;;;5701;019679EC0E28B196522A00 -407;ULAN;FreeTrack20;V160;;;20645;01974ADE68E16780D97A00 -473;Underwater Navigation;FreeTrack20;V160;;;20715;01D9FE2B94FB03772DE200 -408;Unity 3D Plugin;FreeTrack20;V160;;;20430;0198D24C3F9B3B9C31BF00 -409;Untitled 10tacle;FreeTrack20;V160;;;13701;0199FFE9E886F28728AA00 -410;Untitled 3D People;FreeTrack20;V160;;;15501;019A6925968D38AD23A900 -411;Untitled Apportmedia;FreeTrack20;V160;;;6801;019B3C2C1C9728B738B700 -412;Untitled Combat Flight Sim;FreeTrack20;V160;;;13801;019CA59E688D36AA28A600 -413;Untitled Deep Silver;FreeTrack20;V160;;;14601;019D656DD68838B836AD00 -414;Untitled G5 Software;FreeTrack20;V160;;;7301;019E318F88B37AC23BA300 -415;Untitled Microsoft;FreeTrack20;V160;;;2308;019FA15F28739BA32A9300 -416;Untitled Research;FreeTrack20;V160;;;1075;01A07686E5A8B2DA924A00 -417;Untitled Ron E;FreeTrack20;V160;;;14902;01A14ADE68E38AB28B9300 -418;Untitled Sega of America;FreeTrack20;V160;;;12801;01A27A32A1A972DA528A00 -419;Untitled Simbin;FreeTrack20;V160;;;3902;01A36C69678E37AA27AD00 -420;Untitled WorkShield;FreeTrack20;V160;;;4601;01A442868E38AB32BA3600 -421;Untitled ZootFly;FreeTrack20;V160;;;12701;01A5348B1863AA527A6300 -422;UQO;FreeTrack20;V160;;;23085;01A67C822099A187FE3600 -423;UVEG Machinery Simulator;FreeTrack20;V160;;;20024;01A73118585257A0F63100 -424;VAR;FreeTrack20;V160;;;20460;01A8950F9A97FA96FD2E00 -505;VBS2;FreeTrack20;V160;;;7501;01F98EF4FB1278538A7600 -509;VBS2 2.0;FreeTrack20;V170;;;7505;1D51EB3616B3A44F05B900 -426;Vehicle Simulator (Quality Simulations);FreeTrack20;V160;;;5102;01AA0FC9FF9B1FA134A900 -478;Vehicle Simulator Direction;FreeTrack20;V160;;;20735;01DEB88CF58E570F1CEF00 -427;Vestibular Ocular Reflex;FreeTrack20;V160;;;20008;01AB3919C49B31A731A200 -428;Viper Arena;FreeTrack20;V160;;;3501;01AC6F2699559934A53100 -429;VIRTools Engine;FreeTrack20;V160;;;10801;01AD1AAF68905881EB5300 -430;Virtools Plugin;FreeTrack20;V160;;;20200;01AE03FB9B23AB43A42900 -431;Virtual Driving;FreeTrack20;V160;;;20245;01AF99BB5C9927B83FB700 -432;Virtual Heroes;FreeTrack20;V160;;;20375;01B0621E78732B732AE200 -433;Virtual RC Racing;FreeTrack20;V160;;;8201;01B16D2D1038A36A23DA00 -434;Virtual Sailor;FreeTrack20;V160;;;5201;01B25F3D95778C32B33D00 -435;Virtual Shopper;FreeTrack20;V160;;;20610;01B3B78B06EC9927B73E00 -436;Virtual Supermarket;FreeTrack20;V160;;;20280;01B4849F9C39A931AD2800 -496;VirtualiTeach;FreeTrack20;V160;;;20790;01F062AE1CAB33B52D0700 -480;Vizard;FreeTrack20;V160;;;20745;01E0C1F20A79D7C0561300 -437;VizRD;FreeTrack20;V160;;;20031;01B55485D9825BF1D8AB00 -438;Void War;FreeTrack20;V160;;;10001;01B65C1FDE872AA1206600 -477;VRPlayer;FreeTrack20;V160;;;20730;01DD6787E57245201D5000 -439;VT08;FreeTrack20;V160;;;1275;01B7B78B06EC9912750200 -440;VVVV Plugin;FreeTrack20;V160;;;20075;01B8B1C6648A138C205500 -441;VW Testing;FreeTrack20;V160;;;20275;01B9AC6E878D205822AA00 -442;Walkabout3d;FreeTrack20;V160;;;20125;01BA2822901E9E39932F00 -443;Wallbusters;FreeTrack20;V160;;;1450;01BB88F58C1EA127A83F00 -444;War Thunder;FreeTrack20;V160;;;0;01BC17BE029A1FB8ED9600 -445;WAVES;FreeTrack20;V160;;;20515;01BD05B38FFE89008B8B00 -446;Welding Simulator;FreeTrack20;V160;;;2625;01BE348B188319D229B300 -447;West Racing;FreeTrack20;V160;;;1801;01BF91D999022A33B62000 -448;Whirlwind of Vietnam;FreeTrack20;V160;;;11101;01C0054E9935A03AAF3200 -449;Wikid FJ;FreeTrack20;V160;;;20685;01C19BC3BDA98269B25A00 -450;Wings of Prey;FreeTrack20;V160;V;V4Friend;1877;01C25909438736A133AC00 -451;Wings of War;FreeTrack20;V160;;;7807;01C34B0FC38B36B42FB610 -452;World Racing 2;FreeTrack20;V160;;;7201;01C41AAF68A2BA836AAE00 -453;WWII Battle Tanks: T-34 vs. Tiger;FreeTrack20;V160;;;11102;01C5432C29C257F1963100 -454;X Motor Racing;FreeTrack20;V160;;;1150;01C669259690E98629A900 -458;X-Cockpit for X-Plane;FreeTrack20;V160;;;2901;01CA1C76F8BF4852999300 -459;X-Plane (32 and 64 bit);FreeTrack20;V160;V;EmBeES ;7701;01CB3FD0FC9D90FB943300 -460;X-Plane 6DOF Plugin;FreeTrack20;V160;;;10101;01CCA15F28AF7963596300 -461;X-Plane Pilot View (32 and 64 bit);FreeTrack20;V160;V;V4Friend;11301;01CD79EC0E28EFA953CA00 -462;X-Tower for X-Plane;FreeTrack20;V160;;;3001;01CE05B390EA872AAF3200 -455;X1Alpha;FreeTrack20;V160;;;1825;01C76D2D1038CFD7135A00 -456;X2: The Threat;FreeTrack20;V160;;;5501;01C81039EF980EC8D30900 -457;X3: Albion Prelude and Reunion;FreeTrack20;V170;V;V4Friend;5502;01C97E101A708F8524E300 -463;Xyphoid;FreeTrack20;V160;;;14301;01CF656DD68B43B435A800 -464;zedasoft F-35 Demo;FreeTrack20;V160;;;20041;01D02100B01F942CB93C00 -493;ZKT;FreeTrack20;V160;;;20780;01ED2BAA723F3C097EE800 -465;Zombie AA Research;FreeTrack20;V160;;;14201;01D1AA71218B3B9F1C9A00 +174;18 Wheels of Steel: Haulin';FreeTrack20;V160;;;13601;00AE9E109B72BA8DAA1B00 +215;1944 D-Day;FreeTrack20;V160;;;15701;00D73F301108DFC27A7B00 +484;2KMarinNEXT;FreeTrack20;V170;;;3425;0D614F6A0820D1EA8EE800 +392;3D Instructor;FreeTrack20;V160;;;20490;0188250AEFA5B5EA15CB00 +374;3D Interactive;FreeTrack20;V160;;;20425;01768FC3899CF17E7BB300 +492;3D Interieur Visualisation;FreeTrack20;V160;;;20815;01EC9C5D248D93000FEC00 +306;3d Nav;FreeTrack20;V160;;;20235;01323D827F93B498210600 +156;3D-Fahrschule Driving Simulator;FreeTrack20;V160;;;20020;009C90AA65E5BDC1D12A00 +96;3ds Max;FreeTrack20;V160;;;8601;0060A18FECCA3FBFCEDE00 +302;Aaaaa!;FreeTrack20;V160;;;1775;012EBCB2EA96CCD532C000 +46;Accessible Computer Games;FreeTrack20;V160;;;4301;002ECD9251931942DAEB00 +15;Aces High II;FreeTrack20;V160;;;2701;000F3BAF2B82B2E1BACE00 +452;ADS;FreeTrack20;V160;;;20690;01C4C5E387A650CCF60B00 +336;Aerofly;FreeTrack20;V160;;;2025;0150B48DFC3D8EE4210700 +367;Affineon;FreeTrack20;V160;;;20405;016FA2224086841F7DC000 +210;Air Battles: Sky Defender;FreeTrack20;V160;;;7003;00D2A133006D158A0EA800 +284;Air Phobia;FreeTrack20;V160;;;20100;011C608E586982AB1E2C00 +41;Air Traffic Control Tower;FreeTrack20;V160;;;3601;00292A472BF8D9480ED100 +199;AirBook;FreeTrack20;V160;;;15201;00C76A9645BD591075D900 +44;America's Army;FreeTrack20;V160;;;4101;002C360B433EED950F9A00 +301;America's Army 3;FreeTrack20;V170;;;14203;377B3F3206BCEA252BB700 +308;ANAG 3D;FreeTrack20;V160;;;20250;013430823DC1F5E486D100 +322;Apache: Air Assault;FreeTrack20;V160;;;1875;0142A443A20298AFE19700 +133;Aprisoft Gartenplaner;FreeTrack20;V160;;;20014;00855226E8EBAD633BB900 +132;Aprisoft Traumhaus Designer;FreeTrack20;V160;;;20013;0084E25199C61FA7879900 +485;ARI;FreeTrack20;V160;;;20795;01E533F9AAFE57D5430600 +124;ArmA;FreeTrack20;V160;;;10601;007C38EA44ADDAA358D900 +273;ArmA 2;FreeTrack20;V170;;;7502;1D4EEB3616B3A44F05B900 +426;Arma 3;FreeTrack20;V170;;;7503;1D4FB69411ABD4E2B39900 +276;Armored Assault - Gold Edition;FreeTrack20;V170;;;1303;0517A7F7CAA00814ECA700 +423;Arvoch Alliance;FreeTrack20;V160;;;14908;01A7F311F312BFC5057900 +191;Arvoch Conflict;FreeTrack20;V160;;;14901;00BF8E0AA63919A632EB00 +226;Auditory Displays for the blind;FreeTrack20;V160;;;20035;00E233D303ECAA687F6C00 +473;Autodesk;FreeTrack20;V160;;;20755;01D9861B5E74923B501800 +150;AV Core Technology;FreeTrack20;V160;;;20016;009618521D67AAC73AB000 +341;AVRS;FreeTrack20;V160;;;20340;0155286F525153D27DFE00 +469;B.O.M.B.;FreeTrack20;V160;;;3325;01D572C028D57E89BC0200 +154;BAE Systems HILAS cockpit;FreeTrack20;V160;;;20019;009A79731D5E78C1A7A500 +278;Battle of Britain (iENT);FreeTrack20;V170;;;1305;05190BA119195B701AED00 +68;Battle of Britain II - Wings of Victory;FreeTrack20;V160;;;7001;0044F8561890C5731B4A00 +60;Battlecruiser;FreeTrack20;V160;;;6101;003CBB561A0923152A5100 +107;Battlefield 2;FreeTrack20;V170;;;9601;2581B1560A2A7327659200 +64;Battlefield 2 Trauma Studios;FreeTrack20;V160;;;6501;004006A4B42823F88E3400 +271;Battlefield 2142;FreeTrack20;V170;;;9602;25821C739AD3817FD43300 +18;Battleground Europe : World War II Online;FreeTrack20;V160;;;3301;001242F35C2472CB3ACD00 +131;Battleground Europe : WWII Online;FreeTrack20;V160;;;11201;00834A3092D9427631DE00 +126;Beckman Institute UIUC;FreeTrack20;V160;;;20012;007EFB3EEF546B024DFD00 +169;Beyond The Red Line;FreeTrack20;V160;;;13301;00A94CBE5A4F44EB519800 +167;BF2 (Unsupported Demo);FreeTrack20;V160;;;9651;00A7278E32A322457EDD00 +84;Big Scale Racing;FreeTrack20;V160;;;8301;0054C1D0A1C87957F0FE00 +30;Birds of Prey;FreeTrack20;V160;;;1601;001EE77821649406245700 +263;Black Shark;FreeTrack20;V170;;;1003;03EBB6DCD15F5A572F6500 +432;Boeing;FreeTrack20;V160;;;20351;01B00D0EFE298BFC60E800 +343;Boeing Demo;FreeTrack20;V160;;;20350;01578C15DC16F5E33C7D00 +319;Bomber Squadron;FreeTrack20;V160;;;1850;013F72BF1D9C6B401DF700 +260;Brain-IT Group;FreeTrack20;V160;;;20050;0104E1F4D6FD674A4E2500 +173;Brothers In Arms;FreeTrack20;V160;;;13501;00ADC07FF4B1A6E948B600 +347;Bus Simulator;FreeTrack20;V160;;;2225;015BC403649A5E94E6E500 +51;C-Spine;FreeTrack20;V160;;;4901;003395D3663BFBDB6E9A00 +422;C.A.R.S.;FreeTrack20;V170;;;2825;0B0998EFE2EB6EE8E11300 +397;C.U.B.;FreeTrack20;V160;;;20505;018DD932954533C2E0F400 +287;CameraGripTools;FreeTrack20;V160;;;20150;011F7251EA4A4FAD775A00 +355;Caterpillar Simulators;FreeTrack20;V160;;;23080;016329AAA37A9155096E00 +114;CCG Metamedia;FreeTrack20;V160;;;20009;0072377014025EB6EA6C00 +353;CEWIT Immersive Cabin;FreeTrack20;V160;;;20370;0161EFC951AECEF8DAFE00 +447;Chopper;FreeTrack20;V160;;;3150;01BFD5440436C35DE79500 +412;Clearbox;FreeTrack20;V160;;;20565;019CF54508C25F035DF500 +394;CNKFsoft;FreeTrack20;V160;;;20495;018A43B91FFF38CB80DF00 +474;Cognitics;FreeTrack20;V160;;;20760;01DA28209057E9FA6E3500 +111;Colin McRae Rally 04;FreeTrack20;V160;;;8103;006FF602A2B72A614B6E00 +356;Comanche;FreeTrack20;V160;;;2275;01646664AEA1A895F0A000 +14;Combat Flight Simulator 3;FreeTrack20;V160;;;2304;000E8158E318F88163F500 +34;Combat Helo;FreeTrack20;V160;;;2001;002299B710843501AFD700 +98;Commandos Strike Force;FreeTrack20;V160;;;8801;0062114D555A837B30CC00 +125;Concept RS;FreeTrack20;V160;;;10701;007DA1423E0ED64CF47500 +59;Condor: The Competitive Soaring Simulator;FreeTrack20;V160;;;5901;003BE833A39AE3D29DEA00 +331;Conflict Taiwan;FreeTrack20;V160;;;1950;014BA899879AE5481B2B00 +409;Corys;FreeTrack20;V160;;;20550;0199116C7DE46E17A64400 +151;Counter Strike;FreeTrack20;V160;;;12501;0097DF722038FD4EA14D00 +254;Crane Simulator;FreeTrack20;V160;;;20048;00FEE4AAE7A954FA604E00 +56;Crashday;FreeTrack20;V160;;;5601;0038C174E71FFD977CCC00 +297;Creanex Training Simulator;FreeTrack20;V160;;;20205;01292F5C1B72857ADDA400 +153;Creative Labs headset;FreeTrack20;V160;;;20018;009957727B42043CBA9E00 +50;Cross Racing Championship;FreeTrack20;V160;;;4801;0032F7DE5B26B334981B00 +283;Crysis Mod;FreeTrack20;V160;;;1625;011B1BC6B04FFEF5AD1400 +209;Crystal Growth Simulation;FreeTrack20;V160;;;20029;00D13F3A4838913A44B400 +424;Crytek;FreeTrack20;V170;;;2775;0AD7D5F1EBBAD81C714600 +218;D2x-XL;FreeTrack20;V160;;;16001;00DA79A678C0682E30A200 +77;Dark Horizons Lore;FreeTrack20;V160;;;7901;004D45698776A20C324200 +277;Dawn of Aces - Gold Edition;FreeTrack20;V170;;;1304;0518A9ED7700814190DE00 +78;Dawn of Aces II;FreeTrack20;V160;;;1302;004E03B6D3AC5C15BA1900 +372;DBS WalkAndFollow;FreeTrack20;V160;;;2525;0174177CDE734882A0B000 +373;DCS: A-10C;FreeTrack20;V170;;;1006;03EEF688FC9B0556868F00 +121;Dead Reckoning;FreeTrack20;V160;;;10401;0079E323618912A95D5200 +217;Delivery;FreeTrack20;V160;;;15901;00D9802203B1DCC5AA3700 +458;Demon Core;FreeTrack20;V160;;;3225;01CA1F069F2057F4D8CA00 +214;DiRT;FreeTrack20;V160;;;8104;00D6A15BCEFEF6B4ABFE00 +339;DiRT 2;FreeTrack20;V170;;;8107;1FAB7815C5379491C73300 +401;DiRT 3;FreeTrack20;V170;;;8108;1FACABA016ED2DFBDF6F00 +445;Door3;FreeTrack20;V160;;;20665;01BDA4ECFD45C5FE5EBD00 +228;Down In Flames;FreeTrack20;V160;;;1025;00E4BF608EBF49484EEB00 +312;Driver Test;FreeTrack20;V160;;;20265;013849AE3B289D1DC1A200 +182;Driver's Republic;FreeTrack20;V160;;;14001;00B6150AA00D9AD19E9B00 +52;DriveSim;FreeTrack20;V160;;;5001;00343807CA4E9EA3103800 +164;Driving Simulator;FreeTrack20;V160;;;13001;00A4B63D9ADBCB2AC2CE00 +366;dSphere TBA;FreeTrack20;V160;;;2425;016E5D8D2C83442CED7000 +434;DTS;FreeTrack20;V160;;;20625;01B2CF28A299FE354DC100 +282;Dungeons and Dragons Online;FreeTrack20;V170;;;1575;0627BD4D4DDC6BB6818800 +342;DY Demo;FreeTrack20;V160;;;20345;0156D9F373562BF31DE700 +325;EADS Testing;FreeTrack20;V160;;;20303;0145D15AC1FE3D41403900 +491;EAFIT;FreeTrack20;V160;;;20810;01EB99C66DF0A1F91DC100 +143;Eagle Lander 3D;FreeTrack20;V160;;;11901;008F53F747F03F272D4300 +303;EasyVR;FreeTrack20;V160;;;20220;012F8604205595E8B41B00 +417;ECA-Sindel;FreeTrack20;V160;;;20590;01A1B9A2A3B8244B13E000 +495;Elite: Dangerous;FreeTrack20;V170;;;3475;0D93A9485EECA12E18BE00 +468;Embers of Caerus;FreeTrack20;V170;;;3275;0CCB4134258D7E10119E00 +360;EMS Simulations;FreeTrack20;V160;;;20390;0168F93B8F6B68F7D55B00 +221;Enemy Engaged 2;FreeTrack20;V160;;;2102;00DDEFCE2BF04CB9E42B00 +10;Enemy Engaged: Commanche vs Hokum;FreeTrack20;V160;;;2101;000A5A1B0A415F3F531300 +329;Envision TE;FreeTrack20;V160;;;20320;0149BD94BDE99C25D2B300 +369;EON Reality;FreeTrack20;V160;;;20410;017121A16682A941225300 +455;eSigma;FreeTrack20;V160;;;20700;01C78A514A66DC74D00700 +266;Euro Truck Simulator;FreeTrack20;V160;;;13602;010AA042E7114092378600 +142;EVE Online;FreeTrack20;V160;;;11801;008E9A8A9BEFF713DBBE00 +147;Eventology;FreeTrack20;V160;;;12201;009341C3C7271FE1474000 +234;EVOC-101 Training;FreeTrack20;V160;;;20038;00EA0EEDE621545A0D7400 +196;Evochron Alliance 2.0;FreeTrack20;V160;;;14904;00C430A7928686E1E29900 +294;Evochron Legends;FreeTrack20;V160;;;14906;0126357B0DB28B9A7F7F00 +352;Evochron Mercenary;FreeTrack20;V160;;;14907;01608A58CD8C53BBC30100 +227;Evochron Renegades;FreeTrack20;V160;;;14905;00E3000A941E27BA776000 +368;EZCA;FreeTrack20;V160;;;2475;01709579943E9C0D409E00 +300;F-22 Total Air War;FreeTrack20;V160;;;1750;012CA6CCB21E416A793200 +292;F-35 PTA;FreeTrack20;V160;;;20185;01249D0534901AB137A100 +430;F-Trainer;FreeTrack20;V160;;;20615;01AEB888F96E2752298A00 +429;F1 2011;FreeTrack20;V170;;;8109;1FAD265ECD74893EA12900 +22;F1 Challenge 99-02;FreeTrack20;V160;;;4401;00166D27E99118BEEB3300 +396;FAAC;FreeTrack20;V160;;;20500;018C409784864ED81AA100 +9;Falcon 4.0;FreeTrack20;V160;;;1901;000987F8372EE07CA5D000 +99;Falcon 4.0: Allied Force;FreeTrack20;V160;;;8901;0063BCFAB33A4E42FAB300 +33;Falcon 5;FreeTrack20;V160;;;1902;0021977E9CB8EA480D3E00 +295;Farmer Simulator 2009;FreeTrack20;V160;;;1725;0127EAF6C473A66CB4E000 +80;Faros Driving Simulator;FreeTrack20;V160;;;8001;0050BDAA81724BA7917800 +389;Faubert Lab Car Simulator;FreeTrack20;V160;;;20480;0185CB21F2737C4E770E00 +275;FIFA 09;FreeTrack20;V170;;;9002;232A288979C65B0DAA0D00 +94;Fighter Ace;FreeTrack20;V160;;;8401;005EA62AAEB615EE563700 +103;Fighter Ops;FreeTrack20;V160;;;9301;006764CDD851A5FEC18800 +289;Fighter Squadron: Screamin Demons Over Europe;FreeTrack20;V160;;;1675;0121A140A985B64D78EB00 +3;First Eagles, Wings Over Europe, Strike Fighters;FreeTrack20;V160;;;1101;0003FD293BA8A5FCD86500 +163;Flight Gear;FreeTrack20;V160;;;12901;00A31314C59685279E5700 +12;Flight Simulator 2002;FreeTrack20;V160;;;2302;000CFA9D94946AE64BEC00 +13;Flight Simulator 2004;FreeTrack20;V160;;;2303;000D0809BE30FFFC2D2500 +148;Flight Simulator X;FreeTrack20;V160;;;2305;00949527D98EFCF1737F00 +6;Flyboys / Warbirds;FreeTrack20;V160;;;1301;0006B9283164764D951600 +285;Flyer;FreeTrack20;V160;;;1650;011D08CC76BA68B508C800 +202;Flying Tigers;FreeTrack20;V160;;;7002;00CA49A35875264C8AB000 +190;FlyingGuns;FreeTrack20;V160;;;14801;00BEF15778A88E30303100 +67;Ford Racing 3;FreeTrack20;V160;;;6901;004315F6B77EF2371A8900 +257;FreeSpace2;FreeTrack20;V160;;;13302;0101FBF945BBAE0EC0DF00 +313;FTAlpha;FreeTrack20;V160;;;20270;01394E3EC4AD48AA039700 +31;Full Out;FreeTrack20;V160;;;1701;001F249A7499D0A073B700 +165;Future Pinball;FreeTrack20;V160;;;13101;00A5C8B5A9A0E252AA1700 +332;Game VR;FreeTrack20;V160;;;20325;014C20C9A4646102632500 +410;GameLab;FreeTrack20;V160;;;20555;019A2980AAAE6BCE99FC00 +459;Games Farm;FreeTrack20;V160;;;3250;01CBAFBB4FA4A86606BA00 +229;Gamma;FreeTrack20;V160;;;1050;00E5E42ACF41379E700100 +490;Garry's Mod;FreeTrack20;V160;;;12503;01EAEABA1116EB8268CA00 +470;Generic Robotics;FreeTrack20;V160;;;20750;01D6B38BD6799D6BA1BC00 +462;Glider Sim;FreeTrack20;V160;;;20720;01CEE3EDD3D1668F849900 +335;Global Ground Support Deicing Simulation;FreeTrack20;V160;;;20330;014F77EC9DBBA2206C5200 +344;GosNIIAS Sim Trainer;FreeTrack20;V160;;;20355;01581273D0726665DBD500 +185;Gothic 3;FreeTrack20;V160;;;14401;00B9ADA579F7F083EFB800 +27;Grand Prix Legends;FreeTrack20;V160;;;6701;001B6A116A3C368FB86100 +116;Grand Theft Auto: San Andreas;FreeTrack20;V160;;;7808;0074E38D2FB36A4C409400 +265;GRID;FreeTrack20;V160;;;8105;0109211A446AAE7BB7A800 +248;GSE Power Plant Simulation;FreeTrack20;V160;;;20044;00F8E3FA8535BFFBDF2B00 +83;GT Legends;FreeTrack20;V160;;;3902;00536F35170D830A860800 +20;GTR;FreeTrack20;V160;;;3901;0014701F9C50D0D50DEF00 +391;Gun Commander;FreeTrack20;V160;;;2675;0187DD273241B932F30600 +43;Halo;FreeTrack20;V160;;;3801;002BD90B92B3D4D4B3A300 +489;hapTEL;FreeTrack20;V160;;;20805;01E9EDDCA498D073C15900 +456;Hardware Control Simulator, Railway Electronics;FreeTrack20;V160;;;20705;01C8B1A10FBE8974FE1A00 +237;Harrier Attack II;FreeTrack20;V160;;;1175;00ED1E3A76F0924DCE0900 +486;Harry's Hard Choices Interactive;FreeTrack20;V160;;;20800;01E67C35CC39DA9BD80F00 +87;Herissons (Paris France);FreeTrack20;V160;;;20001;0057AB857C2A8AFD8C1C00 +95;HL2 (Unsupported Demo);FreeTrack20;V160;;;7806;005F1FC32D74D01FDEA200 +337;HOBI;FreeTrack20;V160;;;20335;0151836DA0709D2BDB9E00 +200;HoverAssault;FreeTrack20;V160;;;5303;00C855D876AEAB8A7E6300 +420;HPC;FreeTrack20;V160;;;20600;01A44FEEAEF74957B2FA00 +309;HPG Tracking;FreeTrack20;V160;;;20255;0135879A4DC38934590F00 +435;HTW;FreeTrack20;V160;;;20630;01B38FB202777B2045EE00 +444;Huawei Software;FreeTrack20;V160;;;20660;01BCC3A77483ECD51A5800 +398;HueSpace;FreeTrack20;V160;;;20510;018E1F9EA3BD09C1799400 +197;Hyper Vision;FreeTrack20;V160;;;15101;00C5B1A1FC35FE0E556200 +243;iamfootball;FreeTrack20;V160;;;1250;00F3ACA7A917365CD94600 +425;id Research;FreeTrack20;V170;;;2950;0B86E723B873D7FC87D700 +233;IESA;FreeTrack20;V160;;;20037;00E9BC95612083AE32CA00 +1;IL-2 Forgotten Battles, ACE, Pacific Fighters;FreeTrack20;V160;;;1001;0001EA2DFC82DBE9745800 +471;IL-2 Sturmovik: Battle of Stalingrad;FreeTrack20;V170;;;1008;03F04D5368D1FD2DF2AE00 +246;Illumina;FreeTrack20;V160;;;1350;00F6D6B0442BAC92E26900 +326;ILP;FreeTrack20;V160;;;20310;0146936EC3C613E83EF500 +222;Imagine 3D ATC Tower Simulation;FreeTrack20;V160;;;20032;00DE8EDDB7DB62781E2300 +92;In Touch Technologies Inc.;FreeTrack20;V160;;;20006;005C88CE1D058424D88C00 +349;Inglobe;FreeTrack20;V160;;;20360;015D5442514EA727526D00 +231;Innovatec Simulator;FreeTrack20;V160;;;20036;00E7920AF051A330FAA600 +104;Insurgency;FreeTrack20;V160;;;9401;00682CB681F925AB0F6A00 +443;Intific;FreeTrack20;V160;;;20655;01BB9399EA57966BC11300 +184;iRacing;FreeTrack20;V160;;;14101;00B82AAAD44114A5EABB00 +204;IREQ Robotic Camera Control;FreeTrack20;V160;;;20027;00CC44BC073883A1ABB500 +449;ISIC;FreeTrack20;V160;;;20680;01C177201D3A03E4006700 +493;ITCL;FreeTrack20;V160;;;20820;01EDB3182E177EB5026E00 +405;IVD Online;FreeTrack20;V160;;;20535;0195B89FBE2236B3A78000 +88;J.J. Keller and Associates;FreeTrack20;V160;;;20002;005823D7C0F457D4FDF100 +100;Janes F18;FreeTrack20;V160;;;9001;0064165383689BB1055C00 +385;Javal Ent.;FreeTrack20;V160;;;2650;018115942BDF061BE46F00 +387;JC Demo;FreeTrack20;V160;;;20470;018346AFBD4E940FAF8A00 +47;Jet Thunder;FreeTrack20;V160;;;4501;002F81A9CFA072CBE26A00 +36;Jetfighter V;FreeTrack20;V160;;;2501;00244953A2760E826FE100 +411;JFIST;FreeTrack20;V160;;;20560;019B919FDE52C94F722D00 +288;John Deere Vehicle Simulator;FreeTrack20;V160;;;20175;0120CB0E12F3AB55D65300 +25;Jump to Lightspeed;FreeTrack20;V160;;;6001;00196DCDEC96B9C882A500 +192;Jumpgate;FreeTrack20;V160;;;15001;00C04B2449A3F257514E00 +236;Jumpgate Evolution;FreeTrack20;V170;;;15002;3A9A5936D4F93DCE0CE700 +17;KAF Keymapper;FreeTrack20;V160;;;3101;0011E2686B5B23E3B4A800 +463;KAI FLight Simulator;FreeTrack20;V160;;;20725;01CF834F29EBC5A9BFEF00 +144;Key Macro View;FreeTrack20;V160;;;12001;0090F19445683A2168D600 +361;kiwi.vg;FreeTrack20;V160;;;20395;0169B11715289D90E44400 +386;L-3;FreeTrack20;V160;;;20465;018294453C0E0EE16BB100 +264;L-3 Communications;FreeTrack20;V160;;;20051;0108BB71885A4FDA205500 +205;Lionhead MGS Game Research;FreeTrack20;V160;;;15301;00CD43E1E3CCF9BF748F00 +29;Live For Speed;FreeTrack20;V160;;;7101;001D4FC6F4EF3D7E48CF00 +136;Live for Speed S2;FreeTrack20;V160;;;11601;00880D0A41B67A39D28200 +2;Lock-On: Modern Air Combat;FreeTrack20;V160;;;1002;000272D8819F59779B7300 +201;Lockheed Martin Littoral Combat Ship simulator;FreeTrack20;V160;;;20025;00C94C0774EF6B95FC6400 +365;LockOn: Flaming Cliffs 2;FreeTrack20;V170;;;1005;03EDAFB0D279F3A6F72200 +437;London NHS;FreeTrack20;V160;;;20640;01B52A23B6D34D1A1A9F00 +85;Lore (Dark Horizons);FreeTrack20;V160;;;5302;00554096EC8C9878CF9200 +442;Love;FreeTrack20;V160;;;3125;01BA33A33A01A24EC1AB00 +122;Lucid Engine;FreeTrack20;V160;;;10501;007A23340BAB30B9BA1000 +403;M4 Tank Platoon;FreeTrack20;V160;;;1306;0193E33321E9D97274DC00 +379;Mach 1;FreeTrack20;V160;;;2575;017B82264F9497542A2300 +383;ManuVAR;FreeTrack20;V160;;;20455;017FBAE17BB4B1DF9F2400 +203;MaqSIM4;FreeTrack20;V160;;;20026;00CBE1C9442D7E89E78D00 +106;Mech Tactical Sim;FreeTrack20;V160;;;9501;006A32E41D501B43C00F00 +433;Mechwarrior Online;FreeTrack20;V170;;;3025;0BD114954226DB5D8CE200 +318;Medical Image Visualization;FreeTrack20;V160;;;20295;013E06ECEC255F8C3E0800 +249;Meggitt Defense Systems;FreeTrack20;V160;;;20045;00F9DC29D19895487B6C00 +408;MetaVR;FreeTrack20;V160;;;20545;0198614A5C85BC5B21A500 +256;Meteoroid Maze;FreeTrack20;V160;;;13003;0100DA85690FEE4CE8AA00 +348;MeVEA;FreeTrack20;V160;;;2250;015C7C61B1A0B391A82400 +23;Micro Flight;FreeTrack20;V160;;;5101;00173516714FAA1424FD00 +267;Microsoft ESP;FreeTrack20;V160;;;2306;010B6138B193D84B877E00 +281;Microsoft Flight;FreeTrack20;V170;;;2307;0903AFBC54959539C51500 +76;Microsoft Train Simulator;FreeTrack20;V160;;;7805;004CB25F5A748DC56FA600 +481;MiddleVR;FreeTrack20;V160;;;20785;01E15AD9A1BF5788732200 +7;Mig Alley;FreeTrack20;V160;;;1501;00071B1D7811FB865C1800 +416;Mimik Vehicle Simulator;FreeTrack20;V160;;;20585;01A08B8035EED58A8EA300 +378;Miner Wars;FreeTrack20;V160;;;2550;017A23F029863696D3B700 +11;MKMapper Keymapper;FreeTrack20;V160;;;2201;000B3FDEA7219E1B3FE600 +406;ModelSim;FreeTrack20;V160;;;20540;0196544AEBCCB6CDE97700 +118;Morgan State University;FreeTrack20;V160;;;20010;0076E2DD472701CE1FFC00 +135;Motor Company;FreeTrack20;V160;;;11501;0087B44851F711B3E09E00 +45;Motorsport Simulators;FreeTrack20;V160;;;4201;002D0AC61E75F696E43800 +93;Mouse Emulation;FreeTrack20;V160;;;8501;005D125D0C1438B4BD5B00 +65;MS World Tour Kart 2004;FreeTrack20;V160;;;6601;004112C27CFA6F45654500 +158;MSN Virtual Earth;FreeTrack20;V160;;;2309;009E1C037925FD2D541000 +371;mTBI Balance;FreeTrack20;V160;;;20420;01730A097BCAE8DB1D2700 +152;NASA Crew Exploration Vehicle;FreeTrack20;V160;;;20017;0098B9C576512B35B86D00 +37;NASCAR Heat;FreeTrack20;V160;;;2602;00252743D8E81EA5E28300 +75;NASCAR Racing 2003 season;FreeTrack20;V160;;;7804;004B4F68639EA37962BC00 +61;NASCAR SimRacing;FreeTrack20;V160;;;6201;003DD8E1AE9104A69CA200 +213;NecroVisioN;FreeTrack20;V160;;;15601;00D5DEFD8DBD3A898E0400 +127;NetKar Pro;FreeTrack20;V160;;;10901;007F2E80EFBB53C23AE800 +179;Nitro Stunt Racing;FreeTrack20;V160;;;13901;00B31F2576B9676095E200 +89;North Eastern University;FreeTrack20;V160;;;20003;0059549BAAC3509E30D300 +395;Novint;FreeTrack20;V160;;;2725;018B1ACFB3A9DB1F463500 +453;NVH Sound Simulator;FreeTrack20;V160;;;20695;01C52B0F776EB03D40B400 +466;OHJCH;FreeTrack20;V160;;;20740;01D2D53549A4AD258C0700 +259;Onadime - Realtime Animation;FreeTrack20;V160;;;20049;01034B3E9CB4A2BC59A800 +54;Operation Air Assault 2;FreeTrack20;V160;;;5401;003615F0D18EAB10D74700 +73;Operation Flashpoint 2 (inactive);FreeTrack20;V160;;;7601;00490AE7C30678C2BE9300 +272;Operation Flashpoint(r): Dragon Rising(tm);FreeTrack20;V170;;;8106;1FAA3328780E1322676100 +123;OptiMetrics;FreeTrack20;V160;;;20011;007B5456C192EF581A4400 +454;OpusFSX;FreeTrack20;V160;;;3175;01C63EDF50047080DF1C00 +120;Orbiter 2005 Plug-In;FreeTrack20;V160;;;10301;00785F82A85EE37660FC00 +181;Orbiter 2006;FreeTrack20;V160;;;10303;00B5E252B1CA8D5677EF00 +180;Orbiter 2006 Plug-In;FreeTrack20;V160;;;10302;00B445B539602FE137AB00 +207;Oryx Vehicle Simulators;FreeTrack20;V160;;;20028;00CFCE423F4B9979E9BA00 +327;Outer Conflict: Frontiers;FreeTrack20;V160;;;1900;014788F872AB60417F3300 +261;Over Flanders Fields;FreeTrack20;V160;;;2325;010529557D6FA134EDBC00 +402;PanoPro;FreeTrack20;V160;;;20525;0192BD283C4A31B45B4500 +186;Paraworld;FreeTrack20;V160;;;14501;00BA5039D1DDA19907CF00 +440;Phoenix R/C;FreeTrack20;V160;;;3075;01B801D5500DBFF3496300 +350;Pivot Maritime;FreeTrack20;V160;;;20365;015E472408A51DC05B3E00 +451;PlanetSide 2;FreeTrack20;V170;;;6002;1772BB34B53FDC5C5AAF00 +461;PlanetSide 2 M.E.;FreeTrack20;V160;;;6003;01CDF898452E1EBBAE2A00 +296;Pointman;FreeTrack20;V160;;;7525;01280243413FE2E4C8E300 +448;Power Driving Simulator;FreeTrack20;V160;;;20675;01C040D5035311D2527100 +377;Prepar3D;FreeTrack20;V160;;;20440;01790E10088D3907774A00 +108;Priston Tale;FreeTrack20;V160;;;9701;006C870212CBE670973500 +102;Project Reality (BF2 Mod);FreeTrack20;V160;;;9201;006669EDBEC82FE43CE200 +269;Project Torque (Invictus);FreeTrack20;V160;;;4802;010DAAED7202A00A655C00 +160;Project X;FreeTrack20;V160;;;20022;00A09C79A8A0D152677900 +376;Quanser;FreeTrack20;V160;;;20435;0178939BFE9809A627C800 +414;QuantaDyn;FreeTrack20;V160;;;20575;019E557428E37376FF7F00 +247;Quest 3D Xframe Plugin;FreeTrack20;V160;;;20043;00F7BFB47F954C43454300 +251;Quest3D;FreeTrack20;V160;;;1425;00FB1F3D1175694975DC00 +240;Quest3D - CINEACT integration;FreeTrack20;V160;;;20040;00F0989CF1992B06E73500 +101;R-concept X (AdrenalinStorm);FreeTrack20;V160;;;9101;0065FF26067DBF68405000 +239;R.U.D.O. Tools;FreeTrack20;V160;;;20039;00EF12AAAA0FFD211A4400 +193;RACE (the WTCC game);FreeTrack20;V160;;;3904;00C1F93264F7E42807A500 +137;RACE 07, RACE, GTR 2;FreeTrack20;V160;;;3903;0089322254C0FEBA783600 +35;Racer;FreeTrack20;V160;;;2401;0023DD0722234C623D2A00 +157;Racer S;FreeTrack20;V160;;;20030;009D7DDCFB4BA63BF8B900 +477;RaceRoom Racing Experience;FreeTrack20;V160;;;3905;01DDD4149E8079814C4900 +280;Rail Simulator 1;FreeTrack20;V160;;;1550;011861BD945A05CE9A0200 +304;Railway Work Simulator;FreeTrack20;V160;;;20225;01308D38573EFBA8C62900 +407;RailWorks 2;FreeTrack20;V160;;;2750;01972274C0A26400FA4300 +494;RailWorks 5 (TS2014);FreeTrack20;V160;;;1551;01EE0E7CED6052182A9E00 +42;Raydon Driving Simulator;FreeTrack20;V160;;;3701;002ADE17B702A8BA0B7E00 +113;Real Time Visual;FreeTrack20;V160;;;9901;00716D9809FCBF2337FB00 +21;RealFlight;FreeTrack20;V160;;;4001;0015AA9C954F2E10843700 +252;Reality Manager;FreeTrack20;V160;;;20046;00FC1758EC486A46E56A00 +299;RealWorld;FreeTrack20;V160;;;20215;012BEB3D7A9E22A4C30000 +232;Red Baron 3D;FreeTrack20;V160;;;1125;00E8532DCC6880486FE400 +321;Red Orchestra: Heroes of Stalingrad;FreeTrack20;V170;;;12602;313A21F9121056CD997300 +155;Red Orchestra: Ostfront;FreeTrack20;V170;;;12601;31399A9A2BE97252BB9000 +298;Redline Monitor;FreeTrack20;V160;;;20210;012A504D3822948322E400 +345;REFLEX XTR;FreeTrack20;V160;;;2150;01592A614F2916720BF800 +457;Remote Presence;FreeTrack20;V160;;;20710;01C9330C7BE4B9D1123100 +26;rFactor;FreeTrack20;V160;;;7401;001AEDCDB422FA4246F300 +363;rFactor Pro;FreeTrack20;V170;;;7403;1CEB175198D74BE8E89600 +362;rFactor2;FreeTrack20;V170;;;7402;1CEABFF3A86D34DA24C000 +19;Richard Burns Rally;FreeTrack20;V160;;;3401;00132C79AAF822A1782900 +262;RidingStar;FreeTrack20;V160;;;1475;0106F00F81EACE1D121900 +112;Rig N Roll;FreeTrack20;V160;;;9801;0070243DF1E9DDC6128700 +223;Rio Tinto Resource Development;FreeTrack20;V160;;;20033;00DF4685D64605F901FA00 +134;Rise of Flight;FreeTrack20;V160;;;11401;0086411A2283C98DE3F300 +62;Rise: The Vieneo Province;FreeTrack20;V160;;;6301;003E869CA59BA3F8402500 +145;Rising Conflicts;FreeTrack20;V160;;;12101;009157937539889AFFD200 +479;RITS;FreeTrack20;V160;;;20775;01DFEE4278F8DA6241B500 +323;Road Legends;FreeTrack20;V160;;;1876;0143DC9E44CFE362220300 +439;Rogue System;FreeTrack20;V160;;;3050;01B76A748C82E992407600 +198;Rogue Warrior;FreeTrack20;V160;;;14202;00C676A950F883FBE86F00 +404;ROV Sim;FreeTrack20;V160;;;20530;01944B3F641ECAA4EDB400 +8;Rowan's Battle Of Britain;FreeTrack20;V160;;;1502;0008A5372D1F523BA99B00 +334;RSD Demo;FreeTrack20;V160;;;2050;014ECAB716999F1506D800 +364;RTMS Crane Sim;FreeTrack20;V160;;;20400;016C28E2DF8BF660398400 +291;RTT DeltaGen Plugin;FreeTrack20;V160;;;20195;012388ADF7BCEC8D9F7600 +333;Sail Simulator 5;FreeTrack20;V160;;;1975;014D098ACA8727B4127C00 +119;Sailors of the Sky;FreeTrack20;V160;;;10201;0077BA317BF20491617100 +317;Santa Cruz Watermill;FreeTrack20;V160;;;20290;013D8BF77C4CD4F1AEDF00 +380;SCANeR Studio Plugin;FreeTrack20;V160;;;20445;017CB0214D8240D4064300 +338;SEGA Demo;FreeTrack20;V160;;;2075;01525940F7D268551DC000 +358;Seven-G;FreeTrack20;V160;;;2350;0166D25A0B83E25CD1A900 +38;SFSPC;FreeTrack20;V160;;;2801;0026A7AD7AC4939E10F000 +175;Ship Simulator 2006;FreeTrack20;V160;;;5002;00AF6A4327FAC1B8CF3700 +220;Ship Simulator 2008;FreeTrack20;V160;;;5003;00DC36FBF4376972E20B00 +413;Shiphandling Simulator;FreeTrack20;V160;;;20570;019DA9D2D2DD12011B8600 +253;Shooting Simulator;FreeTrack20;V160;;;20047;00FD6924A9F1C5E2675400 +146;SIA Games;FreeTrack20;V160;;;20015;0092DD3AF7E3F75F801200 +97;Silent Wings;FreeTrack20;V160;;;8701;0061C4239F4D39FF8B9B00 +149;SilverHat;FreeTrack20;V160;;;12401;0095BCE3AC4FAE4116FC00 +159;Simax Simulator;FreeTrack20;V160;;;20021;009FAA4AEC13FDC3F27C00 +328;Simball 4D;FreeTrack20;V160;;;20315;0148355F9C387394D83400 +393;Simbionix;FreeTrack20;V160;;;20485;01891920FCD1A3C83AA500 +400;SimCreator;FreeTrack20;V160;;;20520;0190377E4AEA83A138C600 +436;Simlog Personal Simulator;FreeTrack20;V160;;;20635;01B4B4F1588589758BF200 +166;SimQuest immersion system;FreeTrack20;V160;;;20023;00A651AC465CC9512C5C00 +225;SimSol;FreeTrack20;V160;;;20034;00E17A6C94B045AE879900 +478;Simumak;FreeTrack20;V160;;;20770;01DE273F99F32A115C2200 +58;Sirocco Racing;FreeTrack20;V160;;;5801;003ACE0664198937E1AE00 +270;Sky God: Military Freefall;FreeTrack20;V170;;;1526;05F62C0104385FD1C44400 +340;Soft fx Demo;FreeTrack20;V160;;;2125;0154146B0FEE7595399A00 +208;Source Engine (Half-Life 2);FreeTrack20;V160;;;12502;00D0D8070EDB3D4216B400 +238;Space Shuttle Mission;FreeTrack20;V160;;;1225;00EE86ED2641631C4C1B00 +431;SRI;FreeTrack20;V160;;;20620;01AF4A649F85CEE0140D00 +90;Stanford University;FreeTrack20;V160;;;20004;005AD9AFBDC84215FBFE00 +487;Star Citizen;FreeTrack20;V170;;;3450;0D7AF4CE4E343EC6B4A200 +63;Starshatter;FreeTrack20;V160;;;6401;003F15D4AA65E95BD47400 +140;Steel Beasts 2;FreeTrack20;V160;;;11703;008CBFFEDFFD1E2F83BD00 +138;Steel Beasts Pro;FreeTrack20;V160;;;11701;008AA1CD7C4F209928DC00 +139;Steel Beasts Pro Personal;FreeTrack20;V160;;;11702;008B91022DAC9A39FF7D00 +188;Stoked Rider;FreeTrack20;V160;;;14701;00BC8C49F9673F1E485A00 +129;Storm of War: the Battle of Britain;FreeTrack20;V170;;;11001;2AF98F54A68B71F25D0200 +482;STRAFT;FreeTrack20;V160;;;3375;01E2009CCE50B86BAACB00 +351;Stride;FreeTrack20;V170;;;2310;0906C784B21E4B21984400 +320;STS Driving Simulator;FreeTrack20;V160;;;20300;01400983A3CE434CDBF900 +388;Sunaerosys;FreeTrack20;V160;;;20475;018402DCF00E50E5B38F00 +195;Superkarting;FreeTrack20;V160;;;14903;00C35C106A3436F0879100 +206;SuperX Research;FreeTrack20;V160;;;15401;00CE04A93579F18D596900 +305;SWRI Demo;FreeTrack20;V160;;;20230;0131160156AB6742511600 +370;Syncon Robot Control;FreeTrack20;V160;;;20415;0172AD589794629A2B0A00 +418;Synergy Simulation;FreeTrack20;V160;;;20595;01A2FFFA224BC8E142E700 +91;T and TS Corp.;FreeTrack20;V160;;;20005;005BBB45A6C816678D3F00 +427;Take On Helicopters;FreeTrack20;V170;;;7504;1D50513CB40C0623B96A00 +4;Target: Korea;FreeTrack20;V160;;;1201;0004E1565C6D5C74281000 +5;Target: Rabaul;FreeTrack20;V160;;;1202;0005D6AD26B32B6AF1B000 +255;Targeting Demo;FreeTrack20;V160;;;13002;00FF9CDEA19F05FF6F9D00 +330;TD Demo;FreeTrack20;V160;;;1925;014A5259750CDF66619A00 +476;TeachLive;FreeTrack20;V160;;;20765;01DC309E0190220A5A5800 +382;Telepresence;FreeTrack20;V160;;;20450;017E38E23603893246FB00 +421;Tenstar Simulator;FreeTrack20;V160;;;20605;01A5A9D5B49ABF27189900 +168;Test Drive Unlimited;FreeTrack20;V160;;;13201;00A828972ADD80AC840100 +488;The Crew;FreeTrack20;V170;;;1009;03F1F534E94F4834D9B100 +475;The Gallery;FreeTrack20;V160;;;3350;01DB252299A2538C8B0500 +274;The Sky Gods;FreeTrack20;V170;;;1525;05F5DFF782DCCEEA27C200 +359;theHunter;FreeTrack20;V170;;;2375;0947BFF3A86D34DA24C000 +172;thriXXX HII 3D;FreeTrack20;V160;;;13403;00ACD24946AB81B166A200 +170;thriXXX Jenna;FreeTrack20;V160;;;13401;00AA4955337748B5B86700 +171;ThriXXX Technology;FreeTrack20;V160;;;13402;00AB248D535A7739E5C400 +28;tir2joy;FreeTrack20;V160;;;2202;001CF3931AEED44728F000 +79;TIRF4;FreeTrack20;V160;;;2203;004F6839BA86CBE7475000 +316;TNO;FreeTrack20;V160;;;20285;013CF4AF105AC7B7C59800 +110;ToCA Race Driver 2;FreeTrack20;V160;;;8102;006EF22848C883AA250700 +81;Toca Race Driver 3;FreeTrack20;V160;;;8101;005118E83C296C5EEE6E00 +290;Tom Clancy's H.A.W.X.;FreeTrack20;V170;;;1004;03ECAA4D48E85966FBAA00 +390;Tom Clancy's H.A.W.X. 2;FreeTrack20;V170;;;1007;03EF1B7583521C12406F00 +53;Torque Game Engine;FreeTrack20;V160;;;5301;00351B870166E14D541C00 +250;Total War;FreeTrack20;V160;;;1375;00FAE0702DB7A005CEFD00 +446;Tower Crane Simulator;FreeTrack20;V160;;;20670;01BEA0415AA1590240C000 +245;Tower I;FreeTrack20;V160;;;1325;00F59762ABAEA411402B00 +311;TPL Testing;FreeTrack20;V160;;;20260;0137AF436C07F556AA3A00 +415;trackd;FreeTrack20;V160;;;20580;019FB51F837F71D2B53200 +346;TrackMapper2;FreeTrack20;V160;;;2175;015A2AADF4868D09F43500 +242;TrainMaster;FreeTrack20;V160;;;20042;00F2BF26C1C37CB1EC8E00 +49;Trainz;FreeTrack20;V160;;;4701;0031F535362568C64B5C00 +441;TraumTek;FreeTrack20;V160;;;20650;01B902E0159A2B25890A00 +216;Turismo Carretera;FreeTrack20;V160;;;15801;00D85C44219E2BB76A6E00 +57;UK Rally Champion;FreeTrack20;V160;;;5701;0039F003505E80C5BA4500 +438;ULAN;FreeTrack20;V160;;;20645;01B6D49931402D5BD15900 +460;Underwater Navigation;FreeTrack20;V160;;;20715;01CCF2733124B2CB825400 +375;Unity 3D Plugin;FreeTrack20;V160;;;20430;0177AC7406DA8D3A932000 +177;Untitled 10tacle;FreeTrack20;V160;;;13701;00B1EBD1F9FFA6E6686200 +211;Untitled 3D People;FreeTrack20;V160;;;15501;00D37F9EA487AA42247F00 +66;Untitled Apportmedia;FreeTrack20;V160;;;6801;0042D5187BF69F378D7100 +178;Untitled Combat Flight Sim;FreeTrack20;V160;;;13801;00B266CCC6A8DBFECB9800 +187;Untitled Deep Silver;FreeTrack20;V160;;;14601;00BB23F9930F84C5769300 +71;Untitled G5 Software;FreeTrack20;V160;;;7301;00474929D76981E1A02B00 +105;Untitled Microsoft;FreeTrack20;V160;;;2308;0069DBD74AFE91D3024C00 +230;Untitled Research;FreeTrack20;V160;;;1075;00E6CA13538ACC57311300 +194;Untitled Ron E;FreeTrack20;V160;;;14902;00C29095124261E15DF100 +162;Untitled Sega of America;FreeTrack20;V160;;;12801;00A2A551CA58DE6F431100 +86;Untitled Simbin;FreeTrack20;V160;;;3902;0056A59CCCD19640F02800 +48;Untitled WorkShield;FreeTrack20;V160;;;4601;00308A50AB16142C431B00 +161;Untitled ZootFly;FreeTrack20;V160;;;12701;00A192B9918A967B93EE00 +357;UQO;FreeTrack20;V160;;;23085;0165C4249A2AACE457C100 +176;UVEG Machinery Simulator;FreeTrack20;V160;;;20024;00B00EC97C19220E86C200 +384;VAR;FreeTrack20;V160;;;20460;01802E6404E2093E335400 +72;VBS2;FreeTrack20;V160;;;7501;00484D56D30EBF26F9D300 +472;VBS2 2.0;FreeTrack20;V170;;;7505;1D51EB3616B3A44F05B900 +268;Vehicle Simulator (Quality Simulations);FreeTrack20;V160;;;5102;010C5B2715A74AAD11E400 +465;Vehicle Simulator Direction;FreeTrack20;V160;;;20735;01D1C190613C2659205600 +109;Vestibular Ocular Reflex;FreeTrack20;V160;;;20008;006DDB9B67D9FF7B794700 +40;Viper Arena;FreeTrack20;V160;;;3501;00280F44DDAE4E9C216100 +128;VIRTools Engine;FreeTrack20;V160;;;10801;0080121CF5C829C1B6B200 +293;Virtools Plugin;FreeTrack20;V160;;;20200;012513C5A0D1B2E663F300 +307;Virtual Driving;FreeTrack20;V160;;;20245;013304BB3175D4E525A600 +354;Virtual Heroes;FreeTrack20;V160;;;20375;01623EE91E8BE83AEF0100 +82;Virtual RC Racing;FreeTrack20;V160;;;8201;005210874C10ED78B92400 +24;Virtual Sailor;FreeTrack20;V160;;;5201;00189C82D267B22107AF00 +428;Virtual Shopper;FreeTrack20;V160;;;20610;01AC792408643886688500 +315;Virtual Supermarket;FreeTrack20;V160;;;20280;013B45049B1D1AAC1B1500 +483;VirtualiTeach;FreeTrack20;V160;;;20790;01E33372A29B77BE555500 +467;Vizard;FreeTrack20;V160;;;20745;01D31D33B1063E9CB33000 +212;VizRD;FreeTrack20;V160;;;20031;00D46259B91926FBE51000 +69;Void War;FreeTrack20;V160;;;10001;00450D16B44FE54E0DDE00 +464;VRPlayer;FreeTrack20;V160;;;20730;01D06AF3334F6C1327AB00 +244;VT08;FreeTrack20;V160;;;1275;00F429808701FF70751000 +279;VVVV Plugin;FreeTrack20;V160;;;20075;011799A485C311062E3A00 +314;VW Testing;FreeTrack20;V160;;;20275;013A70EEE8249EBB987D00 +286;Walkabout3d;FreeTrack20;V160;;;20125;011EB2F5E9B9AAD8422D00 +258;Wallbusters;FreeTrack20;V160;;;1450;01020B97F896261C609800 +419;War Thunder;FreeTrack20;V160;;;1878;01A3ED245C2D45BE12E100 +399;WAVES;FreeTrack20;V160;;;20515;018F3FD63467A115118800 +381;Welding Simulator;FreeTrack20;V160;;;2625;017D3BC378113A73449600 +32;West Racing;FreeTrack20;V160;;;1801;00207E5E89C98349BE5A00 +130;Whirlwind of Vietnam;FreeTrack20;V160;;;11101;0082CBED7E0405C616EF00 +450;Wikid FJ;FreeTrack20;V160;;;20685;01C242DF76E15A6D43C200 +324;Wings of Prey;FreeTrack20;V160;;;1877;014434CE29E832C5E1A200 +115;Wings of War;FreeTrack20;V160;;;7807;0073A1FD80161F0C641800 +70;World Racing 2;FreeTrack20;V160;;;7201;0046C49D1512D419B7F300 +219;WWII Battle Tanks: T-34 vs. Tiger;FreeTrack20;V160;;;11102;00DBC4D05E9E28F0BF6000 +235;X Motor Racing;FreeTrack20;V160;;;1150;00EBB738DA020969741600 +16;X-Cockpit for X-Plane;FreeTrack20;V160;;;2901;0010B24C9067FE0CA39100 +74;X-Plane;FreeTrack20;V160;;;7701;004A83FD2FD179E4E7B000 +117;X-Plane 6DOF Plugin;FreeTrack20;V160;;;10101;00751C3770B08B370D7000 +141;X-Plane Pilot View;FreeTrack20;V160;;;11301;008D5BA39ED0E94905F700 +39;X-Tower for X-Plane;FreeTrack20;V160;;;3001;00270FA7C9CD672252A000 +310;X1Alpha;FreeTrack20;V160;;;1825;0136A118B1F437F93D2D00 +55;X2: The Threat;FreeTrack20;V160;;;5501;0037C5189007314D35D600 +224;X3: Albion Prelude;FreeTrack20;V170;;;5502;157E7E101A708F8524E300 +189;Xyphoid;FreeTrack20;V160;;;14301;00BDEEB9961F6E08538800 +241;zedasoft F-35 Demo;FreeTrack20;V160;;;20041;00F1FB9C5D8A4AE8793600 +480;ZKT;FreeTrack20;V160;;;20780;01E0DF5AAC54B74772B300 +183;Zombie AA Research;FreeTrack20;V160;;;14201;00B775BD9BCC51E6276000 -- cgit v1.2.3 From f2cc20fd90bc13fa08fa9b8649234f9f2301f333 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 27 Dec 2013 19:04:29 +0100 Subject: regen csv #2 --- bin/settings/facetracknoir supported games.csv | 1003 ++++++++++++------------ 1 file changed, 508 insertions(+), 495 deletions(-) diff --git a/bin/settings/facetracknoir supported games.csv b/bin/settings/facetracknoir supported games.csv index 1f98beab..eb1a64b4 100644 --- a/bin/settings/facetracknoir supported games.csv +++ b/bin/settings/facetracknoir supported games.csv @@ -1,496 +1,509 @@ No;Game Name;Game protocol;Supported since;Verified;By;INTERNATIONAL_ID;FTN_ID -174;18 Wheels of Steel: Haulin';FreeTrack20;V160;;;13601;00AE9E109B72BA8DAA1B00 -215;1944 D-Day;FreeTrack20;V160;;;15701;00D73F301108DFC27A7B00 -484;2KMarinNEXT;FreeTrack20;V170;;;3425;0D614F6A0820D1EA8EE800 -392;3D Instructor;FreeTrack20;V160;;;20490;0188250AEFA5B5EA15CB00 -374;3D Interactive;FreeTrack20;V160;;;20425;01768FC3899CF17E7BB300 -492;3D Interieur Visualisation;FreeTrack20;V160;;;20815;01EC9C5D248D93000FEC00 -306;3d Nav;FreeTrack20;V160;;;20235;01323D827F93B498210600 -156;3D-Fahrschule Driving Simulator;FreeTrack20;V160;;;20020;009C90AA65E5BDC1D12A00 -96;3ds Max;FreeTrack20;V160;;;8601;0060A18FECCA3FBFCEDE00 -302;Aaaaa!;FreeTrack20;V160;;;1775;012EBCB2EA96CCD532C000 -46;Accessible Computer Games;FreeTrack20;V160;;;4301;002ECD9251931942DAEB00 -15;Aces High II;FreeTrack20;V160;;;2701;000F3BAF2B82B2E1BACE00 -452;ADS;FreeTrack20;V160;;;20690;01C4C5E387A650CCF60B00 -336;Aerofly;FreeTrack20;V160;;;2025;0150B48DFC3D8EE4210700 -367;Affineon;FreeTrack20;V160;;;20405;016FA2224086841F7DC000 -210;Air Battles: Sky Defender;FreeTrack20;V160;;;7003;00D2A133006D158A0EA800 -284;Air Phobia;FreeTrack20;V160;;;20100;011C608E586982AB1E2C00 -41;Air Traffic Control Tower;FreeTrack20;V160;;;3601;00292A472BF8D9480ED100 -199;AirBook;FreeTrack20;V160;;;15201;00C76A9645BD591075D900 -44;America's Army;FreeTrack20;V160;;;4101;002C360B433EED950F9A00 -301;America's Army 3;FreeTrack20;V170;;;14203;377B3F3206BCEA252BB700 -308;ANAG 3D;FreeTrack20;V160;;;20250;013430823DC1F5E486D100 -322;Apache: Air Assault;FreeTrack20;V160;;;1875;0142A443A20298AFE19700 -133;Aprisoft Gartenplaner;FreeTrack20;V160;;;20014;00855226E8EBAD633BB900 -132;Aprisoft Traumhaus Designer;FreeTrack20;V160;;;20013;0084E25199C61FA7879900 -485;ARI;FreeTrack20;V160;;;20795;01E533F9AAFE57D5430600 -124;ArmA;FreeTrack20;V160;;;10601;007C38EA44ADDAA358D900 -273;ArmA 2;FreeTrack20;V170;;;7502;1D4EEB3616B3A44F05B900 -426;Arma 3;FreeTrack20;V170;;;7503;1D4FB69411ABD4E2B39900 -276;Armored Assault - Gold Edition;FreeTrack20;V170;;;1303;0517A7F7CAA00814ECA700 -423;Arvoch Alliance;FreeTrack20;V160;;;14908;01A7F311F312BFC5057900 -191;Arvoch Conflict;FreeTrack20;V160;;;14901;00BF8E0AA63919A632EB00 -226;Auditory Displays for the blind;FreeTrack20;V160;;;20035;00E233D303ECAA687F6C00 -473;Autodesk;FreeTrack20;V160;;;20755;01D9861B5E74923B501800 -150;AV Core Technology;FreeTrack20;V160;;;20016;009618521D67AAC73AB000 -341;AVRS;FreeTrack20;V160;;;20340;0155286F525153D27DFE00 -469;B.O.M.B.;FreeTrack20;V160;;;3325;01D572C028D57E89BC0200 -154;BAE Systems HILAS cockpit;FreeTrack20;V160;;;20019;009A79731D5E78C1A7A500 -278;Battle of Britain (iENT);FreeTrack20;V170;;;1305;05190BA119195B701AED00 -68;Battle of Britain II - Wings of Victory;FreeTrack20;V160;;;7001;0044F8561890C5731B4A00 -60;Battlecruiser;FreeTrack20;V160;;;6101;003CBB561A0923152A5100 -107;Battlefield 2;FreeTrack20;V170;;;9601;2581B1560A2A7327659200 -64;Battlefield 2 Trauma Studios;FreeTrack20;V160;;;6501;004006A4B42823F88E3400 -271;Battlefield 2142;FreeTrack20;V170;;;9602;25821C739AD3817FD43300 -18;Battleground Europe : World War II Online;FreeTrack20;V160;;;3301;001242F35C2472CB3ACD00 -131;Battleground Europe : WWII Online;FreeTrack20;V160;;;11201;00834A3092D9427631DE00 -126;Beckman Institute UIUC;FreeTrack20;V160;;;20012;007EFB3EEF546B024DFD00 -169;Beyond The Red Line;FreeTrack20;V160;;;13301;00A94CBE5A4F44EB519800 -167;BF2 (Unsupported Demo);FreeTrack20;V160;;;9651;00A7278E32A322457EDD00 -84;Big Scale Racing;FreeTrack20;V160;;;8301;0054C1D0A1C87957F0FE00 -30;Birds of Prey;FreeTrack20;V160;;;1601;001EE77821649406245700 -263;Black Shark;FreeTrack20;V170;;;1003;03EBB6DCD15F5A572F6500 -432;Boeing;FreeTrack20;V160;;;20351;01B00D0EFE298BFC60E800 -343;Boeing Demo;FreeTrack20;V160;;;20350;01578C15DC16F5E33C7D00 -319;Bomber Squadron;FreeTrack20;V160;;;1850;013F72BF1D9C6B401DF700 -260;Brain-IT Group;FreeTrack20;V160;;;20050;0104E1F4D6FD674A4E2500 -173;Brothers In Arms;FreeTrack20;V160;;;13501;00ADC07FF4B1A6E948B600 -347;Bus Simulator;FreeTrack20;V160;;;2225;015BC403649A5E94E6E500 -51;C-Spine;FreeTrack20;V160;;;4901;003395D3663BFBDB6E9A00 -422;C.A.R.S.;FreeTrack20;V170;;;2825;0B0998EFE2EB6EE8E11300 -397;C.U.B.;FreeTrack20;V160;;;20505;018DD932954533C2E0F400 -287;CameraGripTools;FreeTrack20;V160;;;20150;011F7251EA4A4FAD775A00 -355;Caterpillar Simulators;FreeTrack20;V160;;;23080;016329AAA37A9155096E00 -114;CCG Metamedia;FreeTrack20;V160;;;20009;0072377014025EB6EA6C00 -353;CEWIT Immersive Cabin;FreeTrack20;V160;;;20370;0161EFC951AECEF8DAFE00 -447;Chopper;FreeTrack20;V160;;;3150;01BFD5440436C35DE79500 -412;Clearbox;FreeTrack20;V160;;;20565;019CF54508C25F035DF500 -394;CNKFsoft;FreeTrack20;V160;;;20495;018A43B91FFF38CB80DF00 -474;Cognitics;FreeTrack20;V160;;;20760;01DA28209057E9FA6E3500 -111;Colin McRae Rally 04;FreeTrack20;V160;;;8103;006FF602A2B72A614B6E00 -356;Comanche;FreeTrack20;V160;;;2275;01646664AEA1A895F0A000 -14;Combat Flight Simulator 3;FreeTrack20;V160;;;2304;000E8158E318F88163F500 -34;Combat Helo;FreeTrack20;V160;;;2001;002299B710843501AFD700 -98;Commandos Strike Force;FreeTrack20;V160;;;8801;0062114D555A837B30CC00 -125;Concept RS;FreeTrack20;V160;;;10701;007DA1423E0ED64CF47500 -59;Condor: The Competitive Soaring Simulator;FreeTrack20;V160;;;5901;003BE833A39AE3D29DEA00 -331;Conflict Taiwan;FreeTrack20;V160;;;1950;014BA899879AE5481B2B00 -409;Corys;FreeTrack20;V160;;;20550;0199116C7DE46E17A64400 -151;Counter Strike;FreeTrack20;V160;;;12501;0097DF722038FD4EA14D00 -254;Crane Simulator;FreeTrack20;V160;;;20048;00FEE4AAE7A954FA604E00 -56;Crashday;FreeTrack20;V160;;;5601;0038C174E71FFD977CCC00 -297;Creanex Training Simulator;FreeTrack20;V160;;;20205;01292F5C1B72857ADDA400 -153;Creative Labs headset;FreeTrack20;V160;;;20018;009957727B42043CBA9E00 -50;Cross Racing Championship;FreeTrack20;V160;;;4801;0032F7DE5B26B334981B00 -283;Crysis Mod;FreeTrack20;V160;;;1625;011B1BC6B04FFEF5AD1400 -209;Crystal Growth Simulation;FreeTrack20;V160;;;20029;00D13F3A4838913A44B400 -424;Crytek;FreeTrack20;V170;;;2775;0AD7D5F1EBBAD81C714600 -218;D2x-XL;FreeTrack20;V160;;;16001;00DA79A678C0682E30A200 -77;Dark Horizons Lore;FreeTrack20;V160;;;7901;004D45698776A20C324200 -277;Dawn of Aces - Gold Edition;FreeTrack20;V170;;;1304;0518A9ED7700814190DE00 -78;Dawn of Aces II;FreeTrack20;V160;;;1302;004E03B6D3AC5C15BA1900 -372;DBS WalkAndFollow;FreeTrack20;V160;;;2525;0174177CDE734882A0B000 -373;DCS: A-10C;FreeTrack20;V170;;;1006;03EEF688FC9B0556868F00 -121;Dead Reckoning;FreeTrack20;V160;;;10401;0079E323618912A95D5200 -217;Delivery;FreeTrack20;V160;;;15901;00D9802203B1DCC5AA3700 -458;Demon Core;FreeTrack20;V160;;;3225;01CA1F069F2057F4D8CA00 -214;DiRT;FreeTrack20;V160;;;8104;00D6A15BCEFEF6B4ABFE00 -339;DiRT 2;FreeTrack20;V170;;;8107;1FAB7815C5379491C73300 -401;DiRT 3;FreeTrack20;V170;;;8108;1FACABA016ED2DFBDF6F00 -445;Door3;FreeTrack20;V160;;;20665;01BDA4ECFD45C5FE5EBD00 -228;Down In Flames;FreeTrack20;V160;;;1025;00E4BF608EBF49484EEB00 -312;Driver Test;FreeTrack20;V160;;;20265;013849AE3B289D1DC1A200 -182;Driver's Republic;FreeTrack20;V160;;;14001;00B6150AA00D9AD19E9B00 -52;DriveSim;FreeTrack20;V160;;;5001;00343807CA4E9EA3103800 -164;Driving Simulator;FreeTrack20;V160;;;13001;00A4B63D9ADBCB2AC2CE00 -366;dSphere TBA;FreeTrack20;V160;;;2425;016E5D8D2C83442CED7000 -434;DTS;FreeTrack20;V160;;;20625;01B2CF28A299FE354DC100 -282;Dungeons and Dragons Online;FreeTrack20;V170;;;1575;0627BD4D4DDC6BB6818800 -342;DY Demo;FreeTrack20;V160;;;20345;0156D9F373562BF31DE700 -325;EADS Testing;FreeTrack20;V160;;;20303;0145D15AC1FE3D41403900 -491;EAFIT;FreeTrack20;V160;;;20810;01EB99C66DF0A1F91DC100 -143;Eagle Lander 3D;FreeTrack20;V160;;;11901;008F53F747F03F272D4300 -303;EasyVR;FreeTrack20;V160;;;20220;012F8604205595E8B41B00 -417;ECA-Sindel;FreeTrack20;V160;;;20590;01A1B9A2A3B8244B13E000 -495;Elite: Dangerous;FreeTrack20;V170;;;3475;0D93A9485EECA12E18BE00 -468;Embers of Caerus;FreeTrack20;V170;;;3275;0CCB4134258D7E10119E00 -360;EMS Simulations;FreeTrack20;V160;;;20390;0168F93B8F6B68F7D55B00 -221;Enemy Engaged 2;FreeTrack20;V160;;;2102;00DDEFCE2BF04CB9E42B00 -10;Enemy Engaged: Commanche vs Hokum;FreeTrack20;V160;;;2101;000A5A1B0A415F3F531300 -329;Envision TE;FreeTrack20;V160;;;20320;0149BD94BDE99C25D2B300 -369;EON Reality;FreeTrack20;V160;;;20410;017121A16682A941225300 -455;eSigma;FreeTrack20;V160;;;20700;01C78A514A66DC74D00700 -266;Euro Truck Simulator;FreeTrack20;V160;;;13602;010AA042E7114092378600 -142;EVE Online;FreeTrack20;V160;;;11801;008E9A8A9BEFF713DBBE00 -147;Eventology;FreeTrack20;V160;;;12201;009341C3C7271FE1474000 -234;EVOC-101 Training;FreeTrack20;V160;;;20038;00EA0EEDE621545A0D7400 -196;Evochron Alliance 2.0;FreeTrack20;V160;;;14904;00C430A7928686E1E29900 -294;Evochron Legends;FreeTrack20;V160;;;14906;0126357B0DB28B9A7F7F00 -352;Evochron Mercenary;FreeTrack20;V160;;;14907;01608A58CD8C53BBC30100 -227;Evochron Renegades;FreeTrack20;V160;;;14905;00E3000A941E27BA776000 -368;EZCA;FreeTrack20;V160;;;2475;01709579943E9C0D409E00 -300;F-22 Total Air War;FreeTrack20;V160;;;1750;012CA6CCB21E416A793200 -292;F-35 PTA;FreeTrack20;V160;;;20185;01249D0534901AB137A100 -430;F-Trainer;FreeTrack20;V160;;;20615;01AEB888F96E2752298A00 -429;F1 2011;FreeTrack20;V170;;;8109;1FAD265ECD74893EA12900 -22;F1 Challenge 99-02;FreeTrack20;V160;;;4401;00166D27E99118BEEB3300 -396;FAAC;FreeTrack20;V160;;;20500;018C409784864ED81AA100 -9;Falcon 4.0;FreeTrack20;V160;;;1901;000987F8372EE07CA5D000 -99;Falcon 4.0: Allied Force;FreeTrack20;V160;;;8901;0063BCFAB33A4E42FAB300 -33;Falcon 5;FreeTrack20;V160;;;1902;0021977E9CB8EA480D3E00 -295;Farmer Simulator 2009;FreeTrack20;V160;;;1725;0127EAF6C473A66CB4E000 -80;Faros Driving Simulator;FreeTrack20;V160;;;8001;0050BDAA81724BA7917800 -389;Faubert Lab Car Simulator;FreeTrack20;V160;;;20480;0185CB21F2737C4E770E00 -275;FIFA 09;FreeTrack20;V170;;;9002;232A288979C65B0DAA0D00 -94;Fighter Ace;FreeTrack20;V160;;;8401;005EA62AAEB615EE563700 -103;Fighter Ops;FreeTrack20;V160;;;9301;006764CDD851A5FEC18800 -289;Fighter Squadron: Screamin Demons Over Europe;FreeTrack20;V160;;;1675;0121A140A985B64D78EB00 -3;First Eagles, Wings Over Europe, Strike Fighters;FreeTrack20;V160;;;1101;0003FD293BA8A5FCD86500 -163;Flight Gear;FreeTrack20;V160;;;12901;00A31314C59685279E5700 -12;Flight Simulator 2002;FreeTrack20;V160;;;2302;000CFA9D94946AE64BEC00 -13;Flight Simulator 2004;FreeTrack20;V160;;;2303;000D0809BE30FFFC2D2500 -148;Flight Simulator X;FreeTrack20;V160;;;2305;00949527D98EFCF1737F00 -6;Flyboys / Warbirds;FreeTrack20;V160;;;1301;0006B9283164764D951600 -285;Flyer;FreeTrack20;V160;;;1650;011D08CC76BA68B508C800 -202;Flying Tigers;FreeTrack20;V160;;;7002;00CA49A35875264C8AB000 -190;FlyingGuns;FreeTrack20;V160;;;14801;00BEF15778A88E30303100 -67;Ford Racing 3;FreeTrack20;V160;;;6901;004315F6B77EF2371A8900 -257;FreeSpace2;FreeTrack20;V160;;;13302;0101FBF945BBAE0EC0DF00 -313;FTAlpha;FreeTrack20;V160;;;20270;01394E3EC4AD48AA039700 -31;Full Out;FreeTrack20;V160;;;1701;001F249A7499D0A073B700 -165;Future Pinball;FreeTrack20;V160;;;13101;00A5C8B5A9A0E252AA1700 -332;Game VR;FreeTrack20;V160;;;20325;014C20C9A4646102632500 -410;GameLab;FreeTrack20;V160;;;20555;019A2980AAAE6BCE99FC00 -459;Games Farm;FreeTrack20;V160;;;3250;01CBAFBB4FA4A86606BA00 -229;Gamma;FreeTrack20;V160;;;1050;00E5E42ACF41379E700100 -490;Garry's Mod;FreeTrack20;V160;;;12503;01EAEABA1116EB8268CA00 -470;Generic Robotics;FreeTrack20;V160;;;20750;01D6B38BD6799D6BA1BC00 -462;Glider Sim;FreeTrack20;V160;;;20720;01CEE3EDD3D1668F849900 -335;Global Ground Support Deicing Simulation;FreeTrack20;V160;;;20330;014F77EC9DBBA2206C5200 -344;GosNIIAS Sim Trainer;FreeTrack20;V160;;;20355;01581273D0726665DBD500 -185;Gothic 3;FreeTrack20;V160;;;14401;00B9ADA579F7F083EFB800 -27;Grand Prix Legends;FreeTrack20;V160;;;6701;001B6A116A3C368FB86100 -116;Grand Theft Auto: San Andreas;FreeTrack20;V160;;;7808;0074E38D2FB36A4C409400 -265;GRID;FreeTrack20;V160;;;8105;0109211A446AAE7BB7A800 -248;GSE Power Plant Simulation;FreeTrack20;V160;;;20044;00F8E3FA8535BFFBDF2B00 -83;GT Legends;FreeTrack20;V160;;;3902;00536F35170D830A860800 -20;GTR;FreeTrack20;V160;;;3901;0014701F9C50D0D50DEF00 -391;Gun Commander;FreeTrack20;V160;;;2675;0187DD273241B932F30600 -43;Halo;FreeTrack20;V160;;;3801;002BD90B92B3D4D4B3A300 -489;hapTEL;FreeTrack20;V160;;;20805;01E9EDDCA498D073C15900 -456;Hardware Control Simulator, Railway Electronics;FreeTrack20;V160;;;20705;01C8B1A10FBE8974FE1A00 -237;Harrier Attack II;FreeTrack20;V160;;;1175;00ED1E3A76F0924DCE0900 -486;Harry's Hard Choices Interactive;FreeTrack20;V160;;;20800;01E67C35CC39DA9BD80F00 -87;Herissons (Paris France);FreeTrack20;V160;;;20001;0057AB857C2A8AFD8C1C00 -95;HL2 (Unsupported Demo);FreeTrack20;V160;;;7806;005F1FC32D74D01FDEA200 -337;HOBI;FreeTrack20;V160;;;20335;0151836DA0709D2BDB9E00 -200;HoverAssault;FreeTrack20;V160;;;5303;00C855D876AEAB8A7E6300 -420;HPC;FreeTrack20;V160;;;20600;01A44FEEAEF74957B2FA00 -309;HPG Tracking;FreeTrack20;V160;;;20255;0135879A4DC38934590F00 -435;HTW;FreeTrack20;V160;;;20630;01B38FB202777B2045EE00 -444;Huawei Software;FreeTrack20;V160;;;20660;01BCC3A77483ECD51A5800 -398;HueSpace;FreeTrack20;V160;;;20510;018E1F9EA3BD09C1799400 -197;Hyper Vision;FreeTrack20;V160;;;15101;00C5B1A1FC35FE0E556200 -243;iamfootball;FreeTrack20;V160;;;1250;00F3ACA7A917365CD94600 -425;id Research;FreeTrack20;V170;;;2950;0B86E723B873D7FC87D700 -233;IESA;FreeTrack20;V160;;;20037;00E9BC95612083AE32CA00 -1;IL-2 Forgotten Battles, ACE, Pacific Fighters;FreeTrack20;V160;;;1001;0001EA2DFC82DBE9745800 -471;IL-2 Sturmovik: Battle of Stalingrad;FreeTrack20;V170;;;1008;03F04D5368D1FD2DF2AE00 -246;Illumina;FreeTrack20;V160;;;1350;00F6D6B0442BAC92E26900 -326;ILP;FreeTrack20;V160;;;20310;0146936EC3C613E83EF500 -222;Imagine 3D ATC Tower Simulation;FreeTrack20;V160;;;20032;00DE8EDDB7DB62781E2300 -92;In Touch Technologies Inc.;FreeTrack20;V160;;;20006;005C88CE1D058424D88C00 -349;Inglobe;FreeTrack20;V160;;;20360;015D5442514EA727526D00 -231;Innovatec Simulator;FreeTrack20;V160;;;20036;00E7920AF051A330FAA600 -104;Insurgency;FreeTrack20;V160;;;9401;00682CB681F925AB0F6A00 -443;Intific;FreeTrack20;V160;;;20655;01BB9399EA57966BC11300 -184;iRacing;FreeTrack20;V160;;;14101;00B82AAAD44114A5EABB00 -204;IREQ Robotic Camera Control;FreeTrack20;V160;;;20027;00CC44BC073883A1ABB500 -449;ISIC;FreeTrack20;V160;;;20680;01C177201D3A03E4006700 -493;ITCL;FreeTrack20;V160;;;20820;01EDB3182E177EB5026E00 -405;IVD Online;FreeTrack20;V160;;;20535;0195B89FBE2236B3A78000 -88;J.J. Keller and Associates;FreeTrack20;V160;;;20002;005823D7C0F457D4FDF100 -100;Janes F18;FreeTrack20;V160;;;9001;0064165383689BB1055C00 -385;Javal Ent.;FreeTrack20;V160;;;2650;018115942BDF061BE46F00 -387;JC Demo;FreeTrack20;V160;;;20470;018346AFBD4E940FAF8A00 -47;Jet Thunder;FreeTrack20;V160;;;4501;002F81A9CFA072CBE26A00 -36;Jetfighter V;FreeTrack20;V160;;;2501;00244953A2760E826FE100 -411;JFIST;FreeTrack20;V160;;;20560;019B919FDE52C94F722D00 -288;John Deere Vehicle Simulator;FreeTrack20;V160;;;20175;0120CB0E12F3AB55D65300 -25;Jump to Lightspeed;FreeTrack20;V160;;;6001;00196DCDEC96B9C882A500 -192;Jumpgate;FreeTrack20;V160;;;15001;00C04B2449A3F257514E00 -236;Jumpgate Evolution;FreeTrack20;V170;;;15002;3A9A5936D4F93DCE0CE700 -17;KAF Keymapper;FreeTrack20;V160;;;3101;0011E2686B5B23E3B4A800 -463;KAI FLight Simulator;FreeTrack20;V160;;;20725;01CF834F29EBC5A9BFEF00 -144;Key Macro View;FreeTrack20;V160;;;12001;0090F19445683A2168D600 -361;kiwi.vg;FreeTrack20;V160;;;20395;0169B11715289D90E44400 -386;L-3;FreeTrack20;V160;;;20465;018294453C0E0EE16BB100 -264;L-3 Communications;FreeTrack20;V160;;;20051;0108BB71885A4FDA205500 -205;Lionhead MGS Game Research;FreeTrack20;V160;;;15301;00CD43E1E3CCF9BF748F00 -29;Live For Speed;FreeTrack20;V160;;;7101;001D4FC6F4EF3D7E48CF00 -136;Live for Speed S2;FreeTrack20;V160;;;11601;00880D0A41B67A39D28200 -2;Lock-On: Modern Air Combat;FreeTrack20;V160;;;1002;000272D8819F59779B7300 -201;Lockheed Martin Littoral Combat Ship simulator;FreeTrack20;V160;;;20025;00C94C0774EF6B95FC6400 -365;LockOn: Flaming Cliffs 2;FreeTrack20;V170;;;1005;03EDAFB0D279F3A6F72200 -437;London NHS;FreeTrack20;V160;;;20640;01B52A23B6D34D1A1A9F00 -85;Lore (Dark Horizons);FreeTrack20;V160;;;5302;00554096EC8C9878CF9200 -442;Love;FreeTrack20;V160;;;3125;01BA33A33A01A24EC1AB00 -122;Lucid Engine;FreeTrack20;V160;;;10501;007A23340BAB30B9BA1000 -403;M4 Tank Platoon;FreeTrack20;V160;;;1306;0193E33321E9D97274DC00 -379;Mach 1;FreeTrack20;V160;;;2575;017B82264F9497542A2300 -383;ManuVAR;FreeTrack20;V160;;;20455;017FBAE17BB4B1DF9F2400 -203;MaqSIM4;FreeTrack20;V160;;;20026;00CBE1C9442D7E89E78D00 -106;Mech Tactical Sim;FreeTrack20;V160;;;9501;006A32E41D501B43C00F00 -433;Mechwarrior Online;FreeTrack20;V170;;;3025;0BD114954226DB5D8CE200 -318;Medical Image Visualization;FreeTrack20;V160;;;20295;013E06ECEC255F8C3E0800 -249;Meggitt Defense Systems;FreeTrack20;V160;;;20045;00F9DC29D19895487B6C00 -408;MetaVR;FreeTrack20;V160;;;20545;0198614A5C85BC5B21A500 -256;Meteoroid Maze;FreeTrack20;V160;;;13003;0100DA85690FEE4CE8AA00 -348;MeVEA;FreeTrack20;V160;;;2250;015C7C61B1A0B391A82400 -23;Micro Flight;FreeTrack20;V160;;;5101;00173516714FAA1424FD00 -267;Microsoft ESP;FreeTrack20;V160;;;2306;010B6138B193D84B877E00 -281;Microsoft Flight;FreeTrack20;V170;;;2307;0903AFBC54959539C51500 -76;Microsoft Train Simulator;FreeTrack20;V160;;;7805;004CB25F5A748DC56FA600 -481;MiddleVR;FreeTrack20;V160;;;20785;01E15AD9A1BF5788732200 -7;Mig Alley;FreeTrack20;V160;;;1501;00071B1D7811FB865C1800 -416;Mimik Vehicle Simulator;FreeTrack20;V160;;;20585;01A08B8035EED58A8EA300 -378;Miner Wars;FreeTrack20;V160;;;2550;017A23F029863696D3B700 -11;MKMapper Keymapper;FreeTrack20;V160;;;2201;000B3FDEA7219E1B3FE600 -406;ModelSim;FreeTrack20;V160;;;20540;0196544AEBCCB6CDE97700 -118;Morgan State University;FreeTrack20;V160;;;20010;0076E2DD472701CE1FFC00 -135;Motor Company;FreeTrack20;V160;;;11501;0087B44851F711B3E09E00 -45;Motorsport Simulators;FreeTrack20;V160;;;4201;002D0AC61E75F696E43800 -93;Mouse Emulation;FreeTrack20;V160;;;8501;005D125D0C1438B4BD5B00 -65;MS World Tour Kart 2004;FreeTrack20;V160;;;6601;004112C27CFA6F45654500 -158;MSN Virtual Earth;FreeTrack20;V160;;;2309;009E1C037925FD2D541000 -371;mTBI Balance;FreeTrack20;V160;;;20420;01730A097BCAE8DB1D2700 -152;NASA Crew Exploration Vehicle;FreeTrack20;V160;;;20017;0098B9C576512B35B86D00 -37;NASCAR Heat;FreeTrack20;V160;;;2602;00252743D8E81EA5E28300 -75;NASCAR Racing 2003 season;FreeTrack20;V160;;;7804;004B4F68639EA37962BC00 -61;NASCAR SimRacing;FreeTrack20;V160;;;6201;003DD8E1AE9104A69CA200 -213;NecroVisioN;FreeTrack20;V160;;;15601;00D5DEFD8DBD3A898E0400 -127;NetKar Pro;FreeTrack20;V160;;;10901;007F2E80EFBB53C23AE800 -179;Nitro Stunt Racing;FreeTrack20;V160;;;13901;00B31F2576B9676095E200 -89;North Eastern University;FreeTrack20;V160;;;20003;0059549BAAC3509E30D300 -395;Novint;FreeTrack20;V160;;;2725;018B1ACFB3A9DB1F463500 -453;NVH Sound Simulator;FreeTrack20;V160;;;20695;01C52B0F776EB03D40B400 -466;OHJCH;FreeTrack20;V160;;;20740;01D2D53549A4AD258C0700 -259;Onadime - Realtime Animation;FreeTrack20;V160;;;20049;01034B3E9CB4A2BC59A800 -54;Operation Air Assault 2;FreeTrack20;V160;;;5401;003615F0D18EAB10D74700 -73;Operation Flashpoint 2 (inactive);FreeTrack20;V160;;;7601;00490AE7C30678C2BE9300 -272;Operation Flashpoint(r): Dragon Rising(tm);FreeTrack20;V170;;;8106;1FAA3328780E1322676100 -123;OptiMetrics;FreeTrack20;V160;;;20011;007B5456C192EF581A4400 -454;OpusFSX;FreeTrack20;V160;;;3175;01C63EDF50047080DF1C00 -120;Orbiter 2005 Plug-In;FreeTrack20;V160;;;10301;00785F82A85EE37660FC00 -181;Orbiter 2006;FreeTrack20;V160;;;10303;00B5E252B1CA8D5677EF00 -180;Orbiter 2006 Plug-In;FreeTrack20;V160;;;10302;00B445B539602FE137AB00 -207;Oryx Vehicle Simulators;FreeTrack20;V160;;;20028;00CFCE423F4B9979E9BA00 -327;Outer Conflict: Frontiers;FreeTrack20;V160;;;1900;014788F872AB60417F3300 -261;Over Flanders Fields;FreeTrack20;V160;;;2325;010529557D6FA134EDBC00 -402;PanoPro;FreeTrack20;V160;;;20525;0192BD283C4A31B45B4500 -186;Paraworld;FreeTrack20;V160;;;14501;00BA5039D1DDA19907CF00 -440;Phoenix R/C;FreeTrack20;V160;;;3075;01B801D5500DBFF3496300 -350;Pivot Maritime;FreeTrack20;V160;;;20365;015E472408A51DC05B3E00 -451;PlanetSide 2;FreeTrack20;V170;;;6002;1772BB34B53FDC5C5AAF00 -461;PlanetSide 2 M.E.;FreeTrack20;V160;;;6003;01CDF898452E1EBBAE2A00 -296;Pointman;FreeTrack20;V160;;;7525;01280243413FE2E4C8E300 -448;Power Driving Simulator;FreeTrack20;V160;;;20675;01C040D5035311D2527100 -377;Prepar3D;FreeTrack20;V160;;;20440;01790E10088D3907774A00 -108;Priston Tale;FreeTrack20;V160;;;9701;006C870212CBE670973500 -102;Project Reality (BF2 Mod);FreeTrack20;V160;;;9201;006669EDBEC82FE43CE200 -269;Project Torque (Invictus);FreeTrack20;V160;;;4802;010DAAED7202A00A655C00 -160;Project X;FreeTrack20;V160;;;20022;00A09C79A8A0D152677900 -376;Quanser;FreeTrack20;V160;;;20435;0178939BFE9809A627C800 -414;QuantaDyn;FreeTrack20;V160;;;20575;019E557428E37376FF7F00 -247;Quest 3D Xframe Plugin;FreeTrack20;V160;;;20043;00F7BFB47F954C43454300 -251;Quest3D;FreeTrack20;V160;;;1425;00FB1F3D1175694975DC00 -240;Quest3D - CINEACT integration;FreeTrack20;V160;;;20040;00F0989CF1992B06E73500 -101;R-concept X (AdrenalinStorm);FreeTrack20;V160;;;9101;0065FF26067DBF68405000 -239;R.U.D.O. Tools;FreeTrack20;V160;;;20039;00EF12AAAA0FFD211A4400 -193;RACE (the WTCC game);FreeTrack20;V160;;;3904;00C1F93264F7E42807A500 -137;RACE 07, RACE, GTR 2;FreeTrack20;V160;;;3903;0089322254C0FEBA783600 -35;Racer;FreeTrack20;V160;;;2401;0023DD0722234C623D2A00 -157;Racer S;FreeTrack20;V160;;;20030;009D7DDCFB4BA63BF8B900 -477;RaceRoom Racing Experience;FreeTrack20;V160;;;3905;01DDD4149E8079814C4900 -280;Rail Simulator 1;FreeTrack20;V160;;;1550;011861BD945A05CE9A0200 -304;Railway Work Simulator;FreeTrack20;V160;;;20225;01308D38573EFBA8C62900 -407;RailWorks 2;FreeTrack20;V160;;;2750;01972274C0A26400FA4300 -494;RailWorks 5 (TS2014);FreeTrack20;V160;;;1551;01EE0E7CED6052182A9E00 -42;Raydon Driving Simulator;FreeTrack20;V160;;;3701;002ADE17B702A8BA0B7E00 -113;Real Time Visual;FreeTrack20;V160;;;9901;00716D9809FCBF2337FB00 -21;RealFlight;FreeTrack20;V160;;;4001;0015AA9C954F2E10843700 -252;Reality Manager;FreeTrack20;V160;;;20046;00FC1758EC486A46E56A00 -299;RealWorld;FreeTrack20;V160;;;20215;012BEB3D7A9E22A4C30000 -232;Red Baron 3D;FreeTrack20;V160;;;1125;00E8532DCC6880486FE400 -321;Red Orchestra: Heroes of Stalingrad;FreeTrack20;V170;;;12602;313A21F9121056CD997300 -155;Red Orchestra: Ostfront;FreeTrack20;V170;;;12601;31399A9A2BE97252BB9000 -298;Redline Monitor;FreeTrack20;V160;;;20210;012A504D3822948322E400 -345;REFLEX XTR;FreeTrack20;V160;;;2150;01592A614F2916720BF800 -457;Remote Presence;FreeTrack20;V160;;;20710;01C9330C7BE4B9D1123100 -26;rFactor;FreeTrack20;V160;;;7401;001AEDCDB422FA4246F300 -363;rFactor Pro;FreeTrack20;V170;;;7403;1CEB175198D74BE8E89600 -362;rFactor2;FreeTrack20;V170;;;7402;1CEABFF3A86D34DA24C000 -19;Richard Burns Rally;FreeTrack20;V160;;;3401;00132C79AAF822A1782900 -262;RidingStar;FreeTrack20;V160;;;1475;0106F00F81EACE1D121900 -112;Rig N Roll;FreeTrack20;V160;;;9801;0070243DF1E9DDC6128700 -223;Rio Tinto Resource Development;FreeTrack20;V160;;;20033;00DF4685D64605F901FA00 -134;Rise of Flight;FreeTrack20;V160;;;11401;0086411A2283C98DE3F300 -62;Rise: The Vieneo Province;FreeTrack20;V160;;;6301;003E869CA59BA3F8402500 -145;Rising Conflicts;FreeTrack20;V160;;;12101;009157937539889AFFD200 -479;RITS;FreeTrack20;V160;;;20775;01DFEE4278F8DA6241B500 -323;Road Legends;FreeTrack20;V160;;;1876;0143DC9E44CFE362220300 -439;Rogue System;FreeTrack20;V160;;;3050;01B76A748C82E992407600 -198;Rogue Warrior;FreeTrack20;V160;;;14202;00C676A950F883FBE86F00 -404;ROV Sim;FreeTrack20;V160;;;20530;01944B3F641ECAA4EDB400 -8;Rowan's Battle Of Britain;FreeTrack20;V160;;;1502;0008A5372D1F523BA99B00 -334;RSD Demo;FreeTrack20;V160;;;2050;014ECAB716999F1506D800 -364;RTMS Crane Sim;FreeTrack20;V160;;;20400;016C28E2DF8BF660398400 -291;RTT DeltaGen Plugin;FreeTrack20;V160;;;20195;012388ADF7BCEC8D9F7600 -333;Sail Simulator 5;FreeTrack20;V160;;;1975;014D098ACA8727B4127C00 -119;Sailors of the Sky;FreeTrack20;V160;;;10201;0077BA317BF20491617100 -317;Santa Cruz Watermill;FreeTrack20;V160;;;20290;013D8BF77C4CD4F1AEDF00 -380;SCANeR Studio Plugin;FreeTrack20;V160;;;20445;017CB0214D8240D4064300 -338;SEGA Demo;FreeTrack20;V160;;;2075;01525940F7D268551DC000 -358;Seven-G;FreeTrack20;V160;;;2350;0166D25A0B83E25CD1A900 -38;SFSPC;FreeTrack20;V160;;;2801;0026A7AD7AC4939E10F000 -175;Ship Simulator 2006;FreeTrack20;V160;;;5002;00AF6A4327FAC1B8CF3700 -220;Ship Simulator 2008;FreeTrack20;V160;;;5003;00DC36FBF4376972E20B00 -413;Shiphandling Simulator;FreeTrack20;V160;;;20570;019DA9D2D2DD12011B8600 -253;Shooting Simulator;FreeTrack20;V160;;;20047;00FD6924A9F1C5E2675400 -146;SIA Games;FreeTrack20;V160;;;20015;0092DD3AF7E3F75F801200 -97;Silent Wings;FreeTrack20;V160;;;8701;0061C4239F4D39FF8B9B00 -149;SilverHat;FreeTrack20;V160;;;12401;0095BCE3AC4FAE4116FC00 -159;Simax Simulator;FreeTrack20;V160;;;20021;009FAA4AEC13FDC3F27C00 -328;Simball 4D;FreeTrack20;V160;;;20315;0148355F9C387394D83400 -393;Simbionix;FreeTrack20;V160;;;20485;01891920FCD1A3C83AA500 -400;SimCreator;FreeTrack20;V160;;;20520;0190377E4AEA83A138C600 -436;Simlog Personal Simulator;FreeTrack20;V160;;;20635;01B4B4F1588589758BF200 -166;SimQuest immersion system;FreeTrack20;V160;;;20023;00A651AC465CC9512C5C00 -225;SimSol;FreeTrack20;V160;;;20034;00E17A6C94B045AE879900 -478;Simumak;FreeTrack20;V160;;;20770;01DE273F99F32A115C2200 -58;Sirocco Racing;FreeTrack20;V160;;;5801;003ACE0664198937E1AE00 -270;Sky God: Military Freefall;FreeTrack20;V170;;;1526;05F62C0104385FD1C44400 -340;Soft fx Demo;FreeTrack20;V160;;;2125;0154146B0FEE7595399A00 -208;Source Engine (Half-Life 2);FreeTrack20;V160;;;12502;00D0D8070EDB3D4216B400 -238;Space Shuttle Mission;FreeTrack20;V160;;;1225;00EE86ED2641631C4C1B00 -431;SRI;FreeTrack20;V160;;;20620;01AF4A649F85CEE0140D00 -90;Stanford University;FreeTrack20;V160;;;20004;005AD9AFBDC84215FBFE00 -487;Star Citizen;FreeTrack20;V170;;;3450;0D7AF4CE4E343EC6B4A200 -63;Starshatter;FreeTrack20;V160;;;6401;003F15D4AA65E95BD47400 -140;Steel Beasts 2;FreeTrack20;V160;;;11703;008CBFFEDFFD1E2F83BD00 -138;Steel Beasts Pro;FreeTrack20;V160;;;11701;008AA1CD7C4F209928DC00 -139;Steel Beasts Pro Personal;FreeTrack20;V160;;;11702;008B91022DAC9A39FF7D00 -188;Stoked Rider;FreeTrack20;V160;;;14701;00BC8C49F9673F1E485A00 -129;Storm of War: the Battle of Britain;FreeTrack20;V170;;;11001;2AF98F54A68B71F25D0200 -482;STRAFT;FreeTrack20;V160;;;3375;01E2009CCE50B86BAACB00 -351;Stride;FreeTrack20;V170;;;2310;0906C784B21E4B21984400 -320;STS Driving Simulator;FreeTrack20;V160;;;20300;01400983A3CE434CDBF900 -388;Sunaerosys;FreeTrack20;V160;;;20475;018402DCF00E50E5B38F00 -195;Superkarting;FreeTrack20;V160;;;14903;00C35C106A3436F0879100 -206;SuperX Research;FreeTrack20;V160;;;15401;00CE04A93579F18D596900 -305;SWRI Demo;FreeTrack20;V160;;;20230;0131160156AB6742511600 -370;Syncon Robot Control;FreeTrack20;V160;;;20415;0172AD589794629A2B0A00 -418;Synergy Simulation;FreeTrack20;V160;;;20595;01A2FFFA224BC8E142E700 -91;T and TS Corp.;FreeTrack20;V160;;;20005;005BBB45A6C816678D3F00 -427;Take On Helicopters;FreeTrack20;V170;;;7504;1D50513CB40C0623B96A00 -4;Target: Korea;FreeTrack20;V160;;;1201;0004E1565C6D5C74281000 -5;Target: Rabaul;FreeTrack20;V160;;;1202;0005D6AD26B32B6AF1B000 -255;Targeting Demo;FreeTrack20;V160;;;13002;00FF9CDEA19F05FF6F9D00 -330;TD Demo;FreeTrack20;V160;;;1925;014A5259750CDF66619A00 -476;TeachLive;FreeTrack20;V160;;;20765;01DC309E0190220A5A5800 -382;Telepresence;FreeTrack20;V160;;;20450;017E38E23603893246FB00 -421;Tenstar Simulator;FreeTrack20;V160;;;20605;01A5A9D5B49ABF27189900 -168;Test Drive Unlimited;FreeTrack20;V160;;;13201;00A828972ADD80AC840100 -488;The Crew;FreeTrack20;V170;;;1009;03F1F534E94F4834D9B100 -475;The Gallery;FreeTrack20;V160;;;3350;01DB252299A2538C8B0500 -274;The Sky Gods;FreeTrack20;V170;;;1525;05F5DFF782DCCEEA27C200 -359;theHunter;FreeTrack20;V170;;;2375;0947BFF3A86D34DA24C000 -172;thriXXX HII 3D;FreeTrack20;V160;;;13403;00ACD24946AB81B166A200 -170;thriXXX Jenna;FreeTrack20;V160;;;13401;00AA4955337748B5B86700 -171;ThriXXX Technology;FreeTrack20;V160;;;13402;00AB248D535A7739E5C400 -28;tir2joy;FreeTrack20;V160;;;2202;001CF3931AEED44728F000 -79;TIRF4;FreeTrack20;V160;;;2203;004F6839BA86CBE7475000 -316;TNO;FreeTrack20;V160;;;20285;013CF4AF105AC7B7C59800 -110;ToCA Race Driver 2;FreeTrack20;V160;;;8102;006EF22848C883AA250700 -81;Toca Race Driver 3;FreeTrack20;V160;;;8101;005118E83C296C5EEE6E00 -290;Tom Clancy's H.A.W.X.;FreeTrack20;V170;;;1004;03ECAA4D48E85966FBAA00 -390;Tom Clancy's H.A.W.X. 2;FreeTrack20;V170;;;1007;03EF1B7583521C12406F00 -53;Torque Game Engine;FreeTrack20;V160;;;5301;00351B870166E14D541C00 -250;Total War;FreeTrack20;V160;;;1375;00FAE0702DB7A005CEFD00 -446;Tower Crane Simulator;FreeTrack20;V160;;;20670;01BEA0415AA1590240C000 -245;Tower I;FreeTrack20;V160;;;1325;00F59762ABAEA411402B00 -311;TPL Testing;FreeTrack20;V160;;;20260;0137AF436C07F556AA3A00 -415;trackd;FreeTrack20;V160;;;20580;019FB51F837F71D2B53200 -346;TrackMapper2;FreeTrack20;V160;;;2175;015A2AADF4868D09F43500 -242;TrainMaster;FreeTrack20;V160;;;20042;00F2BF26C1C37CB1EC8E00 -49;Trainz;FreeTrack20;V160;;;4701;0031F535362568C64B5C00 -441;TraumTek;FreeTrack20;V160;;;20650;01B902E0159A2B25890A00 -216;Turismo Carretera;FreeTrack20;V160;;;15801;00D85C44219E2BB76A6E00 -57;UK Rally Champion;FreeTrack20;V160;;;5701;0039F003505E80C5BA4500 -438;ULAN;FreeTrack20;V160;;;20645;01B6D49931402D5BD15900 -460;Underwater Navigation;FreeTrack20;V160;;;20715;01CCF2733124B2CB825400 -375;Unity 3D Plugin;FreeTrack20;V160;;;20430;0177AC7406DA8D3A932000 -177;Untitled 10tacle;FreeTrack20;V160;;;13701;00B1EBD1F9FFA6E6686200 -211;Untitled 3D People;FreeTrack20;V160;;;15501;00D37F9EA487AA42247F00 -66;Untitled Apportmedia;FreeTrack20;V160;;;6801;0042D5187BF69F378D7100 -178;Untitled Combat Flight Sim;FreeTrack20;V160;;;13801;00B266CCC6A8DBFECB9800 -187;Untitled Deep Silver;FreeTrack20;V160;;;14601;00BB23F9930F84C5769300 -71;Untitled G5 Software;FreeTrack20;V160;;;7301;00474929D76981E1A02B00 -105;Untitled Microsoft;FreeTrack20;V160;;;2308;0069DBD74AFE91D3024C00 -230;Untitled Research;FreeTrack20;V160;;;1075;00E6CA13538ACC57311300 -194;Untitled Ron E;FreeTrack20;V160;;;14902;00C29095124261E15DF100 -162;Untitled Sega of America;FreeTrack20;V160;;;12801;00A2A551CA58DE6F431100 -86;Untitled Simbin;FreeTrack20;V160;;;3902;0056A59CCCD19640F02800 -48;Untitled WorkShield;FreeTrack20;V160;;;4601;00308A50AB16142C431B00 -161;Untitled ZootFly;FreeTrack20;V160;;;12701;00A192B9918A967B93EE00 -357;UQO;FreeTrack20;V160;;;23085;0165C4249A2AACE457C100 -176;UVEG Machinery Simulator;FreeTrack20;V160;;;20024;00B00EC97C19220E86C200 -384;VAR;FreeTrack20;V160;;;20460;01802E6404E2093E335400 -72;VBS2;FreeTrack20;V160;;;7501;00484D56D30EBF26F9D300 -472;VBS2 2.0;FreeTrack20;V170;;;7505;1D51EB3616B3A44F05B900 -268;Vehicle Simulator (Quality Simulations);FreeTrack20;V160;;;5102;010C5B2715A74AAD11E400 -465;Vehicle Simulator Direction;FreeTrack20;V160;;;20735;01D1C190613C2659205600 -109;Vestibular Ocular Reflex;FreeTrack20;V160;;;20008;006DDB9B67D9FF7B794700 -40;Viper Arena;FreeTrack20;V160;;;3501;00280F44DDAE4E9C216100 -128;VIRTools Engine;FreeTrack20;V160;;;10801;0080121CF5C829C1B6B200 -293;Virtools Plugin;FreeTrack20;V160;;;20200;012513C5A0D1B2E663F300 -307;Virtual Driving;FreeTrack20;V160;;;20245;013304BB3175D4E525A600 -354;Virtual Heroes;FreeTrack20;V160;;;20375;01623EE91E8BE83AEF0100 -82;Virtual RC Racing;FreeTrack20;V160;;;8201;005210874C10ED78B92400 -24;Virtual Sailor;FreeTrack20;V160;;;5201;00189C82D267B22107AF00 -428;Virtual Shopper;FreeTrack20;V160;;;20610;01AC792408643886688500 -315;Virtual Supermarket;FreeTrack20;V160;;;20280;013B45049B1D1AAC1B1500 -483;VirtualiTeach;FreeTrack20;V160;;;20790;01E33372A29B77BE555500 -467;Vizard;FreeTrack20;V160;;;20745;01D31D33B1063E9CB33000 -212;VizRD;FreeTrack20;V160;;;20031;00D46259B91926FBE51000 -69;Void War;FreeTrack20;V160;;;10001;00450D16B44FE54E0DDE00 -464;VRPlayer;FreeTrack20;V160;;;20730;01D06AF3334F6C1327AB00 -244;VT08;FreeTrack20;V160;;;1275;00F429808701FF70751000 -279;VVVV Plugin;FreeTrack20;V160;;;20075;011799A485C311062E3A00 -314;VW Testing;FreeTrack20;V160;;;20275;013A70EEE8249EBB987D00 -286;Walkabout3d;FreeTrack20;V160;;;20125;011EB2F5E9B9AAD8422D00 -258;Wallbusters;FreeTrack20;V160;;;1450;01020B97F896261C609800 -419;War Thunder;FreeTrack20;V160;;;1878;01A3ED245C2D45BE12E100 -399;WAVES;FreeTrack20;V160;;;20515;018F3FD63467A115118800 -381;Welding Simulator;FreeTrack20;V160;;;2625;017D3BC378113A73449600 -32;West Racing;FreeTrack20;V160;;;1801;00207E5E89C98349BE5A00 -130;Whirlwind of Vietnam;FreeTrack20;V160;;;11101;0082CBED7E0405C616EF00 -450;Wikid FJ;FreeTrack20;V160;;;20685;01C242DF76E15A6D43C200 -324;Wings of Prey;FreeTrack20;V160;;;1877;014434CE29E832C5E1A200 -115;Wings of War;FreeTrack20;V160;;;7807;0073A1FD80161F0C641800 -70;World Racing 2;FreeTrack20;V160;;;7201;0046C49D1512D419B7F300 -219;WWII Battle Tanks: T-34 vs. Tiger;FreeTrack20;V160;;;11102;00DBC4D05E9E28F0BF6000 -235;X Motor Racing;FreeTrack20;V160;;;1150;00EBB738DA020969741600 -16;X-Cockpit for X-Plane;FreeTrack20;V160;;;2901;0010B24C9067FE0CA39100 -74;X-Plane;FreeTrack20;V160;;;7701;004A83FD2FD179E4E7B000 -117;X-Plane 6DOF Plugin;FreeTrack20;V160;;;10101;00751C3770B08B370D7000 -141;X-Plane Pilot View;FreeTrack20;V160;;;11301;008D5BA39ED0E94905F700 -39;X-Tower for X-Plane;FreeTrack20;V160;;;3001;00270FA7C9CD672252A000 -310;X1Alpha;FreeTrack20;V160;;;1825;0136A118B1F437F93D2D00 -55;X2: The Threat;FreeTrack20;V160;;;5501;0037C5189007314D35D600 -224;X3: Albion Prelude;FreeTrack20;V170;;;5502;157E7E101A708F8524E300 -189;Xyphoid;FreeTrack20;V160;;;14301;00BDEEB9961F6E08538800 -241;zedasoft F-35 Demo;FreeTrack20;V160;;;20041;00F1FB9C5D8A4AE8793600 -480;ZKT;FreeTrack20;V160;;;20780;01E0DF5AAC54B74772B300 -183;Zombie AA Research;FreeTrack20;V160;;;14201;00B775BD9BCC51E6276000 +1;18 Wheels of Steel: Haulin';FreeTrack20;V160;V;doc-uk;13601;000121F172F35116A02100 +2;1944 D-Day;FreeTrack20;V160;;;15701;00022E542A6A0575F05200 +497;2KMarinNEXT;FreeTrack20;V170;;;3425;0D614F6A0820D1EA8EE800 +3;3D Instructor;FreeTrack20;V160;;;20490;00034B0FC367116611B100 +4;3D Interactive;FreeTrack20;V160;;;20425;0004C6371D77135815A600 +505;3D Interieur Visualisation;FreeTrack20;V160;;;20815;01F9EDEE75DAC2968D9A00 +5;3d Nav;FreeTrack20;V160;;;20235;000579EC0E26932651EA00 +6;3D-Fahrschule Driving Simulator;FreeTrack20;V160;;;20020;000601075146E0E9625B00 +7;3ds Max;FreeTrack20;V160;;;8601;00077A32A1A7523A4DE700 +8;Aaaaa!;FreeTrack20;V160;;;1775;00085485D831DA62CA7E00 +9;Accessible Computer Games;FreeTrack20;V160;;;4301;000916BC07A2F9B35B6300 +10;Aces High II;FreeTrack20;V160;V;bash1;2701;000A4B798B7221A72E5800 +11;ADS;FreeTrack20;V160;;;20690;000BB25377780C8A894400 +12;Aerofly FS;FreeTrack20;V160;V;V4Friend;2025;000C3797169752CAB39A00 +13;Affineon;FreeTrack20;V160;;;20405;000D662B0374339635A000 +14;Air Battles: Sky Defender;FreeTrack20;V160;;;7003;000E7C822098630A2ED700 +15;Air Phobia;FreeTrack20;V160;;;20100;000F0108339B3E78525B00 +16;Air Traffic Control Tower;FreeTrack20;V160;;;3601;0010432C28637A8EF97400 +17;AirBook;FreeTrack20;V160;;;15201;0011D615A9C8430A201A00 +18;America's Army;FreeTrack20;V160;;;4101;00120BCF5753D98399E200 +19;America's Army 3;FreeTrack20;V170;;;14203;00133F3206BCEA252BB700 +20;ANAG 3D;FreeTrack20;V160;;;20250;0014E2D1D7780A72166300 +21;Apache: Air Assault;FreeTrack20;V160;V;paleta77;1875;001591D997A2D912AAA200 +22;Aprisoft Gartenplaner;FreeTrack20;V160;;;20014;0016F2F27A5762FA937A00 +23;Aprisoft Traumhaus Designer;FreeTrack20;V160;;;20013;00174655E792BB825B9300 +498;ARI;FreeTrack20;V160;;;20795;01F23FB9A61044E206E200 +24;ArmA;FreeTrack20;V160;V;EmBeES;10601;0018F2F27A57631A40F200 +25;ArmA 2;FreeTrack20;V170;V;V4Friend, Ronski;7502;0019EB3616B3A44F05B900 +26;ArmA 2 Operation Arrowhead;FreeTrack20;V160;V;vn88holden;0;001ABC224B7783DAF0D500 +27;ArmA 3;FreeTrack20;V170;;;7503;001BB69411ABD4E2B39900 +28;Armored Assault - Gold Edition;FreeTrack20;V170;;;1303;001CA7F7CAA00814ECA700 +29;Arvoch Alliance;FreeTrack20;V160;;;14908;001D318F8773BAE29A9300 +30;Arvoch Conflict;FreeTrack20;V160;;;14901;001E5C1FDE722DAE2BA900 +31;Auditory Displays for the blind;FreeTrack20;V160;;;20035;001F0FC9FF862F9D34BA00 +486;Autodesk;FreeTrack20;V160;;;20755;01E6953FA7F759AF33AC00 +32;AV Core Technology;FreeTrack20;V160;;;20016;00204655E791166FEB5300 +33;AVRS;FreeTrack20;V160;;;20340;0021231517525830F41D00 +482;B.O.M.B.;FreeTrack20;V160;;;3325;01E248ECCB81191AD49F00 +34;BAE Systems HILAS cockpit;FreeTrack20;V160;;;20019;00220D9C887FD88E98B300 +35;Battle of Britain (iENT);FreeTrack20;V170;;;1305;00230BA119195B701AED00 +36;Battle of Britain II - Wings of Victory;FreeTrack20;V160;V;Normalguy;7001;002452135882CA6419E200 +37;Battlecruiser;FreeTrack20;V160;;;6101;00257C822098728A442900 +38;Battlefield 2;FreeTrack20;V170;;;9601;0026B1560A2A7327659200 +39;Battlefield 2 Trauma Studios;FreeTrack20;V160;;;6501;002720C7529B733AE2EA00 +40;Battlefield 2142;FreeTrack20;V170;;;9602;00281C739AD3817FD43300 +41;Battleground Europe : World War II Online;FreeTrack20;V160;;;3301;0029F07957792CAD3DAF00 +42;Battleground Europe : WWII Online;FreeTrack20;V160;;;11201;002A985017330A844A1200 +43;Beckman Institute UIUC;FreeTrack20;V160;;;20012;002BB59DEFA8322A926A00 +44;Beyond The Red Line;FreeTrack20;V160;;;13301;002CE7A7FAA27424BA2A00 +45;BF2 (Unsupported Demo);FreeTrack20;V160;;;9651;002DC6371D86156AEB6000 +46;Big Scale Racing;FreeTrack20;V160;;;8301;002E4655E7A24ADDB99200 +47;Birds of Prey;FreeTrack20;V160;;;1601;002FBF8C4EAA57730B3200 +48;Birds of Steel;FreeTrack20;V160;;;1878;0030D7690F607233A21E00 +49;Boeing;FreeTrack20;V160;;;20351;0031044872BA630A033E00 +50;Boeing Demo;FreeTrack20;V160;;;20350;003228C57B369A37B13600 +51;Bomber Squadron;FreeTrack20;V160;;;1850;00338481733B9E32A83A00 +52;Brain-IT Group;FreeTrack20;V160;;;20050;0034E482F5772C9330B100 +53;Brothers In Arms;FreeTrack20;V160;;;13501;003503FB872CA8439D1F00 +82;C-Spine;FreeTrack20;V160;;;4901;00525FD692C188FB8B2D00 +54;C.A.R.S.;FreeTrack20;V170;;;2825;003698EFE2EB6EE8E11300 +55;C.U.B.;FreeTrack20;V160;;;20505;0037848174F986FD85F500 +56;CameraGripTools;FreeTrack20;V160;;;20150;003870A8B761FA524A4200 +57;Caterpillar Simulators;FreeTrack20;V160;;;23080;0039F52E4221742FA63100 +58;CCG Metamedia;FreeTrack20;V160;;;20009;003A6FA8A8DD86FE8BDB00 +59;CEWIT Immersive Cabin;FreeTrack20;V160;;;20370;003B90B5780C90078DEE00 +60;Chopper;FreeTrack20;V160;;;3150;003CC166C8632A32EA2300 +61;Clearbox;FreeTrack20;V160;;;20565;003D5C1FDE74279D1DB800 +62;CNKFsoft;FreeTrack20;V160;;;20495;003ED7690F6073187B0000 +487;Cognitics;FreeTrack20;V160;;;20760;01E715A96D19515BFC1500 +63;Colin McRae DiRT 2;FreeTrack20;V170;V;V4Friend;8107;003F7815C5379491C73300 +64;Colin McRae Rally 04;FreeTrack20;V160;;;8103;0040D13C2A843DA526A610 +65;Comanche;FreeTrack20;V160;;;2275;00414097C36A12BA32BA00 +66;Combat Flight Simulator 3;FreeTrack20;V160;V;V4Friend;2304;00420EC5F763AB21CA7310 +67;Combat Helo;FreeTrack20;V160;;;2001;004329DFA863FAE1EA7300 +68;Commandos Strike Force;FreeTrack20;V160;;;8801;0044C1BBF892DB037A7200 +69;Concept RS;FreeTrack20;V160;;;10701;004537971697736A72DA00 +70;Condor: The Competitive Soaring Simulator;FreeTrack20;V160;V;MicheleF;5901;004670A8B762DA623A1300 +71;Conflict Taiwan;FreeTrack20;V160;;;1950;0047D7690F6073399E2000 +72;Corys;FreeTrack20;V160;;;20550;0048157D78738A342A8D00 +73;Counter Strike;FreeTrack20;V160;;;12501;004953FE1E862AB73DA600 +74;Crane Simulator;FreeTrack20;V160;;;20048;004A6B62C6A7931972DA00 +75;Crashday;FreeTrack20;V160;;;5601;004BD6E585F893D933BA00 +76;Creanex Training Simulator;FreeTrack20;V160;;;20205;004CF478D277A40A929A00 +77;Creative Labs headset;FreeTrack20;V160;;;20018;004D348B1743E961FA6300 +78;Cross Racing Championship;FreeTrack20;V160;;;4801;004E20C763AB232B5E8900 +79;Crysis Mod;FreeTrack20;V160;;;1625;004F90B57839B231A24200 +80;Crystal Growth Simulation;FreeTrack20;V160;;;20029;005026F79742FB241A6200 +81;Crytek;FreeTrack20;V170;;;2775;0051D5F1EBBAD81C714600 +83;D2x-XL;FreeTrack20;V160;;;16001;00532E20237BEDABEB8A00 +84;Dark Horizons Lore;FreeTrack20;V160;;;7901;005487801A852AA7385200 +85;Dawn of Aces - Gold Edition;FreeTrack20;V170;;;1304;0055A9ED7700814190DE00 +86;Dawn of Aces II;FreeTrack20;V160;;;1302;00566925967C2BB0285500 +87;DBS WalkAndFollow;FreeTrack20;V160;;;2525;005770A8B77008BDE89200 +88;DCS: Black Shark;FreeTrack20;V170;V;EmBeES;1006;0058F688FC9B0556868F00 +89;DCS: A-10C Warthog (32 and 64 bit);FreeTrack20;V170;V;fabri91, Shadow;1003;0059B6DCD15F5A572F6500 +90;Dead Reckoning;FreeTrack20;V160;;;10401;005A4C2F6752F912D66200 +91;Delivery;FreeTrack20;V160;;;15901;005BF3E85B1A8534AE3400 +471;Demon Core;FreeTrack20;V160;;;3225;01D7D1DC6052A165A7AC00 +92;DiRT;FreeTrack20;V160;;;8104;005C72456F7523881F1800 +93;DiRT 3;FreeTrack20;V170;;;8108;005DABA016ED2DFBDF6F00 +94;Door3;FreeTrack20;V160;;;20665;005ED13C2A853DA82F6B00 +95;Down In Flames;FreeTrack20;V160;;;1025;005F29DFA873FB82A66000 +96;Driver Test;FreeTrack20;V160;;;20265;00609343487C3FAA429D00 +97;Driver's Republic;FreeTrack20;V160;;;14001;0061D24C3F8A3F9C33AB00 +98;DriveSim;FreeTrack20;V160;;;5001;0062DD7CC2B47830A14400 +99;Driving Simulator;FreeTrack20;V160;;;13001;00630AC67539AC3F9F3A00 +100;dSphere TBA;FreeTrack20;V160;;;2425;0064A2AE4981FB5389A300 +101;DTS;FreeTrack20;V160;;;20625;006505B37C12868B3E8500 +102;Dungeons and Dragons Online;FreeTrack20;V170;;;1575;0066BD4D4DDC6BB6818800 +103;DY Demo;FreeTrack20;V160;;;20345;006727D5047A15540F9D00 +104;EADS Testing;FreeTrack20;V160;;;20303;00680288709760D5512900 +504;EAFIT;FreeTrack20;V160;;;20810;01F8D2675ABC163E99B000 +105;Eagle Lander 3D;FreeTrack20;V160;;;11901;00697686E5A7B209C27900 +106;EasyVR;FreeTrack20;V160;;;20220;006A68292872FAC4588100 +107;ECA-Sindel;FreeTrack20;V160;;;20590;006BC5BEE479FD75FB8500 +508;Elite: Dangerous;FreeTrack20;V170;;;3475;0D93A9485EECA12E18BE00 +481;Embers of Caerus;FreeTrack20;V170;;;3275;0CCB4134258D7E10119E00 +108;EMS Simulations;FreeTrack20;V160;;;20390;006CA59E687D1589DE8500 +109;Enemy Engaged 2;FreeTrack20;V160;;;2102;006D010873EA635AEDC800 +110;Enemy Engaged: Commanche vs Hokum;FreeTrack20;V160;;;2101;006E157D789379636AED00 +111;Envision TE;FreeTrack20;V160;;;20320;006FD13C2A863CAF26AB00 +112;EON Reality;FreeTrack20;V160;;;20410;0070B6C6142771F82EE900 +113;eSigma;FreeTrack20;V160;;;20700;0071950F9AA60DAD2E9F00 +114;Euro Truck Simulator;FreeTrack20;V160;V;mamsa;13602;00721B4BFF8B3EA3296600 +115;EVE Online;FreeTrack20;V160;;;11801;0073F47CC377C2388DC900 +116;Eventology;FreeTrack20;V160;;;12201;0074849F8B469C2BAC3600 +117;EVOC-101 Training;FreeTrack20;V160;;;20038;00756925967D2088FC6200 +118;Evochron Alliance 2.0;FreeTrack20;V160;;;14904;00767A32A1A8735A022900 +119;Evochron Legends;FreeTrack20;V160;;;14906;0077D6E585F8B41A12BA00 +120;Evochron Mercenary;FreeTrack20;V160;V;Scavenger4711 ;14907;00783752FBC7B42B221A00 +121;Evochron Renegades;FreeTrack20;V160;;;14905;0079621E7763FB421A1300 +122;EZCA;FreeTrack20;V160;V;dennison ;2475;007A6DBB52F7B147510601 +125;F-22 Total Air War;FreeTrack20;V160;;;1750;007D20C79F475F0621DB00 +126;F-35 PTA;FreeTrack20;V160;;;20185;007E26F7977E96C0352100 +148;F-Trainer;FreeTrack20;V160;;;20615;0094C6371D8AFB8C3E9900 +123;F1 2011/2012;FreeTrack20;V170;;;8109;007B265ECD74893EA12900 +124;F1 Challenge 99-02;FreeTrack20;V160;;;4401;007CA15F278FB660C9D210 +127;FAAC;FreeTrack20;V160;;;20500;007F0F00F489118300C000 +128;Farmer Simulator 2009;FreeTrack20;V160;;;1725;0080926ED8A1EB628AB300 +129;Faros Driving Simulator;FreeTrack20;V160;;;8001;0081B1C6647A1EA839A800 +130;Faubert Lab Car Simulator;FreeTrack20;V160;;;20480;00822E542A7F2DB61F9700 +131;Ferrari Virtual Academy;FreeTrack20;V160;V;sosna1983 ;0;0083C0AF8C24B62D974000 +132;FIFA 09;FreeTrack20;V170;;;9002;0084288979C65B0DAA0D00 +133;Fighter Ace;FreeTrack20;V160;;;8401;0085E2D1D77D259837B700 +134;Fighter Ops;FreeTrack20;V160;;;9301;00860FC9FF8B23A033BA00 +135;Fighter Squadron: Screamin Demons Over Europe;FreeTrack20;V160;;;1675;00872E20237D259A27A600 +136;First Eagles, Wings Over Europe, Strike Fighters;FreeTrack20;V160;;;1101;0088311857638A73BB7E00 +469;Flight Gear;FreeTrack20;V160;;;12901;01D5D896C66B030606E000 +466;Flight Simulator 2002;FreeTrack20;V160;;;2302;01D21F7650E254B4514B00 +467;Flight Simulator 2004;FreeTrack20;V160;;;2303;01D3E91BAAB385B2362E00 +468;Flight Simulator X;FreeTrack20;V160;;;2305;01D41C31F42FAF32603600 +137;FlightGear;FlightGear;V110;V;V4Friend;0;0089054E8839A02FAB2F00 +138;Flyboys / Warbirds;FreeTrack20;V160;;;1301;008ABB5BF72C8934AB2B00 +139;Flyer;FreeTrack20;V160;;;1650;008BD1C9F27826AE2CA500 +140;Flying Tigers;FreeTrack20;V160;;;7002;008C91D997F29A930B0200 +141;FlyingGuns;FreeTrack20;V160;;;14801;008D7A32A1A882BAA28A00 +142;Ford Racing 3;FreeTrack20;V160;;;6901;008E27D5047C2BA62F5800 +143;Free Falcon 4.0;FreeTrack20;V160;;;1901;008F157D78A3B962E55000 +144;Free Falcon 4.0: Allied Force;FreeTrack20;V160;;;8901;0090656DD6793CA9325900 +145;Free Falcon 5;FreeTrack20;V160;V;V4Friend;1902;00911038C3AAB32590E900 +146;FreeSpace2;FreeTrack20;V160;;;13302;0092C8CDF8C2EA63496300 +147;FTAlpha;FreeTrack20;V160;;;20270;00936C69677F1D772AA900 +149;Full Out;FreeTrack20;V160;;;1701;009527D5047C31A0375800 +150;Future Pinball;FreeTrack20;V160;V;V4Friend;13101;00969343487E42B541AA00 +151;Game VR;FreeTrack20;V160;;;20325;009756BA018030B0355500 +152;GameLab;FreeTrack20;V160;;;20555;00985485D891DB23092200 +472;Games Farm;FreeTrack20;V160;;;3250;01D875C0981E627E5C7600 +153;Gamma;FreeTrack20;V160;;;1050;009921007D1B9D38A76F00 +503;Garry's Mod;FreeTrack20;V160;;;12503;01F74EEB71FA7F37856900 +483;Generic Robotics;FreeTrack20;V160;;;20750;01E3FE7B4F05872A415400 +475;Glider Sim;FreeTrack20;V160;;;20720;01DB42130C4B0620871C00 +154;Global Ground Support Deicing Simulation;FreeTrack20;V160;;;20330;009ACFE709237A3AA11F00 +155;GosNIIAS Sim Trainer;FreeTrack20;V160;;;20355;009BB78B06EC8A2DB81800 +156;Gothic 3;FreeTrack20;V160;;;14401;009C37971697B36AD32A00 +157;Grand Prix Legends;FreeTrack20;V160;;;6701;009D521358D3D933B96E01 +158;Grand Theft Auto: San Andreas;FreeTrack20;V160;;;7808;009E5F3D95777D3BA23700 +159;GRID;FreeTrack20;V160;V;LeapoEclipse ;8105;009FD8175F8D1D7C0D3800 +160;GSE Power Plant Simulation;FreeTrack20;V160;;;20044;00A0432C28C217BEF93300 +161;GT Legends;FreeTrack20;V160;V;TrickyDee ;3902;00A116BC08020581CA8200 +162;GTR;FreeTrack20;V160;;;3901;00A2FD6BFE39A881B85B00 +163;GTR2 EVO;FreeTrack20;V160;V;zild1221 ;0;00A34B0FC37B2198F96300 +164;Gun Commander;FreeTrack20;V160;;;2675;00A4E2D1D77E319FEE8600 +165;Half Life 2;FreeTrack20;V160;;;7806;00A556BA018130AF365500 +166;Halo;FreeTrack20;V160;;;3801;00A656BA018130AF3F9C00 +502;hapTEL;FreeTrack20;V160;;;20805;01F63ADE510A20446B6A00 +167;Hardware Control Simulator, Railway Electronics;FreeTrack20;V160;;;20705;00A7F3E85B1A8930B42F00 +168;Harrier Attack II;FreeTrack20;V160;;;1175;00A8F2F27A57D20A940900 +499;Harry's Hard Choices Interactive;FreeTrack20;V160;;;20800;01F33A21BAE3DB6D48A000 +169;HAWX;FreeTrack20;V160;V;EmBeES ;0;00A9D615A9C8B088717000 +170;Herissons (Paris France);FreeTrack20;V160;;;20001;00AAEA1CBED8C20B430B00 +171;HOBI;FreeTrack20;V160;;;20335;00ABB253777F1779168900 +172;HoverAssault;FreeTrack20;V160;;;5303;00AC521358E3AA832A4000 +173;HPC;FreeTrack20;V160;;;20600;00AD0FC9FF8D0A7CEF9500 +174;HPG Tracking;FreeTrack20;V160;;;20255;00AE0288A1879D98930900 +175;HTW;FreeTrack20;V160;;;20630;00AF26F797911901C22C00 +176;Huawei Software;FreeTrack20;V160;;;20660;00B04655E8030A733AB300 +177;HueSpace;FreeTrack20;V160;;;20510;00B1231517C44960FB6300 +178;Hyper Vision;FreeTrack20;V160;;;15101;00B2DB242B657D43B32300 +179;iAmFootball;FreeTrack20;V160;;;1250;00B3B59DEFAAAFDB301A00 +180;id Research;FreeTrack20;V170;;;2950;00B4E723B873D7FC87D700 +181;IESA;FreeTrack20;V160;;;20037;00B5157D78D0E840AD7100 +182;IL-2 Cliffs of Dover;FreeTrack20;V160;V;V4Friend;0;00B6282282095F00521000 +183;IL-2 Forgotten Battles, ACE, Pacific Fighters;FreeTrack20;V160;V;Glenn;1001;00B722FD79137100621100 +484;IL-2 Sturmovik: Battle of Stalingrad;FreeTrack20;V170;;;1008;03F04D5368D1FD2DF2AE00 +184;Illumina;FreeTrack20;V160;;;1350;00B8054E8B39A33DB02400 +185;ILP;FreeTrack20;V160;;;20310;00B9F07957801789C9A600 +186;Imagine 3D ATC Tower Simulation;FreeTrack20;V160;;;20032;00BAEF7A8F4B8812B95300 +187;In Touch Technologies Inc.;FreeTrack20;V160;;;20006;00BB84817A3A5124B23D00 +188;Inglobe;FreeTrack20;V160;;;20360;00BCE7A7FAA27B2DA82700 +189;Innovatec Simulator;FreeTrack20;V160;;;20036;00BD22FD7935B23DB82C00 +190;Insurgency;FreeTrack20;V160;;;9401;00BEB6C61427B3EA744B00 +191;Intific;FreeTrack20;V160;;;20655;00BF2BCA747F2AA8309D00 +192;iRacing;FreeTrack20;V160;V;vn88holden ;14101;00C0103AF1AA730A236900 +193;IREQ Robotic Camera Control;FreeTrack20;V160;;;20027;00C10448E0E8618521EB00 +194;ISIC;FreeTrack20;V160;;;20680;00C2DEE3582F8F217E0B00 +506;ITCL;FreeTrack20;V160;;;20820;01FAD19412681DC9CC6100 +195;IVD Online;FreeTrack20;V160;;;20535;00C390B57E1D7DDD883D00 +196;J.J. Keller and Associates;FreeTrack20;V160;;;20002;00C4E482F57FE77CF46300 +197;Janes F18;FreeTrack20;V160;;;9001;00C55F3D9577802AAF2E00 +198;Javal Ent.;FreeTrack20;V160;;;2650;00C622FD7A28BA2FAEEA00 +199;JC Demo;FreeTrack20;V160;;;20470;00C70AC67B0A630D9B3900 +200;Jet Thunder;FreeTrack20;V160;;;4501;00C82100801FA4EA9A3500 +201;Jetfighter V;FreeTrack20;V160;;;2501;00C9F52E42217B33A63200 +202;JFIST;FreeTrack20;V160;;;20560;00CAC932727C0F8D208600 +203;John Deere Vehicle Simulator;FreeTrack20;V160;;;20175;00CB29DFA8D3FA92A66000 +204;Jump to Lightspeed;FreeTrack20;V160;;;6001;00CCC166C8D3FA12E52400 +205;Jumpgate;FreeTrack20;V160;;;15001;00CD26F797B32A63E99200 +206;Jumpgate Evolution;FreeTrack20;V170;;;15002;00CE5936D4F93DCE0CE700 +207;KAF Keymapper;FreeTrack20;V160;;;3101;00CF934348830E87EB8300 +476;KAI FLight Simulator;FreeTrack20;V160;;;20725;01DCC522132A5C01EDE500 +208;Key Macro View;FreeTrack20;V160;;;12001;00D016BC08431B1EF90100 +209;kiwi.vg;FreeTrack20;V160;;;20395;00D1409A430AB33633E900 +210;L-3;FreeTrack20;V160;;;20465;00D2F885EFA8DE67878B00 +211;L-3 Communications;FreeTrack20;V160;;;20051;00D3D6E585F92F765E7800 +212;Lionhead MGS Game Research;FreeTrack20;V160;;;15301;00D4C1BBF9227B238AE200 +213;Live For Speed;FreeTrack20;V160;V;zild1221 ;7101;00D528228526A833521300 +214;Live for Speed S2;FreeTrack20;V160;;;11601;00D63752FBC8235B923500 +218;Lock-On: Modern Air Combat;FreeTrack20;V160;;;1002;00DAAC156D903C993B6200 +215;Lockheed Martin Littoral Combat Ship simulator;FreeTrack20;V160;;;20025;00D771ED5E802A9827A000 +216;Lockheed Martin Prepar3D;SimConnect;V130;V;elelbe ;0;00D8D615A9C8F36932AA00 +217;LockOn: Flaming Cliffs 2;FreeTrack20;V170;V;EmBeES ;1005;00D9AFB0D279F3A6F72200 +219;London NHS;FreeTrack20;V160;;;20640;00DB2E2023832BA123A100 +220;Lore (Dark Horizons);FreeTrack20;V160;;;5302;00DCF478D27833DB62D500 +221;Love;FreeTrack20;V160;;;3125;00DD71ED5E802AAB214800 +222;Lucid Engine;FreeTrack20;V160;;;10501;00DE71ED5E803098259C00 +223;M4 Tank Platoon;FreeTrack20;V160;;;1306;00DFDCC441A8E036320900 +224;Mach 1;FreeTrack20;V160;;;2575;00E0231518130942466000 +225;ManuVAR;FreeTrack20;V160;;;20455;00E153FE1E901CB0448800 +226;MaqSIM4;FreeTrack20;V160;;;20026;00E28F54A207D29B611700 +227;Mech Tactical Sim;FreeTrack20;V160;;;9501;00E3F3E85B1A8E34A53300 +228;Mechwarrior Online;FreeTrack20;V170;;;3025;00E414954226DB5D8CE200 +229;Medical Image Visualization;FreeTrack20;V160;;;20295;00E59343488532A5359B00 +230;Meggitt Defense Systems;FreeTrack20;V160;;;20045;00E6926ED9122AB22AF300 +231;MetaVR;FreeTrack20;V160;;;20545;00E7C5BEE48120A8308800 +232;Meteoroid Maze;FreeTrack20;V160;;;13003;00E8F079578430AD2EB200 +233;MeVEA;FreeTrack20;V160;;;2250;00E9D24C3F933289028700 +234;Micro Flight;FreeTrack20;V160;V;V4Friend;5101;00EABA89D078439932EA00 +235;Microsoft ESP;FreeTrack20;V160;;;2306;00EB0AC67E30A63BA53F00 +236;Microsoft Flight;FreeTrack20;V170;V;V4Friend;2307;00ECAFBC54959539C51500 +237;Microsoft Flight Simulator 3;FreeTrack20;V160;V;V4Friend;0;00ED5909437D36963EA810 +238;Microsoft FS2002/2004;FSUIPC;V130;V;V4Friend;0;00EE44958F34992CB43A00 +239;Microsoft FSX;SimConnect;V130;V;V4Friend;0;00EFF478D278437A73AA00 +240;Microsoft Train Simulator;FreeTrack20;V160;;;7805;00F00449225A439A13FB00 +494;MiddleVR;FreeTrack20;V160;;;20785;01EE1227DF43CA90C26100 +241;Mig Alley;FreeTrack20;V160;;;1501;00F17686E5A83289CDA700 +242;Mimik Vehicle Simulator;FreeTrack20;V160;;;20585;00F2AB1D58A8E35A531A00 +243;Miner Wars;FreeTrack20;V160;;;2550;00F3C5BEE48124A234A400 +244;MKMapper Keymapper;FreeTrack20;V160;;;2201;00F487801A8E14822EA200 +245;ModelSim;FreeTrack20;V160;;;20540;00F544958F3A9A1FB11A00 +246;Morgan State University;FreeTrack20;V160;;;20010;00F65909437D3CA5339A00 +247;Motor Company;FreeTrack20;V160;;;11501;00F70288F37A629A7DD700 +248;Motorsport Simulators;FreeTrack20;V160;;;4201;00F8F52E42217E3DA63B00 +249;Mouse Emulation;FreeTrack20;V160;;;8501;00F9950F9A8E29B93A9700 +250;MS World Tour Kart 2004;FreeTrack20;V160;;;6601;00FA9F819CA27F10591600 +251;MSN Virtual Earth;FreeTrack20;V160;;;2309;00FBF47CC37842091DC900 +252;mTBI Balance;FreeTrack20;V160;;;20420;00FC72456F9E0E78145800 +253;NASA Crew Exploration Vehicle;FreeTrack20;V160;;;20017;00FD028900985FA5501A00 +254;NASCAR Heat;FreeTrack20;V160;;;2602;00FE311857E10880B84100 +255;NASCAR Racing 2003 season;FreeTrack20;V160;;;7804;00FFDE661F6D920B87FC10 +256;NASCAR SimRacing;FreeTrack20;V160;;;6201;01004098708870D761A500 +257;NecroVisioN;FreeTrack20;V160;;;15601;0101621E77F2EA830A8100 +258;NetKar Pro;FreeTrack20;V160;V;sosna1983 ;10901;01028C3958334A5169A300 +259;Nitro Stunt Racing;FreeTrack20;V160;;;13901;0103C0AF9428B82DA5ED00 +260;North Eastern University;FreeTrack20;V160;;;20003;0104A2AE4823BB7449DE00 +261;Novint;FreeTrack20;V160;;;2725;01051C76F8137B823A4300 +262;NVH Sound Simulator;FreeTrack20;V160;;;20695;010655A2AA93158DDE9500 +479;OHJCH;FreeTrack20;V160;;;20740;01DF992E6C0DA43A703600 +263;OMSI Bus Simulator;FreeTrack20;V160;V;Thiago ;2225;0107F47CC37861A9606600 +264;Onadime - Realtime Animation;FreeTrack20;V160;;;20049;010853FE1E9229A3339B00 +265;Open Falcon 4.5;FreeTrack20;V160;V;muplex ;0;0109B1C664832D9B385500 +266;Operation Air Assault 2;FreeTrack20;V160;;;5401;010ABB5BF72C9238973B00 +267;Operation Flashpoint 2 (inactive);FreeTrack20;V160;;;7601;010BD1C9F2812A9A399400 +268;Operation Flashpoint(r): Dragon Rising(tm);FreeTrack20;V170;;;8106;010C3328780E1322676100 +269;OptiMetrics;FreeTrack20;V160;;;20011;010D55A2AA942FB9288F00 +270;OpusFSX;FreeTrack20;V160;;;3175;010E1C76F8238B72D7C100 +271;Orbiter 2005 Plug-In;FreeTrack20;V160;;;10301;010F87801A903B9736A600 +272;Orbiter 2006;FreeTrack20;V160;V;Ripley;10303;0110D24C3F953F9526BA00 +273;Orbiter 2006 Plug-In;FreeTrack20;V160;;;10302;0111054E913F9931B72000 +274;Oryx Vehicle Simulators;FreeTrack20;V160;;;20028;0112C8CDF952EBA4763100 +275;Outer Conflict: Frontiers;FreeTrack20;V160;;;1900;01136C6967883EAA23AB00 +276;Over Flanders Fields;FreeTrack20;V160;V;Summelar ;2325;0114A59E68873E9B315210 +277;PanoPro;FreeTrack20;V160;;;20525;0115B6C61428231A23E900 +278;Paraworld;FreeTrack20;V160;;;14501;0116656DD6832BB62EB000 +279;Phoenix R/C;FreeTrack20;V160;;;3075;0117B6C61428238A334B00 +280;Pivot Maritime;FreeTrack20;V160;;;20365;01187686E5A8628AB2AA00 +281;PlanetSide 2;FreeTrack20;V170;;;6002;0119BB34B53FDC5C5AAF00 +474;PlanetSide 2 M.E.;FreeTrack20;V160;;;6003;01DA321EF31DA48C159A00 +282;Pointman;FreeTrack20;V160;;;7525;011ACFE70923833D9B2B00 +283;Power Driving Simulator;FreeTrack20;V160;;;20675;011BB78B06EC932DBC2F00 +470;Prepar3D;FreeTrack20;V160;;;20440;01D6DA768CE8AA43D8DC00 +284;Priston Tale;FreeTrack20;V160;;;9701;011C849F9642A030AC3600 +285;Project Reality (BF2 Mod);FreeTrack20;V160;;;9201;011D3C2C1C922CB239A800 +286;Project Torque (Invictus);FreeTrack20;V160;;;4802;011E612F28540B52797100 +287;Project X;FreeTrack20;V160;;;20022;011FE9D85E4842DA439900 +288;Quanser;FreeTrack20;V160;;;20435;0120950F9A922FA535A500 +289;QuantaDyn;FreeTrack20;V160;;;20575;012199BB5C9433A739B600 +290;Quest 3D Xframe Plugin;FreeTrack20;V160;;;20043;0122FD6BFE39A923C98200 +291;Quest3D;FreeTrack20;V160;;;1425;01234B0FC38542AB3BB700 +292;Quest3D - CINEACT integration;FreeTrack20;V160;;;20040;0124A15F28340AB3CA9000 +303;R-concept X (AdrenalinStorm);FreeTrack20;V160;;;9101;012F72456F83E6993AA600 +293;R.U.D.O. Tools;FreeTrack20;V160;;;20039;0125612F287FB9BEA76E00 +294;RACE (the WTCC game);FreeTrack20;V160;;;3904;01263C2C1C94FA86146300 +295;RACE 07, RACE, GTR 2;FreeTrack20;V160;V;zild1221, TrickyDee ;3903;0127C0AF9800870056FD00 +296;RaceOn;FreeTrack20;V160;V;zild1221 ;0;0128621E7832AA82388200 +297;Racer;FreeTrack20;V160;;;2401;01296D2D103862E932EA00 +298;Racer S;FreeTrack20;V160;;;20030;012AEA1CBED961CA52CB00 +490;RaceRoom Racing Experience;FreeTrack20;V160;;;3905;01EA9124F663AF03BBC500 +299;Rail Simulator 1;FreeTrack20;V160;;;1550;012BB253778929A0395900 +300;Railway Work Simulator;FreeTrack20;V160;;;20225;012C91D998B1E9933B9100 +301;RailWorks 2;FreeTrack20;V160;;;2750;012D3919C4972D9D299000 +507;RailWorks 5 (TS2014);FreeTrack20;V160;;;1551;01FB8B5232CB1502C95A00 +302;Raydon Driving Simulator;FreeTrack20;V160;;;3701;012E5485D941DBE2FB5300 +304;Real Time Visual;FreeTrack20;V160;;;9901;0130B1C664862297365500 +305;RealFlight;FreeTrack20;V160;;;4001;0131AC6E87892E993A8B00 +306;Reality Manager;FreeTrack20;V160;;;20046;0132DB242B65872FA42A00 +307;RealWorld;FreeTrack20;V160;;;20215;0133B59DEFA9322A727800 +308;Red Baron 3D;FreeTrack20;V160;;;1125;0134C6371D96349CEB7A00 +309;Red Orchestra: Heroes of Stalingrad;FreeTrack20;V170;;;12602;013521F9121056CD997300 +310;Red Orchestra: Ostfront;FreeTrack20;V170;;;12601;01369A9A2BE97252BB9000 +311;Redline Monitor;FreeTrack20;V160;;;20210;01373752FBC8831A72AA00 +312;REFLEX XTR;FreeTrack20;V160;;;2150;0138054E94127D14881300 +313;Remote Presence;FreeTrack20;V160;;;20710;01399BC3BDA93229D2BB00 +314;rFactor;FreeTrack20;V160;V;V4Friend;7401;013AEF7A8F4B8AA0495200 +315;rFactor Pro;FreeTrack20;V170;;;7403;013B175198D74BE8E89600 +316;rFactor2;FreeTrack20;V170;;;7402;013CBFF3A86D34DA24C000 +317;Richard Burns Rally;FreeTrack20;V160;V;zild1221;3401;013D42868B339A31A73C10 +318;RidingStar;FreeTrack20;V160;;;1475;013E3919C497359826A700 +319;Rig N Roll;FreeTrack20;V160;;;9801;013FD1C9F284239CE68100 +320;Rio Tinto Resource Development;FreeTrack20;V160;;;20033;01401039831B5EC8D31900 +321;Rise of Flight;FreeTrack20;V160;V;Seborgarsen ;11401;0141AA71218335A51F5100 +322;Rise: The Vieneo Province;FreeTrack20;V160;;;6301;0142DEE3582F9837A82D00 +323;Rising Conflicts;FreeTrack20;V160;;;12101;014384818335A439B12F00 +492;RITS;FreeTrack20;V160;;;20775;01ECEE745B83DD3A0DBE00 +324;Road Legends;FreeTrack20;V160;;;1876;0144379716986369A2E600 +325;Rogue Space;FreeTrack20;V160;;;3050;014588F5872C9C30ABE900 +326;Rogue Warrior;FreeTrack20;V160;;;14202;0146432C2973D9D45A8E00 +327;ROV Sim;FreeTrack20;V160;;;20530;0147FA04BD27891D9ADD00 +328;Rowan's Battle Of Britain;FreeTrack20;V160;;;1502;014821008829A72CB4F300 +329;RSD Demo;FreeTrack20;V160;;;2050;0149BF8C4EAA5871A85D00 +330;RTMS Crane Sim;FreeTrack20;V160;;;20400;014AC93272841D91205200 +331;RTT DeltaGen Plugin;FreeTrack20;V160;;;20195;014B90B5871B8DDD7D3400 +332;Sail Simulator 5;FreeTrack20;V160;;;1975;014CE2D1D78A1D9A3B6300 +333;Sailors of the Sky;FreeTrack20;V160;;;10201;014D17BE02961FAF3AB100 +334;Santa Cruz Watermill;FreeTrack20;V160;;;20290;014E88F5881EA32FA7E900 +335;SCANeR Studio Plugin;FreeTrack20;V160;;;20445;014FA2AE4870F861E9A100 +336;SEGA Demo;FreeTrack20;V160;;;2075;015016BC08C117F1163000 +337;Seven-G;FreeTrack20;V160;;;2350;01510F00F49635B822A200 +338;SFSPC;FreeTrack20;V160;;;2801;0152F885EFA9400981B700 +339;Ship Simulator 2006;FreeTrack20;V160;;;5002;015329DFA9638AA2C66100 +340;Ship Simulator 2008;FreeTrack20;V160;V;djj3ff ;5003;01545213599339B3D52100 +341;Shiphandling Simulator;FreeTrack20;V160;;;20570;01553FD0FC9D8B37AD3700 +342;Shooting Simulator;FreeTrack20;V160;;;20047;0156F2F27A58827A63DA00 +343;SIA Games;FreeTrack20;V160;;;20015;0157926ED970685DA8D200 +344;Silent Wings;FreeTrack20;V160;;;8701;0158D615A9C96309C24A00 +345;SilverHat;FreeTrack20;V160;;;12401;0159D8175F99349F3F9600 +346;Simax Simulator;FreeTrack20;V160;;;20021;015AAC156D9736A331AD00 +347;Simball 4D;FreeTrack20;V160;;;20315;015BD6E585F99349F2AA00 +348;Simbionix;FreeTrack20;V160;;;20485;015CE7A7FAA28528AE1D00 +349;SimCreator;FreeTrack20;V160;;;20520;015D3752FBC8935B001A00 +350;Simlog Personal Simulator;FreeTrack20;V160;;;20635;015E42868C33A435B53100 +351;SimQuest immersion system;FreeTrack20;V160;;;20023;015F6C69678C32A30FAE00 +352;SimSol;FreeTrack20;V160;;;20034;01602315187389E0FB5300 +491;Simumak;FreeTrack20;V160;;;20770;01EB119629980784DCE600 +353;Sirocco Racing;FreeTrack20;V160;;;5801;01612BCA748925A6369A00 +354;Sky God: Military Freefall;FreeTrack20;V170;;;1526;01622C0104385FD1C44400 +355;Soft fx Demo;FreeTrack20;V160;;;2125;01632E20238A2B99335200 +356;Source Engine (Half-Life 2);FreeTrack20;V160;;;12502;0164E482F58829A739A600 +357;Space Shuttle Mission 2007;FreeTrack20;V160;V;purewhitewings ;1225;0165662B03863D912F9700 +358;SRI;FreeTrack20;V160;;;20620;01663FD0FC9D8B218D8100 +359;Stanford University;FreeTrack20;V160;;;20004;0167CE35BAF9933A62AA00 +500;Star Citizen;FreeTrack20;V170;;;3450;0D7AF4CE4E343EC6B4A200 +360;Starshatter;FreeTrack20;V160;;;6401;0168F079578A3F9A3BB600 +361;Steel Beasts 2;FreeTrack20;V160;;;11703;0169DCC441A9443A831A00 +362;Steel Beasts Pro;FreeTrack20;V160;;;11701;016A8F54A20833CAA23900 +363;Steel Beasts Pro Personal;FreeTrack20;V160;;;11702;016BF3E85B1A9443A73000 +364;Stoked Rider;FreeTrack20;V160;;;14701;016CC166C963EA32997300 +365;Storm of War: the Battle of Britain;FreeTrack20;V170;;;11001;016D8F54A68B71F25D0200 +495;STRAFT;FreeTrack20;V160;;;3375;01EF1329E014ADF98D6B00 +366;Stride;FreeTrack20;V170;;;2310;016EC784B21E4B21984400 +367;STS Driving Simulator;FreeTrack20;V160;;;20300;016FA59E688B1C89DE7600 +368;Sunaerosys;FreeTrack20;V160;;;20475;01700449831AF28973EB00 +369;Superkarting;FreeTrack20;V160;;;14903;0171DE661F6D973FA41F00 +370;SuperX Research;FreeTrack20;V160;;;15401;0172BA89D078A45A021A00 +371;SWRI Demo;FreeTrack20;V160;;;20230;01730AC6841E9512561000 +372;Syncon Robot Control;FreeTrack20;V160;;;20415;0174C1BBF9937B12DB5200 +373;Synergy Simulation;FreeTrack20;V160;;;20595;0175926ED9736B220B8200 +374;T and TS Corp.;FreeTrack20;V160;;;20005;017617BE0297DDA73CA600 +375;Take On Helicopters;FreeTrack20;V170;;;7504;0177513CB40C0623B96A00 +376;Target: Korea;FreeTrack20;V160;;;1201;0178F52E4221852FA43300 +377;Target: Rabaul;FreeTrack20;V160;;;1202;0179E9D85E4881CA736900 +378;Targeting Demo;FreeTrack20;V160;;;13002;017AAB1D58A952DAA2F900 +379;TD Demo;FreeTrack20;V160;;;1925;017BC5BEE488FE54139700 +489;TeachLive;FreeTrack20;V160;;;20765;01E905245B5AC5484FC100 +380;Telepresence;FreeTrack20;V160;;;20450;017CF478D278B33B02DA00 +381;Tenstar Simulator;FreeTrack20;V160;;;20605;017D318F88A2EA62DBA200 +382;Test Drive Unlimited;FreeTrack20;V160;;;13201;017E6F2699559730A84000 +501;The Crew;FreeTrack20;V170;;;1009;03F1F534E94F4834D9B100 +488;The Gallery;FreeTrack20;V160;;;3350;01E8CE152EDE5FFD267700 +383;The Sky Gods;FreeTrack20;V170;;;1525;017FDFF782DCCEEA27C200 +384;theHunter;FreeTrack20;V170;;;2375;0180BFF3A86D34DA24C000 +385;thriXXX HII 3D;FreeTrack20;V160;;;13403;0181FA04BD27AB36B62700 +386;thriXXX Jenna;FreeTrack20;V160;;;13401;01829F819CA2A625AB2800 +387;ThriXXX Technology;FreeTrack20;V160;;;13402;0183F47CC378B35B526900 +388;tir2joy;FreeTrack20;V160;;;2202;018487801AB532A7FE9C00 +389;TIRF4;FreeTrack20;V160;;;2203;0185311858418870E77000 +390;TNO;FreeTrack20;V160;;;20285;01861AAF6870A853D64900 +391;ToCA Race Driver 2;FreeTrack20;V160;;;8102;0187FFE9E886F286297910 +392;Toca Race Driver 3;FreeTrack20;V160;;;8101;01884098D36972B551A900 +393;Tom Clancy's H.A.W.X.;FreeTrack20;V170;V;EmBeES ;1004;0189AA4D48E85966FBAA00 +394;Tom Clancy's H.A.W.X. 2;FreeTrack20;V170;;;1007;018A1B7583521C12406F00 +395;Torque Game Engine;FreeTrack20;V160;;;5301;018BC0AF9A2EB62CAB3300 +396;Total War;FreeTrack20;V160;;;1375;018C72456F8529AA2CA400 +397;Tower Crane Simulator;FreeTrack20;V160;;;20670;018D03FB9929B034A7D900 +398;Tower I;FreeTrack20;V160;;;1325;018E662B03873CA731A400 +399;TPL Testing;FreeTrack20;V160;;;20260;018F849F9A2083DC8C2C00 +400;trackd;FreeTrack20;V160;;;20580;019053FE1EB72DA3329D00 +401;TrackMapper2;FreeTrack20;V160;;;2175;0191CE35BAF9A31A61FA00 +402;TrainMaster;FreeTrack20;V160;;;20042;01925C1FDE852D9925B400 +403;Trainz;FreeTrack20;V160;;;4701;0193D1C9F2862C9630A100 +404;TraumTek;FreeTrack20;V160;;;20650;0194A2AE4883EA645A2100 +405;Turismo Carretera;FreeTrack20;V160;;;15801;01956F2699559740A73500 +406;UK Rally Champion;FreeTrack20;V160;;;5701;019679EC0E28B196522A00 +407;ULAN;FreeTrack20;V160;;;20645;01974ADE68E16780D97A00 +473;Underwater Navigation;FreeTrack20;V160;;;20715;01D9FE2B94FB03772DE200 +408;Unity 3D Plugin;FreeTrack20;V160;;;20430;0198D24C3F9B3B9C31BF00 +409;Untitled 10tacle;FreeTrack20;V160;;;13701;0199FFE9E886F28728AA00 +410;Untitled 3D People;FreeTrack20;V160;;;15501;019A6925968D38AD23A900 +411;Untitled Apportmedia;FreeTrack20;V160;;;6801;019B3C2C1C9728B738B700 +412;Untitled Combat Flight Sim;FreeTrack20;V160;;;13801;019CA59E688D36AA28A600 +413;Untitled Deep Silver;FreeTrack20;V160;;;14601;019D656DD68838B836AD00 +414;Untitled G5 Software;FreeTrack20;V160;;;7301;019E318F88B37AC23BA300 +415;Untitled Microsoft;FreeTrack20;V160;;;2308;019FA15F28739BA32A9300 +416;Untitled Research;FreeTrack20;V160;;;1075;01A07686E5A8B2DA924A00 +417;Untitled Ron E;FreeTrack20;V160;;;14902;01A14ADE68E38AB28B9300 +418;Untitled Sega of America;FreeTrack20;V160;;;12801;01A27A32A1A972DA528A00 +419;Untitled Simbin;FreeTrack20;V160;;;3902;01A36C69678E37AA27AD00 +420;Untitled WorkShield;FreeTrack20;V160;;;4601;01A442868E38AB32BA3600 +421;Untitled ZootFly;FreeTrack20;V160;;;12701;01A5348B1863AA527A6300 +422;UQO;FreeTrack20;V160;;;23085;01A67C822099A187FE3600 +423;UVEG Machinery Simulator;FreeTrack20;V160;;;20024;01A73118585257A0F63100 +424;VAR;FreeTrack20;V160;;;20460;01A8950F9A97FA96FD2E00 +425;VBS2;FreeTrack20;V160;;;7501;01A999BB5C990099FCBF00 +485;VBS2 2.0;FreeTrack20;V170;;;7505;1D51EB3616B3A44F05B900 +426;Vehicle Simulator (Quality Simulations);FreeTrack20;V160;;;5102;01AA0FC9FF9B1FA134A900 +478;Vehicle Simulator Direction;FreeTrack20;V160;;;20735;01DEB88CF58E570F1CEF00 +427;Vestibular Ocular Reflex;FreeTrack20;V160;;;20008;01AB3919C49B31A731A200 +428;Viper Arena;FreeTrack20;V160;;;3501;01AC6F2699559934A53100 +429;VIRTools Engine;FreeTrack20;V160;;;10801;01AD1AAF68905881EB5300 +430;Virtools Plugin;FreeTrack20;V160;;;20200;01AE03FB9B23AB43A42900 +431;Virtual Driving;FreeTrack20;V160;;;20245;01AF99BB5C9927B83FB700 +432;Virtual Heroes;FreeTrack20;V160;;;20375;01B0621E78732B732AE200 +433;Virtual RC Racing;FreeTrack20;V160;;;8201;01B16D2D1038A36A23DA00 +434;Virtual Sailor;FreeTrack20;V160;;;5201;01B25F3D95778C32B33D00 +435;Virtual Shopper;FreeTrack20;V160;;;20610;01B3B78B06EC9927B73E00 +436;Virtual Supermarket;FreeTrack20;V160;;;20280;01B4849F9C39A931AD2800 +496;VirtualiTeach;FreeTrack20;V160;;;20790;01F062AE1CAB33B52D0700 +480;Vizard;FreeTrack20;V160;;;20745;01E0C1F20A79D7C0561300 +437;VizRD;FreeTrack20;V160;;;20031;01B55485D9825BF1D8AB00 +438;Void War;FreeTrack20;V160;;;10001;01B65C1FDE872AA1206600 +477;VRPlayer;FreeTrack20;V160;;;20730;01DD6787E57245201D5000 +439;VT08;FreeTrack20;V160;;;1275;01B7B78B06EC9912750200 +440;VVVV Plugin;FreeTrack20;V160;;;20075;01B8B1C6648A138C205500 +441;VW Testing;FreeTrack20;V160;;;20275;01B9AC6E878D205822AA00 +442;Walkabout3d;FreeTrack20;V160;;;20125;01BA2822901E9E39932F00 +443;Wallbusters;FreeTrack20;V160;;;1450;01BB88F58C1EA127A83F00 +444;War Thunder;FreeTrack20;V160;;;0;01BC17BE029A1FB8ED9600 +445;WAVES;FreeTrack20;V160;;;20515;01BD05B38FFE89008B8B00 +446;Welding Simulator;FreeTrack20;V160;;;2625;01BE348B188319D229B300 +447;West Racing;FreeTrack20;V160;;;1801;01BF91D999022A33B62000 +448;Whirlwind of Vietnam;FreeTrack20;V160;;;11101;01C0054E9935A03AAF3200 +449;Wikid FJ;FreeTrack20;V160;;;20685;01C19BC3BDA98269B25A00 +450;Wings of Prey;FreeTrack20;V160;V;V4Friend;1877;01C25909438736A133AC00 +451;Wings of War;FreeTrack20;V160;;;7807;01C34B0FC38B36B42FB610 +452;World Racing 2;FreeTrack20;V160;;;7201;01C41AAF68A2BA836AAE00 +453;WWII Battle Tanks: T-34 vs. Tiger;FreeTrack20;V160;;;11102;01C5432C29C257F1963100 +454;X Motor Racing;FreeTrack20;V160;;;1150;01C669259690E98629A900 +458;X-Cockpit for X-Plane;FreeTrack20;V160;;;2901;01CA1C76F8BF4852999300 +459;X-Plane (32 and 64 bit);FreeTrack20;V160;V;EmBeES ;7701;01CB3FD0FC9D90FB943300 +460;X-Plane 6DOF Plugin;FreeTrack20;V160;;;10101;01CCA15F28AF7963596300 +461;X-Plane Pilot View (32 and 64 bit);FreeTrack20;V160;V;V4Friend;11301;01CD79EC0E28EFA953CA00 +462;X-Tower for X-Plane;FreeTrack20;V160;;;3001;01CE05B390EA872AAF3200 +455;X1Alpha;FreeTrack20;V160;;;1825;01C76D2D1038CFD7135A00 +456;X2: The Threat;FreeTrack20;V160;;;5501;01C81039EF980EC8D30900 +457;X3: Albion Prelude and Reunion;FreeTrack20;V170;V;V4Friend;5502;01C97E101A708F8524E300 +463;Xyphoid;FreeTrack20;V160;;;14301;01CF656DD68B43B435A800 +464;zedasoft F-35 Demo;FreeTrack20;V160;;;20041;01D02100B01F942CB93C00 +493;ZKT;FreeTrack20;V160;;;20780;01ED2BAA723F3C097EE800 +465;Zombie AA Research;FreeTrack20;V160;;;14201;01D1AA71218B3B9F1C9A00 -- 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(-) 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 e7877ebef831f1cb36f911e2784af8268c26b5bb Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 28 Dec 2013 00:39:25 +0100 Subject: simconnect: allow for multiple manifest attempts --- ftnoir_protocol_sc/ftnoir-protocol-sc.rc | 3 +- ftnoir_protocol_sc/ftnoir_protocol_sc.cpp | 10 +- ftnoir_protocol_sc/ftnoir_protocol_sc_dialog.cpp | 19 ++- ftnoir_protocol_sc/ftnoir_sccontrols.ui | 146 ++++------------------- ftnoir_protocol_sc/scserver-sp2.manifest | 13 ++ 5 files changed, 61 insertions(+), 130 deletions(-) create mode 100644 ftnoir_protocol_sc/scserver-sp2.manifest diff --git a/ftnoir_protocol_sc/ftnoir-protocol-sc.rc b/ftnoir_protocol_sc/ftnoir-protocol-sc.rc index 3b43715e..693aa12e 100644 --- a/ftnoir_protocol_sc/ftnoir-protocol-sc.rc +++ b/ftnoir_protocol_sc/ftnoir-protocol-sc.rc @@ -1,2 +1,3 @@ #include -142 RT_MANIFEST scserver.manifest \ No newline at end of file +142 RT_MANIFEST scserver.manifest +143 RT_MANIFEST scserver-sp2.manifest diff --git a/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp b/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp index e5d427dd..8449f6ce 100644 --- a/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp +++ b/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp @@ -76,7 +76,6 @@ FTNoIR_Protocol::~FTNoIR_Protocol() // Load the current Settings from the currently 'active' INI-file. // void FTNoIR_Protocol::loadSettings() { -// None yet... } // @@ -186,9 +185,14 @@ bool FTNoIR_Protocol::checkServerInstallationOK() { qDebug() << "SCCheckClientDLL says: Starting Function"; - SCClientLib.setFileName("SimConnect.DLL"); + QSettings settings("opentrack"); + QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); + QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) + iniFile.beginGroup ( "FSX" ); + int act = iniFile.value("version", 0).toInt(); + iniFile.endGroup(); - ActivationContext ctx(142); + ActivationContext ctx(142 + act); if (!SCClientLib.load()) { qDebug() << "SC load" << SCClientLib.errorString(); diff --git a/ftnoir_protocol_sc/ftnoir_protocol_sc_dialog.cpp b/ftnoir_protocol_sc/ftnoir_protocol_sc_dialog.cpp index c2ddb72a..fb822145 100644 --- a/ftnoir_protocol_sc/ftnoir_protocol_sc_dialog.cpp +++ b/ftnoir_protocol_sc/ftnoir_protocol_sc_dialog.cpp @@ -39,8 +39,8 @@ 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.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); + connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); //connect(ui.cbxSelectPPJoyNumber, SIGNAL(currentIndexChanged(int)), this, SLOT(virtualJoystickSelected( int ))); theProtocol = NULL; @@ -118,7 +118,13 @@ void SCControls::doCancel() { // Load the current Settings from the currently 'active' INI-file. // void SCControls::loadSettings() { - + QSettings settings("opentrack"); + QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); + QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) + iniFile.beginGroup ( "FSX" ); + int act = iniFile.value("version", 0).toInt(); + iniFile.endGroup(); + ui.comboBox->setCurrentIndex(act); settingsDirty = false; } @@ -126,7 +132,12 @@ void SCControls::loadSettings() { // Save the current Settings to the currently 'active' INI-file. // void SCControls::save() { - + QSettings settings("opentrack"); + QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); + QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) + iniFile.beginGroup ( "FSX" ); + iniFile.setValue("version", ui.comboBox->currentIndex()); + iniFile.endGroup(); settingsDirty = false; } diff --git a/ftnoir_protocol_sc/ftnoir_sccontrols.ui b/ftnoir_protocol_sc/ftnoir_sccontrols.ui index be42072c..17e94c4b 100644 --- a/ftnoir_protocol_sc/ftnoir_sccontrols.ui +++ b/ftnoir_protocol_sc/ftnoir_sccontrols.ui @@ -9,8 +9,8 @@ 0 0 - 346 - 104 + 258 + 61 @@ -26,132 +26,34 @@ false - - - - - - - - 0 - 0 - - - - There are no setting necessary for SimConnect - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - false - - - - - - - - - Qt::Vertical - - - - 20 - 40 - + + + + + FSX version - + - - + + - - - Qt::Horizontal - - - - 40 - 20 - - - + + Acceleration + - - - QLayout::SetDefaultConstraint - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - OK - - - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - Cancel - - - - + + SP2 + - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 10 - 20 - - - - - + + + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + diff --git a/ftnoir_protocol_sc/scserver-sp2.manifest b/ftnoir_protocol_sc/scserver-sp2.manifest new file mode 100644 index 00000000..19b123ba --- /dev/null +++ b/ftnoir_protocol_sc/scserver-sp2.manifest @@ -0,0 +1,13 @@ + + + + + + + + + + + + + -- cgit v1.2.3 From 0b376956dc68390f76ce3165a2572b9c902027a6 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 28 Dec 2013 05:43:39 +0100 Subject: fix copy-paste marker non-detection --- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index 47c83c12..9a8c09d5 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -239,7 +239,7 @@ void Tracker::run() (detector.detect(grayscale(last_roi), markers, cv::Mat(), cv::Mat(), -1, false), markers.size() == 1 && markers[0].size() == 4)) { - detector.setMinMaxSize(std::max(0.2, 0.08 * grayscale.cols / last_roi.width), + detector.setMinMaxSize(std::max(0.1, 0.08 * grayscale.cols / last_roi.width), std::min(1.0, 0.39 * grayscale.cols / last_roi.width)); auto& m = markers.at(0); for (int i = 0; i < 4; i++) @@ -251,7 +251,7 @@ void Tracker::run() } else { - detector.setMinMaxSize(0.09, 0.4); + detector.setMinMaxSize(0.08, 0.39); detector.detect(grayscale, markers, cv::Mat(), cv::Mat(), -1, false); } -- cgit v1.2.3 From 810293b5639f9a3df67c343866544c34eda84192 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 28 Dec 2013 05:44:14 +0100 Subject: implement optional aruco frame smoothing ewma scheme --- ftnoir_tracker_aruco/aruco-trackercontrols.ui | 310 +++++++++++++++----------- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 53 ++++- ftnoir_tracker_aruco/ftnoir_tracker_aruco.h | 2 + 3 files changed, 233 insertions(+), 132 deletions(-) diff --git a/ftnoir_tracker_aruco/aruco-trackercontrols.ui b/ftnoir_tracker_aruco/aruco-trackercontrols.ui index d4b64c23..340ed0ad 100644 --- a/ftnoir_tracker_aruco/aruco-trackercontrols.ui +++ b/ftnoir_tracker_aruco/aruco-trackercontrols.ui @@ -10,7 +10,7 @@ 0 0 704 - 308 + 399 @@ -32,7 +32,106 @@ -1 - + + + + Horizontal FOV + + + + + + + Enable axes + + + + -1 + + + 6 + + + 0 + + + 6 + + + 0 + + + + + RX + + + + + + + TX + + + + + + + RY + + + + + + + TY + + + + + + + RZ + + + + + + + TZ + + + + + + + + + + Frames per second + + + + + + + + + + + + + 35.000000000000000 + + + 180.000000000000000 + + + 52.000000000000000 + + + + Head centroid position @@ -124,79 +223,6 @@ - - - - Enable axes - - - - -1 - - - 6 - - - 0 - - - 6 - - - 0 - - - - - RX - - - - - - - TX - - - - - - - RY - - - - - - - TY - - - - - - - RZ - - - - - - - TZ - - - - - - - - - - Resolution - - - @@ -221,48 +247,14 @@ - - + + - Frames per second - - - - - - - - 640x480 - - - - - 320x240 - - - - - 320x200 - - - - - Default (not recommended!) - - - - - - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok + Resolution - - - - + @@ -293,19 +285,34 @@ - - - - - - - 35.000000000000000 - - - 180.000000000000000 - - - 52.000000000000000 + + + + + 640x480 + + + + + 320x240 + + + + + 320x200 + + + + + Default (not recommended!) + + + + + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok @@ -316,10 +323,54 @@ - - + + + + + 0 + + + + + 1 + + + + + 2 + + + + + 3 + + + + + 4 + + + + + 5 + + + + + 6 + + + + + 7 + + + + + + - Horizontal FOV + Frame EWMA @@ -340,7 +391,6 @@ tx ty tz - buttonBox diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index 9a8c09d5..fa83955c 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -16,7 +16,7 @@ #include #include #include -#include +#include #if defined(_WIN32) # define NO_DSHOW_STRSAFE @@ -129,12 +129,14 @@ void Tracker::load_settings() headpos[i] = iniFile.value(QString("headpos-%1").arg(i), 0).toDouble(); } headpitch = iniFile.value("pitch", 0).toDouble(); + N_hyst = iniFile.value("ewma", 0).toInt(); iniFile.endGroup(); } Tracker::Tracker() { + N_hyst = 0; layout = nullptr; stop = false; videoWidget = NULL; @@ -192,7 +194,7 @@ void Tracker::run() cv::Mat color, color_, grayscale, rvec, tvec; - const double stateful_coeff = 0.9; + const double stateful_coeff = 0.88; if (!camera.isOpened()) { @@ -209,6 +211,29 @@ void Tracker::run() int fps = 0; int last_fps = 0; cv::Point2f last_centroid; + + bool first_run = true; + + std::vector lasts; + + for (int i = 0; i < N_hyst; i++) + lasts.push_back(cv::Mat()); + + vector weights; + { + const float a = 0.32; + float sum = 0; + float k = 1; + for (int i = 0; i < N_hyst; i++) + { + sum += k; + weights.push_back(k); + k *= 1./(a*N_hyst); + } + for (int i = 0; i < N_hyst; i++) + qDebug() << i << "w" << (weights[i] /= sum); + } + while (!stop) { if (!camera.read(color_)) @@ -217,6 +242,28 @@ void Tracker::run() color_.copyTo(color); cv::cvtColor(color, grayscale, cv::COLOR_BGR2GRAY); + if (first_run) + { + first_run = false; + for (int i = 0; i < N_hyst; i++) + lasts[i] = grayscale; + } + if (N_hyst > 0) + { + cv::Mat hyst(grayscale.rows, grayscale.cols, CV_32F); + hyst.setTo(0); + for (int i = 0; i < N_hyst-1; i++) + lasts[i] = lasts[i+1]; + lasts[N_hyst-1] = grayscale; + for (int i = 0; i < N_hyst; i++) + for (int y = 0; y < grayscale.rows; y++) + for (int x = 0; x < grayscale.cols; x++) + hyst.at(y, x) += (float) lasts[i].at(y, x) * weights[i]; + hyst.convertTo(grayscale, CV_8U); + } + + cv::cvtColor(grayscale, color, cv::COLOR_GRAY2BGR); + const int scale = frame.cols > 480 ? 2 : 1; detector.setThresholdParams(scale > 1 ? 11 : 7, 4); @@ -543,6 +590,7 @@ void TrackerControls::loadSettings() } ui.pitch_deg->setValue(iniFile.value("pitch", 0).toDouble()); + ui.ewma->setCurrentIndex(iniFile.value("ewma", 0).toInt()); iniFile.endGroup(); settingsDirty = false; @@ -583,6 +631,7 @@ void TrackerControls::save() iniFile.setValue("enable-tz", ui.tz->checkState() != Qt::Unchecked ? true : false); iniFile.setValue("resolution", ui.resolution->currentIndex()); iniFile.setValue("pitch", ui.pitch_deg->value()); + iniFile.setValue("ewma", ui.ewma->currentIndex()); QDoubleSpinBox* headpos[] = { ui.cx, diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h index be2ad3d7..249c8829 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h @@ -42,6 +42,8 @@ private: cv::Mat frame; double headpos[3], headpitch; cv::VideoCapture camera; + int N_hyst; + cv::Mat lasts; }; // Widget that has controls for FTNoIR protocol client-settings. -- cgit v1.2.3 From c4bd08796aa00a8a70cbbb8caec947494a39432c Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 28 Dec 2013 05:47:13 +0100 Subject: aruco: decrease ewma alpha for bigger averaging --- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index fa83955c..077bb0d9 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -221,7 +221,7 @@ void Tracker::run() vector weights; { - const float a = 0.32; + const float a = 0.25; float sum = 0; float k = 1; for (int i = 0; i < N_hyst; i++) -- cgit v1.2.3 From 5df8a8cc2869b0eab009841a684b6ee0d4ca390e Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 28 Dec 2013 05:48:10 +0100 Subject: simplify ewma logic --- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index 077bb0d9..c24c233f 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -242,14 +242,14 @@ void Tracker::run() color_.copyTo(color); cv::cvtColor(color, grayscale, cv::COLOR_BGR2GRAY); - if (first_run) - { - first_run = false; - for (int i = 0; i < N_hyst; i++) - lasts[i] = grayscale; - } if (N_hyst > 0) { + if (first_run) + { + first_run = false; + for (int i = 0; i < N_hyst; i++) + lasts[i] = grayscale; + } cv::Mat hyst(grayscale.rows, grayscale.cols, CV_32F); hyst.setTo(0); for (int i = 0; i < N_hyst-1; i++) -- cgit v1.2.3 From d65cf74ce47e66dba1c58212e1aadce07a6ca5cf Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 28 Dec 2013 05:48:34 +0100 Subject: remove redundant cast --- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index c24c233f..999431a0 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -258,7 +258,7 @@ void Tracker::run() for (int i = 0; i < N_hyst; i++) for (int y = 0; y < grayscale.rows; y++) for (int x = 0; x < grayscale.cols; x++) - hyst.at(y, x) += (float) lasts[i].at(y, x) * weights[i]; + hyst.at(y, x) += lasts[i].at(y, x) * weights[i]; hyst.convertTo(grayscale, CV_8U); } -- cgit v1.2.3 From 8d541f45950cb59fe3463bba3cae0024bb466a31 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 28 Dec 2013 05:51:25 +0100 Subject: don't hardcode min/max size constants --- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index 999431a0..09ab4f29 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -282,12 +282,15 @@ void Tracker::run() std::vector< aruco::Marker > markers; + const double size_min = 0.08; + const double size_max = 0.39; + if (last_roi.width > 0 && (detector.detect(grayscale(last_roi), markers, cv::Mat(), cv::Mat(), -1, false), markers.size() == 1 && markers[0].size() == 4)) { - detector.setMinMaxSize(std::max(0.1, 0.08 * grayscale.cols / last_roi.width), - std::min(1.0, 0.39 * grayscale.cols / last_roi.width)); + detector.setMinMaxSize(std::max(0.01, size_min * grayscale.cols / last_roi.width), + std::min(1.0, size_max * grayscale.cols / last_roi.width)); auto& m = markers.at(0); for (int i = 0; i < 4; i++) { @@ -298,7 +301,7 @@ void Tracker::run() } else { - detector.setMinMaxSize(0.08, 0.39); + detector.setMinMaxSize(size_min, size_max); detector.detect(grayscale, markers, cv::Mat(), cv::Mat(), -1, false); } -- cgit v1.2.3 From be1c43cf934cbe4db7a3ad0e857fe1addd4c3329 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 28 Dec 2013 05:51:44 +0100 Subject: change the min/max size constants --- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index 09ab4f29..c6d45f35 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -282,8 +282,8 @@ void Tracker::run() std::vector< aruco::Marker > markers; - const double size_min = 0.08; - const double size_max = 0.39; + const double size_min = 0.04; + const double size_max = 0.38; if (last_roi.width > 0 && (detector.detect(grayscale(last_roi), markers, cv::Mat(), cv::Mat(), -1, false), -- cgit v1.2.3 From 232c41ad8b34f054583505f83f3b7aa3ebbba2b7 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 28 Dec 2013 06:24:59 +0100 Subject: remove ewma frame support, too little gain --- ftnoir_tracker_aruco/aruco-trackercontrols.ui | 109 ++++++++++++-------------- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 49 ------------ ftnoir_tracker_aruco/ftnoir_tracker_aruco.h | 2 - 3 files changed, 52 insertions(+), 108 deletions(-) diff --git a/ftnoir_tracker_aruco/aruco-trackercontrols.ui b/ftnoir_tracker_aruco/aruco-trackercontrols.ui index 340ed0ad..6cc8c29d 100644 --- a/ftnoir_tracker_aruco/aruco-trackercontrols.ui +++ b/ftnoir_tracker_aruco/aruco-trackercontrols.ui @@ -105,6 +105,45 @@ + + + + + 0 + + + + + 1 + + + + + 2 + + + + + 3 + + + + + 4 + + + + + 5 + + + + + 6 + + + + @@ -254,6 +293,13 @@ + + + + Frame EWMA + + + @@ -285,30 +331,6 @@ - - - - - 640x480 - - - - - 320x240 - - - - - 320x200 - - - - - Default (not recommended!) - - - - @@ -323,57 +345,30 @@ - - - - - 0 - - - - - 1 - - - - - 2 - - - - - 3 - - + + - 4 + 640x480 - 5 + 320x240 - 6 + 320x200 - 7 + Default (not recommended!) - - - - Frame EWMA - - - diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index c6d45f35..4c900ab4 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -16,7 +16,6 @@ #include #include #include -#include #if defined(_WIN32) # define NO_DSHOW_STRSAFE @@ -129,14 +128,12 @@ void Tracker::load_settings() headpos[i] = iniFile.value(QString("headpos-%1").arg(i), 0).toDouble(); } headpitch = iniFile.value("pitch", 0).toDouble(); - N_hyst = iniFile.value("ewma", 0).toInt(); iniFile.endGroup(); } Tracker::Tracker() { - N_hyst = 0; layout = nullptr; stop = false; videoWidget = NULL; @@ -212,28 +209,6 @@ void Tracker::run() int last_fps = 0; cv::Point2f last_centroid; - bool first_run = true; - - std::vector lasts; - - for (int i = 0; i < N_hyst; i++) - lasts.push_back(cv::Mat()); - - vector weights; - { - const float a = 0.25; - float sum = 0; - float k = 1; - for (int i = 0; i < N_hyst; i++) - { - sum += k; - weights.push_back(k); - k *= 1./(a*N_hyst); - } - for (int i = 0; i < N_hyst; i++) - qDebug() << i << "w" << (weights[i] /= sum); - } - while (!stop) { if (!camera.read(color_)) @@ -242,28 +217,6 @@ void Tracker::run() color_.copyTo(color); cv::cvtColor(color, grayscale, cv::COLOR_BGR2GRAY); - if (N_hyst > 0) - { - if (first_run) - { - first_run = false; - for (int i = 0; i < N_hyst; i++) - lasts[i] = grayscale; - } - cv::Mat hyst(grayscale.rows, grayscale.cols, CV_32F); - hyst.setTo(0); - for (int i = 0; i < N_hyst-1; i++) - lasts[i] = lasts[i+1]; - lasts[N_hyst-1] = grayscale; - for (int i = 0; i < N_hyst; i++) - for (int y = 0; y < grayscale.rows; y++) - for (int x = 0; x < grayscale.cols; x++) - hyst.at(y, x) += lasts[i].at(y, x) * weights[i]; - hyst.convertTo(grayscale, CV_8U); - } - - cv::cvtColor(grayscale, color, cv::COLOR_GRAY2BGR); - const int scale = frame.cols > 480 ? 2 : 1; detector.setThresholdParams(scale > 1 ? 11 : 7, 4); @@ -593,7 +546,6 @@ void TrackerControls::loadSettings() } ui.pitch_deg->setValue(iniFile.value("pitch", 0).toDouble()); - ui.ewma->setCurrentIndex(iniFile.value("ewma", 0).toInt()); iniFile.endGroup(); settingsDirty = false; @@ -634,7 +586,6 @@ void TrackerControls::save() iniFile.setValue("enable-tz", ui.tz->checkState() != Qt::Unchecked ? true : false); iniFile.setValue("resolution", ui.resolution->currentIndex()); iniFile.setValue("pitch", ui.pitch_deg->value()); - iniFile.setValue("ewma", ui.ewma->currentIndex()); QDoubleSpinBox* headpos[] = { ui.cx, diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h index 249c8829..be2ad3d7 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h @@ -42,8 +42,6 @@ private: cv::Mat frame; double headpos[3], headpitch; cv::VideoCapture camera; - int N_hyst; - cv::Mat lasts; }; // Widget that has controls for FTNoIR protocol client-settings. -- cgit v1.2.3 From fa54d5a4f8a0bf73cad7ebdd3895b8a7467868e6 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 28 Dec 2013 09:42:07 +0100 Subject: remove smoothing/ewma remnants --- ftnoir_tracker_aruco/aruco-trackercontrols.ui | 100 +++++++------------------- 1 file changed, 27 insertions(+), 73 deletions(-) diff --git a/ftnoir_tracker_aruco/aruco-trackercontrols.ui b/ftnoir_tracker_aruco/aruco-trackercontrols.ui index 6cc8c29d..629d1bbb 100644 --- a/ftnoir_tracker_aruco/aruco-trackercontrols.ui +++ b/ftnoir_tracker_aruco/aruco-trackercontrols.ui @@ -105,45 +105,6 @@ - - - - - 0 - - - - - 1 - - - - - 2 - - - - - 3 - - - - - 4 - - - - - 5 - - - - - 6 - - - - @@ -151,26 +112,7 @@ - - - - - - - - - - 35.000000000000000 - - - 180.000000000000000 - - - 52.000000000000000 - - - - + Head centroid position @@ -262,6 +204,25 @@ + + + + + + + + + + 35.000000000000000 + + + 180.000000000000000 + + + 52.000000000000000 + + + @@ -293,13 +254,6 @@ - - - - Frame EWMA - - - @@ -338,13 +292,6 @@ - - - - Camera name - - - @@ -369,6 +316,13 @@ + + + + Camera name + + + -- cgit v1.2.3 From fbef92577584a6000cdbcffa5744b77d28f1dc0c Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 29 Dec 2013 03:33:50 +0100 Subject: unbitrot freetrack proto --- CMakeLists.txt | 6 ++---- freetrackclient/freetrackclient.cpp | 22 +++++++++++----------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index eff5edaf..8e9ade02 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -499,11 +499,9 @@ if(WIN32) add_library(opentrack-proto-win32-mouse SHARED ${opentrack-proto-win32-mouse-c} ${opentrack-proto-win32-mouse-h} ${opentrack-proto-win32-mouse-moc} ${opentrack-proto-win32-mouse-uih} ${opentrack-proto-win32-mouse-rcc}) target_link_libraries(opentrack-proto-win32-mouse ${MY_QT_LIBS}) + add_library(freetrackclient SHARED ${opentrack-freetrack-c} ${opentrack-freetrack-h}) if(CMAKE_COMPILER_IS_GNUCC) - add_library(freetrackclient SHARED ${opentrack-freetrack-c} ${opentrack-freetrack-h} "${CMAKE_SOURCE_DIR}/freetrackclient/freetrackclient.def") - set_target_properties(freetrackclient PROPERTIES LINK_FLAGS "-Wl,--enable-stdcall-fixup") - else() - add_library(freetrackclient SHARED ${opentrack-freetrack-c} ${opentrack-freetrack-h}) + set_target_properties(freetrackclient PROPERTIES LINK_FLAGS "-Wl,--enable-stdcall-fixup -fno-lto -Wl,-kill-at" PREFIX "" COMPILE_FLAGS "-fno-lto") endif() endif() diff --git a/freetrackclient/freetrackclient.cpp b/freetrackclient/freetrackclient.cpp index 71e0e3a7..395f017d 100644 --- a/freetrackclient/freetrackclient.cpp +++ b/freetrackclient/freetrackclient.cpp @@ -17,7 +17,6 @@ * * The FreeTrackClient sources were translated from the original Delphi sources * * * created by the FreeTrack developers. * */ -#define FT_EXPORT(t) extern "C" t __declspec(dllexport) __stdcall #define NP_AXIS_MAX 16383 #include @@ -29,14 +28,15 @@ #include "ftnoir_protocol_ft/fttypes.h" +#define FT_EXPORT(t) extern "C" __declspec(dllexport) t __stdcall + // // Functions to create/open the file-mapping // and to destroy it again. // -bool FTCreateMapping(); -void FTDestroyMapping(); -float scale2AnalogLimits( float x, float min_x, float max_x ); -float getDegreesFromRads ( float rads ); +static float scale2AnalogLimits( float x, float min_x, float max_x ); +static float getDegreesFromRads ( float rads ); +FT_EXPORT(bool) FTCreateMapping(void); #if 0 static FILE *debug_stream = fopen("c:\\FreeTrackClient.log", "a"); @@ -153,7 +153,7 @@ FT_EXPORT(void) FTReportName( int name ) * FTGetDllVersion (FreeTrackClient.3) */ #pragma comment(linker, "/export:FTGetDllVersion@0=FTGetDllVersion") -extern "C" __declspec( dllexport ) const char* FTGetDllVersion(void) +FT_EXPORT(const char*) FTGetDllVersion(void) { dbg_report("FTGetDllVersion request.\n"); @@ -164,7 +164,7 @@ extern "C" __declspec( dllexport ) const char* FTGetDllVersion(void) * FTProvider (FreeTrackClient.4) */ #pragma comment(linker, "/export:FTProvider@0=FTProvider") -extern "C" __declspec( dllexport ) const char* FTProvider(void) +FT_EXPORT(const char*) FTProvider(void) { dbg_report("FTProvider request.\n"); @@ -176,7 +176,7 @@ extern "C" __declspec( dllexport ) const char* FTProvider(void) // It contains the tracking data, a handle to the main-window and the program-name of the Game! // // -bool FTCreateMapping() +FT_EXPORT(bool) FTCreateMapping(void) { // // Memory-mapping already exists! @@ -223,7 +223,7 @@ bool FTCreateMapping() // // Destory the FileMapping to the shared memory // -void FTDestroyMapping() +FT_EXPORT(void) FTDestroyMapping(void) { if ( pMemData != NULL ) { UnmapViewOfFile ( pMemData ); @@ -238,14 +238,14 @@ void FTDestroyMapping() // // 4 convenience // -float getDegreesFromRads ( float rads ) { +static float getDegreesFromRads ( float rads ) { return (rads * 57.295781f); } // // Scale the measured value to the TIR values // -float scale2AnalogLimits( float x, float min_x, float max_x ) { +static float scale2AnalogLimits( float x, float min_x, float max_x ) { double y; double local_x; -- cgit v1.2.3 From fbbe79400ddf7397f2ec09e679ac79e139ebb1d5 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 29 Dec 2013 03:35:03 +0100 Subject: aruco: allow for filter only red spectrum --- ftnoir_tracker_aruco/aruco-trackercontrols.ui | 204 ++++++++++++++------------ ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 12 +- ftnoir_tracker_aruco/ftnoir_tracker_aruco.h | 1 + 3 files changed, 120 insertions(+), 97 deletions(-) diff --git a/ftnoir_tracker_aruco/aruco-trackercontrols.ui b/ftnoir_tracker_aruco/aruco-trackercontrols.ui index 629d1bbb..710a33e1 100644 --- a/ftnoir_tracker_aruco/aruco-trackercontrols.ui +++ b/ftnoir_tracker_aruco/aruco-trackercontrols.ui @@ -10,7 +10,7 @@ 0 0 704 - 399 + 339 @@ -112,98 +112,6 @@ - - - - Head centroid position - - - Qt::AlignCenter - - - - Qt::AlignHCenter|Qt::AlignTop - - - - - TX - - - - - - - -200.000000000000000 - - - 200.000000000000000 - - - - - - - TY - - - - - - - -200.000000000000000 - - - 200.000000000000000 - - - - - - - TZ - - - - - - - -200.000000000000000 - - - 200.000000000000000 - - - - - - - Pitch - - - - - - - ° - - - 2 - - - -60.000000000000000 - - - 60.000000000000000 - - - 0.000000000000000 - - - - - - @@ -254,7 +162,7 @@ - + @@ -285,7 +193,7 @@ - + QDialogButtonBox::Cancel|QDialogButtonBox::Ok @@ -323,6 +231,112 @@ + + + + Red channel only + + + + + + + Recommended! + + + + + + + Head centroid position + + + Qt::AlignCenter + + + + Qt::AlignHCenter|Qt::AlignTop + + + + + TX + + + + + + + -200.000000000000000 + + + 200.000000000000000 + + + + + + + TY + + + + + + + -200.000000000000000 + + + 200.000000000000000 + + + + + + + TZ + + + + + + + -200.000000000000000 + + + 200.000000000000000 + + + + + + + Pitch + + + + + + + ° + + + 2 + + + -60.000000000000000 + + + 60.000000000000000 + + + 0.000000000000000 + + + + + + diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index 4c900ab4..9408de02 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -128,6 +128,7 @@ void Tracker::load_settings() headpos[i] = iniFile.value(QString("headpos-%1").arg(i), 0).toDouble(); } headpitch = iniFile.value("pitch", 0).toDouble(); + red_only = iniFile.value("red-only", true).toBool(); iniFile.endGroup(); } @@ -215,7 +216,13 @@ void Tracker::run() continue; auto tm = cv::getTickCount(); color_.copyTo(color); - cv::cvtColor(color, grayscale, cv::COLOR_BGR2GRAY); + if (red_only) + { + cv::Mat channel[3]; + cv::split(color, channel); + grayscale = channel[2]; + } else + cv::cvtColor(color, grayscale, cv::COLOR_BGR2GRAY); const int scale = frame.cols > 480 ? 2 : 1; detector.setThresholdParams(scale > 1 ? 11 : 7, 4); @@ -546,7 +553,7 @@ void TrackerControls::loadSettings() } ui.pitch_deg->setValue(iniFile.value("pitch", 0).toDouble()); - + ui.red_only->setChecked(iniFile.value("red-only", true).toBool()); iniFile.endGroup(); settingsDirty = false; } @@ -597,6 +604,7 @@ void TrackerControls::save() { iniFile.setValue(QString("headpos-%1").arg(i), headpos[i]->value()); } + iniFile.setValue("red-only", ui.red_only->isChecked()); iniFile.endGroup(); settingsDirty = false; if (tracker) diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h index be2ad3d7..545ad5d0 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h @@ -42,6 +42,7 @@ private: cv::Mat frame; double headpos[3], headpitch; cv::VideoCapture camera; + volatile bool red_only; }; // Widget that has controls for FTNoIR protocol client-settings. -- cgit v1.2.3 From 09a5c7767a2cddb3e2aad89a1a9b2010b3b13fab Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 29 Dec 2013 03:35:15 +0100 Subject: sc: correct manifest --- ftnoir_protocol_sc/scserver.manifest | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ftnoir_protocol_sc/scserver.manifest b/ftnoir_protocol_sc/scserver.manifest index 6d6a8edb..60311d6e 100644 --- a/ftnoir_protocol_sc/scserver.manifest +++ b/ftnoir_protocol_sc/scserver.manifest @@ -2,7 +2,12 @@ - + + + + + + -- cgit v1.2.3 From 00f1a67a25fbe14496b8e69674c83bf02abcd07b Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 29 Dec 2013 04:37:27 +0100 Subject: delete unreferenced header --- freetrackclient/ftclient.h | 30 ------------------------------ 1 file changed, 30 deletions(-) delete mode 100644 freetrackclient/ftclient.h diff --git a/freetrackclient/ftclient.h b/freetrackclient/ftclient.h deleted file mode 100644 index 5e5d8747..00000000 --- a/freetrackclient/ftclient.h +++ /dev/null @@ -1,30 +0,0 @@ -/** @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 -- cgit v1.2.3 From 3cc2032002cd5f5bf6523b0438d362ce991ece34 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 30 Dec 2013 05:20:07 +0100 Subject: coeff fix for new beta --- ftnoir_tracker_ht/ftnoir_tracker_ht.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp index 00dd9919..f9f03fae 100644 --- a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp +++ b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp @@ -99,19 +99,19 @@ static void load_settings(ht_config_t* config, Tracker* tracker) config->field_of_view = iniFile.value("fov", 52).toFloat(); config->pyrlk_pyramids = 0; config->pyrlk_win_size_w = config->pyrlk_win_size_h = 21; - config->max_keypoints = 400; - config->keypoint_distance = 3.3; + config->max_keypoints = 350; + config->keypoint_distance = 3.4; //config->force_width = 640; //config->force_height = 480; config->force_fps = iniFile.value("fps", 0).toInt(); config->camera_index = iniFile.value("camera-index", -1).toInt(); config->ransac_num_iters = 100; - config->ransac_max_reprojection_error = 7.2; - config->ransac_max_inlier_error = 7.2; - config->ransac_abs_max_mean_error = 15; - config->ransac_max_mean_error = 5.0; + config->ransac_max_reprojection_error = 8; + config->ransac_max_inlier_error = 8; + config->ransac_abs_max_mean_error = 20; + config->ransac_max_mean_error = 6.5; config->debug = 0; - config->ransac_min_features = 0.78; + config->ransac_min_features = 0.72; int res = iniFile.value("resolution", 0).toInt(); if (res < 0 || res >= (int)(sizeof(resolution_choices) / sizeof(resolution_tuple))) res = 0; -- 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 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 c2a5e0fcc98fd725c6f978c4fa2e6ba0d2897218 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 30 Dec 2013 08:19:34 +0100 Subject: connect *.hpp to the build --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8e9ade02..8b36cb27 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -180,7 +180,7 @@ file(GLOB opentrack-lib-c "opentrack-api/*.cpp" "facetracknoir/global-settings.c 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") +file(GLOB opentrack-bin-h "facetracknoir/*.h" "facetracknoir/*.hpp") file(GLOB opentrack-bin-ui "facetracknoir/*.ui") file(GLOB opentrack-bin-rc "facetracknoir/*.qrc") QT5_WRAP_UI(opentrack-bin-uih ${opentrack-bin-ui}) -- 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(-) 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(-) 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(-) 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 90d5ffb413bdaa05bc84ff8403ac0399d9ea117a Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 30 Dec 2013 09:55:53 +0100 Subject: use option classes, and remove cruft while we're at it --- .../ftnoir_accela_filtercontrols.ui | 770 ++++++--------------- ftnoir_filter_accela/ftnoir_filter_accela.cpp | 61 +- ftnoir_filter_accela/ftnoir_filter_accela.h | 82 +-- .../ftnoir_filter_accela_dialog.cpp | 243 ++----- ftnoir_filter_accela/ftnoir_filter_accela_dll.cpp | 32 - 5 files changed, 305 insertions(+), 883 deletions(-) diff --git a/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui b/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui index fb6a9565..4ea78c9f 100644 --- a/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui +++ b/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui @@ -9,8 +9,8 @@ 0 0 - 347 - 339 + 202 + 241 @@ -21,8 +21,8 @@ - 347 - 268 + 0 + 0 @@ -47,555 +47,246 @@ - - - 6 - - - 4 - + - - - true + + + + 0 + 0 + + + + Rotation + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + + 0 + 0 + + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + QAbstractSpinBox::CorrectToPreviousValue + + + 4 + + + 0.100000000000000 + + + 65535.000000000000000 + + + 1.000000000000000 + + + + + + + + 0 + 0 + + + + Translation + + + + + + + + 0 + 0 + + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + 4 + + + 0.100000000000000 + + + 65535.000000000000000 + + + 1.000000000000000 + + + + + + + Order #2 + + + + + + + + 0 + 0 + + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + QAbstractSpinBox::CorrectToPreviousValue + + + 4 + + + 0.100000000000000 + + + 65535.000000000000000 + + + 1.000000000000000 + + + + + + + Order #3 + + + + + + + + 0 + 0 + + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + QAbstractSpinBox::CorrectToPreviousValue + + + 4 + + + 0.100000000000000 + + + 65535.000000000000000 + + 1.000000000000000 + + + + + - + 0 0 - 0 + 25 0 - - Basic settings + + + 150 + 16777215 + + + + color:#0; +background:none; + + + Deadband + + + + + + + + 0 + 0 + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - QFormLayout::ExpandingFieldsGrow - - - - - - 0 - 0 - - - - Rotation - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - - - - 0 - 0 - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - QAbstractSpinBox::CorrectToPreviousValue - - - 4 - - - 0.100000000000000 - - - 65535.000000000000000 - - - 1.000000000000000 - - - - - - - - 0 - 0 - - - - Translation - - - - - - - - 0 - 0 - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - 4 - - - 0.100000000000000 - - - 65535.000000000000000 - - - 1.000000000000000 - - - - - - - Order #2 - - - - - - - - 0 - 0 - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - QAbstractSpinBox::CorrectToPreviousValue - - - 4 - - - 0.100000000000000 - - - 65535.000000000000000 - - - 1.000000000000000 - - - - - - - Order #3 - - - - - - - - 0 - 0 - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - QAbstractSpinBox::CorrectToPreviousValue - - - 4 - - - 0.100000000000000 - - - 65535.000000000000000 - - - 1.000000000000000 - - - - - - - - 0 - 0 - - - - - 25 - 0 - - - - - 150 - 16777215 - - - - color:#0; -background:none; - - - Deadband - - - - - - - - 0 - 0 - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - 3 - - - 0.000000000000000 - - - 3.000000000000000 - - - 0.050000000000000 - - - 0.000000000000000 - - - - - - - Exponent - - - - - - - - 0 - 0 - - - - 3 - - - 0.050000000000000 - - - 100.000000000000000 - - - 0.050000000000000 - - - - + + 3 + + + 0.000000000000000 + + + 3.000000000000000 + + + 0.050000000000000 + + + 0.000000000000000 + - - + + + + Exponent + + + + + - + 0 0 - - Axis speed - - - - QFormLayout::ExpandingFieldsGrow - - - 20 - - - 0 - - - 5 - - - 0 - - - 10 - - - 2 - - - - - - 0 - 0 - - - - X - - - - - - - - 0 - 0 - - - - 4 - - - 0.100000000000000 - - - 3.000000000000000 - - - 0.100000000000000 - - - 1.000000000000000 - - - - - - - - 0 - 0 - - - - Y - - - - - - - - 0 - 0 - - - - 4 - - - 0.100000000000000 - - - 3.000000000000000 - - - 0.100000000000000 - - - 1.000000000000000 - - - - - - - - 0 - 0 - - - - Z - - - - - - - - 0 - 0 - - - - 4 - - - 0.100000000000000 - - - 3.000000000000000 - - - 0.100000000000000 - - - 1.000000000000000 - - - - - - - - 0 - 0 - - - - Yaw - - - - - - - - 0 - 0 - - - - false - - - 4 - - - 0.100000000000000 - - - 3.000000000000000 - - - 0.100000000000000 - - - 1.000000000000000 - - - - - - - - 0 - 0 - - - - Pitch - - - - - - - - 0 - 0 - - - - false - - - 4 - - - 0.100000000000000 - - - 3.000000000000000 - - - 0.100000000000000 - - - 1.000000000000000 - - - - - - - - 0 - 0 - - - - Roll - - - - - - - - 0 - 0 - - - - false - - - 4 - - - 0.100000000000000 - - - 3.000000000000000 - - - 0.100000000000000 - - - 1.000000000000000 - - - - + + 3 + + + 0.050000000000000 + + + 100.000000000000000 + + + 0.050000000000000 + - + @@ -640,8 +331,14 @@ background:none; - + + + + 0 + 0 + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok @@ -649,21 +346,6 @@ background:none; - - rotation_alpha - translation_alpha - order_2nd - order_3rd - deadzone - expt - doubleSpinBox - doubleSpinBox_2 - doubleSpinBox_3 - doubleSpinBox_4 - doubleSpinBox_5 - doubleSpinBox_6 - buttonBox - diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.cpp b/ftnoir_filter_accela/ftnoir_filter_accela.cpp index 1046c268..2e70c1b0 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela.cpp @@ -10,55 +10,18 @@ #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" ); - 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(); - third_order_alpha = iniFile.value("third-order-alpha", ACCELA_THIRD_ORDER_ALPHA).toDouble(); - deadzone = iniFile.value("deadzone", 0.0).toDouble(); - // bigger means less filtering - static const double init_scaling[] = { - 1, // X - 1, // Y - 1, // Z - 1, // Yaw - 1, // Pitch - 1 // Roll - }; - for (int i = 0; i < 6; i++) - { - scaling[i] = iniFile.value(QString("axis-%1").arg(QString::number(i)), init_scaling[i]).toDouble(); - } - expt = iniFile.value("exponent", 2.0).toDouble(); - - iniFile.endGroup(); -} - -void FTNoIR_Filter::receiveSettings() +FTNoIR_Filter::FTNoIR_Filter() : + first_run(true), + b(bundle("Accela")), + rotation_alpha(b, "rotation-alpha", ACCELA_SMOOTHING_ROTATION), + translation_alpha(b, "translation-alpha", ACCELA_SMOOTHING_TRANSLATION), + second_order_alpha(b, "second-order-alpha", ACCELA_SECOND_ORDER_ALPHA), + third_order_alpha(b, "third-order-alpha", ACCELA_THIRD_ORDER_ALPHA), + deadzone(b, "deadzone", 0), + expt(b, "exponent", 2) { - QMutexLocker foo(&mutex); - - loadSettings(); } static inline double parabola(const double a, const double x, const double dz, const double expt) @@ -135,9 +98,9 @@ void FTNoIR_Filter::FilterHeadPoseData(const double* target_camera_position, const double a2 = a * second_order_alpha; const double a3 = a * third_order_alpha; const double velocity = - parabola(a, vec * scaling[i], deadzone, expt) + - parabola(a2, vec2 * scaling[i], deadzone, expt) + - parabola(a3, vec3 * scaling[i], deadzone, expt); + parabola(a, vec, deadzone, expt) + + parabola(a2, vec2, deadzone, expt) + + parabola(a3, vec3, 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 d91a5e42..43564bd8 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.h +++ b/ftnoir_filter_accela/ftnoir_filter_accela.h @@ -1,31 +1,4 @@ -/******************************************************************************** -* 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 "ui_ftnoir_accela_filtercontrols.h" #include "facetracknoir/global-settings.h" @@ -37,28 +10,31 @@ #define ACCELA_SECOND_ORDER_ALPHA 100.0 #define ACCELA_THIRD_ORDER_ALPHA 180.0 -//******************************************************************************************************* -// FaceTrackNoIR Filter class. -//******************************************************************************************************* +#include "facetracknoir/options.hpp" +using namespace options; + class FTNoIR_Filter : public IFilter { public: FTNoIR_Filter(); - virtual ~FTNoIR_Filter(); void FilterHeadPoseData(const double* target_camera_position, double *new_camera_position); void Initialize() { first_run = true; } - void receiveSettings(); + void receiveSettings() { + b->reload(); + } + private: QMutex mutex; - void loadSettings(); bool first_run; - double rotation_alpha, translation_alpha; - double second_order_alpha, third_order_alpha; - double scaling[6]; - double deadzone; - double expt; + pbundle b; + value rotation_alpha, + translation_alpha, + second_order_alpha, + third_order_alpha, + deadzone, + expt; double last_input[6]; double last_output[3][6]; QElapsedTimer timer; @@ -74,43 +50,33 @@ class FilterControls: public QWidget, public IFilterDialog { Q_OBJECT public: - explicit FilterControls(); - virtual ~FilterControls(); - void showEvent (QShowEvent *); - void Initialize(QWidget *parent); + FilterControls(); + void Initialize(QWidget *); void registerFilter(IFilter* filter); void unregisterFilter(); private: Ui::AccelaUICFilterControls ui; - void loadSettings(); + void discard(); void save(); - bool settingsDirty; FTNoIR_Filter* accela_filter; + pbundle b; + value rotation_alpha, + translation_alpha, + second_order_alpha, + third_order_alpha, + deadzone, + expt; private slots: void doOK(); void doCancel(); - void settingChanged(bool) { settingsDirty = true; } - void settingChanged(int) { settingsDirty = true; } - void settingChanged(double) { 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 Mk4"); } void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("Accela Mk4"); } void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("Accela filter Mk4"); } 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 a14db280..256f35b4 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp @@ -1,27 +1,3 @@ -/******************************************************************************** -* 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 @@ -29,60 +5,30 @@ #include #include "facetracknoir/global-settings.h" -//******************************************************************************************************* -// FaceTrackNoIR Filter Settings-dialog. -//******************************************************************************************************* -// -// Constructor for server-settings-dialog -// FilterControls::FilterControls() : - QWidget(), accela_filter(NULL) + accela_filter(NULL), + b(bundle("Accela")), + rotation_alpha(b, "rotation-alpha", ACCELA_SMOOTHING_ROTATION), + translation_alpha(b, "translation-alpha", ACCELA_SMOOTHING_TRANSLATION), + second_order_alpha(b, "second-order-alpha", ACCELA_SECOND_ORDER_ALPHA), + third_order_alpha(b, "third-order-alpha", ACCELA_THIRD_ORDER_ALPHA), + deadzone(b, "deadzone", 0), + expt(b, "exponent", 2) + { ui.setupUi( this ); - - // Load the settings from the current .INI-file - loadSettings(); connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); - connect(ui.rotation_alpha, SIGNAL(valueChanged(double)), this, SLOT(settingChanged(double))); - connect(ui.translation_alpha, SIGNAL(valueChanged(double)), this, SLOT(settingChanged(double))); - - QDoubleSpinBox* boxen[] = { - ui.doubleSpinBox, - ui.doubleSpinBox_2, - ui.doubleSpinBox_3, - ui.doubleSpinBox_4, - ui.doubleSpinBox_5, - ui.doubleSpinBox_6, - }; - - for (int i = 0; i < 6; i++) - { - connect(boxen[i], SIGNAL(valueChanged(double)), this, SLOT(settingChanged(double))); - } - - connect(ui.expt, SIGNAL(valueChanged(double)), this, SLOT(settingChanged(double))); - - qDebug() << "FilterControls() says: started"; -} -// -// Destructor for server-dialog -// -FilterControls::~FilterControls() { - qDebug() << "~FilterControls() says: started"; + tie_setting(rotation_alpha, ui.rotation_alpha); + tie_setting(translation_alpha, ui.translation_alpha); + tie_setting(second_order_alpha, ui.order_2nd); + tie_setting(third_order_alpha, ui.order_3rd); + tie_setting(deadzone, ui.deadzone); + tie_setting(expt, ui.expt); } -// -// Initialize tracker-client-dialog -// -void FilterControls::Initialize(QWidget *parent) { - loadSettings(); - - QPoint offsetpos(100, 100); - if (parent) { - this->move(parent->pos() + offsetpos); - } +void FilterControls::Initialize(QWidget *) { show(); } @@ -96,153 +42,50 @@ void FilterControls::unregisterFilter() accela_filter = NULL; } -// -// OK clicked on server-dialog -// void FilterControls::doOK() { save(); this->close(); } -// override show event -void FilterControls::showEvent ( QShowEvent * ) { -} - -// -// 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.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()); - ui.order_3rd->setValue(iniFile.value("third-order-alpha", ACCELA_THIRD_ORDER_ALPHA).toDouble()); - ui.deadzone->setValue(iniFile.value("deadzone", 0).toDouble()); - - // bigger means less filtering - static const double init_scaling[] = { - 1.5, // X - 1.5, // Y - 1, // Z - 0.8, // Yaw - 0.9, // Pitch - 1.25 // Roll - }; - - QDoubleSpinBox* boxen[] = { - ui.doubleSpinBox, - ui.doubleSpinBox_2, - ui.doubleSpinBox_3, - ui.doubleSpinBox_4, - ui.doubleSpinBox_5, - ui.doubleSpinBox_6, - }; - - for (int i = 0; i < 6; i++) + if (!b->modifiedp()) { - boxen[i]->setValue(iniFile.value(QString("axis-%1").arg(QString::number(i)), init_scaling[i]).toDouble()); + 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; + } +} - ui.expt->setValue(iniFile.value("exponent", 2.0).toDouble()); - - iniFile.endGroup(); - settingsDirty = false; +void FilterControls::discard() +{ + b->revert(); } -// -// 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; - - iniFile.beginGroup ( "Accela" ); - iniFile.setValue("rotation-alpha", ui.rotation_alpha->value()); - iniFile.setValue("translation-alpha", ui.translation_alpha->value()); - iniFile.setValue("deadzone", ui.deadzone->value()); - iniFile.setValue("exponent", ui.expt->value()); - iniFile.setValue("second-order-alpha", ui.order_2nd->value()); - iniFile.setValue("third-order-alpha", ui.order_3rd->value()); - - QDoubleSpinBox* boxen[] = { - ui.doubleSpinBox, - ui.doubleSpinBox_2, - ui.doubleSpinBox_3, - ui.doubleSpinBox_4, - ui.doubleSpinBox_5, - ui.doubleSpinBox_6, - }; - - for (int i = 0; i < 6; i++) - { - iniFile.setValue(QString("axis-%1").arg(QString::number(i)), boxen[i]->value()); - } - iniFile.endGroup(); - } - - settingsDirty = false; - + b->save(); if (accela_filter) accela_filter->receiveSettings(); } -//////////////////////////////////////////////////////////////////////////////// -// 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 d4a11028..a024e789 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela_dll.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela_dll.cpp @@ -1,38 +1,6 @@ -/******************************************************************************** -* 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; -- cgit v1.2.3 From a49a146b1a9bb68b763a09684bdae8cc7dd16d65 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 30 Dec 2013 10:02:21 +0100 Subject: remove dist coeffs, no one uses them --- ftnoir_tracker_ht/ftnoir_tracker_ht.cpp | 18 +- ftnoir_tracker_ht/ht-trackercontrols.ui | 591 ++++++++++---------------------- 2 files changed, 186 insertions(+), 423 deletions(-) diff --git a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp index f9f03fae..a1fed131 100644 --- a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp +++ b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp @@ -131,7 +131,7 @@ static void load_settings(ht_config_t* config, Tracker* tracker) } for (int i = 0; i < 5; i++) - config->dist_coeffs[i] = iniFile.value(QString("dc%1").arg(i), 0).toDouble(); + config->dist_coeffs[i] = 0; iniFile.endGroup(); } @@ -285,8 +285,8 @@ TrackerControls::TrackerControls() connect(ui.tx, SIGNAL(clicked()), this, SLOT(settingChanged())); connect(ui.ty, SIGNAL(clicked()), this, SLOT(settingChanged())); connect(ui.tz, SIGNAL(clicked()), this, SLOT(settingChanged())); - connect(ui.buttonCancel, SIGNAL(clicked()), this, SLOT(doCancel())); - connect(ui.buttonOK, SIGNAL(clicked()), this, SLOT(doOK())); + connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); + connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); //connect(ui.buttonSettings, SIGNAL(clicked()), this, SLOT(cameraSettings())); loadSettings(); settingsDirty = false; @@ -344,12 +344,6 @@ void TrackerControls::loadSettings() ui.tz->setCheckState(iniFile.value("enable-tz", true).toBool() ? Qt::Checked : Qt::Unchecked); ui.resolution->setCurrentIndex(iniFile.value("resolution", 0).toInt()); - ui.doubleSpinBox->setValue(iniFile.value("dc0").toDouble()); - ui.doubleSpinBox_2->setValue(iniFile.value("dc1").toDouble()); - ui.doubleSpinBox_3->setValue(iniFile.value("dc2").toDouble()); - ui.doubleSpinBox_4->setValue(iniFile.value("dc3").toDouble()); - ui.doubleSpinBox_5->setValue(iniFile.value("dc4").toDouble()); - iniFile.endGroup(); settingsDirty = false; } @@ -389,12 +383,6 @@ void TrackerControls::save() iniFile.setValue("enable-tz", ui.tz->checkState() != Qt::Unchecked ? true : false); iniFile.setValue("resolution", ui.resolution->currentIndex()); - iniFile.setValue("dc0", ui.doubleSpinBox->value()); - iniFile.setValue("dc1", ui.doubleSpinBox_2->value()); - iniFile.setValue("dc2", ui.doubleSpinBox_3->value()); - iniFile.setValue("dc3", ui.doubleSpinBox_4->value()); - iniFile.setValue("dc4", ui.doubleSpinBox_5->value()); - iniFile.endGroup(); settingsDirty = false; } diff --git a/ftnoir_tracker_ht/ht-trackercontrols.ui b/ftnoir_tracker_ht/ht-trackercontrols.ui index 6153637a..198cca7f 100644 --- a/ftnoir_tracker_ht/ht-trackercontrols.ui +++ b/ftnoir_tracker_ht/ht-trackercontrols.ui @@ -9,8 +9,8 @@ 0 0 - 593 - 280 + 527 + 144 @@ -28,420 +28,195 @@ HT tracker settings - - - - 10 - 10 - 141 - 16 - - - - Horizontal FOV - - - - - - 130 - 10 - 251 - 22 - - - - - - - 35.000000000000000 - - - 180.000000000000000 - - - 52.000000000000000 - - - - - - 10 - 40 - 137 - 16 - - - - Frames per second - - - - - - 130 - 40 - 251 - 22 - - - - - Default - + + + + + + + + 35.000000000000000 + + + 180.000000000000000 + + + 52.000000000000000 + + + + + + + Horizontal FOV + + + + + + + Enable axes + + + + + 10 + 20 + 70 + 17 + + + + RX + + + + + + 10 + 40 + 70 + 17 + + + + RY + + + + + + 10 + 60 + 70 + 17 + + + + RZ + + + + + + 60 + 20 + 70 + 17 + + + + TX + + + + + + 60 + 40 + 70 + 17 + + + + TY + + + + + + 60 + 60 + 70 + 17 + + + + TZ + + + - - - 30 - + + + + Frames per second + + - - - 60 - + + + + + Default + + + + + 30 + + + + + 60 + + + + + 120 + + + - - - 120 - + + + + Camera name + + - - - - - 10 - 70 - 133 - 16 - - - - Camera name - - - - - - 430 - 250 - 75 - 23 - - - - OK - - - - - - 510 - 250 - 75 - 23 - - - - Cancel - - - - - - 390 - 10 - 101 - 81 - - - - Enable axes - - - - - 10 - 20 - 70 - 17 - - - - RX - - - - - - 10 - 40 - 70 - 17 - - - - RY - - - - - - 10 - 60 - 70 - 17 - - - - RZ - - - - - - 60 - 20 - 70 - 17 - - - - TX - - - - - - 60 - 40 - 70 - 17 - - - - TY - - - - - - 60 - 60 - 70 - 17 - - - - TZ - - - - - - - 130 - 70 - 251 - 22 - - - - - - - 10 - 100 - 128 - 16 - - - - Resolution - - - - - - 130 - 100 - 251 - 22 - - - - - 640x480 - + + - - - 320x240 - + + + + Resolution + + - - - 320x200 - + + + + + 640x480 + + + + + 320x240 + + + + + 320x200 + + + + + Default (not recommended!) + + + - - - Default (not recommended!) - + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + - - - - - 130 - 130 - 171 - 22 - - - - true - - - QAbstractSpinBox::NoButtons - - - 24 - - - -1000.000000000000000 - - - 1000.000000000000000 - - - 0.000000000000000 - - - - - - 10 - 130 - 111 - 16 - - - - Distortion coefficients - - - - - - 130 - 160 - 171 - 22 - - - - true - - - QAbstractSpinBox::NoButtons - - - 24 - - - -1000.000000000000000 - - - 1000.000000000000000 - - - 0.000000000000000 - - - - - - 130 - 190 - 171 - 22 - - - - true - - - QAbstractSpinBox::NoButtons - - - 24 - - - -1000.000000000000000 - - - 1000.000000000000000 - - - 0.000000000000000 - - - - - - 130 - 220 - 171 - 22 - - - - true - - - QAbstractSpinBox::NoButtons - - - 24 - - - -1000.000000000000000 - - - 1000.000000000000000 - - - 0.000000000000000 - - - - - - 130 - 250 - 171 - 22 - - - - true - - - QAbstractSpinBox::NoButtons - - - 24 - - - -1000.000000000000000 - - - 1000.000000000000000 - - - 0.000000000000000 - - + -- cgit v1.2.3 From 2f6b8f8b2b5bdaeed540e8b87dcae0dfe7ba1e70 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 30 Dec 2013 10:34:42 +0100 Subject: settings framework for ht tracker --- ftnoir_tracker_ht/ftnoir_tracker_ht.cpp | 251 ++++++++++++-------------------- ftnoir_tracker_ht/ftnoir_tracker_ht.h | 24 +-- 2 files changed, 102 insertions(+), 173 deletions(-) diff --git a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp index a1fed131..ab4c5a3e 100644 --- a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp +++ b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp @@ -88,23 +88,34 @@ static resolution_tuple resolution_choices[] = { { 0, 0 } }; -static void load_settings(ht_config_t* config, Tracker* tracker) +void Tracker::load_settings(ht_config_t* config) { - QSettings settings("opentrack"); - QString currentFile = settings.value( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); - QSettings iniFile( currentFile, QSettings::IniFormat ); + int nframes = 0; + switch (static_cast(fps)) + { + default: + case 0: + nframes = 0; + break; + case 1: + nframes = 30; + break; + case 2: + nframes = 60; + break; + case 3: + nframes = 120; + break; + } - iniFile.beginGroup( "HT-Tracker" ); config->classification_delay = 500; - config->field_of_view = iniFile.value("fov", 52).toFloat(); + config->field_of_view = fov; config->pyrlk_pyramids = 0; config->pyrlk_win_size_w = config->pyrlk_win_size_h = 21; config->max_keypoints = 350; config->keypoint_distance = 3.4; - //config->force_width = 640; - //config->force_height = 480; - config->force_fps = iniFile.value("fps", 0).toInt(); - config->camera_index = iniFile.value("camera-index", -1).toInt(); + config->force_fps = nframes; + config->camera_index = camera_idx - 1; config->ransac_num_iters = 100; config->ransac_max_reprojection_error = 8; config->ransac_max_inlier_error = 8; @@ -112,38 +123,35 @@ static void load_settings(ht_config_t* config, Tracker* tracker) config->ransac_max_mean_error = 6.5; config->debug = 0; config->ransac_min_features = 0.72; - int res = iniFile.value("resolution", 0).toInt(); + int res = resolution; if (res < 0 || res >= (int)(sizeof(resolution_choices) / sizeof(resolution_tuple))) res = 0; resolution_tuple r = resolution_choices[res]; config->force_width = r.width; config->force_height = r.height; config->flandmark_delay = 325; - qDebug() << "width" << r.width << "height" << r.height; - if (tracker) - { - tracker->enableRX = iniFile.value("enable-rx", true).toBool(); - tracker->enableRY = iniFile.value("enable-ry", true).toBool(); - tracker->enableRZ = iniFile.value("enable-rz", true).toBool(); - tracker->enableTX = iniFile.value("enable-tx", true).toBool(); - tracker->enableTY = iniFile.value("enable-ty", true).toBool(); - tracker->enableTZ = iniFile.value("enable-tz", true).toBool(); - } - for (int i = 0; i < 5; i++) config->dist_coeffs[i] = 0; - - iniFile.endGroup(); } -Tracker::Tracker() : lck_shm(HT_SHM_NAME, HT_MUTEX_NAME, sizeof(ht_shm_t)) +Tracker::Tracker() : + b(bundle("HT-Tracker")), + enableTX(b, "enable-tx", true), + enableTY(b, "enable-ty", true), + enableTZ(b, "enable-tz", true), + enableRX(b, "enable-rx", true), + enableRY(b, "enable-ry", true), + enableRZ(b, "enable-rz", true), + fov(b, "fov", 56), + fps(b, "fps", 0), + camera_idx(b, "camera-index", 0), + resolution(b, "resolution", 0), + lck_shm(HT_SHM_NAME, HT_MUTEX_NAME, sizeof(ht_shm_t)), + shm(reinterpret_cast(lck_shm.mem)), + videoWidget(nullptr), + layout(nullptr) { - videoWidget = NULL; - layout = NULL; - enableRX = enableRY = enableRZ = enableTX = enableTY = enableTZ = true; - shm = (ht_shm_t*) lck_shm.mem; shm->terminate = 0; - load_settings(&shm->config, this); shm->result.filled = false; } @@ -174,7 +182,7 @@ void Tracker::StartTracker(QFrame* videoframe) videoframe->setLayout(layout); videoWidget->show(); this->layout = layout; - load_settings(&shm->config, this); + load_settings(&shm->config); shm->frame.channels = shm->frame.width = shm->frame.height = 0; shm->pause = shm->terminate = shm->running = false; shm->timer = 0; @@ -272,153 +280,74 @@ extern "C" FTNOIR_TRACKER_BASE_EXPORT ITrackerDialog* CALLING_CONVENTION GetDial return new TrackerControls; } -TrackerControls::TrackerControls() +TrackerControls::TrackerControls() : + b(bundle("HT-Tracker")), + enableTX(b, "enable-tx", true), + enableTY(b, "enable-ty", true), + enableTZ(b, "enable-tz", true), + enableRX(b, "enable-rx", true), + enableRY(b, "enable-ry", true), + enableRZ(b, "enable-rz", true), + fov(b, "fov", 56), + fps(b, "fps", 0), + camera_idx(b, "camera-index", 0), + resolution(b, "resolution", 0) { 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.cameraFOV, SIGNAL(valueChanged(double)), this, SLOT(settingChanged(double))); - connect(ui.rx, SIGNAL(clicked()), this, SLOT(settingChanged())); - connect(ui.ry, SIGNAL(clicked()), this, SLOT(settingChanged())); - connect(ui.rz, SIGNAL(clicked()), this, SLOT(settingChanged())); - connect(ui.tx, SIGNAL(clicked()), this, SLOT(settingChanged())); - connect(ui.ty, SIGNAL(clicked()), this, SLOT(settingChanged())); - connect(ui.tz, SIGNAL(clicked()), this, SLOT(settingChanged())); + ui.cameraName->clear(); + QList names = get_camera_names(); + names.prepend("Any available"); + ui.cameraName->addItems(names); + tie_setting(camera_idx, ui.cameraName); + tie_setting(fps, ui.cameraFPS); + tie_setting(fov, ui.cameraFOV); + tie_setting(enableTX, ui.tx); + tie_setting(enableTY, ui.ty); + tie_setting(enableTZ, ui.tz); + tie_setting(enableRX, ui.rx); + tie_setting(enableRY, ui.ry); + tie_setting(enableRZ, ui.rz); + tie_setting(resolution, ui.resolution); connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); //connect(ui.buttonSettings, SIGNAL(clicked()), this, SLOT(cameraSettings())); - loadSettings(); - settingsDirty = false; -} - -TrackerControls::~TrackerControls() -{ -} - -void TrackerControls::showEvent(QShowEvent *) -{ } void TrackerControls::Initialize(QWidget*) { - loadSettings(); show(); } -void TrackerControls::loadSettings() -{ - ui.cameraName->clear(); - QList names = get_camera_names(); - names.prepend("Any available"); - ui.cameraName->addItems(names); - QSettings settings("opentrack"); - 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); - ui.cameraFOV->setValue(iniFile.value("fov", 52).toFloat()); - int fps; - switch (iniFile.value("fps", 0).toInt()) - { - default: - case 0: - fps = 0; - break; - case 30: - fps = 1; - break; - case 60: - fps = 2; - break; - case 120: - fps = 3; - break; - } - ui.cameraFPS->setCurrentIndex(fps); - ui.rx->setCheckState(iniFile.value("enable-rx", true).toBool() ? Qt::Checked : Qt::Unchecked); - ui.ry->setCheckState(iniFile.value("enable-ry", true).toBool() ? Qt::Checked : Qt::Unchecked); - ui.rz->setCheckState(iniFile.value("enable-rz", true).toBool() ? Qt::Checked : Qt::Unchecked); - ui.tx->setCheckState(iniFile.value("enable-tx", true).toBool() ? Qt::Checked : Qt::Unchecked); - ui.ty->setCheckState(iniFile.value("enable-ty", true).toBool() ? Qt::Checked : Qt::Unchecked); - ui.tz->setCheckState(iniFile.value("enable-tz", true).toBool() ? Qt::Checked : Qt::Unchecked); - ui.resolution->setCurrentIndex(iniFile.value("resolution", 0).toInt()); - - iniFile.endGroup(); - settingsDirty = false; -} - -void TrackerControls::save() -{ - QSettings settings("opentrack"); - QString currentFile = settings.value( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); - QSettings iniFile( currentFile, QSettings::IniFormat ); - - iniFile.beginGroup( "HT-Tracker" ); - iniFile.setValue("fov", ui.cameraFOV->value()); - int fps; - switch (ui.cameraFPS->currentIndex()) - { - case 0: - default: - fps = 0; - break; - case 1: - fps = 30; - break; - case 2: - fps = 60; - break; - case 3: - fps = 120; - break; - } - iniFile.setValue("fps", fps); - iniFile.setValue("camera-index", ui.cameraName->currentIndex() - 1); - iniFile.setValue("enable-rx", ui.rx->checkState() != Qt::Unchecked ? true : false); - iniFile.setValue("enable-ry", ui.ry->checkState() != Qt::Unchecked ? true : false); - iniFile.setValue("enable-rz", ui.rz->checkState() != Qt::Unchecked ? true : false); - iniFile.setValue("enable-tx", ui.tx->checkState() != Qt::Unchecked ? true : false); - iniFile.setValue("enable-ty", ui.ty->checkState() != Qt::Unchecked ? true : false); - iniFile.setValue("enable-tz", ui.tz->checkState() != Qt::Unchecked ? true : false); - iniFile.setValue("resolution", ui.resolution->currentIndex()); - - iniFile.endGroup(); - settingsDirty = false; -} - void TrackerControls::doOK() { - save(); + b->save(); this->close(); } void TrackerControls::doCancel() { - 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 ); - - 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(); - } + if (!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, + QMessageBox::Discard ); + + switch (ret) { + case QMessageBox::Save: + b->save(); + this->close(); + break; + case QMessageBox::Discard: + b->revert(); + this->close(); + break; + default: + case QMessageBox::Cancel: + break; + } } diff --git a/ftnoir_tracker_ht/ftnoir_tracker_ht.h b/ftnoir_tracker_ht/ftnoir_tracker_ht.h index 404dbf6e..3140e99c 100644 --- a/ftnoir_tracker_ht/ftnoir_tracker_ht.h +++ b/ftnoir_tracker_ht/ftnoir_tracker_ht.h @@ -15,6 +15,8 @@ #include "ht_video_widget.h" #include "compat/compat.h" #include +#include "facetracknoir/options.hpp" +using namespace options; class Tracker : public QObject, public ITracker { @@ -24,10 +26,14 @@ public: virtual ~Tracker(); void StartTracker(QFrame* frame); void GetHeadPoseData(double *data); - bool enableTX, enableTY, enableTZ, enableRX, enableRY, enableRZ; - ht_shm_t* shm; + pbundle b; + value enableTX, enableTY, enableTZ, enableRX, enableRY, enableRZ; + value fov; + value fps, camera_idx, resolution; + void load_settings(ht_config_t* config); private: PortableLockedShm lck_shm; + ht_shm_t* shm; QProcess subprocess; HTVideoWidget* videoWidget; QHBoxLayout* layout; @@ -38,27 +44,21 @@ class TrackerControls : public QWidget, public ITrackerDialog { Q_OBJECT public: - explicit TrackerControls(); - virtual ~TrackerControls(); - void showEvent (QShowEvent *); - void Initialize(QWidget *); void registerTracker(ITracker *) {} void unRegisterTracker() {} private: Ui::Form ui; - void loadSettings(); - void save(); - bool settingsDirty; + pbundle b; + value enableTX, enableTY, enableTZ, enableRX, enableRY, enableRZ; + value fov; + value fps, camera_idx, resolution; private slots: void doOK(); void doCancel(); - void settingChanged() { settingsDirty = true; } - void settingChanged(int) { settingsDirty = true; } - void settingChanged(double) { settingsDirty = true; } }; #endif -- cgit v1.2.3 From 9cb243cc74d953283b0a233e47f1d0a4e303ab55 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 30 Dec 2013 10:39:54 +0100 Subject: remove boring comments --- ftnoir_tracker_ht/ftnoir_tracker_ht.cpp | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp index ab4c5a3e..333ce28a 100644 --- a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp +++ b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp @@ -250,31 +250,16 @@ void TrackerDll::getIcon(QIcon *icon) *icon = QIcon(":/images/ht.png"); } - -//----------------------------------------------------------------------------- -//#pragma comment(linker, "/export:GetTrackerDll=_GetTrackerDll@0") - extern "C" FTNOIR_TRACKER_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata() { return new TrackerDll; } -//#pragma comment(linker, "/export:GetTracker=_GetTracker@0") - extern "C" FTNOIR_TRACKER_BASE_EXPORT ITracker* CALLING_CONVENTION GetConstructor() { return new Tracker; } -//////////////////////////////////////////////////////////////////////////////// -// 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; @@ -310,7 +295,6 @@ TrackerControls::TrackerControls() : tie_setting(resolution, ui.resolution); connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); - //connect(ui.buttonSettings, SIGNAL(clicked()), this, SLOT(cameraSettings())); } void TrackerControls::Initialize(QWidget*) @@ -334,8 +318,7 @@ void TrackerControls::doCancel() int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", - QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, - QMessageBox::Discard ); + QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel); switch (ret) { case QMessageBox::Save: -- 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(-) 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 2a3b4460da901256a60fc2e4bc90adc14284bbf3 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 30 Dec 2013 11:02:53 +0100 Subject: accela: bundle settings to reduce boilerplate --- ftnoir_filter_accela/ftnoir_filter_accela.cpp | 22 ++++--------- ftnoir_filter_accela/ftnoir_filter_accela.h | 37 +++++++++++++--------- .../ftnoir_filter_accela_dialog.cpp | 28 ++++++---------- 3 files changed, 39 insertions(+), 48 deletions(-) diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.cpp b/ftnoir_filter_accela/ftnoir_filter_accela.cpp index 2e70c1b0..1e12e4de 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela.cpp @@ -12,15 +12,7 @@ #include "facetracknoir/global-settings.h" using namespace std; -FTNoIR_Filter::FTNoIR_Filter() : - first_run(true), - b(bundle("Accela")), - rotation_alpha(b, "rotation-alpha", ACCELA_SMOOTHING_ROTATION), - translation_alpha(b, "translation-alpha", ACCELA_SMOOTHING_TRANSLATION), - second_order_alpha(b, "second-order-alpha", ACCELA_SECOND_ORDER_ALPHA), - third_order_alpha(b, "third-order-alpha", ACCELA_THIRD_ORDER_ALPHA), - deadzone(b, "deadzone", 0), - expt(b, "exponent", 2) +FTNoIR_Filter::FTNoIR_Filter() : first_run(true) { } @@ -94,13 +86,13 @@ void FTNoIR_Filter::FilterHeadPoseData(const double* target_camera_position, const double vec2 = target_camera_position[i] - last_output[1][i]; const double vec3 = target_camera_position[i] - last_output[2][i]; const int sign = vec < 0 ? -1 : 1; - 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 a = i >= 3 ? s.rotation_alpha : s.translation_alpha; + const double a2 = a * s.second_order_alpha; + const double a3 = a * s.third_order_alpha; const double velocity = - parabola(a, vec, deadzone, expt) + - parabola(a2, vec2, deadzone, expt) + - parabola(a3, vec3, deadzone, expt); + parabola(a, vec, s.deadzone, s.expt) + + parabola(a2, vec2, s.deadzone, s.expt) + + parabola(a3, vec3, s.deadzone, s.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 43564bd8..2b93f550 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.h +++ b/ftnoir_filter_accela/ftnoir_filter_accela.h @@ -13,6 +13,25 @@ #include "facetracknoir/options.hpp" using namespace options; +struct settings { + pbundle b; + value rotation_alpha, + translation_alpha, + second_order_alpha, + third_order_alpha, + deadzone, + expt; + settings() : + b(bundle("Accela")), + rotation_alpha(b, "rotation-alpha", ACCELA_SMOOTHING_ROTATION), + translation_alpha(b, "translation-alpha", ACCELA_SMOOTHING_TRANSLATION), + second_order_alpha(b, "second-order-alpha", ACCELA_SECOND_ORDER_ALPHA), + third_order_alpha(b, "third-order-alpha", ACCELA_THIRD_ORDER_ALPHA), + deadzone(b, "deadzone", 0), + expt(b, "exponent", 2) + {} +}; + class FTNoIR_Filter : public IFilter { public: @@ -22,19 +41,13 @@ public: first_run = true; } void receiveSettings() { - b->reload(); + s.b->reload(); } private: + settings s; QMutex mutex; bool first_run; - pbundle b; - value rotation_alpha, - translation_alpha, - second_order_alpha, - third_order_alpha, - deadzone, - expt; double last_input[6]; double last_output[3][6]; QElapsedTimer timer; @@ -59,13 +72,7 @@ private: void discard(); void save(); FTNoIR_Filter* accela_filter; - pbundle b; - value rotation_alpha, - translation_alpha, - second_order_alpha, - third_order_alpha, - deadzone, - expt; + settings s; 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 256f35b4..cc759bcb 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp @@ -6,26 +6,18 @@ #include "facetracknoir/global-settings.h" FilterControls::FilterControls() : - accela_filter(NULL), - b(bundle("Accela")), - rotation_alpha(b, "rotation-alpha", ACCELA_SMOOTHING_ROTATION), - translation_alpha(b, "translation-alpha", ACCELA_SMOOTHING_TRANSLATION), - second_order_alpha(b, "second-order-alpha", ACCELA_SECOND_ORDER_ALPHA), - third_order_alpha(b, "third-order-alpha", ACCELA_THIRD_ORDER_ALPHA), - deadzone(b, "deadzone", 0), - expt(b, "exponent", 2) - + accela_filter(nullptr) { ui.setupUi( this ); connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); - tie_setting(rotation_alpha, ui.rotation_alpha); - tie_setting(translation_alpha, ui.translation_alpha); - tie_setting(second_order_alpha, ui.order_2nd); - tie_setting(third_order_alpha, ui.order_3rd); - tie_setting(deadzone, ui.deadzone); - tie_setting(expt, ui.expt); + tie_setting(s.rotation_alpha, ui.rotation_alpha); + tie_setting(s.translation_alpha, ui.translation_alpha); + tie_setting(s.second_order_alpha, ui.order_2nd); + tie_setting(s.third_order_alpha, ui.order_3rd); + tie_setting(s.deadzone, ui.deadzone); + tie_setting(s.expt, ui.expt); } void FilterControls::Initialize(QWidget *) { @@ -48,7 +40,7 @@ void FilterControls::doOK() { } void FilterControls::doCancel() { - if (!b->modifiedp()) + if (!s.b->modifiedp()) { close(); return; @@ -77,11 +69,11 @@ void FilterControls::doCancel() { void FilterControls::discard() { - b->revert(); + s.b->revert(); } void FilterControls::save() { - b->save(); + s.b->save(); if (accela_filter) accela_filter->receiveSettings(); } -- cgit v1.2.3 From 60a8fd51ba9cd77b1944d10cab75e095db7b2815 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 30 Dec 2013 11:03:00 +0100 Subject: ht: reduce boilerplate --- ftnoir_tracker_ht/ftnoir_tracker_ht.cpp | 72 ++++++++++++--------------------- ftnoir_tracker_ht/ftnoir_tracker_ht.h | 30 ++++++++++---- 2 files changed, 47 insertions(+), 55 deletions(-) diff --git a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp index 333ce28a..e154557e 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[] = { void Tracker::load_settings(ht_config_t* config) { int nframes = 0; - switch (static_cast(fps)) + switch (static_cast(s.fps)) { default: case 0: @@ -109,13 +109,13 @@ void Tracker::load_settings(ht_config_t* config) } config->classification_delay = 500; - config->field_of_view = fov; + config->field_of_view = s.fov; config->pyrlk_pyramids = 0; config->pyrlk_win_size_w = config->pyrlk_win_size_h = 21; config->max_keypoints = 350; config->keypoint_distance = 3.4; config->force_fps = nframes; - config->camera_index = camera_idx - 1; + config->camera_index = s.camera_idx - 1; config->ransac_num_iters = 100; config->ransac_max_reprojection_error = 8; config->ransac_max_inlier_error = 8; @@ -123,7 +123,7 @@ void Tracker::load_settings(ht_config_t* config) config->ransac_max_mean_error = 6.5; config->debug = 0; config->ransac_min_features = 0.72; - int res = resolution; + int res = s.resolution; if (res < 0 || res >= (int)(sizeof(resolution_choices) / sizeof(resolution_tuple))) res = 0; resolution_tuple r = resolution_choices[res]; @@ -135,17 +135,6 @@ void Tracker::load_settings(ht_config_t* config) } Tracker::Tracker() : - b(bundle("HT-Tracker")), - enableTX(b, "enable-tx", true), - enableTY(b, "enable-ty", true), - enableTZ(b, "enable-tz", true), - enableRX(b, "enable-rx", true), - enableRY(b, "enable-ry", true), - enableRZ(b, "enable-rz", true), - fov(b, "fov", 56), - fps(b, "fps", 0), - camera_idx(b, "camera-index", 0), - resolution(b, "resolution", 0), lck_shm(HT_SHM_NAME, HT_MUTEX_NAME, sizeof(ht_shm_t)), shm(reinterpret_cast(lck_shm.mem)), videoWidget(nullptr), @@ -205,19 +194,19 @@ void Tracker::GetHeadPoseData(double *data) shm->frame.width = 0; } if (shm->result.filled) { - if (enableRX) + if (s.enableRX) data[Yaw] = shm->result.rotx; - if (enableRY) { + if (s.enableRY) { data[Pitch] = shm->result.roty; } - if (enableRZ) { + if (s.enableRZ) { data[Roll] = shm->result.rotz; } - if (enableTX) + if (s.enableTX) data[TX] = shm->result.tx; - if (enableTY) + if (s.enableTY) data[TY] = shm->result.ty; - if (enableTZ) + if (s.enableTZ) data[TZ] = shm->result.tz; if (fabs(data[Yaw]) > 60 || fabs(data[Pitch]) > 50 || fabs(data[Roll]) > 40) { @@ -265,34 +254,23 @@ extern "C" FTNOIR_TRACKER_BASE_EXPORT ITrackerDialog* CALLING_CONVENTION GetDial return new TrackerControls; } -TrackerControls::TrackerControls() : - b(bundle("HT-Tracker")), - enableTX(b, "enable-tx", true), - enableTY(b, "enable-ty", true), - enableTZ(b, "enable-tz", true), - enableRX(b, "enable-rx", true), - enableRY(b, "enable-ry", true), - enableRZ(b, "enable-rz", true), - fov(b, "fov", 56), - fps(b, "fps", 0), - camera_idx(b, "camera-index", 0), - resolution(b, "resolution", 0) +TrackerControls::TrackerControls() { ui.setupUi(this); ui.cameraName->clear(); QList names = get_camera_names(); names.prepend("Any available"); ui.cameraName->addItems(names); - tie_setting(camera_idx, ui.cameraName); - tie_setting(fps, ui.cameraFPS); - tie_setting(fov, ui.cameraFOV); - tie_setting(enableTX, ui.tx); - tie_setting(enableTY, ui.ty); - tie_setting(enableTZ, ui.tz); - tie_setting(enableRX, ui.rx); - tie_setting(enableRY, ui.ry); - tie_setting(enableRZ, ui.rz); - tie_setting(resolution, ui.resolution); + tie_setting(s.camera_idx, ui.cameraName); + tie_setting(s.fps, ui.cameraFPS); + tie_setting(s.fov, ui.cameraFOV); + tie_setting(s.enableTX, ui.tx); + tie_setting(s.enableTY, ui.ty); + tie_setting(s.enableTZ, ui.tz); + tie_setting(s.enableRX, ui.rx); + tie_setting(s.enableRY, ui.ry); + tie_setting(s.enableRZ, ui.rz); + tie_setting(s.resolution, ui.resolution); connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); } @@ -304,13 +282,13 @@ void TrackerControls::Initialize(QWidget*) void TrackerControls::doOK() { - b->save(); + s.b->save(); this->close(); } void TrackerControls::doCancel() { - if (!b->modifiedp()) + if (!s.b->modifiedp()) { close(); return; @@ -322,11 +300,11 @@ void TrackerControls::doCancel() switch (ret) { case QMessageBox::Save: - b->save(); + s.b->save(); this->close(); break; case QMessageBox::Discard: - b->revert(); + s.b->revert(); this->close(); break; default: diff --git a/ftnoir_tracker_ht/ftnoir_tracker_ht.h b/ftnoir_tracker_ht/ftnoir_tracker_ht.h index 3140e99c..f45e54f9 100644 --- a/ftnoir_tracker_ht/ftnoir_tracker_ht.h +++ b/ftnoir_tracker_ht/ftnoir_tracker_ht.h @@ -18,6 +18,26 @@ #include "facetracknoir/options.hpp" using namespace options; +struct settings { + pbundle b; + value enableTX, enableTY, enableTZ, enableRX, enableRY, enableRZ; + value fov; + value fps, camera_idx, resolution; + settings() : + b(bundle("HT-Tracker")), + enableTX(b, "enable-tx", true), + enableTY(b, "enable-ty", true), + enableTZ(b, "enable-tz", true), + enableRX(b, "enable-rx", true), + enableRY(b, "enable-ry", true), + enableRZ(b, "enable-rz", true), + fov(b, "fov", 56), + fps(b, "fps", 0), + camera_idx(b, "camera-index", 0), + resolution(b, "resolution", 0) + {} +}; + class Tracker : public QObject, public ITracker { Q_OBJECT @@ -26,12 +46,9 @@ public: virtual ~Tracker(); void StartTracker(QFrame* frame); void GetHeadPoseData(double *data); - pbundle b; - value enableTX, enableTY, enableTZ, enableRX, enableRY, enableRZ; - value fov; - value fps, camera_idx, resolution; void load_settings(ht_config_t* config); private: + settings s; PortableLockedShm lck_shm; ht_shm_t* shm; QProcess subprocess; @@ -51,10 +68,7 @@ public: private: Ui::Form ui; - pbundle b; - value enableTX, enableTY, enableTZ, enableRX, enableRY, enableRZ; - value fov; - value fps, camera_idx, resolution; + settings s; private slots: void doOK(); -- cgit v1.2.3 From 272e784d6c79e5f43e2514c349f46734fbbd0078 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 30 Dec 2013 11:15:17 +0100 Subject: hydra: use new settings framework. also decruft --- ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp | 95 +---------- ftnoir_tracker_hydra/ftnoir_tracker_hydra.h | 57 +++---- .../ftnoir_tracker_hydra_dialog.cpp | 177 ++++----------------- ftnoir_tracker_hydra/ftnoir_tracker_hydra_dll.cpp | 18 +-- 4 files changed, 61 insertions(+), 286 deletions(-) diff --git a/ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp b/ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp index 31e3f319..70af2893 100644 --- a/ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp +++ b/ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp @@ -9,22 +9,9 @@ #endif #include #include -#if 0 -#include -#include -#include -#include -#endif -Hydra_Tracker::Hydra_Tracker() +Hydra_Tracker::Hydra_Tracker() : should_quit(false) { - bEnableRoll = true; - bEnablePitch = true; - bEnableYaw = true; - bEnableX = true; - bEnableY = true; - bEnableZ = true; - should_quit = false; for (int i = 0; i < 6; i++) newHeadPose[i] = 0; } @@ -35,48 +22,18 @@ Hydra_Tracker::~Hydra_Tracker() sixenseExit(); } -/* -void controller_manager_setup_callback( sixenseUtils::ControllerManager::setup_step step ) { - - QMessageBox::warning(0,"OpenTrack Info", "controller manager callback",QMessageBox::Ok,QMessageBox::NoButton); - if( sixenseUtils::getTheControllerManager()->isMenuVisible() ) { - // Ask the controller manager what the next instruction string should be. - std::string controller_manager_text_string = sixenseUtils::getTheControllerManager()->getStepString(); - QMessageBox::warning(0,"OpenTrack Info", controller_manager_text_string.c_str(),QMessageBox::Ok,QMessageBox::NoButton); - // We could also load the supplied controllermanager textures using the filename: sixenseUtils::getTheControllerManager()->getTextureFileName(); - - } -}*/ - void Hydra_Tracker::StartTracker(QFrame*) { - //QMessageBox::warning(0,"FaceTrackNoIR Notification", "Tracking loading settings...",QMessageBox::Ok,QMessageBox::NoButton); - loadSettings(); - - // Init sixense - //QMessageBox::warning(0,"OpenTrack Info", "sixense init",QMessageBox::Ok,QMessageBox::NoButton); sixenseInit(); - //QMessageBox::warning(0,"OpenTrack Info", "sixense init complete, setting controller manager",QMessageBox::Ok,QMessageBox::NoButton); - // Init the controller manager. This makes sure the controllers are present, assigned to left and right hands, and that - // the hemisphere calibration is complete. - //sixenseUtils::getTheControllerManager()->setGameType( sixenseUtils::ControllerManager::ONE_PLAYER_TWO_CONTROLLER ); - //sixenseUtils::getTheControllerManager()->registerSetupCallback( controller_manager_setup_callback ); - //QMessageBox::warning(0,"OpenTrack Info", "controller manager callback registered",QMessageBox::Ok,QMessageBox::NoButton); - return; } - void Hydra_Tracker::GetHeadPoseData(double *data) { sixenseSetActiveBase(0); sixenseAllControllerData acd; sixenseGetAllNewestData( &acd ); - //sixenseUtils::getTheControllerManager()->update( &acd ); - - //sixenseControllerData cd; - //Rotation quat = Rotation(acd.controllers[0].rot_quat[1],acd.controllers[0].rot_quat[2],acd.controllers[0].rot_quat[3],acd.controllers[0].rot_quat[0]); - sixenseMath::Matrix4 mat = sixenseMath::Matrix4(acd.controllers[0].rot_mat);// sixenseMath::Quat(acd.controllers[0].rot_quat[1],acd.controllers[0].rot_quat[2],acd.controllers[0].rot_quat[3],acd.controllers[0].rot_quat[0]); + sixenseMath::Matrix4 mat = sixenseMath::Matrix4(acd.controllers[0].rot_mat); float ypr[3]; @@ -90,62 +47,26 @@ void Hydra_Tracker::GetHeadPoseData(double *data) newHeadPose[TY] = acd.controllers[0].pos[1]/50.0f; newHeadPose[TZ] = acd.controllers[0].pos[2]/50.0f; - if (bEnableX) { + if (s.bEnableX) { data[TX] = newHeadPose[TX]; } - if (bEnableY) { + if (s.bEnableY) { data[TY] = newHeadPose[TY]; } - if (bEnableY) { + if (s.bEnableY) { data[TZ] = newHeadPose[TZ]; } - - if (bEnableYaw) { + if (s.bEnableYaw) { data[Yaw] = newHeadPose[Yaw] * 57.295781f; } - if (bEnablePitch) { + if (s.bEnablePitch) { data[Pitch] = newHeadPose[Pitch] * 57.295781f; } - if (bEnableRoll) { + if (s.bEnableRoll) { data[Roll] = newHeadPose[Roll] * 57.295781f; } } - -// -// Load the current Settings from the currently 'active' INI-file. -// -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(); - QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) - - qDebug() << "FTNoIR_Tracker::loadSettings says: iniFile = " << currentFile; - - iniFile.beginGroup ( "Hydra" ); - 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 Hydra_Tracker; diff --git a/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h b/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h index 240f0687..16629c3a 100644 --- a/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h +++ b/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h @@ -5,82 +5,63 @@ #include #include #include "facetracknoir/global-settings.h" +#include "facetracknoir/options.hpp" +using namespace options; + +struct settings { + pbundle b; + value bEnableRoll, bEnablePitch, bEnableYaw, bEnableX, bEnableY, bEnableZ; + settings() : + b(bundle("tracker-hydra")), + bEnableRoll(b, "enable-rz", true), + bEnablePitch(b, "enable-ry", true), + bEnableYaw(b, "enable-rx", true), + bEnableX(b, "enable-tx", true), + bEnableY(b, "enable-ty", true), + bEnableZ(b, "enable-tz", true) + {} +}; + class Hydra_Tracker : public ITracker { public: Hydra_Tracker(); ~Hydra_Tracker(); - void StartTracker(QFrame *) virt_override; void GetHeadPoseData(double *data) virt_override; - void loadSettings(); volatile bool should_quit; protected: void run(); // qthread override run method - private: + settings s; bool isCalibrated; - double newHeadPose[6]; // Structure with new headpose - bool bEnableRoll; - bool bEnablePitch; - bool bEnableYaw; - - bool bEnableX; - bool bEnableY; - bool bEnableZ; - QMutex mutex; - virtual int preferredHz() virt_override { return 250; } }; -// Widget that has controls for FTNoIR protocol client-settings. class TrackerControls: public QWidget, public ITrackerDialog { Q_OBJECT public: - explicit TrackerControls(); - ~TrackerControls(); - void showEvent (QShowEvent *); - void Initialize(QWidget *parent); void registerTracker(ITracker *) {} void unRegisterTracker() {} - private: + settings s; Ui::UIHydraControls 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_hydra/ftnoir_tracker_hydra_dialog.cpp b/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dialog.cpp index fa674662..e92180a3 100644 --- a/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dialog.cpp +++ b/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dialog.cpp @@ -1,37 +1,6 @@ -/******************************************************************************** -* 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_hydra.h" #include "facetracknoir/global-settings.h" -//******************************************************************************************************* -// FaceTrackNoIR Client Settings-dialog. -//******************************************************************************************************* - -// -// Constructor for server-settings-dialog -// TrackerControls::TrackerControls() : QWidget() { @@ -41,28 +10,14 @@ QWidget() connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); - 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))); -#if 0 - 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))); -#endif - // Load the settings from the current .INI-file - loadSettings(); -} - -// -// Destructor for server-dialog -// -TrackerControls::~TrackerControls() { - qDebug() << "~TrackerControls() says: started"; + tie_setting(s.bEnableYaw, ui.chkEnableYaw); + tie_setting(s.bEnablePitch, ui.chkEnablePitch); + tie_setting(s.bEnableRoll, ui.chkEnableRoll); + tie_setting(s.bEnableX, ui.chkEnableX); + tie_setting(s.bEnableY, ui.chkEnableY); + tie_setting(s.bEnableZ, ui.chkEnableZ); } -// -// Initialize tracker-client-dialog -// void TrackerControls::Initialize(QWidget *parent) { QPoint offsetpos(100, 100); @@ -72,108 +27,38 @@ void TrackerControls::Initialize(QWidget *parent) { show(); } -// -// OK clicked on server-dialog -// void TrackerControls::doOK() { - save(); + s.b->save(); this->close(); } -// override show event -void TrackerControls::showEvent ( QShowEvent * ) { - 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 ( "Hydra" ); - 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; + 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; + } } -// -// 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 ( "Hydra" ); - 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 (); - - 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_hydra/ftnoir_tracker_hydra_dll.cpp b/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dll.cpp index db6f658c..a2cc7c01 100644 --- a/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dll.cpp +++ b/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dll.cpp @@ -3,31 +3,19 @@ #include #include "facetracknoir/global-settings.h" -FTNoIR_TrackerDll::FTNoIR_TrackerDll() { - //populate the description strings - trackerFullName = "Hydra"; - trackerShortName = "Hydra"; - trackerDescription = "Hydra"; -} - -FTNoIR_TrackerDll::~FTNoIR_TrackerDll() -{ - -} - void FTNoIR_TrackerDll::getFullName(QString *strToBeFilled) { - *strToBeFilled = trackerFullName; + *strToBeFilled = "Hydra"; } void FTNoIR_TrackerDll::getShortName(QString *strToBeFilled) { - *strToBeFilled = trackerShortName; + *strToBeFilled = "Hydra"; } void FTNoIR_TrackerDll::getDescription(QString *strToBeFilled) { - *strToBeFilled = trackerDescription; + *strToBeFilled = "Hydra"; } void FTNoIR_TrackerDll::getIcon(QIcon *icon) -- 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(-) 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(-) 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 ae777909d23d7cf34d5b2e48a568c1df9dfb9303 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 30 Dec 2013 12:56:34 +0100 Subject: hatire: use new settings framework --- ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp | 207 ++++++++++----------- ftnoir_tracker_hatire/ftnoir_tracker_hat.h | 44 ----- .../ftnoir_tracker_hat_dialog.cpp | 198 +++++++------------- ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.h | 47 +---- .../ftnoir_tracker_hat_settings.cpp | 145 --------------- .../ftnoir_tracker_hat_settings.h | 124 ++++++------ 6 files changed, 240 insertions(+), 525 deletions(-) delete mode 100644 ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.cpp diff --git a/ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp b/ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp index f902b207..dc4b2879 100644 --- a/ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp +++ b/ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp @@ -39,7 +39,6 @@ FTNoIR_Tracker::FTNoIR_Tracker() HAT.Trans[1]=0; HAT.Trans[2]=0; - // prepare & reserve QByteArray dataRead.resize(4096); dataRead.clear(); @@ -47,8 +46,6 @@ FTNoIR_Tracker::FTNoIR_Tracker() Begin.append((char) 0xAA); End.append((char) 0x55); End.append((char) 0x55); - - settings.load_ini(); } FTNoIR_Tracker::~FTNoIR_Tracker() @@ -64,20 +61,18 @@ FTNoIR_Tracker::~FTNoIR_Tracker() //send CENTER to Arduino void FTNoIR_Tracker::notifyCenter() { - sendcmd(sCmdCenter); + sendcmd(static_cast(settings.CmdCenter).toLatin1()); } //send ZERO to Arduino bool FTNoIR_Tracker::notifyZeroed() { - sendcmd(sCmdZero); + sendcmd(static_cast(settings.CmdZero).toLatin1()); return true; } - - //send RESET to Arduino void FTNoIR_Tracker::reset() { - sendcmd(sCmdReset); + sendcmd(static_cast(settings.CmdReset).toLatin1()); } @@ -266,39 +261,91 @@ void FTNoIR_Tracker::StopTracker( bool exit ) #else void FTNoIR_Tracker::StartTracker(QFrame*) { + static const int databits_lookup[] = { + 5, + 6, + 7, + 8, + -1 + }; + + 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; - - settings.load_ini(); - applysettings(settings); ComPort = new QSerialPort(this); - ComPort->setPortName(sSerialPortName); - if (ComPort->open(QIODevice::ReadWrite ) == true) { + { + ComPort->setPortName(QSerialPortInfo::availablePorts().value(settings.SerialPortName).portName()); + } + 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->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) - ) { + && ComPort->setDataErrorPolicy(QSerialPort::IgnorePolicy) + ){ // Wait init arduino sequence - for (int i = 1; i <=iDelayInit; i+=50) { + for (int i = 1; i <=settings.DelayInit; i+=50) { if (ComPort->waitForReadyRead(50)) break; } - sendcmd(sCmdInit); + sendcmd(static_cast(settings.CmdInit).toLatin1()); // Wait init MPU sequence - for (int i = 1; i <=iDelayStart; i+=50) { + for (int i = 1; i <=settings.DelayStart; i+=50) { if (ComPort->waitForReadyRead(50)) break; } // Send START cmd to IMU - sendcmd(sCmdStart); + sendcmd(static_cast(settings.CmdStart).toLatin1()); // Wait start MPU sequence - for (int i = 1; i <=iDelaySeq; i+=50) { + for (int i = 1; i <=settings.DelaySeq; i+=50) { if (ComPort->waitForReadyRead(50)) break; } } else { @@ -329,7 +376,7 @@ void FTNoIR_Tracker::GetHeadPoseData(THeadPoseData *data) while (dataRead.length()>=30) { if ((dataRead.startsWith(Begin) && ( dataRead.mid(28,2)==End )) ) { // .Begin==0xAAAA .End==0x5555 QDataStream datastream(dataRead.left(30)); - if (bBigEndian) datastream.setByteOrder(QDataStream::BigEndian ); + if (settings.BigEndian) datastream.setByteOrder(QDataStream::BigEndian ); else datastream.setByteOrder(QDataStream::LittleEndian ); datastream>>ArduinoData; frame_cnt++; @@ -359,34 +406,45 @@ void FTNoIR_Tracker::GetHeadPoseData(THeadPoseData *data) #ifdef OPENTRACK_API data[frame_cnt] = (long) HAT.Code; - if (bEnableYaw) { - if (bInvertYaw ) data[Yaw] = (double) HAT.Rot[iYawAxe] * -1.0f; - else data[Yaw] = (double) HAT.Rot[iYawAxe]; + 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 (bEnablePitch) { - if (bInvertPitch) data[Pitch] = (double) HAT.Rot[iPitchAxe] * -1.0f; - else data[Pitch] = (double) HAT.Rot[iPitchAxe]; + 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 (bEnableRoll) { - if (bInvertRoll) data[Roll] = (double) HAT.Rot[iRollAxe] * -1.0f; - else data[Roll] = (double) HAT.Rot[iRollAxe]; + 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 (bEnableX) { - if (bInvertX) data[TX] =(double) HAT.Trans[iXAxe]* -1.0f; - else data[TX] = HAT.Trans[iXAxe]; + 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 (bEnableY) { - if (bInvertY) data[TY] =(double) HAT.Trans[iYAxe]* -1.0f; - else data[TY] = HAT.Trans[iYAxe]; + 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 (bEnableZ) { - if (bInvertZ) data[TZ] = HAT.Trans[iZAxe]* -1.0f; - else data[TZ] = HAT.Trans[iZAxe]; + 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)]; } #else data->frame_number = (long) HAT.Code; @@ -421,72 +479,13 @@ void FTNoIR_Tracker::GetHeadPoseData(THeadPoseData *data) else data->z = (double) HAT.Trans[iZAxe]; } #endif - - // For debug - //data->x=dataRead.length(); - //data->y=CptError; } - - -// -// Apply modification Settings -// void FTNoIR_Tracker::applysettings(const TrackerSettings& settings){ QMutexLocker lck(&mutex); - 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; - - iBaudRate=settings.pBaudRate; - iDataBits=settings.pDataBits; - iParity=settings.pParity; - iStopBits=settings.pStopBits; - iFlowControl=settings.pFlowControl; - - sCmdStart= settings.CmdStart.toLatin1(); - sCmdStop= settings.CmdStop.toLatin1(); - sCmdInit= settings.CmdInit.toLatin1(); - sCmdReset= settings.CmdReset.toLatin1(); - sCmdCenter= settings.CmdCenter.toLatin1(); - sCmdZero= settings.CmdZero.toLatin1(); - - iDelayInit=settings.DelayInit; - iDelayStart=settings.DelayStart; - iDelaySeq=settings.DelaySeq; - - bBigEndian=settings.BigEndian; + settings.b->reload(); } - - -//////////////////////////////////////////////////////////////////////////////// -// 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. -//////////////////////////////////////////////////////////////////////////////// #ifdef OPENTRACK_API extern "C" FTNOIR_TRACKER_BASE_EXPORT ITracker* CALLING_CONVENTION GetConstructor() #else diff --git a/ftnoir_tracker_hatire/ftnoir_tracker_hat.h b/ftnoir_tracker_hatire/ftnoir_tracker_hat.h index ec1125b9..a4243c38 100644 --- a/ftnoir_tracker_hatire/ftnoir_tracker_hat.h +++ b/ftnoir_tracker_hatire/ftnoir_tracker_hat.h @@ -62,51 +62,7 @@ private: int frame_cnt; TrackerSettings settings; - - 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; - - QByteArray sCmdStart; - QByteArray sCmdStop; - QByteArray sCmdInit; - QByteArray sCmdReset; - QByteArray sCmdCenter; - QByteArray sCmdZero; - - int iDelayInit; - int iDelayStart; - int iDelaySeq; - - bool bBigEndian; - - QString sSerialPortName; - QSerialPort::BaudRate iBaudRate; - QSerialPort::DataBits iDataBits; - QSerialPort::Parity iParity; - QSerialPort::StopBits iStopBits; - QSerialPort::FlowControl iFlowControl; - int CptError; - - }; diff --git a/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.cpp b/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.cpp index 14b6ef0d..0ef723c9 100644 --- a/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.cpp +++ b/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.cpp @@ -37,11 +37,10 @@ // // Constructor for server-settings-dialog // -TrackerControls::TrackerControls() : theTracker(NULL), settingsDirty(false), timer(this) +TrackerControls::TrackerControls() : theTracker(NULL), timer(this) { ui.setupUi( this ); - settings.load_ini(); ui.label_version->setText(VER_FILEVERSION_STR); @@ -49,21 +48,13 @@ TrackerControls::TrackerControls() : theTracker(NULL), settingsDirty(false), tim 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 { - - 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.cbSerialPort->setCurrentIndex(settings.SerialPortName); } // Serial config ui.QCB_Serial_baudRate->clear(); @@ -72,122 +63,79 @@ TrackerControls::TrackerControls() : theTracker(NULL), settingsDirty(false), tim 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_baudRate->setCurrentIndex(ui.QCB_Serial_baudRate->findData(settings.pBaudRate)); 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_dataBits->setCurrentIndex(ui.QCB_Serial_dataBits->findData(settings.pDataBits)); 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("Mark"), QSerialPort::MarkParity); ui.QCB_Serial_parity->addItem(QLatin1String("Space"), QSerialPort::SpaceParity); - ui.QCB_Serial_parity->setCurrentIndex(ui.QCB_Serial_parity->findData(settings.pParity)); + ui.QCB_Serial_parity->addItem(QLatin1String("Mark"), QSerialPort::MarkParity); ui.QCB_Serial_stopBits->clear(); - ui.QCB_Serial_stopBits->addItem(QLatin1String("1"), QSerialPort::OneStop); - ui.QCB_Serial_stopBits->addItem(QLatin1String("1.5"), QSerialPort::OneAndHalfStop); - ui.QCB_Serial_stopBits->addItem(QLatin1String("2"), QSerialPort::TwoStop); - ui.QCB_Serial_stopBits->setCurrentIndex(ui.QCB_Serial_stopBits->findData(settings.pStopBits)); + 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"), QSerialPort::NoFlowControl); - ui.QCB_Serial_flowControl->addItem(QLatin1String("RTS/CTS"), QSerialPort::HardwareControl); - ui.QCB_Serial_flowControl->addItem(QLatin1String("XON/XOFF"), QSerialPort::SoftwareControl); - ui.QCB_Serial_flowControl->setCurrentIndex(ui.QCB_Serial_flowControl->findData(settings.pFlowControl)); - - - 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); - - ui.le_cmd_start->setText(settings.CmdStart); - ui.le_cmd_stop->setText(settings.CmdStop); - ui.le_cmd_init->setText(settings.CmdInit); - ui.le_cmd_reset->setText(settings.CmdReset); - ui.le_cmd_center->setText(settings.CmdCenter); - ui.le_cmd_zero->setText(settings.CmdZero); - - ui.spb_BeforeInit->setValue(settings.DelayInit); - ui.spb_BeforeStart->setValue(settings.DelayStart); - ui.spb_AfterStart->setValue(settings.DelaySeq); - - ui.cb_Endian->setChecked(settings.BigEndian); - + 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.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.le_cmd_start, SIGNAL(textEdited (QString )), this,SLOT(set_cmd_start(QString))); - connect(ui.le_cmd_stop, SIGNAL(textEdited ( QString )), this,SLOT(set_cmd_stop(QString))); - connect(ui.le_cmd_init, SIGNAL(textChanged ( QString )), this,SLOT(set_cmd_init(QString))); - connect(ui.le_cmd_reset, SIGNAL(textChanged ( QString )), this,SLOT(set_cmd_reset(QString))); - connect(ui.le_cmd_center, SIGNAL(textChanged ( QString )),this,SLOT(set_cmd_center(QString))); - connect(ui.le_cmd_zero, SIGNAL(textChanged ( QString )),this,SLOT(set_cmd_zero(QString))); - - connect(ui.spb_BeforeInit, SIGNAL(valueChanged ( int )), this,SLOT(set_DelayInit(int))); - connect(ui.spb_BeforeStart, SIGNAL(valueChanged ( int )), this,SLOT(set_DelayStart(int))); - connect(ui.spb_AfterStart, SIGNAL(valueChanged ( int )), this,SLOT(set_DelaySeq(int))); - - connect( ui.cb_Endian,SIGNAL(toggled(bool)), this,SLOT(set_endian(bool)) ); - - - connect(ui.QCB_Serial_baudRate, SIGNAL(currentIndexChanged(int)), this,SLOT(set_mod_baud(int)) ); - connect(ui.QCB_Serial_dataBits, SIGNAL(currentIndexChanged(int)), this,SLOT(set_mod_dataBits(int)) ); - connect(ui.QCB_Serial_parity, SIGNAL(currentIndexChanged(int)), this,SLOT(set_mod_parity(int)) ); - connect(ui.QCB_Serial_stopBits, SIGNAL(currentIndexChanged(int)), this,SLOT(set_mod_stopBits(int)) ); - connect(ui.QCB_Serial_flowControl, SIGNAL(currentIndexChanged(int)), this,SLOT(set_mod_flowControl(int)) ); - connect(ui.btnReset, SIGNAL(clicked()), this, SLOT(doReset())); connect(ui.btnCenter, SIGNAL(clicked()), this, SLOT(doCenter())); connect(ui.btnZero, SIGNAL(clicked()), this, SLOT(doZero())); @@ -196,7 +144,6 @@ TrackerControls::TrackerControls() : theTracker(NULL), settingsDirty(false), tim connect(ui.btn_icone, SIGNAL(clicked()), this, SLOT(doSerialInfo())); connect(&timer,SIGNAL(timeout()), this,SLOT(poll_tracker_info())); - } // @@ -217,16 +164,6 @@ void TrackerControls::Initialize(QWidget *parent) { } -// -// Apply online settings to tracker -// -void TrackerControls::settings_changed() -{ - settingsDirty = true; - if (theTracker) theTracker->applysettings(settings); -} - - // // Center asked to ARDUINO // @@ -299,8 +236,9 @@ void TrackerControls::WriteMsgInfo(const QByteArray &MsgInfo) void TrackerControls::doSave() { - settingsDirty=false; - settings.save_ini(); + settings.b->save(); + if (theTracker) + theTracker->applysettings(settings); } @@ -308,8 +246,9 @@ void TrackerControls::doSave() { // OK clicked on server-dialog // void TrackerControls::doOK() { - settingsDirty=false; - settings.save_ini(); + settings.b->save(); + if (theTracker) + theTracker->applysettings(settings); this->close(); } @@ -320,14 +259,15 @@ 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 ); + 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.save_ini(); + settings.b->save(); close(); break; case QMessageBox::Discard: + settings.b->revert(); close(); break; case QMessageBox::Cancel: @@ -348,7 +288,7 @@ void TrackerControls::registerTracker(ITracker *tracker) { theTracker = static_cast(tracker); connect(theTracker, SIGNAL(sendMsgInfo(QByteArray)),this , SLOT(WriteMsgInfo(QByteArray))); - if (isVisible() && settingsDirty) theTracker->applysettings(settings); + if (isVisible() && settings.b->modifiedp()) theTracker->applysettings(settings); ui.cbSerialPort->setEnabled(false); ui.pteINFO->clear(); @@ -367,16 +307,6 @@ void TrackerControls::unRegisterTracker() { 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. #ifdef OPENTRACK_API extern "C" FTNOIR_TRACKER_BASE_EXPORT ITrackerDialog* CALLING_CONVENTION GetDialog( ) #else diff --git a/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.h b/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.h index e413ded6..82c69e0d 100644 --- a/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.h +++ b/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.h @@ -25,7 +25,6 @@ public: void Initialize(QWidget *parent) virt_override; void registerTracker(ITracker *tracker) virt_override; void unRegisterTracker() virt_override; - private: Ui::UIHATControls ui; FTNoIR_Tracker *theTracker; @@ -35,49 +34,7 @@ public slots: void WriteMsgInfo(const QByteArray &MsgInfo); protected slots: - void set_mod_port(const QString & val) { settings.SerialPortName =val; 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 set_cmd_start(const QString &val) { settings.CmdStart = val; settings_changed(); } - void set_cmd_stop(const QString &val) { settings.CmdStop = val; settings_changed(); } - void set_cmd_init(const QString &val) { settings.CmdInit = val; settings_changed(); } - void set_cmd_reset(const QString &val) { settings.CmdReset = val; settings_changed(); } - void set_cmd_center(const QString &val) { settings.CmdCenter = val; settings_changed(); } - void set_cmd_zero(const QString &val) { settings.CmdZero = val; settings_changed(); } - - void set_DelayInit(int val) { settings.DelayInit = val; settings_changed(); } - void set_DelayStart(int val) { settings.DelayStart = val; settings_changed(); } - void set_DelaySeq(int val) { settings.DelaySeq = val; settings_changed(); } - - void set_endian(bool val) { settings.BigEndian = val; settings_changed(); } - - void set_mod_baud(int val) { settings.pBaudRate = static_cast(ui.QCB_Serial_baudRate->itemData(val).toInt()) ; settings_changed(); } - void set_mod_dataBits(int val) { settings.pDataBits = static_cast(ui.QCB_Serial_dataBits->itemData(val).toInt()) ; settings_changed(); } - void set_mod_parity(int val) { settings.pParity = static_cast(ui.QCB_Serial_parity->itemData(val).toInt()) ; settings_changed(); } - void set_mod_stopBits(int val) { settings.pStopBits = static_cast(ui.QCB_Serial_stopBits->itemData(val).toInt()); settings_changed(); } - void set_mod_flowControl(int val) { settings.pFlowControl = static_cast(ui.QCB_Serial_flowControl->itemData(val).toInt()) ; settings_changed(); } - - void doOK(); + void doOK(); void doCancel(); void doSave(); void doReset(); @@ -88,8 +45,6 @@ protected slots: void doSerialInfo(); protected: - bool settingsDirty; - void settings_changed(); TrackerSettings settings; QTimer timer; }; diff --git a/ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.cpp b/ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.cpp deleted file mode 100644 index 0be912f2..00000000 --- a/ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.cpp +++ /dev/null @@ -1,145 +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 -#include -#include - -#include "ftnoir_tracker_hat_settings.h" - -void 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( "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(); - - - CmdStart=iniFile.value ( "CmdStart").toString(); - CmdStop=iniFile.value ( "CmdStop" ).toString(); - CmdInit=iniFile.value ( "CmdInit" ).toString(); - CmdReset=iniFile.value ( "CmdReset" ).toString(); - CmdCenter=iniFile.value ( "CmdCenter" ).toString(); - CmdZero=iniFile.value ( "CmdZero" ).toString(); - - DelayInit=iniFile.value("DelayInit",0).toInt(); - DelayStart=iniFile.value("DelayStart",0).toInt(); - DelaySeq=iniFile.value("DelaySeq",0).toInt(); - - BigEndian=iniFile.value("BigEndian",0).toBool(); - - - pBaudRate=static_cast(iniFile.value("BaudRate",QSerialPort::Baud115200).toInt()); - pDataBits=static_cast(iniFile.value("DataBits",QSerialPort::Data8).toInt()); - pParity=static_cast(iniFile.value("Parity",QSerialPort::NoParity).toInt()); - pStopBits=static_cast(iniFile.value("StopBits",QSerialPort::OneStop).toInt()); - pFlowControl=static_cast(iniFile.value("FlowControl",QSerialPort::HardwareControl).toInt()); - - iniFile.endGroup(); -} - - -void TrackerSettings::save_ini() const -{ - - 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 ( "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.setValue ( "CmdStart",CmdStart.toLatin1()); - iniFile.setValue ( "CmdStop",CmdStop.toLatin1()); - iniFile.setValue ( "CmdInit",CmdInit.toLatin1()); - iniFile.setValue ( "CmdReset",CmdReset.toLatin1()); - iniFile.setValue ( "CmdCenter",CmdCenter.toLatin1() ); - iniFile.setValue ( "CmdZero",CmdZero.toLatin1() ); - - iniFile.setValue ( "DelayInit",DelayInit); - iniFile.setValue ( "DelayStart",DelayStart); - iniFile.setValue ( "DelaySeq",DelaySeq); - - iniFile.setValue("BigEndian",BigEndian); - - iniFile.setValue("BaudRate",pBaudRate); - iniFile.setValue("DataBits",pDataBits); - iniFile.setValue("Parity",pParity); - iniFile.setValue("StopBits",pStopBits); - iniFile.setValue("FlowControl",pFlowControl); - - - iniFile.endGroup(); -} - diff --git a/ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.h b/ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.h index 2e84bde8..8739394f 100644 --- a/ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.h +++ b/ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.h @@ -5,61 +5,81 @@ * copyright notice and this permission notice appear in all copies. */ -#ifndef FTNOIR_TRACKER_HAT_SETTINGS_H -#define FTNOIR_TRACKER_HAT_SETTINGS_H +#pragma once #include +#include "facetracknoir/options.hpp" +#include +using namespace options; -//----------------------------------------------------------------------------- struct TrackerSettings { - - void load_ini(); - void save_ini() const; - - 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; - - QString CmdStart; - QString CmdStop; - QString CmdInit; - QString CmdReset; - QString CmdCenter; - QString CmdZero; - - int DelayInit; - int DelayStart; - int DelaySeq; - - bool BigEndian; - - QString SerialPortName; - QSerialPort::BaudRate pBaudRate; - QSerialPort::DataBits pDataBits; - QSerialPort::Parity pParity; - QSerialPort::StopBits pStopBits; - QSerialPort::FlowControl pFlowControl; - + 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) + { + } }; - - -#endif //FTNOIR_TRACKER_HAT_SETTINGS_H \ No newline at end of file -- cgit v1.2.3 From 9bc97c68bdc64bc4d5735a377b41cf0d697a7824 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 30 Dec 2013 12:56:52 +0100 Subject: resize hatire dialog not to look cramped on Linux --- ftnoir_tracker_hatire/ftnoir_hatcontrols.ui | 116 ++++++++++++++-------------- 1 file changed, 58 insertions(+), 58 deletions(-) diff --git a/ftnoir_tracker_hatire/ftnoir_hatcontrols.ui b/ftnoir_tracker_hatire/ftnoir_hatcontrols.ui index 4446ca85..8a6bae62 100644 --- a/ftnoir_tracker_hatire/ftnoir_hatcontrols.ui +++ b/ftnoir_tracker_hatire/ftnoir_hatcontrols.ui @@ -7,7 +7,7 @@ 0 0 307 - 509 + 567 @@ -126,47 +126,47 @@ 4 - - + + - + 0 0 - 65536 + 65535 16777215 - - Serial port + + false + + + QComboBox::AdjustToMinimumContentsLength + + + 0 - - + + - + 0 0 - 65535 + 65536 16777215 - - false - - - QComboBox::AdjustToMinimumContentsLength - - - 0 + + Serial port @@ -1030,45 +1030,6 @@ p, li { white-space: pre-wrap; } About - - - - <!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 - - - - - - - false - - - - - - - :/images/hat_logo.png - - - - - 128 - 128 - - - - true - - - @@ -1123,6 +1084,45 @@ p, li { white-space: pre-wrap; } + + + + 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 + + + -- cgit v1.2.3 From a54f8dede2cc679d0ef2fe30369cf3764ad3ab54 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 30 Dec 2013 12:58:09 +0100 Subject: hatire: don't hardcode stuff in lookup tables --- ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp b/ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp index dc4b2879..3547dd6b 100644 --- a/ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp +++ b/ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp @@ -262,11 +262,11 @@ void FTNoIR_Tracker::StopTracker( bool exit ) void FTNoIR_Tracker::StartTracker(QFrame*) { static const int databits_lookup[] = { - 5, - 6, - 7, - 8, - -1 + QSerialPort::Data5, + QSerialPort::Data6, + QSerialPort::Data7, + QSerialPort::Data8, + QSerialPort::UnknownDataBits }; struct Local { -- cgit v1.2.3 From bfaa79b997032769cf6b2b68f275260f618dbf58 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 30 Dec 2013 13:26:21 +0100 Subject: settings framework for rift --- ftnoir_tracker_rift/ftnoir_tracker_rift.cpp | 81 ++------------- ftnoir_tracker_rift/ftnoir_tracker_rift.h | 44 ++++---- ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp | 115 +++------------------ 3 files changed, 42 insertions(+), 198 deletions(-) diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp b/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp index da44ea0c..e10db0bf 100644 --- a/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp +++ b/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp @@ -8,14 +8,6 @@ using namespace OVR; Rift_Tracker::Rift_Tracker() { - bEnableRoll = true; - bEnablePitch = true; - bEnableYaw = true; -#if 0 - bEnableX = true; - bEnableY = true; - bEnableZ = true; -#endif should_quit = false; pManager = NULL; pSensor = NULL; @@ -38,10 +30,6 @@ Rift_Tracker::~Rift_Tracker() void Rift_Tracker::StartTracker(QFrame*) { - loadSettings(); - // - // Startup the Oculus SDK device handling, use the first Rift sensor we find. - // System::Init(Log::ConfigureDefaultLog(LogMask_All)); pManager = DeviceManager::Create(); if (pManager != NULL) @@ -81,80 +69,25 @@ void Rift_Tracker::GetHeadPoseData(double *data) newHeadPose[Pitch] = pitch; newHeadPose[Roll] = roll; newHeadPose[Yaw] = yaw; - if (useYawSpring) + if (s.useYawSpring) { - newHeadPose[Yaw] = old_yaw*persistence + (yaw-old_yaw); - if(newHeadPose[Yaw]>deadzone)newHeadPose[Yaw]-= constant_drift; - if(newHeadPose[Yaw]<-deadzone)newHeadPose[Yaw]+= constant_drift; + newHeadPose[Yaw] = old_yaw*s.persistence + (yaw-old_yaw); + if(newHeadPose[Yaw]>s.deadzone)newHeadPose[Yaw]-= s.constant_drift; + if(newHeadPose[Yaw]<-s.deadzone)newHeadPose[Yaw]+= s.constant_drift; old_yaw=yaw; } -#if 0 - newHeadPose[TX] = acd.controllers[0].pos[0]/50.0f; - newHeadPose[TY] = acd.controllers[0].pos[1]/50.0f; - newHeadPose[TZ] = acd.controllers[0].pos[2]/50.0f; - - if (bEnableX) { - data[TX] = newHeadPose[TX]; - } - if (bEnableY) { - data[TY] = newHeadPose[TY]; - } - if (bEnableY) { - data[TZ] = newHeadPose[TZ]; - } -#endif - if (bEnableYaw) { + if (s.bEnableYaw) { data[Yaw] = newHeadPose[Yaw] * 57.295781f; } - if (bEnablePitch) { + if (s.bEnablePitch) { data[Pitch] = newHeadPose[Pitch] * 57.295781f; } - if (bEnableRoll) { + if (s.bEnableRoll) { data[Roll] = newHeadPose[Roll] * 57.295781f; } } } - -// -// Load the current Settings from the currently 'active' INI-file. -// -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(); - QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) - - qDebug() << "FTNoIR_Tracker::loadSettings says: iniFile = " << currentFile; - - iniFile.beginGroup ( "Rift" ); - bEnableRoll = iniFile.value ( "EnableRoll", 1 ).toBool(); - bEnablePitch = iniFile.value ( "EnablePitch", 1 ).toBool(); - bEnableYaw = iniFile.value ( "EnableYaw", 1 ).toBool(); -#if 0 - bEnableX = iniFile.value ( "EnableX", 1 ).toBool(); - bEnableY = iniFile.value ( "EnableY", 1 ).toBool(); - bEnableZ = iniFile.value ( "EnableZ", 1 ).toBool(); -#endif - useYawSpring = iniFile.value("yaw-spring", false).toBool(); - constant_drift = iniFile.value("constant-drift", 0.000005).toDouble(); - persistence = iniFile.value("persistence", 0.99999).toDouble(); - deadzone = iniFile.value("deadzone", 0.02).toDouble(); - 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 Rift_Tracker; diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift.h b/ftnoir_tracker_rift/ftnoir_tracker_rift.h index 3920c6ad..eadf5fa5 100644 --- a/ftnoir_tracker_rift/ftnoir_tracker_rift.h +++ b/ftnoir_tracker_rift/ftnoir_tracker_rift.h @@ -8,6 +8,25 @@ #include "facetracknoir/global-settings.h" #include "OVR.h" #include +#include "facetracknoir/options.hpp" +using namespace options; + +struct settings { + pbundle b; + value bEnableYaw, bEnablePitch, bEnableRoll, useYawSpring; + value constant_drift, persistence, deadzone; + settings() : + b(bundle("Rift")), + bEnableYaw(b, "EnableYaw", true), + bEnablePitch(b, "EnablePitch", true), + bEnableRoll(b, "EnableRoll", true), + useYawSpring(b, "yaw-spring", false), + constant_drift(b, "constant-drift", 0.000005), + persistence(b, "persistence", 0.99999), + deadzone(b, "deadzone", 0.02) + {} +}; + class Rift_Tracker : public ITracker { public: @@ -16,7 +35,6 @@ public: void StartTracker(QFrame *) virt_override; void GetHeadPoseData(double *data) virt_override; - void loadSettings(); virtual int preferredHz() virt_override { return 250; } volatile bool should_quit; protected: @@ -27,16 +45,8 @@ private: OVR::DeviceManager* pManager; OVR::SensorDevice* pSensor; OVR::SensorFusion* pSFusion; - bool bEnableRoll; - bool bEnablePitch; - bool bEnableYaw; -#if 0 - bool bEnableX; - bool bEnableY; - bool bEnableZ; -#endif - bool useYawSpring; - double old_yaw, constant_drift, persistence, deadzone; + settings s; + double old_yaw; }; // Widget that has controls for FTNoIR protocol client-settings. @@ -44,10 +54,7 @@ class TrackerControls: public QWidget, public ITrackerDialog { Q_OBJECT public: - explicit TrackerControls(); - ~TrackerControls(); - void showEvent (QShowEvent *); void Initialize(QWidget *parent); void registerTracker(ITracker *) {} @@ -55,17 +62,10 @@ public: private: Ui::UIRiftControls ui; - void loadSettings(); - void save(); - - /** helper **/ - bool settingsDirty; - + settings s; private slots: void doOK(); void doCancel(); - void settingChanged() { settingsDirty = true; } - void settingChanged(int) { settingsDirty = true; } }; //******************************************************************************************************* diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp b/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp index 2efefbb3..5d3b30c1 100644 --- a/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp +++ b/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp @@ -17,28 +17,16 @@ QWidget() connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); - 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))); -#if 0 - 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))); -#endif - // Load the settings from the current .INI-file - loadSettings(); + tie_setting(s.bEnableYaw, ui.chkEnableYaw); + tie_setting(s.bEnablePitch, ui.chkEnablePitch); + tie_setting(s.bEnableRoll, ui.chkEnableRoll); + + tie_setting(s.constant_drift, ui.constantDrift); + tie_setting(s.deadzone, ui.deadzone); + tie_setting(s.persistence, ui.persistence); + tie_setting(s.useYawSpring, ui.yawSpring); } -// -// Destructor for server-dialog -// -TrackerControls::~TrackerControls() { - qDebug() << "~TrackerControls() says: started"; -} - -// -// Initialize tracker-client-dialog -// void TrackerControls::Initialize(QWidget *parent) { QPoint offsetpos(100, 100); @@ -52,15 +40,10 @@ void TrackerControls::Initialize(QWidget *parent) { // OK clicked on server-dialog // void TrackerControls::doOK() { - save(); + s.b->save(); this->close(); } -// override show event -void TrackerControls::showEvent ( QShowEvent * ) { - loadSettings(); -} - // // Cancel clicked on server-dialog // @@ -68,24 +51,19 @@ 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; - + 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: - 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; } } @@ -94,73 +72,6 @@ void TrackerControls::doCancel() { } } - -// -// 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 ( "Rift" ); - ui.chkEnableRoll->setChecked(iniFile.value ( "EnableRoll", 1 ).toBool()); - ui.chkEnablePitch->setChecked(iniFile.value ( "EnablePitch", 1 ).toBool()); - ui.chkEnableYaw->setChecked(iniFile.value ( "EnableYaw", 1 ).toBool()); -#if 0 - ui.chkEnableX->setChecked(iniFile.value ( "EnableX", 1 ).toBool()); - ui.chkEnableY->setChecked(iniFile.value ( "EnableY", 1 ).toBool()); - ui.chkEnableZ->setChecked(iniFile.value ( "EnableZ", 1 ).toBool()); -#endif - ui.yawSpring->setChecked(iniFile.value("yaw-spring", true).toBool()); - ui.deadzone->setValue(iniFile.value("deadzone", 0.02).toDouble()); - ui.constantDrift->setValue(iniFile.value("constant-drift", 0.000005).toDouble()); - ui.persistence->setValue(iniFile.value("persistence", 0.9999).toDouble()); - 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 ( "Rift" ); - iniFile.setValue ( "EnableRoll", ui.chkEnableRoll->isChecked() ); - iniFile.setValue ( "EnablePitch", ui.chkEnablePitch->isChecked() ); - iniFile.setValue ( "EnableYaw", ui.chkEnableYaw->isChecked() ); -#if 0 - iniFile.setValue ( "EnableX", ui.chkEnableX->isChecked() ); - iniFile.setValue ( "EnableY", ui.chkEnableY->isChecked() ); - iniFile.setValue ( "EnableZ", ui.chkEnableZ->isChecked() ); -#endif - iniFile.setValue("yaw-spring", ui.yawSpring->isChecked()); - iniFile.setValue("deadzone", ui.deadzone->value()); - iniFile.setValue("constant-drift", ui.constantDrift->value()); - iniFile.setValue("persistence", ui.persistence->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; -- cgit v1.2.3 From 6adbfba397237340a2db9d1b0b4c7726cc5df94c Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 30 Dec 2013 13:30:12 +0100 Subject: rift: remove captain obvious comments --- ftnoir_tracker_rift/ftnoir_tracker_rift.h | 4 ---- ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp | 13 ------------- ftnoir_tracker_rift/ftnoir_tracker_rift_dll.cpp | 9 --------- 3 files changed, 26 deletions(-) diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift.h b/ftnoir_tracker_rift/ftnoir_tracker_rift.h index eadf5fa5..80bf6ffa 100644 --- a/ftnoir_tracker_rift/ftnoir_tracker_rift.h +++ b/ftnoir_tracker_rift/ftnoir_tracker_rift.h @@ -49,7 +49,6 @@ private: double old_yaw; }; -// Widget that has controls for FTNoIR protocol client-settings. class TrackerControls: public QWidget, public ITrackerDialog { Q_OBJECT @@ -68,9 +67,6 @@ private slots: void doCancel(); }; -//******************************************************************************************************* -// FaceTrackNoIR Tracker DLL. Functions used to get general info on the Tracker -//******************************************************************************************************* class FTNoIR_TrackerDll : public Metadata { public: diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp b/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp index 5d3b30c1..5487da92 100644 --- a/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp +++ b/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp @@ -1,13 +1,6 @@ #include "ftnoir_tracker_rift.h" #include "facetracknoir/global-settings.h" -//******************************************************************************************************* -// FaceTrackNoIR Client Settings-dialog. -//******************************************************************************************************* - -// -// Constructor for server-settings-dialog -// TrackerControls::TrackerControls() : QWidget() { @@ -36,17 +29,11 @@ void TrackerControls::Initialize(QWidget *parent) { show(); } -// -// OK clicked on server-dialog -// void TrackerControls::doOK() { s.b->save(); this->close(); } -// -// Cancel clicked on server-dialog -// void TrackerControls::doCancel() { // // Ask if changed Settings should be saved diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift_dll.cpp b/ftnoir_tracker_rift/ftnoir_tracker_rift_dll.cpp index 3423ba05..2b24411c 100644 --- a/ftnoir_tracker_rift/ftnoir_tracker_rift_dll.cpp +++ b/ftnoir_tracker_rift/ftnoir_tracker_rift_dll.cpp @@ -35,15 +35,6 @@ void FTNoIR_TrackerDll::getIcon(QIcon *icon) *icon = QIcon(":/images/rift_tiny.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; -- cgit v1.2.3 From b7eb4245fe6dc261a926d31331b2af3fec959401 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 30 Dec 2013 15:40:24 +0100 Subject: pt: use new settings framework, cleanup --- FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui | 214 ++++++--------- FTNoIR_Tracker_PT/camera.h | 12 +- FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp | 155 ++++------- FTNoIR_Tracker_PT/ftnoir_tracker_pt.h | 36 +-- FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.cpp | 318 +++++++++-------------- FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.h | 69 +---- FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.cpp | 156 ----------- FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.h | 137 +++++----- 8 files changed, 338 insertions(+), 759 deletions(-) delete mode 100644 FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.cpp diff --git a/FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui b/FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui index 9ad4f83c..6cd17e8d 100644 --- a/FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui +++ b/FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui @@ -9,7 +9,7 @@ 0 0 - 458 + 459 590 @@ -69,11 +69,39 @@ - + + + + + + Time until automatic reset of tracker's internal state when no valid tracking result is found + + + 9999 + + + + + + + ms + + + + + + + + + + + + + Dynamic Pose Resolution @@ -89,30 +117,6 @@ - - - - - - Time the tracker thread sleeps after each processed frame - - - - - - 9999 - - - - - - - ms - - - - - @@ -123,12 +127,15 @@ - - + + - + - Time until automatic reset of tracker's internal state when no valid tracking result is found + Time the tracker thread sleeps after each processed frame + + + 9999 @@ -136,7 +143,7 @@ - + ms @@ -144,43 +151,7 @@ - - - - Whether to update the content of the VideoWidget - - - Show VideoWidget - - - - - - - Qt::Horizontal - - - - 30 - 20 - - - - - - - - Qt::Horizontal - - - - 30 - 20 - - - - - + false @@ -635,40 +606,7 @@ - - - - - false - - - - 130 - 0 - - - - - - - VideoWidget - - - - - - - Qt::Horizontal - - - - 0 - 20 - - - - - + @@ -848,38 +786,36 @@ - - - - - - - Hysteresis - - - threshold_secondary_slider - - - - - - - Per pixel hysteresis width (leave left if there is little difference between dot and non-dot, move right for increased stability against pixel noise) - - - 255 - - - 100 - - - Qt::Horizontal - - - - - - + + + + + + Hysteresis + + + threshold_secondary_slider + + + + + + + Per pixel hysteresis width (leave left if there is little difference between dot and non-dot, move right for increased stability against pixel noise) + + + 255 + + + 100 + + + Qt::Horizontal + + + + + @@ -1777,6 +1713,13 @@ + + + + Apply + + + @@ -1816,11 +1759,8 @@ tabWidget - videowidget_check sleep_spin - dynpose_check reset_spin - reset_button chkEnableRoll chkEnablePitch chkEnableYaw diff --git a/FTNoIR_Tracker_PT/camera.h b/FTNoIR_Tracker_PT/camera.h index 78fe8dfb..ea68c387 100644 --- a/FTNoIR_Tracker_PT/camera.h +++ b/FTNoIR_Tracker_PT/camera.h @@ -69,13 +69,13 @@ protected: virtual void _set_fps() = 0; virtual void _set_res() = 0; - bool active; + float dt_valid; + float dt_mean; int desired_index; int active_index; + bool active; CamInfo cam_info; CamInfo cam_desired; - float dt_valid; - float dt_mean; }; @@ -128,9 +128,9 @@ protected: enum RotationType { - CLOCKWISE = -1, - ZERO = 0, - COUNTER_CLOCKWISE = 1 + CLOCKWISE = 0, + ZERO = 1, + COUNTER_CLOCKWISE = 2 }; // ---------------------------------------------------------------------------- diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp index e3af446f..25a19ee7 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp @@ -23,8 +23,7 @@ const float deg2rad = 1.0/rad2deg; //----------------------------------------------------------------------------- Tracker::Tracker() - : frame_count(0), - commands(0), + : commands(0), video_widget(NULL), video_frame(NULL), tracking_valid(false) @@ -38,9 +37,10 @@ Tracker::~Tracker() // terminate tracker thread set_command(ABORT); wait(); - // destroy video widget - show_video_widget = false; - update_show_video_widget(); + s.video_widget = false; + delete video_widget; + video_widget = NULL; + if (video_frame->layout()) delete video_frame->layout(); } void Tracker::set_command(Command command) @@ -86,10 +86,7 @@ void Tracker::run() frame = frame_rotation.rotate_frame(frame); 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.clone()); -#endif } #ifdef PT_PERF_LOG log_stream<<"dt: "<(settings.cam_roll); - point_extractor.threshold_val = settings.threshold; - point_extractor.threshold_secondary_val = settings.threshold_secondary; - 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; - sleep_time = settings.sleep_time; - point_tracker.dt_reset = settings.reset_time / 1000.0; - show_video_widget = settings.video_widget; - update_show_video_widget(); - bEnableRoll = settings.bEnableRoll; - bEnablePitch = settings.bEnablePitch; - bEnableYaw = settings.bEnableYaw; - bEnableX = settings.bEnableX; - bEnableY = settings.bEnableY; - bEnableZ = settings.bEnableZ; - - t_MH = settings.t_MH; - R_GC = Matx33f( cos(deg2rad*settings.cam_yaw), 0, sin(deg2rad*settings.cam_yaw), + camera.set_device_index(s.cam_index); + camera.set_res(s.cam_res_x, s.cam_res_y); + camera.set_fps(s.cam_fps); + camera.set_f(s.cam_f); + frame_rotation.rotation = static_cast(static_cast(s.cam_roll)); + point_extractor.threshold_val = s.threshold; + point_extractor.threshold_secondary_val = s.threshold_secondary; + point_extractor.min_size = s.min_point_size; + point_extractor.max_size = s.max_point_size; + { + cv::Vec3f M01(s.m01_x, s.m01_y, s.m01_z); + cv::Vec3f M02(s.m02_x, s.m02_y, s.m02_z); + point_tracker.point_model = boost::shared_ptr(new PointModel(M01, M02)); + } + point_tracker.dynamic_pose_resolution = s.dyn_pose_res; + point_tracker.dt_reset = s.reset_time / 1000.0; + t_MH = cv::Vec3f(s.t_MH_x, s.t_MH_y, s.t_MH_z); + R_GC = Matx33f( cos(deg2rad*s.cam_yaw), 0, sin(deg2rad*s.cam_yaw), 0, 1, 0, - -sin(deg2rad*settings.cam_yaw), 0, cos(deg2rad*settings.cam_yaw)); + -sin(deg2rad*s.cam_yaw), 0, cos(deg2rad*s.cam_yaw)); R_GC = R_GC * Matx33f( 1, 0, 0, - 0, cos(deg2rad*settings.cam_pitch), sin(deg2rad*settings.cam_pitch), - 0, -sin(deg2rad*settings.cam_pitch), cos(deg2rad*settings.cam_pitch)); + 0, cos(deg2rad*s.cam_pitch), sin(deg2rad*s.cam_pitch), + 0, -sin(deg2rad*s.cam_pitch), cos(deg2rad*s.cam_pitch)); FrameTrafo X_MH(Matx33f::eye(), t_MH); X_GH_0 = R_GC * X_MH; @@ -169,58 +160,27 @@ bool Tracker::get_frame_and_points(cv::Mat& frame_copy, boost::shared_ptr< std:: return true; } -void Tracker::update_show_video_widget() -{ - if (!show_video_widget && video_widget) { - delete video_widget; - video_widget = NULL; - if (video_frame->layout()) delete video_frame->layout(); - } - else if (video_frame && show_video_widget && !video_widget) - { - const int VIDEO_FRAME_WIDTH = 320; - const int VIDEO_FRAME_HEIGHT = 240; - video_widget = new PTVideoWidget(video_frame, this); - QHBoxLayout* video_layout = new QHBoxLayout(); - video_layout->setContentsMargins(0, 0, 0, 0); - video_layout->addWidget(video_widget); - video_frame->setLayout(video_layout); - video_widget->resize(VIDEO_FRAME_WIDTH, VIDEO_FRAME_HEIGHT); - } -} - -//----------------------------------------------------------------------------- -// ITracker interface -void Tracker::Initialize(QFrame *video_frame) -{ - qDebug("Tracker::Initialize"); - // setup video frame - this->video_frame = video_frame; - video_frame->setAttribute(Qt::WA_NativeWindow); - video_frame->show(); - update_show_video_widget(); - TrackerSettings settings; - settings.load_ini(); - camera.start(); - apply(settings); - start(); -} - 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); + this->video_frame = parent_window; + video_frame->setAttribute(Qt::WA_NativeWindow); + video_frame->show(); + apply(s); + video_widget = new PTVideoWidget(video_frame, this); + QHBoxLayout* video_layout = new QHBoxLayout(parent_window); + video_layout->setContentsMargins(0, 0, 0, 0); + video_layout->addWidget(video_widget); + video_frame->setLayout(video_layout); + video_widget->resize(video_frame->width(), video_frame->height()); + start(); + camera.start(); + start(); + reset_command(PAUSE); } #ifndef OPENTRACK_API @@ -247,18 +207,12 @@ void Tracker::GetHeadPoseData(THeadPoseData *data) 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 + if (s.bEnableX) data[TX] = t[0] / 10.0; // convert to cm + if (s.bEnableY) data[TY] = t[1] / 10.0; + if (s.bEnableZ) data[TZ] = t[2] / 10.0; + + // translate rotation matrix from opengl (G) to roll-pitch-yaw (E) frame // -z -> x, y -> z, x -> -y Matx33f R_EG( 0, 0,-1, -1, 0, 0, @@ -271,19 +225,10 @@ void Tracker::GetHeadPoseData(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 + if (s.bEnableYaw) data[Yaw] = rad2deg * alpha; + if (s.bEnablePitch) data[Pitch] = - rad2deg * beta; // FTNoIR expects a minus here + if (s.bEnableRoll) data[Roll] = rad2deg * gamma; } -#ifndef OPENTRACK_API - return true; -#endif } //----------------------------------------------------------------------------- diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h index 54edafb2..c7f1dc02 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h @@ -39,20 +39,11 @@ class Tracker : public ITracker, QThread, public FrameProvider public: Tracker(); virtual ~Tracker(); - - // --- ITracker interface --- - virtual void Initialize(QFrame *videoframe); -#ifdef OPENTRACK_API virtual void StartTracker(QFrame* parent_window); virtual void GetHeadPoseData(double* data); -#else - virtual void StartTracker(HWND parent_window); - virtual void StopTracker(bool exit); - virtual bool GetHeadPoseData(THeadPoseData *data); -#endif virtual void refreshVideo(); - void apply(const TrackerSettings& settings); + void apply(settings& s); void center(); void reset(); // reset the trackers internal state variables void run(); @@ -74,20 +65,12 @@ protected: }; void set_command(Command command); void reset_command(Command command); - int commands; - - int sleep_time; + int commands; - // --- tracking chain --- -#ifdef OPENTRACK_API CVCamera camera; -#else - VICamera camera; -#endif FrameRotation frame_rotation; PointExtractor point_extractor; PointTracker point_tracker; - bool tracking_valid; FrameTrafo X_GH_0; // for centering cv::Vec3f t_MH; // translation from model frame to head frame @@ -96,22 +79,11 @@ protected: // --- ui --- cv::Mat frame; // the output frame for display - void update_show_video_widget(); - bool show_video_widget; -#ifdef OPENTRACK_API PTVideoWidget* video_widget; -#endif QFrame* video_frame; + bool tracking_valid; - // --- misc --- - bool bEnableRoll; - bool bEnablePitch; - bool bEnableYaw; - bool bEnableX; - bool bEnableY; - bool bEnableZ; - - long frame_count; + settings s; Timer time; }; diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.cpp b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.cpp index f8afa790..a88e3a07 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.cpp +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.cpp @@ -21,8 +21,7 @@ using namespace std; //----------------------------------------------------------------------------- TrackerDialog::TrackerDialog() - : settings_dirty(false), - tracker(NULL), + : tracker(NULL), video_widget_dialog(NULL), timer(this), trans_calib_running(false) @@ -32,191 +31,112 @@ TrackerDialog::TrackerDialog() 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); - - vector device_names; + vector device_names; get_camera_device_names(device_names); for (vector::iterator iter = device_names.begin(); iter != device_names.end(); ++iter) { ui.camdevice_combo->addItem(iter->c_str()); } - ui.camdevice_combo->setCurrentIndex(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.camroll_combo->addItem("-90", -1); - ui.camroll_combo->addItem("0" , 0); - ui.camroll_combo->addItem("90" , 1); - int i = ui.camroll_combo->findData(settings.cam_roll); - ui.camroll_combo->setCurrentIndex(i>=0 ? i : 0); - - ui.campitch_spin->setValue(settings.cam_pitch); - ui.camyaw_spin->setValue(settings.cam_yaw); - ui.threshold_slider->setValue(settings.threshold); - ui.threshold_secondary_slider->setValue(settings.threshold_secondary); - - 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.camdevice_combo,SIGNAL(currentIndexChanged(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.camroll_combo,SIGNAL(currentIndexChanged(int)), this,SLOT(set_cam_roll(int)) ); - connect( ui.campitch_spin,SIGNAL(valueChanged(int)), this,SLOT(set_cam_pitch(int)) ); - connect( ui.camyaw_spin,SIGNAL(valueChanged(int)), this,SLOT(set_cam_yaw(int)) ); - connect( ui.threshold_slider,SIGNAL(sliderMoved(int)), this,SLOT(set_threshold(int)) ); - connect( ui.threshold_secondary_slider,SIGNAL(sliderMoved(int)), this,SLOT(set_threshold_secondary(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.videowidget_button,SIGNAL(clicked()), this,SLOT(create_video_widget()) ); - - 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"; -} + ui.camroll_combo->addItem("-90"); + ui.camroll_combo->addItem("0"); + ui.camroll_combo->addItem("90"); -void TrackerDialog::set_cam_roll(int idx) -{ - settings.cam_roll = ui.camroll_combo->itemData(idx).toInt(); - settings_changed(); + tie_setting(s.dyn_pose_res, ui.dynpose_check); + tie_setting(s.sleep_time, ui.sleep_spin); + tie_setting(s.reset_time, ui.reset_spin); + + tie_setting(s.cam_index, ui.camdevice_combo); + tie_setting(s.cam_f, ui.f_dspin); + tie_setting(s.cam_res_x, ui.res_x_spin); + tie_setting(s.cam_res_y, ui.res_y_spin); + tie_setting(s.cam_fps, ui.fps_spin); + tie_setting(s.cam_roll, ui.camroll_combo); + tie_setting(s.cam_pitch, ui.campitch_spin); + tie_setting(s.cam_yaw, ui.camyaw_spin); + + tie_setting(s.threshold_secondary, ui.threshold_secondary_slider); + tie_setting(s.threshold, ui.threshold_slider); + + tie_setting(s.bEnableYaw, ui.chkEnableYaw); + tie_setting(s.bEnablePitch, ui.chkEnablePitch); + tie_setting(s.bEnableRoll, ui.chkEnableRoll); + tie_setting(s.bEnableX, ui.chkEnableX); + tie_setting(s.bEnableY, ui.chkEnableY); + tie_setting(s.bEnableZ, ui.chkEnableZ); + + tie_setting(s.min_point_size, ui.mindiam_spin); + tie_setting(s.max_point_size, ui.maxdiam_spin); + + tie_setting(s.clip_by, ui.clip_bheight_spin); + tie_setting(s.clip_bz, ui.clip_blength_spin); + tie_setting(s.clip_ty, ui.clip_theight_spin); + tie_setting(s.clip_tz, ui.clip_tlength_spin); + + tie_setting(s.cap_x, ui.cap_width_spin); + tie_setting(s.cap_y, ui.cap_height_spin); + tie_setting(s.cap_z, ui.cap_length_spin); + + tie_setting(s.m01_x, ui.m1x_spin); + tie_setting(s.m01_y, ui.m1y_spin); + tie_setting(s.m01_z, ui.m1z_spin); + + tie_setting(s.m02_x, ui.m2x_spin); + tie_setting(s.m02_y, ui.m2y_spin); + tie_setting(s.m02_z, ui.m2z_spin); + + tie_setting(s.t_MH_x, ui.tx_spin); + tie_setting(s.t_MH_y, ui.ty_spin); + tie_setting(s.t_MH_z, ui.tz_spin); + + connect( ui.tcalib_button,SIGNAL(toggled(bool)), this,SLOT(startstop_trans_calib(bool)) ); + connect(ui.reset_button, SIGNAL(clicked()), this, SLOT(doReset())); + + connect(ui.ok_button, SIGNAL(clicked()), this, SLOT(doOK())); + connect(ui.cancel_button, SIGNAL(clicked()), this, SLOT(doCancel())); + connect(ui.btnApply, SIGNAL(clicked()), this, SLOT(doApply())); + + ui.model_tabs->setCurrentIndex(s.active_model_panel); + + connect(ui.model_tabs, SIGNAL(currentChanged(int)), this, SLOT(set_model(int))); + connect(&timer,SIGNAL(timeout()), this,SLOT(poll_tracker_info())); + timer.start(100); + + connect(s.b.get(), SIGNAL(bundleChanged()), this, SLOT(do_apply_without_saving())); } void TrackerDialog::set_model_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; + s.m01_x = 0; + s.m01_y = static_cast(s.clip_ty); + s.m01_z = -static_cast(s.clip_tz); + s.m02_x = 0; + s.m02_y = -static_cast(s.clip_by); + s.m02_z = -static_cast(s.clip_bz); settings_changed(); } void TrackerDialog::set_model_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; + s.m01_x = -static_cast(s.cap_x); + s.m01_y = -static_cast(s.cap_y); + s.m01_z = -static_cast(s.cap_z); + s.m02_x = static_cast(s.cap_x); + s.m02_y = -static_cast(s.cap_y); + s.m02_z = -static_cast(s.cap_z); settings_changed(); } void TrackerDialog::set_model_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_model_clip(); - break; - - case TrackerDialogSettings::MODEL_CAP: - set_model_cap(); - break; - - case TrackerDialogSettings::MODEL_CUSTOM: - set_model_custom(); - break; - - default: - break; - } + s.active_model_panel = val; } void TrackerDialog::startstop_trans_calib(bool start) @@ -231,7 +151,12 @@ void TrackerDialog::startstop_trans_calib(bool start) { qDebug()<<"TrackerDialog:: Stoppping translation calibration"; trans_calib_running = false; - settings.t_MH = trans_calib.get_estimate(); + { + auto tmp = trans_calib.get_estimate(); + s.t_MH_x = tmp[0]; + s.t_MH_y = tmp[1]; + s.t_MH_z = tmp[2]; + } settings_changed(); } } @@ -244,17 +169,15 @@ void TrackerDialog::trans_calib_step() 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]); + s.t_MH_x = t_MH[0]; + s.t_MH_y = t_MH[1]; + s.t_MH_z = t_MH[2]; } } void TrackerDialog::settings_changed() { - settings_dirty = true; - if (tracker) tracker->apply(settings); + if (tracker) tracker->apply(s); } void TrackerDialog::doCenter() @@ -267,25 +190,52 @@ void TrackerDialog::doReset() if (tracker) tracker->reset(); } +void TrackerDialog::save() +{ + do_apply_without_saving(); + s.b->save(); +} + void TrackerDialog::doOK() { - settings.save_ini(); - dialog_settings.save_ini(); + save(); close(); } +void TrackerDialog::do_apply_without_saving() +{ + switch (s.active_model_panel) { + default: + case 0: + set_model_clip(); + break; + case 1: + set_model_cap(); + break; + case 2: + set_model_custom(); + break; + } + if (tracker) tracker->apply(s); +} + +void TrackerDialog::doApply() +{ + save(); +} + void TrackerDialog::doCancel() { - if (settings_dirty) { + 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: - settings.save_ini(); - dialog_settings.save_ini(); + save(); close(); break; case QMessageBox::Discard: + s.b->revert(); close(); break; case QMessageBox::Cancel: @@ -319,8 +269,6 @@ void TrackerDialog::create_video_widget() video_widget_dialog->setAttribute( Qt::WA_DeleteOnClose ); connect( video_widget_dialog, SIGNAL(destroyed(QObject*)), this, SLOT(widget_destroyed(QObject*)) ); video_widget_dialog->show(); - - ui.videowidget_button->setEnabled(false); } void TrackerDialog::destroy_video_widget(bool do_delete /*= true*/) @@ -329,7 +277,6 @@ void TrackerDialog::destroy_video_widget(bool do_delete /*= true*/) if (do_delete) delete video_widget_dialog; video_widget_dialog = NULL; } - if (tracker) ui.videowidget_button->setEnabled(true); } void TrackerDialog::poll_tracker_info() @@ -369,24 +316,12 @@ void TrackerDialog::poll_tracker_info() } } - -//----------------------------------------------------------------------------- -// 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.videowidget_button->setEnabled(true); + if (isVisible() & s.b->modifiedp()) + tracker->apply(s); ui.tcalib_button->setEnabled(true); //ui.center_button->setEnabled(true); ui.reset_button->setEnabled(true); @@ -397,19 +332,12 @@ void TrackerDialog::unRegisterTracker() qDebug()<<"TrackerDialog:: Tracker un-registered"; tracker = NULL; destroy_video_widget(); - ui.videowidget_button->setEnabled(false); ui.tcalib_button->setEnabled(false); //ui.center_button->setEnabled(false); ui.reset_button->setEnabled(false); } -//----------------------------------------------------------------------------- -#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; } diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.h b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.h index de743ad8..0325160d 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.h +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.h @@ -28,71 +28,24 @@ class TrackerDialog : public QWidget, Ui::UICPTClientControls, public ITrackerDi Q_OBJECT public: TrackerDialog(); - ~TrackerDialog(); - - // ITrackerDialog interface - void Initialize(QWidget *parent); void registerTracker(ITracker *tracker); void unRegisterTracker(); - + void save(); 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 idx) { settings.cam_index = idx; 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_roll(int idx); - void set_cam_pitch(int val) { settings.cam_pitch = val; settings_changed(); } - void set_cam_yaw(int val) { settings.cam_yaw = 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_threshold_secondary(int val) { settings.threshold_secondary = 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_model_clip(); } - void set_clip_t_length(int val) { dialog_settings.clip_tz = val; set_model_clip(); } - void set_clip_b_height(int val) { dialog_settings.clip_by = val; set_model_clip(); } - void set_clip_b_length(int val) { dialog_settings.clip_bz = val; set_model_clip(); } - void set_cap_width(int val) { dialog_settings.cap_x = val; set_model_cap(); } - void set_cap_height(int val) { dialog_settings.cap_y = val; set_model_cap(); } - void set_cap_length(int val) { dialog_settings.cap_z = val; set_model_cap(); } - void set_m1x(int val) { dialog_settings.M01x = val; set_model_custom(); } - void set_m1y(int val) { dialog_settings.M01y = val; set_model_custom(); } - void set_m1z(int val) { dialog_settings.M01z = val; set_model_custom(); } - void set_m2x(int val) { dialog_settings.M02x = val; set_model_custom(); } - void set_m2y(int val) { dialog_settings.M02y = val; set_model_custom(); } - void set_m2z(int val) { dialog_settings.M02z = val; set_model_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(); - +public slots: + void doCenter(); + void doReset(); void doOK(); + void doApply(); void doCancel(); + void do_apply_without_saving(); void startstop_trans_calib(bool start); - void widget_destroyed(QObject* obj); - void create_video_widget(); - void poll_tracker_info(); + void set_model(int idx); protected: void destroy_video_widget(bool do_delete = true); @@ -103,15 +56,11 @@ protected: void settings_changed(); - TrackerSettings settings; - TrackerDialogSettings dialog_settings; - bool settings_dirty; - + settings s; Tracker* tracker; + VideoWidgetDialog* video_widget_dialog; QTimer timer; - VideoWidgetDialog* video_widget_dialog; - TranslationCalibrator trans_calib; bool trans_calib_running; diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.cpp b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.cpp deleted file mode 100644 index 50835cb8..00000000 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.cpp +++ /dev/null @@ -1,156 +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 "ftnoir_tracker_pt.h" -#include -#include - -//----------------------------------------------------------------------------- -void TrackerSettings::load_ini() -{ - qDebug("TrackerSettings::load_ini()"); - - QSettings settings("opentrack"); - 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_roll = iniFile.value("CameraRoll", 0).toInt(); - cam_pitch = iniFile.value("CameraPitch", 0).toInt(); - cam_yaw = iniFile.value("CameraYaw", 0).toInt(); - threshold = iniFile.value("PointExtractThreshold", 128).toInt(); - threshold_secondary = iniFile.value("PointExtractThresholdSecondary", 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"); - 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("CameraRoll", cam_roll); - iniFile.setValue("CameraPitch", cam_pitch); - iniFile.setValue("CameraYaw", cam_yaw); - iniFile.setValue("PointExtractThreshold", threshold); - iniFile.setValue("PointExtractThresholdSecondary", threshold_secondary); - 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"); - 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"); - 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); -} diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.h b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.h index 91a7a8d5..8c590db2 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.h +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.h @@ -11,80 +11,81 @@ #include #include "point_tracker.h" +#include "facetracknoir/options.hpp" +using namespace options; -//----------------------------------------------------------------------------- -// Tracker settings and their ini-IO -struct TrackerSettings -{ - // camera - int cam_index; - float cam_f; - int cam_res_x; - int cam_res_y; - int cam_fps; - int cam_roll; - int cam_pitch; - int cam_yaw; - - // point extraction - int threshold; - int threshold_secondary; - - 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; +struct settings +{ + pbundle b; + value cam_index, + cam_res_x, + cam_res_y, + cam_fps, + cam_roll, + cam_pitch, + cam_yaw, + threshold, + threshold_secondary, + min_point_size, + max_point_size; + value cam_f; - bool bEnableRoll; - bool bEnablePitch; - bool bEnableYaw; - bool bEnableX; - bool bEnableY; - bool bEnableZ; + value m01_x, m01_y, m01_z; + value m02_x, m02_y, m02_z; + value dyn_pose_res, video_widget; - void load_ini(); - void save_ini() const; -}; + value t_MH_x, t_MH_y, t_MH_z; + value sleep_time, reset_time; -//----------------------------------------------------------------------------- -// Settings specific to the tracker dialog and their ini-IO -struct TrackerDialogSettings -{ - enum - { - MODEL_CLIP, - MODEL_CAP, - MODEL_CUSTOM - }; - int active_model_panel; + value bEnableYaw, bEnablePitch, bEnableRoll; + value bEnableX, bEnableY, bEnableZ; - 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; + value clip_ty, clip_tz, clip_by, clip_bz; + value active_model_panel, cap_x, cap_y, cap_z; - void load_ini(); - void save_ini() const; + settings() : + b(bundle("tracker-pt")), + cam_index(b, "camera-index", 0), + cam_res_x(b, "camera-res-width", 640), + cam_res_y(b, "camera-res-height", 480), + cam_fps(b, "camera-fps", 30), + cam_roll(b, "camera-roll", 1), + cam_pitch(b, "camera-pitch", 0), + cam_yaw(b, "camera-yaw", 0), + threshold(b, "threshold-primary", 128), + threshold_secondary(b, "threshold-secondary", 128), + min_point_size(b, "min-point-size", 10), + max_point_size(b, "max-point-size", 50), + cam_f(b, "camera-focal-length", 1), + m01_x(b, "m_01-x", 0), + m01_y(b, "m_01-y", 0), + m01_z(b, "m_01-z", 0), + m02_x(b, "m_02-x", 0), + m02_y(b, "m_02-y", 0), + m02_z(b, "m_02-z", 0), + dyn_pose_res(b, "dynamic-pose-resolution", false), + video_widget(b, "video-widget", true), + t_MH_x(b, "model-centroid-x", 0), + t_MH_y(b, "model-centroid-y", 0), + t_MH_z(b, "model-centroid-z", 0), + sleep_time(b, "sleep-time", 0), + reset_time(b, "reset-time", 0), + bEnableYaw(b, "enable-yaw", true), + bEnablePitch(b, "enable-pitch", true), + bEnableRoll(b, "enable-roll", true), + bEnableX(b, "enable-x", true), + bEnableY(b, "enable-y", true), + bEnableZ(b, "enable-z", true), + clip_ty(b, "clip-ty", 0), + clip_tz(b, "clip-tz", 0), + clip_by(b, "clip-by", 0), + clip_bz(b, "clip-bz", 0), + active_model_panel(b, "active-model-panel", 0), + cap_x(b, "cap-x", 0), + cap_y(b, "cap-y", 0), + cap_z(b, "cap-z", 0) + {} }; -#endif //FTNOIR_TRACKER_PT_SETTINGS_H \ No newline at end of file +#endif //FTNOIR_TRACKER_PT_SETTINGS_H -- 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(-) 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(-) 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 d1e0537f704ea67483ccbdf7461e636490aba0cf Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 31 Dec 2013 08:41:16 +0100 Subject: meta: get rid of Initialize(), now RAII --- FTNoIR_Tracker_PT/ftnoir_tracker_pt_dll.h | 4 - ftnoir_filter_accela/ftnoir_filter_accela.h | 4 +- .../ftnoir_filter_accela_dialog.cpp | 4 - ftnoir_filter_base/ftnoir_filter_base.h | 3 +- ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp | 4 - ftnoir_filter_ewma2/ftnoir_filter_ewma2.h | 5 +- ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp | 21 -- ftnoir_filter_kalman/ftnoir_filter_kalman.h | 9 +- ftnoir_filter_kalman/kalman.cpp | 4 +- ftnoir_protocol_base/ftnoir_protocol_base.h | 3 - ftnoir_protocol_fg/ftnoir_protocol_fg.h | 7 - ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp | 24 -- ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h | 3 - .../ftnoir_protocol_fsuipc_dialog.cpp | 29 -- ftnoir_protocol_ft/ftnoir_protocol_ft.h | 3 - ftnoir_protocol_ft/ftnoir_protocol_ft_dialog.cpp | 30 -- ftnoir_protocol_ftn/ftnoir_protocol_ftn.h | 3 - ftnoir_protocol_ftn/ftnoir_protocol_ftn_dialog.cpp | 24 -- .../ftnoir_protocol_libevdev.h | 4 - .../ftnoir_protocol_libevdev_dialog.cpp | 15 - ftnoir_protocol_sc/ftnoir_protocol_sc.h | 3 - ftnoir_protocol_sc/ftnoir_protocol_sc_dialog.cpp | 30 -- ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.h | 4 - .../ftnoir_protocol_vjoy_dialog.cpp | 15 - ftnoir_protocol_wine/ftnoir_protocol_wine.h | 3 - ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 309 +++++---------------- ftnoir_tracker_aruco/ftnoir_tracker_aruco.h | 55 ++-- ftnoir_tracker_base/ftnoir_tracker_base.h | 3 +- ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp | 34 --- ftnoir_tracker_hatire/ftnoir_tracker_hat.h | 7 - .../ftnoir_tracker_hat_dialog.cpp | 18 -- ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.h | 4 +- ftnoir_tracker_ht/ftnoir_tracker_ht.cpp | 5 - ftnoir_tracker_ht/ftnoir_tracker_ht.h | 1 - ftnoir_tracker_hydra/ftnoir_tracker_hydra.h | 1 - .../ftnoir_tracker_hydra_dialog.cpp | 9 - ftnoir_tracker_joystick/ftnoir_tracker_joystick.h | 6 +- .../ftnoir_tracker_joystick_dialog.cpp | 18 -- ftnoir_tracker_rift/ftnoir_tracker_rift.cpp | 2 - ftnoir_tracker_rift/ftnoir_tracker_rift.h | 1 - ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp | 9 - ftnoir_tracker_udp/ftnoir_tracker_udp.h | 3 - ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp | 23 -- 43 files changed, 118 insertions(+), 648 deletions(-) diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dll.h b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dll.h index 18283837..1d30e7e5 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dll.h +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dll.h @@ -20,10 +20,6 @@ class TrackerDll : public ITrackerDll #endif { - // ITrackerDll interface -#ifndef OPENTRACK_API - void Initialize() {} -#endif void getFullName(QString *strToBeFilled); void getShortName(QString *strToBeFilled); void getDescription(QString *strToBeFilled); diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.h b/ftnoir_filter_accela/ftnoir_filter_accela.h index 2b93f550..1aaa039f 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.h +++ b/ftnoir_filter_accela/ftnoir_filter_accela.h @@ -37,7 +37,7 @@ class FTNoIR_Filter : public IFilter public: FTNoIR_Filter(); void FilterHeadPoseData(const double* target_camera_position, double *new_camera_position); - void Initialize() { + void reset() { first_run = true; } void receiveSettings() { @@ -64,7 +64,7 @@ class FilterControls: public QWidget, public IFilterDialog Q_OBJECT public: FilterControls(); - void Initialize(QWidget *); + void reset(QWidget *); void registerFilter(IFilter* filter); void unregisterFilter(); private: diff --git a/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp b/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp index cc759bcb..6d1ad384 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp @@ -20,10 +20,6 @@ FilterControls::FilterControls() : tie_setting(s.expt, ui.expt); } -void FilterControls::Initialize(QWidget *) { - show(); -} - void FilterControls::registerFilter(IFilter* filter) { accela_filter = (FTNoIR_Filter*) filter; diff --git a/ftnoir_filter_base/ftnoir_filter_base.h b/ftnoir_filter_base/ftnoir_filter_base.h index 800e5deb..fbb0441d 100644 --- a/ftnoir_filter_base/ftnoir_filter_base.h +++ b/ftnoir_filter_base/ftnoir_filter_base.h @@ -14,7 +14,7 @@ struct IFilter { virtual ~IFilter() = 0; virtual void FilterHeadPoseData(const double *target_camera_position, double *new_camera_position) = 0; - virtual void Initialize() = 0; + virtual void reset() = 0; }; inline IFilter::~IFilter() { } @@ -22,7 +22,6 @@ inline IFilter::~IFilter() { } struct IFilterDialog { virtual ~IFilterDialog() {} - virtual void Initialize(QWidget *parent) = 0; virtual void registerFilter(IFilter* tracker) = 0; virtual void unregisterFilter() = 0; }; diff --git a/ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp b/ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp index 5f66be96..77596b71 100644 --- a/ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp +++ b/ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp @@ -44,10 +44,6 @@ FTNoIR_Filter::FTNoIR_Filter() loadSettings(); // Load the Settings } -FTNoIR_Filter::~FTNoIR_Filter() -{ -} - void FTNoIR_Filter::receiveSettings(double smin, double smax, double sexpt) { QMutexLocker foo(&mutex); diff --git a/ftnoir_filter_ewma2/ftnoir_filter_ewma2.h b/ftnoir_filter_ewma2/ftnoir_filter_ewma2.h index 86e4b65c..7c98b2cb 100644 --- a/ftnoir_filter_ewma2/ftnoir_filter_ewma2.h +++ b/ftnoir_filter_ewma2/ftnoir_filter_ewma2.h @@ -41,8 +41,7 @@ class FTNoIR_Filter : public IFilter { public: FTNoIR_Filter(); - virtual ~FTNoIR_Filter(); - void Initialize() {} + void reset() {} void FilterHeadPoseData(const double *target_camera_position, double *new_camera_position); @@ -73,9 +72,7 @@ class FilterControls: public QWidget, public IFilterDialog Q_OBJECT public: explicit FilterControls(); - virtual ~FilterControls(); void showEvent (QShowEvent *); - void Initialize(QWidget *parent); void registerFilter(IFilter* flt); void unregisterFilter(); diff --git a/ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp b/ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp index c304eb0a..eb414340 100644 --- a/ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp +++ b/ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp @@ -59,27 +59,6 @@ FilterControls::FilterControls() : 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; diff --git a/ftnoir_filter_kalman/ftnoir_filter_kalman.h b/ftnoir_filter_kalman/ftnoir_filter_kalman.h index da6df2b1..9e0d817d 100644 --- a/ftnoir_filter_kalman/ftnoir_filter_kalman.h +++ b/ftnoir_filter_kalman/ftnoir_filter_kalman.h @@ -28,7 +28,7 @@ public: FTNoIR_Filter(); ~FTNoIR_Filter() virt_override { } - void Initialize() virt_override; + void reset() virt_override; void FilterHeadPoseData(const double *target_camera_position, double *new_camera_position) virt_override; cv::KalmanFilter kalman; @@ -68,16 +68,9 @@ public: connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); show(); } - ~FilterControls() {} void showEvent ( QShowEvent * ) virt_override { show(); } - - void Initialize(QWidget *) virt_override { - show(); - raise(); - } - bool settingsDirty; Ui::KalmanUICFilterControls ui; virtual void registerFilter(IFilter*) virt_override {} diff --git a/ftnoir_filter_kalman/kalman.cpp b/ftnoir_filter_kalman/kalman.cpp index 629cfcc8..743eb3d4 100644 --- a/ftnoir_filter_kalman/kalman.cpp +++ b/ftnoir_filter_kalman/kalman.cpp @@ -31,12 +31,12 @@ void kalman_save_settings(FilterControls&) { FTNoIR_Filter::FTNoIR_Filter() { kalman_load_settings(*this); - Initialize(); + reset(); } // the following was written by Donovan Baarda // https://sourceforge.net/p/facetracknoir/discussion/1150909/thread/418615e1/?limit=25#af75/084b -void FTNoIR_Filter::Initialize() { +void FTNoIR_Filter::reset() { const double accel_variance = 1e-3; const double noise_variance = 5e2; kalman.init(12, 6, 0, CV_64F); diff --git a/ftnoir_protocol_base/ftnoir_protocol_base.h b/ftnoir_protocol_base/ftnoir_protocol_base.h index e4ca1977..d2f85ec0 100644 --- a/ftnoir_protocol_base/ftnoir_protocol_base.h +++ b/ftnoir_protocol_base/ftnoir_protocol_base.h @@ -50,9 +50,6 @@ inline IProtocol::~IProtocol() { } 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; }; diff --git a/ftnoir_protocol_fg/ftnoir_protocol_fg.h b/ftnoir_protocol_fg/ftnoir_protocol_fg.h index 9a4f304c..0a255d84 100644 --- a/ftnoir_protocol_fg/ftnoir_protocol_fg.h +++ b/ftnoir_protocol_fg/ftnoir_protocol_fg.h @@ -35,11 +35,8 @@ #include #include #include -#include #include "facetracknoir/global-settings.h" -#define FT_PROGRAMID "FT_ProgramID" - class FTNoIR_Protocol : public IProtocol { public: @@ -65,10 +62,6 @@ class FGControls: public QWidget, public IProtocolDialog 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 } diff --git a/ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp b/ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp index 45123540..cb11ace6 100644 --- a/ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp +++ b/ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp @@ -63,25 +63,6 @@ QWidget() 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 // @@ -90,11 +71,6 @@ void FGControls::doOK() { this->close(); } -// override show event -void FGControls::showEvent ( QShowEvent * ) { - loadSettings(); -} - // // Cancel clicked on server-dialog // diff --git a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h index 87c6a3a4..9f5e3b6f 100644 --- a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h +++ b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h @@ -83,9 +83,6 @@ class FSUIPCControls: public QWidget, public IProtocolDialog 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 } diff --git a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dialog.cpp b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dialog.cpp index 985915b4..b2f28ba1 100644 --- a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dialog.cpp +++ b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dialog.cpp @@ -48,41 +48,12 @@ QWidget() 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 diff --git a/ftnoir_protocol_ft/ftnoir_protocol_ft.h b/ftnoir_protocol_ft/ftnoir_protocol_ft.h index e13d260f..56316ec4 100644 --- a/ftnoir_protocol_ft/ftnoir_protocol_ft.h +++ b/ftnoir_protocol_ft/ftnoir_protocol_ft.h @@ -93,9 +93,6 @@ class FTControls: public QWidget, public IProtocolDialog 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 } diff --git a/ftnoir_protocol_ft/ftnoir_protocol_ft_dialog.cpp b/ftnoir_protocol_ft/ftnoir_protocol_ft_dialog.cpp index df13a6dc..0b29db6e 100644 --- a/ftnoir_protocol_ft/ftnoir_protocol_ft_dialog.cpp +++ b/ftnoir_protocol_ft/ftnoir_protocol_ft_dialog.cpp @@ -75,41 +75,11 @@ QWidget() } -// -// 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 diff --git a/ftnoir_protocol_ftn/ftnoir_protocol_ftn.h b/ftnoir_protocol_ftn/ftnoir_protocol_ftn.h index 9aee73ac..acccc9e7 100644 --- a/ftnoir_protocol_ftn/ftnoir_protocol_ftn.h +++ b/ftnoir_protocol_ftn/ftnoir_protocol_ftn.h @@ -64,9 +64,6 @@ class FTNControls: public QWidget, public IProtocolDialog public: explicit FTNControls(); - virtual ~FTNControls(); - void showEvent (QShowEvent *); - void Initialize(QWidget *parent); void registerProtocol(IProtocol *) {} void unRegisterProtocol() {} diff --git a/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dialog.cpp b/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dialog.cpp index 3b4e851c..72c30051 100644 --- a/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dialog.cpp +++ b/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dialog.cpp @@ -56,25 +56,6 @@ QWidget() 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 // @@ -83,11 +64,6 @@ void FTNControls::doOK() { this->close(); } -// override show event -void FTNControls::showEvent ( QShowEvent * ) { - loadSettings(); -} - // // Cancel clicked on server-dialog // diff --git a/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.h b/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.h index aabd3e51..5df59919 100644 --- a/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.h +++ b/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.h @@ -41,10 +41,6 @@ class LibevdevControls: public QWidget, public IProtocolDialog public: explicit LibevdevControls(); - virtual ~LibevdevControls(); - void showEvent ( QShowEvent *) {} - - void Initialize(QWidget *); void registerProtocol(IProtocol *) {} void unRegisterProtocol() {} diff --git a/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev_dialog.cpp b/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev_dialog.cpp index 6665a3d2..bb54c354 100644 --- a/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev_dialog.cpp +++ b/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev_dialog.cpp @@ -8,21 +8,6 @@ LibevdevControls::LibevdevControls() : QWidget() connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); } -LibevdevControls::~LibevdevControls() { -} - -// -// Initialize tracker-client-dialog -// -void LibevdevControls::Initialize(QWidget *parent) { - - QPoint offsetpos(100, 100); - if (parent) { - this->move(parent->pos() + offsetpos); - } - show(); -} - void LibevdevControls::doOK() { save(); this->close(); diff --git a/ftnoir_protocol_sc/ftnoir_protocol_sc.h b/ftnoir_protocol_sc/ftnoir_protocol_sc.h index e17cabb5..7917c532 100644 --- a/ftnoir_protocol_sc/ftnoir_protocol_sc.h +++ b/ftnoir_protocol_sc/ftnoir_protocol_sc.h @@ -131,9 +131,6 @@ class SCControls: public QWidget, public IProtocolDialog 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 } diff --git a/ftnoir_protocol_sc/ftnoir_protocol_sc_dialog.cpp b/ftnoir_protocol_sc/ftnoir_protocol_sc_dialog.cpp index fb822145..eb15ca69 100644 --- a/ftnoir_protocol_sc/ftnoir_protocol_sc_dialog.cpp +++ b/ftnoir_protocol_sc/ftnoir_protocol_sc_dialog.cpp @@ -49,41 +49,11 @@ QWidget() 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 diff --git a/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.h b/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.h index c4db29e4..873b4e3c 100644 --- a/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.h +++ b/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.h @@ -60,10 +60,6 @@ class VJoyControls: public QWidget, public IProtocolDialog public: explicit VJoyControls(); - virtual ~VJoyControls(); - void showEvent ( QShowEvent *) {} - - void Initialize(QWidget *); void registerProtocol(IProtocol *l) {} void unRegisterProtocol() {} diff --git a/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy_dialog.cpp b/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy_dialog.cpp index 0009553b..febb7b18 100644 --- a/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy_dialog.cpp +++ b/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy_dialog.cpp @@ -8,21 +8,6 @@ VJoyControls::VJoyControls() : QWidget() connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); } -VJoyControls::~VJoyControls() { -} - -// -// Initialize tracker-client-dialog -// -void VJoyControls::Initialize(QWidget *parent) { - - QPoint offsetpos(100, 100); - if (parent) { - this->move(parent->pos() + offsetpos); - } - show(); -} - void VJoyControls::doOK() { save(); this->close(); diff --git a/ftnoir_protocol_wine/ftnoir_protocol_wine.h b/ftnoir_protocol_wine/ftnoir_protocol_wine.h index d7276b8e..e84dbd69 100644 --- a/ftnoir_protocol_wine/ftnoir_protocol_wine.h +++ b/ftnoir_protocol_wine/ftnoir_protocol_wine.h @@ -70,10 +70,7 @@ class FTControls: public QWidget, public IProtocolDialog { Q_OBJECT public: - FTControls(); - void showEvent ( QShowEvent * ) {show();} - void Initialize(QWidget *) {show();} void registerProtocol(IProtocol *) {} void unRegisterProtocol() {} diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index 9408de02..a0a11ed2 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -99,47 +99,8 @@ static resolution_tuple resolution_choices[] = { { 0, 0 } }; -void Tracker::load_settings() +Tracker::Tracker() : stop(false), layout(nullptr), videoWidget(nullptr) { - QMutexLocker foo(&mtx); - QSettings settings("opentrack"); - QString currentFile = settings.value( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); - QSettings iniFile( currentFile, QSettings::IniFormat ); - - iniFile.beginGroup( "aruco-Tracker" ); - fov = iniFile.value("fov", 56).toFloat(); - force_fps = iniFile.value("fps", 0).toInt(); - camera_index = iniFile.value("camera-index", -1).toInt(); - int res = iniFile.value("resolution", 0).toInt(); - if (res < 0 || res >= (int)(sizeof(resolution_choices) / sizeof(resolution_tuple))) - res = 0; - resolution_tuple r = resolution_choices[res]; - force_width = r.width; - force_height = r.height; - enableRX = iniFile.value("enable-rx", true).toBool(); - enableRY = iniFile.value("enable-ry", true).toBool(); - enableRZ = iniFile.value("enable-rz", true).toBool(); - enableTX = iniFile.value("enable-tx", true).toBool(); - enableTY = iniFile.value("enable-ty", true).toBool(); - enableTZ = iniFile.value("enable-tz", true).toBool(); - - for (int i = 0; i < 3; i++) - { - headpos[i] = iniFile.value(QString("headpos-%1").arg(i), 0).toDouble(); - } - headpitch = iniFile.value("pitch", 0).toDouble(); - red_only = iniFile.value("red-only", true).toBool(); - - iniFile.endGroup(); -} - -Tracker::Tracker() -{ - layout = nullptr; - stop = false; - videoWidget = NULL; - enableRX = enableRY = enableRZ = enableTX = enableTY = enableTZ = true; - load_settings(); } Tracker::~Tracker() @@ -166,7 +127,6 @@ void Tracker::StartTracker(QFrame* videoframe) delete videoframe->layout(); videoframe->setLayout(layout); videoWidget->show(); - load_settings(); start(); for (int i = 0; i < 6; i++) pose[i] = 0; @@ -177,13 +137,35 @@ void Tracker::StartTracker(QFrame* videoframe) void Tracker::run() { - camera = cv::VideoCapture(camera_index); - if (force_width) - camera.set(CV_CAP_PROP_FRAME_WIDTH, force_width); - if (force_height) - camera.set(CV_CAP_PROP_FRAME_HEIGHT, force_height); - if (force_fps) - camera.set(CV_CAP_PROP_FPS, force_fps); + int res = s.resolution; + if (res < 0 || res >= (int)(sizeof(resolution_choices) / sizeof(resolution_tuple))) + res = 0; + resolution_tuple r = resolution_choices[res]; + int fps; + switch (static_cast(s.force_fps)) + { + default: + case 0: + fps = 0; + break; + case 30: + fps = 1; + break; + case 60: + fps = 2; + break; + case 120: + fps = 3; + break; + } + camera = cv::VideoCapture(s.camera_index); + if (r.width) + { + camera.set(CV_CAP_PROP_FRAME_WIDTH, r.width); + camera.set(CV_CAP_PROP_FRAME_HEIGHT, r.height); + } + if (fps) + camera.set(CV_CAP_PROP_FPS, fps); aruco::MarkerDetector detector; detector.setDesiredSpeed(3); @@ -206,7 +188,7 @@ void Tracker::run() auto freq = cv::getTickFrequency(); auto last_time = cv::getTickCount(); - int fps = 0; + int cur_fps = 0; int last_fps = 0; cv::Point2f last_centroid; @@ -216,7 +198,7 @@ void Tracker::run() continue; auto tm = cv::getTickCount(); color_.copyTo(color); - if (red_only) + if (s.red_only) { cv::Mat channel[3]; cv::split(color, channel); @@ -227,8 +209,8 @@ void Tracker::run() const int scale = frame.cols > 480 ? 2 : 1; detector.setThresholdParams(scale > 1 ? 11 : 7, 4); - const float focal_length_w = 0.5 * grayscale.cols / tan(0.5 * fov * HT_PI / 180); - const float focal_length_h = 0.5 * grayscale.rows / tan(0.5 * fov * grayscale.rows / grayscale.cols * HT_PI / 180.0); + const float focal_length_w = 0.5 * grayscale.cols / tan(0.5 * s.fov * HT_PI / 180); + const float focal_length_h = 0.5 * grayscale.rows / tan(0.5 * s.fov * grayscale.rows / grayscale.cols * HT_PI / 180.0); cv::Mat intrinsics = cv::Mat::eye(3, 3, CV_32FC1); intrinsics.at (0, 0) = focal_length_w; intrinsics.at (1, 1) = focal_length_h; @@ -275,12 +257,12 @@ void Tracker::run() if ((long) (time / freq) != (long) (last_time / freq)) { - last_fps = fps; - fps = 0; + last_fps = cur_fps; + cur_fps = 0; last_time = time; } - fps++; + cur_fps++; char buf[128]; @@ -296,18 +278,18 @@ void Tracker::run() const float size = 7; cv::Mat obj_points(4,3,CV_32FC1); - obj_points.at(1,0)=-size + headpos[0]; - obj_points.at(1,1)=-size + headpos[1]; - obj_points.at(1,2)=0 + headpos[2]; - obj_points.at(2,0)=size + headpos[0]; - obj_points.at(2,1)=-size + headpos[1]; - obj_points.at(2,2)=0 + headpos[2]; - obj_points.at(3,0)=size + headpos[0]; - obj_points.at(3,1)=size + headpos[1]; - obj_points.at(3,2)=0 + headpos[2]; - obj_points.at(0,0)=-size + headpos[0]; - obj_points.at(0,1)=size + headpos[1]; - obj_points.at(0,2)=0 + headpos[2]; + obj_points.at(1,0)=-size + s.headpos_x; + obj_points.at(1,1)=-size + s.headpos_y; + obj_points.at(1,2)=0 + s.headpos_z; + obj_points.at(2,0)=size + s.headpos_x; + obj_points.at(2,1)=-size + s.headpos_y; + obj_points.at(2,2)=0 + s.headpos_z; + obj_points.at(3,0)=size + s.headpos_x; + obj_points.at(3,1)=size + s.headpos_y; + obj_points.at(3,2)=0 + s.headpos_z; + obj_points.at(0,0)=-size + s.headpos_x; + obj_points.at(0,1)=size + s.headpos_y; + obj_points.at(0,2)=0 + s.headpos_z; last_roi = cv::Rect(65535, 65535, 0, 0); @@ -341,22 +323,12 @@ void Tracker::run() cv::Rodrigues(rvec, rotation_matrix); { - const double beta = headpitch * HT_PI / 180; - double pitch[] = { - 1, 0, 0, - 0, cos(beta), -sin(beta), - 0, sin(beta), cos(beta) - }; - cv::Mat rot(3, 3, CV_64F, pitch); - cv::Mat tvec2 = rot * tvec; - rotation_matrix = rot * rotation_matrix; - cv::Vec3d euler = cv::RQDecomp3x3(rotation_matrix, junk1, junk2); QMutexLocker lck(&mtx); for (int i = 0; i < 3; i++) - pose[i] = tvec2.at(i); + pose[i] = tvec.at(i); pose[Yaw] = euler[1]; pose[Pitch] = -euler[0]; @@ -389,17 +361,17 @@ void Tracker::GetHeadPoseData(double *data) { QMutexLocker lck(&mtx); - if (enableRX) + if (s.eyaw) data[Yaw] = pose[Yaw]; - if (enableRY) + if (s.epitch) data[Pitch] = pose[Pitch]; - if (enableRZ) + if (s.eroll) data[Roll] = pose[Roll]; - if (enableTX) + if (s.ex) data[TX] = pose[TX]; - if (enableTY) + if (s.ey) data[TY] = pose[TY]; - if (enableTZ) + if (s.ez) data[TZ] = pose[TZ]; } @@ -468,178 +440,49 @@ TrackerControls::TrackerControls() tracker = nullptr; 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.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.cx, SIGNAL(valueChanged(double)), this, SLOT(settingChanged(double))); - connect(ui.cy, SIGNAL(valueChanged(double)), this, SLOT(settingChanged(double))); - connect(ui.cz, SIGNAL(valueChanged(double)), this, SLOT(settingChanged(double))); - //connect(ui.buttonCancel, SIGNAL(clicked()), this, SLOT(doCancel())); - //connect(ui.buttonOK, SIGNAL(clicked()), this, SLOT(doOK())); - //connect(ui.buttonSettings, SIGNAL(clicked()), this, SLOT(cameraSettings())); + tie_setting(s.camera_index, ui.cameraName); + tie_setting(s.force_fps, ui.cameraFPS); + tie_setting(s.fov, ui.cameraFOV); + tie_setting(s.eyaw, ui.rx); + tie_setting(s.epitch, ui.ry); + tie_setting(s.eroll, ui.rz); + tie_setting(s.ex, ui.tx); + tie_setting(s.ey, ui.ty); + tie_setting(s.ez, ui.tz); + tie_setting(s.headpos_x, ui.cx); + tie_setting(s.headpos_y, ui.cy); + tie_setting(s.headpos_z, ui.cz); + tie_setting(s.red_only, ui.red_only); connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); - loadSettings(); - settingsDirty = false; -} - -TrackerControls::~TrackerControls() -{ -} - -void TrackerControls::showEvent(QShowEvent *) -{ -} - -void TrackerControls::Initialize(QWidget*) -{ - loadSettings(); - show(); -} - -void TrackerControls::loadSettings() -{ - ui.cameraName->clear(); - QList names = get_camera_names(); - names.prepend("Any available"); - ui.cameraName->addItems(names); - QSettings settings("opentrack"); - 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); - ui.cameraFOV->setValue(iniFile.value("fov", 56).toFloat()); - int fps; - switch (iniFile.value("fps", 0).toInt()) - { - default: - case 0: - fps = 0; - break; - case 30: - fps = 1; - break; - case 60: - fps = 2; - break; - case 120: - fps = 3; - break; - } - ui.cameraFPS->setCurrentIndex(fps); - ui.rx->setCheckState(iniFile.value("enable-rx", true).toBool() ? Qt::Checked : Qt::Unchecked); - ui.ry->setCheckState(iniFile.value("enable-ry", true).toBool() ? Qt::Checked : Qt::Unchecked); - ui.rz->setCheckState(iniFile.value("enable-rz", true).toBool() ? Qt::Checked : Qt::Unchecked); - ui.tx->setCheckState(iniFile.value("enable-tx", true).toBool() ? Qt::Checked : Qt::Unchecked); - ui.ty->setCheckState(iniFile.value("enable-ty", true).toBool() ? Qt::Checked : Qt::Unchecked); - ui.tz->setCheckState(iniFile.value("enable-tz", true).toBool() ? Qt::Checked : Qt::Unchecked); - ui.resolution->setCurrentIndex(iniFile.value("resolution", 0).toInt()); - - QDoubleSpinBox* headpos[] = { - ui.cx, - ui.cy, - ui.cz - }; - - for (int i = 0; i < 3; i++) - { - headpos[i]->setValue(iniFile.value(QString("headpos-%1").arg(i)).toDouble()); - } - - ui.pitch_deg->setValue(iniFile.value("pitch", 0).toDouble()); - ui.red_only->setChecked(iniFile.value("red-only", true).toBool()); - iniFile.endGroup(); - settingsDirty = false; -} - -void TrackerControls::save() -{ - QSettings settings("opentrack"); - QString currentFile = settings.value( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); - QSettings iniFile( currentFile, QSettings::IniFormat ); - - iniFile.beginGroup( "aruco-Tracker" ); - iniFile.setValue("fov", ui.cameraFOV->value()); - int fps; - switch (ui.cameraFPS->currentIndex()) - { - case 0: - default: - fps = 0; - break; - case 1: - fps = 30; - break; - case 2: - fps = 60; - break; - case 3: - fps = 120; - break; - } - iniFile.setValue("fps", fps); - iniFile.setValue("camera-index", ui.cameraName->currentIndex() - 1); - iniFile.setValue("enable-rx", ui.rx->checkState() != Qt::Unchecked ? true : false); - iniFile.setValue("enable-ry", ui.ry->checkState() != Qt::Unchecked ? true : false); - iniFile.setValue("enable-rz", ui.rz->checkState() != Qt::Unchecked ? true : false); - iniFile.setValue("enable-tx", ui.tx->checkState() != Qt::Unchecked ? true : false); - iniFile.setValue("enable-ty", ui.ty->checkState() != Qt::Unchecked ? true : false); - iniFile.setValue("enable-tz", ui.tz->checkState() != Qt::Unchecked ? true : false); - iniFile.setValue("resolution", ui.resolution->currentIndex()); - iniFile.setValue("pitch", ui.pitch_deg->value()); - - QDoubleSpinBox* headpos[] = { - ui.cx, - ui.cy, - ui.cz - }; - - for (int i = 0; i < 3; i++) - { - iniFile.setValue(QString("headpos-%1").arg(i), headpos[i]->value()); - } - iniFile.setValue("red-only", ui.red_only->isChecked()); - iniFile.endGroup(); - settingsDirty = false; - if (tracker) - tracker->load_settings(); + ui.cameraName->addItems(get_camera_names()); } void TrackerControls::doOK() { - save(); + s.b->save(); this->close(); } void TrackerControls::doCancel() { - if (settingsDirty) { + 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 ); + QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel ); switch (ret) { case QMessageBox::Save: - 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; + break; } } else { diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h index 545ad5d0..23598f4d 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h @@ -18,6 +18,33 @@ #include #include #include +#include "facetracknoir/options.hpp" +using namespace options; + +struct settings { + pbundle b; + value fov, headpos_x, headpos_y, headpos_z; + value camera_index, force_fps, resolution; + value red_only; + value eyaw, epitch, eroll, ex, ey, ez; + settings() : + b(bundle("aruco-tracker")), + fov(b, "field-of-view", 56), + headpos_x(b, "headpos-x", 0), + headpos_y(b, "headpos-y", 0), + headpos_z(b, "headpos-z", 0), + camera_index(b, "camera-index", 0), + force_fps(b, "force-fps", 0), + resolution(b, "force-resolution", 0), + red_only(b, "red-only", false), + eyaw(b, "enable-y", true), + epitch(b, "enable-p", true), + eroll(b, "enable-r", true), + ex(b, "enable-x", true), + ey(b, "enable-y", true), + ez(b, "enable-z", true) + {} +}; class Tracker : protected QThread, public ITracker { @@ -27,22 +54,16 @@ public: virtual ~Tracker(); void StartTracker(QFrame* frame); void GetHeadPoseData(double *data); - bool enableTX, enableTY, enableTZ, enableRX, enableRY, enableRZ; void run(); - void load_settings(); private: QMutex mtx; - ArucoVideoWidget* videoWidget; - QHBoxLayout* layout; volatile bool stop; - float fov; - int camera_index; - int force_fps, force_width, force_height; + QHBoxLayout* layout; + ArucoVideoWidget* videoWidget; + settings s; double pose[6]; cv::Mat frame; - double headpos[3], headpitch; cv::VideoCapture camera; - volatile bool red_only; }; // Widget that has controls for FTNoIR protocol client-settings. @@ -50,32 +71,20 @@ class TrackerControls : public QWidget, public ITrackerDialog { Q_OBJECT public: - - explicit TrackerControls(); - virtual ~TrackerControls(); - void showEvent (QShowEvent *); - - void Initialize(QWidget *); + TrackerControls(); void registerTracker(ITracker * x) { tracker = dynamic_cast(x); } void unRegisterTracker() { tracker = nullptr; } - private: Ui::Form ui; - void loadSettings(); - void save(); - bool settingsDirty; Tracker* tracker; - + settings s; private slots: void doOK(); void doCancel(); - void settingChanged() { settingsDirty = true; } - void settingChanged(int) { settingsDirty = true; } - void settingChanged(double) { settingsDirty = true; } }; #endif diff --git a/ftnoir_tracker_base/ftnoir_tracker_base.h b/ftnoir_tracker_base/ftnoir_tracker_base.h index 16f76cf3..b8e16e9d 100644 --- a/ftnoir_tracker_base/ftnoir_tracker_base.h +++ b/ftnoir_tracker_base/ftnoir_tracker_base.h @@ -58,8 +58,7 @@ inline ITracker::~ITracker() { } struct ITrackerDialog { virtual ~ITrackerDialog() {} - virtual void Initialize(QWidget *parent) = 0; - virtual void registerTracker(ITracker *tracker) = 0; + virtual void registerTracker(ITracker *tracker) = 0; virtual void unRegisterTracker() = 0; }; diff --git a/ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp b/ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp index 3547dd6b..6fef2db0 100644 --- a/ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp +++ b/ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp @@ -403,7 +403,6 @@ void FTNoIR_Tracker::GetHeadPoseData(THeadPoseData *data) CptError=0; return; } -#ifdef OPENTRACK_API data[frame_cnt] = (long) HAT.Code; struct Fun { @@ -446,39 +445,6 @@ void FTNoIR_Tracker::GetHeadPoseData(THeadPoseData *data) if (settings.InvertZ) data[TZ] = HAT.Trans[Fun::clamp3(settings.ZAxe)]* -1.0f; else data[TZ] = HAT.Trans[Fun::clamp3(settings.ZAxe)]; } -#else - data->frame_number = (long) HAT.Code; - - if (bEnableYaw) { - if (bInvertYaw ) data->yaw = (double) HAT.Rot[iYawAxe] * -1.0f; - else data->yaw = (double) HAT.Rot[iYawAxe]; - } - - if (bEnablePitch) { - if (bInvertPitch)data->pitch = (double) HAT.Rot[iPitchAxe] * -1.0f; - else data->pitch = (double) HAT.Rot[iPitchAxe]; - } - - if (bEnableRoll) { - if (bInvertRoll) data->roll = (double) HAT.Rot[iRollAxe] * -1.0f; - else data->roll = (double) HAT.Rot[iRollAxe]; - } - - if (bEnableX) { - if (bInvertX) data->x = (double) HAT.Trans[iXAxe]* -1.0f; - else data->x = (double) HAT.Trans[iXAxe]; - } - - if (bEnableY) { - if (bInvertY) data->y = (double) HAT.Trans[iYAxe]* -1.0f; - else data->y = (double) HAT.Trans[iYAxe]; - } - - if (bEnableZ) { - if (bInvertZ) data->z = (double) HAT.Trans[iZAxe]* -1.0f; - else data->z = (double) HAT.Trans[iZAxe]; - } -#endif } void FTNoIR_Tracker::applysettings(const TrackerSettings& settings){ diff --git a/ftnoir_tracker_hatire/ftnoir_tracker_hat.h b/ftnoir_tracker_hatire/ftnoir_tracker_hat.h index a4243c38..57ead58d 100644 --- a/ftnoir_tracker_hatire/ftnoir_tracker_hat.h +++ b/ftnoir_tracker_hatire/ftnoir_tracker_hat.h @@ -27,15 +27,8 @@ public: FTNoIR_Tracker(); ~FTNoIR_Tracker(); -#ifdef OPENTRACK_API virtual void StartTracker(QFrame*); virtual void GetHeadPoseData(double* data); -#else - void Initialize( QFrame *videoframe ); - virtual void StartTracker(HWND parent_window); - virtual void StopTracker(bool exit); - virtual bool GetHeadPoseData(THeadPoseData *data); -#endif void applysettings(const TrackerSettings& settings); void notifyCenter(); bool notifyZeroed(); diff --git a/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.cpp b/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.cpp index 0ef723c9..2ef75b89 100644 --- a/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.cpp +++ b/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.cpp @@ -146,24 +146,6 @@ TrackerControls::TrackerControls() : theTracker(NULL), timer(this) connect(&timer,SIGNAL(timeout()), this,SLOT(poll_tracker_info())); } -// -// Destructor for server-dialog -// -TrackerControls::~TrackerControls() { -} - -// -// Initialize tracker-client-dialog -// -void TrackerControls::Initialize(QWidget *parent) { - QPoint offsetpos(100, 100); - if (parent) { - this->move(parent->pos() + offsetpos); - } - show(); -} - - // // Center asked to ARDUINO // diff --git a/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.h b/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.h index 82c69e0d..fe16e5e8 100644 --- a/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.h +++ b/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.h @@ -21,8 +21,6 @@ class TrackerControls: public QWidget, public ITrackerDialog Q_OBJECT public: explicit TrackerControls(); - virtual ~TrackerControls(); - void Initialize(QWidget *parent) virt_override; void registerTracker(ITracker *tracker) virt_override; void unRegisterTracker() virt_override; private: @@ -30,7 +28,7 @@ private: FTNoIR_Tracker *theTracker; QTime last_time; -public slots: +public slots: void WriteMsgInfo(const QByteArray &MsgInfo); protected slots: diff --git a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp index e154557e..1773b018 100644 --- a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp +++ b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp @@ -275,11 +275,6 @@ TrackerControls::TrackerControls() connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); } -void TrackerControls::Initialize(QWidget*) -{ - show(); -} - void TrackerControls::doOK() { s.b->save(); diff --git a/ftnoir_tracker_ht/ftnoir_tracker_ht.h b/ftnoir_tracker_ht/ftnoir_tracker_ht.h index f45e54f9..b3c89136 100644 --- a/ftnoir_tracker_ht/ftnoir_tracker_ht.h +++ b/ftnoir_tracker_ht/ftnoir_tracker_ht.h @@ -62,7 +62,6 @@ class TrackerControls : public QWidget, public ITrackerDialog Q_OBJECT public: explicit TrackerControls(); - void Initialize(QWidget *); void registerTracker(ITracker *) {} void unRegisterTracker() {} diff --git a/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h b/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h index 16629c3a..8d91dfbb 100644 --- a/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h +++ b/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h @@ -45,7 +45,6 @@ class TrackerControls: public QWidget, public ITrackerDialog Q_OBJECT public: explicit TrackerControls(); - void Initialize(QWidget *parent); void registerTracker(ITracker *) {} void unRegisterTracker() {} private: diff --git a/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dialog.cpp b/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dialog.cpp index e92180a3..4a2deb9f 100644 --- a/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dialog.cpp +++ b/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dialog.cpp @@ -18,15 +18,6 @@ QWidget() tie_setting(s.bEnableZ, ui.chkEnableZ); } -void TrackerControls::Initialize(QWidget *parent) { - - QPoint offsetpos(100, 100); - if (parent) { - this->move(parent->pos() + offsetpos); - } - show(); -} - void TrackerControls::doOK() { s.b->save(); this->close(); diff --git a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h index 9c856d85..67291e6f 100644 --- a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h +++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h @@ -62,11 +62,7 @@ class TrackerControls: public QWidget, public ITrackerDialog { Q_OBJECT public: - explicit TrackerControls(); - ~TrackerControls(); - void showEvent (QShowEvent *); - - void Initialize(QWidget *parent); + TrackerControls(); void registerTracker(ITracker *foo) { tracker = dynamic_cast(foo); } diff --git a/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp b/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp index af3613d9..42ca8689 100644 --- a/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp +++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp @@ -50,29 +50,11 @@ fin: loadSettings(); } -// -// Destructor for server-dialog -// -TrackerControls::~TrackerControls() { -} - -void TrackerControls::Initialize(QWidget *parent) { - QPoint offsetpos(100, 100); - if (parent) { - this->move(parent->pos() + offsetpos); - } - show(); -} - void TrackerControls::doOK() { save(); this->close(); } -void TrackerControls::showEvent ( QShowEvent * ) { - loadSettings(); -} - void TrackerControls::doCancel() { 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 ); diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp b/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp index e10db0bf..b548db71 100644 --- a/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp +++ b/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp @@ -26,8 +26,6 @@ Rift_Tracker::~Rift_Tracker() System::Destroy(); } - - void Rift_Tracker::StartTracker(QFrame*) { System::Init(Log::ConfigureDefaultLog(LogMask_All)); diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift.h b/ftnoir_tracker_rift/ftnoir_tracker_rift.h index 80bf6ffa..b1f96bf2 100644 --- a/ftnoir_tracker_rift/ftnoir_tracker_rift.h +++ b/ftnoir_tracker_rift/ftnoir_tracker_rift.h @@ -55,7 +55,6 @@ class TrackerControls: public QWidget, public ITrackerDialog public: explicit TrackerControls(); - void Initialize(QWidget *parent); void registerTracker(ITracker *) {} void unRegisterTracker() {} diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp b/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp index 5487da92..763ddd11 100644 --- a/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp +++ b/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp @@ -20,15 +20,6 @@ QWidget() tie_setting(s.useYawSpring, ui.yawSpring); } -void TrackerControls::Initialize(QWidget *parent) { - - QPoint offsetpos(100, 100); - if (parent) { - this->move(parent->pos() + offsetpos); - } - show(); -} - void TrackerControls::doOK() { s.b->save(); this->close(); diff --git a/ftnoir_tracker_udp/ftnoir_tracker_udp.h b/ftnoir_tracker_udp/ftnoir_tracker_udp.h index c7e9decf..7157f064 100644 --- a/ftnoir_tracker_udp/ftnoir_tracker_udp.h +++ b/ftnoir_tracker_udp/ftnoir_tracker_udp.h @@ -49,9 +49,6 @@ public: explicit TrackerControls(); ~TrackerControls(); - void showEvent (QShowEvent *); - - void Initialize(QWidget *parent); void registerTracker(ITracker *) {} void unRegisterTracker() {} diff --git a/ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp b/ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp index e17d5c32..707abf37 100644 --- a/ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp +++ b/ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp @@ -60,34 +60,11 @@ 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 * ) { - loadSettings(); -} - -// -// Cancel clicked on server-dialog -// void TrackerControls::doCancel() { // // Ask if changed Settings should be saved -- cgit v1.2.3 From 379137fcf8fda2fd480d467f82bf072523e707aa Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 31 Dec 2013 08:42:51 +0100 Subject: qfc: delete copy ctor --- qfunctionconfigurator/functionconfig.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qfunctionconfigurator/functionconfig.h b/qfunctionconfigurator/functionconfig.h index a8bb3371..d809259b 100644 --- a/qfunctionconfigurator/functionconfig.h +++ b/qfunctionconfigurator/functionconfig.h @@ -30,7 +30,7 @@ private: volatile bool _tracking_active; int _max_Input; int _max_Output; - FunctionConfig(const FunctionConfig&) {} + FunctionConfig(const FunctionConfig&) = delete; public: // // Contructor(s) and destructor -- 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 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 f32f731518ffe2a2b3f7463eda6cf01b7e09eab3 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 31 Dec 2013 08:43:51 +0100 Subject: resize and cleanup aruco ui --- ftnoir_tracker_aruco/aruco-trackercontrols.ui | 256 ++++++++++++-------------- 1 file changed, 122 insertions(+), 134 deletions(-) diff --git a/ftnoir_tracker_aruco/aruco-trackercontrols.ui b/ftnoir_tracker_aruco/aruco-trackercontrols.ui index 710a33e1..3bf141de 100644 --- a/ftnoir_tracker_aruco/aruco-trackercontrols.ui +++ b/ftnoir_tracker_aruco/aruco-trackercontrols.ui @@ -9,12 +9,12 @@ 0 0 - 704 - 339 + 630 + 315 - + 0 0 @@ -32,78 +32,8 @@ -1 - - - - Horizontal FOV - - - - - - - Enable axes - - - - -1 - - - 6 - - - 0 - - - 6 - - - 0 - - - - - RX - - - - - - - TX - - - - - - - RY - - - - - - - TY - - - - - - - RZ - - - - - - - TZ - - - - - + + @@ -112,9 +42,6 @@ - - - @@ -131,6 +58,20 @@ + + + + Recommended! + + + + + + + Camera name + + + @@ -155,13 +96,6 @@ - - - - Resolution - - - @@ -193,13 +127,6 @@ - - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - @@ -224,39 +151,109 @@ - - + + - Camera name + Red channel only - - + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + - Red channel only + Horizontal FOV - - + + - Recommended! + Resolution - + + + + Enable axes + + + + -1 + + + 6 + + + 0 + + + 6 + + + 0 + + + + + RX + + + + + + + TX + + + + + + + RY + + + + + + + TY + + + + + + + RZ + + + + + + + TZ + + + + + + + - Head centroid position + Head position Qt::AlignCenter - - - Qt::AlignHCenter|Qt::AlignTop - + @@ -266,6 +263,12 @@ + + + 0 + 0 + + -200.000000000000000 @@ -283,6 +286,12 @@ + + + 0 + 0 + + -200.000000000000000 @@ -300,6 +309,12 @@ + + + 0 + 0 + + -200.000000000000000 @@ -308,32 +323,6 @@ - - - - Pitch - - - - - - - ° - - - 2 - - - -60.000000000000000 - - - 60.000000000000000 - - - 0.000000000000000 - - - @@ -347,7 +336,6 @@ cx cy cz - pitch_deg rx ry rz -- cgit v1.2.3 From faec4fed35fc7e30ba50143a4f7cdbbd68fb0508 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 31 Dec 2013 08:57:39 +0100 Subject: ewma use settings framework --- ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp | 39 +-------- ftnoir_filter_ewma2/ftnoir_filter_ewma2.h | 45 ++++------ ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp | 99 +++------------------- ftnoir_filter_ewma2/ftnoir_filter_ewma_dll.cpp | 18 ---- 4 files changed, 32 insertions(+), 169 deletions(-) diff --git a/ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp b/ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp index 77596b71..4f07443a 100644 --- a/ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp +++ b/ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp @@ -37,42 +37,13 @@ // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -FTNoIR_Filter::FTNoIR_Filter() +FTNoIR_Filter::FTNoIR_Filter() : first_run(true), alpha_smoothing(0.02) { - first_run = true; - alpha_smoothing = 0.02f; // this is a constant for now, might be a parameter later - loadSettings(); // Load the Settings } -void FTNoIR_Filter::receiveSettings(double smin, double smax, double sexpt) +void FTNoIR_Filter::receiveSettings() { - 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 (); + s.b->reload(); } void FTNoIR_Filter::FilterHeadPoseData(const double *target_camera_position, @@ -93,15 +64,13 @@ void FTNoIR_Filter::FilterHeadPoseData(const double *target_camera_position, 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))); + new_alpha=1.0/(s.kMinSmoothing+((1.0-pow(delta,s.kSmoothingScaleCurve))*(s.kMaxSmoothing-s.kMinSmoothing))); // Update the smoothed alpha. alpha[i]=(alpha_smoothing*new_alpha)+((1.0-alpha_smoothing)*alpha[i]); } diff --git a/ftnoir_filter_ewma2/ftnoir_filter_ewma2.h b/ftnoir_filter_ewma2/ftnoir_filter_ewma2.h index 7c98b2cb..6e9a7f9a 100644 --- a/ftnoir_filter_ewma2/ftnoir_filter_ewma2.h +++ b/ftnoir_filter_ewma2/ftnoir_filter_ewma2.h @@ -31,35 +31,35 @@ #include "ui_ftnoir_ewma_filtercontrols.h" #include #include +#include "facetracknoir/options.hpp" +using namespace options; + +struct settings { + pbundle b; + value kMinSmoothing, kMaxSmoothing, kSmoothingScaleCurve; + settings() : + b(bundle("ewma-filter")), + kMinSmoothing(b, "min-smoothing", 15), + kMaxSmoothing(b, "max-smoothing", 50), + kSmoothingScaleCurve(b, "smoothing-scale-curve", 10) + {} +}; + -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// -// EWMA Filter: Exponentially Weighted Moving Average filter with dynamic smoothing parameter -// -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// class FTNoIR_Filter : public IFilter { public: FTNoIR_Filter(); void reset() {} - void FilterHeadPoseData(const double *target_camera_position, double *new_camera_position); - void receiveSettings(double smin, double smax, double sexpt); - + void receiveSettings(); 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; double current_camera_position[6]; - QMutex mutex; + settings s; }; //******************************************************************************************************* @@ -71,26 +71,19 @@ class FilterControls: public QWidget, public IFilterDialog { Q_OBJECT public: - explicit FilterControls(); - void showEvent (QShowEvent *); + FilterControls(); void registerFilter(IFilter* flt); void unregisterFilter(); private: Ui::UICFilterControls ui; - void loadSettings(); void save(); - - /** helper **/ - bool settingsDirty; - + settings s; FTNoIR_Filter* pFilter; private slots: void doOK(); void doCancel(); - void settingChanged() { settingsDirty = true; } - void settingChanged( int ) { settingsDirty = true; } }; //******************************************************************************************************* @@ -99,8 +92,6 @@ private slots: 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"); } diff --git a/ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp b/ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp index eb414340..e452c6f0 100644 --- a/ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp +++ b/ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp @@ -28,35 +28,17 @@ #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 ); + ui.setupUi( this ); - QPoint offsetpos(100, 100); - //if (parent) { - // this->move(parent->pos() + offsetpos); - //} + connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); + connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); - // 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(); + tie_setting(s.kMaxSmoothing, ui.maxSmooth); + tie_setting(s.kMinSmoothing, ui.minSmooth); + tie_setting(s.kSmoothingScaleCurve, ui.powCurve); } void FilterControls::registerFilter(IFilter* flt) @@ -69,34 +51,23 @@ void FilterControls::unregisterFilter() pFilter = NULL; } -// -// OK clicked on server-dialog -// void FilterControls::doOK() { save(); this->close(); } -// override show event -void FilterControls::showEvent ( QShowEvent * ) { - loadSettings(); -} - -// -// Cancel clicked on server-dialog -// void FilterControls::doCancel() { // // Ask if changed Settings should be saved // - if (settingsDirty) { + 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: - save(); + save(); this->close(); break; case QMessageBox::Discard: @@ -115,62 +86,12 @@ void FilterControls::doCancel() { } } -// -// 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; - + s.b->save(); if (pFilter) - pFilter->receiveSettings(smooth_min, smooth_max, smooth_expt); + pFilter->receiveSettings(); } -//////////////////////////////////////////////////////////////////////////////// -// 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 087ede1b..6ef7768e 100644 --- a/ftnoir_filter_ewma2/ftnoir_filter_ewma_dll.cpp +++ b/ftnoir_filter_ewma2/ftnoir_filter_ewma_dll.cpp @@ -23,26 +23,8 @@ * * ********************************************************************************/ #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; -- cgit v1.2.3 From 2c88cc23a4b68261a43895ecc5197658bbe20884 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 31 Dec 2013 09:02:29 +0100 Subject: ewma: discard settings on cancel --- ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp b/ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp index e452c6f0..7ab2b09c 100644 --- a/ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp +++ b/ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp @@ -61,7 +61,7 @@ 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, QMessageBox::Discard ); + 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; @@ -71,13 +71,11 @@ void FilterControls::doCancel() { 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; } } -- cgit v1.2.3 From 754c2e6ce637698d8aaf16d5bf05e8185e17b9ef Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 31 Dec 2013 09:05:35 +0100 Subject: kalman: remove (all) settings not hooked up --- ftnoir_filter_kalman/ftnoir_filter_kalman.h | 16 +-- .../ftnoir_kalman_filtercontrols.ui | 120 --------------------- ftnoir_filter_kalman/kalman.cpp | 47 +------- 3 files changed, 4 insertions(+), 179 deletions(-) diff --git a/ftnoir_filter_kalman/ftnoir_filter_kalman.h b/ftnoir_filter_kalman/ftnoir_filter_kalman.h index 9e0d817d..8f5bcd8b 100644 --- a/ftnoir_filter_kalman/ftnoir_filter_kalman.h +++ b/ftnoir_filter_kalman/ftnoir_filter_kalman.h @@ -21,13 +21,13 @@ #include #include #include +#include "facetracknoir/options.hpp" +using namespace options; class FTNOIR_FILTER_BASE_EXPORT FTNoIR_Filter : public IFilter { public: FTNoIR_Filter(); - ~FTNoIR_Filter() virt_override { - } void reset() virt_override; void FilterHeadPoseData(const double *target_camera_position, double *new_camera_position) virt_override; @@ -39,9 +39,6 @@ public: qint64 timedelta; }; -void kalman_load_settings(FTNoIR_Filter&); -void kalman_save_settings(FTNoIR_Filter&); - class FTNOIR_FILTER_BASE_EXPORT FTNoIR_FilterDll : public Metadata { public: @@ -55,7 +52,7 @@ class FTNOIR_FILTER_BASE_EXPORT FilterControls: public QWidget, public IFilterDi { Q_OBJECT public: - explicit FilterControls() : settingsDirty(false) { + FilterControls() { ui.setupUi(this); QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // Registry settings (in HK_USER) @@ -68,19 +65,12 @@ public: connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); show(); } - void showEvent ( QShowEvent * ) virt_override { - show(); - } - bool settingsDirty; Ui::KalmanUICFilterControls ui; virtual void registerFilter(IFilter*) virt_override {} virtual void unregisterFilter() virt_override {} public slots: void doOK(); void doCancel(); - void settingsChanged(double) { - settingsDirty = true; - } }; #endif diff --git a/ftnoir_filter_kalman/ftnoir_kalman_filtercontrols.ui b/ftnoir_filter_kalman/ftnoir_kalman_filtercontrols.ui index 7b71712a..d1cff81e 100644 --- a/ftnoir_filter_kalman/ftnoir_kalman_filtercontrols.ui +++ b/ftnoir_filter_kalman/ftnoir_kalman_filtercontrols.ui @@ -63,126 +63,6 @@ Cancel - - - - 9 - 30 - 169 - 16 - - - - process-noise-covariance - - - - - - 180 - 26 - 150 - 22 - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - 14 - - - 1.000000000000000 - - - 0.000001000000000 - - - 0.500000000000000 - - - - - - 180 - 6 - 150 - 22 - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - 14 - - - 1.000000000000000 - - - 0.000001000000000 - - - 0.500000000000000 - - - - - - 9 - 10 - 165 - 16 - - - - post-error-matrix - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - 0 - - - - - - 9 - 55 - 109 - 16 - - - - accel-coefficient - - - - - - 181 - 47 - 150 - 22 - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - 6 - - - 1000000000.000000000000000 - - - 0.000001000000000 - - - 1.000000000000000 - - diff --git a/ftnoir_filter_kalman/kalman.cpp b/ftnoir_filter_kalman/kalman.cpp index 743eb3d4..bef6ddad 100644 --- a/ftnoir_filter_kalman/kalman.cpp +++ b/ftnoir_filter_kalman/kalman.cpp @@ -9,28 +9,7 @@ #include #include -void kalman_load_settings(FTNoIR_Filter&) { - 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("ftnoir-filter-kalman"); - iniFile.endGroup(); -} - -void kalman_save_settings(FilterControls&) { - 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("ftnoir-filter-kalman"); - iniFile.endGroup(); -} - FTNoIR_Filter::FTNoIR_Filter() { - kalman_load_settings(*this); reset(); } @@ -135,35 +114,11 @@ void FTNoIR_Filter::FilterHeadPoseData(const double* target_camera_position, } void FilterControls::doOK() { - kalman_save_settings(*this); close(); } void FilterControls::doCancel() { - 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: - kalman_save_settings(*this); - 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(); - } + close(); } extern "C" FTNOIR_FILTER_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata() -- cgit v1.2.3 From 7bd962db428e403b7e53f9671af313b835f4b858 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 31 Dec 2013 09:25:47 +0100 Subject: fgfs: use settings framework --- ftnoir_protocol_fg/ftnoir_fgcontrols.ui | 321 +++++++---------------- ftnoir_protocol_fg/ftnoir_protocol_fg.cpp | 41 +-- ftnoir_protocol_fg/ftnoir_protocol_fg.h | 52 ++-- ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp | 168 +++--------- ftnoir_protocol_fg/ftnoir_protocol_fg_dll.cpp | 17 -- 5 files changed, 151 insertions(+), 448 deletions(-) diff --git a/ftnoir_protocol_fg/ftnoir_fgcontrols.ui b/ftnoir_protocol_fg/ftnoir_fgcontrols.ui index fd0df6b0..f3b54486 100644 --- a/ftnoir_protocol_fg/ftnoir_fgcontrols.ui +++ b/ftnoir_protocol_fg/ftnoir_fgcontrols.ui @@ -9,8 +9,8 @@ 0 0 - 518 - 208 + 404 + 112 @@ -26,239 +26,101 @@ false - - - - - - - - 60 - 16777215 - - - - 255 - - - 1 - - - - - - - - 60 - 16777215 - - - - 255 - - - 1 - - - - - - - - 60 - 16777215 - - - - 255 - - - 1 - - - - - - - - 60 - 16777215 - - - - 255 - - - 1 - - - - - - - IP-address remote PC - - - - - - - Qt::RightToLeft - - - Local PC only - - - - - - - Port-number - - - - - - - 1000 - - - 10000 - - - - + + + + + IP-address remote PC + + - - - - Qt::Vertical + + + + + 60 + 16777215 + + + + 255 - + + 1 + + + + + + - 20 - 40 + 60 + 16777215 - + + 255 + + + 1 + + - - - - - - If FlightGear is on the same PC as FaceTrackNoIR, tick the 'Local PC only' box. - - - - - - - Otherwise: enter IP-address and port-number for the remote PC. - - - true - - - - - - - Remember: you may have to change firewall-settings too! - - - - + + + + + 60 + 16777215 + + + + 255 + + + 1 + + - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - QLayout::SetDefaultConstraint - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - OK - - - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - Cancel - - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 10 - 20 - - - - - + + + + + 60 + 16777215 + + + + 255 + + + 1 + + + + + + + Port-number + + + + + + + 1000 + + + 10000 + + + + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + @@ -268,9 +130,6 @@ spinIPThirdNibble spinIPFourthNibble spinPortNumber - btnOK - btnCancel - chkLocalPC diff --git a/ftnoir_protocol_fg/ftnoir_protocol_fg.cpp b/ftnoir_protocol_fg/ftnoir_protocol_fg.cpp index 08e7370b..0ef6b50f 100644 --- a/ftnoir_protocol_fg/ftnoir_protocol_fg.cpp +++ b/ftnoir_protocol_fg/ftnoir_protocol_fg.cpp @@ -26,41 +26,14 @@ * 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 -FTNoIR_Protocol::FTNoIR_Protocol() +void FTNoIR_Protocol::reloadSettings() { - loadSettings(); -} - -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(); - 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", 5542 ).toInt(); - - iniFile.endGroup (); - + s.b->reload(); } void FTNoIR_Protocol::sendHeadposeToGame(const double* headpose) { @@ -71,13 +44,15 @@ void FTNoIR_Protocol::sendHeadposeToGame(const double* headpose) { FlightData.h = headpose[Yaw]; FlightData.r = headpose[Roll]; FlightData.status = 1; + QHostAddress destIP(QString("%1.%2.%3.%4").arg( + QString::number(static_cast(s.ip1)), + QString::number(static_cast(s.ip2)), + QString::number(static_cast(s.ip3)), + QString::number(static_cast(s.ip4)))); + int destPort = s.port; (void) outSocket.writeDatagram(reinterpret_cast(&FlightData), sizeof(FlightData), destIP, static_cast(destPort)); } -// -// Check if the Client DLL exists and load it (to test it), if so. -// Returns 'true' if all seems OK. -// bool FTNoIR_Protocol::checkServerInstallationOK() { return outSocket.bind(QHostAddress::Any, 0, QUdpSocket::ShareAddress | QUdpSocket::ReuseAddressHint); diff --git a/ftnoir_protocol_fg/ftnoir_protocol_fg.h b/ftnoir_protocol_fg/ftnoir_protocol_fg.h index 0a255d84..13aaeab4 100644 --- a/ftnoir_protocol_fg/ftnoir_protocol_fg.h +++ b/ftnoir_protocol_fg/ftnoir_protocol_fg.h @@ -26,9 +26,6 @@ * 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" @@ -36,23 +33,36 @@ #include #include #include "facetracknoir/global-settings.h" +#include "facetracknoir/options.hpp" +using namespace options; + +struct settings { + pbundle b; + value ip1, ip2, ip3, ip4; + value port; + settings() : + b(bundle("flightgear-proto")), + ip1(b, "ip1", 192), + ip2(b, "ip2", 168), + ip3(b, "ip3", 0), + ip4(b, "ip4", 2), + port(b, "port", 5542) + {} +}; class FTNoIR_Protocol : public IProtocol { public: - FTNoIR_Protocol(); - virtual ~FTNoIR_Protocol(); bool checkServerInstallationOK(); void sendHeadposeToGame(const double *headpose); QString getGameName() { return "FlightGear"; } + void reloadSettings(); private: + settings s; TFlightGearData FlightData; - QUdpSocket outSocket; // Send to FligthGear - QHostAddress destIP; // Destination IP-address - int destPort; // Destination port-number - void loadSettings(); + QUdpSocket outSocket; }; // Widget that has controls for FTNoIR protocol client-settings. @@ -60,47 +70,27 @@ class FGControls: public QWidget, public IProtocolDialog { Q_OBJECT public: - - explicit FGControls(); + FGControls(); 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; - + settings s; 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 cb11ace6..887020c5 100644 --- a/ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp +++ b/ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp @@ -37,155 +37,51 @@ // // Constructor for server-settings-dialog // -FGControls::FGControls() : -QWidget() +FGControls::FGControls() : theProtocol(nullptr) { ui.setupUi( this ); - QPoint offsetpos(100, 100); - //if (parent) { - // this->move(parent->pos() + offsetpos); - //} + tie_setting(s.ip1, ui.spinIPFirstNibble); + tie_setting(s.ip2, ui.spinIPSecondNibble); + tie_setting(s.ip3, ui.spinIPThirdNibble); + tie_setting(s.ip4, ui.spinIPFourthNibble); + tie_setting(s.port, ui.spinPortNumber); - // 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(); + connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); + connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); } -// -// OK clicked on server-dialog -// void FGControls::doOK() { - save(); + s.b->save(); this->close(); + if (theProtocol) + theProtocol->reloadSettings(); } -// -// 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(); - } + 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(); + } } -// -// 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", 5542 ).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 6c7e7c52..3125f136 100644 --- a/ftnoir_protocol_fg/ftnoir_protocol_fg_dll.cpp +++ b/ftnoir_protocol_fg/ftnoir_protocol_fg_dll.cpp @@ -26,23 +26,6 @@ #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; -- cgit v1.2.3 From a93c86a81574d4d8410448c46b6de3a7ce06505a Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 31 Dec 2013 12:21:25 +0100 Subject: fix qt being broken as usual, by cleanup --- CMakeLists.txt | 189 +++++++++++---------------------------------------------- 1 file changed, 37 insertions(+), 152 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8b36cb27..aa551885 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,6 +8,8 @@ if(GIT_FOUND) git_describe(OPENTRACK__COMMIT --tags --always) endif() +include_directories(${CMAKE_SOURCE_DIR}) + if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") set(CMAKE_COMPILER_IS_GNUCC TRUE) set(CMAKE_COMPILER_IS_GNUCXX TRUE) @@ -39,6 +41,7 @@ SET(CMAKE_SKIP_RPATH FALSE) SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}") set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTOMOC_RELAXED_MODE ON) set(CMAKE_POSITION_INDEPENDENT_CODE ON) add_definitions(-DOPENTRACK_API -DIN_OPENTRACK) @@ -174,171 +177,53 @@ else() include_directories("qxt-mini/") endif() endif() -# main app -file(GLOB opentrack-lib-c "opentrack-api/*.cpp" "facetracknoir/global-settings.cpp") -file(GLOB opentrack-lib-h "opentrack-api/*.h" "facetracknoir/global-settings.h") +# qt being broken as usual +set(EXTRA-MOCS "${CMAKE_SOURCE_DIR}/facetracknoir/options.h") -file(GLOB opentrack-bin-c "facetracknoir/*.cpp" "facetracknoir/*.rc") -file(GLOB opentrack-bin-h "facetracknoir/*.h" "facetracknoir/*.hpp") -file(GLOB opentrack-bin-ui "facetracknoir/*.ui") -file(GLOB opentrack-bin-rc "facetracknoir/*.qrc") -QT5_WRAP_UI(opentrack-bin-uih ${opentrack-bin-ui}) -QT5_ADD_RESOURCES(opentrack-bin-rcc ${opentrack-bin-rc}) +macro(opentrack_module n dir) + file(GLOB ${n}-c "${dir}/*.cpp" "${dir}/*.h" ${EXTRA-MOCS}) + file(GLOB ${n}-ui "${dir}/*.ui") + file(GLOB ${n}-rc "${dir}/*.qrc") + QT5_WRAP_UI(${n}-uih ${${n}-ui}) + QT5_ADD_RESOURCES(${n}-rcc ${${n}-rc}) +endmacro() -file(GLOB opentrack-pose-widget-c "ftnoir_posewidget/*.cpp") -file(GLOB opentrack-pose-widget-h "ftnoir_posewidget/*.h") -file(GLOB opentrack-pose-widget-rc "ftnoir_posewidget/*.qrc") -QT5_ADD_RESOURCES(opentrack-pose-widget-rcc ${opentrack-pose-widget-rc}) +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-spline-widget-c "qfunctionconfigurator/*.cpp") -file(GLOB opentrack-spline-widget-h "qfunctionconfigurator/*.h") +opentrack_module(opentrack-bin facetracknoir) +opentrack_module(opentrack-pose-widget ftnoir_posewidget) +opentrack_module(opentrack-spline-widget qfunctionconfigurator) # filters -file(GLOB opentrack-filter-accela-c "ftnoir_filter_accela/*.cpp") -file(GLOB opentrack-filter-accela-h "ftnoir_filter_accela/*.h") -file(GLOB opentrack-filter-accela-ui "ftnoir_filter_accela/*.ui") -file(GLOB opentrack-filter-accela-rc "ftnoir_filter_accela/*.qrc") -QT5_WRAP_UI(opentrack-filter-accela-uih ${opentrack-filter-accela-ui}) -QT5_ADD_RESOURCES(opentrack-filter-accela-rcc ${opentrack-filter-accela-rc}) - -file(GLOB opentrack-filter-kalman-c "ftnoir_filter_kalman/*.cpp") -file(GLOB opentrack-filter-kalman-h "ftnoir_filter_kalman/*.h") -file(GLOB opentrack-filter-kalman-ui "ftnoir_filter_kalman/*.ui") -file(GLOB opentrack-filter-kalman-rc "ftnoir_filter_kalman/*.qrc") -QT5_WRAP_UI(opentrack-filter-kalman-uih ${opentrack-filter-kalman-ui}) -QT5_ADD_RESOURCES(opentrack-filter-kalman-rcc ${opentrack-filter-kalman-rc}) - -file(GLOB opentrack-filter-ewma-c "ftnoir_filter_ewma2/*.cpp") -file(GLOB opentrack-filter-ewma-h "ftnoir_filter_ewma2/*.h") -file(GLOB opentrack-filter-ewma-ui "ftnoir_filter_ewma2/*.ui") -file(GLOB opentrack-filter-ewma-rc "ftnoir_filter_ewma2/*.qrc") -QT5_WRAP_UI(opentrack-filter-ewma-uih ${opentrack-filter-ewma-ui}) -QT5_ADD_RESOURCES(opentrack-filter-ewma-rcc ${opentrack-filter-ewma-rc}) +opentrack_module(opentrack-filter-accela ftnoir_filter_accela) +opentrack_module(opentrack-filter-kalman ftnoir_filter_kalman) +opentrack_module(opentrack-filter-ewma ftnoir_filter_ewma2) # protocols -file(GLOB opentrack-proto-fgfs-c "ftnoir_protocol_fg/*.cpp") -file(GLOB opentrack-proto-fgfs-h "ftnoir_protocol_fg/*.h") -file(GLOB opentrack-proto-fgfs-ui "ftnoir_protocol_fg/*.ui") -file(GLOB opentrack-proto-fgfs-rc "ftnoir_protocol_fg/*.qrc") -QT5_WRAP_UI(opentrack-proto-fgfs-uih ${opentrack-proto-fgfs-ui}) -QT5_ADD_RESOURCES(opentrack-proto-fgfs-rcc ${opentrack-proto-fgfs-rc}) - -file(GLOB opentrack-proto-fsuipc-c "ftnoir_protocol_fsuipc/*.cpp") -file(GLOB opentrack-proto-fsuipc-h "ftnoir_protocol_fsuipc/*.h") -file(GLOB opentrack-proto-fsuipc-ui "ftnoir_protocol_fsuipc/*.ui") -file(GLOB opentrack-proto-fsuipc-rc "ftnoir_protocol_fsuipc/*.qrc") -QT5_WRAP_UI(opentrack-proto-fsuipc-uih ${opentrack-proto-fsuipc-ui}) -QT5_ADD_RESOURCES(opentrack-proto-fsuipc-rcc ${opentrack-proto-fsuipc-rc}) - -file(GLOB opentrack-proto-freetrack-c "ftnoir_protocol_ft/*.cpp") -file(GLOB opentrack-proto-freetrack-h "ftnoir_protocol_ft/*.h") -file(GLOB opentrack-proto-freetrack-ui "ftnoir_protocol_ft/*.ui") -file(GLOB opentrack-proto-freetrack-rc "ftnoir_protocol_ft/*.qrc") -QT5_WRAP_UI(opentrack-proto-freetrack-uih ${opentrack-proto-freetrack-ui}) -QT5_ADD_RESOURCES(opentrack-proto-freetrack-rcc ${opentrack-proto-freetrack-rc}) - -file(GLOB opentrack-proto-udp-c "ftnoir_protocol_ftn/*.cpp") -file(GLOB opentrack-proto-udp-h "ftnoir_protocol_ftn/*.h") -file(GLOB opentrack-proto-udp-ui "ftnoir_protocol_ftn/*.ui") -file(GLOB opentrack-proto-udp-rc "ftnoir_protocol_ftn/*.qrc") -QT5_WRAP_UI(opentrack-proto-udp-uih ${opentrack-proto-udp-ui}) -QT5_ADD_RESOURCES(opentrack-proto-udp-rcc ${opentrack-proto-udp-rc}) - -file(GLOB opentrack-proto-wine-c "ftnoir_protocol_wine/*.cpp") -file(GLOB opentrack-proto-wine-h "ftnoir_protocol_wine/*.h") -file(GLOB opentrack-proto-wine-ui "ftnoir_protocol_wine/*.ui") -file(GLOB opentrack-proto-wine-rc "ftnoir_protocol_wine/*.qrc") -QT5_WRAP_UI(opentrack-proto-wine-uih ${opentrack-proto-wine-ui}) -QT5_ADD_RESOURCES(opentrack-proto-wine-rcc ${opentrack-proto-wine-rc}) - -file(GLOB opentrack-proto-win32-mouse-c "ftnoir_protocol_mouse/*.cpp") -file(GLOB opentrack-proto-win32-mouse-h "ftnoir_protocol_mouse/*.h") -file(GLOB opentrack-proto-win32-mouse-ui "ftnoir_protocol_mouse/*.ui") -file(GLOB opentrack-proto-win32-mouse-rc "ftnoir_protocol_mouse/*.qrc") -QT5_WRAP_UI(opentrack-proto-win32-mouse-uih ${opentrack-proto-win32-mouse-ui}) -QT5_ADD_RESOURCES(opentrack-proto-win32-mouse-rcc ${opentrack-proto-win32-mouse-rc}) - -file(GLOB opentrack-proto-simconnect-c "ftnoir_protocol_sc/*.cpp" "ftnoir_protocol_sc/ftnoir-protocol-sc.rc") -file(GLOB opentrack-proto-simconnect-h "ftnoir_protocol_sc/*.h") -file(GLOB opentrack-proto-simconnect-ui "ftnoir_protocol_sc/*.ui") -file(GLOB opentrack-proto-simconnect-rc "ftnoir_protocol_sc/*.qrc") -QT5_WRAP_UI(opentrack-proto-simconnect-uih ${opentrack-proto-simconnect-ui}) -QT5_ADD_RESOURCES(opentrack-proto-simconnect-rcc ${opentrack-proto-simconnect-rc}) - -file(GLOB opentrack-proto-vjoy-c "ftnoir_protocol_vjoy/*.cpp") -file(GLOB opentrack-proto-vjoy-h "ftnoir_protocol_vjoy/*.h") -file(GLOB opentrack-proto-vjoy-ui "ftnoir_protocol_vjoy/*.ui") -file(GLOB opentrack-proto-vjoy-rc "ftnoir_protocol_vjoy/*.qrc") -QT5_WRAP_UI(opentrack-proto-vjoy-uih ${opentrack-proto-vjoy-ui}) -QT5_ADD_RESOURCES(opentrack-proto-vjoy-rcc ${opentrack-proto-vjoy-rc}) - -file(GLOB opentrack-proto-libevdev-c "ftnoir_protocol_libevdev/*.cpp") -file(GLOB opentrack-proto-libevdev-h "ftnoir_protocol_libevdev/*.h") -file(GLOB opentrack-proto-libevdev-ui "ftnoir_protocol_libevdev/*.ui") -file(GLOB opentrack-proto-libevdev-rc "ftnoir_protocol_libevdev/*.qrc") -QT5_WRAP_UI(opentrack-proto-libevdev-uih ${opentrack-proto-libevdev-ui}) -QT5_ADD_RESOURCES(opentrack-proto-libevdev-rcc ${opentrack-proto-libevdev-rc}) +opentrack_module(opentrack-proto-fgfs ftnoir_protocol_fg) +opentrack_module(opentrack-proto-fsuipc ftnoir_protocol_fsuipc) +opentrack_module(opentrack-proto-freetrack ftnoir_protocol_ft) +opentrack_module(opentrack-proto-udp ftnoir_protocol_ftn) +opentrack_module(opentrack-proto-wine ftnoir_protocol_wine) +opentrack_module(opentrack-proto-win32-mouse ftnoir_protocol_mouse) +opentrack_module(opentrack-proto-simconnect ftnoir_protocol_sc) +opentrack_module(opentrack-proto-vjoy ftnoir_protocol_vjoy) +opentrack_module(opentrack-proto-libevdev ftnoir_protocol_libevdev) # trackers -file(GLOB opentrack-tracker-ht-c "ftnoir_tracker_ht/*.cpp") -file(GLOB opentrack-tracker-ht-h "ftnoir_tracker_ht/*.h") -file(GLOB opentrack-tracker-ht-ui "ftnoir_tracker_ht/*.ui") -file(GLOB opentrack-tracker-ht-rc "ftnoir_tracker_ht/*.qrc") -QT5_WRAP_UI(opentrack-tracker-ht-uih ${opentrack-tracker-ht-ui}) -QT5_ADD_RESOURCES(opentrack-tracker-ht-rcc ${opentrack-tracker-ht-rc}) - -file(GLOB opentrack-tracker-aruco-c "ftnoir_tracker_aruco/*.cpp") -file(GLOB opentrack-tracker-aruco-h "ftnoir_tracker_aruco/*.h") -file(GLOB opentrack-tracker-aruco-ui "ftnoir_tracker_aruco/*.ui") -file(GLOB opentrack-tracker-aruco-rc "ftnoir_tracker_aruco/*.qrc") -QT5_WRAP_UI(opentrack-tracker-aruco-uih ${opentrack-tracker-aruco-ui}) -QT5_ADD_RESOURCES(opentrack-tracker-aruco-rcc ${opentrack-tracker-aruco-rc}) - -file(GLOB opentrack-tracker-pt-c "FTNoIR_Tracker_PT/*.cpp") -file(GLOB opentrack-tracker-pt-h "FTNoIR_Tracker_PT/*.h") -file(GLOB opentrack-tracker-pt-ui "FTNoIR_Tracker_PT/*.ui") -file(GLOB opentrack-tracker-pt-rc "FTNoIR_Tracker_PT/*.qrc") -QT5_WRAP_UI(opentrack-tracker-pt-uih ${opentrack-tracker-pt-ui}) -QT5_ADD_RESOURCES(opentrack-tracker-pt-rcc ${opentrack-tracker-pt-rc}) - -file(GLOB opentrack-tracker-udp-c "ftnoir_tracker_udp/*.cpp") -file(GLOB opentrack-tracker-udp-h "ftnoir_tracker_udp/*.h") -file(GLOB opentrack-tracker-udp-ui "ftnoir_tracker_udp/*.ui") -file(GLOB opentrack-tracker-udp-rc "ftnoir_tracker_udp/*.qrc") -QT5_WRAP_UI(opentrack-tracker-udp-uih ${opentrack-tracker-udp-ui}) -QT5_ADD_RESOURCES(opentrack-tracker-udp-rcc ${opentrack-tracker-udp-rc}) - -file(GLOB opentrack-tracker-joystick-c "ftnoir_tracker_joystick/*.cpp") -file(GLOB opentrack-tracker-joystick-h "ftnoir_tracker_joystick/*.h") -file(GLOB opentrack-tracker-joystick-ui "ftnoir_tracker_joystick/*.ui") -file(GLOB opentrack-tracker-joystick-rc "ftnoir_tracker_joystick/*.qrc") -QT5_WRAP_UI(opentrack-tracker-joystick-uih ${opentrack-tracker-joystick-ui}) -QT5_ADD_RESOURCES(opentrack-tracker-joystick-rcc ${opentrack-tracker-joystick-rc}) - -file(GLOB opentrack-tracker-rift-c "ftnoir_tracker_rift/*.cpp") -file(GLOB opentrack-tracker-rift-h "ftnoir_tracker_rift/*.h") -file(GLOB opentrack-tracker-rift-ui "ftnoir_tracker_rift/*.ui") -file(GLOB opentrack-tracker-rift-rc "ftnoir_tracker_rift/*.qrc") -QT5_WRAP_UI(opentrack-tracker-rift-uih ${opentrack-tracker-rift-ui}) -QT5_ADD_RESOURCES(opentrack-tracker-rift-rcc ${opentrack-tracker-rift-rc}) - -file(GLOB opentrack-tracker-hydra-c "ftnoir_tracker_hydra/*.cpp") -file(GLOB opentrack-tracker-hydra-h "ftnoir_tracker_hydra/*.h") -file(GLOB opentrack-tracker-hydra-ui "ftnoir_tracker_hydra/*.ui") -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}) +opentrack_module(opentrack-tracker-ht ftnoir_tracker_ht) +opentrack_module(opentrack-tracker-aruco ftnoir_tracker_aruco) +opentrack_module(opentrack-tracker-pt FTNoIR_Tracker_PT) +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") -- cgit v1.2.3 From 647b9c58e437fa2c3f0464f630001e1c0b53927a Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 31 Dec 2013 12:39:58 +0100 Subject: cmake: clean up unreferenced globs --- CMakeLists.txt | 61 +++++++++++++++++++++++++++++----------------------------- 1 file changed, 30 insertions(+), 31 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index aa551885..2033a597 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -189,8 +189,7 @@ macro(opentrack_module n dir) QT5_ADD_RESOURCES(${n}-rcc ${${n}-rc}) endmacro() -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-lib-c "opentrack-api/*.cpp" "facetracknoir/global-settings.cpp" "opentrack-api/*.h" "facetracknoir/global-settings.h") opentrack_module(opentrack-bin facetracknoir) opentrack_module(opentrack-pose-widget ftnoir_posewidget) @@ -225,11 +224,11 @@ 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") +file(GLOB opentrack-csv-c "ftnoir_csv/*.cpp" "ftnoir_csv/*.h") # compat lib for POSIX/win32 -file(GLOB opentrack-compat-c "compat/*.cpp") +file(GLOB opentrack-compat-c "compat/*.cpp" "compat/*.h") # x-plane plugin file(GLOB opentrack-xplane-plugin-c "x-plane-plugin/*.c") @@ -271,7 +270,7 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) 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} ${opentrack-compat-h}) +add_library(opentrack-compat SHARED ${opentrack-compat-c}) if(NOT WIN32 AND NOT APPLE) target_link_libraries(opentrack-compat rt) endif() @@ -298,18 +297,18 @@ else() ${Qt5Network_LIBRARIES} ${Qt5Xml_LIBRARIES} ${Qt5Core_LIBRARIES} ${maybe-hatire} ${my-qt-deps}) endif() -add_library(opentrack-csv SHARED ${opentrack-csv-c} ${opentrack-csv-h}) +add_library(opentrack-csv SHARED ${opentrack-csv-c}) target_link_libraries(opentrack-csv ${MY_QT_LIBS}) -add_library(opentrack-pose-widget SHARED ${opentrack-pose-widget-c} ${opentrack-pose-widget-h} ${opentrack-pose-widget-moc} ${opentrack-pose-widget-rcc}) +add_library(opentrack-pose-widget SHARED ${opentrack-pose-widget-c} ${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-h} ${opentrack-spline-widget-moc}) +add_library(opentrack-spline-widget SHARED ${opentrack-spline-widget-c}) target_link_libraries(opentrack-spline-widget ${MY_QT_LIBS}) -add_library(opentrack-filter-accela SHARED ${opentrack-filter-accela-c} ${opentrack-filter-accela-h} ${opentrack-filter-accela-moc} ${opentrack-filter-accela-uih} ${opentrack-filter-accela-rcc}) +add_library(opentrack-filter-accela SHARED ${opentrack-filter-accela-c} ${opentrack-filter-accela-uih} ${opentrack-filter-accela-rcc}) target_link_libraries(opentrack-filter-accela ${MY_QT_LIBS}) -add_library(opentrack-filter-kalman SHARED ${opentrack-filter-kalman-c} ${opentrack-filter-kalman-h} ${opentrack-filter-kalman-moc} ${opentrack-filter-kalman-uih} ${opentrack-filter-kalman-rcc}) +add_library(opentrack-filter-kalman SHARED ${opentrack-filter-kalman-c} ${opentrack-filter-kalman-uih} ${opentrack-filter-kalman-rcc}) target_link_libraries(opentrack-filter-kalman ${MY_QT_LIBS} ${OpenCV_LIBS}) if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) @@ -322,7 +321,7 @@ if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt") endif() -add_library(opentrack-filter-ewma SHARED ${opentrack-filter-ewma-uih} ${opentrack-filter-ewma-c} ${opentrack-filter-ewma-h} ${opentrack-filter-ewma-moc} ${opentrack-filter-ewma-rcc}) +add_library(opentrack-filter-ewma SHARED ${opentrack-filter-ewma-uih} ${opentrack-filter-ewma-c} ${opentrack-filter-ewma-rcc}) target_link_libraries(opentrack-filter-ewma ${MY_QT_LIBS}) if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) @@ -330,7 +329,7 @@ if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt") endif() -add_library(opentrack-proto-fgfs SHARED ${opentrack-proto-fgfs-c} ${opentrack-proto-fgfs-h} ${opentrack-proto-fgfs-moc} ${opentrack-proto-fgfs-uih} ${opentrack-proto-fgfs-rcc}) +add_library(opentrack-proto-fgfs SHARED ${opentrack-proto-fgfs-c} ${opentrack-proto-fgfs-uih} ${opentrack-proto-fgfs-rcc}) target_link_libraries(opentrack-proto-fgfs ${MY_QT_LIBS}) if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) SET_TARGET_PROPERTIES(opentrack-proto-fgfs @@ -339,7 +338,7 @@ endif() if(WIN32 AND SDK_VJOY) include_directories(${SDK_VJOY}) - add_library(opentrack-proto-vjoy SHARED ${opentrack-proto-vjoy-c} ${opentrack-proto-vjoy-h} ${opentrack-proto-vjoy-moc} ${opentrack-proto-vjoy-uih} ${opentrack-proto-vjoy-rcc}) + add_library(opentrack-proto-vjoy SHARED ${opentrack-proto-vjoy-c} ${opentrack-proto-vjoy-uih} ${opentrack-proto-vjoy-rcc}) if(MSVC) target_link_libraries(opentrack-proto-vjoy ${MY_QT_LIBS} "${SDK_VJOY}/VJoy.lib") else() @@ -352,7 +351,7 @@ if(WIN32 AND SDK_VJOY) endif() if(UNIX AND SDK_ENABLE_LIBEVDEV) - add_library(opentrack-proto-libevdev SHARED ${opentrack-proto-libevdev-c} ${opentrack-proto-libevdev-h} ${opentrack-proto-libevdev-moc} ${opentrack-proto-libevdev-uih} ${opentrack-proto-libevdev-rcc}) + add_library(opentrack-proto-libevdev SHARED ${opentrack-proto-libevdev-c} ${opentrack-proto-libevdev-uih} ${opentrack-proto-libevdev-rcc}) target_link_libraries(opentrack-proto-libevdev ${MY_QT_LIBS} evdev) if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) SET_TARGET_PROPERTIES(opentrack-proto-libevdev @@ -363,7 +362,7 @@ endif() if(WIN32) if(SDK_FSUIPC) - add_library(opentrack-proto-fsuipc SHARED ${opentrack-proto-fsuipc-c} ${opentrack-proto-fsuipc-h} ${opentrack-proto-fsuipc-moc} ${opentrack-proto-fsuipc-uih} ${opentrack-proto-fsuipc-rcc}) + add_library(opentrack-proto-fsuipc SHARED ${opentrack-proto-fsuipc-c} ${opentrack-proto-fsuipc-uih} ${opentrack-proto-fsuipc-rcc}) target_link_libraries(opentrack-proto-fsuipc ${MY_QT_LIBS} "${SDK_FSUIPC}/FSUIPC_User.lib") if(MSVC) set_target_properties(opentrack-proto-fsuipc PROPERTIES LINK_FLAGS "/NODEFAULTLIB:libc") @@ -373,24 +372,24 @@ if(WIN32) endif() if(SDK_SIMCONNECT) - add_library(opentrack-proto-simconnect SHARED ${opentrack-proto-simconnect-c} ${opentrack-proto-simconnect-h} ${opentrack-proto-simconnect-moc} ${opentrack-proto-simconnect-uih} ${opentrack-proto-simconnect-rcc}) + add_library(opentrack-proto-simconnect SHARED ${opentrack-proto-simconnect-c} ${opentrack-proto-simconnect-uih} ${opentrack-proto-simconnect-rcc}) target_link_libraries(opentrack-proto-simconnect ${MY_QT_LIBS}) include_directories("${SDK_SIMCONNECT}/inc") target_link_libraries(opentrack-proto-simconnect "${SDK_SIMCONNECT}/lib/SimConnect.lib") endif() - add_library(opentrack-proto-freetrack SHARED ${opentrack-proto-freetrack-c} ${opentrack-proto-freetrack-h} ${opentrack-proto-freetrack-moc} ${opentrack-proto-freetrack-uih} ${opentrack-proto-freetrack-rcc}) + add_library(opentrack-proto-freetrack SHARED ${opentrack-proto-freetrack-c} ${opentrack-proto-freetrack-uih} ${opentrack-proto-freetrack-rcc}) target_link_libraries(opentrack-proto-freetrack opentrack-csv ${MY_QT_LIBS} opentrack-compat) - add_library(opentrack-proto-win32-mouse SHARED ${opentrack-proto-win32-mouse-c} ${opentrack-proto-win32-mouse-h} ${opentrack-proto-win32-mouse-moc} ${opentrack-proto-win32-mouse-uih} ${opentrack-proto-win32-mouse-rcc}) + add_library(opentrack-proto-win32-mouse SHARED ${opentrack-proto-win32-mouse-c} ${opentrack-proto-win32-mouse-uih} ${opentrack-proto-win32-mouse-rcc}) target_link_libraries(opentrack-proto-win32-mouse ${MY_QT_LIBS}) - add_library(freetrackclient SHARED ${opentrack-freetrack-c} ${opentrack-freetrack-h}) + add_library(freetrackclient SHARED ${opentrack-freetrack-c}) if(CMAKE_COMPILER_IS_GNUCC) set_target_properties(freetrackclient PROPERTIES LINK_FLAGS "-Wl,--enable-stdcall-fixup -fno-lto -Wl,-kill-at" PREFIX "" COMPILE_FLAGS "-fno-lto") endif() endif() -add_library(opentrack-proto-udp SHARED ${opentrack-proto-udp-c} ${opentrack-proto-udp-h} ${opentrack-proto-udp-moc} ${opentrack-proto-udp-uih} ${opentrack-proto-udp-rcc}) +add_library(opentrack-proto-udp SHARED ${opentrack-proto-udp-c} ${opentrack-proto-udp-uih} ${opentrack-proto-udp-rcc}) target_link_libraries(opentrack-proto-udp ${MY_QT_LIBS}) if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) SET_TARGET_PROPERTIES(opentrack-proto-udp @@ -398,7 +397,7 @@ if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) endif() if(WIN32) - add_library(opentrack-tracker-joystick SHARED ${opentrack-tracker-joystick-c} ${opentrack-tracker-joystick-h} ${opentrack-tracker-joystick-moc} ${opentrack-tracker-joystick-uih} ${opentrack-tracker-joystick-rcc}) + add_library(opentrack-tracker-joystick SHARED ${opentrack-tracker-joystick-c} ${opentrack-tracker-joystick-uih} ${opentrack-tracker-joystick-rcc}) target_link_libraries(opentrack-tracker-joystick ${MY_QT_LIBS}) if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) SET_TARGET_PROPERTIES(opentrack-tracker-joystick @@ -407,7 +406,7 @@ if(WIN32) endif() if(NOT WIN32 AND SDK_WINE_PREFIX) - add_library(opentrack-proto-wine SHARED ${opentrack-proto-wine-c} ${opentrack-proto-wine-h} ${opentrack-proto-wine-moc} ${opentrack-proto-wine-uih} ${opentrack-proto-wine-rcc}) + add_library(opentrack-proto-wine SHARED ${opentrack-proto-wine-c} ${opentrack-proto-wine-uih} ${opentrack-proto-wine-rcc}) target_link_libraries(opentrack-proto-wine ${MY_QT_LIBS} opentrack-compat opentrack-csv) if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) SET_TARGET_PROPERTIES(opentrack-proto-wine @@ -439,7 +438,7 @@ if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt") endif() -add_library(opentrack-tracker-ht SHARED ${opentrack-tracker-ht-c} ${opentrack-tracker-ht-h} ${opentrack-tracker-ht-moc} ${opentrack-tracker-ht-uih} ${opentrack-tracker-ht-rcc}) +add_library(opentrack-tracker-ht SHARED ${opentrack-tracker-ht-c} ${opentrack-tracker-ht-uih} ${opentrack-tracker-ht-rcc}) target_link_libraries(opentrack-tracker-ht ${MY_QT_LIBS} opentrack-compat) if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) SET_TARGET_PROPERTIES(opentrack-tracker-ht @@ -448,7 +447,7 @@ endif() if(SDK_ARUCO_LIBPATH) include_directories(${CMAKE_SOURCE_DIR}/ftnoir_tracker_aruco/include) - add_library(opentrack-tracker-aruco SHARED ${opentrack-tracker-aruco-c} ${opentrack-tracker-aruco-h} ${opentrack-tracker-aruco-moc} ${opentrack-tracker-aruco-uih} ${opentrack-tracker-aruco-rcc}) + add_library(opentrack-tracker-aruco SHARED ${opentrack-tracker-aruco-c} ${opentrack-tracker-aruco-uih} ${opentrack-tracker-aruco-rcc}) target_link_libraries(opentrack-tracker-aruco ${MY_QT_LIBS} ${SDK_ARUCO_LIBPATH} ${OpenCV_LIBS}) if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) SET_TARGET_PROPERTIES(opentrack-tracker-aruco @@ -463,7 +462,7 @@ if(SDK_ARUCO_LIBPATH) endif() if(SDK_HATIRE) - 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}) + add_library(opentrack-tracker-hatire SHARED ${opentrack-tracker-hatire-c} ${opentrack-tracker-hatire-uih} ${opentrack-tracker-hatire-rcc}) target_link_libraries(opentrack-tracker-hatire ${MY_QT_LIBS}) install(TARGETS opentrack-tracker-hatire RUNTIME DESTINATION . LIBRARY DESTINATION . ) if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) @@ -484,7 +483,7 @@ if(WIN32) uuid) endif() -add_library(opentrack-tracker-pt SHARED ${opentrack-tracker-pt-c} ${opentrack-tracker-pt-h} ${opentrack-tracker-pt-moc} ${opentrack-tracker-pt-uih} ${opentrack-tracker-pt-rcc}) +add_library(opentrack-tracker-pt SHARED ${opentrack-tracker-pt-c} ${opentrack-tracker-pt-uih} ${opentrack-tracker-pt-rcc}) target_link_libraries(opentrack-tracker-pt ${MY_QT_LIBS} ${OpenCV_LIBS}) if(APPLE) @@ -504,7 +503,7 @@ if(WIN32) uuid) endif() -add_library(opentrack-tracker-udp SHARED ${opentrack-tracker-udp-c} ${opentrack-tracker-udp-h} ${opentrack-tracker-udp-moc} ${opentrack-tracker-udp-uih} ${opentrack-tracker-udp-rcc}) +add_library(opentrack-tracker-udp SHARED ${opentrack-tracker-udp-c} ${opentrack-tracker-udp-uih} ${opentrack-tracker-udp-rcc}) target_link_libraries(opentrack-tracker-udp ${MY_QT_LIBS}) if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) SET_TARGET_PROPERTIES(opentrack-tracker-udp @@ -514,7 +513,7 @@ endif() if(SDK_RIFT) include_directories("${SDK_RIFT}/Include") include_directories("${SDK_RIFT}/Src") - add_library(opentrack-tracker-rift SHARED ${opentrack-tracker-rift-c} ${opentrack-tracker-rift-h} ${opentrack-tracker-rift-moc} ${opentrack-tracker-rift-uih} ${opentrack-tracker-rift-rcc}) + add_library(opentrack-tracker-rift SHARED ${opentrack-tracker-rift-c} ${opentrack-tracker-rift-uih} ${opentrack-tracker-rift-rcc}) target_link_libraries(opentrack-tracker-rift ${MY_QT_LIBS}) if(MSVC) target_link_libraries(opentrack-tracker-rift "${SDK_RIFT}/Lib/Win32/libovr.lib" winmm.lib setupapi.lib) @@ -546,7 +545,7 @@ if(SDK_RIFT) if(SDK_HYDRA) include_directories("${SDK_HYDRA}/include") include_directories("${SDK_HYDRA}/include/sixense_utils") - add_library(opentrack-tracker-hydra SHARED ${opentrack-tracker-hydra-c} ${opentrack-tracker-hydra-h} ${opentrack-tracker-hydra-moc} ${opentrack-tracker-hydra-uih} ${opentrack-tracker-hydra-rcc}) + add_library(opentrack-tracker-hydra SHARED ${opentrack-tracker-hydra-c} ${opentrack-tracker-hydra-uih} ${opentrack-tracker-hydra-rcc}) target_link_libraries(opentrack-tracker-hydra ${MY_QT_LIBS}) if(WIN32) target_link_libraries(opentrack-tracker-hydra @@ -594,7 +593,7 @@ if(UNIX OR 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}) +add_executable(opentrack ${opentrack-win32-executable} ${opentrack-bin-c} ${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) @@ -603,7 +602,7 @@ 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}) +add_library(opentrack-api SHARED ${opentrack-lib-c}) target_link_libraries(opentrack-api ${MY_QT_LIBS}) if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) SET_TARGET_PROPERTIES(opentrack-api PROPERTIES -- 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 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(-) 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(-) 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 e1d96c01dc5d7707c7e3a260f49881e6bded832e Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 31 Dec 2013 12:54:31 +0100 Subject: kalman: remove qsettings cruft --- ftnoir_filter_kalman/ftnoir_filter_kalman.h | 7 ------- 1 file changed, 7 deletions(-) diff --git a/ftnoir_filter_kalman/ftnoir_filter_kalman.h b/ftnoir_filter_kalman/ftnoir_filter_kalman.h index 25f0a0ad..f2a1b4ec 100644 --- a/ftnoir_filter_kalman/ftnoir_filter_kalman.h +++ b/ftnoir_filter_kalman/ftnoir_filter_kalman.h @@ -54,13 +54,6 @@ class FTNOIR_FILTER_BASE_EXPORT FilterControls: public QWidget, public IFilterDi public: FilterControls() { ui.setupUi(this); - 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("ftnoir-filter-kalman"); - iniFile.endGroup(); connect(ui.btnOk, SIGNAL(clicked()), this, SLOT(doOK())); connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); show(); -- cgit v1.2.3 From edcdcaadb5920cebc9aaa34572cba74de5637241 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 31 Dec 2013 12:54:42 +0100 Subject: udp: update to settings framework --- ftnoir_protocol_ftn/ftnoir_protocol_ftn.cpp | 79 ++-------------- ftnoir_protocol_ftn/ftnoir_protocol_ftn.h | 46 ++++----- ftnoir_protocol_ftn/ftnoir_protocol_ftn_dialog.cpp | 105 +++------------------ ftnoir_protocol_ftn/ftnoir_protocol_ftn_dll.cpp | 18 ---- 4 files changed, 41 insertions(+), 207 deletions(-) diff --git a/ftnoir_protocol_ftn/ftnoir_protocol_ftn.cpp b/ftnoir_protocol_ftn/ftnoir_protocol_ftn.cpp index 80cbfa0a..e93a751e 100644 --- a/ftnoir_protocol_ftn/ftnoir_protocol_ftn.cpp +++ b/ftnoir_protocol_ftn/ftnoir_protocol_ftn.cpp @@ -32,86 +32,23 @@ /** 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(const double *headpose) { - 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!"; - } - } + int destPort = s.port; + QHostAddress destIP(QString("%1.%2.%3.%4").arg( + QString::number(static_cast(s.ip1)), + QString::number(static_cast(s.ip2)), + QString::number(static_cast(s.ip3)), + QString::number(static_cast(s.ip4)))); + outSocket.writeDatagram((const char *) headpose, sizeof( double[6] ), destIP, destPort); } -// -// 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; + 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_ftn/ftnoir_protocol_ftn.h b/ftnoir_protocol_ftn/ftnoir_protocol_ftn.h index acccc9e7..d5dc2cfe 100644 --- a/ftnoir_protocol_ftn/ftnoir_protocol_ftn.h +++ b/ftnoir_protocol_ftn/ftnoir_protocol_ftn.h @@ -26,8 +26,6 @@ * 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" @@ -38,23 +36,34 @@ #include #include #include "facetracknoir/global-settings.h" +#include "facetracknoir/options.h" +using namespace options; + +struct settings { + pbundle b; + value ip1, ip2, ip3, ip4, port; + settings() : + b(bundle("udp-proto")), + ip1(b, "ip1", 192), + ip2(b, "ip2", 168), + ip3(b, "ip3", 0), + ip4(b, "ip4", 2), + port(b, "port", 4242) + {} +}; class FTNoIR_Protocol : public IProtocol { public: FTNoIR_Protocol(); - virtual ~FTNoIR_Protocol(); bool checkServerInstallationOK(); void sendHeadposeToGame(const double *headpose); QString getGameName() { return "UDP Tracker"; } - private: - QUdpSocket *outSocket; // Send to FaceTrackNoIR - QHostAddress destIP; // Destination IP-address - int destPort; // Destination port-number - void loadSettings(); + QUdpSocket outSocket; + settings s; }; // Widget that has controls for FTNoIR protocol client-settings. @@ -62,40 +71,23 @@ class FTNControls: public QWidget, public IProtocolDialog { Q_OBJECT public: - - explicit FTNControls(); + FTNControls(); void registerProtocol(IProtocol *) {} void unRegisterProtocol() {} - private: Ui::UICFTNControls ui; - void loadSettings(); - void save(); - - /** helper **/ - bool settingsDirty; - + settings s; 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("UDP"); } void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("UDP"); } void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("opentrack UDP 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 72c30051..ce4b3cb0 100644 --- a/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dialog.cpp +++ b/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dialog.cpp @@ -23,44 +23,28 @@ * * ********************************************************************************/ #include "ftnoir_protocol_ftn.h" -#include #include "facetracknoir/global-settings.h" -//******************************************************************************************************* -// FaceTrackNoIR Client Settings-dialog. -//******************************************************************************************************* - -// -// Constructor for server-settings-dialog -// FTNControls::FTNControls() : -QWidget() + QWidget() { - ui.setupUi( this ); - - QPoint offsetpos(100, 100); - //if (parent) { - // this->move(parent->pos() + offsetpos); - //} + 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.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())); + tie_setting(s.ip1, ui.spinIPFirstNibble); + tie_setting(s.ip2, ui.spinIPSecondNibble); + tie_setting(s.ip3, ui.spinIPThirdNibble); + tie_setting(s.ip4, ui.spinIPFourthNibble); + tie_setting(s.port, ui.spinPortNumber); - // 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())); } // // OK clicked on server-dialog // void FTNControls::doOK() { - save(); + s.b->save(); this->close(); } @@ -68,27 +52,19 @@ void FTNControls::doOK() { // 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; - + 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: - 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; } } @@ -97,59 +73,6 @@ void FTNControls::doCancel() { } } -// -// 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 acd3b990..99689432 100644 --- a/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dll.cpp +++ b/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dll.cpp @@ -23,26 +23,8 @@ * * ********************************************************************************/ #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; -- cgit v1.2.3 From 4411f8aa4508f2759c29181b668ebf949dc3bc8c Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 31 Dec 2013 13:06:30 +0100 Subject: udp: use settings framework --- ftnoir_tracker_udp/ftnoir_tracker_udp.cpp | 119 +++-------------------- ftnoir_tracker_udp/ftnoir_tracker_udp.h | 58 +++++------ ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp | 105 +++----------------- ftnoir_tracker_udp/ftnoir_tracker_udp_dll.cpp | 21 ---- 4 files changed, 52 insertions(+), 251 deletions(-) diff --git a/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp b/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp index e70bfdc7..02ae21f0 100644 --- a/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp +++ b/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp @@ -25,18 +25,8 @@ #include "ftnoir_tracker_udp.h" #include "facetracknoir/global-settings.h" -FTNoIR_Tracker::FTNoIR_Tracker() +FTNoIR_Tracker::FTNoIR_Tracker() : should_quit(false) { - 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++) @@ -47,127 +37,46 @@ FTNoIR_Tracker::~FTNoIR_Tracker() { should_quit = true; wait(); - 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()) { - + while (inSocket.hasPendingDatagrams()) { + QMutexLocker foo(&mutex); QByteArray datagram; - datagram.resize(inSocket->pendingDatagramSize()); - mutex.lock(); - inSocket->readDatagram( (char * ) &newHeadPose, sizeof(newHeadPose), &sender, &senderPort); - mutex.unlock(); - } - } - else { - break; - } - + datagram.resize(sizeof(newHeadPose)); + inSocket.readDatagram((char * ) newHeadPose, sizeof(double[6])); + } usleep(10000); } } void FTNoIR_Tracker::StartTracker(QFrame*) { - 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; - } - } + (void) inSocket.bind(QHostAddress::Any, (int) s.port, QUdpSocket::ShareAddress | QUdpSocket::ReuseAddressHint); start(); - return; } void FTNoIR_Tracker::GetHeadPoseData(double *data) { - mutex.lock(); - if (bEnableX) { + QMutexLocker foo(&mutex); + if (s.enable_x) data[TX] = newHeadPose[TX]; - } - if (bEnableX) { + if (s.enable_y) data[TY] = newHeadPose[TY]; - } - if (bEnableX) { + if (s.enable_z) data[TZ] = newHeadPose[TZ]; - } - if (bEnableYaw) { + if (s.enable_yaw) data[Yaw] = newHeadPose[Yaw]; - } - if (bEnablePitch) { + if (s.enable_pitch) data[Pitch] = newHeadPose[Pitch]; - } - if (bEnableRoll) { + if (s.enable_roll) data[Roll] = newHeadPose[Roll]; - } - mutex.unlock(); } -// -// 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 7157f064..140a935d 100644 --- a/ftnoir_tracker_udp/ftnoir_tracker_udp.h +++ b/ftnoir_tracker_udp/ftnoir_tracker_udp.h @@ -8,37 +8,43 @@ #include #include #include "facetracknoir/global-settings.h" +#include "facetracknoir/options.h" +using namespace options; + +struct settings { + pbundle b; + value port; + value enable_roll, enable_pitch, enable_yaw, + enable_x, enable_y, enable_z; + settings() : + b(bundle("udp-tracker")), + port(b, "port", 4242), + enable_roll(b, "enable-roll", true), + enable_pitch(b, "enable-pitch", true), + enable_yaw(b, "enable-yaw", true), + enable_x(b, "enable-x", true), + enable_y(b, "enable-y", true), + enable_z(b, "enable-y", true) + {} +}; class FTNoIR_Tracker : public ITracker, public QThread { public: FTNoIR_Tracker(); - ~FTNoIR_Tracker(); - + ~FTNoIR_Tracker(); void StartTracker(QFrame *); void GetHeadPoseData(double *data); - void loadSettings(); volatile bool should_quit; 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; + QUdpSocket inSocket; + QHostAddress destIP; + QHostAddress srcIP; + double newHeadPose[6]; QMutex mutex; + settings s; }; // Widget that has controls for FTNoIR protocol client-settings. @@ -48,23 +54,14 @@ class TrackerControls: public QWidget, public ITrackerDialog public: explicit TrackerControls(); - ~TrackerControls(); void registerTracker(ITracker *) {} void unRegisterTracker() {} - private: Ui::UICFTNClientControls ui; - void loadSettings(); - void save(); - - /** helper **/ - bool settingsDirty; - + settings s; private slots: void doOK(); void doCancel(); - void settingChanged() { settingsDirty = true; }; - void settingChanged(int) { settingsDirty = true; }; }; //******************************************************************************************************* @@ -73,9 +70,6 @@ private slots: class FTNoIR_TrackerDll : public Metadata { public: - FTNoIR_TrackerDll(); - ~FTNoIR_TrackerDll(); - void getFullName(QString *strToBeFilled); void getShortName(QString *strToBeFilled); void getDescription(QString *strToBeFilled); diff --git a/ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp b/ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp index 707abf37..59026288 100644 --- a/ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp +++ b/ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp @@ -25,61 +25,38 @@ #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"; + tie_setting(s.enable_x, ui.chkEnableX); + tie_setting(s.enable_y, ui.chkEnableY); + tie_setting(s.enable_z, ui.chkEnableZ); + tie_setting(s.enable_yaw, ui.chkEnableYaw); + tie_setting(s.enable_pitch, ui.chkEnablePitch); + tie_setting(s.enable_roll, ui.chkEnableRoll); + tie_setting(s.port, ui.spinPortNumber); } void TrackerControls::doOK() { - save(); + s.b->save(); this->close(); } 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; - + 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: - save(); + s.b->save(); this->close(); break; case QMessageBox::Discard: + s.b->revert(); this->close(); break; case QMessageBox::Cancel: @@ -95,64 +72,6 @@ void TrackerControls::doCancel() { } } - -// -// 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 7d7b7c81..6732b599 100644 --- a/ftnoir_tracker_udp/ftnoir_tracker_udp_dll.cpp +++ b/ftnoir_tracker_udp/ftnoir_tracker_udp_dll.cpp @@ -26,18 +26,6 @@ #include #include "facetracknoir/global-settings.h" -FTNoIR_TrackerDll::FTNoIR_TrackerDll() { - //populate the description strings - trackerFullName = "UDP"; - trackerShortName = "UDP"; - trackerDescription = "opentrack UDP client"; -} - -FTNoIR_TrackerDll::~FTNoIR_TrackerDll() -{ - -} - void FTNoIR_TrackerDll::getFullName(QString *strToBeFilled) { *strToBeFilled = trackerFullName; @@ -58,15 +46,6 @@ 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; -- 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(+) 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 5ec8d2bb1b36510988b112cf1b830208ce6910a1 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 31 Dec 2013 13:51:55 +0100 Subject: fsuipc: decruft, use settings framework --- ftnoir_protocol_fsuipc/ftnoir_fsuipccontrols.ui | 277 +++++++-------------- ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp | 88 ++----- ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h | 58 ++--- .../ftnoir_protocol_fsuipc_dialog.cpp | 151 ++++------- .../ftnoir_protocol_fsuipc_dll.cpp | 18 -- 5 files changed, 177 insertions(+), 415 deletions(-) diff --git a/ftnoir_protocol_fsuipc/ftnoir_fsuipccontrols.ui b/ftnoir_protocol_fsuipc/ftnoir_fsuipccontrols.ui index 9ccfa119..1ce77862 100644 --- a/ftnoir_protocol_fsuipc/ftnoir_fsuipccontrols.ui +++ b/ftnoir_protocol_fsuipc/ftnoir_fsuipccontrols.ui @@ -9,8 +9,8 @@ 0 0 - 541 - 139 + 512 + 100 @@ -26,198 +26,101 @@ false - - - - - - - - 0 - 0 - - - - Location of FSUIPC.dll: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - false - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - + + + + + + 0 + 0 + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + Cancel + + - - - - - - - 230 - 0 - - - - Location of FSUIPC.dll - - - QFrame::Box - - - QFrame::Sunken - - - 1 - - - Location of FSUIPC.dll - - - - - - - - 35 - 16777215 - - - - ... - - - - + + + + + 230 + 0 + + + + Location of FSUIPC.dll + + + QFrame::Box + + + QFrame::Sunken + + + 1 + + + Location of FSUIPC.dll + + + + + + + The DLL should be located in the Modules/ directory of MS FS 2004 + + - - - - Qt::Vertical + + + + + 0 + 0 + - + - 20 - 40 + 100 + 0 - - - - - - - - The DLL should be placed in the Modules folder of MS Flight Simulator - - - - + + + 100 + 16777215 + + + + OK + + - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - QLayout::SetDefaultConstraint - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - OK - - - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - Cancel - - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 10 - 20 - - - - - + + + + + 35 + 16777215 + + + + ... + + diff --git a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp index 986ccc65..7ca990af 100644 --- a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp +++ b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp @@ -30,32 +30,22 @@ /** 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; + prevPosX = 0.0; + prevPosY = 0.0; + prevPosZ = 0.0; + prevRotX = 0.0; + prevRotY = 0.0; + prevRotZ = 0.0; } -/** destructor **/ FTNoIR_Protocol::~FTNoIR_Protocol() { - // - // Free the DLL - // - FSUIPCLib.unload(); + 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; + double y; + double local_x; local_x = x; if (local_x > max_x) { @@ -69,40 +59,20 @@ double local_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(const double *headpose ) { -DWORD result; -TFSState pitch; -TFSState yaw; -TFSState roll; -WORD FSZoom; + DWORD result; + TFSState pitch; + TFSState yaw; + TFSState roll; + WORD FSZoom; -float virtPosX; -float virtPosY; -float virtPosZ; + float virtPosX; + float virtPosY; + float virtPosZ; -float virtRotX; -float virtRotY; -float virtRotZ; - -// qDebug() << "FSUIPCServer::run() says: started!"; + float virtRotX; + float virtRotY; + float virtRotZ; virtRotX = -headpose[Pitch]; // degrees virtRotY = headpose[Yaw]; @@ -112,17 +82,11 @@ float virtRotZ; 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) || + if ((prevPosX != virtPosX) || (prevPosY != virtPosY) || (prevPosZ != virtPosZ) || (prevRotX != virtRotX) || (prevRotY != virtRotY) || (prevRotZ != virtRotZ)) { // // Open the connection @@ -178,7 +142,7 @@ bool FTNoIR_Protocol::checkServerInstallationOK() // // Load the DLL. // - FSUIPCLib.setFileName( LocationOfDLL ); + FSUIPCLib.setFileName( s.LocationOfDLL ); if (FSUIPCLib.load() != true) { qDebug() << "checkServerInstallationOK says: Error loading FSUIPC DLL"; return false; @@ -190,14 +154,6 @@ 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 FTNoIR_Protocol* CALLING_CONVENTION GetConstructor(void) { diff --git a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h index 9f5e3b6f..a099df36 100644 --- a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h +++ b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h @@ -41,12 +41,20 @@ #include #include #include +#include "facetracknoir/options.h" +using namespace options; #define FSUIPC_FILENAME "C:\\Program Files\\Microsoft Games\\Flight Simulator 9\\Modules\\FSUIPC.dll" -// -// Define the structures necessary for the FSUIPC_Write calls -// +struct settings { + pbundle b; + value LocationOfDLL; + settings() : + b(bundle("proto-fsuipc")), + LocationOfDLL(b, "dll-location", FSUIPC_FILENAME) + {} +}; + #pragma pack(push,1) // All fields in structure must be byte aligned. typedef struct { @@ -59,50 +67,32 @@ class FTNoIR_Protocol : public IProtocol { public: FTNoIR_Protocol(); - virtual ~FTNoIR_Protocol(); + virtual ~FTNoIR_Protocol() virt_override; bool checkServerInstallationOK(); void sendHeadposeToGame(const double* headpose); QString getGameName() { return "Microsoft Flight Simulator X"; } private: - // Private properties - QString ProgramName; QLibrary FSUIPCLib; - QString LocationOfDLL; - float prevPosX, prevPosY, prevPosZ, prevRotX, prevRotY, prevRotZ; - + double prevPosX, prevPosY, prevPosZ, prevRotX, prevRotY, prevRotZ; + settings s; 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(); - void registerProtocol(IProtocol *protocol) { - theProtocol = (FTNoIR_Protocol *) protocol; // Accept the pointer to the Protocol - } - void unRegisterProtocol() { - theProtocol = NULL; // Reset the pointer - } - + FSUIPCControls(); + void registerProtocol(IProtocol *protocol) {} + void unRegisterProtocol() {} private: Ui::UICFSUIPCControls ui; - void loadSettings(); - void save(); - - /** helper **/ - bool settingsDirty; - FTNoIR_Protocol *theProtocol; - + settings s; private slots: void doOK(); void doCancel(); - void settingChanged() { settingsDirty = true; }; void getLocationOfDLL(); }; @@ -112,14 +102,10 @@ private slots: 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"); }; + 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"); } }; diff --git a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dialog.cpp b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dialog.cpp index b2f28ba1..9ef4ad67 100644 --- a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dialog.cpp +++ b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dialog.cpp @@ -25,131 +25,66 @@ #include "ftnoir_protocol_fsuipc.h" #include "facetracknoir/global-settings.h" -//******************************************************************************************************* -// FaceTrackNoIR Client Settings-dialog. -//******************************************************************************************************* - -// -// Constructor for server-settings-dialog -// FSUIPCControls::FSUIPCControls() : -QWidget() + 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())); + ui.setupUi( this ); - theProtocol = NULL; + // 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())); - // Load the settings from the current .INI-file - loadSettings(); + tie_setting(s.LocationOfDLL, ui.txtLocationOfDLL); } void FSUIPCControls::doOK() { - save(); - this->close(); + s.b->save(); + this->close(); } 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; + // + // 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, 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(); + } } -// -// 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; - } + // + // 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()) { + s.LocationOfDLL = fileName; + } } - -//////////////////////////////////////////////////////////////////////////////// -// 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 b0ca2eee..57b174c5 100644 --- a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dll.cpp +++ b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dll.cpp @@ -23,26 +23,8 @@ * * ********************************************************************************/ #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; -- cgit v1.2.3 From c750ecd74d9e356b762c9b81b5c105f1ec3f997a Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 31 Dec 2013 15:12:25 +0100 Subject: cmake: how did this ever get here? --- CMakeLists.txt | 6 ------ 1 file changed, 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2033a597..d7495ab2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -264,12 +264,6 @@ if(QT_USE_FILE) INCLUDE(${QT_USE_FILE}) endif() -if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) - SET (CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS_INIT} -rdynamic CACHE STRING "Flags used by the linker during the creation of dll's.") - SET (CMAKE_MODULE_LINKER_FLAGS ${CMAKE_MODULE_LINKER_FLAGS_INIT} -rdynamic CACHE STRING "Flags used by the linker during the creation of modules.") - 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 AND NOT APPLE) target_link_libraries(opentrack-compat rt) -- cgit v1.2.3 From d74a275e6f81d17911972c0c627fb56479e272a1 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 31 Dec 2013 15:12:43 +0100 Subject: cmake: add missing version script; fix lto build --- CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index d7495ab2..93649fa7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -374,6 +374,10 @@ if(WIN32) add_library(opentrack-proto-freetrack SHARED ${opentrack-proto-freetrack-c} ${opentrack-proto-freetrack-uih} ${opentrack-proto-freetrack-rcc}) target_link_libraries(opentrack-proto-freetrack opentrack-csv ${MY_QT_LIBS} opentrack-compat) + if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) + SET_TARGET_PROPERTIES(opentrack-proto-freetrack + PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt") + endif() add_library(opentrack-proto-win32-mouse SHARED ${opentrack-proto-win32-mouse-c} ${opentrack-proto-win32-mouse-uih} ${opentrack-proto-win32-mouse-rcc}) target_link_libraries(opentrack-proto-win32-mouse ${MY_QT_LIBS}) -- cgit v1.2.3 From 4b5bd9d5e8f2b239da4979e33f42a4ca5f5498db Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 31 Dec 2013 15:52:21 +0100 Subject: cmake: cleanup copypasta --- CMakeLists.txt | 298 +++++++++++++++++---------------------------------------- 1 file changed, 90 insertions(+), 208 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 93649fa7..a88e6995 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,8 @@ project(opentrack) cmake_minimum_required(VERSION 2.8) +include(CMakeParseArguments) + set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${CMAKE_SOURCE_DIR}/cmake/") include(GetGitRevisionDescription) find_package(Git QUIET) @@ -41,7 +43,6 @@ SET(CMAKE_SKIP_RPATH FALSE) SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}") set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTOMOC_RELAXED_MODE ON) set(CMAKE_POSITION_INDEPENDENT_CODE ON) add_definitions(-DOPENTRACK_API -DIN_OPENTRACK) @@ -189,6 +190,21 @@ macro(opentrack_module n dir) QT5_ADD_RESOURCES(${n}-rcc ${${n}-rc}) endmacro() +macro(opentrack_library n) + cmake_parse_arguments(lib- "" "LINK COMPILE" "" ${ARGN}) + add_library(${n} SHARED ${${n}-c} ${${n}-uih} ${${n}-rcc}) + target_link_libraries(${n} ${MY_QT_LIBS}) + if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) + SET_TARGET_PROPERTIES(${n} PROPERTIES + LINK_FLAGS "${lib-LINK} -Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt" + COMPILE_FLAGS "${lib-COMPILE}" + ) + else() + set_target_properties(${n} PROPERTIES LINK_FLAGS "${lib-LINK}" COMPILE_FLAGS "${lib-COMPILE}") + endif() + install(TARGETS ${n} RUNTIME DESTINATION . LIBRARY DESTINATION .) +endmacro() + file(GLOB opentrack-lib-c "opentrack-api/*.cpp" "facetracknoir/global-settings.cpp" "opentrack-api/*.h" "facetracknoir/global-settings.h") opentrack_module(opentrack-bin facetracknoir) @@ -208,7 +224,9 @@ opentrack_module(opentrack-proto-fsuipc ftnoir_protocol_fsuipc) opentrack_module(opentrack-proto-freetrack ftnoir_protocol_ft) opentrack_module(opentrack-proto-udp ftnoir_protocol_ftn) opentrack_module(opentrack-proto-wine ftnoir_protocol_wine) -opentrack_module(opentrack-proto-win32-mouse ftnoir_protocol_mouse) +if(WIN32) + opentrack_module(opentrack-proto-win32-mouse ftnoir_protocol_mouse) +endif() opentrack_module(opentrack-proto-simconnect ftnoir_protocol_sc) opentrack_module(opentrack-proto-vjoy ftnoir_protocol_vjoy) opentrack_module(opentrack-proto-libevdev ftnoir_protocol_libevdev) @@ -299,117 +317,65 @@ target_link_libraries(opentrack-pose-widget ${MY_QT_LIBS}) add_library(opentrack-spline-widget SHARED ${opentrack-spline-widget-c}) target_link_libraries(opentrack-spline-widget ${MY_QT_LIBS}) -add_library(opentrack-filter-accela SHARED ${opentrack-filter-accela-c} ${opentrack-filter-accela-uih} ${opentrack-filter-accela-rcc}) -target_link_libraries(opentrack-filter-accela ${MY_QT_LIBS}) - -add_library(opentrack-filter-kalman SHARED ${opentrack-filter-kalman-c} ${opentrack-filter-kalman-uih} ${opentrack-filter-kalman-rcc}) -target_link_libraries(opentrack-filter-kalman ${MY_QT_LIBS} ${OpenCV_LIBS}) - -if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) - SET_TARGET_PROPERTIES(opentrack-filter-kalman - PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt") -endif() - -if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) - SET_TARGET_PROPERTIES(opentrack-filter-accela - PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt") -endif() +opentrack_library(opentrack-filter-accela) +opentrack_library(opentrack-filter-kalman) +opentrack_library(opentrack-filter-ewma) -add_library(opentrack-filter-ewma SHARED ${opentrack-filter-ewma-uih} ${opentrack-filter-ewma-c} ${opentrack-filter-ewma-rcc}) -target_link_libraries(opentrack-filter-ewma ${MY_QT_LIBS}) +target_link_libraries(opentrack-filter-kalman ${OpenCV_LIBS}) -if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) - SET_TARGET_PROPERTIES(opentrack-filter-ewma - PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt") -endif() - -add_library(opentrack-proto-fgfs SHARED ${opentrack-proto-fgfs-c} ${opentrack-proto-fgfs-uih} ${opentrack-proto-fgfs-rcc}) -target_link_libraries(opentrack-proto-fgfs ${MY_QT_LIBS}) -if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) - SET_TARGET_PROPERTIES(opentrack-proto-fgfs - PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt") -endif() +opentrack_library(opentrack-proto-fgfs) -if(WIN32 AND SDK_VJOY) +if(SDK_VJOY) include_directories(${SDK_VJOY}) - add_library(opentrack-proto-vjoy SHARED ${opentrack-proto-vjoy-c} ${opentrack-proto-vjoy-uih} ${opentrack-proto-vjoy-rcc}) + opentrack_library(opentrack-proto-vjoy) if(MSVC) target_link_libraries(opentrack-proto-vjoy ${MY_QT_LIBS} "${SDK_VJOY}/VJoy.lib") else() target_link_libraries(opentrack-proto-vjoy ${MY_QT_LIBS} "${SDK_VJOY}/VJoy.dll") endif() - if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) - SET_TARGET_PROPERTIES(opentrack-proto-vjoy - PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt -Wl,--enable-stdcall-fixup") - endif() endif() -if(UNIX AND SDK_ENABLE_LIBEVDEV) - add_library(opentrack-proto-libevdev SHARED ${opentrack-proto-libevdev-c} ${opentrack-proto-libevdev-uih} ${opentrack-proto-libevdev-rcc}) - target_link_libraries(opentrack-proto-libevdev ${MY_QT_LIBS} evdev) - if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) - SET_TARGET_PROPERTIES(opentrack-proto-libevdev - PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt") - endif() - install(TARGETS opentrack-proto-libevdev RUNTIME DESTINATION . LIBRARY DESTINATION . ) +if(SDK_ENABLE_LIBEVDEV) + opentrack_library(opentrack-proto-libevdev) + target_link_libraries(opentrack-proto-libevdev evdev) endif() -if(WIN32) - if(SDK_FSUIPC) - add_library(opentrack-proto-fsuipc SHARED ${opentrack-proto-fsuipc-c} ${opentrack-proto-fsuipc-uih} ${opentrack-proto-fsuipc-rcc}) - target_link_libraries(opentrack-proto-fsuipc ${MY_QT_LIBS} "${SDK_FSUIPC}/FSUIPC_User.lib") - if(MSVC) - set_target_properties(opentrack-proto-fsuipc PROPERTIES LINK_FLAGS "/NODEFAULTLIB:libc") - else() - set_target_properties(opentrack-proto-fsuipc PROPERTIES LINK_FLAGS "-Wl,--exclude-all-symbols") - endif() +if(SDK_FSUIPC) + if(MSVC) + set(link-flags "/NODEFAULTLIB:libc") endif() + opentrack_library(opentrack-proto-fsuipc LINK "${link-flags}") + target_link_libraries(opentrack-proto-fsuipc "${SDK_FSUIPC}/FSUIPC_User.lib") +endif() - if(SDK_SIMCONNECT) - add_library(opentrack-proto-simconnect SHARED ${opentrack-proto-simconnect-c} ${opentrack-proto-simconnect-uih} ${opentrack-proto-simconnect-rcc}) - target_link_libraries(opentrack-proto-simconnect ${MY_QT_LIBS}) - include_directories("${SDK_SIMCONNECT}/inc") - target_link_libraries(opentrack-proto-simconnect "${SDK_SIMCONNECT}/lib/SimConnect.lib") - endif() +if(SDK_SIMCONNECT) + opentrack_library(opentrack-proto-simconnect) + include_directories("${SDK_SIMCONNECT}/inc") + target_link_libraries(opentrack-proto-simconnect "${SDK_SIMCONNECT}/lib/SimConnect.lib") +endif() - add_library(opentrack-proto-freetrack SHARED ${opentrack-proto-freetrack-c} ${opentrack-proto-freetrack-uih} ${opentrack-proto-freetrack-rcc}) - target_link_libraries(opentrack-proto-freetrack opentrack-csv ${MY_QT_LIBS} opentrack-compat) - if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) - SET_TARGET_PROPERTIES(opentrack-proto-freetrack - PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt") - endif() +if(WIN32) + opentrack_library(opentrack-proto-freetrack) + target_link_libraries(opentrack-proto-freetrack opentrack-csv opentrack-compat) +endif() - add_library(opentrack-proto-win32-mouse SHARED ${opentrack-proto-win32-mouse-c} ${opentrack-proto-win32-mouse-uih} ${opentrack-proto-win32-mouse-rcc}) - target_link_libraries(opentrack-proto-win32-mouse ${MY_QT_LIBS}) +opentrack_library(opentrack-proto-win32-mouse) + +if(WIN32) add_library(freetrackclient SHARED ${opentrack-freetrack-c}) if(CMAKE_COMPILER_IS_GNUCC) set_target_properties(freetrackclient PROPERTIES LINK_FLAGS "-Wl,--enable-stdcall-fixup -fno-lto -Wl,-kill-at" PREFIX "" COMPILE_FLAGS "-fno-lto") endif() endif() -add_library(opentrack-proto-udp SHARED ${opentrack-proto-udp-c} ${opentrack-proto-udp-uih} ${opentrack-proto-udp-rcc}) -target_link_libraries(opentrack-proto-udp ${MY_QT_LIBS}) -if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) - SET_TARGET_PROPERTIES(opentrack-proto-udp - PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt") -endif() +opentrack_library(opentrack-proto-udp) if(WIN32) - add_library(opentrack-tracker-joystick SHARED ${opentrack-tracker-joystick-c} ${opentrack-tracker-joystick-uih} ${opentrack-tracker-joystick-rcc}) - target_link_libraries(opentrack-tracker-joystick ${MY_QT_LIBS}) - if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) - SET_TARGET_PROPERTIES(opentrack-tracker-joystick - PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt") - endif() + opentrack_library(opentrack-tracker-joystick) endif() -if(NOT WIN32 AND SDK_WINE_PREFIX) - add_library(opentrack-proto-wine SHARED ${opentrack-proto-wine-c} ${opentrack-proto-wine-uih} ${opentrack-proto-wine-rcc}) - target_link_libraries(opentrack-proto-wine ${MY_QT_LIBS} opentrack-compat opentrack-csv) - if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) - SET_TARGET_PROPERTIES(opentrack-proto-wine - PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt") - endif() +if(SDK_WINE_PREFIX) + opentrack_library(opentrack-proto-wine) if(NOT SDK_WINE_NO_WRAPPER) set(my-rt -lrt) if(APPLE) @@ -431,26 +397,13 @@ if(NOT WIN32 AND SDK_WINE_PREFIX) endif() endif() -if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) - SET_TARGET_PROPERTIES(opentrack-proto-fgfs - PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt") -endif() - -add_library(opentrack-tracker-ht SHARED ${opentrack-tracker-ht-c} ${opentrack-tracker-ht-uih} ${opentrack-tracker-ht-rcc}) -target_link_libraries(opentrack-tracker-ht ${MY_QT_LIBS} opentrack-compat) -if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) - SET_TARGET_PROPERTIES(opentrack-tracker-ht - PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt") -endif() +opentrack_library(opentrack-tracker-ht) +target_link_libraries(opentrack-tracker-ht opentrack-compat) if(SDK_ARUCO_LIBPATH) include_directories(${CMAKE_SOURCE_DIR}/ftnoir_tracker_aruco/include) - add_library(opentrack-tracker-aruco SHARED ${opentrack-tracker-aruco-c} ${opentrack-tracker-aruco-uih} ${opentrack-tracker-aruco-rcc}) - target_link_libraries(opentrack-tracker-aruco ${MY_QT_LIBS} ${SDK_ARUCO_LIBPATH} ${OpenCV_LIBS}) - if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) - SET_TARGET_PROPERTIES(opentrack-tracker-aruco - PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt") - endif() + opentrack_library(opentrack-tracker-aruco) + target_link_libraries(opentrack-tracker-aruco ${SDK_ARUCO_LIBPATH} ${OpenCV_LIBS}) if(WIN32 AND MSVC) target_link_libraries(opentrack-tracker-aruco "${CMAKE_SOURCE_DIR}/dinput/dxguid.lib" @@ -459,15 +412,7 @@ if(SDK_ARUCO_LIBPATH) endif() endif() -if(SDK_HATIRE) - add_library(opentrack-tracker-hatire SHARED ${opentrack-tracker-hatire-c} ${opentrack-tracker-hatire-uih} ${opentrack-tracker-hatire-rcc}) - target_link_libraries(opentrack-tracker-hatire ${MY_QT_LIBS}) - install(TARGETS opentrack-tracker-hatire RUNTIME DESTINATION . LIBRARY DESTINATION . ) - if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) - SET_TARGET_PROPERTIES(opentrack-tracker-hatire - PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt") - endif() -endif() +opentrack_library(opentrack-tracker-hatire) if(WIN32) target_link_libraries(opentrack-tracker-ht @@ -481,18 +426,8 @@ if(WIN32) uuid) endif() -add_library(opentrack-tracker-pt SHARED ${opentrack-tracker-pt-c} ${opentrack-tracker-pt-uih} ${opentrack-tracker-pt-rcc}) -target_link_libraries(opentrack-tracker-pt ${MY_QT_LIBS} ${OpenCV_LIBS}) - -if(APPLE) - SET_TARGET_PROPERTIES(opentrack-tracker-pt PROPERTIES COMPILE_FLAGS "-std=c++11") -endif() - -if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) - SET_TARGET_PROPERTIES(opentrack-tracker-pt - PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt") -endif() - +opentrack_library(opentrack-tracker-pt) +target_link_libraries(opentrack-tracker-pt ${OpenCV_LIBS}) if(WIN32) target_link_libraries(opentrack-tracker-pt @@ -501,50 +436,44 @@ if(WIN32) uuid) endif() -add_library(opentrack-tracker-udp SHARED ${opentrack-tracker-udp-c} ${opentrack-tracker-udp-uih} ${opentrack-tracker-udp-rcc}) -target_link_libraries(opentrack-tracker-udp ${MY_QT_LIBS}) -if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) - SET_TARGET_PROPERTIES(opentrack-tracker-udp - PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt") -endif() +opentrack_library(opentrack-tracker-udp) if(SDK_RIFT) include_directories("${SDK_RIFT}/Include") include_directories("${SDK_RIFT}/Src") - add_library(opentrack-tracker-rift SHARED ${opentrack-tracker-rift-c} ${opentrack-tracker-rift-uih} ${opentrack-tracker-rift-rcc}) - target_link_libraries(opentrack-tracker-rift ${MY_QT_LIBS}) - if(MSVC) - target_link_libraries(opentrack-tracker-rift "${SDK_RIFT}/Lib/Win32/libovr.lib" winmm.lib setupapi.lib) - set_target_properties(opentrack-tracker-rift PROPERTIES LINK_FLAGS "/NODEFAULTLIB:LIBCMT") + set(link-flags) + if(APPLE) + set(link-flags "-framework CoreFoundation -framework CoreGraphics -framework IOKit -framework Quartz") + else() + if(MSVC) + set(link-flags "/NODEFAULTLIB:LIBCMT") + endif() + endif() + if(NOT MSVC) + set(c-flags -fno-strict-aliasing) + else() + set(c-flags) + endif() + opentrack_library(opentrack-tracker-rift LINK "${link-flags}" COMPILE "${c-flags}") + if(MSVC) + target_link_libraries(opentrack-tracker-rift "${SDK_RIFT}/Lib/Win32/libovr.lib" winmm.lib setupapi.lib) + else() + if(WIN32) + target_link_libraries(opentrack-tracker-rift "${SDK_RIFT}/libLibOVR.a" winmm setupapi) + else() + if(NOT APPLE) + target_link_libraries(opentrack-tracker-rift "${SDK_RIFT}/libLibOVR.a" udev Xinerama) else() - if(WIN32) - target_link_libraries(opentrack-tracker-rift "${SDK_RIFT}/libLibOVR.a" winmm.lib setupapi.lib) - else() - if(NOT APPLE) - target_link_libraries(opentrack-tracker-rift "${SDK_RIFT}/libLibOVR.a" udev Xinerama) - else() - target_link_libraries(opentrack-tracker-rift "${SDK_RIFT}/libLibOVR.a") - endif() - endif() + target_link_libraries(opentrack-tracker-rift "${SDK_RIFT}/libLibOVR.a") endif() - if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) - SET_TARGET_PROPERTIES(opentrack-tracker-rift - PROPERTIES - LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt" - 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() +endif() if(SDK_HYDRA) include_directories("${SDK_HYDRA}/include") include_directories("${SDK_HYDRA}/include/sixense_utils") - add_library(opentrack-tracker-hydra SHARED ${opentrack-tracker-hydra-c} ${opentrack-tracker-hydra-uih} ${opentrack-tracker-hydra-rcc}) - target_link_libraries(opentrack-tracker-hydra ${MY_QT_LIBS}) + opentrack_library(opentrack-tracker-hydra) if(WIN32) target_link_libraries(opentrack-tracker-hydra "${SDK_HYDRA}/lib/win32/release_dll/sixense.lib" @@ -572,10 +501,6 @@ if(SDK_HYDRA) ) target_link_libraries(opentrack-tracker-hydra "${SDK_HYDRA}/lib/${sixense-plat}${underscore-sixtyfour}/release${underscore-dll}/libsixense${underscore-sixtyfour}.${soext}" "${SDK_HYDRA}/lib/${sixense-plat}${underscore-sixtyfour}/release${underscore-dll}/libsixense_utils${underscore-sixtyfour}.${soext}") endif() - if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) - SET_TARGET_PROPERTIES(opentrack-tracker-hydra - PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt") - endif() endif() if(WIN32 AND NOT SDK_CONSOLE_DEBUG) @@ -655,11 +580,13 @@ install(FILES "${CMAKE_SOURCE_DIR}/README.md" DESTINATION .) if(SDK_XPLANE) install(TARGETS opentrack-xplane-plugin RUNTIME DESTINATION . LIBRARY DESTINATION . ) endif() + if(WIN32) install(DIRECTORY "${CMAKE_SOURCE_DIR}/bin/tracker-ht" DESTINATION .) install(TARGETS freetrackclient RUNTIME DESTINATION . LIBRARY DESTINATION . ) endif() - install(DIRECTORY "${CMAKE_SOURCE_DIR}/3rdparty-notices" DESTINATION .) + +install(DIRECTORY "${CMAKE_SOURCE_DIR}/3rdparty-notices" DESTINATION .) install(FILES "${CMAKE_SOURCE_DIR}/bin/NPClient.dll" "${CMAKE_SOURCE_DIR}/bin/NPClient64.dll" "${CMAKE_SOURCE_DIR}/bin/TrackIR.exe" DESTINATION .) install(DIRECTORY "${CMAKE_SOURCE_DIR}/bin/settings" "${CMAKE_SOURCE_DIR}/facetracknoir/clientfiles" DESTINATION .) @@ -667,69 +594,24 @@ install(DIRECTORY "${CMAKE_SOURCE_DIR}/bin/settings" "${CMAKE_SOURCE_DIR}/facetr if(NOT WIN32 AND SDK_WINE_PREFIX) install(FILES "${CMAKE_BINARY_DIR}/opentrack-wrapper-wine.exe.so" DESTINATION .) - install(TARGETS opentrack-proto-wine RUNTIME DESTINATION . LIBRARY DESTINATION . ) -endif() - -install(TARGETS opentrack-tracker-pt RUNTIME DESTINATION . LIBRARY DESTINATION . ) - -if(SDK_ARUCO_LIBPATH) - install(TARGETS opentrack-tracker-aruco RUNTIME DESTINATION . LIBRARY DESTINATION . ) endif() install(TARGETS - opentrack-proto-fgfs - opentrack-proto-udp opentrack-api opentrack-compat opentrack-csv opentrack-pose-widget opentrack-spline-widget - opentrack-filter-accela - opentrack-filter-kalman - opentrack-filter-ewma - opentrack-tracker-ht - opentrack-tracker-udp RUNTIME DESTINATION . LIBRARY DESTINATION . ) -install(TARGETS - opentrack - DESTINATION . -) +install(TARGETS opentrack DESTINATION .) -if(WIN32) - install(TARGETS opentrack-tracker-joystick RUNTIME DESTINATION . LIBRARY DESTINATION . ) -endif() - -if(WIN32 AND SDK_VJOY) - install(TARGETS opentrack-proto-vjoy RUNTIME DESTINATION . LIBRARY DESTINATION . ) +if(SDK_VJOY) install(FILES "${SDK_VJOY}/VJoy.dll" DESTINATION .) endif() -if(SDK_RIFT) - install(TARGETS opentrack-tracker-rift RUNTIME DESTINATION . LIBRARY DESTINATION . ) -endif() - -if(SDK_HYDRA) - install( - TARGETS opentrack-tracker-hydra - RUNTIME DESTINATION . LIBRARY DESTINATION . - ) -endif() - if(WIN32) install(FILES "${CMAKE_SOURCE_DIR}/bin/cleye.config" DESTINATION .) - if(SDK_SIMCONNECT) - install(TARGETS opentrack-proto-simconnect RUNTIME DESTINATION . LIBRARY DESTINATION . ) - endif() - install(TARGETS - opentrack-proto-freetrack - opentrack-proto-win32-mouse - RUNTIME DESTINATION . LIBRARY DESTINATION . - ) - if(SDK_FSUIPC) - install(TARGETS opentrack-proto-fsuipc RUNTIME DESTINATION . LIBRARY DESTINATION .) - endif() - endif() if(MSVC) -- cgit v1.2.3 From 4abd0ca3b5090018a7db05e8c2e0f478d861d978 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 31 Dec 2013 15:52:50 +0100 Subject: ft: use settings framework --- ftnoir_protocol_ft/ftnoir_protocol_ft.cpp | 102 +++--------- ftnoir_protocol_ft/ftnoir_protocol_ft.h | 100 +++++------- ftnoir_protocol_ft/ftnoir_protocol_ft_dialog.cpp | 194 ++++++++--------------- ftnoir_protocol_ft/ftnoir_protocol_ft_dll.cpp | 18 +-- 4 files changed, 124 insertions(+), 290 deletions(-) diff --git a/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp b/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp index 84d1d20b..5c086c10 100644 --- a/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp +++ b/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp @@ -24,78 +24,30 @@ * 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; + 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(); - } - dummyTrackIR.terminate(); + if (viewsStop != NULL) { + viewsStop(); + FTIRViewsLib.unload(); + } + dummyTrackIR.terminate(); dummyTrackIR.kill(); dummyTrackIR.waitForFinished(50); - } -// -// 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", 0 ).toBool(); - iniFile.endGroup (); -} - -// -// Update Headpose in Game. -// void FTNoIR_Protocol::sendHeadposeToGame(const double* headpose) { float virtPosX; float virtPosY; @@ -112,7 +64,7 @@ void FTNoIR_Protocol::sendHeadposeToGame(const double* headpose) { float headRotX; float headRotY; float headRotZ; - headRotX = virtRotX = getRadsFromDegrees(headpose[Pitch]) * (useDummyExe ? 2.0 : 1.0); + headRotX = virtRotX = getRadsFromDegrees(headpose[Pitch]) * (s.useDummyExe ? 2.0 : 1.0); headRotY = virtRotY = getRadsFromDegrees(headpose[Yaw]); headRotZ = virtRotZ = getRadsFromDegrees(headpose[Roll]); headPosX = virtPosX = headpose[TX] * 10; @@ -149,13 +101,6 @@ void FTNoIR_Protocol::sendHeadposeToGame(const double* headpose) { 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; @@ -167,8 +112,7 @@ void FTNoIR_Protocol::sendHeadposeToGame(const double* headpose) { } pMemData->data.DataID += 1; - - shm.unlock(); + shm.unlock(); } void FTNoIR_Protocol::start_tirviews() { @@ -212,6 +156,10 @@ bool FTNoIR_Protocol::checkServerInstallationOK() QSettings settingsTIR("NaturalPoint", "NATURALPOINT\\NPClient Location"); // Registry settings (in HK_USER) QString aLocation; // Location of Client DLL + + if (!shm.success()) + return false; + qDebug() << "checkServerInstallationOK says: Starting Function"; // @@ -219,8 +167,8 @@ bool FTNoIR_Protocol::checkServerInstallationOK() // aLocation = QCoreApplication::applicationDirPath() + "/"; - qDebug() << "checkServerInstallationOK says: used interface = " << intUsedInterface; - switch (intUsedInterface) { + qDebug() << "checkServerInstallationOK says: used interface = " << s.intUsedInterface; + switch (s.intUsedInterface) { case 0: // Use both interfaces settings.setValue( "Path" , aLocation ); settingsTIR.setValue( "Path" , aLocation ); @@ -241,20 +189,17 @@ bool FTNoIR_Protocol::checkServerInstallationOK() // // TIRViews must be started first, or the NPClient DLL will never be loaded. // - if (useTIRViews) { + if (s.useTIRViews) { start_tirviews(); } // // Check if TIRViews or dummy TrackIR.exe is required for this game // - if (useDummyExe) { + if (s.useDummyExe) { start_dummy(); } - if (!shm.success()) - return false; - pMemData->data.DataID = 1; pMemData->data.CamWidth = 100; pMemData->data.CamHeight = 250; @@ -264,15 +209,6 @@ 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_ft/ftnoir_protocol_ft.h b/ftnoir_protocol_ft/ftnoir_protocol_ft.h index 56316ec4..8f27b071 100644 --- a/ftnoir_protocol_ft/ftnoir_protocol_ft.h +++ b/ftnoir_protocol_ft/ftnoir_protocol_ft.h @@ -25,9 +25,6 @@ * 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" @@ -43,7 +40,20 @@ #include #include #include "compat/compat.h" -//#include "math.h" +#include "facetracknoir/options.h" +using namespace options; + +struct settings { + pbundle b; + value intUsedInterface; + value useTIRViews, useDummyExe; + settings() : + b(bundle("proto-freetrack")), + intUsedInterface(b, "used-interfaces", 0), + useTIRViews(b, "use-memory-hacks", false), + useDummyExe(b, "ezca-mode", false) + {} +}; //typedef char *(WINAPI *importProvider)(void); typedef void (WINAPI *importTIRViewsStart)(void); @@ -52,87 +62,59 @@ typedef void (WINAPI *importTIRViewsStop)(void); class FTNoIR_Protocol : public IProtocol { public: - FTNoIR_Protocol(); + FTNoIR_Protocol(); virtual ~FTNoIR_Protocol(); - bool checkServerInstallationOK( ); + bool checkServerInstallationOK( ); void sendHeadposeToGame( const double *headpose ); QString getGameName() { QMutexLocker foo(&game_name_mutex); return connected_game; } - private: - importTIRViewsStart viewsStart; // Functions inside TIRViews.dll - importTIRViewsStop viewsStop; + importTIRViewsStart viewsStart; // Functions inside TIRViews.dll + importTIRViewsStop viewsStop; - FTMemMap *pMemData; + 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(); + // Private properties + QString ProgramName; + QLibrary FTIRViewsLib; + QProcess dummyTrackIR; + static inline double getRadsFromDegrees ( double degrees ) + { + return degrees * 0.017453; + } + int intGameID; void start_tirviews(); void start_dummy(); - QString connected_game; QMutex game_name_mutex; + settings s; }; -// Widget that has controls for FTNoIR protocol client-settings. class FTControls: public QWidget, public IProtocolDialog { Q_OBJECT public: - - explicit FTControls(); - void registerProtocol(IProtocol *protocol) { - theProtocol = (FTNoIR_Protocol *) protocol; // Accept the pointer to the Protocol - } - void unRegisterProtocol() { - theProtocol = NULL; // Reset the pointer - } - + explicit FTControls(); + void registerProtocol(IProtocol *protocol) {} + void unRegisterProtocol() {} private: - Ui::UICFTControls ui; - void loadSettings(); - void save(); - - /** helper **/ - bool settingsDirty; - FTNoIR_Protocol *theProtocol; - + Ui::UICFTControls ui; + settings s; private slots: - void selectDLL(); - void doOK(); - void doCancel(); - void settingChanged() { settingsDirty = true; } - void settingChanged(int) { settingsDirty = true; } + void selectDLL(); + void doOK(); + void doCancel(); }; -//******************************************************************************************************* -// 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"); } + 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 0b29db6e..b414561d 100644 --- a/ftnoir_protocol_ft/ftnoir_protocol_ft_dialog.cpp +++ b/ftnoir_protocol_ft/ftnoir_protocol_ft_dialog.cpp @@ -34,155 +34,87 @@ // Constructor for server-settings-dialog // FTControls::FTControls() : -QWidget() + QWidget() { - QString aFileName; // File Path and Name + QString aFileName; // File Path and Name - ui.setupUi( this ); + ui.setupUi( this ); - // Connect Qt signals to member-functions + // Connect Qt signals to member-functions connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); connect(ui.buttonBox, SIGNAL(rejected()), 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 ); - } - - + connect(ui.bntLocateNPClient, SIGNAL(clicked()), this, SLOT(selectDLL())); + + tie_setting(s.intUsedInterface, ui.cbxSelectInterface); + tie_setting(s.useDummyExe, ui.chkStartDummy); + tie_setting(s.useTIRViews, ui.chkTIRViews); + + ui.cbxSelectInterface->addItem("Enable both"); + ui.cbxSelectInterface->addItem("Use FreeTrack, hide TrackIR"); + ui.cbxSelectInterface->addItem("Use TrackIR, hide FreeTrack"); + + aFileName = QCoreApplication::applicationDirPath() + "/TIRViews.dll"; + if ( !QFile::exists( aFileName ) ) { + ui.chkTIRViews->setChecked( false ); + ui.chkTIRViews->setEnabled ( false ); + } + else { + ui.chkTIRViews->setEnabled ( true ); + } } void FTControls::doOK() { - save(); - this->close(); + s.b->save(); + this->close(); } 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", 0 ).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; + // + // 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(); + } } -// -// Select a NPClient.dll file, to repair the Location in the Registry. -// Several program distribute their own version of this file. -// void FTControls::selectDLL() { 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 ); - } - } + // + // 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 f4e4a40e..38f11211 100644 --- a/ftnoir_protocol_ft/ftnoir_protocol_ft_dll.cpp +++ b/ftnoir_protocol_ft/ftnoir_protocol_ft_dll.cpp @@ -23,24 +23,8 @@ * * ********************************************************************************/ #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 +} -- cgit v1.2.3 From 40f4c6944799bd696ccf358c5378b230ecc7f52b Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 31 Dec 2013 16:10:17 +0100 Subject: sc: settings framework --- ftnoir_protocol_sc/ftnoir_protocol_sc.cpp | 173 ++++------------------- ftnoir_protocol_sc/ftnoir_protocol_sc.h | 62 +++----- ftnoir_protocol_sc/ftnoir_protocol_sc_dialog.cpp | 96 +++---------- ftnoir_protocol_sc/ftnoir_protocol_sc_dll.cpp | 17 --- 4 files changed, 75 insertions(+), 273 deletions(-) diff --git a/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp b/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp index 8449f6ce..9fb48527 100644 --- a/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp +++ b/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp @@ -50,15 +50,12 @@ 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; @@ -69,18 +66,8 @@ FTNoIR_Protocol::~FTNoIR_Protocol() 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() { -} - -// -// Update Headpose in Game. -// void FTNoIR_Protocol::sendHeadposeToGame( const double *headpose ) { virtSCRotX = -headpose[Pitch]; // degrees virtSCRotY = -headpose[Yaw]; @@ -90,14 +77,8 @@ void FTNoIR_Protocol::sendHeadposeToGame( const double *headpose ) { 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"); @@ -105,39 +86,11 @@ void FTNoIR_Protocol::sendHeadposeToGame( const double *headpose ) { 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!"; - } - } + else + (void) (simconnect_calldispatch(hSimConnect, processNextSimconnectEvent, NULL)); } class ActivationContext { @@ -176,30 +129,16 @@ private: HANDLE hactctx; }; -// -// Returns 'true' if all seems OK. -// bool FTNoIR_Protocol::checkServerInstallationOK() { if (!SCClientLib.isLoaded()) { - qDebug() << "SCCheckClientDLL says: Starting Function"; - - QSettings settings("opentrack"); - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); - QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) - iniFile.beginGroup ( "FSX" ); - int act = iniFile.value("version", 0).toInt(); - iniFile.endGroup(); - - ActivationContext ctx(142 + act); + ActivationContext ctx(142 + static_cast(s.sxs_manifest)); if (!SCClientLib.load()) { qDebug() << "SC load" << SCClientLib.errorString(); return false; } - } else { - qDebug() << "SimConnect already loaded"; } // @@ -260,97 +199,47 @@ bool FTNoIR_Protocol::checkServerInstallationOK() 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; + default: + break; + case SIMCONNECT_RECV_ID_EVENT_FRAME: + { + if ((prevSCPosX != virtSCPosX) || (prevSCPosY != virtSCPosY) || (prevSCPosZ != virtSCPosZ) || + (prevSCRotX != virtSCRotX) || (prevSCRotY != virtSCRotY) || (prevSCRotZ != virtSCRotZ)) { + (void) simconnect_set6DOF(hSimConnect, virtSCPosX, virtSCPosY, virtSCPosZ, virtSCRotX, virtSCRotZ, virtSCRotY); } - 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; - } + 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; - case SIMCONNECT_RECV_ID_EXCEPTION: + switch (except->dwException) { - SIMCONNECT_RECV_EXCEPTION *except = (SIMCONNECT_RECV_EXCEPTION*)pData; - - switch (except->dwException) - { - case SIMCONNECT_EXCEPTION_ERROR: - printf("\nCamera error"); - break; - - default: - printf("\nException"); - break; - } + case SIMCONNECT_EXCEPTION_ERROR: + qDebug() << "Camera error"; break; - } - case SIMCONNECT_RECV_ID_QUIT: - { - qDebug() << "FTNoIR_Protocol::processNextSimconnectEvent() says: Quit event!"; -// quit = 1; + default: + qDebug() << "Exception"; break; } + break; + } - default: - break; + case SIMCONNECT_RECV_ID_QUIT: + { + 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 7917c532..a13c0097 100644 --- a/ftnoir_protocol_sc/ftnoir_protocol_sc.h +++ b/ftnoir_protocol_sc/ftnoir_protocol_sc.h @@ -27,8 +27,6 @@ * must be treated as such... * ********************************************************************************/ #pragma once -#ifndef INCLUDED_SCSERVER_H -#define INCLUDED_SCSERVER_H #undef _WIN32_WINNT #define _WIN32_WINNT 0x0502 #include "facetracknoir/global-settings.h" @@ -48,7 +46,8 @@ #include #include #include -//#include "math.h" +#include "facetracknoir/options.h" +using namespace options; typedef HRESULT (WINAPI *importSimConnect_Open)(HANDLE * phSimConnect, LPCSTR szName, HWND hWnd, DWORD UserEventWin32, HANDLE hEventHandle, DWORD ConfigIndex); typedef HRESULT (WINAPI *importSimConnect_Close)(HANDLE hSimConnect); @@ -77,6 +76,15 @@ enum INPUT_ID INPUT0=0, }; +struct settings { + pbundle b; + value sxs_manifest; + settings() : + b(bundle("proto-simconnect")), + sxs_manifest(b, "sxs-manifest-version", 0) + {} +}; + class FTNoIR_Protocol : public IProtocol { public: @@ -87,11 +95,7 @@ public: QString getGameName() { return "FS2004/FSX"; } - private: - // Private properties - QString ProgramName; - static float virtSCPosX; static float virtSCPosY; static float virtSCPosZ; @@ -121,7 +125,7 @@ private: static HANDLE hSimConnect; // Handle to SimConnect static void CALLBACK processNextSimconnectEvent(SIMCONNECT_RECV* pData, DWORD cbData, void *pContext); - void loadSettings(); + settings s; }; // Widget that has controls for FTNoIR protocol client-settings. @@ -129,28 +133,15 @@ class SCControls: public QWidget, public IProtocolDialog { Q_OBJECT public: - - explicit SCControls(); - void registerProtocol(IProtocol *protocol) { - theProtocol = (FTNoIR_Protocol *) protocol; // Accept the pointer to the Protocol - } - void unRegisterProtocol() { - theProtocol = NULL; // Reset the pointer - } - + SCControls(); + void registerProtocol(IProtocol *protocol) {} + void unRegisterProtocol() {} private: - Ui::UICSCControls ui; - void loadSettings(); - void save(); - - /** helper **/ - bool settingsDirty; - FTNoIR_Protocol *theProtocol; - + Ui::UICSCControls ui; + settings s; private slots: - void doOK(); - void doCancel(); - void settingChanged() { settingsDirty = true; }; + void doOK(); + void doCancel(); }; //******************************************************************************************************* @@ -159,15 +150,8 @@ private slots: 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"); }; + 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 eb15ca69..6af87285 100644 --- a/ftnoir_protocol_sc/ftnoir_protocol_sc_dialog.cpp +++ b/ftnoir_protocol_sc/ftnoir_protocol_sc_dialog.cpp @@ -26,13 +26,6 @@ #include #include "facetracknoir/global-settings.h" -//******************************************************************************************************* -// FaceTrackNoIR Client Settings-dialog. -//******************************************************************************************************* - -// -// Constructor for server-settings-dialog -// SCControls::SCControls() : QWidget() { @@ -41,85 +34,38 @@ QWidget() // Connect Qt signals to member-functions connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); - //connect(ui.cbxSelectPPJoyNumber, SIGNAL(currentIndexChanged(int)), this, SLOT(virtualJoystickSelected( int ))); - - theProtocol = NULL; - // Load the settings from the current .INI-file - loadSettings(); + tie_setting(s.sxs_manifest, ui.comboBox); } void SCControls::doOK() { - save(); + s.b->save(); this->close(); } 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(); - } -} + 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); -// -// Load the current Settings from the currently 'active' INI-file. -// -void SCControls::loadSettings() { - QSettings settings("opentrack"); - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); - QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) - iniFile.beginGroup ( "FSX" ); - int act = iniFile.value("version", 0).toInt(); - iniFile.endGroup(); - ui.comboBox->setCurrentIndex(act); - settingsDirty = false; + 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(); + } } -// -// Save the current Settings to the currently 'active' INI-file. -// -void SCControls::save() { - QSettings settings("opentrack"); - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString(); - QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) - iniFile.beginGroup ( "FSX" ); - iniFile.setValue("version", ui.comboBox->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 SCControls; diff --git a/ftnoir_protocol_sc/ftnoir_protocol_sc_dll.cpp b/ftnoir_protocol_sc/ftnoir_protocol_sc_dll.cpp index 59a921b8..0a52fa96 100644 --- a/ftnoir_protocol_sc/ftnoir_protocol_sc_dll.cpp +++ b/ftnoir_protocol_sc/ftnoir_protocol_sc_dll.cpp @@ -26,23 +26,6 @@ #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; -- cgit v1.2.3 From e437f501a6b7a6a9ac90eec6d91ebf022aa09ff8 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 31 Dec 2013 16:16:01 +0100 Subject: fsuipc: decruft more --- ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp | 35 +++++++++++++--------- ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h | 7 ++--- .../ftnoir_protocol_fsuipc_dialog.cpp | 9 ------ 3 files changed, 23 insertions(+), 28 deletions(-) diff --git a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp index 7ca990af..632d502a 100644 --- a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp +++ b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp @@ -30,22 +30,25 @@ /** constructor **/ FTNoIR_Protocol::FTNoIR_Protocol() { - prevPosX = 0.0; - prevPosY = 0.0; - prevPosZ = 0.0; - prevRotX = 0.0; - prevRotY = 0.0; - prevRotZ = 0.0; + prevPosX = 0.0f; + prevPosY = 0.0f; + prevPosZ = 0.0f; + prevRotX = 0.0f; + prevRotY = 0.0f; + prevRotZ = 0.0f; } FTNoIR_Protocol::~FTNoIR_Protocol() { - FSUIPCLib.unload(); + 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; +double y; +double local_x; local_x = x; if (local_x > max_x) { @@ -74,6 +77,8 @@ void FTNoIR_Protocol::sendHeadposeToGame(const double *headpose ) { float virtRotY; float virtRotZ; +// qDebug() << "FSUIPCServer::run() says: started!"; + virtRotX = -headpose[Pitch]; // degrees virtRotY = headpose[Yaw]; virtRotZ = headpose[Roll]; @@ -82,11 +87,17 @@ void FTNoIR_Protocol::sendHeadposeToGame(const double *headpose ) { virtPosY = 0.0f; virtPosZ = headpose[TZ]; + // + // Init. the FSUIPC offsets (derived from Free-track...) + // pitch.Control = 66503; yaw.Control = 66504; roll.Control = 66505; - if ((prevPosX != virtPosX) || (prevPosY != virtPosY) || (prevPosZ != virtPosZ) || + // + // 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 @@ -132,9 +143,6 @@ void FTNoIR_Protocol::sendHeadposeToGame(const double *headpose ) { prevRotZ = virtRotZ; } -// -// Returns 'true' if all seems OK. -// bool FTNoIR_Protocol::checkServerInstallationOK() { qDebug() << "checkServerInstallationOK says: Starting Function"; @@ -154,7 +162,6 @@ bool FTNoIR_Protocol::checkServerInstallationOK() return true; } - 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 a099df36..ff8d3b7f 100644 --- a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h +++ b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h @@ -76,8 +76,8 @@ public: private: QLibrary FSUIPCLib; double prevPosX, prevPosY, prevPosZ, prevRotX, prevRotY, prevRotZ; - settings s; static int scale2AnalogLimits( float x, float min_x, float max_x ); + settings s; }; class FSUIPCControls: public QWidget, public IProtocolDialog @@ -85,7 +85,7 @@ class FSUIPCControls: public QWidget, public IProtocolDialog Q_OBJECT public: FSUIPCControls(); - void registerProtocol(IProtocol *protocol) {} + void registerProtocol(IProtocol *) {} void unRegisterProtocol() {} private: Ui::UICFSUIPCControls ui; @@ -96,9 +96,6 @@ private slots: void getLocationOfDLL(); }; -//******************************************************************************************************* -// FaceTrackNoIR Protocol DLL. Functions used to get general info on the Protocol -//******************************************************************************************************* class FTNoIR_ProtocolDll : public Metadata { public: diff --git a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dialog.cpp b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dialog.cpp index 9ef4ad67..bae3d5df 100644 --- a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dialog.cpp +++ b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dialog.cpp @@ -29,8 +29,6 @@ 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())); @@ -43,11 +41,7 @@ void FSUIPCControls::doOK() { this->close(); } - void FSUIPCControls::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, QMessageBox::Discard ); @@ -74,9 +68,6 @@ void FSUIPCControls::doCancel() { 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 (*)")); -- cgit v1.2.3 From afaeec72c57a368eb3db072b9157eb1089c37fc1 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 31 Dec 2013 16:30:09 +0100 Subject: reindent cmake --- CMakeLists.txt | 78 +++++++++++++++++++++++++++++----------------------------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a88e6995..a3162637 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -114,54 +114,54 @@ if(MINGW) set(Qt5Gui_gdi32_LIBRARY ${SDK_MINGW_PREFIX}/mingw/lib/libgdi32.a) endif() - find_package(OpenCV REQUIRED) - set(maybe-serial-port) - if(SDK_HATIRE) - set(maybe-serial-port SerialPort) - 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) - 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}) +find_package(Qt5 REQUIRED COMPONENTS Core Xml Network Widgets Gui ${maybe-serial-port} 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}) - INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) - INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/qfunctionconfigurator) - INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/ftnoir_posewidget) +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/qfunctionconfigurator) +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/ftnoir_posewidget) - set(SDK_ARUCO_LIBPATH "" CACHE FILEPATH "Path to Aruco static library") +set(SDK_ARUCO_LIBPATH "" CACHE FILEPATH "Path to Aruco static library") - SET(SDK_OPENCV_STATIC FALSE CACHE BOOL "Whether OpenCV is statically linked") - if(WIN32) - set(SDK_SIMCONNECT "" CACHE PATH "Path to SimConnect SDK") - set(SDK_DIRECTX "" CACHE PATH "Path to DirectX SDK") - set(SDK_FSUIPC "" CACHE PATH "Path to FSUIPC") - if(SDK_DIRECTX) - include_directories("${SDK_DIRECTX}/Include") - link_directories("${SDK_DIRECTX}/Lib") - endif() +SET(SDK_OPENCV_STATIC FALSE CACHE BOOL "Whether OpenCV is statically linked") +if(WIN32) + set(SDK_SIMCONNECT "" CACHE PATH "Path to SimConnect SDK") + set(SDK_DIRECTX "" CACHE PATH "Path to DirectX SDK") + set(SDK_FSUIPC "" CACHE PATH "Path to FSUIPC") + if(SDK_DIRECTX) + include_directories("${SDK_DIRECTX}/Include") + link_directories("${SDK_DIRECTX}/Lib") endif() +endif() - if(NOT WIN32) - set(SDK_WINE_PREFIX "" CACHE PATH "Path where Wine is installed") - set(SDK_WINE_NO_WRAPPER FALSE CACHE BOOL "Don't build wrapper, for instance X-Plane is native Linux app") - endif() - IF("${CMAKE_SYSTEM}" MATCHES "Linux" OR APPLE) - set(SDK_XPLANE "" CACHE PATH "Path to X-Plane SDK") - endif() +if(NOT WIN32) + set(SDK_WINE_PREFIX "" CACHE PATH "Path where Wine is installed") + set(SDK_WINE_NO_WRAPPER FALSE CACHE BOOL "Don't build wrapper, for instance X-Plane is native Linux app") +endif() +IF("${CMAKE_SYSTEM}" MATCHES "Linux" OR APPLE) + set(SDK_XPLANE "" CACHE PATH "Path to X-Plane SDK") +endif() - if(SDK_XPLANE) - INCLUDE_DIRECTORIES("${SDK_XPLANE}/CHeaders" "${SDK_XPLANE}/CHeaders/XPLM") - endif() +if(SDK_XPLANE) + INCLUDE_DIRECTORIES("${SDK_XPLANE}/CHeaders" "${SDK_XPLANE}/CHeaders/XPLM") +endif() - if(WIN32) - if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) - set(CMAKE_RC_COMPILER_INIT i686-w64-mingw32-windres) - SET(CMAKE_RC_COMPILE_OBJECT " -O coff -i -o ") - endif() - ENABLE_LANGUAGE(RC) - endif(WIN32) +if(WIN32) + if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) + set(CMAKE_RC_COMPILER_INIT i686-w64-mingw32-windres) + SET(CMAKE_RC_COMPILE_OBJECT " -O coff -i -o ") + endif() + ENABLE_LANGUAGE(RC) +endif(WIN32) if(SDK_FSUIPC AND WIN32) include_directories("${SDK_FSUIPC}") -- cgit v1.2.3 From 823fdc531192ca4a7e831dbfc0c3755f65e17cd6 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 31 Dec 2013 16:38:22 +0100 Subject: duh, braino --- CMakeLists.txt | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a3162637..100cad67 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -224,9 +224,7 @@ opentrack_module(opentrack-proto-fsuipc ftnoir_protocol_fsuipc) opentrack_module(opentrack-proto-freetrack ftnoir_protocol_ft) opentrack_module(opentrack-proto-udp ftnoir_protocol_ftn) opentrack_module(opentrack-proto-wine ftnoir_protocol_wine) -if(WIN32) - opentrack_module(opentrack-proto-win32-mouse ftnoir_protocol_mouse) -endif() +opentrack_module(opentrack-proto-win32-mouse ftnoir_protocol_mouse) opentrack_module(opentrack-proto-simconnect ftnoir_protocol_sc) opentrack_module(opentrack-proto-vjoy ftnoir_protocol_vjoy) opentrack_module(opentrack-proto-libevdev ftnoir_protocol_libevdev) @@ -357,10 +355,9 @@ endif() if(WIN32) opentrack_library(opentrack-proto-freetrack) target_link_libraries(opentrack-proto-freetrack opentrack-csv opentrack-compat) + opentrack_library(opentrack-proto-win32-mouse) endif() -opentrack_library(opentrack-proto-win32-mouse) - if(WIN32) add_library(freetrackclient SHARED ${opentrack-freetrack-c}) if(CMAKE_COMPILER_IS_GNUCC) -- cgit v1.2.3 From 521151115b6a8c8808b2d449345ce1f0fed4e061 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 31 Dec 2013 17:12:49 +0100 Subject: Update README.md --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 9b1fa53a..2044a44b 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,4 @@ - -Windows binary builds are available at +Windows binary builds are available at Source code access available at -- cgit v1.2.3 From cb24e0d1dc2917691db6f30c063f2add323ca70b Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 31 Dec 2013 17:14:45 +0100 Subject: web host gone away, long live the new web host --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9b1fa53a..67fa3df8 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -Windows binary builds are available at +Windows binary builds are available at Source code access available at -- cgit v1.2.3 From 4a9c157caa350f0e333cba8444793ddae840bf12 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 1 Jan 2014 10:33:12 +0100 Subject: settings for mouse --- ftnoir_protocol_mouse/ftnoir_protocol_mouse.cpp | 56 ++----- ftnoir_protocol_mouse/ftnoir_protocol_mouse.h | 78 ++++----- .../ftnoir_protocol_mouse_dialog.cpp | 180 ++++++--------------- .../ftnoir_protocol_mouse_dll.cpp | 18 --- 4 files changed, 86 insertions(+), 246 deletions(-) diff --git a/ftnoir_protocol_mouse/ftnoir_protocol_mouse.cpp b/ftnoir_protocol_mouse/ftnoir_protocol_mouse.cpp index 64e010a8..cc8aa11e 100644 --- a/ftnoir_protocol_mouse/ftnoir_protocol_mouse.cpp +++ b/ftnoir_protocol_mouse/ftnoir_protocol_mouse.cpp @@ -29,38 +29,12 @@ #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(const double *headpose ) { - float fMouse_X = 0; - float fMouse_Y = 0; + double fMouse_X = 0; + double fMouse_Y = 0; + + int Mouse_X = s.Mouse_X; + int Mouse_Y = s.Mouse_Y; if (Mouse_X > 0 && Mouse_X <= 6) fMouse_X = headpose[Mouse_X-1] / (Mouse_X < 3 ? 100 : 180); @@ -77,24 +51,16 @@ void FTNoIR_Protocol::sendHeadposeToGame(const double *headpose ) { } } -// -// Returns 'true' if all seems OK. -// +void FTNoIR_Protocol::reload() +{ + s.b->reload(); +} + bool FTNoIR_Protocol::checkServerInstallationOK() { - - return true; + 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 1ce72f69..01f283d3 100644 --- a/ftnoir_protocol_mouse/ftnoir_protocol_mouse.h +++ b/ftnoir_protocol_mouse/ftnoir_protocol_mouse.h @@ -41,37 +41,34 @@ #include #include #include "facetracknoir/global-settings.h" +#include "facetracknoir/options.h" +using namespace options; + +struct settings { + pbundle b; + value Mouse_X, Mouse_Y; + settings() : + b(bundle("mouse-proto")), + Mouse_X(b, "mouse-x", 0), + Mouse_Y(b, "mouse-y", 0) + {} +}; #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(); - virtual ~FTNoIR_Protocol(); + FTNoIR_Protocol() {} bool checkServerInstallationOK(); void sendHeadposeToGame( const double *headpose); QString getGameName() { return "Mouse tracker"; } + void reload(); 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(); + struct settings s; }; // Widget that has controls for FTNoIR protocol client-settings. @@ -79,31 +76,20 @@ 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 - } - + MOUSEControls(); + void registerProtocol(IProtocol *protocol) { + _proto = (FTNoIR_Protocol *) protocol; + } + void unRegisterProtocol() { + _proto = NULL; + } private: - Ui::UICMOUSEControls ui; - void loadSettings(); - void save(); - - /** helper **/ - bool settingsDirty; - FTNoIR_Protocol *theProtocol; - + Ui::UICMOUSEControls ui; + settings s; + FTNoIR_Protocol* _proto; private slots: - void doOK(); - void doCancel(); - void settingChanged( int setting ) { settingsDirty = true; } + void doOK(); + void doCancel(); }; //******************************************************************************************************* @@ -112,13 +98,9 @@ private slots: 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 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"); } }; diff --git a/ftnoir_protocol_mouse/ftnoir_protocol_mouse_dialog.cpp b/ftnoir_protocol_mouse/ftnoir_protocol_mouse_dialog.cpp index c8d62a58..cc62b004 100644 --- a/ftnoir_protocol_mouse/ftnoir_protocol_mouse_dialog.cpp +++ b/ftnoir_protocol_mouse/ftnoir_protocol_mouse_dialog.cpp @@ -23,158 +23,68 @@ * * ********************************************************************************/ #include "ftnoir_protocol_mouse.h" -#include #include "facetracknoir/global-settings.h" -//******************************************************************************************************* -// FaceTrackNoIR Client Settings-dialog. -//******************************************************************************************************* - -// -// Constructor for server-settings-dialog -// -MOUSEControls::MOUSEControls() : -QWidget() +MOUSEControls::MOUSEControls() : _proto(nullptr) { - ui.setupUi( this ); - ui.cbxSelectMouse_X->addItem("None"); + 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("Y"); + ui.cbxSelectMouse_X->addItem("Z"); + ui.cbxSelectMouse_X->addItem("Yaw"); ui.cbxSelectMouse_X->addItem("Pitch"); - ui.cbxSelectMouse_X->addItem("Roll"); + 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("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"; -} + ui.cbxSelectMouse_Y->addItem("Pitch"); + ui.cbxSelectMouse_Y->addItem("Roll"); -// -// Initialize tracker-client-dialog -// -void MOUSEControls::Initialize(QWidget *parent) { + connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); + connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); - QPoint offsetpos(100, 100); - if (parent) { - this->move(parent->pos() + offsetpos); - } - show(); + tie_setting(s.Mouse_X, ui.cbxSelectMouse_X); + tie_setting(s.Mouse_Y, ui.cbxSelectMouse_Y); } -// -// OK clicked on server-dialog -// void MOUSEControls::doOK() { - save(); - this->close(); -} - -// override show event -void MOUSEControls::showEvent ( QShowEvent * event ) { - loadSettings(); + s.b->save(); + if (_proto) + _proto->reload(); + this->close(); } -// -// 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; + 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(); + } } -// -// 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 d142934d..54f6b307 100644 --- a/ftnoir_protocol_mouse/ftnoir_protocol_mouse_dll.cpp +++ b/ftnoir_protocol_mouse/ftnoir_protocol_mouse_dll.cpp @@ -23,26 +23,8 @@ * * ********************************************************************************/ #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; -- cgit v1.2.3 From 46807a9feea303144884f2865ac37f55c54fdb5a Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 1 Jan 2014 10:48:33 +0100 Subject: joystick: don't be a phonebook --- .../ftnoir_tracker_joystick.cpp | 22 +--- ftnoir_tracker_joystick/ftnoir_tracker_joystick.h | 49 +++++--- .../ftnoir_tracker_joystick_dialog.cpp | 134 ++++++--------------- .../ftnoir_tracker_joystick_dll.cpp | 29 +---- 4 files changed, 71 insertions(+), 163 deletions(-) diff --git a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp index 5be6b3db..28fc034a 100644 --- a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp +++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp @@ -10,24 +10,24 @@ static BOOL CALLBACK EnumJoysticksCallback2( const DIDEVICEINSTANCE* pdidInstanc self->def = *pdidInstance; - return self->iter++ == self->joyid ? DIENUM_STOP : DIENUM_CONTINUE; + return self->iter++ == self->s.joyid ? DIENUM_STOP : DIENUM_CONTINUE; } FTNoIR_Tracker::FTNoIR_Tracker() : g_pDI(nullptr), g_pJoystick(nullptr), - joyid(-1), iter(-1), mtx(QMutex::Recursive) { for (int i = 0; i < 6; i++) - axes[i] = min_[i] = max_[i] = 0; + *s.axes[i] = min_[i] = max_[i] = 0; GUID bar = {0}; preferred = bar; } void FTNoIR_Tracker::reload() { + s.b->reload(); QMutexLocker foo(&mtx); if (g_pJoystick) { @@ -100,7 +100,6 @@ void FTNoIR_Tracker::StartTracker(QFrame* frame) QMutexLocker foo(&mtx); this->frame = frame; iter = 0; - loadSettings(); auto hr = CoInitialize( nullptr ); DI_ENUM_CONTEXT enumContext = {0}; @@ -218,7 +217,7 @@ void FTNoIR_Tracker::GetHeadPoseData(double *data) for (int i = 0; i < 6; i++) { - auto idx = axes[i] - 1; + auto idx = *s.axes[i] - 1; if (idx < 0 || idx > 7) { data[i] = 0; @@ -234,19 +233,6 @@ void FTNoIR_Tracker::GetHeadPoseData(double *data) } } -void FTNoIR_Tracker::loadSettings() { - - QMutexLocker foo(&mtx); - 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 ( "tracker-joy" ); - joyid = iniFile.value("joyid", -1).toInt(); - for (int i = 0; i < 6; i++) - axes[i] = iniFile.value(QString("axis-%1").arg(i), 0).toInt() - 1; - iniFile.endGroup (); -} - extern "C" FTNOIR_TRACKER_BASE_EXPORT ITracker* CALLING_CONVENTION GetConstructor() { return new FTNoIR_Tracker; diff --git a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h index 67291e6f..162cbe48 100644 --- a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h +++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h @@ -24,10 +24,12 @@ #include #include #include -//#include #include #include +#include "facetracknoir/options.h" +using namespace options; + struct DI_ENUM_CONTEXT { GUID preferred_instance; @@ -35,29 +37,48 @@ struct DI_ENUM_CONTEXT LPDIRECTINPUT8 g_pDI; }; +struct settings { + pbundle b; + value axis_0; + value axis_1; + value axis_2; + value axis_3; + value axis_4; + value axis_5; + value joyid; + value* axes[6]; + settings() : + b(bundle("tracker-joystick")), + axis_0(b, "axis-0", 0), + axis_1(b, "axis-1", 0), + axis_2(b, "axis-2", 0), + axis_3(b, "axis-3", 0), + axis_4(b, "axis-4", 0), + axis_5(b, "axis-5", 0), + joyid(b, "joy-id", 0), + axes{&axis_0, &axis_1, &axis_2, &axis_3, &axis_4, &axis_5} + {} +}; + class FTNoIR_Tracker : public ITracker { public: FTNoIR_Tracker(); ~FTNoIR_Tracker(); - void StartTracker(QFrame *frame); void GetHeadPoseData(double *data); - void loadSettings(); + void reload(); LPDIRECTINPUT8 g_pDI; LPDIRECTINPUTDEVICE8 g_pJoystick; - int axes[6]; int min_[8], max_[8]; GUID preferred; - int joyid; QMutex mtx; QFrame* frame; DIDEVICEINSTANCE def; - void reload(); int iter; // XXX bad style + settings s; }; -// Widget that has controls for FTNoIR protocol client-settings. class TrackerControls: public QWidget, public ITrackerDialog { Q_OBJECT @@ -71,32 +92,20 @@ public: } QList guids; Ui::UIJoystickControls ui; - void loadSettings(); - void save(); - bool settingsDirty; FTNoIR_Tracker* tracker; - + settings s; 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; diff --git a/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp b/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp index 42ca8689..812ad454 100644 --- a/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp +++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp @@ -11,22 +11,21 @@ static BOOL CALLBACK EnumJoysticksCallback( const DIDEVICEINSTANCE* pdidInstance return DIENUM_CONTINUE; } -TrackerControls::TrackerControls() : - QWidget(), tracker(nullptr), settingsDirty(false) +TrackerControls::TrackerControls() : tracker(nullptr) { - ui.setupUi( this ); + ui.setupUi( this ); - // Connect Qt signals to member-functions + // Connect Qt signals to member-functions connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); - connect(ui.joylist, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.comboBox_2, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.comboBox_3, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.comboBox_4, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.comboBox_5, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.comboBox_6, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged(int))); + tie_setting(s.joyid, ui.joylist); + tie_setting(s.axis_0, ui.comboBox); + tie_setting(s.axis_1, ui.comboBox_2); + tie_setting(s.axis_2, ui.comboBox_3); + tie_setting(s.axis_3, ui.comboBox_4); + tie_setting(s.axis_4, ui.comboBox_5); + tie_setting(s.axis_5, ui.comboBox_6); { auto hr = CoInitialize( nullptr ); @@ -46,107 +45,42 @@ fin: if (g_pDI) g_pDI->Release(); } - - loadSettings(); } void TrackerControls::doOK() { - save(); - this->close(); + s.b->save(); + if (tracker) + tracker->reload(); + this->close(); } void TrackerControls::doCancel() { - 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 (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: - 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 TrackerControls::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) - - QComboBox* boxen[] = { - ui.comboBox_4, - ui.comboBox_5, - ui.comboBox_6, - ui.comboBox, - ui.comboBox_2, - ui.comboBox_3, - }; - - iniFile.beginGroup ( "tracker-joy" ); - for (int i = 0; i < 6; i++) - { - boxen[i]->setCurrentIndex(iniFile.value(QString("axis-%1").arg(i), 0).toInt()); - } - ui.joylist->setCurrentIndex(iniFile.value("joyid", -1).toInt()); - iniFile.endGroup (); - - settingsDirty = false; -} - -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) - - QComboBox* boxen[] = { - ui.comboBox_4, - ui.comboBox_5, - ui.comboBox_6, - ui.comboBox, - ui.comboBox_2, - ui.comboBox_3, - }; - - iniFile.beginGroup ( "tracker-joy" ); - for (int i = 0; i < 6; i++) - { - iniFile.setValue(QString("axis-%1").arg(i), boxen[i]->currentIndex()); + 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; } - iniFile.setValue("joyid", ui.joylist->currentIndex()); - iniFile.endGroup (); } - - if(tracker) - { - tracker->reload(); + else { + this->close(); } - - 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( ) { diff --git a/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dll.cpp b/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dll.cpp index c5ee4e5f..325d24a4 100644 --- a/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dll.cpp +++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dll.cpp @@ -2,31 +2,19 @@ #include #include "facetracknoir/global-settings.h" -FTNoIR_TrackerDll::FTNoIR_TrackerDll() { - //populate the description strings - trackerFullName = "Joystick"; - trackerShortName = "Joystick"; - trackerDescription = "joystick"; -} - -FTNoIR_TrackerDll::~FTNoIR_TrackerDll() -{ - -} - void FTNoIR_TrackerDll::getFullName(QString *strToBeFilled) { - *strToBeFilled = trackerFullName; + *strToBeFilled = "Joystick"; } void FTNoIR_TrackerDll::getShortName(QString *strToBeFilled) { - *strToBeFilled = trackerShortName; + *strToBeFilled = "Joystick"; } void FTNoIR_TrackerDll::getDescription(QString *strToBeFilled) { - *strToBeFilled = trackerDescription; + *strToBeFilled = "Joystick"; } void FTNoIR_TrackerDll::getIcon(QIcon *icon) @@ -34,16 +22,7 @@ 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; + return new FTNoIR_TrackerDll; } -- cgit v1.2.3 From 8744ae5baea83ed068a432d2dcc1c13fc347b8b2 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 1 Jan 2014 11:22:19 +0100 Subject: fix build --- CMakeLists.txt | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 100cad67..f7459e0a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -191,16 +191,19 @@ macro(opentrack_module n dir) endmacro() macro(opentrack_library n) - cmake_parse_arguments(lib- "" "LINK COMPILE" "" ${ARGN}) + cmake_parse_arguments(foolib "" "LINK;COMPILE" "" ${ARGN}) + if(NOT " ${foolib_UNPARSED_ARGUMENTS}" STREQUAL " ") + message(FATAL_ERROR "opentrack_library bad formals") + endif() add_library(${n} SHARED ${${n}-c} ${${n}-uih} ${${n}-rcc}) target_link_libraries(${n} ${MY_QT_LIBS}) if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) SET_TARGET_PROPERTIES(${n} PROPERTIES - LINK_FLAGS "${lib-LINK} -Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt" - COMPILE_FLAGS "${lib-COMPILE}" + LINK_FLAGS "${foolib_LINK} -Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt" + COMPILE_FLAGS "${foolib_COMPILE}" ) else() - set_target_properties(${n} PROPERTIES LINK_FLAGS "${lib-LINK}" COMPILE_FLAGS "${lib-COMPILE}") + set_target_properties(${n} PROPERTIES LINK_FLAGS "${foolib_LINK}" COMPILE_FLAGS "${foolib_COMPILE}") endif() install(TARGETS ${n} RUNTIME DESTINATION . LIBRARY DESTINATION .) endmacro() @@ -373,6 +376,7 @@ endif() if(SDK_WINE_PREFIX) opentrack_library(opentrack-proto-wine) + target_link_libraries(opentrack-proto-wine opentrack-compat opentrack-csv) if(NOT SDK_WINE_NO_WRAPPER) set(my-rt -lrt) if(APPLE) -- cgit v1.2.3 From b4cd90ce91322830a6b08d6f18440cd92987f166 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 1 Jan 2014 11:28:44 +0100 Subject: libovr doesn't require strict aliasing anymore --- CMakeLists.txt | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 100cad67..2092aee3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -446,12 +446,7 @@ if(SDK_RIFT) set(link-flags "/NODEFAULTLIB:LIBCMT") endif() endif() - if(NOT MSVC) - set(c-flags -fno-strict-aliasing) - else() - set(c-flags) - endif() - opentrack_library(opentrack-tracker-rift LINK "${link-flags}" COMPILE "${c-flags}") + opentrack_library(opentrack-tracker-rift LINK "${link-flags}") if(MSVC) target_link_libraries(opentrack-tracker-rift "${SDK_RIFT}/Lib/Win32/libovr.lib" winmm.lib setupapi.lib) else() -- cgit v1.2.3 From c2e56bd21ee40501dab53b3647c8bdd1f370dba3 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 1 Jan 2014 11:28:59 +0100 Subject: don't reference QSettings anymore --- ftnoir_protocol_ftn/ftnoir_protocol_ftn.h | 1 - ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.h | 1 - ftnoir_protocol_wine/ftnoir_protocol_wine.h | 1 - ftnoir_tracker_hatire/ftnoir_tracker_hat.h | 1 - ftnoir_tracker_ht/stdafx.h | 1 - ftnoir_tracker_hydra/ftnoir_tracker_hydra.h | 1 - ftnoir_tracker_rift/ftnoir_tracker_rift.h | 1 - ftnoir_tracker_udp/ftnoir_tracker_udp.h | 1 - 8 files changed, 8 deletions(-) diff --git a/ftnoir_protocol_ftn/ftnoir_protocol_ftn.h b/ftnoir_protocol_ftn/ftnoir_protocol_ftn.h index d5dc2cfe..99e6c6a1 100644 --- a/ftnoir_protocol_ftn/ftnoir_protocol_ftn.h +++ b/ftnoir_protocol_ftn/ftnoir_protocol_ftn.h @@ -33,7 +33,6 @@ #include #include #include -#include #include #include "facetracknoir/global-settings.h" #include "facetracknoir/options.h" diff --git a/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.h b/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.h index 5df59919..f92bb7bb 100644 --- a/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.h +++ b/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.h @@ -9,7 +9,6 @@ #include "ui_ftnoir_libevdev_controls.h" #include -#include #include "facetracknoir/global-settings.h" extern "C" { diff --git a/ftnoir_protocol_wine/ftnoir_protocol_wine.h b/ftnoir_protocol_wine/ftnoir_protocol_wine.h index e84dbd69..50d2bc0c 100644 --- a/ftnoir_protocol_wine/ftnoir_protocol_wine.h +++ b/ftnoir_protocol_wine/ftnoir_protocol_wine.h @@ -33,7 +33,6 @@ #include "ftnoir_csv/csv.h" #include "ui_ftnoir_winecontrols.h" #include -#include #include #include #include diff --git a/ftnoir_tracker_hatire/ftnoir_tracker_hat.h b/ftnoir_tracker_hatire/ftnoir_tracker_hat.h index 57ead58d..0dbc4c8c 100644 --- a/ftnoir_tracker_hatire/ftnoir_tracker_hat.h +++ b/ftnoir_tracker_hatire/ftnoir_tracker_hat.h @@ -16,7 +16,6 @@ #include #include #include -#include #define VER_FILEVERSION_STR "Version 2.0.7\0" diff --git a/ftnoir_tracker_ht/stdafx.h b/ftnoir_tracker_ht/stdafx.h index 0e532c9f..6f1539b7 100644 --- a/ftnoir_tracker_ht/stdafx.h +++ b/ftnoir_tracker_ht/stdafx.h @@ -4,7 +4,6 @@ #include #include #include -#include #include #include #include diff --git a/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h b/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h index e569efab..05a8b076 100644 --- a/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h +++ b/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h @@ -1,7 +1,6 @@ #include "ftnoir_tracker_base/ftnoir_tracker_base.h" #include "ui_ftnoir_hydra_clientcontrols.h" #include -#include #include #include #include "facetracknoir/global-settings.h" diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift.h b/ftnoir_tracker_rift/ftnoir_tracker_rift.h index dd673308..7162b7ca 100644 --- a/ftnoir_tracker_rift/ftnoir_tracker_rift.h +++ b/ftnoir_tracker_rift/ftnoir_tracker_rift.h @@ -2,7 +2,6 @@ #include "ftnoir_tracker_base/ftnoir_tracker_base.h" #include "ui_ftnoir_rift_clientcontrols.h" #include -#include #include #include #include "facetracknoir/global-settings.h" diff --git a/ftnoir_tracker_udp/ftnoir_tracker_udp.h b/ftnoir_tracker_udp/ftnoir_tracker_udp.h index 140a935d..20d4f742 100644 --- a/ftnoir_tracker_udp/ftnoir_tracker_udp.h +++ b/ftnoir_tracker_udp/ftnoir_tracker_udp.h @@ -3,7 +3,6 @@ #include #include #include -#include #include #include #include -- cgit v1.2.3 From 495b518b4b4127ed3656c8da817c1f9744abee9e Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 1 Jan 2014 11:31:21 +0100 Subject: empty default config. should have sane defaults by now --- bin/settings/default.ini | 130 ----------------------------------------------- 1 file changed, 130 deletions(-) diff --git a/bin/settings/default.ini b/bin/settings/default.ini index 05ce3af4..e69de29b 100644 --- a/bin/settings/default.ini +++ b/bin/settings/default.ini @@ -1,130 +0,0 @@ -[Curves-rx] -point-count=4 -point-0-x=0 -point-0-y=0 -point-1-x=5 -point-1-y=14 -point-2-x=12.222222328186 -point-2-y=75 -point-3-x=19 -point-3-y=158 - -[Curves-ry] -point-count=1 -point-0-x=19 -point-0-y=90 - -[Curves-ry_alt] -point-count=4 -point-0-x=0 -point-0-y=0 -point-1-x=4.88888883590698 -point-1-y=16 -point-2-x=8.88888931274414 -point-2-y=36 -point-3-x=12 -point-3-y=69 - -[Curves-rz] -point-count=1 -point-0-x=60 -point-0-y=60 - -[Curves-tx] -point-count=1 -point-0-x=59.8888893127441 -point-0-y=165 - -[Curves-ty] -point-count=1 -point-0-x=60 -point-0-y=165 - -[Curves-tz] -point-count=1 -point-0-x=60 -point-0-y=200 - -[Tracking] -Smooth=1 -invertYaw=false -invertPitch=false -invertRoll=false -invertX=false -invertY=false -invertZ=false -rx_alt=false -ry_alt=true -rz_alt=false -tx_alt=false -ty_alt=false -tz_alt=false - -[GameProtocol] -DLL=FTNoIR_Protocol_FT.dll - -[KB_Shortcuts] -Keycode_Center=199 -Shift_Center=false -Ctrl_Center=false -Alt_Center=false -Keycode_StartStop=207 -Shift_StartStop=false -Ctrl_StartStop=false -Alt_StartStop=false - -[PPJoy] -Selection=1 - -[FSUIPC] -LocationOfDLL=C:/Program Files/Microsoft Games/Flight Simulator 9/Modules/FSUIPC.dll - -[TrackerSource] -Selection=0 -DLL=FTNoIR_Tracker_SM.dll -2ndDLL=None - -[Filter] -DLL=FTNoIR_Filter_Accela.dll - -[SMTracker] -FilterLevel=1 -EnableRoll=true -EnablePitch=true -EnableYaw=true -EnableX=true -EnableY=true -EnableZ=true - -[Accela] -Reduction=1000 -zoom-slowness=5 -smoothing-factor=1.5 - -[Curves-Accela-Scaling-Rotation] -point-count=6 -point-0-x=0 -point-0-y=0 -point-1-x=0.535433053970337 -point-1-y=0.29824560880661 -point-2-x=0.992125988006592 -point-2-y=0.736842095851898 -point-3-x=1.33070862293243 -point-3-y=1.59649121761322 -point-4-x=1.4960629940033 -point-4-y=3.29824566841125 -point-5-x=1.58267712593079 -point-5-y=8 - -[Curves-Accela-Scaling-Translation] -point-count=5 -point-0-x=0 -point-0-y=0 -point-1-x=0.346456706523895 -point-1-y=1 -point-2-x=0.559055089950562 -point-2-y=3.15789484977722 -point-3-x=0.700787425041199 -point-3-y=5.54385948181152 -point-4-x=0.795275568962097 -point-4-y=8 \ No newline at end of file -- cgit v1.2.3 From a154845c21a58891f9368c560cfe26602b19ff10 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 1 Jan 2014 11:35:35 +0100 Subject: UDP: fill in description strings --- ftnoir_tracker_udp/ftnoir_tracker_udp.h | 5 ----- ftnoir_tracker_udp/ftnoir_tracker_udp_dll.cpp | 6 +++--- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/ftnoir_tracker_udp/ftnoir_tracker_udp.h b/ftnoir_tracker_udp/ftnoir_tracker_udp.h index 20d4f742..62eb67df 100644 --- a/ftnoir_tracker_udp/ftnoir_tracker_udp.h +++ b/ftnoir_tracker_udp/ftnoir_tracker_udp.h @@ -73,10 +73,5 @@ public: 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_dll.cpp b/ftnoir_tracker_udp/ftnoir_tracker_udp_dll.cpp index 6732b599..22dc7daa 100644 --- a/ftnoir_tracker_udp/ftnoir_tracker_udp_dll.cpp +++ b/ftnoir_tracker_udp/ftnoir_tracker_udp_dll.cpp @@ -28,17 +28,17 @@ void FTNoIR_TrackerDll::getFullName(QString *strToBeFilled) { - *strToBeFilled = trackerFullName; + *strToBeFilled = "UDP"; } void FTNoIR_TrackerDll::getShortName(QString *strToBeFilled) { - *strToBeFilled = trackerShortName; + *strToBeFilled = "UDP"; } void FTNoIR_TrackerDll::getDescription(QString *strToBeFilled) { - *strToBeFilled = trackerDescription; + *strToBeFilled = "UDP"; } void FTNoIR_TrackerDll::getIcon(QIcon *icon) -- 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(-) 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(-) 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(+) 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(+) 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 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(-) 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 50104a86acbc20ba1854926a68349eae5459522a 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(-) diff --git a/facetracknoir/ftnoir_curves.ui b/facetracknoir/ftnoir_curves.ui index 77df9a20..5355dd20 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 a8bb3371..6b154e33 100644 --- a/qfunctionconfigurator/functionconfig.h +++ b/qfunctionconfigurator/functionconfig.h @@ -32,6 +32,8 @@ private: int _max_Output; FunctionConfig(const FunctionConfig&) {} 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 44162ed05648e68bd07dfcb35e86b6a18b3d3372 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 1 Jan 2014 13:50:44 +0100 Subject: one const too many --- qfunctionconfigurator/functionconfig.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qfunctionconfigurator/functionconfig.h b/qfunctionconfigurator/functionconfig.h index ab2d0d0c..4d771dfd 100644 --- a/qfunctionconfigurator/functionconfig.h +++ b/qfunctionconfigurator/functionconfig.h @@ -32,8 +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; } + int maxInput() const { return _max_Input; } + int maxOutput() const { return _max_Output; } // // Contructor(s) and destructor // -- cgit v1.2.3 From 2d5bdc9d7211d68e619b9d255b46f551d50ef515 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 1 Jan 2014 13:53:17 +0100 Subject: fix rift build --- CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 93e0b415..e6efa07d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -443,14 +443,18 @@ if(SDK_RIFT) include_directories("${SDK_RIFT}/Include") include_directories("${SDK_RIFT}/Src") set(link-flags) + set(c-flags) if(APPLE) set(link-flags "-framework CoreFoundation -framework CoreGraphics -framework IOKit -framework Quartz") + set(c-flags "-fno-strict-aliasing") else() if(MSVC) set(link-flags "/NODEFAULTLIB:LIBCMT") + else() + set(c-flags "-fno-strict-aliasing") endif() endif() - opentrack_library(opentrack-tracker-rift LINK "${link-flags}") + opentrack_library(opentrack-tracker-rift LINK "${link-flags}" COMPILE "${c-flags}") if(MSVC) target_link_libraries(opentrack-tracker-rift "${SDK_RIFT}/Lib/Win32/libovr.lib" winmm.lib setupapi.lib) else() -- cgit v1.2.3 From f00e6945cf0634e1b8f01d1f9208fb792902b3b1 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 1 Jan 2014 13:50:44 +0100 Subject: one const too many --- qfunctionconfigurator/functionconfig.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qfunctionconfigurator/functionconfig.h b/qfunctionconfigurator/functionconfig.h index 6b154e33..9654fffb 100644 --- a/qfunctionconfigurator/functionconfig.h +++ b/qfunctionconfigurator/functionconfig.h @@ -32,8 +32,8 @@ private: int _max_Output; FunctionConfig(const FunctionConfig&) {} public: - const int maxInput() const { return _max_Input; } - const int maxOutput() const { return _max_Output; } + int maxInput() const { return _max_Input; } + int maxOutput() const { return _max_Output; } // // Contructor(s) and destructor // -- 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(-) 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(-) 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 63e130f42c2ad329aba3da9e3121323914fac3fc Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 2 Jan 2014 06:25:30 +0100 Subject: fix win32 native build by reordering headers --- FTNoIR_Tracker_PT/camera.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/FTNoIR_Tracker_PT/camera.cpp b/FTNoIR_Tracker_PT/camera.cpp index 5f6db57c..754533c5 100644 --- a/FTNoIR_Tracker_PT/camera.cpp +++ b/FTNoIR_Tracker_PT/camera.cpp @@ -5,6 +5,11 @@ * copyright notice and this permission notice appear in all copies. */ + #if defined(OPENTRACK_API) && defined(_WIN32) +#include +#include +#endif + #include "camera.h" #include #include @@ -15,11 +20,6 @@ using namespace cv; #include #endif -#if defined(OPENTRACK_API) && defined(_WIN32) -#include -#include -#endif - #ifdef OPENTRACK_API void get_camera_device_names(std::vector& device_names) { # if defined(_WIN32) -- cgit v1.2.3 From a4eb9e8d6d727516e77bf370c2b0838850e52f81 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 2 Jan 2014 06:25:53 +0100 Subject: fix header/lib mismatch on windows --- CMakeLists.txt | 48 ++++++++++++++++++++++-------------------------- 1 file changed, 22 insertions(+), 26 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e6efa07d..0d2c0006 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -182,6 +182,20 @@ endif() # qt being broken as usual set(EXTRA-MOCS "${CMAKE_SOURCE_DIR}/facetracknoir/options.h") +function(link_with_dinput8 n) + if(WIN32) + if(MSVC) + target_link_libraries(${n} + "${CMAKE_SOURCE_DIR}/dinput/dinput8.lib" + "${CMAKE_SOURCE_DIR}/dinput/dxguid.lib" + "${CMAKE_SOURCE_DIR}/dinput/strmiids.lib" + uuid) + else() + target_link_libraries(${n} dinput8 dxguid strmiids) + endif() + endif() +endfunction() + macro(opentrack_module n dir) file(GLOB ${n}-c "${dir}/*.cpp" "${dir}/*.h" ${EXTRA-MOCS}) file(GLOB ${n}-ui "${dir}/*.ui") @@ -413,29 +427,17 @@ if(SDK_ARUCO_LIBPATH) endif() endif() -opentrack_library(opentrack-tracker-hatire) - -if(WIN32) - target_link_libraries(opentrack-tracker-ht - "${CMAKE_SOURCE_DIR}/dinput/dxguid.lib" - "${CMAKE_SOURCE_DIR}/dinput/strmiids.lib" - uuid) - target_link_libraries(opentrack-tracker-joystick - "${CMAKE_SOURCE_DIR}/dinput/dinput8.lib" - "${CMAKE_SOURCE_DIR}/dinput/dxguid.lib" - "${CMAKE_SOURCE_DIR}/dinput/strmiids.lib" - uuid) +if(SDK_HATIRE) + opentrack_library(opentrack-tracker-hatire) endif() +link_with_dinput8(opentrack-tracker-ht) +link_with_dinput8(opentrack-tracker-joystick) + opentrack_library(opentrack-tracker-pt) target_link_libraries(opentrack-tracker-pt ${OpenCV_LIBS}) -if(WIN32) - target_link_libraries(opentrack-tracker-pt - "${CMAKE_SOURCE_DIR}/dinput/dxguid.lib" - "${CMAKE_SOURCE_DIR}/dinput/strmiids.lib" - uuid) -endif() +link_with_dinput8(opentrack-tracker-pt) opentrack_library(opentrack-tracker-udp) @@ -547,14 +549,8 @@ if(UNIX OR APPLE) install(TARGETS opentrack-qxt-mini RUNTIME DESTINATION . LIBRARY DESTINATION . ) endif() -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 - uuid - ) -endif() +link_with_dinput8(opentrack) + if(MSVC) SET_TARGET_PROPERTIES(opentrack PROPERTIES LINK_FLAGS "/ENTRY:mainCRTStartup") endif() -- cgit v1.2.3 From f998dc6ce88d8439e5e6ec9e506bd82255ef71f7 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 2 Jan 2014 07:17:45 +0100 Subject: add missing resolution forcing --- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index a0a11ed2..651f7dbf 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -441,6 +441,7 @@ TrackerControls::TrackerControls() ui.setupUi(this); setAttribute(Qt::WA_NativeWindow, true); tie_setting(s.camera_index, ui.cameraName); + tie_setting(s.resolution, ui.resolution); tie_setting(s.force_fps, ui.cameraFPS); tie_setting(s.fov, ui.cameraFOV); tie_setting(s.eyaw, ui.rx); -- cgit v1.2.3 From fba587185e077cf6ed4b37d213553f87e3b859cb Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 2 Jan 2014 08:07:03 +0100 Subject: fix bad fps copy-paste-o --- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index 651f7dbf..ff7821fd 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -146,16 +146,16 @@ void Tracker::run() { default: case 0: - fps = 0; + fps = 30; break; - case 30: - fps = 1; + case 1: + fps = 60; break; - case 60: - fps = 2; + case 2: + fps = 120; break; - case 120: - fps = 3; + case 3: + fps = 0; break; } camera = cv::VideoCapture(s.camera_index); -- cgit v1.2.3 From 58a8a9eeaf85f017f38741a2b7c3c46a22431a88 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 2 Jan 2014 08:10:45 +0100 Subject: add .rc files to build following cmake debloatification --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0d2c0006..776473b6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -197,7 +197,7 @@ function(link_with_dinput8 n) endfunction() macro(opentrack_module n dir) - file(GLOB ${n}-c "${dir}/*.cpp" "${dir}/*.h" ${EXTRA-MOCS}) + file(GLOB ${n}-c "${dir}/*.cpp" "${dir}/*.h" "${dir}/*.rc" ${EXTRA-MOCS}) file(GLOB ${n}-ui "${dir}/*.ui") file(GLOB ${n}-rc "${dir}/*.qrc") QT5_WRAP_UI(${n}-uih ${${n}-ui}) -- cgit v1.2.3 From b2a79761e49b847e1ba30915045404e4a218fd86 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 2 Jan 2014 08:12:28 +0100 Subject: delete msvc cruft --- FTNoIR_Tracker_PT/FTNoIR_Tracker_PT_vc10.vcxproj | 212 ----------------------- 1 file changed, 212 deletions(-) delete mode 100644 FTNoIR_Tracker_PT/FTNoIR_Tracker_PT_vc10.vcxproj diff --git a/FTNoIR_Tracker_PT/FTNoIR_Tracker_PT_vc10.vcxproj b/FTNoIR_Tracker_PT/FTNoIR_Tracker_PT_vc10.vcxproj deleted file mode 100644 index b777077b..00000000 --- a/FTNoIR_Tracker_PT/FTNoIR_Tracker_PT_vc10.vcxproj +++ /dev/null @@ -1,212 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Template - Win32 - - - - FTNoIR_Tracker_PT - {7A2A2560-9253-4CC8-A9D5-4B9D9C224D9D} - FTNoIR_Tracker_PT - Qt4VSv1.0 - - - - DynamicLibrary - - - DynamicLibrary - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - $(SolutionDir)\bin\ - $(SolutionDir)\$(Configuration)\ - $(SolutionDir)/bin_dbg\ - $(SolutionDir)\$(Configuration)\ - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - - - - MaxSpeed - .;.\GeneratedFiles;.\GeneratedFiles\$(Configuration);$(QTDIR)\include;$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(OPENCV_DIR)\include;$(BOOST_DIR);$(QTDIR)\include\QtOpenGL;%(AdditionalIncludeDirectories) - UNICODE;WIN32;QT_DLL;QT_NO_DEBUG;NDEBUG;QT_CORE_LIB;QT_GUI_LIB;FTNOIR_TRACKER_BASE_LIB;QT_OPENGL_LIB;%(PreprocessorDefinitions) - MultiThreadedDLL - false - - - - - qtmain.lib;QtCore4.lib;QtGui4.lib;QtOpenGL4.lib;opengl32.lib;glu32.lib;opencv_core242.lib;opencv_imgproc242.lib;opencv_calib3d242.lib;videoInput_vc10.lib;%(AdditionalDependencies) - $(OutDir)$(ProjectName).dll - $(QTDIR)\lib;$(OPENCV_DIR)\x86\vc10\lib;$(ProjectDir)\videoInput;%(AdditionalLibraryDirectories) - atlthunk.lib;libcmt;%(IgnoreSpecificDefaultLibraries) - false - Windows - - - - - Disabled - .;.\GeneratedFiles;.\GeneratedFiles\$(Configuration);$(QTDIR)\include;$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(OPENCV_DIR)\include;$(BOOST_DIR);$(QTDIR)\include\QtOpenGL;%(AdditionalIncludeDirectories) - UNICODE;WIN32;QT_DLL;QT_CORE_LIB;QT_GUI_LIB;FTNOIR_TRACKER_BASE_LIB;QT_OPENGL_LIB;%(PreprocessorDefinitions) - MultiThreadedDebugDLL - false - ProgramDatabase - - - qtmaind.lib;QtCored4.lib;QtGuid4.lib;QtOpenGLd4.lib;opengl32.lib;glu32.lib;opencv_core242d.lib;opencv_imgproc242d.lib;opencv_calib3d242d.lib;videoInput_vc10.lib;%(AdditionalDependencies) - $(OutDir)$(ProjectName).dll - $(QTDIR)\lib;$(OPENCV_DIR)\x86\vc10\lib;$(ProjectDir)\videoInput;%(AdditionalLibraryDirectories) - atlthunk.lib;libcmt;%(IgnoreSpecificDefaultLibraries) - true - Windows - - - - - - - - - - - - - - - - - - - - - - true - true - - - true - true - - - true - true - - - true - true - - - - - - - - - - - - %(AdditionalInputs) - %(Outputs) - - - - - %(AdditionalInputs) - %(Outputs) - - - Moc%27ing ftnoir_tracker_pt_dialog.h... - "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DQT_DLL -DQT_CORE_LIB -DQT_GUI_LIB -DFTNOIR_TRACKER_BASE_LIB -DQT_OPENGL_LIB -D_WINDLL "-I." "-I.\GeneratedFiles" "-I.\GeneratedFiles\$(Configuration)\." "-I$(QTDIR)\include" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" "-I$(OPENCV_DIR)\include" "-I$(BOOST_DIR)\." "-I$(QTDIR)\include\QtOpenGL" - $(QTDIR)\bin\moc.exe;%(FullPath);%(AdditionalInputs) - .\GeneratedFiles\$(Configuration)\moc_%(Filename).cpp;%(Outputs) - Moc%27ing ftnoir_tracker_pt_dialog.h... - "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DQT_DLL -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_GUI_LIB -DFTNOIR_TRACKER_BASE_LIB -DQT_OPENGL_LIB -D_WINDLL "-I." "-I.\GeneratedFiles" "-I.\GeneratedFiles\$(Configuration)\." "-I$(QTDIR)\include" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" "-I$(OPENCV_DIR)\include" "-I$(BOOST_DIR)\." "-I$(QTDIR)\include\QtOpenGL" - $(QTDIR)\bin\moc.exe;%(FullPath);%(AdditionalInputs) - .\GeneratedFiles\$(Configuration)\moc_%(Filename).cpp;%(Outputs) - - - - - - - - - - Moc%27ing video_widget.h... - "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DQT_DLL -DQT_CORE_LIB -DQT_GUI_LIB -DFTNOIR_TRACKER_BASE_LIB -DQT_OPENGL_LIB -D_WINDLL "-I." "-I.\GeneratedFiles" "-I.\GeneratedFiles\$(Configuration)\." "-I$(QTDIR)\include" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" "-I$(OPENCV_DIR)\include" "-I$(BOOST_DIR)\." "-I$(QTDIR)\include\QtOpenGL" - $(QTDIR)\bin\moc.exe;%(FullPath);%(AdditionalInputs) - .\GeneratedFiles\$(Configuration)\moc_%(Filename).cpp;%(Outputs) - Moc%27ing video_widget.h... - "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DQT_DLL -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_GUI_LIB -DFTNOIR_TRACKER_BASE_LIB -DQT_OPENGL_LIB -D_WINDLL "-I." "-I.\GeneratedFiles" "-I.\GeneratedFiles\$(Configuration)\." "-I$(QTDIR)\include" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" "-I$(OPENCV_DIR)\include" "-I$(BOOST_DIR)\." "-I$(QTDIR)\include\QtOpenGL" - $(QTDIR)\bin\moc.exe;%(FullPath);%(AdditionalInputs) - .\GeneratedFiles\$(Configuration)\moc_%(Filename).cpp;%(Outputs) - - - - - - Uic%27ing %(Filename)%(Extension)... - "$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)" - - $(QTDIR)\bin\uic.exe;%(AdditionalInputs) - .\GeneratedFiles\ui_%(Filename).h;%(Outputs) - Uic%27ing %(Filename)%(Extension)... - "$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)" - - $(QTDIR)\bin\uic.exe;%(AdditionalInputs) - .\GeneratedFiles\ui_%(Filename).h;%(Outputs) - - - Rcc%27ing %(Filename)%(Extension)... - "$(QTDIR)\bin\rcc.exe" -name "%(Filename)" -no-compress "%(FullPath)" -o .\GeneratedFiles\qrc_%(Filename).cpp - - %(FullPath);.\Resources\icon.ico;.\Resources\Logo_IR.png;%(AdditionalInputs) - .\GeneratedFiles\qrc_%(Filename).cpp;%(Outputs) - Rcc%27ing %(Filename)%(Extension)... - "$(QTDIR)\bin\rcc.exe" -name "%(Filename)" -no-compress "%(FullPath)" -o .\GeneratedFiles\qrc_%(Filename).cpp - - %(FullPath);.\Resources\icon.ico;.\Resources\Logo_IR.png;%(AdditionalInputs) - .\GeneratedFiles\qrc_%(Filename).cpp;%(Outputs) - - - - - - - - - - - - - - \ No newline at end of file -- cgit v1.2.3 From dd41c425229716c82b4b4b4444e04f644c7a22f6 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 2 Jan 2014 08:12:34 +0100 Subject: fix build --- FTNoIR_Tracker_PT/FTNoIR_Tracker_PT.rc | 61 ---------------------------------- 1 file changed, 61 deletions(-) delete mode 100644 FTNoIR_Tracker_PT/FTNoIR_Tracker_PT.rc diff --git a/FTNoIR_Tracker_PT/FTNoIR_Tracker_PT.rc b/FTNoIR_Tracker_PT/FTNoIR_Tracker_PT.rc deleted file mode 100644 index 11c5d52f..00000000 --- a/FTNoIR_Tracker_PT/FTNoIR_Tracker_PT.rc +++ /dev/null @@ -1,61 +0,0 @@ -// 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 - -- cgit v1.2.3 From 1a95a291666f82d15fc1fe6e91803d3a71816883 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 2 Jan 2014 16:35:45 +0100 Subject: align offsets with combobox entries --- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index ff7821fd..b4f35c6f 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -146,16 +146,16 @@ void Tracker::run() { default: case 0: - fps = 30; + fps = 0; break; case 1: - fps = 60; + fps = 30; break; case 2: - fps = 120; + fps = 60; break; case 3: - fps = 0; + fps = 120; break; } camera = cv::VideoCapture(s.camera_index); -- cgit v1.2.3 From 12dd00394b62d26d892cbd320fcb5652df6635e6 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 3 Jan 2014 10:35:14 +0100 Subject: Fix FSX manifest. Ouch! --- ftnoir_protocol_sc/ftnoir-protocol-sc.rc | 1 + ftnoir_protocol_sc/ftnoir_protocol_sc.cpp | 8 +++++++- ftnoir_protocol_sc/ftnoir_sccontrols.ui | 11 ++++++++--- ftnoir_protocol_sc/scserver-acceleration.manifest | 13 +++++++++++++ 4 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 ftnoir_protocol_sc/scserver-acceleration.manifest diff --git a/ftnoir_protocol_sc/ftnoir-protocol-sc.rc b/ftnoir_protocol_sc/ftnoir-protocol-sc.rc index 693aa12e..80b6c12c 100644 --- a/ftnoir_protocol_sc/ftnoir-protocol-sc.rc +++ b/ftnoir_protocol_sc/ftnoir-protocol-sc.rc @@ -1,3 +1,4 @@ #include 142 RT_MANIFEST scserver.manifest 143 RT_MANIFEST scserver-sp2.manifest +144 RT_MANIFEST scserver-acceleration.manifest \ No newline at end of file diff --git a/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp b/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp index 9fb48527..2714e980 100644 --- a/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp +++ b/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp @@ -102,7 +102,12 @@ public: actx.cbSize = sizeof(ACTCTXA); actx.lpResourceName = MAKEINTRESOURCEA(resid); actx.dwFlags = ACTCTX_FLAG_RESOURCE_NAME_VALID; - QString path = QCoreApplication::applicationDirPath() + "/opentrack-proto-simconnect.dll"; +#ifdef _MSC_VER +# define PREFIX "" +#else +# define PREFIX "lib" +#endif + QString path = QCoreApplication::applicationDirPath() + "/" PREFIX "opentrack-proto-simconnect.dll"; QByteArray name = QFile::encodeName(path); actx.lpSource = name.constData(); hactctx = CreateActCtxA(&actx); @@ -135,6 +140,7 @@ bool FTNoIR_Protocol::checkServerInstallationOK() { ActivationContext ctx(142 + static_cast(s.sxs_manifest)); + SCClientLib.setFileName("SimConnect.dll"); if (!SCClientLib.load()) { qDebug() << "SC load" << SCClientLib.errorString(); return false; diff --git a/ftnoir_protocol_sc/ftnoir_sccontrols.ui b/ftnoir_protocol_sc/ftnoir_sccontrols.ui index 17e94c4b..430b3912 100644 --- a/ftnoir_protocol_sc/ftnoir_sccontrols.ui +++ b/ftnoir_protocol_sc/ftnoir_sccontrols.ui @@ -9,8 +9,8 @@ 0 0 - 258 - 61 + 290 + 79 @@ -38,7 +38,7 @@ - Acceleration + SP1 @@ -46,6 +46,11 @@ SP2 + + + Acceleration + + diff --git a/ftnoir_protocol_sc/scserver-acceleration.manifest b/ftnoir_protocol_sc/scserver-acceleration.manifest new file mode 100644 index 00000000..06459587 --- /dev/null +++ b/ftnoir_protocol_sc/scserver-acceleration.manifest @@ -0,0 +1,13 @@ + + + + + + + + + + + + + -- cgit v1.2.3 From b9d8ae0b1bb7186b0e2e4a225b53006553406b79 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 3 Jan 2014 10:35:14 +0100 Subject: Fix FSX manifest. Ouch! --- ftnoir_protocol_sc/ftnoir-protocol-sc.rc | 1 + ftnoir_protocol_sc/ftnoir_protocol_sc.cpp | 8 +++++++- ftnoir_protocol_sc/ftnoir_sccontrols.ui | 11 ++++++++--- ftnoir_protocol_sc/scserver-acceleration.manifest | 13 +++++++++++++ 4 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 ftnoir_protocol_sc/scserver-acceleration.manifest diff --git a/ftnoir_protocol_sc/ftnoir-protocol-sc.rc b/ftnoir_protocol_sc/ftnoir-protocol-sc.rc index 693aa12e..80b6c12c 100644 --- a/ftnoir_protocol_sc/ftnoir-protocol-sc.rc +++ b/ftnoir_protocol_sc/ftnoir-protocol-sc.rc @@ -1,3 +1,4 @@ #include 142 RT_MANIFEST scserver.manifest 143 RT_MANIFEST scserver-sp2.manifest +144 RT_MANIFEST scserver-acceleration.manifest \ No newline at end of file diff --git a/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp b/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp index 8449f6ce..9c144b5d 100644 --- a/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp +++ b/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp @@ -149,7 +149,12 @@ public: actx.cbSize = sizeof(ACTCTXA); actx.lpResourceName = MAKEINTRESOURCEA(resid); actx.dwFlags = ACTCTX_FLAG_RESOURCE_NAME_VALID; - QString path = QCoreApplication::applicationDirPath() + "/opentrack-proto-simconnect.dll"; +#ifdef _MSC_VER +# define PREFIX "" +#else +# define PREFIX "lib" +#endif + QString path = QCoreApplication::applicationDirPath() + "/" PREFIX "opentrack-proto-simconnect.dll"; QByteArray name = QFile::encodeName(path); actx.lpSource = name.constData(); hactctx = CreateActCtxA(&actx); @@ -194,6 +199,7 @@ bool FTNoIR_Protocol::checkServerInstallationOK() ActivationContext ctx(142 + act); + SCClientLib.setFileName("SimConnect.dll"); if (!SCClientLib.load()) { qDebug() << "SC load" << SCClientLib.errorString(); return false; diff --git a/ftnoir_protocol_sc/ftnoir_sccontrols.ui b/ftnoir_protocol_sc/ftnoir_sccontrols.ui index 17e94c4b..430b3912 100644 --- a/ftnoir_protocol_sc/ftnoir_sccontrols.ui +++ b/ftnoir_protocol_sc/ftnoir_sccontrols.ui @@ -9,8 +9,8 @@ 0 0 - 258 - 61 + 290 + 79 @@ -38,7 +38,7 @@ - Acceleration + SP1 @@ -46,6 +46,11 @@ SP2 + + + Acceleration + + diff --git a/ftnoir_protocol_sc/scserver-acceleration.manifest b/ftnoir_protocol_sc/scserver-acceleration.manifest new file mode 100644 index 00000000..06459587 --- /dev/null +++ b/ftnoir_protocol_sc/scserver-acceleration.manifest @@ -0,0 +1,13 @@ + + + + + + + + + + + + + -- cgit v1.2.3 From 6ed4a95ce604417f53b729cc4fa6d879cc95c901 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 2 Jan 2014 06:25:30 +0100 Subject: fix win32 native build by reordering headers --- FTNoIR_Tracker_PT/camera.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/FTNoIR_Tracker_PT/camera.cpp b/FTNoIR_Tracker_PT/camera.cpp index 5f6db57c..754533c5 100644 --- a/FTNoIR_Tracker_PT/camera.cpp +++ b/FTNoIR_Tracker_PT/camera.cpp @@ -5,6 +5,11 @@ * copyright notice and this permission notice appear in all copies. */ + #if defined(OPENTRACK_API) && defined(_WIN32) +#include +#include +#endif + #include "camera.h" #include #include @@ -15,11 +20,6 @@ using namespace cv; #include #endif -#if defined(OPENTRACK_API) && defined(_WIN32) -#include -#include -#endif - #ifdef OPENTRACK_API void get_camera_device_names(std::vector& device_names) { # if defined(_WIN32) -- 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(-) 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 7307adbc3b8ec2213bc90a91deb1beb9198e7ff2 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(-) 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 a97755aecdd6632b13f026e1a1e5cbc1cd18e22e Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 3 Jan 2014 12:55:00 +0100 Subject: fix build --- ftnoir_tracker_hatire/ftnoir_tracker_hat.rc | 61 ----------------------------- 1 file changed, 61 deletions(-) delete mode 100644 ftnoir_tracker_hatire/ftnoir_tracker_hat.rc diff --git a/ftnoir_tracker_hatire/ftnoir_tracker_hat.rc b/ftnoir_tracker_hatire/ftnoir_tracker_hat.rc deleted file mode 100644 index 62e0a613..00000000 --- a/ftnoir_tracker_hatire/ftnoir_tracker_hat.rc +++ /dev/null @@ -1,61 +0,0 @@ -// 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 - -- cgit v1.2.3 From 01b0a3bcfa48422289dab9df7af88eda52e80d9d Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 3 Jan 2014 20:47:55 +0100 Subject: initialize joylist in right order. pad out device list. --- ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp b/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp index 812ad454..a22c90f4 100644 --- a/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp +++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp @@ -19,7 +19,6 @@ TrackerControls::TrackerControls() : tracker(nullptr) connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); - tie_setting(s.joyid, ui.joylist); tie_setting(s.axis_0, ui.comboBox); tie_setting(s.axis_1, ui.comboBox_2); tie_setting(s.axis_2, ui.comboBox_3); @@ -45,6 +44,15 @@ fin: if (g_pDI) g_pDI->Release(); } + + for (int i = ui.joylist->count(); i < 8; i++) + { + GUID dummy = {0}; + guids.push_back(dummy); + ui.joylist->addItem("Nonexistent"); + } + + tie_setting(s.joyid, ui.joylist); } void TrackerControls::doOK() { -- cgit v1.2.3 From b0448c93ffe119c11042efa74c45aa7b4819a681 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 3 Jan 2014 20:59:59 +0100 Subject: use joystick friendly name for remembering it to avoid reorder issues --- ftnoir_tracker_joystick/ftnoir_tracker_joystick.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h index 162cbe48..bd261a25 100644 --- a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h +++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h @@ -45,7 +45,7 @@ struct settings { value axis_3; value axis_4; value axis_5; - value joyid; + value joyid; value* axes[6]; settings() : b(bundle("tracker-joystick")), -- cgit v1.2.3 From e81ddcffb98d8a20fe55bca5fea08e854d19ef06 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 3 Jan 2014 21:00:29 +0100 Subject: Padding no longer necessary. --- ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp | 7 ------- 1 file changed, 7 deletions(-) diff --git a/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp b/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp index a22c90f4..a089385f 100644 --- a/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp +++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp @@ -45,13 +45,6 @@ fin: g_pDI->Release(); } - for (int i = ui.joylist->count(); i < 8; i++) - { - GUID dummy = {0}; - guids.push_back(dummy); - ui.joylist->addItem("Nonexistent"); - } - tie_setting(s.joyid, ui.joylist); } -- 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(+) 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 fcbce27643f7017af6e9fc5affa39fc5e40643d7 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 3 Jan 2014 21:17:14 +0100 Subject: Store joystick selection as friendly name, not arbitrary device index --- ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp | 2 +- ftnoir_tracker_joystick/ftnoir_tracker_joystick.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp index 28fc034a..e605ea40 100644 --- a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp +++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp @@ -10,7 +10,7 @@ static BOOL CALLBACK EnumJoysticksCallback2( const DIDEVICEINSTANCE* pdidInstanc self->def = *pdidInstance; - return self->iter++ == self->s.joyid ? DIENUM_STOP : DIENUM_CONTINUE; + return QString(pdidInstance->tszInstanceName) == self->s.joyid ? DIENUM_STOP : DIENUM_CONTINUE; } FTNoIR_Tracker::FTNoIR_Tracker() : diff --git a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h index bd261a25..2f630d18 100644 --- a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h +++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h @@ -55,7 +55,7 @@ struct settings { axis_3(b, "axis-3", 0), axis_4(b, "axis-4", 0), axis_5(b, "axis-5", 0), - joyid(b, "joy-id", 0), + joyid(b, "joy-id", ""), axes{&axis_0, &axis_1, &axis_2, &axis_3, &axis_4, &axis_5} {} }; -- cgit v1.2.3 From df195bae5f406dace6fe23586165516ed8b95fc1 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 3 Jan 2014 21:24:28 +0100 Subject: nix unused member variable --- ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp | 1 - ftnoir_tracker_joystick/ftnoir_tracker_joystick.h | 1 - 2 files changed, 2 deletions(-) diff --git a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp index e605ea40..550e05c9 100644 --- a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp +++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp @@ -22,7 +22,6 @@ FTNoIR_Tracker::FTNoIR_Tracker() : for (int i = 0; i < 6; i++) *s.axes[i] = min_[i] = max_[i] = 0; GUID bar = {0}; - preferred = bar; } void FTNoIR_Tracker::reload() diff --git a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h index 2f630d18..0c2b3919 100644 --- a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h +++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h @@ -71,7 +71,6 @@ public: LPDIRECTINPUT8 g_pDI; LPDIRECTINPUTDEVICE8 g_pJoystick; int min_[8], max_[8]; - GUID preferred; QMutex mtx; QFrame* frame; DIDEVICEINSTANCE def; -- cgit v1.2.3 From 156676ade065f5d2634a0117372254ac4fb4629c Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 3 Jan 2014 22:14:24 +0100 Subject: simplify logic. remove incorrect setting reset --- .../ftnoir_tracker_joystick.cpp | 64 ++++++++++------------ ftnoir_tracker_joystick/ftnoir_tracker_joystick.h | 11 +--- 2 files changed, 29 insertions(+), 46 deletions(-) diff --git a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp index 550e05c9..f9789dce 100644 --- a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp +++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp @@ -1,18 +1,8 @@ #include "ftnoir_tracker_joystick.h" #include "facetracknoir/global-settings.h" #undef NDEBUG -#include #include -static BOOL CALLBACK EnumJoysticksCallback2( const DIDEVICEINSTANCE* pdidInstance, VOID* pContext ) -{ - auto self = ( FTNoIR_Tracker* )pContext; - - self->def = *pdidInstance; - - return QString(pdidInstance->tszInstanceName) == self->s.joyid ? DIENUM_STOP : DIENUM_CONTINUE; -} - FTNoIR_Tracker::FTNoIR_Tracker() : g_pDI(nullptr), g_pJoystick(nullptr), @@ -20,7 +10,7 @@ FTNoIR_Tracker::FTNoIR_Tracker() : mtx(QMutex::Recursive) { for (int i = 0; i < 6; i++) - *s.axes[i] = min_[i] = max_[i] = 0; + min_[i] = max_[i] = 0; GUID bar = {0}; } @@ -50,14 +40,16 @@ FTNoIR_Tracker::~FTNoIR_Tracker() g_pJoystick->Release(); } if (g_pDI) + { g_pDI->Release(); + } } static BOOL CALLBACK EnumObjectsCallback( const DIDEVICEOBJECTINSTANCE* pdidoi, VOID* pContext ) { auto self = (FTNoIR_Tracker*) pContext; - + // For axes that are returned, set the DIPROP_RANGE property for the // enumerated axis in order to scale min/max values. if( pdidoi->dwType & DIDFT_AXIS ) @@ -84,14 +76,16 @@ static BOOL CALLBACK EnumObjectsCallback( const DIDEVICEOBJECTINSTANCE* pdidoi, static BOOL CALLBACK EnumJoysticksCallback( const DIDEVICEINSTANCE* pdidInstance, VOID* pContext ) { - DI_ENUM_CONTEXT* pEnumContext = ( DI_ENUM_CONTEXT* )pContext; + auto self = reinterpret_cast(pContext); + bool stop = QString(pdidInstance->tszInstanceName) == self->s.joyid; - if (!IsEqualGUID(pEnumContext->preferred_instance, pdidInstance->guidInstance)) - return DIENUM_CONTINUE; + if (stop) + { + (void) self->g_pDI->CreateDevice( pdidInstance->guidInstance, &self->g_pJoystick, NULL); + qDebug() << "device" << static_cast(self->s.joyid); + } - (void) pEnumContext->g_pDI->CreateDevice( pdidInstance->guidInstance, pEnumContext->g_pJoystick, NULL); - - return DIENUM_STOP; + return stop ? DIENUM_STOP : DIENUM_CONTINUE; } void FTNoIR_Tracker::StartTracker(QFrame* frame) @@ -100,7 +94,6 @@ void FTNoIR_Tracker::StartTracker(QFrame* frame) this->frame = frame; iter = 0; auto hr = CoInitialize( nullptr ); - DI_ENUM_CONTEXT enumContext = {0}; if( FAILED( hr = DirectInput8Create( GetModuleHandle( NULL ), DIRECTINPUT_VERSION, IID_IDirectInput8, ( VOID** )&g_pDI, NULL ) ) ) @@ -108,9 +101,9 @@ void FTNoIR_Tracker::StartTracker(QFrame* frame) qDebug() << "create"; goto fail; } - - if( FAILED( hr = g_pDI->EnumDevices( DI8DEVCLASS_GAMECTRL, - EnumJoysticksCallback2, + + if( FAILED( hr = g_pDI->EnumDevices( DI8DEVCLASS_GAMECTRL, + EnumJoysticksCallback, this, DIEDFL_ATTACHEDONLY))) { @@ -118,19 +111,6 @@ void FTNoIR_Tracker::StartTracker(QFrame* frame) goto fail; } - enumContext.g_pDI = g_pDI; - enumContext.g_pJoystick = &g_pJoystick; - enumContext.preferred_instance = def.guidInstance; - - if( FAILED( hr = g_pDI->EnumDevices( DI8DEVCLASS_GAMECTRL, - EnumJoysticksCallback, - &enumContext, - DIEDFL_ATTACHEDONLY))) - { - qDebug() << "enum1"; - goto fail; - } - if (!g_pJoystick) { qDebug() << "ENODEV"; @@ -188,7 +168,10 @@ void FTNoIR_Tracker::GetHeadPoseData(double *data) for (int i = 0; hr == DIERR_INPUTLOST && i < 200; i++) hr = g_pJoystick->Acquire(); if (hr != DI_OK) + { + qDebug() << "joy read failure" << hr; return; + } } if( FAILED( hr = g_pJoystick->GetDeviceState( sizeof( js ), &js ) ) ) @@ -213,10 +196,19 @@ void FTNoIR_Tracker::GetHeadPoseData(double *data) 90, 180 }; + + int axes[] = { + s.axis_0, + s.axis_1, + s.axis_2, + s.axis_3, + s.axis_4, + s.axis_5 + }; for (int i = 0; i < 6; i++) { - auto idx = *s.axes[i] - 1; + auto idx = axes[i] - 1; if (idx < 0 || idx > 7) { data[i] = 0; diff --git a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h index 0c2b3919..06d06186 100644 --- a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h +++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h @@ -30,13 +30,6 @@ #include "facetracknoir/options.h" using namespace options; -struct DI_ENUM_CONTEXT -{ - GUID preferred_instance; - LPDIRECTINPUTDEVICE8* g_pJoystick; - LPDIRECTINPUT8 g_pDI; -}; - struct settings { pbundle b; value axis_0; @@ -46,7 +39,6 @@ struct settings { value axis_4; value axis_5; value joyid; - value* axes[6]; settings() : b(bundle("tracker-joystick")), axis_0(b, "axis-0", 0), @@ -55,8 +47,7 @@ struct settings { axis_3(b, "axis-3", 0), axis_4(b, "axis-4", 0), axis_5(b, "axis-5", 0), - joyid(b, "joy-id", ""), - axes{&axis_0, &axis_1, &axis_2, &axis_3, &axis_4, &axis_5} + joyid(b, "joy-id", "") {} }; -- 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(-) 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 58b4133cc98701b630286e53e37d4b540d9436f2 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 4 Jan 2014 09:07:35 +0100 Subject: initialize camera params in right order --- FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp index 25a19ee7..fad53d60 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp @@ -170,15 +170,14 @@ void Tracker::StartTracker(QFrame *parent_window) this->video_frame = parent_window; video_frame->setAttribute(Qt::WA_NativeWindow); video_frame->show(); - apply(s); video_widget = new PTVideoWidget(video_frame, this); QHBoxLayout* video_layout = new QHBoxLayout(parent_window); video_layout->setContentsMargins(0, 0, 0, 0); video_layout->addWidget(video_widget); video_frame->setLayout(video_layout); video_widget->resize(video_frame->width(), video_frame->height()); - start(); camera.start(); + apply(s); start(); reset_command(PAUSE); } -- cgit v1.2.3 From b66bf8bccc9a52d8c24763010567da8c083c482e Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 4 Jan 2014 13:26:04 +0100 Subject: PT: remove sleep interval The rationale is that camera blocks while the frame's being retrieved anyway. --- FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui | 161 +++++++++---------------- FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp | 43 +++---- FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.cpp | 1 - FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.h | 3 +- 4 files changed, 81 insertions(+), 127 deletions(-) diff --git a/FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui b/FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui index 6cd17e8d..ce708849 100644 --- a/FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui +++ b/FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui @@ -10,7 +10,7 @@ 0 0 459 - 590 + 621 @@ -66,105 +66,65 @@ Tracker Thread - - - - - - - - - Time until automatic reset of tracker's internal state when no valid tracking result is found - - - 9999 - - - - - - - ms - - - - - - - - - - - - - - - - - - - Dynamic Pose Resolution - - - - - - - Sleep time - - - sleep_spin - - - - - - - Auto-reset time - - - reset_spin - - - - - - - - - Time the tracker thread sleeps after each processed frame - - - - - - 9999 - - - - - - - ms - - - - - - - - - false - - - Reset the tracker's internal state - - - Reset - - - - + + + + + Auto-reset time + + + reset_spin + + + + + + + + 0 + 0 + + + + Time until automatic reset of tracker's internal state when no valid tracking result is found + + + ms + + + 9999 + + + + + + + Dynamic Pose Resolution + + + + + + + + + + + + + + + + + false + + + Reset the tracker's internal state + + + Reset + + @@ -1759,7 +1719,6 @@ tabWidget - sleep_spin reset_spin chkEnableRoll chkEnablePitch diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp index fad53d60..e8bc7208 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp @@ -70,31 +70,28 @@ void Tracker::run() bool new_frame; forever { - { - QMutexLocker lock(&mutex); - - 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()) - { - frame = frame_rotation.rotate_frame(frame); - const std::vector& points = point_extractor.extract_points(frame, dt, has_observers()); - tracking_valid = point_tracker.track(points, camera.get_info().f, dt); - video_widget->update_image(frame.clone()); - } + QMutexLocker lock(&mutex); + + 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()) + { + frame = frame_rotation.rotate_frame(frame); + const std::vector& points = point_extractor.extract_points(frame, dt, has_observers()); + tracking_valid = point_tracker.track(points, camera.get_info().f, dt); + video_widget->update_image(frame.clone()); + } #ifdef PT_PERF_LOG - log_stream<<"dt: "<addItem("90"); tie_setting(s.dyn_pose_res, ui.dynpose_check); - tie_setting(s.sleep_time, ui.sleep_spin); tie_setting(s.reset_time, ui.reset_spin); tie_setting(s.cam_index, ui.camdevice_combo); diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.h b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.h index a828ea48..564e1264 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.h +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.h @@ -36,7 +36,7 @@ struct settings value t_MH_x, t_MH_y, t_MH_z; - value sleep_time, reset_time; + value reset_time; value bEnableYaw, bEnablePitch, bEnableRoll; value bEnableX, bEnableY, bEnableZ; @@ -69,7 +69,6 @@ struct settings t_MH_x(b, "model-centroid-x", 0), t_MH_y(b, "model-centroid-y", 0), t_MH_z(b, "model-centroid-z", 0), - sleep_time(b, "sleep-time", 0), reset_time(b, "reset-time", 0), bEnableYaw(b, "enable-yaw", true), bEnablePitch(b, "enable-pitch", true), -- cgit v1.2.3 From 66466d0c30e7a2aed1a0c6c45db4b86dd5f0a99e Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 4 Jan 2014 13:26:11 +0100 Subject: PT: decruft MSVC --- FTNoIR_Tracker_PT/resource.h | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 FTNoIR_Tracker_PT/resource.h diff --git a/FTNoIR_Tracker_PT/resource.h b/FTNoIR_Tracker_PT/resource.h deleted file mode 100644 index c14e94ad..00000000 --- a/FTNoIR_Tracker_PT/resource.h +++ /dev/null @@ -1,14 +0,0 @@ -//{{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 -- cgit v1.2.3 From 8b845f242495a91aca45cd1bf59d1823517b32c8 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 4 Jan 2014 13:41:46 +0100 Subject: disable hysteresis debug; throttle frame update rate --- FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp | 4 ++-- FTNoIR_Tracker_PT/pt_video_widget.cpp | 13 +++++++++++-- FTNoIR_Tracker_PT/pt_video_widget.h | 11 +++++++++-- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp index e8bc7208..6bcad861 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp @@ -83,9 +83,9 @@ void Tracker::run() if (new_frame && !frame.empty()) { frame = frame_rotation.rotate_frame(frame); - const std::vector& points = point_extractor.extract_points(frame, dt, has_observers()); + const std::vector& points = point_extractor.extract_points(frame, dt, false); tracking_valid = point_tracker.track(points, camera.get_info().f, dt); - video_widget->update_image(frame.clone()); + video_widget->update_image(frame); } #ifdef PT_PERF_LOG log_stream<<"dt: "< rate) + { + _frame = frame.clone(); + update_throttler.restart(); + freshp = true; + } } // ---------------------------------------------------------------------------- @@ -42,8 +50,9 @@ VideoWidgetDialog::VideoWidgetDialog(QWidget *parent, FrameProvider* provider) void PTVideoWidget::update_and_repaint() { QMutexLocker foo(&mtx); - if (_frame.empty()) + if (_frame.empty() || !freshp) return; + freshp = false; QImage qframe = QImage(_frame.cols, _frame.rows, QImage::Format_RGB888); uchar* data = qframe.bits(); const int pitch = qframe.bytesPerLine(); diff --git a/FTNoIR_Tracker_PT/pt_video_widget.h b/FTNoIR_Tracker_PT/pt_video_widget.h index acff43fb..c47198db 100644 --- a/FTNoIR_Tracker_PT/pt_video_widget.h +++ b/FTNoIR_Tracker_PT/pt_video_widget.h @@ -24,15 +24,20 @@ #include #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) { + PTVideoWidget(QWidget *parent, FrameProvider* provider) : + QWidget(parent), + /* to avoid linker errors */ FrameObserver(provider), + freshp(false) + { connect(&timer, SIGNAL(timeout()), this, SLOT(update_and_repaint())); - timer.start(45); + timer.start(40); } void update_image(const cv::Mat &frame); void update_frame_and_points() {} @@ -48,6 +53,8 @@ private: QImage texture; QTimer timer; cv::Mat _frame; + QElapsedTimer update_throttler; + bool freshp; }; // ---------------------------------------------------------------------------- -- cgit v1.2.3 From 4bef8ec6aebad1b709efd7393cb9f4a63b28ebf3 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 4 Jan 2014 13:44:39 +0100 Subject: allow aruco to run at 180 hz --- ftnoir_tracker_aruco/aruco-trackercontrols.ui | 9 +++++++-- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 3 +++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ftnoir_tracker_aruco/aruco-trackercontrols.ui b/ftnoir_tracker_aruco/aruco-trackercontrols.ui index 3bf141de..3f5a1d2a 100644 --- a/ftnoir_tracker_aruco/aruco-trackercontrols.ui +++ b/ftnoir_tracker_aruco/aruco-trackercontrols.ui @@ -30,7 +30,7 @@ - -1 + 7 @@ -94,6 +94,11 @@ 120 + + + 180 + + @@ -186,7 +191,7 @@ - -1 + 7 6 diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index b4f35c6f..136a983a 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -157,6 +157,9 @@ void Tracker::run() case 3: fps = 120; break; + case 4: + fps = 180; + break; } camera = cv::VideoCapture(s.camera_index); if (r.width) -- cgit v1.2.3 From 2cc7ff7cb2346dcd2582aa3f18ff134c16c23e25 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 4 Jan 2014 13:45:58 +0100 Subject: default to 240Hz for PS3 eye users' sake --- ftnoir_tracker_base/ftnoir_tracker_base.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ftnoir_tracker_base/ftnoir_tracker_base.h b/ftnoir_tracker_base/ftnoir_tracker_base.h index b8e16e9d..8da72896 100644 --- a/ftnoir_tracker_base/ftnoir_tracker_base.h +++ b/ftnoir_tracker_base/ftnoir_tracker_base.h @@ -44,7 +44,7 @@ struct ITracker virtual ~ITracker() = 0; virtual void StartTracker( QFrame* frame ) = 0; virtual void GetHeadPoseData(double *data) = 0; - virtual int preferredHz() { return 66; } + virtual int preferredHz() { return 4; } }; inline ITracker::~ITracker() { } -- cgit v1.2.3 From be2911f415bd63e248476ebf9012fb4573a90dd7 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 4 Jan 2014 14:14:34 +0100 Subject: correct focal length equation --- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index 136a983a..19413e2f 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -212,8 +212,8 @@ void Tracker::run() const int scale = frame.cols > 480 ? 2 : 1; detector.setThresholdParams(scale > 1 ? 11 : 7, 4); - const float focal_length_w = 0.5 * grayscale.cols / tan(0.5 * s.fov * HT_PI / 180); - const float focal_length_h = 0.5 * grayscale.rows / tan(0.5 * s.fov * grayscale.rows / grayscale.cols * HT_PI / 180.0); + const float focal_length_w = 0.5 * grayscale.cols / tan(s.fov * HT_PI / 180); + const float focal_length_h = 0.5 * grayscale.rows / tan(s.fov * grayscale.rows / grayscale.cols * HT_PI / 180.0); cv::Mat intrinsics = cv::Mat::eye(3, 3, CV_32FC1); intrinsics.at (0, 0) = focal_length_w; intrinsics.at (1, 1) = focal_length_h; -- 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 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 8a6e59ec2be2a72fd4b009851d3241d663d8289f Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 4 Jan 2014 14:56:42 +0100 Subject: HT: allow for 187 fps with PS3 Eye --- ftnoir_tracker_ht/ftnoir_tracker_ht.cpp | 3 +++ ftnoir_tracker_ht/ht-trackercontrols.ui | 9 +++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp index 1773b018..5fced44e 100644 --- a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp +++ b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp @@ -106,6 +106,9 @@ void Tracker::load_settings(ht_config_t* config) case 3: nframes = 120; break; + case 4: + nframes = 180; + break; } config->classification_delay = 500; diff --git a/ftnoir_tracker_ht/ht-trackercontrols.ui b/ftnoir_tracker_ht/ht-trackercontrols.ui index 198cca7f..55501ef1 100644 --- a/ftnoir_tracker_ht/ht-trackercontrols.ui +++ b/ftnoir_tracker_ht/ht-trackercontrols.ui @@ -9,8 +9,8 @@ 0 0 - 527 - 144 + 531 + 166 @@ -166,6 +166,11 @@ 120 + + + 180 + + -- cgit v1.2.3 From ca76154afd3157bfb1d1f65082cb43a12c234547 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 4 Jan 2014 19:40:56 +0100 Subject: allow for changing centroid while software's running --- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 4 ++++ ftnoir_tracker_aruco/ftnoir_tracker_aruco.h | 1 + 2 files changed, 5 insertions(+) diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index 19413e2f..50496ed7 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -465,6 +465,8 @@ TrackerControls::TrackerControls() void TrackerControls::doOK() { s.b->save(); + if (tracker) + tracker->reload(); this->close(); } @@ -480,6 +482,8 @@ void TrackerControls::doCancel() case QMessageBox::Save: s.b->save(); this->close(); + if (tracker) + tracker->reload(); break; case QMessageBox::Discard: s.b->revert(); diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h index 2ff40c77..91a5ae8e 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h @@ -55,6 +55,7 @@ public: void StartTracker(QFrame* frame); void GetHeadPoseData(double *data); void run(); + void reload() { s.b->reload(); } private: QMutex mtx; volatile bool stop; -- 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(-) 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(-) 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 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 b9d3ebfb00bdda87715e99795176ee202a797147 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 5 Jan 2014 12:17:40 +0100 Subject: fix/reword the UI --- ftnoir_protocol_ft/ftnoir_ftcontrols.ui | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/ftnoir_protocol_ft/ftnoir_ftcontrols.ui b/ftnoir_protocol_ft/ftnoir_ftcontrols.ui index 39787d90..bd5980b4 100644 --- a/ftnoir_protocol_ft/ftnoir_ftcontrols.ui +++ b/ftnoir_protocol_ft/ftnoir_ftcontrols.ui @@ -12,8 +12,8 @@ 0 0 - 407 - 414 + 489 + 402 @@ -66,7 +66,7 @@ Qt::RightToLeft - TRViews + Memory hacks @@ -120,7 +120,7 @@ - Spawn a useless "dummy" process called TrackIR.exe in order to fool EZCA. + FSX-specific EZCA protocol hacks true @@ -147,17 +147,14 @@ false - - - QFormLayout::ExpandingFieldsGrow - + - Disable one of the protocols if games are confused by presence of both at the same time. + Disable one of the protocols if game is confused by presence of both at the same time. true @@ -195,7 +192,7 @@ - Replace the registry entry if you want to use other software with the TrackIR protocol and it doesn't work automatically. + Replace the registry entry if you want to use other software with the NPClient protocol and it doesn't work automatically. true -- 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(-) 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(+) 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(-) 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(-) 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(-) 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(-) 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 944051f3bac7a1c66fb309375d39007a06d6601f Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 5 Jan 2014 14:16:45 +0100 Subject: resize the UI to be more high-dpi friendly --- .../ftnoir_accela_filtercontrols.ui | 188 +++++++++++---------- 1 file changed, 97 insertions(+), 91 deletions(-) diff --git a/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui b/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui index ba750cd6..6111b3f9 100644 --- a/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui +++ b/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui @@ -47,11 +47,17 @@ - + + + 5 + + + 7 + - + 0 0 @@ -92,7 +98,7 @@ - + @@ -105,7 +111,7 @@ - + @@ -130,15 +136,22 @@ - + Order #2 - - + + + + Order #3 + + + + + 0 @@ -148,59 +161,53 @@ Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - QAbstractSpinBox::CorrectToPreviousValue - - 4 + 3 - 0.100000000000000 + 0.000000000000000 - 65535.000000000000000 + 3.000000000000000 + + + 0.050000000000000 - 1.000000000000000 + 0.000000000000000 - - + + - Order #3 + Exponent - - + + - + 0 0 - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - QAbstractSpinBox::CorrectToPreviousValue - - 4 + 3 - 0.100000000000000 + 0.050000000000000 - 65535.000000000000000 + 100.000000000000000 - - 1.000000000000000 + + 0.050000000000000 - + @@ -229,64 +236,7 @@ background:none; - - - - - 0 - 0 - - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - 3 - - - 0.000000000000000 - - - 3.000000000000000 - - - 0.050000000000000 - - - 0.000000000000000 - - - - - - - Exponent - - - - - - - - 0 - 0 - - - - 3 - - - 0.050000000000000 - - - 100.000000000000000 - - - 0.050000000000000 - - - - + @@ -331,7 +281,7 @@ background:none; - + @@ -344,6 +294,62 @@ background:none; + + + + + 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 + + + -- cgit v1.2.3 From db6be88b3a4ecded2f8434663fcf75b2c9e9b2ab Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 5 Jan 2014 14:19:56 +0100 Subject: Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index b8291699..fe5f5d1e 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,8 @@ movements and relaying them to games and flight simulation software. Not to be confused with railway planning software <> +See our wiki at <> + # Tracking sources - PointTracker by Patrick Ruoff, freetrack-like light sources -- cgit v1.2.3 From cf2b1e8a28a17de533da3fd4aeff35d8d11bdc6d Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 5 Jan 2014 14:27:45 +0100 Subject: Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fe5f5d1e..b549c00d 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ See our wiki at <> # Configuration **opentrack** offers output shaping, filtering, is buildable on -both MS Windows and GNU/Linux. +MS Windows MacOSX and GNU/Linux. Don't be afraid to submit an issue/feature request if the need arises. -- cgit v1.2.3 From 8f70d4c8eeaa6a9fbdb88ee85ebc82dacda86162 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 5 Jan 2014 14:27:57 +0100 Subject: Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b549c00d..f42684bb 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ See our wiki at <> # Configuration **opentrack** offers output shaping, filtering, is buildable on -MS Windows MacOSX and GNU/Linux. +MS Windows, MacOSX and GNU/Linux. Don't be afraid to submit an issue/feature request if the need arises. -- 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(-) 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(-) 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(+) 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(-) 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(-) 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 53b62eb2c7c8ffea2baecbb8e663a3c590604174 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 5 Jan 2014 19:13:30 +0100 Subject: guard against win32 cruft inclusion --- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index 2edac4a2..70c82c52 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -18,6 +18,7 @@ #include #if defined(_WIN32) +#define NOMINMAX # define NO_DSHOW_STRSAFE # include #else -- 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(-) 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 53275ebd1926c47794d54aab9dc7531abe878b11 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 5 Jan 2014 19:43:12 +0100 Subject: tweak the ransac coeff in futile attempt to make HT work properly --- ftnoir_tracker_ht/ftnoir_tracker_ht.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp index 4ce56acc..a133fd7a 100644 --- a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp +++ b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp @@ -115,17 +115,17 @@ void Tracker::load_settings(ht_config_t* config) config->field_of_view = s.fov; config->pyrlk_pyramids = 0; config->pyrlk_win_size_w = config->pyrlk_win_size_h = 21; - config->max_keypoints = 350; - config->keypoint_distance = 3.4; + config->max_keypoints = 300; + config->keypoint_distance = 3.2; config->force_fps = nframes; config->camera_index = s.camera_idx - 1; config->ransac_num_iters = 100; config->ransac_max_reprojection_error = 8; config->ransac_max_inlier_error = 8; - config->ransac_abs_max_mean_error = 20; + config->ransac_abs_max_mean_error = 16; config->ransac_max_mean_error = 6.5; config->debug = 0; - config->ransac_min_features = 0.72; + config->ransac_min_features = 0.83; int res = s.resolution; if (res < 0 || res >= (int)(sizeof(resolution_choices) / sizeof(resolution_tuple))) res = 0; -- cgit v1.2.3 From 477bf983513fca2674134953fe65d679fc280ab1 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 6 Jan 2014 15:35:14 +0100 Subject: tab order for ui --- ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui b/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui index 6111b3f9..54493041 100644 --- a/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui +++ b/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui @@ -352,6 +352,15 @@ background:none; + + rotation_alpha + translation_alpha + order_2nd + order_3rd + deadzone + expt + buttonBox + -- cgit v1.2.3 From 5f14d59ba285c72682e99c0fb95310f5920898de Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 6 Jan 2014 15:35:29 +0100 Subject: optimize existing pose when it makes sense --- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index 70c82c52..9c8cd52b 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -195,6 +195,7 @@ void Tracker::run() int cur_fps = 0; int last_fps = 0; cv::Point2f last_centroid; + bool first = true, pitch_sign = true; while (!stop) { @@ -318,7 +319,9 @@ void Tracker::run() last_roi.height = std::min(grayscale.rows - last_roi.y, last_roi.height); } - cv::solvePnP(obj_points, m, intrinsics, dist_coeffs, rvec, tvec, false, cv::ITERATIVE); + cv::solvePnP(obj_points, m, intrinsics, dist_coeffs, rvec, tvec, !first, cv::ITERATIVE); + + first = false; cv::Mat rotation_matrix = cv::Mat::zeros(3, 3, CV_64FC1); @@ -329,6 +332,12 @@ void Tracker::run() { cv::Vec3d euler = cv::RQDecomp3x3(rotation_matrix, junk1, junk2); + if ((euler[0] > 0) != pitch_sign) + { + first = true; + pitch_sign = euler[0] > 0; + } + QMutexLocker lck(&mtx); for (int i = 0; i < 3; i++) @@ -354,6 +363,7 @@ void Tracker::run() else { last_roi = cv::Rect(65535, 65535, 0, 0); + first = true; } if (frame.rows > 0) -- cgit v1.2.3 From 59d7366bcd79aa1bb4bb12876036a1c434683630 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 6 Jan 2014 17:44:21 +0100 Subject: fix Apple --- CMakeLists.txt | 18 ++++-------------- install-fail-tool | 6 +++--- 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 776473b6..149dfc21 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -308,21 +308,11 @@ if(WIN32) set(my-qt-deps ws2_32) endif() -if(APPLE) - link_directories(${CMAKE_INSTALL_PREFIX}) - set(maybe-hatire) - if(SDK_HATIRE) - set(maybe-hatire Qt5SerialPort) - endif() - set(MY_QT_LIBS Qt5Widgets Qt5Gui Qt5Network Qt5Xml Qt5Core ${maybe-hatire} ${my-qt-deps}) -else() - 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(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}) add_library(opentrack-csv SHARED ${opentrack-csv-c}) target_link_libraries(opentrack-csv ${MY_QT_LIBS}) diff --git a/install-fail-tool b/install-fail-tool index be80dd12..99f8fbdf 100755 --- a/install-fail-tool +++ b/install-fail-tool @@ -4,12 +4,12 @@ test -n "$1" || exit 1 dir="$1" -for i in "$dir"/*.dylib "$dir"/opentrack; do +for i in "$dir"/* "$dir"/*/*; do + { test -x "$i" && test -f "$i"; } || continue echo ---- $i ---- - install_name_tool -id "@executable_path/$(basename -- "$i")" "$i" - otool -L "$i" | awk '$1 ~ /\.dylib$/ { print $1 }' | + otool -L "$i" | awk '{ print $1 }' | while read l; do j="$(basename -- "$l")" if test -e "$dir/$j"; then -- cgit v1.2.3 From 55b133b78752137e05aa1437fbe9db83a7324d85 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 6 Jan 2014 17:47:19 +0100 Subject: aruco: allow for changing marker pitch --- ftnoir_tracker_aruco/aruco-trackercontrols.ui | 326 ++++++++++++++------------ ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 21 +- ftnoir_tracker_aruco/ftnoir_tracker_aruco.h | 4 +- 3 files changed, 189 insertions(+), 162 deletions(-) diff --git a/ftnoir_tracker_aruco/aruco-trackercontrols.ui b/ftnoir_tracker_aruco/aruco-trackercontrols.ui index 3f5a1d2a..e699eccc 100644 --- a/ftnoir_tracker_aruco/aruco-trackercontrols.ui +++ b/ftnoir_tracker_aruco/aruco-trackercontrols.ui @@ -32,158 +32,6 @@ 7 - - - - - - - Frames per second - - - - - - - - - - 35.000000000000000 - - - 180.000000000000000 - - - 52.000000000000000 - - - - - - - Recommended! - - - - - - - Camera name - - - - - - - - Default - - - - - 30 - - - - - 60 - - - - - 120 - - - - - 180 - - - - - - - - - 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 - - - - - - - - 640x480 - - - - - 320x240 - - - - - 320x200 - - - - - Default (not recommended!) - - - - - - - - Red channel only - - - - - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - Horizontal FOV - - - - - - - Resolution - - - @@ -250,7 +98,7 @@ - + Head position @@ -331,6 +179,175 @@ + + + + + + + + + + 35.000000000000000 + + + 180.000000000000000 + + + 52.000000000000000 + + + + + + + Recommended! + + + + + + + Frames per second + + + + + + + + 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 + + + + + 180 + + + + + + + + + 640x480 + + + + + 320x240 + + + + + 320x200 + + + + + Default (not recommended!) + + + + + + + + Camera name + + + + + + + Red channel only + + + + + + + Horizontal FOV + + + + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + Resolution + + + + + + + Marker pitch + + + + + + + -180.000000000000000 + + + 180.000000000000000 + + + @@ -338,6 +355,8 @@ cameraFPS cameraName resolution + red_only + marker_pitch cx cy cz @@ -347,6 +366,7 @@ tx ty tz + buttonBox diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index 9c8cd52b..776d443a 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -282,19 +282,23 @@ void Tracker::run() const aruco::Marker& m = markers.at(0); const float size = 7; + const double p = s.marker_pitch; + const double sq = sin(p * HT_PI / 180); + const double cq = cos(p * HT_PI / 180); + cv::Mat obj_points(4,3,CV_32FC1); obj_points.at(1,0)=-size + s.headpos_x; - obj_points.at(1,1)=-size + s.headpos_y; - obj_points.at(1,2)=0 + s.headpos_z; + obj_points.at(1,1)=-size * cq + s.headpos_y; + obj_points.at(1,2)=-size * sq + s.headpos_z; obj_points.at(2,0)=size + s.headpos_x; - obj_points.at(2,1)=-size + s.headpos_y; - obj_points.at(2,2)=0 + s.headpos_z; + obj_points.at(2,1)=-size * cq + s.headpos_y; + obj_points.at(2,2)=-size * sq + s.headpos_z; obj_points.at(3,0)=size + s.headpos_x; - obj_points.at(3,1)=size + s.headpos_y; - obj_points.at(3,2)=0 + s.headpos_z; + obj_points.at(3,1)=size * cq + s.headpos_y; + obj_points.at(3,2)=size * sq + s.headpos_z; obj_points.at(0,0)=-size + s.headpos_x; - obj_points.at(0,1)=size + s.headpos_y; - obj_points.at(0,2)=0 + s.headpos_z; + obj_points.at(0,1)=size * cq + s.headpos_y; + obj_points.at(0,2)=size * sq + s.headpos_z; last_roi = cv::Rect(65535, 65535, 0, 0); @@ -468,6 +472,7 @@ TrackerControls::TrackerControls() tie_setting(s.headpos_y, ui.cy); tie_setting(s.headpos_z, ui.cz); tie_setting(s.red_only, ui.red_only); + tie_setting(s.marker_pitch, ui.marker_pitch); connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); ui.cameraName->addItems(get_camera_names()); diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h index 91a5ae8e..4cab84b5 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h @@ -27,6 +27,7 @@ struct settings { value camera_index, force_fps, resolution; value red_only; value eyaw, epitch, eroll, ex, ey, ez; + value marker_pitch; settings() : b(bundle("aruco-tracker")), fov(b, "field-of-view", 56), @@ -42,7 +43,8 @@ struct settings { eroll(b, "enable-r", true), ex(b, "enable-x", true), ey(b, "enable-y", true), - ez(b, "enable-z", true) + ez(b, "enable-z", true), + marker_pitch(b, "marker-pitch", 0) {} }; -- 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(-) 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 2a7bb33871dee1124dd1956fe14503845e8cee3f Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 6 Jan 2014 23:45:43 +0100 Subject: aruco: allow for perfect fisheye correction --- ftnoir_tracker_aruco/aruco-trackercontrols.ui | 455 +++++++++++++------------- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 18 +- ftnoir_tracker_aruco/ftnoir_tracker_aruco.h | 4 +- 3 files changed, 249 insertions(+), 228 deletions(-) diff --git a/ftnoir_tracker_aruco/aruco-trackercontrols.ui b/ftnoir_tracker_aruco/aruco-trackercontrols.ui index e699eccc..7dadb58c 100644 --- a/ftnoir_tracker_aruco/aruco-trackercontrols.ui +++ b/ftnoir_tracker_aruco/aruco-trackercontrols.ui @@ -10,7 +10,7 @@ 0 0 630 - 315 + 326 @@ -32,169 +32,42 @@ 7 - - - - Enable axes - - - - 7 + + + + + + + + Default - - 6 + + + + 30 - - 0 + + + + 60 - - 6 + + + + 120 - - 0 + + + + 180 - - - - RX - - - - - - - TX - - - - - - - RY - - - - - - - TY - - - - - - - RZ - - - - - - - TZ - - - - - - - - - - Head position - - - Qt::AlignCenter - - - - - - TX - - - - - - - - 0 - 0 - - - - -200.000000000000000 - - - 200.000000000000000 - - - - - - - TY - - - - - - - - 0 - 0 - - - - -200.000000000000000 - - - 200.000000000000000 - - - - - - - TZ - - - - - - - - 0 - 0 - - - - -200.000000000000000 - - - 200.000000000000000 - - - - + - - - - - - - - - - 35.000000000000000 - - - 180.000000000000000 - - - 52.000000000000000 + + + + Frames per second @@ -205,14 +78,7 @@ - - - - Frames per second - - - - + @@ -243,33 +109,41 @@ - - - - - Default - - - - - 30 - - - - - 60 - - - - - 120 - - - - - 180 - - + + + + + + + 35.000000000000000 + + + 180.000000000000000 + + + 52.000000000000000 + + + + + + + Camera name + + + + + + + Red channel only + + + + + + + Horizontal FOV + @@ -296,28 +170,7 @@ - - - - Camera name - - - - - - - Red channel only - - - - - - - Horizontal FOV - - - - + QDialogButtonBox::Cancel|QDialogButtonBox::Ok @@ -331,6 +184,16 @@ + + + + -180.000000000000000 + + + 180.000000000000000 + + + @@ -338,13 +201,164 @@ - - - - -180.000000000000000 + + + + Head position - - 180.000000000000000 + + Qt::AlignCenter + + + + + + TY + + + + + + + TX + + + + + + + + 0 + 0 + + + + -200.000000000000000 + + + 200.000000000000000 + + + + + + + TZ + + + + + + + + 0 + 0 + + + + -200.000000000000000 + + + 200.000000000000000 + + + + + + + + 0 + 0 + + + + -200.000000000000000 + + + 200.000000000000000 + + + + + + + + + + Enable axes + + + + 7 + + + 6 + + + 0 + + + 6 + + + 0 + + + + + RX + + + + + + + TX + + + + + + + RY + + + + + + + TY + + + + + + + RZ + + + + + + + TZ + + + + + + + + + + Check if yaw/X interconnect + + + + + + + Fisheye correction @@ -357,6 +371,7 @@ resolution red_only marker_pitch + fisheye_correction cx cy cz diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index 776d443a..67c88e3e 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -18,7 +18,8 @@ #include #if defined(_WIN32) -#define NOMINMAX +# undef NOMINMAX +# define NOMINMAX # define NO_DSHOW_STRSAFE # include #else @@ -322,17 +323,13 @@ void Tracker::run() last_roi.width = std::min(grayscale.cols - last_roi.x, last_roi.width); last_roi.height = std::min(grayscale.rows - last_roi.y, last_roi.height); } - - cv::solvePnP(obj_points, m, intrinsics, dist_coeffs, rvec, tvec, !first, cv::ITERATIVE); + cv::solvePnP(obj_points, m, intrinsics, dist_coeffs, rvec, tvec, !first, cv::ITERATIVE); first = false; - cv::Mat rotation_matrix = cv::Mat::zeros(3, 3, CV_64FC1); - cv::Mat junk1(3, 3, CV_64FC1), junk2(3, 3, CV_64FC1); - cv::Rodrigues(rvec, rotation_matrix); - + { cv::Vec3d euler = cv::RQDecomp3x3(rotation_matrix, junk1, junk2); @@ -350,6 +347,12 @@ void Tracker::run() pose[Yaw] = euler[1]; pose[Pitch] = -euler[0]; pose[Roll] = euler[2]; + + if (s.fisheye_correction) + { + pose[Yaw] -= atan(pose[TX] / pose[TZ]) * 180 / HT_PI; + pose[Pitch] -= atan(pose[TY] / pose[TZ]) * 180 / HT_PI; + } } std::vector repr2; @@ -473,6 +476,7 @@ TrackerControls::TrackerControls() tie_setting(s.headpos_z, ui.cz); tie_setting(s.red_only, ui.red_only); tie_setting(s.marker_pitch, ui.marker_pitch); + tie_setting(s.fisheye_correction, ui.fisheye_correction); connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); ui.cameraName->addItems(get_camera_names()); diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h index 4cab84b5..e32e304a 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h @@ -28,6 +28,7 @@ struct settings { value red_only; value eyaw, epitch, eroll, ex, ey, ez; value marker_pitch; + value fisheye_correction; settings() : b(bundle("aruco-tracker")), fov(b, "field-of-view", 56), @@ -44,7 +45,8 @@ struct settings { ex(b, "enable-x", true), ey(b, "enable-y", true), ez(b, "enable-z", true), - marker_pitch(b, "marker-pitch", 0) + marker_pitch(b, "marker-pitch", 0), + fisheye_correction(b, "fisheye-correction", false) {} }; -- cgit v1.2.3 From f5496ba4712f16244b8ab8dc90253e19ef1ad54f Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 6 Jan 2014 23:51:31 +0100 Subject: treat pitch delta +- 60 as breakage, instead of sign change --- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index 67c88e3e..bb4ca96f 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -196,7 +196,9 @@ void Tracker::run() int cur_fps = 0; int last_fps = 0; cv::Point2f last_centroid; - bool first = true, pitch_sign = true; + const double pitch_eps = 60; + double last_pitch = 0; + bool first = true; while (!stop) { @@ -333,10 +335,11 @@ void Tracker::run() { cv::Vec3d euler = cv::RQDecomp3x3(rotation_matrix, junk1, junk2); - if ((euler[0] > 0) != pitch_sign) + if (fabs(euler[0] - last_pitch) > pitch_eps) { first = true; - pitch_sign = euler[0] > 0; + last_pitch = euler[0]; + qDebug() << "reset levmarq due to pitch breakage"; } QMutexLocker lck(&mtx); -- cgit v1.2.3 From 1f258153f00ed0427a77077775274acd17a9fbe4 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 6 Jan 2014 23:52:39 +0100 Subject: resize --- ftnoir_tracker_aruco/aruco-trackercontrols.ui | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ftnoir_tracker_aruco/aruco-trackercontrols.ui b/ftnoir_tracker_aruco/aruco-trackercontrols.ui index 7dadb58c..59d3f69c 100644 --- a/ftnoir_tracker_aruco/aruco-trackercontrols.ui +++ b/ftnoir_tracker_aruco/aruco-trackercontrols.ui @@ -9,8 +9,8 @@ 0 0 - 630 - 326 + 615 + 353 -- cgit v1.2.3 From a7ea46dca6e791b1c6785e270b5d6fbe42f449dc Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 7 Jan 2014 07:29:00 +0100 Subject: reduce pitch reset thres to 45 deg --- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index bb4ca96f..0719faac 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -196,7 +196,7 @@ void Tracker::run() int cur_fps = 0; int last_fps = 0; cv::Point2f last_centroid; - const double pitch_eps = 60; + const double pitch_eps = 45; double last_pitch = 0; bool first = true; -- cgit v1.2.3 From cc4e7e331ba24b260edc44db8b09de274cd658a7 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 7 Jan 2014 09:00:57 +0100 Subject: pose breaks with negative pitch --- FTNoIR_Tracker_PT/point_tracker.cpp | 4 ++-- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/FTNoIR_Tracker_PT/point_tracker.cpp b/FTNoIR_Tracker_PT/point_tracker.cpp index 8b508897..dfefdaf8 100644 --- a/FTNoIR_Tracker_PT/point_tracker.cpp +++ b/FTNoIR_Tracker_PT/point_tracker.cpp @@ -267,8 +267,8 @@ int PointTracker::POSIT(float f) // initial pose = last (predicted) pose Vec3f k; - get_row(X_CM.R, 2, k); - float Z0 = X_CM.t[2]; + get_row(R_expected, 2, k); + float Z0 = init_phase ? 1000 : X_CM.t[2]; float old_epsilon_1 = 0; float old_epsilon_2 = 0; diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index 0719faac..93b43de7 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -335,7 +335,7 @@ void Tracker::run() { cv::Vec3d euler = cv::RQDecomp3x3(rotation_matrix, junk1, junk2); - if (fabs(euler[0] - last_pitch) > pitch_eps) + if (fabs(euler[0] - last_pitch) > pitch_eps || euler[0] < 0) { first = true; last_pitch = euler[0]; -- cgit v1.2.3 From 72c99ae7a23a05bf64412f0c271c94a9672d5bc1 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 7 Jan 2014 09:07:54 +0100 Subject: include .hpp in source list --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 149dfc21..7b29008b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -197,7 +197,7 @@ function(link_with_dinput8 n) endfunction() macro(opentrack_module n dir) - file(GLOB ${n}-c "${dir}/*.cpp" "${dir}/*.h" "${dir}/*.rc" ${EXTRA-MOCS}) + file(GLOB ${n}-c "${dir}/*.cpp" "${dir}/*.h" "${dir}/*.rc" "${dir}/*.hpp" ${EXTRA-MOCS}) file(GLOB ${n}-ui "${dir}/*.ui") file(GLOB ${n}-rc "${dir}/*.qrc") QT5_WRAP_UI(${n}-uih ${${n}-ui}) -- cgit v1.2.3 From aaf0dba05d00d3c38eb4fe78a092216a991495fd Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 7 Jan 2014 09:24:48 +0100 Subject: use subpixel corner opt to reduce filter need --- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index 93b43de7..823c5578 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -282,7 +282,13 @@ void Tracker::run() cv::putText(frame, buf, cv::Point(10, 54), cv::FONT_HERSHEY_PLAIN, scale, cv::Scalar(80, 255, 0), scale); if (markers.size() == 1 && markers[0].size() == 4) { - const aruco::Marker& m = markers.at(0); + const aruco::Marker& m = static_cast>(markers.at(0)); + cv::cornerSubPix(grayscale, + m, + cv::Size(5, 5), cv::Size(-1, -1), + cv::TermCriteria(cv::TermCriteria::MAX_ITER | cv::TermCriteria::EPS, + 10, + 1e-2)); const float size = 7; const double p = s.marker_pitch; -- cgit v1.2.3 From 9b42cf232a918987d675cdf041e49c73e597b110 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 8 Jan 2014 17:12:37 +0100 Subject: fix hyst slider --- FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui | 3 +++ 1 file changed, 3 insertions(+) diff --git a/FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui b/FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui index 9f00cf29..db7a5998 100644 --- a/FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui +++ b/FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui @@ -766,6 +766,9 @@ 255 + + 1 + 100 -- 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(-) 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 98facf366f9e5100cbd8da4e55c10029be73d4e3 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 8 Jan 2014 18:01:35 +0100 Subject: apply -> save, that's what it actually does --- FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui b/FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui index db7a5998..bdbed955 100644 --- a/FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui +++ b/FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui @@ -1679,7 +1679,7 @@ - Apply + Save -- cgit v1.2.3 From f653bffa5f3422f8eb5f29e49d5b0d45b76047a2 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 8 Jan 2014 18:02:40 +0100 Subject: add credit to stargazer for awesome, countless bug reports Signed-off-by: Stanislaw Halik --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index f42684bb..6a8a61f0 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,7 @@ Don't be afraid to submit an issue/feature request if the need arises. - Patrick Ruoff (PT tracker) - FuraX49 (hatire arduino tracker) - Ulf Schreiber (PT tracker) +- George Trigonakis (tester) - Wim Vriend (historically) - Ron Hendriks (historically) -- cgit v1.2.3 From 267010ba42b00cfd1ecc73c86d99c647ff191175 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 8 Jan 2014 19:40:06 +0100 Subject: use levmarq instead of coplanar POSIT implemented in numerically unstable fashion Signed-off-by: Stanislaw Halik --- FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui | 13 +- FTNoIR_Tracker_PT/camera.cpp | 8 +- FTNoIR_Tracker_PT/camera.h | 6 +- FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp | 4 +- FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.cpp | 2 +- FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.h | 4 +- FTNoIR_Tracker_PT/point_tracker.cpp | 191 ++++++------------------- FTNoIR_Tracker_PT/point_tracker.h | 33 ++++- 8 files changed, 92 insertions(+), 169 deletions(-) diff --git a/FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui b/FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui index bdbed955..461253cf 100644 --- a/FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui +++ b/FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui @@ -515,23 +515,26 @@ - F/W + FOV - f_dspin + fov_dspin - + The camera's focal length devided by its sensor width 2 + + 1.000000000000000 + - 0.100000000000000 + 1.000000000000000 @@ -1733,7 +1736,7 @@ res_x_spin res_y_spin fps_spin - f_dspin + fov_dspin camroll_combo campitch_spin camyaw_spin diff --git a/FTNoIR_Tracker_PT/camera.cpp b/FTNoIR_Tracker_PT/camera.cpp index 754533c5..8986be60 100644 --- a/FTNoIR_Tracker_PT/camera.cpp +++ b/FTNoIR_Tracker_PT/camera.cpp @@ -108,11 +108,11 @@ void Camera::set_device_index(int index) } } -void Camera::set_f(float f) +void Camera::set_fov(float f) { - if (cam_desired.f != f) + if (cam_desired.fov != f) { - cam_desired.f = f; + cam_desired.fov = f; _set_f(); } } @@ -208,7 +208,7 @@ void CVCamera::_set_index() void CVCamera::_set_f() { - cam_info.f = cam_desired.f; + cam_info.fov = cam_desired.fov; } void CVCamera::_set_fps() diff --git a/FTNoIR_Tracker_PT/camera.h b/FTNoIR_Tracker_PT/camera.h index ea68c387..6768e419 100644 --- a/FTNoIR_Tracker_PT/camera.h +++ b/FTNoIR_Tracker_PT/camera.h @@ -25,12 +25,12 @@ void get_camera_device_names(std::vector& device_names); // ---------------------------------------------------------------------------- struct CamInfo { - CamInfo() : res_x(0), res_y(0), fps(0), f(1) {} + CamInfo() : res_x(0), res_y(0), fps(0), fov(56) {} int res_x; int res_y; int fps; - float f; // (focal length) / (sensor width) + float fov; }; // ---------------------------------------------------------------------------- @@ -48,7 +48,7 @@ public: // calls corresponding template methods and reinitializes frame rate calculation void set_device_index(int index); - void set_f(float f); + void set_fov(float f); void set_fps(int fps); void set_res(int x_res, int y_res); diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp index 6bcad861..a3e8919b 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp @@ -84,7 +84,7 @@ void Tracker::run() { frame = frame_rotation.rotate_frame(frame); const std::vector& points = point_extractor.extract_points(frame, dt, false); - tracking_valid = point_tracker.track(points, camera.get_info().f, dt); + tracking_valid = point_tracker.track(points, camera.get_info().fov, dt, frame.cols, frame.rows, t_MH); video_widget->update_image(frame); } #ifdef PT_PERF_LOG @@ -104,7 +104,7 @@ void Tracker::apply(settings& s) camera.set_device_index(s.cam_index); camera.set_res(s.cam_res_x, s.cam_res_y); camera.set_fps(s.cam_fps); - camera.set_f(s.cam_f); + camera.set_fov(s.cam_fov); frame_rotation.rotation = static_cast(static_cast(s.cam_roll)); point_extractor.threshold_val = s.threshold; point_extractor.threshold_secondary_val = s.threshold_secondary; diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.cpp b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.cpp index c103b78c..4ae20f48 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.cpp +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.cpp @@ -46,7 +46,7 @@ TrackerDialog::TrackerDialog() tie_setting(s.reset_time, ui.reset_spin); tie_setting(s.cam_index, ui.camdevice_combo); - tie_setting(s.cam_f, ui.f_dspin); + tie_setting(s.cam_fov, ui.fov_dspin); tie_setting(s.cam_res_x, ui.res_x_spin); tie_setting(s.cam_res_y, ui.res_y_spin); tie_setting(s.cam_fps, ui.fps_spin); diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.h b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.h index 564e1264..e0dfa2e6 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.h +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.h @@ -28,7 +28,7 @@ struct settings threshold_secondary, min_point_size, max_point_size; - value cam_f; + value cam_fov; value m01_x, m01_y, m01_z; value m02_x, m02_y, m02_z; @@ -57,7 +57,7 @@ struct settings threshold_secondary(b, "threshold-secondary", 128), min_point_size(b, "min-point-size", 10), max_point_size(b, "max-point-size", 50), - cam_f(b, "camera-focal-length", 1), + cam_fov(b, "camera-fov", 56), m01_x(b, "m_01-x", 0), m01_y(b, "m_01-y", 0), m01_z(b, "m_01-z", 0), diff --git a/FTNoIR_Tracker_PT/point_tracker.cpp b/FTNoIR_Tracker_PT/point_tracker.cpp index dfefdaf8..1df70b17 100644 --- a/FTNoIR_Tracker_PT/point_tracker.cpp +++ b/FTNoIR_Tracker_PT/point_tracker.cpp @@ -17,23 +17,6 @@ using namespace cv; using namespace boost; 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), @@ -108,9 +91,11 @@ PointTracker::PointTracker() dt_reset(1), v_t(0,0,0), v_r(0,0,0), - dynamic_pose_resolution(true) + dynamic_pose_resolution(true), + fov(0), + _w(0), + _h(0) { - X_CM.t[2] = 1000; // default position: 1 m away from cam; } void PointTracker::reset() @@ -128,7 +113,7 @@ void PointTracker::reset_velocities() } -bool PointTracker::track(const vector& points, float f, float dt) +bool PointTracker::track(const vector& points, float fov, float dt, int w, int h, const cv::Vec3f& headpos) { if (!dynamic_pose_resolution) init_phase = true; @@ -140,12 +125,7 @@ bool PointTracker::track(const vector& points, float f, float dt) reset(); } - bool no_model = -#ifdef OPENTRACK_API - point_model.get() == NULL; -#else - !point_model; -#endif + bool no_model = !point_model; // if there is a pointtracking problem, reset the velocities if (no_model || points.size() != PointModel::N_POINTS) @@ -161,7 +141,7 @@ bool PointTracker::track(const vector& points, float f, float dt) predict(dt_valid); // if there is a point correspondence problem something has gone wrong, do a reset - if (!find_correspondences(points, f)) + if (!find_correspondences(points)) { //qDebug()<<"Error in finding point correspondences!"; X_CM = X_CM_old; // undo prediction @@ -169,7 +149,8 @@ bool PointTracker::track(const vector& points, float f, float dt) return false; } - int n_iter = POSIT(f); + // XXX TODO fov + POSIT(fov, w, h, headpos); //qDebug()<<"Number of POSIT iterations: "<& points, float f) +bool PointTracker::find_correspondences(const vector& points) { if (init_phase) { // We do a simple freetrack-like sorting in the init phase... @@ -215,9 +196,9 @@ bool PointTracker::find_correspondences(const vector& points, float f) 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); + p_exp[0] = project(Vec3f(0,0,0)); + p_exp[1] = project(point_model->M01); + p_exp[2] = project(point_model->M02); // set correspondences by minimum distance to projected model point bool point_taken[PointModel::N_POINTS]; @@ -251,130 +232,48 @@ bool PointTracker::find_correspondences(const vector& points, float f) -int PointTracker::POSIT(float f) +void PointTracker::POSIT(float fov, int w, int h, const cv::Vec3f& headpos) { - // POSIT algorithm for coplanar points as presented in - // [Denis Oberkampf, Daniel F. DeMenthon, Larry S. Davis: "Iterative Pose Estimation Using Coplanar Feature Points"] - // we use the same notation as in the paper here - - // The expected rotation used for resolving the ambiguity in POSIT: - // In every iteration step the rotation closer to R_expected is taken - Matx33f R_expected; - if (init_phase) - R_expected = Matx33f::eye(); // in the init phase, we want to be close to the default pose = no rotation - else - R_expected = X_CM.R; // later we want to be close to the last (predicted) rotation - - // initial pose = last (predicted) pose - Vec3f k; - get_row(R_expected, 2, k); - float Z0 = init_phase ? 1000 : X_CM.t[2]; - - float old_epsilon_1 = 0; - float old_epsilon_2 = 0; - float epsilon_1 = 1; - float epsilon_2 = 1; - - Vec3f I0, J0; - Vec2f I0_coeff, J0_coeff; - - Vec3f I_1, J_1, I_2, J_2; - Matx33f R_1, R_2; - Matx33f* R_current; - - const int MAX_ITER = 100; - const float EPS_THRESHOLD = 1e-4; - - int i=1; - for (; 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; - } + // XXX hack + this->fov = fov; + _w = w; + _h = h; + std::vector obj_points; + std::vector img_points; - // construct the two solutions - I_1 = I0 + rho*cos(theta)*point_model->u; - I_2 = I0 - rho*cos(theta)*point_model->u; + obj_points.push_back(headpos); + obj_points.push_back(point_model->M01 + headpos); + obj_points.push_back(point_model->M02 + headpos); - J_1 = J0 + rho*sin(theta)*point_model->u; - J_2 = J0 - rho*sin(theta)*point_model->u; + img_points.push_back(p[0]); + img_points.push_back(p[1]); + img_points.push_back(p[2]); - 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; + const float HT_PI = 3.1415926535; - 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)); + const float focal_length_w = 0.5 * w / tan(fov * HT_PI / 180); + const float focal_length_h = 0.5 * h / tan(fov * h / w * HT_PI / 180.0); - // the single translation solution - Z0 = norm_const * f; + cv::Mat intrinsics = cv::Mat::eye(3, 3, CV_32FC1); + intrinsics.at (0, 0) = focal_length_w; + intrinsics.at (1, 1) = focal_length_h; + intrinsics.at (0, 2) = w/2; + intrinsics.at (1, 2) = h/2; - // 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()); + cv::Mat dist_coeffs = cv::Mat::zeros(5, 1, CV_32FC1); - if (R_1_deviation < R_2_deviation) - R_current = &R_1; - else - R_current = &R_2; + bool lastp = !rvec.empty() && !tvec.empty() && !init_phase; - get_row(*R_current, 2, k); + cv::solvePnP(obj_points, img_points, intrinsics, dist_coeffs, rvec, tvec, lastp, cv::ITERATIVE); - // 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; - } + cv::Mat rmat; + cv::Rodrigues(rvec, rmat); // 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: "<(i); + for (int j = 0; j < 3; j++) + X_CM.R(i, j) = rmat.at(i, j); + } } diff --git a/FTNoIR_Tracker_PT/point_tracker.h b/FTNoIR_Tracker_PT/point_tracker.h index 11034100..e05e8f98 100644 --- a/FTNoIR_Tracker_PT/point_tracker.h +++ b/FTNoIR_Tracker_PT/point_tracker.h @@ -90,7 +90,7 @@ public: // 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); + bool track(const std::vector& points, float fov, float dt, int w, int h, const cv::Vec3f &headpos); boost::shared_ptr point_model; bool dynamic_pose_resolution; @@ -98,15 +98,35 @@ public: FrameTrafo get_pose() const { return X_CM; } void reset(); + float fov; + int _w, _h; protected: - inline cv::Vec2f project(const cv::Vec3f& v_M, float f) + cv::Vec2f project(const cv::Vec3f& v_M) { - 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]); + if (!rvec.empty() && !tvec.empty() && fov > 0) + { + const float HT_PI = 3.1415926535; + const int w = _w, h = _h; + const float focal_length_w = 0.5 * w / tan(fov * HT_PI / 180); + const float focal_length_h = 0.5 * h / tan(fov * h / w * HT_PI / 180.0); + + cv::Mat intrinsics = cv::Mat::eye(3, 3, CV_32FC1); + intrinsics.at (0, 0) = focal_length_w; + intrinsics.at (1, 1) = focal_length_h; + intrinsics.at (0, 2) = w/2; + intrinsics.at (1, 2) = h/2; + std::vector xs; + xs.push_back(v_M); + cv::Mat dist_coeffs = cv::Mat::zeros(5, 1, CV_32FC1); + std::vector rets(1); + cv::projectPoints(xs, rvec, tvec, intrinsics, dist_coeffs, rets); + return rets[0]; + } + return cv::Vec2f(); } - bool find_correspondences(const std::vector& points, float f); + bool find_correspondences(const std::vector& points); cv::Vec2f p[PointModel::N_POINTS]; // the points in model order cv::Vec2f p_exp[PointModel::N_POINTS]; // the expected point positions @@ -116,7 +136,7 @@ protected: void reset_velocities(); - int POSIT(float f); // The POSIT algorithm, returns the number of iterations + void POSIT(float fov, int w, int h, const cv::Vec3f &headpos); // The POSIT algorithm, returns the number of iterations bool init_phase; float dt_valid; // time since last valid tracking result @@ -124,6 +144,7 @@ protected: cv::Vec3f v_r; FrameTrafo X_CM; // trafo from model to camera FrameTrafo X_CM_old; + cv::Mat rvec, tvec; }; #endif //POINTTRACKER_H -- cgit v1.2.3 From a6bb6becb0365f2dc79a24d0e3979d42f1496a21 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 8 Jan 2014 19:40:17 +0100 Subject: remove redundant initialization --- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index 823c5578..6935dd43 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -226,10 +226,7 @@ void Tracker::run() intrinsics.at (1, 2) = grayscale.rows/2; cv::Mat dist_coeffs = cv::Mat::zeros(5, 1, CV_32FC1); - - for (int i = 0; i < 5; i++) - dist_coeffs.at(i) = 0; - + std::vector< aruco::Marker > markers; const double size_min = 0.04; -- cgit v1.2.3 From 0a32ae32452b02fae0036f9c5099b043d0c9052e Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 8 Jan 2014 21:45:34 +0100 Subject: buffer flush --- FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp | 30 ++++++++++++++---------------- FTNoIR_Tracker_PT/point_tracker.cpp | 33 ++++++++++++++++++++++++--------- FTNoIR_Tracker_PT/point_tracker.h | 18 +++++++++--------- 3 files changed, 47 insertions(+), 34 deletions(-) diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp index a3e8919b..7bd447cb 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp @@ -83,8 +83,8 @@ void Tracker::run() if (new_frame && !frame.empty()) { frame = frame_rotation.rotate_frame(frame); - const std::vector& points = point_extractor.extract_points(frame, dt, false); - tracking_valid = point_tracker.track(points, camera.get_info().fov, dt, frame.cols, frame.rows, t_MH); + const std::vector& points = point_extractor.extract_points(frame, dt, true); + tracking_valid = point_tracker.track(points, camera.get_info().fov, dt, frame.cols, frame.rows); video_widget->update_image(frame); } #ifdef PT_PERF_LOG @@ -119,15 +119,13 @@ void Tracker::apply(settings& s) point_tracker.dt_reset = s.reset_time / 1000.0; t_MH = cv::Vec3f(s.t_MH_x, s.t_MH_y, s.t_MH_z); R_GC = Matx33f( cos(deg2rad*s.cam_yaw), 0, sin(deg2rad*s.cam_yaw), - 0, 1, 0, - -sin(deg2rad*s.cam_yaw), 0, cos(deg2rad*s.cam_yaw)); - R_GC = R_GC * Matx33f( 1, 0, 0, + 0, 1, 0, + -sin(deg2rad*s.cam_yaw), 0, cos(deg2rad*s.cam_yaw)); + R_GC = R_GC * Matx33f( 1, 0, 0, 0, cos(deg2rad*s.cam_pitch), sin(deg2rad*s.cam_pitch), 0, -sin(deg2rad*s.cam_pitch), cos(deg2rad*s.cam_pitch)); - - FrameTrafo X_MH(Matx33f::eye(), t_MH); - X_GH_0 = R_GC * X_MH; - + FrameTrafo X_MH(Matx33f::eye(), t_MH); + X_GH_0 = R_GC * X_MH; qDebug()<<"Tracker::apply ends"; } @@ -140,10 +138,10 @@ void 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_GH_0 = R_GC * X_CM_0 * X_MH; + QMutexLocker lock(&mutex); + FrameTrafo X_CM_0 = point_tracker.get_pose(); + FrameTrafo X_MH(Matx33f::eye(), t_MH); + X_GH_0 = R_GC * X_CM_0 * X_MH; } bool Tracker::get_frame_and_points(cv::Mat& frame_copy, boost::shared_ptr< std::vector >& points) @@ -198,10 +196,10 @@ void Tracker::GetHeadPoseData(THeadPoseData *data) if (!tracking_valid) return; FrameTrafo X_CM = point_tracker.get_pose(); - FrameTrafo X_MH(Matx33f::eye(), t_MH); - FrameTrafo X_GH = R_GC * X_CM * X_MH; + 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(); - Vec3f t = X_GH.t - X_GH_0.t; + Vec3f t = X_GH.t - X_GH_0.t; // get translation(s) if (s.bEnableX) data[TX] = t[0] / 10.0; // convert to cm diff --git a/FTNoIR_Tracker_PT/point_tracker.cpp b/FTNoIR_Tracker_PT/point_tracker.cpp index 1df70b17..263be43a 100644 --- a/FTNoIR_Tracker_PT/point_tracker.cpp +++ b/FTNoIR_Tracker_PT/point_tracker.cpp @@ -104,6 +104,9 @@ void PointTracker::reset() init_phase = true; dt_valid = 0; reset_velocities(); + // assume identity rotation again + X_CM.R = cv::Matx33d::eye(); + X_CM.t = cv::Vec3f(); } void PointTracker::reset_velocities() @@ -113,7 +116,7 @@ void PointTracker::reset_velocities() } -bool PointTracker::track(const vector& points, float fov, float dt, int w, int h, const cv::Vec3f& headpos) +bool PointTracker::track(const vector& points, float fov, float dt, int w, int h) { if (!dynamic_pose_resolution) init_phase = true; @@ -150,7 +153,7 @@ bool PointTracker::track(const vector& points, float fov, float dt, int w } // XXX TODO fov - POSIT(fov, w, h, headpos); + POSIT(fov, w, h); //qDebug()<<"Number of POSIT iterations: "<& points, float fov, float dt, int w void PointTracker::predict(float dt) { // predict with constant velocity - Matx33f R; + Matx33d R; Rodrigues(dt*v_r, R); X_CM.R = R*X_CM.R; X_CM.t += dt * v_t; @@ -232,7 +235,7 @@ bool PointTracker::find_correspondences(const vector& points) -void PointTracker::POSIT(float fov, int w, int h, const cv::Vec3f& headpos) +void PointTracker::POSIT(float fov, int w, int h) { // XXX hack this->fov = fov; @@ -241,9 +244,9 @@ void PointTracker::POSIT(float fov, int w, int h, const cv::Vec3f& headpos) std::vector obj_points; std::vector img_points; - obj_points.push_back(headpos); - obj_points.push_back(point_model->M01 + headpos); - obj_points.push_back(point_model->M02 + headpos); + obj_points.push_back(cv::Vec3f(0, 0, 0)); + obj_points.push_back(point_model->M01); + obj_points.push_back(point_model->M02); img_points.push_back(p[0]); img_points.push_back(p[1]); @@ -262,17 +265,29 @@ void PointTracker::POSIT(float fov, int w, int h, const cv::Vec3f& headpos) cv::Mat dist_coeffs = cv::Mat::zeros(5, 1, CV_32FC1); - bool lastp = !rvec.empty() && !tvec.empty() && !init_phase; + bool lastp = !rvec.empty() && !tvec.empty(); cv::solvePnP(obj_points, img_points, intrinsics, dist_coeffs, rvec, tvec, lastp, cv::ITERATIVE); cv::Mat rmat; cv::Rodrigues(rvec, rmat); + // finally, find the closer solution + cv::Mat expected = cv::Mat(X_CM.R); + cv::Mat eye = cv::Mat::eye(3, 3, CV_64FC1); + double dev1 = norm(eye - expected * rmat.t()); + double dev2 = norm(eye - expected * rmat); + + if (dev1 > dev2) + { + rmat = rmat.t(); + cv::Rodrigues(rmat, rvec); + } + // apply results for (int i = 0; i < 3; i++) { - X_CM.t[i] = tvec.at(i); + X_CM.t[i] = tvec.at(i) * 1e-2; for (int j = 0; j < 3; j++) X_CM.R(i, j) = rmat.at(i, j); } diff --git a/FTNoIR_Tracker_PT/point_tracker.h b/FTNoIR_Tracker_PT/point_tracker.h index e05e8f98..823d75c0 100644 --- a/FTNoIR_Tracker_PT/point_tracker.h +++ b/FTNoIR_Tracker_PT/point_tracker.h @@ -21,11 +21,11 @@ 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) {} + FrameTrafo() : R(cv::Matx33d::eye()), t(0,0,0) {} + FrameTrafo(const cv::Matx33d& R, const cv::Vec3d& t) : R(R),t(t) {} - cv::Matx33f R; - cv::Vec3f t; + cv::Matx33d R; + cv::Vec3d t; }; inline FrameTrafo operator*(const FrameTrafo& X, const FrameTrafo& Y) @@ -33,17 +33,17 @@ inline FrameTrafo operator*(const FrameTrafo& X, const FrameTrafo& Y) return FrameTrafo(X.R*Y.R, X.R*Y.t + X.t); } -inline FrameTrafo operator*(const cv::Matx33f& X, const FrameTrafo& Y) +inline FrameTrafo operator*(const cv::Matx33d& X, const FrameTrafo& Y) { return FrameTrafo(X*Y.R, X*Y.t); } -inline FrameTrafo operator*(const FrameTrafo& X, const cv::Matx33f& Y) +inline FrameTrafo operator*(const FrameTrafo& X, const cv::Matx33d& Y) { return FrameTrafo(X.R*Y, X.t); } -inline cv::Vec3f operator*(const FrameTrafo& X, const cv::Vec3f& v) +inline cv::Vec3f operator*(const FrameTrafo& X, const cv::Vec3d& v) { return X.R*v + X.t; } @@ -90,7 +90,7 @@ public: // 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 fov, float dt, int w, int h, const cv::Vec3f &headpos); + bool track(const std::vector& points, float fov, float dt, int w, int h); boost::shared_ptr point_model; bool dynamic_pose_resolution; @@ -136,7 +136,7 @@ protected: void reset_velocities(); - void POSIT(float fov, int w, int h, const cv::Vec3f &headpos); // The POSIT algorithm, returns the number of iterations + void POSIT(float fov, int w, int h); // The POSIT algorithm, returns the number of iterations bool init_phase; float dt_valid; // time since last valid tracking result -- cgit v1.2.3 From d6855de1a83fd54c43384de218d61252de7a7a1b Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 8 Jan 2014 23:53:45 +0100 Subject: fix crash due to mismatched float/double --- FTNoIR_Tracker_PT/point_tracker.cpp | 11 +++++++---- FTNoIR_Tracker_PT/point_tracker.h | 14 +++++++------- FTNoIR_Tracker_PT/trans_calib.cpp | 4 ++-- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/FTNoIR_Tracker_PT/point_tracker.cpp b/FTNoIR_Tracker_PT/point_tracker.cpp index 263be43a..9f0fb59e 100644 --- a/FTNoIR_Tracker_PT/point_tracker.cpp +++ b/FTNoIR_Tracker_PT/point_tracker.cpp @@ -105,8 +105,8 @@ void PointTracker::reset() dt_valid = 0; reset_velocities(); // assume identity rotation again - X_CM.R = cv::Matx33d::eye(); - X_CM.t = cv::Vec3f(); + X_CM.R = cv::Matx33f::eye(); + X_CM.t = cv::Vec3f(0, 0, 1); } void PointTracker::reset_velocities() @@ -168,7 +168,7 @@ bool PointTracker::track(const vector& points, float fov, float dt, int w void PointTracker::predict(float dt) { // predict with constant velocity - Matx33d R; + Matx33f R; Rodrigues(dt*v_r, R); X_CM.R = R*X_CM.R; X_CM.t += dt * v_t; @@ -273,7 +273,10 @@ void PointTracker::POSIT(float fov, int w, int h) cv::Rodrigues(rvec, rmat); // finally, find the closer solution - cv::Mat expected = cv::Mat(X_CM.R); + cv::Mat expected(3, 3, CV_64FC1); + for (int i = 0; i < 3; i++) + for (int j = 0; j < 3; j++) + expected.at(i, j) = X_CM.R(i, j); cv::Mat eye = cv::Mat::eye(3, 3, CV_64FC1); double dev1 = norm(eye - expected * rmat.t()); double dev2 = norm(eye - expected * rmat); diff --git a/FTNoIR_Tracker_PT/point_tracker.h b/FTNoIR_Tracker_PT/point_tracker.h index 823d75c0..ac43489e 100644 --- a/FTNoIR_Tracker_PT/point_tracker.h +++ b/FTNoIR_Tracker_PT/point_tracker.h @@ -21,11 +21,11 @@ class FrameTrafo { public: - FrameTrafo() : R(cv::Matx33d::eye()), t(0,0,0) {} - FrameTrafo(const cv::Matx33d& R, const cv::Vec3d& t) : R(R),t(t) {} + FrameTrafo() : R(cv::Matx33f::eye()), t(0,0,0) {} + FrameTrafo(const cv::Matx33f& R, const cv::Vec3f& t) : R(R),t(t) {} - cv::Matx33d R; - cv::Vec3d t; + cv::Matx33f R; + cv::Vec3f t; }; inline FrameTrafo operator*(const FrameTrafo& X, const FrameTrafo& Y) @@ -33,17 +33,17 @@ inline FrameTrafo operator*(const FrameTrafo& X, const FrameTrafo& Y) return FrameTrafo(X.R*Y.R, X.R*Y.t + X.t); } -inline FrameTrafo operator*(const cv::Matx33d& X, const FrameTrafo& Y) +inline FrameTrafo operator*(const cv::Matx33f& X, const FrameTrafo& Y) { return FrameTrafo(X*Y.R, X*Y.t); } -inline FrameTrafo operator*(const FrameTrafo& X, const cv::Matx33d& Y) +inline FrameTrafo operator*(const FrameTrafo& X, const cv::Matx33f& Y) { return FrameTrafo(X.R*Y, X.t); } -inline cv::Vec3f operator*(const FrameTrafo& X, const cv::Vec3d& v) +inline cv::Vec3f operator*(const FrameTrafo& X, const cv::Vec3f& v) { return X.R*v + X.t; } diff --git a/FTNoIR_Tracker_PT/trans_calib.cpp b/FTNoIR_Tracker_PT/trans_calib.cpp index 9b75a1b6..b2e0ead0 100644 --- a/FTNoIR_Tracker_PT/trans_calib.cpp +++ b/FTNoIR_Tracker_PT/trans_calib.cpp @@ -40,5 +40,5 @@ void TranslationCalibrator::update(const Matx33f& R_CM_k, const Vec3f& 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 + return Vec3f(-x[0], -x[1], -x[2]); +} -- cgit v1.2.3 From b4e666a34081e9bfd22e136ee5413e39b400569b Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 9 Jan 2014 07:21:05 +0100 Subject: fix copy-paste mistake --- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index 6935dd43..db3d695c 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -279,7 +279,7 @@ void Tracker::run() cv::putText(frame, buf, cv::Point(10, 54), cv::FONT_HERSHEY_PLAIN, scale, cv::Scalar(80, 255, 0), scale); if (markers.size() == 1 && markers[0].size() == 4) { - const aruco::Marker& m = static_cast>(markers.at(0)); + const auto& m = static_cast>(markers.at(0)); cv::cornerSubPix(grayscale, m, cv::Size(5, 5), cv::Size(-1, -1), -- cgit v1.2.3 From ff04681a70ad5f3f8984aee465b4c20b648779be Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 9 Jan 2014 07:21:23 +0100 Subject: don't touch tvec scale --- FTNoIR_Tracker_PT/point_tracker.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FTNoIR_Tracker_PT/point_tracker.cpp b/FTNoIR_Tracker_PT/point_tracker.cpp index 9f0fb59e..c0221909 100644 --- a/FTNoIR_Tracker_PT/point_tracker.cpp +++ b/FTNoIR_Tracker_PT/point_tracker.cpp @@ -290,7 +290,7 @@ void PointTracker::POSIT(float fov, int w, int h) // apply results for (int i = 0; i < 3; i++) { - X_CM.t[i] = tvec.at(i) * 1e-2; + X_CM.t[i] = tvec.at(i); for (int j = 0; j < 3; j++) X_CM.R(i, j) = rmat.at(i, j); } -- cgit v1.2.3 From 839d5207517c86885c14bdf018f5599a4ca97a5b Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 9 Jan 2014 07:30:28 +0100 Subject: no need for ref here --- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index db3d695c..f00c8bfc 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -238,7 +238,7 @@ void Tracker::run() { detector.setMinMaxSize(std::max(0.01, size_min * grayscale.cols / last_roi.width), std::min(1.0, size_max * grayscale.cols / last_roi.width)); - auto& m = markers.at(0); + auto m = markers.at(0); for (int i = 0; i < 4; i++) { auto& p = m.at(i); @@ -279,7 +279,7 @@ void Tracker::run() cv::putText(frame, buf, cv::Point(10, 54), cv::FONT_HERSHEY_PLAIN, scale, cv::Scalar(80, 255, 0), scale); if (markers.size() == 1 && markers[0].size() == 4) { - const auto& m = static_cast>(markers.at(0)); + const auto m = static_cast>(markers.at(0)); cv::cornerSubPix(grayscale, m, cv::Size(5, 5), cv::Size(-1, -1), -- cgit v1.2.3 From 32d2bb24dc947e6ce4ed7dfe2596d6bbc1dba892 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 11 Jan 2014 15:25:27 +0100 Subject: sane default value for PT reset time --- FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.h b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.h index e0dfa2e6..b2ab8854 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.h +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.h @@ -69,7 +69,7 @@ struct settings t_MH_x(b, "model-centroid-x", 0), t_MH_y(b, "model-centroid-y", 0), t_MH_z(b, "model-centroid-z", 0), - reset_time(b, "reset-time", 0), + reset_time(b, "reset-time", 2000), bEnableYaw(b, "enable-yaw", true), bEnablePitch(b, "enable-pitch", true), bEnableRoll(b, "enable-roll", true), -- cgit v1.2.3 From 24287f1c4c8308678b1f7320b303548027dd8954 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 11 Jan 2014 15:27:11 +0100 Subject: remove an outdated comment --- FTNoIR_Tracker_PT/point_tracker.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/FTNoIR_Tracker_PT/point_tracker.cpp b/FTNoIR_Tracker_PT/point_tracker.cpp index c0221909..cce327e9 100644 --- a/FTNoIR_Tracker_PT/point_tracker.cpp +++ b/FTNoIR_Tracker_PT/point_tracker.cpp @@ -152,7 +152,6 @@ bool PointTracker::track(const vector& points, float fov, float dt, int w return false; } - // XXX TODO fov POSIT(fov, w, h); //qDebug()<<"Number of POSIT iterations: "< Date: Sat, 11 Jan 2014 15:36:14 +0100 Subject: remove hack of passing fov/w/h as member vars --- FTNoIR_Tracker_PT/point_tracker.cpp | 19 ++++++------------- FTNoIR_Tracker_PT/point_tracker.h | 8 ++------ 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/FTNoIR_Tracker_PT/point_tracker.cpp b/FTNoIR_Tracker_PT/point_tracker.cpp index cce327e9..a881da62 100644 --- a/FTNoIR_Tracker_PT/point_tracker.cpp +++ b/FTNoIR_Tracker_PT/point_tracker.cpp @@ -91,10 +91,7 @@ PointTracker::PointTracker() dt_reset(1), v_t(0,0,0), v_r(0,0,0), - dynamic_pose_resolution(true), - fov(0), - _w(0), - _h(0) + dynamic_pose_resolution(true) { } @@ -144,7 +141,7 @@ bool PointTracker::track(const vector& points, float fov, float dt, int w predict(dt_valid); // if there is a point correspondence problem something has gone wrong, do a reset - if (!find_correspondences(points)) + if (!find_correspondences(points, fov, w, h)) { //qDebug()<<"Error in finding point correspondences!"; X_CM = X_CM_old; // undo prediction @@ -181,7 +178,7 @@ void PointTracker::update_velocities(float dt) v_t = (X_CM.t - X_CM_old.t)/dt; } -bool PointTracker::find_correspondences(const vector& points) +bool PointTracker::find_correspondences(const vector& points, float fov, int w, int h) { if (init_phase) { // We do a simple freetrack-like sorting in the init phase... @@ -198,9 +195,9 @@ bool PointTracker::find_correspondences(const vector& points) 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)); - p_exp[1] = project(point_model->M01); - p_exp[2] = project(point_model->M02); + p_exp[0] = project(Vec3f(0,0,0), fov, w, h); + p_exp[1] = project(point_model->M01, fov, w, h); + p_exp[2] = project(point_model->M02, fov, w, h); // set correspondences by minimum distance to projected model point bool point_taken[PointModel::N_POINTS]; @@ -236,10 +233,6 @@ bool PointTracker::find_correspondences(const vector& points) void PointTracker::POSIT(float fov, int w, int h) { - // XXX hack - this->fov = fov; - _w = w; - _h = h; std::vector obj_points; std::vector img_points; diff --git a/FTNoIR_Tracker_PT/point_tracker.h b/FTNoIR_Tracker_PT/point_tracker.h index ac43489e..741d5af4 100644 --- a/FTNoIR_Tracker_PT/point_tracker.h +++ b/FTNoIR_Tracker_PT/point_tracker.h @@ -98,16 +98,12 @@ public: FrameTrafo get_pose() const { return X_CM; } void reset(); - float fov; - int _w, _h; - protected: - cv::Vec2f project(const cv::Vec3f& v_M) + cv::Vec2f project(const cv::Vec3f& v_M, float fov, int w, int h) { if (!rvec.empty() && !tvec.empty() && fov > 0) { const float HT_PI = 3.1415926535; - const int w = _w, h = _h; const float focal_length_w = 0.5 * w / tan(fov * HT_PI / 180); const float focal_length_h = 0.5 * h / tan(fov * h / w * HT_PI / 180.0); @@ -126,7 +122,7 @@ protected: return cv::Vec2f(); } - bool find_correspondences(const std::vector& points); + bool find_correspondences(const std::vector& points, float fov, int w, int h); cv::Vec2f p[PointModel::N_POINTS]; // the points in model order cv::Vec2f p_exp[PointModel::N_POINTS]; // the expected point positions -- cgit v1.2.3 From 786fbaef73c522b6d138145b612034913ff70d03 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 11 Jan 2014 15:40:31 +0100 Subject: replace hand-rolled timer class with QElapsedTimer --- FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp | 3 +- FTNoIR_Tracker_PT/ftnoir_tracker_pt.h | 4 +- FTNoIR_Tracker_PT/timer.cpp | 66 --------------------------------- FTNoIR_Tracker_PT/timer.h | 44 ---------------------- 4 files changed, 3 insertions(+), 114 deletions(-) delete mode 100644 FTNoIR_Tracker_PT/timer.cpp delete mode 100644 FTNoIR_Tracker_PT/timer.h diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp index 7bd447cb..83bf6911 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp @@ -76,8 +76,7 @@ void Tracker::run() if (commands & PAUSE) continue; commands = 0; - dt = time.elapsed() / 1000.0; - time.restart(); + dt = time.restart() / 1000.0; new_frame = camera.get_frame(dt, &frame); if (new_frame && !frame.empty()) diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h index c7f1dc02..067a4072 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h @@ -18,7 +18,7 @@ #include "point_extractor.h" #include "point_tracker.h" #include "pt_video_widget.h" -#include "timer.h" +#include #include #include @@ -84,7 +84,7 @@ protected: bool tracking_valid; settings s; - Timer time; + QElapsedTimer time; }; #undef VideoWidget diff --git a/FTNoIR_Tracker_PT/timer.cpp b/FTNoIR_Tracker_PT/timer.cpp deleted file mode 100644 index 080dd713..00000000 --- a/FTNoIR_Tracker_PT/timer.cpp +++ /dev/null @@ -1,66 +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 "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); - return endTime - startTime; -#else - if(running) - gettimeofday(&endCount, NULL); - - startTime = (startCount.tv_sec) + startCount.tv_usec * 1e-6; - endTime = (endCount.tv_sec) + endCount.tv_usec * 1e-6; - return (endTime - startTime) * 1e3; -#endif -} diff --git a/FTNoIR_Tracker_PT/timer.h b/FTNoIR_Tracker_PT/timer.h deleted file mode 100644 index f189e23c..00000000 --- a/FTNoIR_Tracker_PT/timer.h +++ /dev/null @@ -1,44 +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 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 -- cgit v1.2.3 From 9d3b82bf518798635ddc9f1de8446ff37a5e2281 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 11 Jan 2014 16:16:39 +0100 Subject: prevent empty video frame upon race --- FTNoIR_Tracker_PT/pt_video_widget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FTNoIR_Tracker_PT/pt_video_widget.cpp b/FTNoIR_Tracker_PT/pt_video_widget.cpp index 38c49567..75fa18a0 100644 --- a/FTNoIR_Tracker_PT/pt_video_widget.cpp +++ b/FTNoIR_Tracker_PT/pt_video_widget.cpp @@ -21,7 +21,7 @@ void PTVideoWidget::update_image(const cv::Mat& frame) const int rate = 40; if (freshp) return; - if (!update_throttler.isValid() || update_throttler.elapsed() > rate) + if (frame.empty() || !update_throttler.isValid() || update_throttler.elapsed() > rate) { _frame = frame.clone(); update_throttler.restart(); -- cgit v1.2.3 From 9e9d76b68996840d264f7c8760d7879c2cc8781c Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 11 Jan 2014 16:16:55 +0100 Subject: display extracted points' centers --- FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp index 83bf6911..b4100998 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp @@ -83,6 +83,23 @@ void Tracker::run() { frame = frame_rotation.rotate_frame(frame); const std::vector& points = point_extractor.extract_points(frame, dt, true); + for (auto p : points) + { + auto p2 = cv::Point(p[0] * frame.cols + frame.cols/2, + p[1] * frame.rows + frame.rows/2); + cv::Scalar color(0, 255, 0); + qDebug() << p2.x << p2.y; + cv::line(frame, + cv::Point(p2.x - 20, p2.y), + cv::Point(p2.x + 20, p2.y), + color, + 4); + cv::line(frame, + cv::Point(p2.x, p2.y - 20), + cv::Point(p2.x, p2.y + 20), + color, + 4); + } tracking_valid = point_tracker.track(points, camera.get_info().fov, dt, frame.cols, frame.rows); video_widget->update_image(frame); } -- cgit v1.2.3 From 7217cf5ac2191c92c956c88f012282882593bfc4 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 11 Jan 2014 16:27:09 +0100 Subject: fix translation estimation --- FTNoIR_Tracker_PT/point_tracker.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/FTNoIR_Tracker_PT/point_tracker.cpp b/FTNoIR_Tracker_PT/point_tracker.cpp index a881da62..2dd89aed 100644 --- a/FTNoIR_Tracker_PT/point_tracker.cpp +++ b/FTNoIR_Tracker_PT/point_tracker.cpp @@ -240,9 +240,11 @@ void PointTracker::POSIT(float fov, int w, int h) obj_points.push_back(point_model->M01); obj_points.push_back(point_model->M02); - img_points.push_back(p[0]); - img_points.push_back(p[1]); - img_points.push_back(p[2]); + for (int i = 0; i < 3; i++) + { + auto p2 = cv::Point(p[i][0] * w + w/2, p[i][1] * h + h/2); + img_points.push_back(p2); + } const float HT_PI = 3.1415926535; -- cgit v1.2.3 From cb2afb510c98f168e312007cbb92f70b7b4ffa4b Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 11 Jan 2014 16:41:55 +0100 Subject: reset levmarq internal state on reset (duh) --- FTNoIR_Tracker_PT/point_tracker.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/FTNoIR_Tracker_PT/point_tracker.cpp b/FTNoIR_Tracker_PT/point_tracker.cpp index 2dd89aed..69d46645 100644 --- a/FTNoIR_Tracker_PT/point_tracker.cpp +++ b/FTNoIR_Tracker_PT/point_tracker.cpp @@ -104,6 +104,8 @@ void PointTracker::reset() // assume identity rotation again X_CM.R = cv::Matx33f::eye(); X_CM.t = cv::Vec3f(0, 0, 1); + rvec = Mat(); + tvec = Mat(); } void PointTracker::reset_velocities() -- cgit v1.2.3 From d9953cc2cdb7c679f7df2cfb118644cb81d23bbd Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 11 Jan 2014 18:07:24 +0100 Subject: use proper scale for translation --- FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp index b4100998..c94fa3ff 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp @@ -218,9 +218,9 @@ void Tracker::GetHeadPoseData(THeadPoseData *data) Vec3f t = X_GH.t - X_GH_0.t; // get translation(s) - if (s.bEnableX) data[TX] = t[0] / 10.0; // convert to cm - if (s.bEnableY) data[TY] = t[1] / 10.0; - if (s.bEnableZ) data[TZ] = t[2] / 10.0; + if (s.bEnableX) data[TX] = t[0]; // convert to cm + if (s.bEnableY) data[TY] = t[1]; + if (s.bEnableZ) data[TZ] = t[2]; // translate rotation matrix from opengl (G) to roll-pitch-yaw (E) frame // -z -> x, y -> z, x -> -y -- cgit v1.2.3 From 7da7a26385c1d54762d6f2d11a7036d856bc5864 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 11 Jan 2014 18:07:48 +0100 Subject: use correct scale for point coords --- FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp | 2 +- FTNoIR_Tracker_PT/point_tracker.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp index c94fa3ff..9f74127f 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp @@ -86,7 +86,7 @@ void Tracker::run() for (auto p : points) { auto p2 = cv::Point(p[0] * frame.cols + frame.cols/2, - p[1] * frame.rows + frame.rows/2); + -p[1] * frame.cols + frame.rows/2); cv::Scalar color(0, 255, 0); qDebug() << p2.x << p2.y; cv::line(frame, diff --git a/FTNoIR_Tracker_PT/point_tracker.cpp b/FTNoIR_Tracker_PT/point_tracker.cpp index 69d46645..faac9963 100644 --- a/FTNoIR_Tracker_PT/point_tracker.cpp +++ b/FTNoIR_Tracker_PT/point_tracker.cpp @@ -244,7 +244,7 @@ void PointTracker::POSIT(float fov, int w, int h) for (int i = 0; i < 3; i++) { - auto p2 = cv::Point(p[i][0] * w + w/2, p[i][1] * h + h/2); + auto p2 = cv::Point(p[i][0] * w + w/2, -p[i][1] * h + w/2); img_points.push_back(p2); } -- cgit v1.2.3 From 19dcf6de27cbb4347f940186370823f479ab1a5c Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 11 Jan 2014 18:08:15 +0100 Subject: get rid of frame copy throttling --- FTNoIR_Tracker_PT/pt_video_widget.cpp | 11 ++--------- FTNoIR_Tracker_PT/pt_video_widget.h | 2 -- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/FTNoIR_Tracker_PT/pt_video_widget.cpp b/FTNoIR_Tracker_PT/pt_video_widget.cpp index 75fa18a0..02817cbf 100644 --- a/FTNoIR_Tracker_PT/pt_video_widget.cpp +++ b/FTNoIR_Tracker_PT/pt_video_widget.cpp @@ -18,15 +18,8 @@ using namespace std; void PTVideoWidget::update_image(const cv::Mat& frame) { QMutexLocker foo(&mtx); - const int rate = 40; - if (freshp) - return; - if (frame.empty() || !update_throttler.isValid() || update_throttler.elapsed() > rate) - { - _frame = frame.clone(); - update_throttler.restart(); - freshp = true; - } + _frame = frame.clone(); + freshp = true; } // ---------------------------------------------------------------------------- diff --git a/FTNoIR_Tracker_PT/pt_video_widget.h b/FTNoIR_Tracker_PT/pt_video_widget.h index c47198db..25d593c3 100644 --- a/FTNoIR_Tracker_PT/pt_video_widget.h +++ b/FTNoIR_Tracker_PT/pt_video_widget.h @@ -24,7 +24,6 @@ #include #include #include -#include class PTVideoWidget : public QWidget, public FrameObserver { @@ -53,7 +52,6 @@ private: QImage texture; QTimer timer; cv::Mat _frame; - QElapsedTimer update_throttler; bool freshp; }; -- cgit v1.2.3 From fa0908c3a5d449afab5d48553c6af7294e1b6998 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 11 Jan 2014 18:09:46 +0100 Subject: remove forgotten debug code --- FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp index 9f74127f..102f62ee 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp @@ -88,7 +88,6 @@ void Tracker::run() auto p2 = cv::Point(p[0] * frame.cols + frame.cols/2, -p[1] * frame.cols + frame.rows/2); cv::Scalar color(0, 255, 0); - qDebug() << p2.x << p2.y; cv::line(frame, cv::Point(p2.x - 20, p2.y), cv::Point(p2.x + 20, p2.y), -- cgit v1.2.3 From 69dddfbab322d55d6b26336f20fcfdb2ebaecdad Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 11 Jan 2014 18:13:01 +0100 Subject: FINALLY fix d_order -> image pos --- FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp | 3 +-- FTNoIR_Tracker_PT/point_tracker.cpp | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp index 102f62ee..c949b8d0 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp @@ -85,8 +85,7 @@ void Tracker::run() const std::vector& points = point_extractor.extract_points(frame, dt, true); for (auto p : points) { - auto p2 = cv::Point(p[0] * frame.cols + frame.cols/2, - -p[1] * frame.cols + frame.rows/2); + auto p2 = cv::Point(p[0] * frame.cols + frame.cols/2, -p[1] * frame.cols + frame.rows/2); cv::Scalar color(0, 255, 0); cv::line(frame, cv::Point(p2.x - 20, p2.y), diff --git a/FTNoIR_Tracker_PT/point_tracker.cpp b/FTNoIR_Tracker_PT/point_tracker.cpp index faac9963..96d9d972 100644 --- a/FTNoIR_Tracker_PT/point_tracker.cpp +++ b/FTNoIR_Tracker_PT/point_tracker.cpp @@ -244,7 +244,7 @@ void PointTracker::POSIT(float fov, int w, int h) for (int i = 0; i < 3; i++) { - auto p2 = cv::Point(p[i][0] * w + w/2, -p[i][1] * h + w/2); + auto p2 = cv::Point(p[i][0] * w + w/2, -p[i][1] * w + h/2); img_points.push_back(p2); } -- cgit v1.2.3 From cbe0f250b3f41237fe6b448ec841adf3dc6d92aa Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 11 Jan 2014 18:49:27 +0100 Subject: change coeffs before snapshot --- ftnoir_tracker_ht/ftnoir_tracker_ht.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp index a133fd7a..3f9f9fa1 100644 --- a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp +++ b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp @@ -115,7 +115,7 @@ void Tracker::load_settings(ht_config_t* config) config->field_of_view = s.fov; config->pyrlk_pyramids = 0; config->pyrlk_win_size_w = config->pyrlk_win_size_h = 21; - config->max_keypoints = 300; + config->max_keypoints = 120; config->keypoint_distance = 3.2; config->force_fps = nframes; config->camera_index = s.camera_idx - 1; @@ -125,7 +125,7 @@ void Tracker::load_settings(ht_config_t* config) config->ransac_abs_max_mean_error = 16; config->ransac_max_mean_error = 6.5; config->debug = 0; - config->ransac_min_features = 0.83; + config->ransac_min_features = 0.85; int res = s.resolution; if (res < 0 || res >= (int)(sizeof(resolution_choices) / sizeof(resolution_tuple))) res = 0; -- cgit v1.2.3 From 5ac13932342530b68708c202d1227267bd4733bf Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 11 Jan 2014 21:31:51 +0100 Subject: fix labels for joy tracker MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reported-by: Sascha Bönhardt --- .../ftnoir_tracker_joystick_controls.ui | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/ftnoir_tracker_joystick/ftnoir_tracker_joystick_controls.ui b/ftnoir_tracker_joystick/ftnoir_tracker_joystick_controls.ui index a0fa43d3..7522cf31 100644 --- a/ftnoir_tracker_joystick/ftnoir_tracker_joystick_controls.ui +++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick_controls.ui @@ -57,21 +57,21 @@ - Yaw + X - Pitch + Y - Z + Roll @@ -323,7 +323,7 @@ - X + Yaw @@ -379,14 +379,14 @@ - Roll + Z - Y + Pitch @@ -419,6 +419,16 @@ + + joylist + comboBox + comboBox_2 + comboBox_3 + comboBox_4 + comboBox_5 + comboBox_6 + buttonBox + -- cgit v1.2.3 From bffc54d3b7f3fae018db7e371b7ee8f4e3d57f6a Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 12 Jan 2014 00:10:25 +0100 Subject: fix aruco ROI bug --- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index f00c8bfc..be5d0f32 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -238,7 +238,7 @@ void Tracker::run() { detector.setMinMaxSize(std::max(0.01, size_min * grayscale.cols / last_roi.width), std::min(1.0, size_max * grayscale.cols / last_roi.width)); - auto m = markers.at(0); + auto& m = markers.at(0); for (int i = 0; i < 4; i++) { auto& p = m.at(i); @@ -253,7 +253,7 @@ void Tracker::run() } if (markers.size() == 1 && markers[0].size() == 4) { - const aruco::Marker& m = markers.at(0); + const auto& m = markers.at(0); for (int i = 0; i < 4; i++) cv::line(color, m[i], m[(i+1)%4], cv::Scalar(0, 0, 255), scale, 8); } @@ -279,7 +279,7 @@ void Tracker::run() cv::putText(frame, buf, cv::Point(10, 54), cv::FONT_HERSHEY_PLAIN, scale, cv::Scalar(80, 255, 0), scale); if (markers.size() == 1 && markers[0].size() == 4) { - const auto m = static_cast>(markers.at(0)); + const auto& m = markers.at(0); cv::cornerSubPix(grayscale, m, cv::Size(5, 5), cv::Size(-1, -1), -- cgit v1.2.3 From 94226df9ba710ee8bf5a28baeebbb5d470796e24 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 12 Jan 2014 01:44:17 +0100 Subject: correct aruco min pitch equation --- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index be5d0f32..cbd9f531 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -284,7 +284,7 @@ void Tracker::run() m, cv::Size(5, 5), cv::Size(-1, -1), cv::TermCriteria(cv::TermCriteria::MAX_ITER | cv::TermCriteria::EPS, - 10, + 20, 1e-2)); const float size = 7; @@ -338,7 +338,7 @@ void Tracker::run() { cv::Vec3d euler = cv::RQDecomp3x3(rotation_matrix, junk1, junk2); - if (fabs(euler[0] - last_pitch) > pitch_eps || euler[0] < 0) + if (fabs(euler[0] - last_pitch) > pitch_eps || euler[0] - s.marker_pitch < 0) { first = true; last_pitch = euler[0]; -- cgit v1.2.3 From c8917c62d6415706380102c78af3c99a127722ed Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 12 Jan 2014 12:47:10 +0100 Subject: accela: implement separate rot/trans deadbands --- .../ftnoir_accela_filtercontrols.ui | 152 +++++++++++++-------- ftnoir_filter_accela/ftnoir_filter_accela.cpp | 7 +- ftnoir_filter_accela/ftnoir_filter_accela.h | 6 +- .../ftnoir_filter_accela_dialog.cpp | 3 +- 4 files changed, 104 insertions(+), 64 deletions(-) diff --git a/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui b/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui index 54493041..a3deacbd 100644 --- a/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui +++ b/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui @@ -9,8 +9,8 @@ 0 0 - 215 - 285 + 261 + 330 @@ -54,19 +54,16 @@ 7 - - + + - + 0 0 - Rotation - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + Translation @@ -98,16 +95,33 @@ - - + + - + 0 0 - Translation + Rotation + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + Exponent + + + + + + + Order #3 @@ -143,15 +157,8 @@ - - - - Order #3 - - - - + 0 @@ -178,35 +185,6 @@ - - - - Exponent - - - - - - - - 0 - 0 - - - - 3 - - - 0.050000000000000 - - - 100.000000000000000 - - - 0.050000000000000 - - - @@ -232,11 +210,11 @@ background:none; - Deadband + Rotation deadband - + @@ -281,7 +259,29 @@ background:none; - + + + + + 0 + 0 + + + + 3 + + + 0.050000000000000 + + + 100.000000000000000 + + + 0.050000000000000 + + + + @@ -294,8 +294,8 @@ background:none; - - + + 0 @@ -322,8 +322,8 @@ background:none; - - + + 0 @@ -350,6 +350,41 @@ background:none; + + + + Translation deadband + + + + + + + + 0 + 0 + + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + 3 + + + 0.000000000000000 + + + 3.000000000000000 + + + 0.050000000000000 + + + 0.000000000000000 + + + @@ -357,7 +392,8 @@ background:none; translation_alpha order_2nd order_3rd - deadzone + rot_deadzone + trans_deadzone expt buttonBox diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.cpp b/ftnoir_filter_accela/ftnoir_filter_accela.cpp index 1e12e4de..558b3189 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela.cpp @@ -89,10 +89,11 @@ void FTNoIR_Filter::FilterHeadPoseData(const double* target_camera_position, const double a = i >= 3 ? s.rotation_alpha : s.translation_alpha; const double a2 = a * s.second_order_alpha; const double a3 = a * s.third_order_alpha; + const double deadzone = i >= 3 ? s.rot_deadzone : s.trans_deadzone; const double velocity = - parabola(a, vec, s.deadzone, s.expt) + - parabola(a2, vec2, s.deadzone, s.expt) + - parabola(a3, vec3, s.deadzone, s.expt); + parabola(a, vec, deadzone, s.expt) + + parabola(a2, vec2, deadzone, s.expt) + + parabola(a3, vec3, deadzone, s.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 e8f077c3..42d9b772 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.h +++ b/ftnoir_filter_accela/ftnoir_filter_accela.h @@ -19,7 +19,8 @@ struct settings { translation_alpha, second_order_alpha, third_order_alpha, - deadzone, + rot_deadzone, + trans_deadzone, expt; settings() : b(bundle("Accela")), @@ -27,7 +28,8 @@ struct settings { translation_alpha(b, "translation-alpha", ACCELA_SMOOTHING_TRANSLATION), second_order_alpha(b, "second-order-alpha", ACCELA_SECOND_ORDER_ALPHA), third_order_alpha(b, "third-order-alpha", ACCELA_THIRD_ORDER_ALPHA), - deadzone(b, "deadzone", 0), + rot_deadzone(b, "rotation-deadband", 0), + trans_deadzone(b, "translation-deadband", 0), expt(b, "exponent", 2) {} }; diff --git a/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp b/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp index 56b76a55..ca321891 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp @@ -16,7 +16,8 @@ FilterControls::FilterControls() : tie_setting(s.translation_alpha, ui.translation_alpha); tie_setting(s.second_order_alpha, ui.order_2nd); tie_setting(s.third_order_alpha, ui.order_3rd); - tie_setting(s.deadzone, ui.deadzone); + tie_setting(s.rot_deadzone, ui.rot_deadzone); + tie_setting(s.trans_deadzone, ui.trans_deadzone); tie_setting(s.expt, ui.expt); } -- cgit v1.2.3 From a95b9c206231cb7749648574b31c06b17a5a41d0 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 12 Jan 2014 14:19:36 +0100 Subject: qfc: simplify --- qfunctionconfigurator/qfunctionconfigurator.cpp | 59 +++++++------------------ qfunctionconfigurator/qfunctionconfigurator.h | 1 - 2 files changed, 17 insertions(+), 43 deletions(-) diff --git a/qfunctionconfigurator/qfunctionconfigurator.cpp b/qfunctionconfigurator/qfunctionconfigurator.cpp index 5a02a826..cd79f23a 100644 --- a/qfunctionconfigurator/qfunctionconfigurator.cpp +++ b/qfunctionconfigurator/qfunctionconfigurator.cpp @@ -370,10 +370,8 @@ void QFunctionConfigurator::mousePressEvent(QMouseEvent *e) // If the Left Mouse-button was clicked without touching a Point, add a new Point // if (!bTouchingPoint) { - if (withinRect(e->pos(), range)) { - _config->addPoint(normalizePoint(e->pos())); - emit CurveChanged( true ); - } + _config->addPoint(normalizePoint(e->pos())); + emit CurveChanged( true ); } } } @@ -433,26 +431,20 @@ void QFunctionConfigurator::mouseMoveEvent(QMouseEvent *e) } } else { - if (withinRect(e->pos(), rect())) - { - // - // Check to see if the cursor is touching one of the points. - // - bool bTouchingPoint = false; - if (_config) { - for (int i = 0; i < points.size(); i++) { - if ( markContains( graphicalizePoint( points[i] ), e->pos() ) ) { - bTouchingPoint = true; - } + bool bTouchingPoint = false; + if (_config) { + for (int i = 0; i < points.size(); i++) { + if ( markContains( graphicalizePoint( points[i] ), e->pos() ) ) { + bTouchingPoint = true; } } + } - if ( bTouchingPoint ) { - setCursor(Qt::OpenHandCursor); - } - else { - setCursor(Qt::ArrowCursor); - } + if ( bTouchingPoint ) { + setCursor(Qt::OpenHandCursor); + } + else { + setCursor(Qt::ArrowCursor); } } } @@ -489,22 +481,10 @@ void QFunctionConfigurator::mouseReleaseEvent(QMouseEvent *e) // bool QFunctionConfigurator::markContains(const QPointF &pos, const QPointF &coord) const { - QRectF rect(pos.x() - pointSize, - pos.y() - pointSize, - pointSize*M_PI, pointSize*M_PI); - QPainterPath path; - path.addEllipse(rect); - return path.contains(coord); + return coord.x() >= pos.x() - pointSize && coord.x() < pos.x() + pointSize && + coord.y() >= pos.y() - pointSize && coord.y() < pos.y() + pointSize; } -bool QFunctionConfigurator::withinRect( const QPointF &coord, const QRectF &rect ) const -{ - QPainterPath path; - path.addRect(rect); - return path.contains(coord); -} - -// // Convert the Point in the graph, to the real-life Point. // QPointF QFunctionConfigurator::normalizePoint(QPointF point) const @@ -533,8 +513,8 @@ QPointF QFunctionConfigurator::graphicalizePoint(QPointF point) const { QPointF graph; - graph.setX( range.left() + (fabs(point.x()) * pPerEGU_Input) ); - graph.setY( range.bottom() - (fabs(point.y()) * pPerEGU_Output) ); + graph.setX( range.left() + point.x() * pPerEGU_Input); + graph.setY( range.bottom() - point.y() * pPerEGU_Output); return graph; } @@ -542,14 +522,11 @@ QPointF graph; void QFunctionConfigurator::setmaxInputEGU(int value) { MaxInput = value; - setMinimumWidth(MaxInput * pPerEGU_Input + 55); -// resetCurve(); resize( MaxInput * pPerEGU_Input + 55, MaxOutput * pPerEGU_Output + 60 ); } void QFunctionConfigurator::setmaxOutputEGU(int value) { MaxOutput = value; - setMinimumHeight(MaxOutput * pPerEGU_Output + 60); // resetCurve(); resize( MaxInput * pPerEGU_Input + 55, MaxOutput * pPerEGU_Output + 60 ); } @@ -560,7 +537,6 @@ void QFunctionConfigurator::setmaxOutputEGU(int value) void QFunctionConfigurator::setpixPerEGU_Input(int value) { pPerEGU_Input = value; - setMinimumWidth(MaxInput * pPerEGU_Input + 55); resize( MaxInput * pPerEGU_Input + 55, MaxOutput * pPerEGU_Output + 60 ); } @@ -570,7 +546,6 @@ void QFunctionConfigurator::setpixPerEGU_Input(int value) void QFunctionConfigurator::setpixPerEGU_Output(int value) { pPerEGU_Output = value; - setMinimumHeight(MaxOutput * pPerEGU_Output + 60); resize( MaxInput * pPerEGU_Input + 55, MaxOutput * pPerEGU_Output + 60 ); } diff --git a/qfunctionconfigurator/qfunctionconfigurator.h b/qfunctionconfigurator/qfunctionconfigurator.h index dccd4601..84f4ad8b 100644 --- a/qfunctionconfigurator/qfunctionconfigurator.h +++ b/qfunctionconfigurator/qfunctionconfigurator.h @@ -117,7 +117,6 @@ protected: void drawPoint(QPainter *painter, const QPointF &pt, QColor colBG ); void drawLine(QPainter *painter, const QPointF &start, const QPointF &end, QPen pen); bool markContains(const QPointF &pt, const QPointF &coord) const; - bool withinRect( const QPointF &coord, const QRectF &rect ) const; protected: virtual void resizeEvent(QResizeEvent *); -- cgit v1.2.3 From c4fd758f368972ecf49e8e1828409488919ead02 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 12 Jan 2014 16:08:52 +0100 Subject: refactor QFC --- qfunctionconfigurator/qfunctionconfigurator.cpp | 415 +++++++----------------- qfunctionconfigurator/qfunctionconfigurator.h | 92 +----- 2 files changed, 132 insertions(+), 375 deletions(-) diff --git a/qfunctionconfigurator/qfunctionconfigurator.cpp b/qfunctionconfigurator/qfunctionconfigurator.cpp index cd79f23a..755e2f9c 100644 --- a/qfunctionconfigurator/qfunctionconfigurator.cpp +++ b/qfunctionconfigurator/qfunctionconfigurator.cpp @@ -21,97 +21,52 @@ #include #include #include +#include static const int pointSize = 5; QFunctionConfigurator::QFunctionConfigurator(QWidget *parent) : QWidget(parent) { - - // - // Defaults, for when the widget has no values different from the domXML() - // - - pPerEGU_Output = 1; // Number of pixels, per EGU - pPerEGU_Input = 4; // Number of pixels, per EGU - gDistEGU_Input = 5; // Distance of gridlines - gDistEGU_Output = 10; // Distance of gridlines - - - // Change compared to BezierConfigurator: X = horizontal (input), Y = vertical (output) - // 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); - movingPoint = -1; // Index of that same point - - // - // Variables for FunctionConfig - // _config = 0; _draw_background = true; _draw_function = true; - + update_range(); setMouseTracking(true); - -// qDebug() << "QFunctionConfigurator::QFunctionConfigurator object created."; - } -// -// Attach an existing FunctionConfig to the Widget. -// void QFunctionConfigurator::setConfig(FunctionConfig* config, QString settingsFile) { 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->loadSettings(iniFile); _config = config; - - strSettingsFile = settingsFile; // Remember for Reset() - - setCaption(config->getTitle()); - _draw_function = _draw_background = true; - - setmaxInputEGU(config->maxInput()); - setmaxOutputEGU(config->maxOutput()); - this->update(); } -// -// Load the FunctionConfig (points) from the INI-file. -// void QFunctionConfigurator::loadSettings(QString settingsFile) { QSettings iniFile( settingsFile, QSettings::IniFormat ); // Application settings (in INI-file) - strSettingsFile = settingsFile; // Remember for Reset() if (_config) { _config->loadSettings(iniFile); } } -// -// Save the FunctionConfig (points) to the INI-file. -// void QFunctionConfigurator::saveSettings(QString settingsFile) { QSettings iniFile( settingsFile, QSettings::IniFormat ); // Application settings (in INI-file) - strSettingsFile = settingsFile; // Remember for Reset() if (_config) { _config->saveSettings(iniFile); } } -// -// 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() { - int i; - QRect scale; + if (!_config) + return; _background = QPixmap(width(), height()); QPainter painter(&_background); painter.fillRect(rect(), QColor::fromRgb(204, 204, 204)); @@ -122,87 +77,94 @@ void QFunctionConfigurator::drawBackground() QFont font; font.setPointSize(8); painter.setFont(font); + QFontMetrics metrics(font); QPen pen(QColor(55, 104, 170, 127), 1, Qt::SolidLine); - // - // Draw the Caption - // - if (_config) { - strCaption = _config->getTitle(); + const int xstep = 10, ystep = 10; + const int maxx = _config->maxInput(); + const int maxy = _config->maxOutput(); + + // horizontal grid + + for (int i = 0; i < maxx; i += xstep) + { + double y = range.height() - i * c.y() + range.y(); + drawLine(&painter, + QPointF(range.x(), y), + QPointF(range.x() + range.width(), y), + pen); + painter.drawText(QRectF(10, + y - metrics.height()/2, + range.left(), + metrics.height()), + QString::number(i)); } - scale.setCoords(range.left(), 0, range.right(), 20); - painter.drawText(scale, Qt::AlignCenter, strCaption); - - // - // Draw the horizontal grid - // - for (i = range.bottom() - gDistEGU_Output * pPerEGU_Output; i >= range.top(); i -= gDistEGU_Output * pPerEGU_Output) { - drawLine(&painter, QPointF(40, i), QPointF(range.right(), i), pen); - scale.setCoords(0, i - 5, range.left() - 5, i + 5); - painter.drawText(scale, Qt::AlignRight, tr("%1").arg(((range.bottom() - i))/pPerEGU_Output)); + { + const int i = maxx; + double y = range.height() - i * c.y() + range.y(); + drawLine(&painter, + QPointF(range.x(), y), + QPointF(range.x() + range.width(), y), + pen); + painter.drawText(QRectF(10, + y - metrics.height()/2, + range.x() - 10, + metrics.height()), + QString::number(i)); } - // - // Draw the vertical guidelines - // - for (i = range.left(); i <= range.right(); i += gDistEGU_Input * pPerEGU_Input) { - drawLine(&painter, QPointF(i, range.top()), QPointF(i, range.bottom()), pen); - scale.setCoords(i - 10, range.bottom() + 2, i + 10, range.bottom() + 15); - painter.drawText(scale, Qt::AlignCenter, tr("%1").arg(abs(((range.left() - i))/pPerEGU_Input))); + // vertical grid + + for (int i = 0; i < maxy; i += ystep) + { + double x = range.x() + i * c.x(); + drawLine(&painter, + QPointF(x, range.y()), + QPointF(x, range.y() + range.height()), + pen); + const QString text = QString::number(i); + painter.drawText(QRectF(x - metrics.width(text)/2, + range.height() + 10 + metrics.height(), + metrics.width(text), + metrics.height()), + text); + } + { + const int i = maxy; + double x = range.x() + i * c.x(); + drawLine(&painter, + QPointF(x, range.y()), + QPointF(x, range.y() + range.height()), + pen); + const QString text = QString::number(i); + painter.drawText(QRectF(x - metrics.width(text)/2, + range.height() + 10 + metrics.height(), + metrics.width(text), + metrics.height()), + text); } - - scale.setCoords(range.left(), range.bottom() + 20, range.right(), range.bottom() + 35); - painter.drawText(scale, Qt::AlignRight, strInputEGU); - - // - // Draw the EGU of the vertical axis (vertically!) - // - font.setPointSize(10); - painter.translate(range.topLeft().x() - 35, range.topLeft().y()); - painter.rotate(90); - painter.drawText(0,0,strOutputEGU ); - - // - // Draw the two axis - // - pen.setWidth(2); - pen.setColor( Qt::black ); - drawLine(&painter, range.topLeft() - QPointF(2,0), range.bottomLeft() - QPointF(2,0), pen); - drawLine(&painter, range.bottomLeft(), range.bottomRight(), pen); } - -// -// Draw the Function for the graph, on a Pixmap. -// void QFunctionConfigurator::drawFunction() { if (!_config) return; -int i; -QPointF prevPoint; -QPointF currentPoint; - - // - // Use the background picture to draw on. - // ToDo: find out how to add Pixmaps, without getting it all green... - // + int i; + QPointF prevPoint; + QPointF currentPoint; + _function = QPixmap(_background); QPainter painter(&_function); painter.save(); painter.setRenderHint(QPainter::Antialiasing, true); - // - // Draw the handles for the Points - // - QList points = _config->getPoints(); for (i = 0; i < points.size(); i++) { - currentPoint = graphicalizePoint( points[i] ); // Get the next point and convert it to Widget measures + currentPoint = point_to_pixel( points[i] ); // Get the next point and convert it to Widget measures drawPoint(&painter, currentPoint, QColor(200, 200, 210, 120)); lastPoint = currentPoint; // Remember which point is the rightmost in the graph } @@ -210,39 +172,34 @@ QPointF currentPoint; QPen pen(colBezier, 1.2, Qt::SolidLine); - prevPoint = graphicalizePoint( QPointF(0,0) ); // Start at the Axis - double max = maxInputEGU(); - QPointF prev = graphicalizePoint(QPointF(0, 0)); + prevPoint = point_to_pixel( QPointF(0,0) ); // Start at the Axis + double max = _config->maxInput(); + QPointF prev = point_to_pixel(QPointF(0, 0)); const double step = 1.01; for (double i = 0; i < max; i += step) { double val = _config->getValue(i); - QPointF cur = graphicalizePoint(QPointF(i, val)); + QPointF cur = point_to_pixel(QPointF(i, val)); drawLine(&painter, prev, cur, pen); prev = cur; } painter.restore(); } -// -// The Widget paints the surface every x msecs. -// void QFunctionConfigurator::paintEvent(QPaintEvent *e) { -QPointF prevPoint; -QPointF currentPoint; -QPointF actualPos; -int i; - -// qDebug() << "QFunctionConfigurator::paintEvent."; + QPointF prevPoint; + QPointF currentPoint; + QPointF actualPos; + int i; QPainter p(this); p.setRenderHint(QPainter::Antialiasing); if (_draw_background) { - drawBackground(); // Draw the static parts on a Pixmap - p.drawPixmap(e->rect(), _background); // Paint the background + drawBackground(); _draw_background = false; } + p.drawPixmap(e->rect(), _background); if (_draw_function) { drawFunction(); // Draw the Function on a Pixmap @@ -250,33 +207,22 @@ int i; } 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. - // if (movingPoint >= 0 && movingPoint < points.size()) { - prevPoint = graphicalizePoint( QPointF(0,0) ); // Start at the Axis + prevPoint = point_to_pixel( QPointF(0,0) ); // Start at the Axis for (i = 0; i < points.size(); i++) { - currentPoint = graphicalizePoint( points[i] ); // Get the next point and convert it to Widget measures + currentPoint = point_to_pixel( points[i] ); // Get the next point and convert it to Widget measures drawLine(&p, prevPoint, currentPoint, pen); prevPoint = currentPoint; -// qDebug() << "QFunctionConfigurator::paintEvent, drawing while moving " << currentPoint; } - - // - // When moving, also draw a few help-lines, so positioning the point gets easier. - // pen.setWidth(1); pen.setColor( Qt::white ); pen.setStyle( Qt::DashLine ); - actualPos = graphicalizePoint(points[movingPoint]); + actualPos = point_to_pixel(points[movingPoint]); drawLine(&p, QPoint(range.left(), actualPos.y()), QPoint(actualPos.x(), actualPos.y()), pen); - drawLine(&p, QPoint(actualPos.x(), actualPos.y()), QPoint(actualPos.x(), range.bottom()), pen); + drawLine(&p, QPoint(actualPos.x(), actualPos.y()), QPoint(actualPos.x(), range.height() + range.top()), pen); } // @@ -285,32 +231,17 @@ int i; // This new feature is very handy for tweaking the curves! // if (_config->getLastPoint( currentPoint )) { - -// qDebug() << "QFunctionConfigurator::paintEvent, drawing tracked Point " << currentPoint; - - actualPos = graphicalizePoint( currentPoint ); + actualPos = point_to_pixel( currentPoint ); drawPoint(&p, actualPos, QColor(255, 0, 0, 120)); pen.setWidth(1); pen.setColor( Qt::black ); pen.setStyle( Qt::SolidLine ); drawLine(&p, QPoint(range.left(), actualPos.y()), QPoint(actualPos.x(), actualPos.y()), pen); - drawLine(&p, QPoint(actualPos.x(), actualPos.y()), QPoint(actualPos.x(), range.bottom()), pen); + drawLine(&p, QPoint(actualPos.x(), actualPos.y()), QPoint(actualPos.x(), range.width()), pen); } } - - // - // 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())); } // @@ -336,65 +267,40 @@ void QFunctionConfigurator::drawLine(QPainter *painter, const QPointF &start, co painter->restore(); } -// -// If the mousebutton is pressed, check if it is inside one of the Points. -// If so: start moving that Point, until mouse release. -// void QFunctionConfigurator::mousePressEvent(QMouseEvent *e) { if (!_config) return; QList points = _config->getPoints(); - - // - // First: check the left mouse-button - // if (e->button() == Qt::LeftButton) { - - // - // Check to see if the cursor is touching one of the points. - // bool bTouchingPoint = false; movingPoint = -1; if (_config) { for (int i = 0; i < points.size(); i++) { - if ( markContains( graphicalizePoint( points[i] ), e->pos() ) ) { + if ( point_within_pixel(points[i], e->pos() ) ) { bTouchingPoint = true; movingPoint = i; timer.restart(); break; } } - - // - // If the Left Mouse-button was clicked without touching a Point, add a new Point - // if (!bTouchingPoint) { - _config->addPoint(normalizePoint(e->pos())); + _config->addPoint(pixel_coord_to_point(e->pos())); emit CurveChanged( true ); } } } - // Then: check the right mouse-button - // if (e->button() == Qt::RightButton) { - - // - // Check to see if the cursor is touching one of the points. - // if (_config) { int found_pt = -1; for (int i = 0; i < points.size(); i++) { - if ( markContains( graphicalizePoint( points[i] ), e->pos() ) ) { + if ( point_within_pixel(points[i], e->pos() ) ) { found_pt = i; break; } } - // - // If the Right Mouse-button was clicked while touching a Point, remove the Point - // if (found_pt != -1) { _config->removePoint(found_pt); emit CurveChanged( true ); @@ -402,14 +308,10 @@ void QFunctionConfigurator::mousePressEvent(QMouseEvent *e) movingPoint = -1; } } - _draw_function = _draw_background = true; + _draw_function = true; update(); } -// -// If the mouse if moving, make sure the Bezier moves along. -// Of course, only when a Point is selected... -// void QFunctionConfigurator::mouseMoveEvent(QMouseEvent *e) { if (!_config) @@ -423,10 +325,10 @@ void QFunctionConfigurator::mouseMoveEvent(QMouseEvent *e) if (timer.isValid() && timer.elapsed() > refresh_delay) { timer.restart(); - QPointF new_pt = normalizePoint(e->pos()); + QPointF new_pt = pixel_coord_to_point(e->pos()); points[movingPoint] = new_pt; _config->movePoint(movingPoint, new_pt); - _draw_function = _draw_background = true; + _draw_function = true; update(); } } @@ -434,7 +336,7 @@ void QFunctionConfigurator::mouseMoveEvent(QMouseEvent *e) bool bTouchingPoint = false; if (_config) { for (int i = 0; i < points.size(); i++) { - if ( markContains( graphicalizePoint( points[i] ), e->pos() ) ) { + if ( point_within_pixel(points[i], e->pos() ) ) { bTouchingPoint = true; } } @@ -457,118 +359,52 @@ void QFunctionConfigurator::mouseReleaseEvent(QMouseEvent *e) if (e->button() == Qt::LeftButton) { timer.invalidate(); - //qDebug()<<"releasing"; if (movingPoint >= 0 && movingPoint < points.size()) { emit CurveChanged( true ); - - // - // Update the Point in the _config - // if (_config) { - _config->movePoint(movingPoint, normalizePoint(e->pos())); + _config->movePoint(movingPoint, pixel_coord_to_point(e->pos())); } } setCursor(Qt::ArrowCursor); movingPoint = -1; } - _draw_function = _draw_background = true; + _draw_function = true; update(); } -// -// Determine if the mousebutton was pressed within the range of the Point. -// -bool QFunctionConfigurator::markContains(const QPointF &pos, const QPointF &coord) const +bool QFunctionConfigurator::point_within_pixel(QPointF pt, QPointF pixel) const { - return coord.x() >= pos.x() - pointSize && coord.x() < pos.x() + pointSize && - coord.y() >= pos.y() - pointSize && coord.y() < pos.y() + pointSize; -} - -// Convert the Point in the graph, to the real-life Point. -// -QPointF QFunctionConfigurator::normalizePoint(QPointF point) const -{ - QPointF norm; - - norm.setX( (point.x() - range.left()) / pPerEGU_Input ); - norm.setY( (range.bottom() - point.y()) / pPerEGU_Output ); - - if (norm.x() > maxInputEGU()) - norm.setX(maxInputEGU()); - else if (norm.x() < 0) - norm.setX(0); - if (norm.y() > maxOutputEGU()) - norm.setY(maxOutputEGU()); - else if (norm.y() < 0) - norm.setY(0); - - return norm; + QPointF pixel2(range.x() + pt.x() * c.x(), (range.y() + range.height() - pt.y() * c.y())); + return pixel2.x() >= pixel.x() - pointSize && pixel2.x() < pixel.x() + pointSize && + pixel2.y() >= pixel.y() - pointSize && pixel2.y() < pixel.y() + pointSize; } -// -// Convert the real-life Point into the graphical Point. -// -QPointF QFunctionConfigurator::graphicalizePoint(QPointF point) const +QPointF QFunctionConfigurator::pixel_coord_to_point(QPointF point) const { -QPointF graph; - - graph.setX( range.left() + point.x() * pPerEGU_Input); - graph.setY( range.bottom() - point.y() * pPerEGU_Output); - - return graph; -} + if (!_config) + return QPointF(-1, -1); -void QFunctionConfigurator::setmaxInputEGU(int value) -{ - MaxInput = value; - resize( MaxInput * pPerEGU_Input + 55, MaxOutput * pPerEGU_Output + 60 ); -} -void QFunctionConfigurator::setmaxOutputEGU(int value) -{ - MaxOutput = value; -// resetCurve(); - resize( MaxInput * pPerEGU_Input + 55, MaxOutput * pPerEGU_Output + 60 ); -} + double x = (point.x() - range.x()) / c.x(); + double y = (range.height() - point.y() + range.y()) / c.y(); -// -// To make configuration more visibly attractive, the number of pixels 'per EGU' can be defined. -// -void QFunctionConfigurator::setpixPerEGU_Input(int value) -{ - pPerEGU_Input = value; - resize( MaxInput * pPerEGU_Input + 55, MaxOutput * pPerEGU_Output + 60 ); -} + if (x < 0) + x = 0; + if (x > _config->maxInput()) + x = _config->maxInput(); -// -// To make configuration more visibly attractive, the number of pixels 'per EGU' can be defined. -// -void QFunctionConfigurator::setpixPerEGU_Output(int value) -{ - pPerEGU_Output = value; - resize( MaxInput * pPerEGU_Input + 55, MaxOutput * pPerEGU_Output + 60 ); -} + if (y < 0) + y = 0; + if (y > _config->maxOutput()) + y = _config->maxOutput(); -// -// Define the distance of the grid 'in EGU' points. -// -void QFunctionConfigurator::setgridDistEGU_Input(int value) -{ - gDistEGU_Input = value; - _draw_background = true; - _draw_function = true; - repaint(); + return QPointF(x, y); } -// -// Define the distance of the grid 'in EGU' points. -// -void QFunctionConfigurator::setgridDistEGU_Output(int value) +QPointF QFunctionConfigurator::point_to_pixel(QPointF point) const { - gDistEGU_Output = value; - _draw_background = true; - _draw_function = true; - repaint(); + return QPointF(range.x() + point.x() * c.x(), + range.y() + range.height() - point.y() * c.y()); } void QFunctionConfigurator::setColorBezier(QColor color) @@ -577,27 +413,10 @@ void QFunctionConfigurator::setColorBezier(QColor color) update(); } -void QFunctionConfigurator::setInputEGU(QString egu) -{ - strInputEGU = egu; - update(); -} -void QFunctionConfigurator::setOutputEGU(QString egu) -{ - strOutputEGU = egu; - update(); -} -void QFunctionConfigurator::setCaption(QString cap) -{ - strCaption = cap; - update(); -} - void QFunctionConfigurator::resizeEvent(QResizeEvent *) { - range = QRectF(40, 20, MaxInput * pPerEGU_Input, MaxOutput * pPerEGU_Output); - _draw_background = true; _draw_function = true; + update_range(); repaint(); } diff --git a/qfunctionconfigurator/qfunctionconfigurator.h b/qfunctionconfigurator/qfunctionconfigurator.h index 84f4ad8b..17cb3a44 100644 --- a/qfunctionconfigurator/qfunctionconfigurator.h +++ b/qfunctionconfigurator/qfunctionconfigurator.h @@ -25,62 +25,11 @@ class FTNOIR_TRACKER_BASE_EXPORT QFunctionConfigurator : public QWidget { Q_OBJECT - - Q_PROPERTY(double maxInputEGU READ maxInputEGU WRITE setmaxInputEGU) - Q_PROPERTY(double maxOutputEGU READ maxOutputEGU WRITE setmaxOutputEGU) - Q_PROPERTY(double pixPerEGU_Input READ pixPerEGU_Input WRITE setpixPerEGU_Input) - Q_PROPERTY(double pixPerEGU_Output READ pixPerEGU_Output WRITE setpixPerEGU_Output) - Q_PROPERTY(double gridDistEGU_Input READ gridDistEGU_Input WRITE setgridDistEGU_Input) - Q_PROPERTY(double gridDistEGU_Output READ gridDistEGU_Output WRITE setgridDistEGU_Output) - Q_PROPERTY(QColor colorBezier READ colorBezier WRITE setColorBezier) - Q_PROPERTY(QString stringInputEGU READ stringInputEGU WRITE setInputEGU) - Q_PROPERTY(QString stringOutputEGU READ stringOutputEGU WRITE setOutputEGU) - Q_PROPERTY(QString stringCaption READ stringCaption WRITE setCaption) - - // Return the current value to Designer - double maxInputEGU() const - { - return MaxInput; - } - double maxOutputEGU() const - { - return MaxOutput; - } - double pixPerEGU_Input() const - { - return pPerEGU_Input; - } - double pixPerEGU_Output() const - { - return pPerEGU_Output; - } - double gridDistEGU_Input() const - { - return gDistEGU_Input; - } - double gridDistEGU_Output() const - { - return gDistEGU_Output; - } - - QColor colorBezier() const + QColor colorBezier() const { return colBezier; } - QString stringInputEGU() const - { - return strInputEGU; - } - QString stringOutputEGU() const - { - return strOutputEGU; - } - QString stringCaption() const - { - return strCaption; - } - public: QFunctionConfigurator(QWidget *parent = 0); FunctionConfig* config(); @@ -93,18 +42,7 @@ signals: void CurveChanged(bool); public slots: - void setmaxInputEGU(int); - void setmaxOutputEGU(int); - void setpixPerEGU_Input(int); - void setpixPerEGU_Output(int); - void setgridDistEGU_Input(int); - void setgridDistEGU_Output(int); - void setColorBezier(QColor); - void setInputEGU(QString); - void setOutputEGU(QString); - void setCaption(QString); - protected slots: void paintEvent(QPaintEvent *e); void mousePressEvent(QMouseEvent *e); @@ -116,32 +54,32 @@ protected: void drawFunction(); void drawPoint(QPainter *painter, const QPointF &pt, QColor colBG ); void drawLine(QPainter *painter, const QPointF &start, const QPointF &end, QPen pen); - bool markContains(const QPointF &pt, const QPointF &coord) const; + bool point_within_pixel(QPointF pt, QPointF pixel) const; protected: virtual void resizeEvent(QResizeEvent *); private: + void update_range() { + if (!_config) + return; + double w = width(), h = height(); + const double mwl = 40, mhl = 20; + 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()); + } + QRectF range; // The actual rectangle for the Bezier-curve QPointF lastPoint; // The right-most point of the Function - QPointF normalizePoint (QPointF point) const; // Convert the graphical Point to a real-life Point - QPointF graphicalizePoint (QPointF point) const; // Convert the Point to a graphical Point + QPointF pixel_coord_to_point (QPointF point) const; // Convert the graphical Point to a real-life Point + QPointF point_to_pixel (QPointF point) const; // Convert the Point to a graphical Point int movingPoint; QElapsedTimer timer; - - double MaxInput; // Maximum input limit - double MaxOutput; // Maximum output limit - double pPerEGU_Input; // Number of pixels, per EGU of Input - double pPerEGU_Output; // Number of pixels, per EGU of Output - double gDistEGU_Input; // Distance of the grid, in EGU of Input - double gDistEGU_Output; // Distance of the grid, in EGU of Output + QPointF c; QColor colBezier; // Color of Bezier curve - QString strInputEGU; // Engineering Units input (vertical axis) - QString strOutputEGU; // Engineering Units output (horizontal axis) - QString strCaption; // Caption of the graph - QString strSettingsFile; // Name of last read INI-file bool _draw_background; // Flag to determine if the background should be (re-)drawn on the QPixmap QPixmap _background; // Image of the static parts (axis, lines, etc.) -- 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(+) 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(-) 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 d471aba741dc9e3c70c919820e36a2613590d723 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 12 Jan 2014 18:23:21 +0100 Subject: correct focal length equation --- FTNoIR_Tracker_PT/point_tracker.cpp | 4 ++-- FTNoIR_Tracker_PT/point_tracker.h | 4 ++-- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/FTNoIR_Tracker_PT/point_tracker.cpp b/FTNoIR_Tracker_PT/point_tracker.cpp index 96d9d972..885b327a 100644 --- a/FTNoIR_Tracker_PT/point_tracker.cpp +++ b/FTNoIR_Tracker_PT/point_tracker.cpp @@ -250,8 +250,8 @@ void PointTracker::POSIT(float fov, int w, int h) const float HT_PI = 3.1415926535; - const float focal_length_w = 0.5 * w / tan(fov * HT_PI / 180); - const float focal_length_h = 0.5 * h / tan(fov * h / w * HT_PI / 180.0); + const float focal_length_w = 0.5 * w / tan(0.5 * fov * HT_PI / 180); + const float focal_length_h = 0.5 * h / tan(0.5 * fov * h / w * HT_PI / 180.0); cv::Mat intrinsics = cv::Mat::eye(3, 3, CV_32FC1); intrinsics.at (0, 0) = focal_length_w; diff --git a/FTNoIR_Tracker_PT/point_tracker.h b/FTNoIR_Tracker_PT/point_tracker.h index 741d5af4..69eb9bba 100644 --- a/FTNoIR_Tracker_PT/point_tracker.h +++ b/FTNoIR_Tracker_PT/point_tracker.h @@ -104,8 +104,8 @@ protected: if (!rvec.empty() && !tvec.empty() && fov > 0) { const float HT_PI = 3.1415926535; - const float focal_length_w = 0.5 * w / tan(fov * HT_PI / 180); - const float focal_length_h = 0.5 * h / tan(fov * h / w * HT_PI / 180.0); + const float focal_length_w = 0.5 * w / tan(0.5 * fov * HT_PI / 180); + const float focal_length_h = 0.5 * h / tan(0.5 * fov * h / w * HT_PI / 180.0); cv::Mat intrinsics = cv::Mat::eye(3, 3, CV_32FC1); intrinsics.at (0, 0) = focal_length_w; diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index cbd9f531..77f794b9 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -217,8 +217,8 @@ void Tracker::run() const int scale = frame.cols > 480 ? 2 : 1; detector.setThresholdParams(scale > 1 ? 11 : 7, 4); - const float focal_length_w = 0.5 * grayscale.cols / tan(s.fov * HT_PI / 180); - const float focal_length_h = 0.5 * grayscale.rows / tan(s.fov * grayscale.rows / grayscale.cols * HT_PI / 180.0); + const float focal_length_w = 0.5 * grayscale.cols / tan(0.5 * s.fov * HT_PI / 180); + const float focal_length_h = 0.5 * grayscale.rows / tan(0.5 * s.fov * grayscale.rows / grayscale.cols * HT_PI / 180.0); cv::Mat intrinsics = cv::Mat::eye(3, 3, CV_32FC1); intrinsics.at (0, 0) = focal_length_w; intrinsics.at (1, 1) = focal_length_h; @@ -286,7 +286,7 @@ void Tracker::run() cv::TermCriteria(cv::TermCriteria::MAX_ITER | cv::TermCriteria::EPS, 20, 1e-2)); - const float size = 7; + const float size = 3.5; const double p = s.marker_pitch; const double sq = sin(p * HT_PI / 180); -- cgit v1.2.3 From c2b5f86e85698068bd92de0e59e4f7b90c04cd60 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 12 Jan 2014 18:50:44 +0100 Subject: remove fisheye correction based on wrong focal length --- ftnoir_tracker_aruco/aruco-trackercontrols.ui | 341 ++++++++++++-------------- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 7 - ftnoir_tracker_aruco/ftnoir_tracker_aruco.h | 4 +- 3 files changed, 164 insertions(+), 188 deletions(-) diff --git a/ftnoir_tracker_aruco/aruco-trackercontrols.ui b/ftnoir_tracker_aruco/aruco-trackercontrols.ui index 59d3f69c..03975390 100644 --- a/ftnoir_tracker_aruco/aruco-trackercontrols.ui +++ b/ftnoir_tracker_aruco/aruco-trackercontrols.ui @@ -10,7 +10,7 @@ 0 0 615 - 353 + 326 @@ -32,176 +32,7 @@ 7 - - - - - - - - Default - - - - - 30 - - - - - 60 - - - - - 120 - - - - - 180 - - - - - - - - Frames per second - - - - - - - Recommended! - - - - - - - - 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 - - - - - - - Red channel only - - - - - - - Horizontal FOV - - - - - - - - 640x480 - - - - - 320x240 - - - - - 320x200 - - - - - Default (not recommended!) - - - - - - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - Resolution - - - - - - - -180.000000000000000 - - - 180.000000000000000 - - - - - - - Marker pitch - - - - + Head position @@ -348,17 +179,172 @@ - - + + + + Frames per second + + + + + + + + + + + Default + + + + + 30 + + + + + 60 + + + + + 120 + + + + + 180 + + + + + + - Check if yaw/X interconnect + Recommended! - - + + - Fisheye correction + Camera name + + + + + + + + + + 35.000000000000000 + + + 180.000000000000000 + + + 52.000000000000000 + + + + + + + + 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 + + + + + + + Red channel only + + + + + + + + 640x480 + + + + + 320x240 + + + + + 320x200 + + + + + Default (not recommended!) + + + + + + + + Horizontal FOV + + + + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + -180.000000000000000 + + + 180.000000000000000 + + + + + + + Resolution + + + + + + + Marker pitch @@ -371,7 +357,6 @@ resolution red_only marker_pitch - fisheye_correction cx cy cz diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index 77f794b9..9d484775 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -353,12 +353,6 @@ void Tracker::run() pose[Yaw] = euler[1]; pose[Pitch] = -euler[0]; pose[Roll] = euler[2]; - - if (s.fisheye_correction) - { - pose[Yaw] -= atan(pose[TX] / pose[TZ]) * 180 / HT_PI; - pose[Pitch] -= atan(pose[TY] / pose[TZ]) * 180 / HT_PI; - } } std::vector repr2; @@ -482,7 +476,6 @@ TrackerControls::TrackerControls() tie_setting(s.headpos_z, ui.cz); tie_setting(s.red_only, ui.red_only); tie_setting(s.marker_pitch, ui.marker_pitch); - tie_setting(s.fisheye_correction, ui.fisheye_correction); connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); ui.cameraName->addItems(get_camera_names()); diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h index e32e304a..4cab84b5 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h @@ -28,7 +28,6 @@ struct settings { value red_only; value eyaw, epitch, eroll, ex, ey, ez; value marker_pitch; - value fisheye_correction; settings() : b(bundle("aruco-tracker")), fov(b, "field-of-view", 56), @@ -45,8 +44,7 @@ struct settings { ex(b, "enable-x", true), ey(b, "enable-y", true), ez(b, "enable-z", true), - marker_pitch(b, "marker-pitch", 0), - fisheye_correction(b, "fisheye-correction", false) + marker_pitch(b, "marker-pitch", 0) {} }; -- cgit v1.2.3 From 6e822bf3984270ead48249714f2cd77747fc2383 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 12 Jan 2014 18:50:54 +0100 Subject: display current value in qfc correctly --- qfunctionconfigurator/qfunctionconfigurator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qfunctionconfigurator/qfunctionconfigurator.cpp b/qfunctionconfigurator/qfunctionconfigurator.cpp index 6540e66f..b959b56c 100644 --- a/qfunctionconfigurator/qfunctionconfigurator.cpp +++ b/qfunctionconfigurator/qfunctionconfigurator.cpp @@ -232,7 +232,7 @@ void QFunctionConfigurator::paintEvent(QPaintEvent *e) // This new feature is very handy for tweaking the curves! // if (_config->getLastPoint( currentPoint )) { - actualPos = point_to_pixel( currentPoint ); + actualPos = point_to_pixel( QPointF(fabs(currentPoint.x()), fabs(currentPoint.y())) ); drawPoint(&p, actualPos, QColor(255, 0, 0, 120)); pen.setWidth(1); -- cgit v1.2.3 From b83a47cb32443981ce9998b2015f7d310fb72821 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 12 Jan 2014 19:49:57 +0100 Subject: Revert "correct focal length equation" This reverts commit 4312ef4098a449d38209c4f20ed573e9deb1713c. --- FTNoIR_Tracker_PT/point_tracker.cpp | 4 ++-- FTNoIR_Tracker_PT/point_tracker.h | 4 ++-- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/FTNoIR_Tracker_PT/point_tracker.cpp b/FTNoIR_Tracker_PT/point_tracker.cpp index 885b327a..96d9d972 100644 --- a/FTNoIR_Tracker_PT/point_tracker.cpp +++ b/FTNoIR_Tracker_PT/point_tracker.cpp @@ -250,8 +250,8 @@ void PointTracker::POSIT(float fov, int w, int h) const float HT_PI = 3.1415926535; - const float focal_length_w = 0.5 * w / tan(0.5 * fov * HT_PI / 180); - const float focal_length_h = 0.5 * h / tan(0.5 * fov * h / w * HT_PI / 180.0); + const float focal_length_w = 0.5 * w / tan(fov * HT_PI / 180); + const float focal_length_h = 0.5 * h / tan(fov * h / w * HT_PI / 180.0); cv::Mat intrinsics = cv::Mat::eye(3, 3, CV_32FC1); intrinsics.at (0, 0) = focal_length_w; diff --git a/FTNoIR_Tracker_PT/point_tracker.h b/FTNoIR_Tracker_PT/point_tracker.h index 69eb9bba..741d5af4 100644 --- a/FTNoIR_Tracker_PT/point_tracker.h +++ b/FTNoIR_Tracker_PT/point_tracker.h @@ -104,8 +104,8 @@ protected: if (!rvec.empty() && !tvec.empty() && fov > 0) { const float HT_PI = 3.1415926535; - const float focal_length_w = 0.5 * w / tan(0.5 * fov * HT_PI / 180); - const float focal_length_h = 0.5 * h / tan(0.5 * fov * h / w * HT_PI / 180.0); + const float focal_length_w = 0.5 * w / tan(fov * HT_PI / 180); + const float focal_length_h = 0.5 * h / tan(fov * h / w * HT_PI / 180.0); cv::Mat intrinsics = cv::Mat::eye(3, 3, CV_32FC1); intrinsics.at (0, 0) = focal_length_w; diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index 9d484775..fc641ef1 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -217,8 +217,8 @@ void Tracker::run() const int scale = frame.cols > 480 ? 2 : 1; detector.setThresholdParams(scale > 1 ? 11 : 7, 4); - const float focal_length_w = 0.5 * grayscale.cols / tan(0.5 * s.fov * HT_PI / 180); - const float focal_length_h = 0.5 * grayscale.rows / tan(0.5 * s.fov * grayscale.rows / grayscale.cols * HT_PI / 180.0); + const float focal_length_w = 0.5 * grayscale.cols / tan(s.fov * HT_PI / 180); + const float focal_length_h = 0.5 * grayscale.rows / tan(s.fov * grayscale.rows / grayscale.cols * HT_PI / 180.0); cv::Mat intrinsics = cv::Mat::eye(3, 3, CV_32FC1); intrinsics.at (0, 0) = focal_length_w; intrinsics.at (1, 1) = focal_length_h; @@ -286,7 +286,7 @@ void Tracker::run() cv::TermCriteria(cv::TermCriteria::MAX_ITER | cv::TermCriteria::EPS, 20, 1e-2)); - const float size = 3.5; + const float size = 7; const double p = s.marker_pitch; const double sq = sin(p * HT_PI / 180); -- cgit v1.2.3 From 488198a4b440936a7fb7fc90c5527a32a0f0b249 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 12 Jan 2014 19:50:00 +0100 Subject: Revert "FINALLY fix d_order -> image pos" This reverts commit 4bfda0171465193476cebb03373ae165ab9e67ab. --- FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp | 3 ++- FTNoIR_Tracker_PT/point_tracker.cpp | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp index c949b8d0..102f62ee 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp @@ -85,7 +85,8 @@ void Tracker::run() const std::vector& points = point_extractor.extract_points(frame, dt, true); for (auto p : points) { - auto p2 = cv::Point(p[0] * frame.cols + frame.cols/2, -p[1] * frame.cols + frame.rows/2); + auto p2 = cv::Point(p[0] * frame.cols + frame.cols/2, + -p[1] * frame.cols + frame.rows/2); cv::Scalar color(0, 255, 0); cv::line(frame, cv::Point(p2.x - 20, p2.y), diff --git a/FTNoIR_Tracker_PT/point_tracker.cpp b/FTNoIR_Tracker_PT/point_tracker.cpp index 96d9d972..faac9963 100644 --- a/FTNoIR_Tracker_PT/point_tracker.cpp +++ b/FTNoIR_Tracker_PT/point_tracker.cpp @@ -244,7 +244,7 @@ void PointTracker::POSIT(float fov, int w, int h) for (int i = 0; i < 3; i++) { - auto p2 = cv::Point(p[i][0] * w + w/2, -p[i][1] * w + h/2); + auto p2 = cv::Point(p[i][0] * w + w/2, -p[i][1] * h + w/2); img_points.push_back(p2); } -- cgit v1.2.3 From fcda9735bf3df5b43286cbd340f4c85de9228323 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 12 Jan 2014 19:50:03 +0100 Subject: Revert "remove forgotten debug code" This reverts commit c2bd0204f1cc9f68d0a43581aa6a767959d92ed0. --- FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp index 102f62ee..9f74127f 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp @@ -88,6 +88,7 @@ void Tracker::run() auto p2 = cv::Point(p[0] * frame.cols + frame.cols/2, -p[1] * frame.cols + frame.rows/2); cv::Scalar color(0, 255, 0); + qDebug() << p2.x << p2.y; cv::line(frame, cv::Point(p2.x - 20, p2.y), cv::Point(p2.x + 20, p2.y), -- cgit v1.2.3 From f281ba0224b31eec31469372b3cbc27706a9b381 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 12 Jan 2014 19:50:03 +0100 Subject: Revert "use correct scale for point coords" This reverts commit 3ea8dbeb7574e7a61388adcc3a9fd722798504fe. --- FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp | 2 +- FTNoIR_Tracker_PT/point_tracker.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp index 9f74127f..c94fa3ff 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp @@ -86,7 +86,7 @@ void Tracker::run() for (auto p : points) { auto p2 = cv::Point(p[0] * frame.cols + frame.cols/2, - -p[1] * frame.cols + frame.rows/2); + p[1] * frame.rows + frame.rows/2); cv::Scalar color(0, 255, 0); qDebug() << p2.x << p2.y; cv::line(frame, diff --git a/FTNoIR_Tracker_PT/point_tracker.cpp b/FTNoIR_Tracker_PT/point_tracker.cpp index faac9963..69d46645 100644 --- a/FTNoIR_Tracker_PT/point_tracker.cpp +++ b/FTNoIR_Tracker_PT/point_tracker.cpp @@ -244,7 +244,7 @@ void PointTracker::POSIT(float fov, int w, int h) for (int i = 0; i < 3; i++) { - auto p2 = cv::Point(p[i][0] * w + w/2, -p[i][1] * h + w/2); + auto p2 = cv::Point(p[i][0] * w + w/2, p[i][1] * h + h/2); img_points.push_back(p2); } -- cgit v1.2.3 From 74b4bd09a8b70ceeec59a96b50bd36b3ebfa1237 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 12 Jan 2014 19:50:05 +0100 Subject: Revert "use proper scale for translation" This reverts commit efe0a4ae5985fbbbca6ae86c40c61d87d4aa6bae. --- FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp index c94fa3ff..b4100998 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp @@ -218,9 +218,9 @@ void Tracker::GetHeadPoseData(THeadPoseData *data) Vec3f t = X_GH.t - X_GH_0.t; // get translation(s) - if (s.bEnableX) data[TX] = t[0]; // convert to cm - if (s.bEnableY) data[TY] = t[1]; - if (s.bEnableZ) data[TZ] = t[2]; + if (s.bEnableX) data[TX] = t[0] / 10.0; // convert to cm + if (s.bEnableY) data[TY] = t[1] / 10.0; + if (s.bEnableZ) data[TZ] = t[2] / 10.0; // translate rotation matrix from opengl (G) to roll-pitch-yaw (E) frame // -z -> x, y -> z, x -> -y -- cgit v1.2.3 From 4e4e72f6c9c2c133f050c04c4f9117aebfd1ee4b Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 12 Jan 2014 19:50:05 +0100 Subject: Revert "reset levmarq internal state on reset (duh)" This reverts commit 476b4fd96effe8108ad65930bb90cb2a4bed2216. --- FTNoIR_Tracker_PT/point_tracker.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/FTNoIR_Tracker_PT/point_tracker.cpp b/FTNoIR_Tracker_PT/point_tracker.cpp index 69d46645..2dd89aed 100644 --- a/FTNoIR_Tracker_PT/point_tracker.cpp +++ b/FTNoIR_Tracker_PT/point_tracker.cpp @@ -104,8 +104,6 @@ void PointTracker::reset() // assume identity rotation again X_CM.R = cv::Matx33f::eye(); X_CM.t = cv::Vec3f(0, 0, 1); - rvec = Mat(); - tvec = Mat(); } void PointTracker::reset_velocities() -- cgit v1.2.3 From 421f63c8ff3d434fec8a93e38e9178cdb3c593c6 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 12 Jan 2014 19:50:06 +0100 Subject: Revert "fix translation estimation" This reverts commit 5cf25c6d0e524d21ea3eb9691f922b8c9b2fd73d. --- FTNoIR_Tracker_PT/point_tracker.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/FTNoIR_Tracker_PT/point_tracker.cpp b/FTNoIR_Tracker_PT/point_tracker.cpp index 2dd89aed..a881da62 100644 --- a/FTNoIR_Tracker_PT/point_tracker.cpp +++ b/FTNoIR_Tracker_PT/point_tracker.cpp @@ -240,11 +240,9 @@ void PointTracker::POSIT(float fov, int w, int h) obj_points.push_back(point_model->M01); obj_points.push_back(point_model->M02); - for (int i = 0; i < 3; i++) - { - auto p2 = cv::Point(p[i][0] * w + w/2, p[i][1] * h + h/2); - img_points.push_back(p2); - } + img_points.push_back(p[0]); + img_points.push_back(p[1]); + img_points.push_back(p[2]); const float HT_PI = 3.1415926535; -- cgit v1.2.3 From 0d2a44867c9f5c31789152e8f5735dc85987554e Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 12 Jan 2014 19:50:07 +0100 Subject: Revert "display extracted points' centers" This reverts commit cfbcc6b5dba563b3d4d41a82aa990445730b0528. --- FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp index b4100998..83bf6911 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp @@ -83,23 +83,6 @@ void Tracker::run() { frame = frame_rotation.rotate_frame(frame); const std::vector& points = point_extractor.extract_points(frame, dt, true); - for (auto p : points) - { - auto p2 = cv::Point(p[0] * frame.cols + frame.cols/2, - p[1] * frame.rows + frame.rows/2); - cv::Scalar color(0, 255, 0); - qDebug() << p2.x << p2.y; - cv::line(frame, - cv::Point(p2.x - 20, p2.y), - cv::Point(p2.x + 20, p2.y), - color, - 4); - cv::line(frame, - cv::Point(p2.x, p2.y - 20), - cv::Point(p2.x, p2.y + 20), - color, - 4); - } tracking_valid = point_tracker.track(points, camera.get_info().fov, dt, frame.cols, frame.rows); video_widget->update_image(frame); } -- cgit v1.2.3 From 302dfd055bd368752216701a0d0e963d5bf6d3e9 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 12 Jan 2014 19:53:59 +0100 Subject: Revert "remove hack of passing fov/w/h as member vars" This reverts commit 6e1610667fb33517299997e628652fd91380e762. --- FTNoIR_Tracker_PT/point_tracker.cpp | 19 +++++++++++++------ FTNoIR_Tracker_PT/point_tracker.h | 8 ++++++-- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/FTNoIR_Tracker_PT/point_tracker.cpp b/FTNoIR_Tracker_PT/point_tracker.cpp index a881da62..cce327e9 100644 --- a/FTNoIR_Tracker_PT/point_tracker.cpp +++ b/FTNoIR_Tracker_PT/point_tracker.cpp @@ -91,7 +91,10 @@ PointTracker::PointTracker() dt_reset(1), v_t(0,0,0), v_r(0,0,0), - dynamic_pose_resolution(true) + dynamic_pose_resolution(true), + fov(0), + _w(0), + _h(0) { } @@ -141,7 +144,7 @@ bool PointTracker::track(const vector& points, float fov, float dt, int w predict(dt_valid); // if there is a point correspondence problem something has gone wrong, do a reset - if (!find_correspondences(points, fov, w, h)) + if (!find_correspondences(points)) { //qDebug()<<"Error in finding point correspondences!"; X_CM = X_CM_old; // undo prediction @@ -178,7 +181,7 @@ void PointTracker::update_velocities(float dt) v_t = (X_CM.t - X_CM_old.t)/dt; } -bool PointTracker::find_correspondences(const vector& points, float fov, int w, int h) +bool PointTracker::find_correspondences(const vector& points) { if (init_phase) { // We do a simple freetrack-like sorting in the init phase... @@ -195,9 +198,9 @@ bool PointTracker::find_correspondences(const vector& points, float fov, 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), fov, w, h); - p_exp[1] = project(point_model->M01, fov, w, h); - p_exp[2] = project(point_model->M02, fov, w, h); + p_exp[0] = project(Vec3f(0,0,0)); + p_exp[1] = project(point_model->M01); + p_exp[2] = project(point_model->M02); // set correspondences by minimum distance to projected model point bool point_taken[PointModel::N_POINTS]; @@ -233,6 +236,10 @@ bool PointTracker::find_correspondences(const vector& points, float fov, void PointTracker::POSIT(float fov, int w, int h) { + // XXX hack + this->fov = fov; + _w = w; + _h = h; std::vector obj_points; std::vector img_points; diff --git a/FTNoIR_Tracker_PT/point_tracker.h b/FTNoIR_Tracker_PT/point_tracker.h index 741d5af4..ac43489e 100644 --- a/FTNoIR_Tracker_PT/point_tracker.h +++ b/FTNoIR_Tracker_PT/point_tracker.h @@ -98,12 +98,16 @@ public: FrameTrafo get_pose() const { return X_CM; } void reset(); + float fov; + int _w, _h; + protected: - cv::Vec2f project(const cv::Vec3f& v_M, float fov, int w, int h) + cv::Vec2f project(const cv::Vec3f& v_M) { if (!rvec.empty() && !tvec.empty() && fov > 0) { const float HT_PI = 3.1415926535; + const int w = _w, h = _h; const float focal_length_w = 0.5 * w / tan(fov * HT_PI / 180); const float focal_length_h = 0.5 * h / tan(fov * h / w * HT_PI / 180.0); @@ -122,7 +126,7 @@ protected: return cv::Vec2f(); } - bool find_correspondences(const std::vector& points, float fov, int w, int h); + bool find_correspondences(const std::vector& points); cv::Vec2f p[PointModel::N_POINTS]; // the points in model order cv::Vec2f p_exp[PointModel::N_POINTS]; // the expected point positions -- cgit v1.2.3 From 7a7f7e70a6f104c5838b162f4d28afa6a8ae1d5f Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 12 Jan 2014 19:54:00 +0100 Subject: Revert "remove an outdated comment" This reverts commit 7be138a8ece3cd90e0cbca0b30e812d0a19d10c6. --- FTNoIR_Tracker_PT/point_tracker.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/FTNoIR_Tracker_PT/point_tracker.cpp b/FTNoIR_Tracker_PT/point_tracker.cpp index cce327e9..c0221909 100644 --- a/FTNoIR_Tracker_PT/point_tracker.cpp +++ b/FTNoIR_Tracker_PT/point_tracker.cpp @@ -152,6 +152,7 @@ bool PointTracker::track(const vector& points, float fov, float dt, int w return false; } + // XXX TODO fov POSIT(fov, w, h); //qDebug()<<"Number of POSIT iterations: "< Date: Sun, 12 Jan 2014 19:54:01 +0100 Subject: Revert "don't touch tvec scale" This reverts commit 69bc6490911f062c7eb72ff73431bfe7381034fd. --- FTNoIR_Tracker_PT/point_tracker.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FTNoIR_Tracker_PT/point_tracker.cpp b/FTNoIR_Tracker_PT/point_tracker.cpp index c0221909..9f0fb59e 100644 --- a/FTNoIR_Tracker_PT/point_tracker.cpp +++ b/FTNoIR_Tracker_PT/point_tracker.cpp @@ -290,7 +290,7 @@ void PointTracker::POSIT(float fov, int w, int h) // apply results for (int i = 0; i < 3; i++) { - X_CM.t[i] = tvec.at(i); + X_CM.t[i] = tvec.at(i) * 1e-2; for (int j = 0; j < 3; j++) X_CM.R(i, j) = rmat.at(i, j); } -- cgit v1.2.3 From 80c43ba62517d1228423f9d1992999edda612616 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 12 Jan 2014 19:54:02 +0100 Subject: Revert "fix crash due to mismatched float/double" This reverts commit 9fc8e2da02f2e5c2295199826e408cc026d6eae6. --- FTNoIR_Tracker_PT/point_tracker.cpp | 11 ++++------- FTNoIR_Tracker_PT/point_tracker.h | 14 +++++++------- FTNoIR_Tracker_PT/trans_calib.cpp | 4 ++-- 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/FTNoIR_Tracker_PT/point_tracker.cpp b/FTNoIR_Tracker_PT/point_tracker.cpp index 9f0fb59e..263be43a 100644 --- a/FTNoIR_Tracker_PT/point_tracker.cpp +++ b/FTNoIR_Tracker_PT/point_tracker.cpp @@ -105,8 +105,8 @@ void PointTracker::reset() dt_valid = 0; reset_velocities(); // assume identity rotation again - X_CM.R = cv::Matx33f::eye(); - X_CM.t = cv::Vec3f(0, 0, 1); + X_CM.R = cv::Matx33d::eye(); + X_CM.t = cv::Vec3f(); } void PointTracker::reset_velocities() @@ -168,7 +168,7 @@ bool PointTracker::track(const vector& points, float fov, float dt, int w void PointTracker::predict(float dt) { // predict with constant velocity - Matx33f R; + Matx33d R; Rodrigues(dt*v_r, R); X_CM.R = R*X_CM.R; X_CM.t += dt * v_t; @@ -273,10 +273,7 @@ void PointTracker::POSIT(float fov, int w, int h) cv::Rodrigues(rvec, rmat); // finally, find the closer solution - cv::Mat expected(3, 3, CV_64FC1); - for (int i = 0; i < 3; i++) - for (int j = 0; j < 3; j++) - expected.at(i, j) = X_CM.R(i, j); + cv::Mat expected = cv::Mat(X_CM.R); cv::Mat eye = cv::Mat::eye(3, 3, CV_64FC1); double dev1 = norm(eye - expected * rmat.t()); double dev2 = norm(eye - expected * rmat); diff --git a/FTNoIR_Tracker_PT/point_tracker.h b/FTNoIR_Tracker_PT/point_tracker.h index ac43489e..823d75c0 100644 --- a/FTNoIR_Tracker_PT/point_tracker.h +++ b/FTNoIR_Tracker_PT/point_tracker.h @@ -21,11 +21,11 @@ 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) {} + FrameTrafo() : R(cv::Matx33d::eye()), t(0,0,0) {} + FrameTrafo(const cv::Matx33d& R, const cv::Vec3d& t) : R(R),t(t) {} - cv::Matx33f R; - cv::Vec3f t; + cv::Matx33d R; + cv::Vec3d t; }; inline FrameTrafo operator*(const FrameTrafo& X, const FrameTrafo& Y) @@ -33,17 +33,17 @@ inline FrameTrafo operator*(const FrameTrafo& X, const FrameTrafo& Y) return FrameTrafo(X.R*Y.R, X.R*Y.t + X.t); } -inline FrameTrafo operator*(const cv::Matx33f& X, const FrameTrafo& Y) +inline FrameTrafo operator*(const cv::Matx33d& X, const FrameTrafo& Y) { return FrameTrafo(X*Y.R, X*Y.t); } -inline FrameTrafo operator*(const FrameTrafo& X, const cv::Matx33f& Y) +inline FrameTrafo operator*(const FrameTrafo& X, const cv::Matx33d& Y) { return FrameTrafo(X.R*Y, X.t); } -inline cv::Vec3f operator*(const FrameTrafo& X, const cv::Vec3f& v) +inline cv::Vec3f operator*(const FrameTrafo& X, const cv::Vec3d& v) { return X.R*v + X.t; } diff --git a/FTNoIR_Tracker_PT/trans_calib.cpp b/FTNoIR_Tracker_PT/trans_calib.cpp index b2e0ead0..9b75a1b6 100644 --- a/FTNoIR_Tracker_PT/trans_calib.cpp +++ b/FTNoIR_Tracker_PT/trans_calib.cpp @@ -40,5 +40,5 @@ void TranslationCalibrator::update(const Matx33f& R_CM_k, const Vec3f& t_CM_k) Vec3f TranslationCalibrator::get_estimate() { Vec6f x = P.inv() * y; - return Vec3f(-x[0], -x[1], -x[2]); -} + return Vec3f(-x[0], -x[1], -x[2]); +} \ No newline at end of file -- cgit v1.2.3 From 9d21e7d23fa17b91fb76a14d90630b027b78c2c8 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 12 Jan 2014 19:54:03 +0100 Subject: Revert "buffer flush" This reverts commit 0f6a0d8b20aa1d7415f6d0596f91ea9b766ecf69. --- FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp | 30 ++++++++++++++++-------------- FTNoIR_Tracker_PT/point_tracker.cpp | 33 +++++++++------------------------ FTNoIR_Tracker_PT/point_tracker.h | 18 +++++++++--------- 3 files changed, 34 insertions(+), 47 deletions(-) diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp index 83bf6911..740cf3da 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp @@ -82,8 +82,8 @@ void Tracker::run() if (new_frame && !frame.empty()) { frame = frame_rotation.rotate_frame(frame); - const std::vector& points = point_extractor.extract_points(frame, dt, true); - tracking_valid = point_tracker.track(points, camera.get_info().fov, dt, frame.cols, frame.rows); + const std::vector& points = point_extractor.extract_points(frame, dt, false); + tracking_valid = point_tracker.track(points, camera.get_info().fov, dt, frame.cols, frame.rows, t_MH); video_widget->update_image(frame); } #ifdef PT_PERF_LOG @@ -118,13 +118,15 @@ void Tracker::apply(settings& s) point_tracker.dt_reset = s.reset_time / 1000.0; t_MH = cv::Vec3f(s.t_MH_x, s.t_MH_y, s.t_MH_z); R_GC = Matx33f( cos(deg2rad*s.cam_yaw), 0, sin(deg2rad*s.cam_yaw), - 0, 1, 0, - -sin(deg2rad*s.cam_yaw), 0, cos(deg2rad*s.cam_yaw)); - R_GC = R_GC * Matx33f( 1, 0, 0, + 0, 1, 0, + -sin(deg2rad*s.cam_yaw), 0, cos(deg2rad*s.cam_yaw)); + R_GC = R_GC * Matx33f( 1, 0, 0, 0, cos(deg2rad*s.cam_pitch), sin(deg2rad*s.cam_pitch), 0, -sin(deg2rad*s.cam_pitch), cos(deg2rad*s.cam_pitch)); - FrameTrafo X_MH(Matx33f::eye(), t_MH); - X_GH_0 = R_GC * X_MH; + + FrameTrafo X_MH(Matx33f::eye(), t_MH); + X_GH_0 = R_GC * X_MH; + qDebug()<<"Tracker::apply ends"; } @@ -137,10 +139,10 @@ void 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_GH_0 = R_GC * X_CM_0 * X_MH; + QMutexLocker lock(&mutex); + FrameTrafo X_CM_0 = point_tracker.get_pose(); + FrameTrafo X_MH(Matx33f::eye(), t_MH); + X_GH_0 = R_GC * X_CM_0 * X_MH; } bool Tracker::get_frame_and_points(cv::Mat& frame_copy, boost::shared_ptr< std::vector >& points) @@ -195,10 +197,10 @@ void Tracker::GetHeadPoseData(THeadPoseData *data) if (!tracking_valid) return; FrameTrafo X_CM = point_tracker.get_pose(); - FrameTrafo X_MH(Matx33f::eye(), t_MH); - FrameTrafo X_GH = R_GC * X_CM * X_MH; + 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(); - Vec3f t = X_GH.t - X_GH_0.t; + Vec3f t = X_GH.t - X_GH_0.t; // get translation(s) if (s.bEnableX) data[TX] = t[0] / 10.0; // convert to cm diff --git a/FTNoIR_Tracker_PT/point_tracker.cpp b/FTNoIR_Tracker_PT/point_tracker.cpp index 263be43a..1df70b17 100644 --- a/FTNoIR_Tracker_PT/point_tracker.cpp +++ b/FTNoIR_Tracker_PT/point_tracker.cpp @@ -104,9 +104,6 @@ void PointTracker::reset() init_phase = true; dt_valid = 0; reset_velocities(); - // assume identity rotation again - X_CM.R = cv::Matx33d::eye(); - X_CM.t = cv::Vec3f(); } void PointTracker::reset_velocities() @@ -116,7 +113,7 @@ void PointTracker::reset_velocities() } -bool PointTracker::track(const vector& points, float fov, float dt, int w, int h) +bool PointTracker::track(const vector& points, float fov, float dt, int w, int h, const cv::Vec3f& headpos) { if (!dynamic_pose_resolution) init_phase = true; @@ -153,7 +150,7 @@ bool PointTracker::track(const vector& points, float fov, float dt, int w } // XXX TODO fov - POSIT(fov, w, h); + POSIT(fov, w, h, headpos); //qDebug()<<"Number of POSIT iterations: "<& points, float fov, float dt, int w void PointTracker::predict(float dt) { // predict with constant velocity - Matx33d R; + Matx33f R; Rodrigues(dt*v_r, R); X_CM.R = R*X_CM.R; X_CM.t += dt * v_t; @@ -235,7 +232,7 @@ bool PointTracker::find_correspondences(const vector& points) -void PointTracker::POSIT(float fov, int w, int h) +void PointTracker::POSIT(float fov, int w, int h, const cv::Vec3f& headpos) { // XXX hack this->fov = fov; @@ -244,9 +241,9 @@ void PointTracker::POSIT(float fov, int w, int h) std::vector obj_points; std::vector img_points; - obj_points.push_back(cv::Vec3f(0, 0, 0)); - obj_points.push_back(point_model->M01); - obj_points.push_back(point_model->M02); + obj_points.push_back(headpos); + obj_points.push_back(point_model->M01 + headpos); + obj_points.push_back(point_model->M02 + headpos); img_points.push_back(p[0]); img_points.push_back(p[1]); @@ -265,29 +262,17 @@ void PointTracker::POSIT(float fov, int w, int h) cv::Mat dist_coeffs = cv::Mat::zeros(5, 1, CV_32FC1); - bool lastp = !rvec.empty() && !tvec.empty(); + bool lastp = !rvec.empty() && !tvec.empty() && !init_phase; cv::solvePnP(obj_points, img_points, intrinsics, dist_coeffs, rvec, tvec, lastp, cv::ITERATIVE); cv::Mat rmat; cv::Rodrigues(rvec, rmat); - // finally, find the closer solution - cv::Mat expected = cv::Mat(X_CM.R); - cv::Mat eye = cv::Mat::eye(3, 3, CV_64FC1); - double dev1 = norm(eye - expected * rmat.t()); - double dev2 = norm(eye - expected * rmat); - - if (dev1 > dev2) - { - rmat = rmat.t(); - cv::Rodrigues(rmat, rvec); - } - // apply results for (int i = 0; i < 3; i++) { - X_CM.t[i] = tvec.at(i) * 1e-2; + X_CM.t[i] = tvec.at(i); for (int j = 0; j < 3; j++) X_CM.R(i, j) = rmat.at(i, j); } diff --git a/FTNoIR_Tracker_PT/point_tracker.h b/FTNoIR_Tracker_PT/point_tracker.h index 823d75c0..e05e8f98 100644 --- a/FTNoIR_Tracker_PT/point_tracker.h +++ b/FTNoIR_Tracker_PT/point_tracker.h @@ -21,11 +21,11 @@ class FrameTrafo { public: - FrameTrafo() : R(cv::Matx33d::eye()), t(0,0,0) {} - FrameTrafo(const cv::Matx33d& R, const cv::Vec3d& t) : R(R),t(t) {} + FrameTrafo() : R(cv::Matx33f::eye()), t(0,0,0) {} + FrameTrafo(const cv::Matx33f& R, const cv::Vec3f& t) : R(R),t(t) {} - cv::Matx33d R; - cv::Vec3d t; + cv::Matx33f R; + cv::Vec3f t; }; inline FrameTrafo operator*(const FrameTrafo& X, const FrameTrafo& Y) @@ -33,17 +33,17 @@ inline FrameTrafo operator*(const FrameTrafo& X, const FrameTrafo& Y) return FrameTrafo(X.R*Y.R, X.R*Y.t + X.t); } -inline FrameTrafo operator*(const cv::Matx33d& X, const FrameTrafo& Y) +inline FrameTrafo operator*(const cv::Matx33f& X, const FrameTrafo& Y) { return FrameTrafo(X*Y.R, X*Y.t); } -inline FrameTrafo operator*(const FrameTrafo& X, const cv::Matx33d& Y) +inline FrameTrafo operator*(const FrameTrafo& X, const cv::Matx33f& Y) { return FrameTrafo(X.R*Y, X.t); } -inline cv::Vec3f operator*(const FrameTrafo& X, const cv::Vec3d& v) +inline cv::Vec3f operator*(const FrameTrafo& X, const cv::Vec3f& v) { return X.R*v + X.t; } @@ -90,7 +90,7 @@ public: // 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 fov, float dt, int w, int h); + bool track(const std::vector& points, float fov, float dt, int w, int h, const cv::Vec3f &headpos); boost::shared_ptr point_model; bool dynamic_pose_resolution; @@ -136,7 +136,7 @@ protected: void reset_velocities(); - void POSIT(float fov, int w, int h); // The POSIT algorithm, returns the number of iterations + void POSIT(float fov, int w, int h, const cv::Vec3f &headpos); // The POSIT algorithm, returns the number of iterations bool init_phase; float dt_valid; // time since last valid tracking result -- cgit v1.2.3 From 689c297be28e2f5050e234bdc69594c53166f194 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 12 Jan 2014 19:54:04 +0100 Subject: Revert "use levmarq instead of coplanar POSIT implemented in numerically unstable fashion" This reverts commit 0bc59a0a7a42bcf65ebf3814e5f25fb17d735faa. --- FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui | 13 +- FTNoIR_Tracker_PT/camera.cpp | 8 +- FTNoIR_Tracker_PT/camera.h | 6 +- FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp | 4 +- FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.cpp | 2 +- FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.h | 4 +- FTNoIR_Tracker_PT/point_tracker.cpp | 191 +++++++++++++++++++------ FTNoIR_Tracker_PT/point_tracker.h | 33 +---- 8 files changed, 169 insertions(+), 92 deletions(-) diff --git a/FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui b/FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui index 461253cf..bdbed955 100644 --- a/FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui +++ b/FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui @@ -515,26 +515,23 @@ - FOV + F/W - fov_dspin + f_dspin - + The camera's focal length devided by its sensor width 2 - - 1.000000000000000 - - 1.000000000000000 + 0.100000000000000 @@ -1736,7 +1733,7 @@ res_x_spin res_y_spin fps_spin - fov_dspin + f_dspin camroll_combo campitch_spin camyaw_spin diff --git a/FTNoIR_Tracker_PT/camera.cpp b/FTNoIR_Tracker_PT/camera.cpp index 8986be60..754533c5 100644 --- a/FTNoIR_Tracker_PT/camera.cpp +++ b/FTNoIR_Tracker_PT/camera.cpp @@ -108,11 +108,11 @@ void Camera::set_device_index(int index) } } -void Camera::set_fov(float f) +void Camera::set_f(float f) { - if (cam_desired.fov != f) + if (cam_desired.f != f) { - cam_desired.fov = f; + cam_desired.f = f; _set_f(); } } @@ -208,7 +208,7 @@ void CVCamera::_set_index() void CVCamera::_set_f() { - cam_info.fov = cam_desired.fov; + cam_info.f = cam_desired.f; } void CVCamera::_set_fps() diff --git a/FTNoIR_Tracker_PT/camera.h b/FTNoIR_Tracker_PT/camera.h index 6768e419..ea68c387 100644 --- a/FTNoIR_Tracker_PT/camera.h +++ b/FTNoIR_Tracker_PT/camera.h @@ -25,12 +25,12 @@ void get_camera_device_names(std::vector& device_names); // ---------------------------------------------------------------------------- struct CamInfo { - CamInfo() : res_x(0), res_y(0), fps(0), fov(56) {} + CamInfo() : res_x(0), res_y(0), fps(0), f(1) {} int res_x; int res_y; int fps; - float fov; + float f; // (focal length) / (sensor width) }; // ---------------------------------------------------------------------------- @@ -48,7 +48,7 @@ public: // calls corresponding template methods and reinitializes frame rate calculation void set_device_index(int index); - void set_fov(float f); + void set_f(float f); void set_fps(int fps); void set_res(int x_res, int y_res); diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp index 740cf3da..53d9c9e4 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp @@ -83,7 +83,7 @@ void Tracker::run() { frame = frame_rotation.rotate_frame(frame); const std::vector& points = point_extractor.extract_points(frame, dt, false); - tracking_valid = point_tracker.track(points, camera.get_info().fov, dt, frame.cols, frame.rows, t_MH); + tracking_valid = point_tracker.track(points, camera.get_info().f, dt); video_widget->update_image(frame); } #ifdef PT_PERF_LOG @@ -103,7 +103,7 @@ void Tracker::apply(settings& s) camera.set_device_index(s.cam_index); camera.set_res(s.cam_res_x, s.cam_res_y); camera.set_fps(s.cam_fps); - camera.set_fov(s.cam_fov); + camera.set_f(s.cam_f); frame_rotation.rotation = static_cast(static_cast(s.cam_roll)); point_extractor.threshold_val = s.threshold; point_extractor.threshold_secondary_val = s.threshold_secondary; diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.cpp b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.cpp index 4ae20f48..c103b78c 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.cpp +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.cpp @@ -46,7 +46,7 @@ TrackerDialog::TrackerDialog() tie_setting(s.reset_time, ui.reset_spin); tie_setting(s.cam_index, ui.camdevice_combo); - tie_setting(s.cam_fov, ui.fov_dspin); + tie_setting(s.cam_f, ui.f_dspin); tie_setting(s.cam_res_x, ui.res_x_spin); tie_setting(s.cam_res_y, ui.res_y_spin); tie_setting(s.cam_fps, ui.fps_spin); diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.h b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.h index b2ab8854..109090b3 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.h +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.h @@ -28,7 +28,7 @@ struct settings threshold_secondary, min_point_size, max_point_size; - value cam_fov; + value cam_f; value m01_x, m01_y, m01_z; value m02_x, m02_y, m02_z; @@ -57,7 +57,7 @@ struct settings threshold_secondary(b, "threshold-secondary", 128), min_point_size(b, "min-point-size", 10), max_point_size(b, "max-point-size", 50), - cam_fov(b, "camera-fov", 56), + cam_f(b, "camera-focal-length", 1), m01_x(b, "m_01-x", 0), m01_y(b, "m_01-y", 0), m01_z(b, "m_01-z", 0), diff --git a/FTNoIR_Tracker_PT/point_tracker.cpp b/FTNoIR_Tracker_PT/point_tracker.cpp index 1df70b17..dfefdaf8 100644 --- a/FTNoIR_Tracker_PT/point_tracker.cpp +++ b/FTNoIR_Tracker_PT/point_tracker.cpp @@ -17,6 +17,23 @@ using namespace cv; using namespace boost; 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), @@ -91,11 +108,9 @@ PointTracker::PointTracker() dt_reset(1), v_t(0,0,0), v_r(0,0,0), - dynamic_pose_resolution(true), - fov(0), - _w(0), - _h(0) + dynamic_pose_resolution(true) { + X_CM.t[2] = 1000; // default position: 1 m away from cam; } void PointTracker::reset() @@ -113,7 +128,7 @@ void PointTracker::reset_velocities() } -bool PointTracker::track(const vector& points, float fov, float dt, int w, int h, const cv::Vec3f& headpos) +bool PointTracker::track(const vector& points, float f, float dt) { if (!dynamic_pose_resolution) init_phase = true; @@ -125,7 +140,12 @@ bool PointTracker::track(const vector& points, float fov, float dt, int w reset(); } - bool no_model = !point_model; + bool no_model = +#ifdef OPENTRACK_API + point_model.get() == NULL; +#else + !point_model; +#endif // if there is a pointtracking problem, reset the velocities if (no_model || points.size() != PointModel::N_POINTS) @@ -141,7 +161,7 @@ bool PointTracker::track(const vector& points, float fov, float dt, int w predict(dt_valid); // if there is a point correspondence problem something has gone wrong, do a reset - if (!find_correspondences(points)) + if (!find_correspondences(points, f)) { //qDebug()<<"Error in finding point correspondences!"; X_CM = X_CM_old; // undo prediction @@ -149,8 +169,7 @@ bool PointTracker::track(const vector& points, float fov, float dt, int w return false; } - // XXX TODO fov - POSIT(fov, w, h, headpos); + int n_iter = POSIT(f); //qDebug()<<"Number of POSIT iterations: "<& points) +bool PointTracker::find_correspondences(const vector& points, float f) { if (init_phase) { // We do a simple freetrack-like sorting in the init phase... @@ -196,9 +215,9 @@ bool PointTracker::find_correspondences(const vector& points) 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)); - p_exp[1] = project(point_model->M01); - p_exp[2] = project(point_model->M02); + 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]; @@ -232,48 +251,130 @@ bool PointTracker::find_correspondences(const vector& points) -void PointTracker::POSIT(float fov, int w, int h, const cv::Vec3f& headpos) +int PointTracker::POSIT(float f) { - // XXX hack - this->fov = fov; - _w = w; - _h = h; - std::vector obj_points; - std::vector img_points; + // POSIT algorithm for coplanar points as presented in + // [Denis Oberkampf, Daniel F. DeMenthon, Larry S. Davis: "Iterative Pose Estimation Using Coplanar Feature Points"] + // we use the same notation as in the paper here + + // The expected rotation used for resolving the ambiguity in POSIT: + // In every iteration step the rotation closer to R_expected is taken + Matx33f R_expected; + if (init_phase) + R_expected = Matx33f::eye(); // in the init phase, we want to be close to the default pose = no rotation + else + R_expected = X_CM.R; // later we want to be close to the last (predicted) rotation + + // initial pose = last (predicted) pose + Vec3f k; + get_row(R_expected, 2, k); + float Z0 = init_phase ? 1000 : X_CM.t[2]; + + float old_epsilon_1 = 0; + float old_epsilon_2 = 0; + float epsilon_1 = 1; + float epsilon_2 = 1; + + Vec3f I0, J0; + Vec2f I0_coeff, J0_coeff; + + Vec3f I_1, J_1, I_2, J_2; + Matx33f R_1, R_2; + Matx33f* R_current; + + const int MAX_ITER = 100; + const float EPS_THRESHOLD = 1e-4; + + int i=1; + for (; 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; + } - obj_points.push_back(headpos); - obj_points.push_back(point_model->M01 + headpos); - obj_points.push_back(point_model->M02 + headpos); + // construct the two solutions + I_1 = I0 + rho*cos(theta)*point_model->u; + I_2 = I0 - rho*cos(theta)*point_model->u; - img_points.push_back(p[0]); - img_points.push_back(p[1]); - img_points.push_back(p[2]); + J_1 = J0 + rho*sin(theta)*point_model->u; + J_2 = J0 - rho*sin(theta)*point_model->u; - const float HT_PI = 3.1415926535; + 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; - const float focal_length_w = 0.5 * w / tan(fov * HT_PI / 180); - const float focal_length_h = 0.5 * h / tan(fov * h / w * HT_PI / 180.0); + 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)); - cv::Mat intrinsics = cv::Mat::eye(3, 3, CV_32FC1); - intrinsics.at (0, 0) = focal_length_w; - intrinsics.at (1, 1) = focal_length_h; - intrinsics.at (0, 2) = w/2; - intrinsics.at (1, 2) = h/2; + // the single translation solution + Z0 = norm_const * f; - cv::Mat dist_coeffs = cv::Mat::zeros(5, 1, CV_32FC1); + // 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()); - bool lastp = !rvec.empty() && !tvec.empty() && !init_phase; + if (R_1_deviation < R_2_deviation) + R_current = &R_1; + else + R_current = &R_2; - cv::solvePnP(obj_points, img_points, intrinsics, dist_coeffs, rvec, tvec, lastp, cv::ITERATIVE); + get_row(*R_current, 2, k); - cv::Mat rmat; - cv::Rodrigues(rvec, rmat); + // 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 - for (int i = 0; i < 3; i++) - { - X_CM.t[i] = tvec.at(i); - for (int j = 0; j < 3; j++) - X_CM.R(i, j) = rmat.at(i, j); - } + 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: "<& points, float fov, float dt, int w, int h, const cv::Vec3f &headpos); + bool track(const std::vector& points, float f, float dt); boost::shared_ptr point_model; bool dynamic_pose_resolution; @@ -98,35 +98,15 @@ public: FrameTrafo get_pose() const { return X_CM; } void reset(); - float fov; - int _w, _h; protected: - cv::Vec2f project(const cv::Vec3f& v_M) + inline cv::Vec2f project(const cv::Vec3f& v_M, float f) { - if (!rvec.empty() && !tvec.empty() && fov > 0) - { - const float HT_PI = 3.1415926535; - const int w = _w, h = _h; - const float focal_length_w = 0.5 * w / tan(fov * HT_PI / 180); - const float focal_length_h = 0.5 * h / tan(fov * h / w * HT_PI / 180.0); - - cv::Mat intrinsics = cv::Mat::eye(3, 3, CV_32FC1); - intrinsics.at (0, 0) = focal_length_w; - intrinsics.at (1, 1) = focal_length_h; - intrinsics.at (0, 2) = w/2; - intrinsics.at (1, 2) = h/2; - std::vector xs; - xs.push_back(v_M); - cv::Mat dist_coeffs = cv::Mat::zeros(5, 1, CV_32FC1); - std::vector rets(1); - cv::projectPoints(xs, rvec, tvec, intrinsics, dist_coeffs, rets); - return rets[0]; - } - return cv::Vec2f(); + 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); + 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 @@ -136,7 +116,7 @@ protected: void reset_velocities(); - void POSIT(float fov, int w, int h, const cv::Vec3f &headpos); // The POSIT algorithm, returns the number of iterations + int POSIT(float f); // The POSIT algorithm, returns the number of iterations bool init_phase; float dt_valid; // time since last valid tracking result @@ -144,7 +124,6 @@ protected: cv::Vec3f v_r; FrameTrafo X_CM; // trafo from model to camera FrameTrafo X_CM_old; - cv::Mat rvec, tvec; }; #endif //POINTTRACKER_H -- cgit v1.2.3 From fbad3658c9418171f2c2d1013230470926471e1a Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 12 Jan 2014 20:24:04 +0100 Subject: fix accidental revert --- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index fc641ef1..feb7fb9d 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -217,8 +217,8 @@ void Tracker::run() const int scale = frame.cols > 480 ? 2 : 1; detector.setThresholdParams(scale > 1 ? 11 : 7, 4); - const float focal_length_w = 0.5 * grayscale.cols / tan(s.fov * HT_PI / 180); - const float focal_length_h = 0.5 * grayscale.rows / tan(s.fov * grayscale.rows / grayscale.cols * HT_PI / 180.0); + const float focal_length_w = 0.5 * grayscale.cols / tan(0.5 * s.fov * HT_PI / 180); + const float focal_length_h = 0.5 * grayscale.rows / tan(0.5 * s.fov * grayscale.rows / grayscale.cols * HT_PI / 180.0); cv::Mat intrinsics = cv::Mat::eye(3, 3, CV_32FC1); intrinsics.at (0, 0) = focal_length_w; intrinsics.at (1, 1) = focal_length_h; -- cgit v1.2.3 From c057fc0acfccb5772514cebd82a9a6337ca8c231 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 12 Jan 2014 19:50:07 +0100 Subject: pt: display points' centers --- FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp index 53d9c9e4..39825168 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp @@ -82,7 +82,22 @@ void Tracker::run() if (new_frame && !frame.empty()) { frame = frame_rotation.rotate_frame(frame); - const std::vector& points = point_extractor.extract_points(frame, dt, false); + const std::vector& points = point_extractor.extract_points(frame, dt, true); + for (auto p : points) + { + auto p2 = cv::Point(p[0] * frame.cols + frame.cols/2, -p[1] * frame.cols + frame.rows/2); + cv::Scalar color(0, 255, 0); + cv::line(frame, + cv::Point(p2.x - 20, p2.y), + cv::Point(p2.x + 20, p2.y), + color, + 4); + cv::line(frame, + cv::Point(p2.x, p2.y - 20), + cv::Point(p2.x, p2.y + 20), + color, + 4); + } tracking_valid = point_tracker.track(points, camera.get_info().f, dt); video_widget->update_image(frame); } -- 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(-) 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 193b7f6e6bd6449442998e601bbb5734b29e2000 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 13 Jan 2014 08:24:01 +0100 Subject: accela: change allowed input scale --- ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui b/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui index a3deacbd..debd1250 100644 --- a/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui +++ b/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui @@ -175,7 +175,7 @@ 0.000000000000000 - 3.000000000000000 + 100.000000000000000 0.050000000000000 @@ -375,7 +375,7 @@ background:none; 0.000000000000000 - 3.000000000000000 + 100.000000000000000 0.050000000000000 -- cgit v1.2.3 From 87f57ad0bdf4ad5495dcc6068d3a0853a4c57a18 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 13 Jan 2014 08:24:15 +0100 Subject: aruco: change allowed scale, now that units are in millimeters --- ftnoir_tracker_aruco/aruco-trackercontrols.ui | 12 ++++++------ ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ftnoir_tracker_aruco/aruco-trackercontrols.ui b/ftnoir_tracker_aruco/aruco-trackercontrols.ui index 03975390..e0794eb9 100644 --- a/ftnoir_tracker_aruco/aruco-trackercontrols.ui +++ b/ftnoir_tracker_aruco/aruco-trackercontrols.ui @@ -64,10 +64,10 @@ - -200.000000000000000 + -10000.000000000000000 - 200.000000000000000 + 10000.000000000000000 @@ -87,10 +87,10 @@ - -200.000000000000000 + -10000.000000000000000 - 200.000000000000000 + 10000.000000000000000 @@ -103,10 +103,10 @@ - -200.000000000000000 + -10000.000000000000000 - 200.000000000000000 + 10000.000000000000000 diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index feb7fb9d..cb44927a 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -286,7 +286,7 @@ void Tracker::run() cv::TermCriteria(cv::TermCriteria::MAX_ITER | cv::TermCriteria::EPS, 20, 1e-2)); - const float size = 7; + const float size = 40; const double p = s.marker_pitch; const double sq = sin(p * HT_PI / 180); -- 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(-) 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 86624024323616370433df39ace145f779b8c311 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 13 Jan 2014 08:37:06 +0100 Subject: correct preferred hz --- ftnoir_tracker_base/ftnoir_tracker_base.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ftnoir_tracker_base/ftnoir_tracker_base.h b/ftnoir_tracker_base/ftnoir_tracker_base.h index 8da72896..09723d84 100644 --- a/ftnoir_tracker_base/ftnoir_tracker_base.h +++ b/ftnoir_tracker_base/ftnoir_tracker_base.h @@ -44,7 +44,7 @@ struct ITracker virtual ~ITracker() = 0; virtual void StartTracker( QFrame* frame ) = 0; virtual void GetHeadPoseData(double *data) = 0; - virtual int preferredHz() { return 4; } + virtual int preferredHz() { return 200; } }; inline ITracker::~ITracker() { } -- cgit v1.2.3 From 17bca6cacbd56f4692927a4571b8e49361b52bca Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 13 Jan 2014 08:43:35 +0100 Subject: rescale aruco to centimeters, like PT does --- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index cb44927a..845179f2 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -389,11 +389,11 @@ void Tracker::GetHeadPoseData(double *data) if (s.eroll) data[Roll] = pose[Roll]; if (s.ex) - data[TX] = pose[TX]; + data[TX] = pose[TX] * .1; if (s.ey) - data[TY] = pose[TY]; + data[TY] = pose[TY] * .1; if (s.ez) - data[TZ] = pose[TZ]; + data[TZ] = pose[TZ] * .1; } class TrackerDll : public Metadata -- cgit v1.2.3 From 464cb73809b73f533d4ddc401425484b890b170c Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 13 Jan 2014 09:38:44 +0100 Subject: pt: protect against pthread starvation when stopping --- FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp | 4 ++-- FTNoIR_Tracker_PT/ftnoir_tracker_pt.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp index 39825168..d15e13f8 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp @@ -45,13 +45,13 @@ Tracker::~Tracker() void Tracker::set_command(Command command) { - QMutexLocker lock(&mutex); + //QMutexLocker lock(&mutex); commands |= command; } void Tracker::reset_command(Command command) { - QMutexLocker lock(&mutex); + //QMutexLocker lock(&mutex); commands &= ~command; } diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h index 067a4072..1f6efce1 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h @@ -65,7 +65,7 @@ protected: }; void set_command(Command command); void reset_command(Command command); - int commands; + volatile int commands; CVCamera camera; FrameRotation frame_rotation; -- 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(-) 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(-) 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 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(-) 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 0232c0af79ce21c5c5735db5368ac83aa12f94b2 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 14 Jan 2014 00:44:09 +0100 Subject: prevent mutex starvation with PT on non-Windows platforms --- FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp index d15e13f8..162e4343 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp @@ -69,9 +69,7 @@ void Tracker::run() float dt; bool new_frame; forever - { - QMutexLocker lock(&mutex); - + { if (commands & ABORT) break; if (commands & PAUSE) continue; commands = 0; @@ -79,8 +77,11 @@ void Tracker::run() dt = time.restart() / 1000.0; new_frame = camera.get_frame(dt, &frame); + if (new_frame && !frame.empty()) { + QMutexLocker lock(&mutex); + frame = frame_rotation.rotate_frame(frame); const std::vector& points = point_extractor.extract_points(frame, dt, true); for (auto p : points) -- 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(-) 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 2a494c722c978b79c2c3e7b423dffee53e4cc3f1 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 14 Jan 2014 07:22:38 +0100 Subject: adjust subpix epsilon --- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index 845179f2..d4489638 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -284,8 +284,8 @@ void Tracker::run() m, cv::Size(5, 5), cv::Size(-1, -1), cv::TermCriteria(cv::TermCriteria::MAX_ITER | cv::TermCriteria::EPS, - 20, - 1e-2)); + 5, + 1e-4)); const float size = 40; const double p = s.marker_pitch; -- cgit v1.2.3 From 7890c4e4f5b8aeefc919fd4dcb8aa8ac35313374 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 14 Jan 2014 07:24:30 +0100 Subject: remove broken half of pitch breakage detection --- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index d4489638..99ef3271 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -196,8 +196,6 @@ void Tracker::run() int cur_fps = 0; int last_fps = 0; cv::Point2f last_centroid; - const double pitch_eps = 45; - double last_pitch = 0; bool first = true; while (!stop) @@ -338,10 +336,9 @@ void Tracker::run() { cv::Vec3d euler = cv::RQDecomp3x3(rotation_matrix, junk1, junk2); - if (fabs(euler[0] - last_pitch) > pitch_eps || euler[0] - s.marker_pitch < 0) + if (euler[0] - s.marker_pitch < 0) { first = true; - last_pitch = euler[0]; qDebug() << "reset levmarq due to pitch breakage"; } -- cgit v1.2.3 From 698b9f80810861693183e7a0fd2899560c741bd5 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 15 Jan 2014 19:01:18 +0100 Subject: remove harmless warning --- ftnoir_protocol_ft/ftnoir_protocol_ft.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ftnoir_protocol_ft/ftnoir_protocol_ft.h b/ftnoir_protocol_ft/ftnoir_protocol_ft.h index 8f27b071..0af9ff07 100644 --- a/ftnoir_protocol_ft/ftnoir_protocol_ft.h +++ b/ftnoir_protocol_ft/ftnoir_protocol_ft.h @@ -99,7 +99,7 @@ class FTControls: public QWidget, public IProtocolDialog Q_OBJECT public: explicit FTControls(); - void registerProtocol(IProtocol *protocol) {} + void registerProtocol(IProtocol *) {} void unRegisterProtocol() {} private: Ui::UICFTControls ui; -- 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(+) 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 65facfc7c819a5fc14385aedbb2848eb68bac390 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 15 Jan 2014 19:17:51 +0100 Subject: make all tracker/protocol/filter dialogs non-modal --- FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui | 2 +- ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui | 2 +- ftnoir_filter_ewma2/ftnoir_ewma_filtercontrols.ui | 2 +- ftnoir_filter_kalman/ftnoir_kalman_filtercontrols.ui | 2 +- ftnoir_protocol_fg/ftnoir_fgcontrols.ui | 2 +- ftnoir_protocol_fsuipc/ftnoir_fsuipccontrols.ui | 2 +- ftnoir_protocol_ft/ftnoir_ftcontrols.ui | 2 +- ftnoir_protocol_ftn/ftnoir_ftncontrols.ui | 2 +- ftnoir_protocol_libevdev/ftnoir_libevdev_controls.ui | 2 +- ftnoir_protocol_mouse/ftnoir_mousecontrols.ui | 2 +- ftnoir_protocol_sc/ftnoir_sccontrols.ui | 2 +- ftnoir_protocol_vjoy/ftnoir_vjoy_controls.ui | 2 +- ftnoir_protocol_wine/ftnoir_winecontrols.ui | 2 +- ftnoir_tracker_aruco/aruco-trackercontrols.ui | 2 +- ftnoir_tracker_ht/ht-trackercontrols.ui | 2 +- ftnoir_tracker_hydra/ftnoir_hydra_clientcontrols.ui | 2 +- ftnoir_tracker_joystick/ftnoir_tracker_joystick_controls.ui | 2 +- ftnoir_tracker_rift/ftnoir_rift_clientcontrols.ui | 2 +- ftnoir_tracker_udp/ftnoir_ftnclientcontrols.ui | 2 +- 19 files changed, 19 insertions(+), 19 deletions(-) diff --git a/FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui b/FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui index bdbed955..0bbec7e1 100644 --- a/FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui +++ b/FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui @@ -3,7 +3,7 @@ UICPTClientControls - Qt::ApplicationModal + Qt::NonModal diff --git a/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui b/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui index debd1250..c544263d 100644 --- a/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui +++ b/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui @@ -3,7 +3,7 @@ AccelaUICFilterControls - Qt::ApplicationModal + Qt::NonModal diff --git a/ftnoir_filter_ewma2/ftnoir_ewma_filtercontrols.ui b/ftnoir_filter_ewma2/ftnoir_ewma_filtercontrols.ui index a1083265..8ee633cc 100644 --- a/ftnoir_filter_ewma2/ftnoir_ewma_filtercontrols.ui +++ b/ftnoir_filter_ewma2/ftnoir_ewma_filtercontrols.ui @@ -3,7 +3,7 @@ UICFilterControls - Qt::ApplicationModal + Qt::NonModal diff --git a/ftnoir_filter_kalman/ftnoir_kalman_filtercontrols.ui b/ftnoir_filter_kalman/ftnoir_kalman_filtercontrols.ui index a9fdec6e..e0c849c9 100644 --- a/ftnoir_filter_kalman/ftnoir_kalman_filtercontrols.ui +++ b/ftnoir_filter_kalman/ftnoir_kalman_filtercontrols.ui @@ -3,7 +3,7 @@ KalmanUICFilterControls - Qt::ApplicationModal + Qt::NonModal diff --git a/ftnoir_protocol_fg/ftnoir_fgcontrols.ui b/ftnoir_protocol_fg/ftnoir_fgcontrols.ui index e351647b..a4092c05 100644 --- a/ftnoir_protocol_fg/ftnoir_fgcontrols.ui +++ b/ftnoir_protocol_fg/ftnoir_fgcontrols.ui @@ -3,7 +3,7 @@ UICFGControls - Qt::ApplicationModal + Qt::NonModal diff --git a/ftnoir_protocol_fsuipc/ftnoir_fsuipccontrols.ui b/ftnoir_protocol_fsuipc/ftnoir_fsuipccontrols.ui index 1ce77862..6cb066bd 100644 --- a/ftnoir_protocol_fsuipc/ftnoir_fsuipccontrols.ui +++ b/ftnoir_protocol_fsuipc/ftnoir_fsuipccontrols.ui @@ -3,7 +3,7 @@ UICFSUIPCControls - Qt::ApplicationModal + Qt::NonModal diff --git a/ftnoir_protocol_ft/ftnoir_ftcontrols.ui b/ftnoir_protocol_ft/ftnoir_ftcontrols.ui index bd5980b4..941aaff0 100644 --- a/ftnoir_protocol_ft/ftnoir_ftcontrols.ui +++ b/ftnoir_protocol_ft/ftnoir_ftcontrols.ui @@ -3,7 +3,7 @@ UICFTControls - Qt::ApplicationModal + Qt::NonModal true diff --git a/ftnoir_protocol_ftn/ftnoir_ftncontrols.ui b/ftnoir_protocol_ftn/ftnoir_ftncontrols.ui index 429e7046..48679f3c 100644 --- a/ftnoir_protocol_ftn/ftnoir_ftncontrols.ui +++ b/ftnoir_protocol_ftn/ftnoir_ftncontrols.ui @@ -3,7 +3,7 @@ UICFTNControls - Qt::ApplicationModal + Qt::NonModal diff --git a/ftnoir_protocol_libevdev/ftnoir_libevdev_controls.ui b/ftnoir_protocol_libevdev/ftnoir_libevdev_controls.ui index e85e001e..d2b86445 100644 --- a/ftnoir_protocol_libevdev/ftnoir_libevdev_controls.ui +++ b/ftnoir_protocol_libevdev/ftnoir_libevdev_controls.ui @@ -3,7 +3,7 @@ UICLibevdevControls - Qt::ApplicationModal + Qt::NonModal diff --git a/ftnoir_protocol_mouse/ftnoir_mousecontrols.ui b/ftnoir_protocol_mouse/ftnoir_mousecontrols.ui index 540e4f0d..2705fff7 100644 --- a/ftnoir_protocol_mouse/ftnoir_mousecontrols.ui +++ b/ftnoir_protocol_mouse/ftnoir_mousecontrols.ui @@ -3,7 +3,7 @@ UICMOUSEControls - Qt::ApplicationModal + Qt::NonModal diff --git a/ftnoir_protocol_sc/ftnoir_sccontrols.ui b/ftnoir_protocol_sc/ftnoir_sccontrols.ui index 430b3912..87dc8d86 100644 --- a/ftnoir_protocol_sc/ftnoir_sccontrols.ui +++ b/ftnoir_protocol_sc/ftnoir_sccontrols.ui @@ -3,7 +3,7 @@ UICSCControls - Qt::ApplicationModal + Qt::NonModal diff --git a/ftnoir_protocol_vjoy/ftnoir_vjoy_controls.ui b/ftnoir_protocol_vjoy/ftnoir_vjoy_controls.ui index 94b229fb..2214b887 100644 --- a/ftnoir_protocol_vjoy/ftnoir_vjoy_controls.ui +++ b/ftnoir_protocol_vjoy/ftnoir_vjoy_controls.ui @@ -3,7 +3,7 @@ UICVJoyControls - Qt::ApplicationModal + Qt::NonModal diff --git a/ftnoir_protocol_wine/ftnoir_winecontrols.ui b/ftnoir_protocol_wine/ftnoir_winecontrols.ui index 749feb0f..9356c448 100644 --- a/ftnoir_protocol_wine/ftnoir_winecontrols.ui +++ b/ftnoir_protocol_wine/ftnoir_winecontrols.ui @@ -3,7 +3,7 @@ UICFTControls - Qt::ApplicationModal + Qt::NonModal diff --git a/ftnoir_tracker_aruco/aruco-trackercontrols.ui b/ftnoir_tracker_aruco/aruco-trackercontrols.ui index e0794eb9..1d5a4241 100644 --- a/ftnoir_tracker_aruco/aruco-trackercontrols.ui +++ b/ftnoir_tracker_aruco/aruco-trackercontrols.ui @@ -3,7 +3,7 @@ Form - Qt::ApplicationModal + Qt::NonModal diff --git a/ftnoir_tracker_ht/ht-trackercontrols.ui b/ftnoir_tracker_ht/ht-trackercontrols.ui index 55501ef1..f57022c8 100644 --- a/ftnoir_tracker_ht/ht-trackercontrols.ui +++ b/ftnoir_tracker_ht/ht-trackercontrols.ui @@ -3,7 +3,7 @@ Form - Qt::ApplicationModal + Qt::NonModal diff --git a/ftnoir_tracker_hydra/ftnoir_hydra_clientcontrols.ui b/ftnoir_tracker_hydra/ftnoir_hydra_clientcontrols.ui index 1acbf93f..e5e41bec 100644 --- a/ftnoir_tracker_hydra/ftnoir_hydra_clientcontrols.ui +++ b/ftnoir_tracker_hydra/ftnoir_hydra_clientcontrols.ui @@ -3,7 +3,7 @@ UIHydraControls - Qt::ApplicationModal + Qt::NonModal diff --git a/ftnoir_tracker_joystick/ftnoir_tracker_joystick_controls.ui b/ftnoir_tracker_joystick/ftnoir_tracker_joystick_controls.ui index 7522cf31..5d349169 100644 --- a/ftnoir_tracker_joystick/ftnoir_tracker_joystick_controls.ui +++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick_controls.ui @@ -3,7 +3,7 @@ UIJoystickControls - Qt::ApplicationModal + Qt::NonModal diff --git a/ftnoir_tracker_rift/ftnoir_rift_clientcontrols.ui b/ftnoir_tracker_rift/ftnoir_rift_clientcontrols.ui index e868a9c3..a9168239 100644 --- a/ftnoir_tracker_rift/ftnoir_rift_clientcontrols.ui +++ b/ftnoir_tracker_rift/ftnoir_rift_clientcontrols.ui @@ -3,7 +3,7 @@ UIRiftControls - Qt::ApplicationModal + Qt::NonModal diff --git a/ftnoir_tracker_udp/ftnoir_ftnclientcontrols.ui b/ftnoir_tracker_udp/ftnoir_ftnclientcontrols.ui index fc614477..5c602792 100644 --- a/ftnoir_tracker_udp/ftnoir_ftnclientcontrols.ui +++ b/ftnoir_tracker_udp/ftnoir_ftnclientcontrols.ui @@ -3,7 +3,7 @@ UICFTNClientControls - Qt::ApplicationModal + Qt::NonModal -- cgit v1.2.3 From 505cee88bcffb5167d7eb400465adb49610c61fe Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 15 Jan 2014 19:40:23 +0100 Subject: fix ft interface selection not persisting --- ftnoir_protocol_ft/ftnoir_protocol_ft_dialog.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ftnoir_protocol_ft/ftnoir_protocol_ft_dialog.cpp b/ftnoir_protocol_ft/ftnoir_protocol_ft_dialog.cpp index 7f070857..5ce903b7 100644 --- a/ftnoir_protocol_ft/ftnoir_protocol_ft_dialog.cpp +++ b/ftnoir_protocol_ft/ftnoir_protocol_ft_dialog.cpp @@ -45,7 +45,6 @@ FTControls::FTControls() : connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); connect(ui.bntLocateNPClient, SIGNAL(clicked()), this, SLOT(selectDLL())); - tie_setting(s.intUsedInterface, ui.cbxSelectInterface); tie_setting(s.useDummyExe, ui.chkStartDummy); tie_setting(s.useTIRViews, ui.chkTIRViews); @@ -53,6 +52,8 @@ FTControls::FTControls() : ui.cbxSelectInterface->addItem("Use FreeTrack, hide TrackIR"); ui.cbxSelectInterface->addItem("Use TrackIR, hide FreeTrack"); + tie_setting(s.intUsedInterface, ui.cbxSelectInterface); + aFileName = QCoreApplication::applicationDirPath() + "/TIRViews.dll"; if ( !QFile::exists( aFileName ) ) { ui.chkTIRViews->setChecked( false ); -- 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(+) 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 eb49b953f7216527cf4a78272f321a73706f0536 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 16 Jan 2014 05:40:27 +0100 Subject: get rid of corner subpix, causes nonsense on certain poses --- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index 99ef3271..ee20a9c4 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -278,12 +278,6 @@ void Tracker::run() if (markers.size() == 1 && markers[0].size() == 4) { const auto& m = markers.at(0); - cv::cornerSubPix(grayscale, - m, - cv::Size(5, 5), cv::Size(-1, -1), - cv::TermCriteria(cv::TermCriteria::MAX_ITER | cv::TermCriteria::EPS, - 5, - 1e-4)); const float size = 40; const double p = s.marker_pitch; @@ -336,7 +330,7 @@ void Tracker::run() { cv::Vec3d euler = cv::RQDecomp3x3(rotation_matrix, junk1, junk2); - if (euler[0] - s.marker_pitch < 0) + if (fabs(euler[0]) + fabs(s.marker_pitch) > 60) { first = true; qDebug() << "reset levmarq due to pitch breakage"; -- cgit v1.2.3 From de3ab0c3c1aee424a9a04963c976242b03827e17 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 16 Jan 2014 08:24:43 +0100 Subject: remove now-unused useless block --- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index ee20a9c4..ae7ca0b5 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -187,10 +187,6 @@ void Tracker::run() return; } - while (!stop) - if(camera.read(color_)) - break; - auto freq = cv::getTickFrequency(); auto last_time = cv::getTickCount(); int cur_fps = 0; -- cgit v1.2.3 From 84b790bba2d3272ea38e473ad951b4dc6259ec58 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 18 Jan 2014 18:58:59 +0100 Subject: ht: adjust coeffs --- ftnoir_tracker_ht/ftnoir_tracker_ht.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp index 3f9f9fa1..76a6ba71 100644 --- a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp +++ b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp @@ -115,24 +115,24 @@ void Tracker::load_settings(ht_config_t* config) config->field_of_view = s.fov; config->pyrlk_pyramids = 0; config->pyrlk_win_size_w = config->pyrlk_win_size_h = 21; - config->max_keypoints = 120; - config->keypoint_distance = 3.2; + config->max_keypoints = 150; + config->keypoint_distance = 6; config->force_fps = nframes; config->camera_index = s.camera_idx - 1; config->ransac_num_iters = 100; - config->ransac_max_reprojection_error = 8; - config->ransac_max_inlier_error = 8; - config->ransac_abs_max_mean_error = 16; - config->ransac_max_mean_error = 6.5; + config->ransac_max_reprojection_error = 10; + config->ransac_max_inlier_error = 10; + config->ransac_abs_max_mean_error = 14; + config->ransac_max_mean_error = 8; config->debug = 0; - config->ransac_min_features = 0.85; + config->ransac_min_features = 0.86; int res = s.resolution; if (res < 0 || res >= (int)(sizeof(resolution_choices) / sizeof(resolution_tuple))) res = 0; resolution_tuple r = resolution_choices[res]; config->force_width = r.width; config->force_height = r.height; - config->flandmark_delay = 325; + config->flandmark_delay = 500; for (int i = 0; i < 5; i++) config->dist_coeffs[i] = 0; } -- cgit v1.2.3 From 6b1a0d5705d3eea34fbdc6a8acf6aa6bc225a868 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 23 Jan 2014 04:21:00 +0100 Subject: glwidget: don't perform useless computation The distances are known, so hardcode them instead. --- ftnoir_posewidget/glwidget.cpp | 41 ++++++++++++----------------------------- 1 file changed, 12 insertions(+), 29 deletions(-) diff --git a/ftnoir_posewidget/glwidget.cpp b/ftnoir_posewidget/glwidget.cpp index 70667f06..590edbc6 100644 --- a/ftnoir_posewidget/glwidget.cpp +++ b/ftnoir_posewidget/glwidget.cpp @@ -186,37 +186,20 @@ void GLWidget::project_quad_texture() { int qx2 = std::min(ow - 1, std::max(0, qx + 1.0)); int qy2 = std::min(oh - 1, std::max(0, qy + 1.0)); - 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 r = (4 * (double) orig[qy1 * orig_pitch + qx1 * orig_depth + 2] + + 1 * (double) orig[qy2 * orig_pitch + qx2 * orig_depth + 2] + + 2 * (double) orig[qy1 * orig_pitch + qx2 * orig_depth + 2] + + 2 * (double) orig[qy2 * orig_pitch + qx1 * orig_depth + 2]) / 9; - 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 g = (4 * (double) orig[qy1 * orig_pitch + qx1 * orig_depth + 1] + + 1 * (double) orig[qy2 * orig_pitch + qx2 * orig_depth + 1] + + 2 * (double) orig[qy1 * orig_pitch + qx2 * orig_depth + 1] + + 2 * (double) orig[qy2 * orig_pitch + qx1 * orig_depth + 1]) / 9; - 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]; + double b = (4 * (double) orig[qy1 * orig_pitch + qx1 * orig_depth + 0] + + 1 * (double) orig[qy2 * orig_pitch + qx2 * orig_depth + 0] + + 2 * (double) orig[qy1 * orig_pitch + qx2 * orig_depth + 0] + + 2 * (double) orig[qy2 * orig_pitch + qx1 * orig_depth + 0]) / 9; 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)); -- cgit v1.2.3 From 5296a52fec9288f22aaf6c4a5f8141d8a36014fc Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 23 Jan 2014 04:26:03 +0100 Subject: glwidget: don't use doubles for no good reason --- ftnoir_posewidget/glwidget.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/ftnoir_posewidget/glwidget.cpp b/ftnoir_posewidget/glwidget.cpp index 590edbc6..ab8bede1 100644 --- a/ftnoir_posewidget/glwidget.cpp +++ b/ftnoir_posewidget/glwidget.cpp @@ -186,20 +186,20 @@ void GLWidget::project_quad_texture() { int qx2 = std::min(ow - 1, std::max(0, qx + 1.0)); int qy2 = std::min(oh - 1, std::max(0, qy + 1.0)); - double r = (4 * (double) orig[qy1 * orig_pitch + qx1 * orig_depth + 2] - + 1 * (double) orig[qy2 * orig_pitch + qx2 * orig_depth + 2] - + 2 * (double) orig[qy1 * orig_pitch + qx2 * orig_depth + 2] - + 2 * (double) orig[qy2 * orig_pitch + qx1 * orig_depth + 2]) / 9; + int r = (4 * orig[qy1 * orig_pitch + qx1 * orig_depth + 2] + + 1 * orig[qy2 * orig_pitch + qx2 * orig_depth + 2] + + 2 * orig[qy1 * orig_pitch + qx2 * orig_depth + 2] + + 2 * orig[qy2 * orig_pitch + qx1 * orig_depth + 2]) / 9; - double g = (4 * (double) orig[qy1 * orig_pitch + qx1 * orig_depth + 1] - + 1 * (double) orig[qy2 * orig_pitch + qx2 * orig_depth + 1] - + 2 * (double) orig[qy1 * orig_pitch + qx2 * orig_depth + 1] - + 2 * (double) orig[qy2 * orig_pitch + qx1 * orig_depth + 1]) / 9; + int g = (4 * orig[qy1 * orig_pitch + qx1 * orig_depth + 1] + + 1 * orig[qy2 * orig_pitch + qx2 * orig_depth + 1] + + 2 * orig[qy1 * orig_pitch + qx2 * orig_depth + 1] + + 2 * orig[qy2 * orig_pitch + qx1 * orig_depth + 1]) / 9; - double b = (4 * (double) orig[qy1 * orig_pitch + qx1 * orig_depth + 0] - + 1 * (double) orig[qy2 * orig_pitch + qx2 * orig_depth + 0] - + 2 * (double) orig[qy1 * orig_pitch + qx2 * orig_depth + 0] - + 2 * (double) orig[qy2 * orig_pitch + qx1 * orig_depth + 0]) / 9; + int b = (4 * orig[qy1 * orig_pitch + qx1 * orig_depth + 0] + + 1 * orig[qy2 * orig_pitch + qx2 * orig_depth + 0] + + 2 * orig[qy1 * orig_pitch + qx2 * orig_depth + 0] + + 2 * orig[qy2 * orig_pitch + qx1 * orig_depth + 0]) / 9; 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)); -- cgit v1.2.3 From fee33d472b6a576ccb2ede75de4c1132d828fc3f Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 25 Jan 2014 12:14:32 +0100 Subject: accela: remove now-unused mutex --- ftnoir_filter_accela/ftnoir_filter_accela.cpp | 2 -- ftnoir_filter_accela/ftnoir_filter_accela.h | 1 - 2 files changed, 3 deletions(-) diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.cpp b/ftnoir_filter_accela/ftnoir_filter_accela.cpp index 558b3189..13e4ea79 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela.cpp @@ -78,8 +78,6 @@ void FTNoIR_Filter::FilterHeadPoseData(const double* target_camera_position, return; } - QMutexLocker foo(&mutex); - for (int i=0;i<6;i++) { const double vec = target_camera_position[i] - last_output[0][i]; diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.h b/ftnoir_filter_accela/ftnoir_filter_accela.h index 42d9b772..4b92ef8b 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.h +++ b/ftnoir_filter_accela/ftnoir_filter_accela.h @@ -48,7 +48,6 @@ public: private: settings s; - QMutex mutex; bool first_run; double last_input[6]; double last_output[3][6]; -- cgit v1.2.3 From 10dd63b28ca2ca0413fb6b840aad7ad6a7ee1c85 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 25 Jan 2014 12:20:44 +0100 Subject: remove undefined member function from class --- ftnoir_filter_accela/ftnoir_filter_accela.h | 1 - 1 file changed, 1 deletion(-) diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.h b/ftnoir_filter_accela/ftnoir_filter_accela.h index 4b92ef8b..42db2e47 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.h +++ b/ftnoir_filter_accela/ftnoir_filter_accela.h @@ -65,7 +65,6 @@ class FilterControls: public QWidget, public IFilterDialog Q_OBJECT public: FilterControls(); - void reset(QWidget *); void registerFilter(IFilter* filter); void unregisterFilter(); private: -- cgit v1.2.3 From 48461f79f824cf9fc6987ef309125ec9c6cf5be9 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 10 Feb 2014 06:03:47 +0100 Subject: replace incorrect interpolation with nearest neighbor --- ftnoir_posewidget/glwidget.cpp | 40 ++++++++++++---------------------------- 1 file changed, 12 insertions(+), 28 deletions(-) diff --git a/ftnoir_posewidget/glwidget.cpp b/ftnoir_posewidget/glwidget.cpp index ab8bede1..26803385 100644 --- a/ftnoir_posewidget/glwidget.cpp +++ b/ftnoir_posewidget/glwidget.cpp @@ -175,35 +175,19 @@ void GLWidget::project_quad_texture() { 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)); - int qy1 = std::min(oh - 1, std::max(0, qy)); - int qx2 = std::min(ow - 1, std::max(0, qx + 1.0)); - int qy2 = std::min(oh - 1, std::max(0, qy + 1.0)); + int px = origs[i][0].x + + coords.x * (origs[i][2].x - origs[i][0].x) + + coords.y * (origs[i][1].x - origs[i][0].x); + int py = 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 r = orig[py * orig_pitch + px * orig_depth + 2]; + int g = orig[py * orig_pitch + px * orig_depth + 1]; + int b = orig[py * orig_pitch + px * orig_depth + 0]; - int r = (4 * orig[qy1 * orig_pitch + qx1 * orig_depth + 2] - + 1 * orig[qy2 * orig_pitch + qx2 * orig_depth + 2] - + 2 * orig[qy1 * orig_pitch + qx2 * orig_depth + 2] - + 2 * orig[qy2 * orig_pitch + qx1 * orig_depth + 2]) / 9; - - int g = (4 * orig[qy1 * orig_pitch + qx1 * orig_depth + 1] - + 1 * orig[qy2 * orig_pitch + qx2 * orig_depth + 1] - + 2 * orig[qy1 * orig_pitch + qx2 * orig_depth + 1] - + 2 * orig[qy2 * orig_pitch + qx1 * orig_depth + 1]) / 9; - - int b = (4 * orig[qy1 * orig_pitch + qx1 * orig_depth + 0] - + 1 * orig[qy2 * orig_pitch + qx2 * orig_depth + 0] - + 2 * orig[qy1 * orig_pitch + qx2 * orig_depth + 0] - + 2 * orig[qy2 * orig_pitch + qx1 * orig_depth + 0]) / 9; - - 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)); + dest[y * dest_pitch + x * dest_depth + 0] = r; + dest[y * dest_pitch + x * dest_depth + 1] = g; + dest[y * dest_pitch + x * dest_depth + 2] = b; break; } -- 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(-) 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 89e040931523f3b90a44f711a7e76f3b189a2eb5 Mon Sep 17 00:00:00 2001 From: okdshin Date: Wed, 21 May 2014 18:08:04 +0900 Subject: add SDK_LIBEVDEV to enable users to select libevdev path. --- CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 40682474..c2763dec 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -88,7 +88,10 @@ if(WIN32 AND DEFINED MSVC_VERSION AND NOT ${MSVC_VERSION} LESS 1700) endif() if(UNIX) - set(SDK_ENABLE_LIBEVDEV FALSE CACHE BOOL "libevdev virtual joystick protocol support (probably Linux only)") + set(SDK_ENABLE_LIBEVDEV FALSE CACHE BOOL "libevdev virtual joystick protocol support (probably Linux only)") + if(SDK_ENABLE_LIBEVDEV) + SET(SDK_LIBEVDEV "" CACHE PATH "libevdev SDK path") + endif() endif() if(WIN32) SET(SDK_CONSOLE_DEBUG FALSE CACHE BOOL "Console build") @@ -330,6 +333,7 @@ if(SDK_VJOY) endif() if(SDK_ENABLE_LIBEVDEV) + include_directories(${SDK_LIBEVDEV}) opentrack_library(opentrack-proto-libevdev) target_link_libraries(opentrack-proto-libevdev evdev) endif() -- cgit v1.2.3 From a79e5b0e24e9b756e88d97173e76a91a59f6eb6a Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 30 May 2014 14:47:42 +0200 Subject: vjoy: Fix POV hat state MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit POV hat key was always stuck in one position, confusing certain games. Reported-by: ASQ_Dak Fix-by: Rickard Öberg Tested-by: no one at all! --- ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.cpp b/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.cpp index 76767c3b..a3a5cb5f 100644 --- a/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.cpp +++ b/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.cpp @@ -16,6 +16,8 @@ FTNoIR_Protocol::~FTNoIR_Protocol() void FTNoIR_Protocol::sendHeadposeToGame( const double *headpose ) { JOYSTICK_STATE state[2] = { 0 }; + + state[0].POV = (4 << 12) | (4 << 8) | (4 << 4) | 4; state[0].XAxis = std::min(VJOY_AXIS_MAX, std::max(VJOY_AXIS_MIN, headpose[Yaw] * VJOY_AXIS_MAX / 180.0)); state[0].YAxis = std::min(VJOY_AXIS_MAX, std::max(VJOY_AXIS_MIN, headpose[Pitch] * VJOY_AXIS_MAX / 180.0)); -- cgit v1.2.3 From 564384f83c376a9624662a1eab9cec9caca16493 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 5 Jun 2014 09:31:43 +0200 Subject: Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6a8a61f0..59d80403 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ ======= -Windows binary builds are available at +Windows binary builds are available at Source code access available at -- cgit v1.2.3 From 8a386b16ed0619d25f04f5b3a85205abea7b184e Mon Sep 17 00:00:00 2001 From: okdshin Date: Thu, 5 Jun 2014 19:33:56 +0900 Subject: remove SDK_ENABLE_LIBEVDEV macro and simplify sdk libevdev config --- CMakeLists.txt | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c2763dec..7e268a65 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -88,11 +88,9 @@ if(WIN32 AND DEFINED MSVC_VERSION AND NOT ${MSVC_VERSION} LESS 1700) endif() if(UNIX) - set(SDK_ENABLE_LIBEVDEV FALSE CACHE BOOL "libevdev virtual joystick protocol support (probably Linux only)") - if(SDK_ENABLE_LIBEVDEV) - SET(SDK_LIBEVDEV "" CACHE PATH "libevdev SDK path") - endif() + SET(SDK_LIBEVDEV "" CACHE PATH "libevdev SDK path") endif() + if(WIN32) SET(SDK_CONSOLE_DEBUG FALSE CACHE BOOL "Console build") endif() @@ -332,7 +330,7 @@ if(SDK_VJOY) endif() endif() -if(SDK_ENABLE_LIBEVDEV) +if(SDK_LIBEVDEV) include_directories(${SDK_LIBEVDEV}) opentrack_library(opentrack-proto-libevdev) target_link_libraries(opentrack-proto-libevdev evdev) -- cgit v1.2.3 From 09ef6d7c5e33beb16f81871b3a776d479355b4ac Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 5 Jun 2014 14:09:51 +0200 Subject: Only enable libevdev on Linux. Default to it enabled. --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7e268a65..44e853af 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -87,8 +87,8 @@ if(WIN32 AND DEFINED MSVC_VERSION AND NOT ${MSVC_VERSION} LESS 1700) SET (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /SAFESEH:NO") endif() -if(UNIX) - SET(SDK_LIBEVDEV "" CACHE PATH "libevdev SDK path") +if(CMAKE_SYSTEM_NAME STREQUAL Linux) + SET(SDK_LIBEVDEV "/usr" CACHE PATH "libevdev install prefix") endif() if(WIN32) -- cgit v1.2.3 From 922de20236423932edc5c4ff28e697b7c32c8a45 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 6 Jun 2014 10:07:36 +0200 Subject: Revert cmake libevdev changes It doesn't do what it's supposed to. Doesn't point to prefix, only relevant for include path. Previous setup isn't that bad so revert for now. --- CMakeLists.txt | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 44e853af..40682474 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -87,10 +87,9 @@ if(WIN32 AND DEFINED MSVC_VERSION AND NOT ${MSVC_VERSION} LESS 1700) SET (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /SAFESEH:NO") endif() -if(CMAKE_SYSTEM_NAME STREQUAL Linux) - SET(SDK_LIBEVDEV "/usr" CACHE PATH "libevdev install prefix") +if(UNIX) + set(SDK_ENABLE_LIBEVDEV FALSE CACHE BOOL "libevdev virtual joystick protocol support (probably Linux only)") endif() - if(WIN32) SET(SDK_CONSOLE_DEBUG FALSE CACHE BOOL "Console build") endif() @@ -330,8 +329,7 @@ if(SDK_VJOY) endif() endif() -if(SDK_LIBEVDEV) - include_directories(${SDK_LIBEVDEV}) +if(SDK_ENABLE_LIBEVDEV) opentrack_library(opentrack-proto-libevdev) target_link_libraries(opentrack-proto-libevdev evdev) endif() -- cgit v1.2.3 From 8bb1cb71bbf7800d1098e725435f08385de2e979 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 6 Jun 2014 11:17:42 +0200 Subject: New game support for freetrack protocol --- bin/settings/facetracknoir supported games.csv | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/bin/settings/facetracknoir supported games.csv b/bin/settings/facetracknoir supported games.csv index eb1a64b4..91b9e6e6 100644 --- a/bin/settings/facetracknoir supported games.csv +++ b/bin/settings/facetracknoir supported games.csv @@ -73,6 +73,7 @@ No;Game Name;Game protocol;Supported since;Verified;By;INTERNATIONAL_ID;FTN_ID 65;Comanche;FreeTrack20;V160;;;2275;00414097C36A12BA32BA00 66;Combat Flight Simulator 3;FreeTrack20;V160;V;V4Friend;2304;00420EC5F763AB21CA7310 67;Combat Helo;FreeTrack20;V160;;;2001;004329DFA863FAE1EA7300 +515;Combined Arms;FreeTrack20;V160;;;1309;0203387EDB1A5AFEADB600 68;Commandos Strike Force;FreeTrack20;V160;;;8801;0044C1BBF892DB037A7200 69;Concept RS;FreeTrack20;V160;;;10701;004537971697736A72DA00 70;Condor: The Competitive Soaring Simulator;FreeTrack20;V160;V;MicheleF;5901;004670A8B762DA623A1300 @@ -91,6 +92,7 @@ No;Game Name;Game protocol;Supported since;Verified;By;INTERNATIONAL_ID;FTN_ID 84;Dark Horizons Lore;FreeTrack20;V160;;;7901;005487801A852AA7385200 85;Dawn of Aces - Gold Edition;FreeTrack20;V170;;;1304;0055A9ED7700814190DE00 86;Dawn of Aces II;FreeTrack20;V160;;;1302;00566925967C2BB0285500 +513;Dawn of Aces/Red Baron;FreeTrack20;V160;;;1307;0201916C14F32918D9B800 87;DBS WalkAndFollow;FreeTrack20;V160;;;2525;005770A8B77008BDE89200 88;DCS: Black Shark;FreeTrack20;V170;V;EmBeES;1006;0058F688FC9B0556868F00 89;DCS: A-10C Warthog (32 and 64 bit);FreeTrack20;V170;V;fabri91, Shadow;1003;0059B6DCD15F5A572F6500 @@ -244,11 +246,13 @@ No;Game Name;Game protocol;Supported since;Verified;By;INTERNATIONAL_ID;FTN_ID 220;Lore (Dark Horizons);FreeTrack20;V160;;;5302;00DCF478D27833DB62D500 221;Love;FreeTrack20;V160;;;3125;00DD71ED5E802AAB214800 222;Lucid Engine;FreeTrack20;V160;;;10501;00DE71ED5E803098259C00 +514;M4 Tank Brigade;FreeTrack20;V160;;;1308;02024ED5A3A26741604300 223;M4 Tank Platoon;FreeTrack20;V160;;;1306;00DFDCC441A8E036320900 224;Mach 1;FreeTrack20;V160;;;2575;00E0231518130942466000 225;ManuVAR;FreeTrack20;V160;;;20455;00E153FE1E901CB0448800 226;MaqSIM4;FreeTrack20;V160;;;20026;00E28F54A207D29B611700 227;Mech Tactical Sim;FreeTrack20;V160;;;9501;00E3F3E85B1A8E34A53300 +516;MechWarrior Online;FreeTrack20;V170;;;3026;0BD2E0DCBC723836CD2400 228;Mechwarrior Online;FreeTrack20;V170;;;3025;00E414954226DB5D8CE200 229;Medical Image Visualization;FreeTrack20;V160;;;20295;00E59343488532A5359B00 230;Meggitt Defense Systems;FreeTrack20;V160;;;20045;00E6926ED9122AB22AF300 @@ -360,6 +364,7 @@ No;Game Name;Game protocol;Supported since;Verified;By;INTERNATIONAL_ID;FTN_ID 329;RSD Demo;FreeTrack20;V160;;;2050;0149BF8C4EAA5871A85D00 330;RTMS Crane Sim;FreeTrack20;V160;;;20400;014AC93272841D91205200 331;RTT DeltaGen Plugin;FreeTrack20;V160;;;20195;014B90B5871B8DDD7D3400 +511;Sail;FreeTrack20;V160;;;3575;01FF2916D764159099F800 332;Sail Simulator 5;FreeTrack20;V160;;;1975;014CE2D1D78A1D9A3B6300 333;Sailors of the Sky;FreeTrack20;V160;;;10201;014D17BE02961FAF3AB100 334;Santa Cruz Watermill;FreeTrack20;V160;;;20290;014E88F5881EA32FA7E900 @@ -377,16 +382,19 @@ No;Game Name;Game protocol;Supported since;Verified;By;INTERNATIONAL_ID;FTN_ID 346;Simax Simulator;FreeTrack20;V160;;;20021;015AAC156D9736A331AD00 347;Simball 4D;FreeTrack20;V160;;;20315;015BD6E585F99349F2AA00 348;Simbionix;FreeTrack20;V160;;;20485;015CE7A7FAA28528AE1D00 +518;SimCraft;FreeTrack20;V160;;;3650;02065BA013963203CB1900 349;SimCreator;FreeTrack20;V160;;;20520;015D3752FBC8935B001A00 350;Simlog Personal Simulator;FreeTrack20;V160;;;20635;015E42868C33A435B53100 351;SimQuest immersion system;FreeTrack20;V160;;;20023;015F6C69678C32A30FAE00 352;SimSol;FreeTrack20;V160;;;20034;01602315187389E0FB5300 491;Simumak;FreeTrack20;V160;;;20770;01EB119629980784DCE600 +510;Sir, You Are Being Hunted;FreeTrack20;V160;;;3550;01FEDAB345FA104ED4A100 353;Sirocco Racing;FreeTrack20;V160;;;5801;01612BCA748925A6369A00 354;Sky God: Military Freefall;FreeTrack20;V170;;;1526;01622C0104385FD1C44400 355;Soft fx Demo;FreeTrack20;V160;;;2125;01632E20238A2B99335200 356;Source Engine (Half-Life 2);FreeTrack20;V160;;;12502;0164E482F58829A739A600 357;Space Shuttle Mission 2007;FreeTrack20;V160;V;purewhitewings ;1225;0165662B03863D912F9700 +517;Spaze;FreeTrack20;V160;;;3625;020573F9D3ED8C43B8DC00 358;SRI;FreeTrack20;V160;;;20620;01663FD0FC9D8B218D8100 359;Stanford University;FreeTrack20;V160;;;20004;0167CE35BAF9933A62AA00 500;Star Citizen;FreeTrack20;V170;;;3450;0D7AF4CE4E343EC6B4A200 @@ -415,6 +423,7 @@ No;Game Name;Game protocol;Supported since;Verified;By;INTERNATIONAL_ID;FTN_ID 380;Telepresence;FreeTrack20;V160;;;20450;017CF478D278B33B02DA00 381;Tenstar Simulator;FreeTrack20;V160;;;20605;017D318F88A2EA62DBA200 382;Test Drive Unlimited;FreeTrack20;V160;;;13201;017E6F2699559730A84000 +509;Tetrahedral;FreeTrack20;V160;;;3525;01FDCFF1C56D6F757E8200 501;The Crew;FreeTrack20;V170;;;1009;03F1F534E94F4834D9B100 488;The Gallery;FreeTrack20;V160;;;3350;01E8CE152EDE5FFD267700 383;The Sky Gods;FreeTrack20;V170;;;1525;017FDFF782DCCEEA27C200 @@ -492,6 +501,7 @@ No;Game Name;Game protocol;Supported since;Verified;By;INTERNATIONAL_ID;FTN_ID 449;Wikid FJ;FreeTrack20;V160;;;20685;01C19BC3BDA98269B25A00 450;Wings of Prey;FreeTrack20;V160;V;V4Friend;1877;01C25909438736A133AC00 451;Wings of War;FreeTrack20;V160;;;7807;01C34B0FC38B36B42FB610 +512;Wings: Over Flanders Fields;FreeTrack20;V160;;;2326;02008AE39AAA4624B33C00 452;World Racing 2;FreeTrack20;V160;;;7201;01C41AAF68A2BA836AAE00 453;WWII Battle Tanks: T-34 vs. Tiger;FreeTrack20;V160;;;11102;01C5432C29C257F1963100 454;X Motor Racing;FreeTrack20;V160;;;1150;01C669259690E98629A900 -- cgit v1.2.3 From f7e9f2e133b99c7cab097a4a416eeb48ca75bdc9 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 7 Jun 2014 21:24:25 +0200 Subject: freetrack: enable dummy executable unconditionally Signed-off-by: Stanislaw Halik --- ftnoir_protocol_ft/ftnoir_protocol_ft.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp b/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp index 5c086c10..281af6a0 100644 --- a/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp +++ b/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp @@ -193,13 +193,9 @@ bool FTNoIR_Protocol::checkServerInstallationOK() start_tirviews(); } - // - // Check if TIRViews or dummy TrackIR.exe is required for this game - // - if (s.useDummyExe) { - start_dummy(); - } - + // more games need the dummy executable than previously thought + start_dummy(); + pMemData->data.DataID = 1; pMemData->data.CamWidth = 100; pMemData->data.CamHeight = 250; -- cgit v1.2.3 From 80e7167f0b679782d7f5fc1200112026a64d8339 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 7 Jun 2014 21:53:22 +0200 Subject: fix some confused crapola that never worked anyway Broke some games. How did it EVER work, is beyond me. Signed-off-by: Stanislaw Halik --- ftnoir_csv/csv.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ftnoir_csv/csv.cpp b/ftnoir_csv/csv.cpp index ebdf50bb..66823d24 100644 --- a/ftnoir_csv/csv.cpp +++ b/ftnoir_csv/csv.cpp @@ -155,7 +155,7 @@ void CSV::getGameData( const int id, unsigned char* table, QString& gamename) tmp + 6, tmp + 5, tmp + 4, - fuzz + 1) != 11 || (int) ((fuzz[2] << 8) | fuzz[0]) != gameLine.at(0).toInt()) + fuzz + 1) != 11) { qDebug() << "scanf failed" << fuzz[0] << fuzz[1] << fuzz[2]; } -- cgit v1.2.3 From 1603c540fa807b7ff3a2384bf800ba83c61ccdeb Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 8 Jun 2014 17:24:51 +0200 Subject: credit uglyDwarf --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 59d80403..04704cfe 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,7 @@ Don't be afraid to submit an issue/feature request if the need arises. - Patrick Ruoff (PT tracker) - FuraX49 (hatire arduino tracker) - Ulf Schreiber (PT tracker) +- uglyDwarf (high CON) - George Trigonakis (tester) - Wim Vriend (historically) - Ron Hendriks (historically) -- 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 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 e5276167b90c9f156c31fd811a7106f1880b2856 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 11 Jun 2014 17:42:05 +0200 Subject: use the precise counter Signed-off-by: Stanislaw Halik --- FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp | 2 +- FTNoIR_Tracker_PT/ftnoir_tracker_pt.h | 4 ++-- ftnoir_filter_accela/ftnoir_filter_accela.cpp | 3 +-- ftnoir_filter_accela/ftnoir_filter_accela.h | 4 ++-- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp index 162e4343..cbc1f1dc 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp @@ -74,7 +74,7 @@ void Tracker::run() if (commands & PAUSE) continue; commands = 0; - dt = time.restart() / 1000.0; + dt = time.start() / 1000.0; new_frame = camera.get_frame(dt, &frame); diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h index 1f6efce1..80abbc6a 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h @@ -18,7 +18,7 @@ #include "point_extractor.h" #include "point_tracker.h" #include "pt_video_widget.h" -#include +#include "facetracknoir/timer.hpp" #include #include @@ -84,7 +84,7 @@ protected: bool tracking_valid; settings s; - QElapsedTimer time; + Timer time; }; #undef VideoWidget diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.cpp b/ftnoir_filter_accela/ftnoir_filter_accela.cpp index 13e4ea79..31cb94bd 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela.cpp @@ -67,8 +67,7 @@ void FTNoIR_Filter::FilterHeadPoseData(const double* target_camera_position, { for (int i = 0; i < 6; i++) last_input[i] = target_camera_position[i]; - frame_delta = timer.isValid() ? timer.elapsed() : 1; - timer.start(); + frame_delta = timer.start(); } else { auto d = timer.elapsed(); double c = clamp(0.0, 1.0, d / (double) frame_delta); diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.h b/ftnoir_filter_accela/ftnoir_filter_accela.h index 42db2e47..f56ae57c 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.h +++ b/ftnoir_filter_accela/ftnoir_filter_accela.h @@ -3,7 +3,7 @@ #include "ui_ftnoir_accela_filtercontrols.h" #include "facetracknoir/global-settings.h" #include -#include +#include "facetracknoir/timer.hpp" #define ACCELA_SMOOTHING_ROTATION 60.0 #define ACCELA_SMOOTHING_TRANSLATION 40.0 @@ -51,7 +51,7 @@ private: bool first_run; double last_input[6]; double last_output[3][6]; - QElapsedTimer timer; + Timer timer; qint64 frame_delta; }; -- 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(-) 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 64dea656becd8c914a3c8dc3f3b4f0d71bd3f2d0 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 11 Jun 2014 20:05:36 +0200 Subject: Defer PT apply to avoid deadlock --- FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp | 22 ++++++++++++++++++---- FTNoIR_Tracker_PT/ftnoir_tracker_pt.h | 6 ++++-- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp index cbc1f1dc..787a5128 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp @@ -26,7 +26,9 @@ Tracker::Tracker() : commands(0), video_widget(NULL), video_frame(NULL), - tracking_valid(false) + tracking_valid(false), + need_apply(false), + new_settings(nullptr) { qDebug()<<"Tracker::Tracker"; } @@ -73,7 +75,7 @@ void Tracker::run() if (commands & ABORT) break; if (commands & PAUSE) continue; commands = 0; - + apply_inner(); dt = time.start() / 1000.0; new_frame = camera.get_frame(dt, &frame); @@ -111,11 +113,23 @@ void Tracker::run() qDebug()<<"Tracker:: Thread stopping"; } - void Tracker::apply(settings& s) { - qDebug()<<"Tracker:: Applying settings"; QMutexLocker lock(&mutex); + need_apply = true; + // caller guarantees object lifetime + new_settings = &s; +} + +void Tracker::apply_inner() +{ + QMutexLocker lock(&mutex); + if (!need_apply) + return; + qDebug()<<"Tracker:: Applying settings"; + auto& s = *new_settings; + new_settings = nullptr; + need_apply = false; camera.set_device_index(s.cam_index); camera.set_res(s.cam_res_x, s.cam_res_y); camera.set_fps(s.cam_fps); diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h index 80abbc6a..47a9987b 100644 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h +++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h @@ -44,6 +44,7 @@ public: virtual void refreshVideo(); void apply(settings& s); + void apply_inner(); void center(); void reset(); // reset the trackers internal state variables void run(); @@ -81,9 +82,10 @@ protected: PTVideoWidget* video_widget; QFrame* video_frame; - bool tracking_valid; - + bool tracking_valid, need_apply; + settings s; + settings* new_settings; Timer time; }; -- 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(-) 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(-) 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