From 07ec84196efaa8286975db792f5ca3e31ca28edb Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 14 Oct 2014 23:15:54 +0200 Subject: add-comment --- facetracknoir/facetracknoir.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.h b/facetracknoir/facetracknoir.h index d4c3a369..040bb170 100644 --- a/facetracknoir/facetracknoir.h +++ b/facetracknoir/facetracknoir.h @@ -91,6 +91,8 @@ public slots: void shortcutRecentered(); void shortcutToggled(); private: + // XXX move the shit outta the _widget_, establish a class + // for running tracker state, etc -sh 20141014 Mappings pose; Ui::OpentrackUI ui; QTimer timUpdateHeadPose; -- cgit v1.2.3 From f43e48bc3388743bc233f7b0b5196a437c937224 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 15 Oct 2014 02:28:29 +0200 Subject: rotation below -99 didn't display, just froze --- facetracknoir/facetracknoir.ui | 42 ++++++++++++------------------------------ 1 file changed, 12 insertions(+), 30 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.ui b/facetracknoir/facetracknoir.ui index ad968030..a201b643 100644 --- a/facetracknoir/facetracknoir.ui +++ b/facetracknoir/facetracknoir.ui @@ -95,7 +95,7 @@ QFrame::NoFrame - 3 + 4 QLCDNumber::Outline @@ -117,7 +117,7 @@ QFrame::NoFrame - 3 + 4 QLCDNumber::Outline @@ -165,7 +165,7 @@ QFrame::NoFrame - 3 + 4 QLCDNumber::Outline @@ -187,7 +187,7 @@ QFrame::NoFrame - 3 + 4 QLCDNumber::Outline @@ -247,7 +247,7 @@ QFrame::NoFrame - 3 + 4 QLCDNumber::Outline @@ -295,7 +295,7 @@ QFrame::NoFrame - 3 + 4 QLCDNumber::Outline @@ -341,14 +341,11 @@ QFrame::NoFrame - - QFrame::Raised - true - 3 + 4 QLCDNumber::Flat @@ -369,14 +366,11 @@ QFrame::NoFrame - - QFrame::Raised - true - 3 + 4 QLCDNumber::Flat @@ -413,14 +407,11 @@ QFrame::NoFrame - - QFrame::Raised - true - 3 + 4 QLCDNumber::Flat @@ -463,14 +454,11 @@ QFrame::NoFrame - - QFrame::Raised - true - 3 + 4 QLCDNumber::Flat @@ -529,14 +517,11 @@ QFrame::NoFrame - - QFrame::Raised - true - 3 + 4 QLCDNumber::Flat @@ -573,14 +558,11 @@ QFrame::NoFrame - - QFrame::Raised - true - 3 + 4 QLCDNumber::Flat -- cgit v1.2.3 From 8662964ed74af867b2f2c19782478f709e586fc0 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 15 Oct 2014 02:28:50 +0200 Subject: drop decimal places for rot/trans in UI --- facetracknoir/facetracknoir.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'facetracknoir') diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp index f689cb5f..73dae199 100644 --- a/facetracknoir/facetracknoir.cpp +++ b/facetracknoir/facetracknoir.cpp @@ -353,6 +353,12 @@ void FaceTrackNoIR::showHeadPose() if (mapping_widget) mapping_widget->update(); + + for (int i = 0; i < 6; i++) + { + mapped[i] = (int) mapped[i]; + raw[i] = (int) raw[i]; + } ui.lcdNumX->display(raw[TX]); ui.lcdNumY->display(raw[TY]); -- cgit v1.2.3 From a2ed9ca0f2a237e4de3fab61beff3191935e8986 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 15 Oct 2014 04:59:27 +0200 Subject: submit mapped data to filter, not raw --- facetracknoir/tracker.cpp | 103 +++++++++++++++++++++++++--------------------- facetracknoir/tracker.h | 6 ++- 2 files changed, 60 insertions(+), 49 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/tracker.cpp b/facetracknoir/tracker.cpp index 4a80c722..f17b257f 100644 --- a/facetracknoir/tracker.cpp +++ b/facetracknoir/tracker.cpp @@ -36,14 +36,13 @@ Tracker::~Tracker() wait(); } -void Tracker::get_curve(double pos, double& out, Mapping& axis) { +double Tracker::map(double pos, Mapping& axis) { bool altp = (pos < 0) && axis.opts.altp; axis.curve.setTrackingActive( !altp ); axis.curveAlt.setTrackingActive( altp ); auto& fc = altp ? axis.curveAlt : axis.curve; - out = (axis.opts.invert ? -1 : 1) * fc.getValue(pos); - - out += axis.opts.zero; + double invert = axis.opts.invert ? -1 : 1; + return invert * (fc.getValue(pos) + axis.opts.zero); } void Tracker::t_compensate(const double* input, double* output, bool rz) @@ -82,24 +81,14 @@ void Tracker::t_compensate(const double* input, double* output, bool rz) output[i] = ret(i); } -void Tracker::run() { - Pose pose_offset, unstopped_pose; - - double newpose[6] = {0}; - const int sleep_ms = 3; - -#if defined(_WIN32) - (void) timeBeginPeriod(1); -#endif +void Tracker::logic() +{ + Libraries->pTracker->GetHeadPoseData(newpose); + + Pose final_raw; - while (!should_quit) + if (enabledp) { - t.start(); - - Libraries->pTracker->GetHeadPoseData(newpose); - - Pose final_raw, filtered; - for (int i = 0; i < 6; i++) { auto& axis = m(i); @@ -109,37 +98,57 @@ void Tracker::run() { // not really raw, after axis remap -sh final_raw(i) = newpose[k]; } + unstopped_raw = final_raw; + } + + Pose filtered_pose; + + if (Libraries->pFilter) + Libraries->pFilter->FilterHeadPoseData(final_raw, filtered_pose); + else + filtered_pose = final_raw; + + if (centerp) + { + centerp = false; + raw_center = final_raw; + } + + Pose raw_centered = filtered_pose & raw_center; + + Pose mapped_pose_precomp; + + for (int i = 0; i < 6; i++) + mapped_pose_precomp(i) = map(raw_centered(i), m(i)); + + Pose mapped_pose; + + if (s.tcomp_p) + t_compensate(mapped_pose_precomp, mapped_pose, s.tcomp_tz); + else + mapped_pose = mapped_pose_precomp; - { - if (enabledp) - unstopped_pose = final_raw; - - if (Libraries->pFilter) - Libraries->pFilter->FilterHeadPoseData(unstopped_pose, filtered); - else - filtered = unstopped_pose; - - if (centerp) { - centerp = false; - pose_offset = filtered; - } - - filtered = filtered & pose_offset; - - for (int i = 0; i < 6; i++) - get_curve(filtered(i), filtered(i), m(i)); - } + Libraries->pProtocol->sendHeadposeToGame(mapped_pose); - if (s.tcomp_p) - t_compensate(filtered, filtered, s.tcomp_tz); + { + QMutexLocker foo(&mtx); + output_pose = mapped_pose; + raw_6dof = unstopped_raw; + } +} - Libraries->pProtocol->sendHeadposeToGame(filtered); +void Tracker::run() { + const int sleep_ms = 3; - { - QMutexLocker foo(&mtx); - output_pose = filtered; - raw_6dof = final_raw; - } +#if defined(_WIN32) + (void) timeBeginPeriod(1); +#endif + + while (!should_quit) + { + t.start(); + + logic(); const long q = 1000L * std::max(0L, sleep_ms - t.elapsed_ms()); usleep(q); diff --git a/facetracknoir/tracker.h b/facetracknoir/tracker.h index d65e1cf1..afb86802 100644 --- a/facetracknoir/tracker.h +++ b/facetracknoir/tracker.h @@ -23,12 +23,14 @@ private: // XXX can be const-cast when functionconfig const-correct -sh 20141004 Mappings& m; Timer t; - Pose output_pose, raw_6dof; + Pose output_pose, raw_6dof, raw_center, unstopped_raw; + double newpose[6]; std::atomic centerp; std::atomic enabledp; std::atomic should_quit; - static void get_curve(double pos, double& out, Mapping& axis); + double map(double pos, Mapping& axis); + void logic(); static void t_compensate(const double* input, double* output, bool rz); protected: void run() override; -- cgit v1.2.3 From 619d3d8010b3c093fba8e87f831cc438d8822479 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 15 Oct 2014 17:31:29 +0200 Subject: gcc too much a piece of work often Issue: #81 --- facetracknoir/options.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'facetracknoir') diff --git a/facetracknoir/options.h b/facetracknoir/options.h index 7833ea41..d9667e4a 100644 --- a/facetracknoir/options.h +++ b/facetracknoir/options.h @@ -75,7 +75,7 @@ namespace options { // snapshot of qsettings group at given time class group { private: - map map; + map kvs; string name; static const QString ini_pathname() { @@ -93,7 +93,7 @@ namespace options { { auto tmp = k_.toUtf8(); string k(tmp); - map[k] = conf.value(k_); + kvs[k] = conf.value(k_); } conf.endGroup(); } @@ -104,7 +104,7 @@ namespace options { QSettings s(ini_pathname(), QSettings::IniFormat); auto q_name = QString::fromStdString(name); s.beginGroup(q_name); - for (auto& i : map) + for (auto& i : kvs) { auto k = QString::fromStdString(i.first); s.setValue(k, i.second); @@ -115,17 +115,17 @@ namespace options { template t get(const string& k) { - return qcruft_to_t(map[k]); + return qcruft_to_t(kvs[k]); } void put(const string& s, const QVariant& d) { - map[s] = d; + kvs[s] = d; } bool contains(const string& s) { - return map.count(s) != 0; + return kvs.count(s) != 0; } }; -- cgit v1.2.3