From 9e58eb6d5eebb3ca67bf4dba6b7fef58588d492e Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 7 Aug 2015 05:50:21 +0200 Subject: aruco: don't hardcode thres param 2 --- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index 08ddd3b2..a6889f82 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -144,11 +144,12 @@ void Tracker::run() if (!camera.read(color)) continue; } + static constexpr int thres_param2 = 5; cv::Mat grayscale; cv::cvtColor(color, grayscale, cv::COLOR_RGB2GRAY); const int scale = grayscale.cols > 480 ? 2 : 1; - detector.setThresholdParams(box_sizes[box_idx], 5); + detector.setThresholdParams(box_sizes[box_idx], thres_param2); static constexpr double pi = 3.1415926f; const int w = grayscale.cols, h = grayscale.rows; @@ -177,7 +178,7 @@ void Tracker::run() if (last_roi.width > 0 && last_roi.height) { - detector.setThresholdParams(box_sizes[box_idx], 5); + detector.setThresholdParams(box_sizes[box_idx], thres_param2); detector.setMinMaxSize(std::max(0.01, size_min * grayscale.cols / last_roi.width), std::min(1.0, size_max * grayscale.cols / last_roi.width)); @@ -206,7 +207,7 @@ void Tracker::run() qDebug() << "aruco: box size now" << box_sizes[box_idx]; failed = 0; } - detector.setThresholdParams(box_sizes[box_idx], 5); + detector.setThresholdParams(box_sizes[box_idx], thres_param2); detector.setMinMaxSize(size_min, size_max); detector.detect(grayscale, markers, cv::Mat(), cv::Mat(), -1, false); } -- cgit v1.2.3 From b68cf0b79cf112d919ee0f224bc205f57c7cac92 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 7 Aug 2015 05:50:42 +0200 Subject: aruco: try otsu for one frame if regular fails --- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 6 +++++- ftnoir_tracker_aruco/include/markerdetector.h | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) mode change 100644 => 100755 ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp mode change 100644 => 100755 ftnoir_tracker_aruco/include/markerdetector.h diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp old mode 100644 new mode 100755 index a6889f82..84f20a61 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -134,6 +134,7 @@ void Tracker::run() cv::Vec3d rvec, tvec; cv::Mat intrinsics = cv::Mat::eye(3, 3, CV_32FC1); cv::Mat dist_coeffs = cv::Mat::zeros(5, 1, CV_32FC1); + bool otsu = false; while (!stop) { @@ -182,7 +183,8 @@ 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)); - if (detector.detect(grayscale(last_roi), markers, cv::Mat(), cv::Mat(), -1, false), + cv::Mat grayscale_ = grayscale(last_roi).clone(); + if (detector.detect(grayscale_, markers, cv::Mat(), cv::Mat(), -1, false), markers.size() == 1 && markers[0].size() == 4) { failed = std::max(0., failed - dt); @@ -199,6 +201,8 @@ void Tracker::run() if (!roi_valid) { + otsu = !otsu; + detector._thresMethod = otsu ? aruco::MarkerDetector::FIXED_THRES : aruco::MarkerDetector::ADPT_THRES; failed += dt; if (failed > max_failed) { diff --git a/ftnoir_tracker_aruco/include/markerdetector.h b/ftnoir_tracker_aruco/include/markerdetector.h old mode 100644 new mode 100755 index ac120b18..8a7e75ca --- a/ftnoir_tracker_aruco/include/markerdetector.h +++ b/ftnoir_tracker_aruco/include/markerdetector.h @@ -277,6 +277,7 @@ private: * This function returns in candidates all the rectangles found in a thresolded image */ void detectRectangles(const cv::Mat &thresImg,vector & candidates); +public: //Current threshold method ThresholdMethods _thresMethod; //Threshold parameters @@ -297,7 +298,7 @@ private: cv::Mat grey,thres,thres2,reduced; //pointer to the function that analizes a rectangular region so as to detect its internal marker int (* markerIdDetector_ptrfunc)(const cv::Mat &in,int &nRotations); - +private: /** */ bool isInto(cv::Mat &contour,std::vector &b); -- cgit v1.2.3 From 1e6f070677ebcf2649924f682aa66b939fa874f8 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 9 Aug 2015 04:03:40 +0200 Subject: main: remap axis before mapping Issue: #213 --- opentrack/tracker.cpp | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/opentrack/tracker.cpp b/opentrack/tracker.cpp index e03342e4..acbfded5 100644 --- a/opentrack/tracker.cpp +++ b/opentrack/tracker.cpp @@ -81,7 +81,12 @@ void Tracker::logic() if (!zero_) for (int i = 0; i < 6; i++) { - value(i) = newpose[i]; + auto& axis = m(i); + int k = axis.opts.src; + if (k < 0 || k >= 6) + value(i) = 0; + else + value(i) = newpose[k]; raw(i) = newpose[i]; } else @@ -157,23 +162,10 @@ void Tracker::logic() for (int i = 0; i < 6; i++) value[i] *= inverts[i] ? -1. : 1.; - Pose output_pose_; - - for (int i = 0; i < 6; i++) - { - auto& axis = m(i); - int k = axis.opts.src; - if (k < 0 || k >= 6) - output_pose_(i) = 0; - else - output_pose_(i) = value(k); - } - - - libs.pProtocol->pose(output_pose_); + libs.pProtocol->pose(value); QMutexLocker foo(&mtx); - output_pose = output_pose_; + output_pose = value; raw_6dof = raw; } -- cgit v1.2.3 From 573a78eeda6423ff4ce72dda9f00c366b20672d5 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 9 Aug 2015 04:04:32 +0200 Subject: main: apply center pose after compensation Issue: #212 --- opentrack/tracker.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) mode change 100644 => 100755 opentrack/tracker.cpp diff --git a/opentrack/tracker.cpp b/opentrack/tracker.cpp old mode 100644 new mode 100755 index acbfded5..f31e1185 --- a/opentrack/tracker.cpp +++ b/opentrack/tracker.cpp @@ -46,7 +46,7 @@ double Tracker::map(double pos, Mapping& axis) axis.curve.setTrackingActive( !altp ); axis.curveAlt.setTrackingActive( altp ); auto& fc = altp ? axis.curveAlt : axis.curve; - return fc.getValue(pos) + axis.opts.zero; + return fc.getValue(pos); } void Tracker::t_compensate(const rmat& rmat, const double* xyz, double* output, bool rz) @@ -149,7 +149,7 @@ void Tracker::logic() if (libs.pFilter) libs.pFilter->filter(tmp, value); } - + for (int i = 0; i < 6; i++) value(i) = map(value(i), m(i)); @@ -158,7 +158,10 @@ void Tracker::logic() value, value, s.tcomp_tz); - + + for (int i = 0; i < 6; i++) + value(i) += m(i).opts.zero; + for (int i = 0; i < 6; i++) value[i] *= inverts[i] ? -1. : 1.; -- cgit v1.2.3 From 32c7d8370faca901162500a26f43a445f4f8e095 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 11 Aug 2015 03:32:23 +0200 Subject: simple-mat: open-code operator()(x, y) calls --- opentrack/simple-mat.hpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) mode change 100644 => 100755 opentrack/simple-mat.hpp diff --git a/opentrack/simple-mat.hpp b/opentrack/simple-mat.hpp old mode 100644 new mode 100755 index 7432e665..1d3b10e1 --- a/opentrack/simple-mat.hpp +++ b/opentrack/simple-mat.hpp @@ -90,7 +90,7 @@ struct Mat num ret = 0; constexpr int len = vector_len::value; for (int i = 0; i < len; i++) - ret += operator()(i) * p2.operator ()(i); + ret += operator()(i) * p2(i); return ret; } @@ -108,7 +108,7 @@ struct Mat Mat ret; for (int j = 0; j < h_; j++) for (int i = 0; i < w_; i++) - ret(j, i) = this->operator ()(j, i) + other(j, i); + ret(j, i) = data[j][i] + other(j, i); return ret; } @@ -117,7 +117,7 @@ struct Mat Mat ret; for (int j = 0; j < h_; j++) for (int i = 0; i < w_; i++) - ret(j, i) = this->operator ()(j, i) - other(j, i); + ret(j, i) = data[j][i] - other(j, i); return ret; } @@ -126,7 +126,7 @@ struct Mat Mat ret; for (int j = 0; j < h_; j++) for (int i = 0; i < w_; i++) - ret(j, i) = this->operator ()(j, i) + other; + ret(j, i) = data[j][i] + other; return ret; } @@ -135,7 +135,7 @@ struct Mat Mat ret; for (int j = 0; j < h_; j++) for (int i = 0; i < w_; i++) - ret(j, i) = this->operator ()(j, i) - other; + ret(j, i) = data[j][i] - other; return ret; } @@ -144,7 +144,7 @@ struct Mat Mat ret; for (int j = 0; j < h_; j++) for (int i = 0; i < w_; i++) - ret(j, i) = operator()(j, i) * other; + ret(j, i) = data[j][i] * other; return ret; } -- cgit v1.2.3 From 6685572195f1e3e22a803ca984d3566516488815 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 11 Aug 2015 03:48:13 +0200 Subject: pose-widget: use floats --- pose-widget/glwidget.cpp | 59 +++++++++++++++++++++++++++--------------------- pose-widget/glwidget.h | 9 ++++---- 2 files changed, 38 insertions(+), 30 deletions(-) mode change 100644 => 100755 pose-widget/glwidget.cpp mode change 100644 => 100755 pose-widget/glwidget.h diff --git a/pose-widget/glwidget.cpp b/pose-widget/glwidget.cpp old mode 100644 new mode 100755 index 8fbe046e..6da1948e --- a/pose-widget/glwidget.cpp +++ b/pose-widget/glwidget.cpp @@ -12,6 +12,10 @@ #include #include +#ifdef __GNUC__ +#pragma GCC diagnostic ignored "-Wnarrowing" +#endif + GLWidget::GLWidget(QWidget *parent) : QWidget(parent) { Q_INIT_RESOURCE(posewidget); @@ -31,17 +35,17 @@ void GLWidget::paintEvent ( QPaintEvent * event ) { p.drawImage(event->rect(), texture); } -void GLWidget::rotateBy(double xAngle, double yAngle, double zAngle, double x, double y, double z) +void GLWidget::rotateBy(float xAngle, float yAngle, float zAngle, float x, float y, float z) { - double c1 = cos(yAngle / 57.295781); - double s1 = sin(yAngle / 57.295781); - double c2 = cos(xAngle / 57.295781); - double s2 = sin(xAngle / 57.295781); - double c3 = cos(zAngle / 57.295781); - double s3 = sin(zAngle / 57.295781); + float c1 = cos(yAngle / 57.295781); + float s1 = sin(yAngle / 57.295781); + float c2 = cos(xAngle / 57.295781); + float s2 = sin(xAngle / 57.295781); + float c3 = cos(zAngle / 57.295781); + float s3 = sin(zAngle / 57.295781); - double foo[] = { + float foo[] = { c2*c3, -c2*s3, s2, c1*s3+c3*s1*s2, c1*c3-s1*s2*s3, -c2*s1, s1*s3-c1*c3*s2, c3*s1+c1*s2*s3, c1*c2, @@ -55,6 +59,7 @@ void GLWidget::rotateBy(double xAngle, double yAngle, double zAngle, double x, d class Triangle { + using num = GLWidget::num; public: Triangle(const vec2& p1, const vec2& p2, @@ -71,27 +76,29 @@ public: bool barycentric_coords(const vec2& px, vec2& uv) const { vec2 v2 = px - origin; - double dot12 = v1.dot(v2); - double dot02 = v0.dot(v2); - double u = (dot11 * dot02 - dot01 * dot12) * invDenom; - double v = (dot00 * dot12 - dot01 * dot02) * invDenom; + num dot12 = v1.dot(v2); + num dot02 = v0.dot(v2); + num u = (dot11 * dot02 - dot01 * dot12) * invDenom; + num v = (dot00 * dot12 - dot01 * dot02) * invDenom; uv = vec2({u, v}); return (u >= 0) && (v >= 0) && (u + v <= 1); } private: - double dot00, dot01, dot11, invDenom; + num dot00, dot01, dot11, invDenom; vec2 v0, v1, origin; }; static __inline vec3 normal(const vec3& p1, const vec3& p2, const vec3& p3) { + using num = GLWidget::num; + vec3 u = p2 - p1; vec3 v = p3 - p1; vec3 tmp = u.cross(v); - double i = 1./sqrt(tmp.dot(tmp)); + num i = 1./sqrt(tmp.dot(tmp)); return tmp * i; } @@ -100,14 +107,14 @@ void GLWidget::project_quad_texture() { const int sx = width(), sy = height(); vec2 pt[4]; const vec3 corners[] = { - vec3({0., 0., 0.}), - vec3({sx-1., 0., 0.}), - vec3({0., sy-1., 0.}), - vec3({sx-1., sy-1., 0.}) + vec3({0., 0, 0}), + vec3({sx-1, 0, 0}), + vec3({0, sy-1, 0}), + vec3({sx-1, sy-1, 0.}) }; for (int i = 0; i < 4; i++) { - pt[i] = project(vec3({corners[i].x() - sx/2., corners[i].y() - sy/2., 0})); + pt[i] = project(vec3({corners[i].x() - sx/2, corners[i].y() - sy/2, 0})); pt[i].x() += sx/2.; pt[i].y() += sy/2.; } @@ -121,7 +128,7 @@ void GLWidget::project_quad_texture() { normal2 = normal(foo[0], foo[1], foo[2]); } - double dir = normal1.dot(normal2); + num dir = normal1.dot(normal2); QImage& tex = dir < 0 ? back : front; @@ -137,8 +144,8 @@ void GLWidget::project_quad_texture() { const vec2 projected[2][3] = { { p2[0], p2[1], p2[2] }, { p2[3], p2[1], p2[2] } }; const vec2 origs[2][3] = { - { vec2({0., 0.}), vec2({ow-1., 0.}), vec2({0., oh-1.}) }, - { vec2({ow-1., oh-1.}), vec2({ow-1., 0.}), vec2({0., oh-1.}) } + { vec2({0, 0}), vec2({ow-1, 0}), vec2({0, oh-1}) }, + { vec2({ow-1, oh-1}), vec2({ow-1, 0}), vec2({0, oh-1}) } }; const Triangle triangles[2] = { Triangle(projected[0][0], projected[0][1], projected[0][2]), @@ -160,7 +167,7 @@ void GLWidget::project_quad_texture() { for (int y = 0; y < sy; y++) for (int x = 0; x < sx; x++) { - vec2 pos({(double)x, (double)y}); + vec2 pos({(num)x, (num)y}); for (int i = 0; i < 2; i++) { vec2 uv; if (triangles[i].barycentric_coords(pos, uv)) @@ -190,12 +197,12 @@ void GLWidget::project_quad_texture() { vec2 GLWidget::project(const vec3 &point) { vec3 ret = rotation * point; - double z = std::max(.75, 1. + translation.z()/-60.); + num z = std::max(.75, 1. + translation.z()/-60); int w = width(), h = height(); - double x = w * translation.x() / 2. / -40.; + num x = w * translation.x() / 2 / -40; if (std::abs(x) > w/2) x = x > 0 ? w/2 : w/-2; - double y = h * translation.y() / 2. / -40.; + num y = h * translation.y() / 2 / -40; if (std::abs(y) > h/2) y = y > 0 ? h/2 : h/-2; return vec2 { z * (ret.x() + x), z * (ret.y() + y) }; diff --git a/pose-widget/glwidget.h b/pose-widget/glwidget.h old mode 100644 new mode 100755 index 88961fbd..aaea3e06 --- a/pose-widget/glwidget.h +++ b/pose-widget/glwidget.h @@ -12,16 +12,17 @@ #include "opentrack/plugin-api.hpp" #include "opentrack/simple-mat.hpp" -typedef dmat<2, 1> vec2; -typedef dmat<3, 1> vec3; -typedef dmat<3, 3> rmat; +typedef Mat vec2; +typedef Mat vec3; +typedef Mat rmat; class GLWidget : public QWidget { public: + using num = float; GLWidget(QWidget *parent); ~GLWidget(); - void rotateBy(double xAngle, double yAngle, double zAngle, double x, double y, double z); + void rotateBy(float xAngle, float yAngle, float zAngle, float x, float y, float z); protected: void paintEvent ( QPaintEvent * event ) override; private: -- cgit v1.2.3 From 9161646a6ed0b84770c9645689b98b2d4a2dfb82 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 11 Aug 2015 06:35:43 +0200 Subject: pose-widget: don't pollute global namespace --- pose-widget/glwidget.cpp | 10 +++++----- pose-widget/glwidget.h | 9 +++++---- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/pose-widget/glwidget.cpp b/pose-widget/glwidget.cpp index 6da1948e..d6d5260e 100755 --- a/pose-widget/glwidget.cpp +++ b/pose-widget/glwidget.cpp @@ -60,6 +60,8 @@ void GLWidget::rotateBy(float xAngle, float yAngle, float zAngle, float x, float class Triangle { using num = GLWidget::num; + using vec2 = GLWidget::vec2; + using vec3 = GLWidget::vec3; public: Triangle(const vec2& p1, const vec2& p2, @@ -89,10 +91,8 @@ private: vec2 v0, v1, origin; }; -static __inline vec3 normal(const vec3& p1, const vec3& p2, const vec3& p3) +inline GLWidget::vec3 GLWidget::normal(const vec3& p1, const vec3& p2, const vec3& p3) { - using num = GLWidget::num; - vec3 u = p2 - p1; vec3 v = p3 - p1; @@ -194,7 +194,7 @@ void GLWidget::project_quad_texture() { this->texture = texture; } -vec2 GLWidget::project(const vec3 &point) +GLWidget::vec2 GLWidget::project(const vec3 &point) { vec3 ret = rotation * point; num z = std::max(.75, 1. + translation.z()/-60); @@ -208,7 +208,7 @@ vec2 GLWidget::project(const vec3 &point) return vec2 { z * (ret.x() + x), z * (ret.y() + y) }; } -vec3 GLWidget::project2(const vec3 &point) +GLWidget::vec3 GLWidget::project2(const vec3 &point) { return rotation * point; } diff --git a/pose-widget/glwidget.h b/pose-widget/glwidget.h index aaea3e06..81517399 100755 --- a/pose-widget/glwidget.h +++ b/pose-widget/glwidget.h @@ -12,14 +12,14 @@ #include "opentrack/plugin-api.hpp" #include "opentrack/simple-mat.hpp" -typedef Mat vec2; -typedef Mat vec3; -typedef Mat rmat; - class GLWidget : public QWidget { public: using num = float; + using vec2 = Mat; + using vec3 = Mat; + using rmat = Mat; + GLWidget(QWidget *parent); ~GLWidget(); void rotateBy(float xAngle, float yAngle, float zAngle, float x, float y, float z); @@ -29,6 +29,7 @@ private: vec2 project(const vec3& point); vec3 project2(const vec3& point); void project_quad_texture(); + static inline vec3 normal(const vec3& p1, const vec3& p2, const vec3& p3); rmat rotation; vec3 translation; QImage front; -- cgit v1.2.3 From 7b6627bb4769ada62c0b632cd72db9d0f0f74406 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 11 Aug 2015 06:35:52 +0200 Subject: pose-widget: we no longer warn on narrowing conversions --- pose-widget/glwidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pose-widget/glwidget.cpp b/pose-widget/glwidget.cpp index d6d5260e..8a90c37c 100755 --- a/pose-widget/glwidget.cpp +++ b/pose-widget/glwidget.cpp @@ -167,7 +167,7 @@ void GLWidget::project_quad_texture() { for (int y = 0; y < sy; y++) for (int x = 0; x < sx; x++) { - vec2 pos({(num)x, (num)y}); + vec2 pos({x, y}); for (int i = 0; i < 2; i++) { vec2 uv; if (triangles[i].barycentric_coords(pos, uv)) -- cgit v1.2.3 From f0f18a08e2f4a82902098df8d54578811919fa67 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 11 Aug 2015 06:41:02 +0200 Subject: simple-mat: open-code more, add comment --- opentrack/simple-mat.hpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/opentrack/simple-mat.hpp b/opentrack/simple-mat.hpp index 1d3b10e1..49bf4feb 100755 --- a/opentrack/simple-mat.hpp +++ b/opentrack/simple-mat.hpp @@ -47,6 +47,9 @@ template struct Mat { num data[h_][w_]; + + // parameters w_ and h_ are rebound so that SFINAE occurs + // removing them causes a compile-time error -sh 20150811 template typename std::enable_if::value, num>::type __inline operator()(int i) const { return data[i][0]; } @@ -108,7 +111,7 @@ struct Mat Mat ret; for (int j = 0; j < h_; j++) for (int i = 0; i < w_; i++) - ret(j, i) = data[j][i] + other(j, i); + ret(j, i) = data[j][i] + other.data[j][i]; return ret; } @@ -117,7 +120,7 @@ struct Mat Mat ret; for (int j = 0; j < h_; j++) for (int i = 0; i < w_; i++) - ret(j, i) = data[j][i] - other(j, i); + ret(j, i) = data[j][i] - other.data[j][i]; return ret; } -- cgit v1.2.3 From 33286a3e74b03d1942a2ad61d69320a9434fd75a Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 11 Aug 2015 06:49:33 +0200 Subject: tracker-udp: prevent read past end of buffer Can happen with incorrect .ini values. --- ftnoir_tracker_udp/ftnoir_tracker_udp.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) mode change 100644 => 100755 ftnoir_tracker_udp/ftnoir_tracker_udp.cpp diff --git a/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp b/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp old mode 100644 new mode 100755 index bc42f402..f03e75aa --- a/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp +++ b/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp @@ -59,7 +59,10 @@ void FTNoIR_Tracker::data(double *data) }; for (int i = 0; i < 3; i++) - data[Yaw + i] += values[indices[i]]; + { + int k = std::min(sizeof(values)/sizeof(values[0]), std::max(0, indices[i])); + data[Yaw + i] += values[k]; + } } -- cgit v1.2.3 From 96a8c6776ce4451b0b725cf3f2086f65d1ed9824 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 11 Aug 2015 06:56:00 +0200 Subject: qfc: add comment --- qfunctionconfigurator/functionconfig.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/qfunctionconfigurator/functionconfig.cpp b/qfunctionconfigurator/functionconfig.cpp index c97aec16..08fef64c 100755 --- a/qfunctionconfigurator/functionconfig.cpp +++ b/qfunctionconfigurator/functionconfig.cpp @@ -120,6 +120,7 @@ void Map::reload() { const n t2 = t*t; const n t3 = t*t*t; + // XXX we could solve for t instead -sh 20150811 const int x = .5 * ((2. * p1_x) + (-p0_x + p2_x) * t + (2. * p0_x - 5. * p1_x + 4. * p2_x - p3_x) * t2 + -- cgit v1.2.3 From 87379aa9dcbf83badec1d236ae0007f8eaf66a88 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 11 Aug 2015 07:27:57 +0200 Subject: qfc: type mismatch --- qfunctionconfigurator/functionconfig.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qfunctionconfigurator/functionconfig.cpp b/qfunctionconfigurator/functionconfig.cpp index 08fef64c..8301c7f9 100755 --- a/qfunctionconfigurator/functionconfig.cpp +++ b/qfunctionconfigurator/functionconfig.cpp @@ -141,7 +141,7 @@ void Map::reload() { } } - num last = 0; + integral last = 0; for (int i = 0; i < sz; i++) { if (data[i] == integral_max) -- cgit v1.2.3 From 36d8cab7c3a975fe53ca7429f2017efb99acee51 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 13 Aug 2015 09:42:19 +0200 Subject: update mingw-w64 cmake toolchain file --- cmake/mingw-w64.cmake | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cmake/mingw-w64.cmake b/cmake/mingw-w64.cmake index 80ecf0f5..f8ee1d41 100644 --- a/cmake/mingw-w64.cmake +++ b/cmake/mingw-w64.cmake @@ -25,11 +25,12 @@ SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) -set(cpu "-O3 -march=i686 -mtune=corei7-avx -ffast-math -mfpmath=both -msse -msse2 -mno-sse3 -mno-avx") +# oldest CPU supported here is Northwood-based Pentium 4. -sh 20150811 +set(cpu "-O3 -march=pentium4 -mtune=corei7-avx -ffast-math -mfpmath=both -msse -msse2 -mno-sse3") set(CFLAGS-OVERRIDE "" CACHE STRING "") -set(CMAKE_C_FLAGS_RELEASE "${rice} ${cpu} ${CFLAGS-OVERRIDE}" CACHE STRING "" FORCE) +set(CMAKE_C_FLAGS_RELEASE "${cpu} ${CFLAGS-OVERRIDE}" CACHE STRING "" FORCE) set(CMAKE_CXX_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE} CACHE STRING "" FORCE) set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${cpu} ${CFLAGS-OVERRIDE}" CACHE STRING "" FORCE) set(CMAKE_EXE_LINKER_FLAGS_RELEASE ${CMAKE_SHARED_LINKER_FLAGS_RELEASE} CACHE STRING "" FORCE) -- cgit v1.2.3 From 0f89e2439ac7a89baf371ce3dd522e96bb933c83 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 13 Aug 2015 09:42:56 +0200 Subject: tracker: use concise syntax for vector access --- opentrack/tracker.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/opentrack/tracker.cpp b/opentrack/tracker.cpp index f31e1185..e79d32c1 100755 --- a/opentrack/tracker.cpp +++ b/opentrack/tracker.cpp @@ -55,11 +55,11 @@ void Tracker::t_compensate(const rmat& rmat, const double* xyz, double* output, dmat<3, 1> tvec({ xyz[2], -xyz[0], -xyz[1] }); const dmat<3, 1> ret = rmat * tvec; if (!rz) - output[2] = ret(0, 0); + output[2] = ret(0); else output[2] = xyz[2]; - output[1] = -ret(2, 0); - output[0] = -ret(1, 0); + output[1] = -ret(2); + output[0] = -ret(1); } void Tracker::logic() @@ -95,7 +95,7 @@ void Tracker::logic() for (int i = 0; i < 3; i++) { - raw(i+3) = value(i+3) = mat(i, 0) * r2d; + raw(i+3) = value(i+3) = mat(i) * r2d; raw(i) = value(i) = t_b[i]; } } @@ -127,19 +127,19 @@ void Tracker::logic() { centerp = false; for (int i = 0; i < 3; i++) - t_b[i] = t(i, 0); + t_b[i] = t(i); r_b = r; } { - double tmp[3] = { t(0, 0) - t_b[0], t(1, 0) - t_b[1], t(2, 0) - t_b[2] }; + double tmp[3] = { t(0) - t_b[0], t(1) - t_b[1], t(2) - t_b[2] }; t_compensate(cam, tmp, tmp, false); const rmat m_ = r_b.t() * r; const dmat<3, 1> euler = rmat::rmat_to_euler(m_); for (int i = 0; i < 3; i++) { value(i) = tmp[i]; - value(i+3) = euler(i, 0) * r2d; + value(i+3) = euler(i) * r2d; } } -- cgit v1.2.3 From 1ea849d0f6f934beb69ed72790f02d079a7ba435 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 13 Aug 2015 09:43:13 +0200 Subject: tracker: no need to run logic() at all --- opentrack/tracker.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/opentrack/tracker.cpp b/opentrack/tracker.cpp index e79d32c1..22a8933c 100755 --- a/opentrack/tracker.cpp +++ b/opentrack/tracker.cpp @@ -197,10 +197,6 @@ void Tracker::run() { } { - // do one last pass with origin pose - for (int i = 0; i < 6; i++) - newpose[i] = 0; - logic(); // filter may inhibit exact origin Pose p; libs.pProtocol->pose(p); -- cgit v1.2.3 From 9814176e83fc621f5dc150ec923c558435a41b4e Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 13 Aug 2015 09:43:35 +0200 Subject: pose-widget: const nonsense --- pose-widget/glwidget.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pose-widget/glwidget.cpp b/pose-widget/glwidget.cpp index 8a90c37c..6c04c4e6 100755 --- a/pose-widget/glwidget.cpp +++ b/pose-widget/glwidget.cpp @@ -77,11 +77,11 @@ public: } bool barycentric_coords(const vec2& px, vec2& uv) const { - vec2 v2 = px - origin; - num dot12 = v1.dot(v2); - num dot02 = v0.dot(v2); - num u = (dot11 * dot02 - dot01 * dot12) * invDenom; - num v = (dot00 * dot12 - dot01 * dot02) * invDenom; + const vec2 v2 = px - origin; + const num dot12 = v1.dot(v2); + const num dot02 = v0.dot(v2); + const num u = (dot11 * dot02 - dot01 * dot12) * invDenom; + const num v = (dot00 * dot12 - dot01 * dot02) * invDenom; uv = vec2({u, v}); return (u >= 0) && (v >= 0) && (u + v <= 1); } -- cgit v1.2.3 From 91f6a2c3822987c321d74da8bacf6b6460eb7388 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 13 Aug 2015 09:56:39 +0200 Subject: cmake: remove obsolete hack --- CMakeLists.txt | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) mode change 100644 => 100755 CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt old mode 100644 new mode 100755 index e6a3afc3..1f943879 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,11 +37,7 @@ if(MSVC) add_definitions(-DNOMINMAX -D_CRT_SECURE_NO_WARNINGS) endif() -set(my-qt-deps) -if(WIN32) # hack to avoid breakage on buildbot - set(my-qt-deps ws2_32) -endif() -set(MY_QT_LIBS ${Qt5Core_LIBRARIES} ${Qt5Gui_LIBRARIES} ${Qt5Widgets_LIBRARIES} ${Qt5Network_LIBRARIES} ${Qt5Xml_LIBRARIES} ${my-qt-deps}) +set(MY_QT_LIBS ${Qt5Core_LIBRARIES} ${Qt5Gui_LIBRARIES} ${Qt5Widgets_LIBRARIES} ${Qt5Network_LIBRARIES} ${Qt5Xml_LIBRARIES}) # note, hatire supports both ftnoir and opentrack # don't remove without being sure as hell -sh 20140922 -- cgit v1.2.3 From 7579786e0007537db659b7a8cf4a78120ef4c4d5 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 13 Aug 2015 09:59:14 +0200 Subject: cmake: actually fix msvc subsystem to support xp --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1f943879..65c7c81d 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -124,6 +124,7 @@ macro(opentrack_library n dir) if(NOT foolib_STATIC) install(TARGETS ${n} RUNTIME DESTINATION . LIBRARY DESTINATION .) endif() + opentrack_compat(${n}) endmacro() function(link_with_dinput8 n) -- cgit v1.2.3 From 96841349464fa38e6d0d5f79d66d4012b6ab315c Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 13 Aug 2015 10:06:12 +0200 Subject: fsuipc: add comment --- ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp | 3 +++ 1 file changed, 3 insertions(+) mode change 100644 => 100755 ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp diff --git a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp old mode 100644 new mode 100755 index a7bb4a39..8b92055d --- a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp +++ b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp @@ -126,6 +126,9 @@ void FTNoIR_Protocol::pose(const double *headpose ) { // FSUIPC_Process(&result); if (result == FSUIPC_ERR_SENDMSG) { + // FSUIPC checks for already open connections and returns FSUIPC_ERR_OPEN in that case + // the connection scope is global for the process. this is why above code doesn't + // leak resources or have logic errors. see: http://www.purebasic.fr/english/viewtopic.php?t=31112 FSUIPC_Close(); //timeout (1 second) so assume FS closed } } -- cgit v1.2.3 From 9a0cb353b8a19b186fe3c9138e058779cd53bd33 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 13 Aug 2015 10:53:19 +0200 Subject: initial broken multi-platform process lister --- facetracknoir/process_detector.cpp | 34 +----------- facetracknoir/process_detector.h | 17 ------ opentrack-compat/process-list.hpp | 105 +++++++++++++++++++++++++++++++++++++ 3 files changed, 106 insertions(+), 50 deletions(-) mode change 100644 => 100755 facetracknoir/process_detector.cpp mode change 100644 => 100755 facetracknoir/process_detector.h create mode 100755 opentrack-compat/process-list.hpp diff --git a/facetracknoir/process_detector.cpp b/facetracknoir/process_detector.cpp old mode 100644 new mode 100755 index df38eb29..19611241 --- a/facetracknoir/process_detector.cpp +++ b/facetracknoir/process_detector.cpp @@ -8,6 +8,7 @@ #include "process_detector.h" #include "facetracknoir/ui.h" +#include "opentrack-compat/process-list.hpp" #include #include #include @@ -153,36 +154,6 @@ void process_detector::remove() ui.tableWidget->removeRow(r); } -#ifdef _WIN32 - -#include -#include - -static QStringList get_all_executable_names() -{ - QStringList ret; - HANDLE h = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); - if (h == INVALID_HANDLE_VALUE) - return ret; - - PROCESSENTRY32 e; - e.dwSize = sizeof(e); - - if (Process32First(h, &e) != TRUE) - { - CloseHandle(h); - return ret; - } - - do { - ret.append(e.szExeFile); - } while (Process32Next(h, &e) == TRUE); - - CloseHandle(h); - - return ret; -} - bool process_detector_worker::should_stop() { if (last_exe_name == "") @@ -237,6 +208,3 @@ bool process_detector_worker::config_to_start(QString& str) return false; } - - -#endif diff --git a/facetracknoir/process_detector.h b/facetracknoir/process_detector.h old mode 100644 new mode 100755 index 792a941f..f6497c90 --- a/facetracknoir/process_detector.h +++ b/facetracknoir/process_detector.h @@ -74,8 +74,6 @@ public slots: void browse(); }; -#ifdef _WIN32 - class process_detector_worker : QObject { Q_OBJECT @@ -86,18 +84,3 @@ public: bool should_stop(); }; -#else - -class process_detector_worker : QObject -{ - Q_OBJECT -public: - bool config_to_start(QString&) - { - return false; - } - bool should_stop() { return false; } - -}; - -#endif diff --git a/opentrack-compat/process-list.hpp b/opentrack-compat/process-list.hpp new file mode 100755 index 00000000..a00cbb17 --- /dev/null +++ b/opentrack-compat/process-list.hpp @@ -0,0 +1,105 @@ +#pragma once + +#include +#include + +#if defined _WIN32 + +#include +#include + +template +static QStringList get_all_executable_names() +{ + QStringList ret; + HANDLE h = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); + if (h == INVALID_HANDLE_VALUE) + return ret; + + PROCESSENTRY32 e; + e.dwSize = sizeof(e); + + if (Process32First(h, &e) != TRUE) + { + CloseHandle(h); + return ret; + } + + do { + ret.append(e.szExeFile); + } while (Process32Next(h, &e) == TRUE); + + CloseHandle(h); + + return ret; +} +#elif defined __APPLE__ +#include +#include +#include +#include + +// link to libproc +template +static QStringList get_all_executable_names() +{ + QStringList ret; + std::vector vec; + + while (true) + { + int numproc = proc_listpids(PROC_ALL_PIDS, 0, nullptr, 0); + if (numproc == -1) + { + qDebug() << "numproc failed" << errno; + break; + } + vec.resize(numproc); + int cnt = proc_listpids(PROC_ALL_PIDS, 0, &vec[0], sizeof(int) * numproc); + if (cnt <= numproc) + { + char name[2 * 2 * MAXCOMLEN + 1]; + for (int i = 0; i < cnt; i++) + { + int ret = proc_name(vec[i], name, sizeof(name)-1); + if (ret <= 0) + continue; + name[ret] = '\0'; + ret.append(name); + } + return ret; + } + } +} + +#elif defined __linux + +// link to procps +#include +#include +template +static QStringList get_all_executable_names() +{ + QStringList ret; + proc_t** procs = readproctab(PROC_FILLCOM); + if (procs == nullptr) + { + qDebug() << "readproctab" << errno; + return ret; + } + for (int i = 0; procs[i]; i++) + { + auto& proc = *procs[i]; + ret.append(proc.cmd); + } + freeproctab(procs); + return ret; +} + +#else +template +static QStringList get_all_executable_names() +{ + return QStringList(); +} +#endif -- cgit v1.2.3 From 413e6fef09190b0ddc1a110415d964f88f332655 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 13 Aug 2015 13:00:38 +0200 Subject: fixed process detector for OSX Issue: #181 --- CMakeLists.txt | 5 +++ opentrack-compat/process-list.hpp | 68 +++++++++++++++++++++++++++++++++------ 2 files changed, 64 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 65c7c81d..18e2a9cd 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -509,6 +509,11 @@ if(CMAKE_SYSTEM STREQUAL LINUX) link_libraries(rt) endif() +if(APPLE) + # for process detector + target_link_libraries(opentrack proc) +endif() + # ---- # make install diff --git a/opentrack-compat/process-list.hpp b/opentrack-compat/process-list.hpp index a00cbb17..f3388c4f 100755 --- a/opentrack-compat/process-list.hpp +++ b/opentrack-compat/process-list.hpp @@ -36,10 +36,12 @@ static QStringList get_all_executable_names() #elif defined __APPLE__ #include #include +#include +#include #include +#include #include -// link to libproc template static QStringList get_all_executable_names() { @@ -51,21 +53,69 @@ static QStringList get_all_executable_names() int numproc = proc_listpids(PROC_ALL_PIDS, 0, nullptr, 0); if (numproc == -1) { - qDebug() << "numproc failed" << errno; - break; + qDebug() << "proc_listpids numproc failed" << errno; + return ret; } vec.resize(numproc); int cnt = proc_listpids(PROC_ALL_PIDS, 0, &vec[0], sizeof(int) * numproc); + if (cnt <= numproc) { - char name[2 * 2 * MAXCOMLEN + 1]; - for (int i = 0; i < cnt; i++) + std::vector arglist; + int mib[2] { CTL_KERN, KERN_ARGMAX }; + size_t sz = sizeof(int); + int maxarg = 0; + if (sysctl(mib, 2, &maxarg, &sz, NULL, 0) == -1) + { + qDebug() << "sysctl KERN_ARGMAX" << errno; + return ret; + } + arglist.resize(maxarg); + for (int i = 0; i < numproc; i++) { - int ret = proc_name(vec[i], name, sizeof(name)-1); - if (ret <= 0) + size_t maxarg_ = (size_t)maxarg; + int mib[3] { CTL_KERN, KERN_PROCARGS2, vec[i] }; + if (sysctl(mib, 3, &arglist[0], &maxarg_, NULL, 0) == -1) + { + //qDebug() << "sysctl KERN_PROCARGS2" << vec[i] << errno; continue; - name[ret] = '\0'; - ret.append(name); + } + QStringList cmdline; + for (unsigned j = sizeof(int) + strlen(&arglist[sizeof(int)]); j < maxarg_; j++) + { + QString arg(&arglist[j]); + if (arg.size() != 0) + { + cmdline << arg; + j += arg.size(); + } + } + if (cmdline.size() > 0) + { + int idx = cmdline[0].lastIndexOf('/'); + if (idx != -1) + { + QString tmp = cmdline[0].mid(idx+1); + if (cmdline.size() > 1 && (tmp == "wine.bin" || tmp == "wine")) + { + idx = cmdline[1].lastIndexOf('/'); + if (idx == -1) + idx = cmdline[1].lastIndexOf('\\'); + if (idx != -1) + { + ret.append(cmdline[1].mid(idx+1)); + } + else + ret.append(cmdline[1]); + } + else + { + ret.append(tmp); + } + } + else + ret.append(cmdline[0]); + } } return ret; } -- cgit v1.2.3 From 1ebfd95dce50db4fa9523a26aba1f80e4ff5db52 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 14 Aug 2015 09:28:42 +0200 Subject: fix Linux game detection code Issue: #181 --- CMakeLists.txt | 15 ++++++++++----- opentrack-compat/process-list.hpp | 10 ++++++---- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 18e2a9cd..54fbfed5 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -144,7 +144,11 @@ IF(WIN32) SET(SDK_CONSOLE_DEBUG FALSE CACHE BOOL "Console window visible at runtime") ENDIF() -IF("${CMAKE_SYSTEM}" MATCHES "Linux" OR APPLE) +IF(CMAKE_SYSTEM_NAME STREQUAL "Linux") + set(LINUX TRUE) +endif() + +if(LINUX OR APPLE) set(SDK_XPLANE "" CACHE PATH "Path to X-Plane SDK") set(SDK_ENABLE_LIBEVDEV FALSE CACHE BOOL "libevdev virtual joystick protocol support") endif() @@ -505,15 +509,16 @@ endif() link_with_dinput8(opentrack) target_link_libraries(opentrack ${MY_QT_LIBS}) -if(CMAKE_SYSTEM STREQUAL LINUX) - link_libraries(rt) -endif() - if(APPLE) # for process detector target_link_libraries(opentrack proc) endif() +if(LINUX) + # for process detector + target_link_libraries(opentrack procps) +endif() + # ---- # make install diff --git a/opentrack-compat/process-list.hpp b/opentrack-compat/process-list.hpp index f3388c4f..6b139739 100755 --- a/opentrack-compat/process-list.hpp +++ b/opentrack-compat/process-list.hpp @@ -124,7 +124,6 @@ static QStringList get_all_executable_names() #elif defined __linux -// link to procps #include #include template @@ -139,10 +138,13 @@ static QStringList get_all_executable_names() } for (int i = 0; procs[i]; i++) { - auto& proc = *procs[i]; - ret.append(proc.cmd); + // note, wine sets argv[0] so no parsing like in OSX case + auto proc = procs[i]; + if (proc->cmdline && proc->cmdline[0]) + ret.append(proc->cmdline[0]); + freeproc(procs[i]); } - freeproctab(procs); + free(procs); return ret; } -- cgit v1.2.3 From e419da059974933deec16a597f5888ade27d8617 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 14 Aug 2015 09:54:12 +0200 Subject: run basename on Linux process detector --- opentrack-compat/process-list.hpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/opentrack-compat/process-list.hpp b/opentrack-compat/process-list.hpp index 6b139739..7dd206ab 100755 --- a/opentrack-compat/process-list.hpp +++ b/opentrack-compat/process-list.hpp @@ -141,7 +141,12 @@ static QStringList get_all_executable_names() // note, wine sets argv[0] so no parsing like in OSX case auto proc = procs[i]; if (proc->cmdline && proc->cmdline[0]) - ret.append(proc->cmdline[0]); + { + QString tmp(proc->cmdline[0]); + const int idx = std::max(tmp.lastIndexOf('\\'), tmp.lastIndexOf('/')); + tmp = tmp.mid(idx == -1 ? 0 : idx+1); + ret.append(tmp); + } freeproc(procs[i]); } free(procs); -- cgit v1.2.3 From 0d4899cc4ad3c77c09fa97dbab99d3e975b0cab3 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 14 Aug 2015 09:55:42 +0200 Subject: reformat --- opentrack-compat/process-list.hpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/opentrack-compat/process-list.hpp b/opentrack-compat/process-list.hpp index 7dd206ab..65735740 100755 --- a/opentrack-compat/process-list.hpp +++ b/opentrack-compat/process-list.hpp @@ -141,12 +141,12 @@ static QStringList get_all_executable_names() // note, wine sets argv[0] so no parsing like in OSX case auto proc = procs[i]; if (proc->cmdline && proc->cmdline[0]) - { - QString tmp(proc->cmdline[0]); - const int idx = std::max(tmp.lastIndexOf('\\'), tmp.lastIndexOf('/')); - tmp = tmp.mid(idx == -1 ? 0 : idx+1); + { + QString tmp(proc->cmdline[0]); + const int idx = std::max(tmp.lastIndexOf('\\'), tmp.lastIndexOf('/')); + tmp = tmp.mid(idx == -1 ? 0 : idx+1); ret.append(tmp); - } + } freeproc(procs[i]); } free(procs); -- cgit v1.2.3 From dfc157dfba05985caa963ccb22240e238133e066 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 18 Aug 2015 05:50:15 +0200 Subject: simple-mat: don't inline so much --- opentrack/simple-mat.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/opentrack/simple-mat.hpp b/opentrack/simple-mat.hpp index 49bf4feb..af23d01e 100755 --- a/opentrack/simple-mat.hpp +++ b/opentrack/simple-mat.hpp @@ -89,7 +89,7 @@ struct Mat template typename std::enable_if::value, num>::type - __inline dot(const Mat& p2) const { + dot(const Mat& p2) const { num ret = 0; constexpr int len = vector_len::value; for (int i = 0; i < len; i++) @@ -99,7 +99,7 @@ struct Mat template typename std::enable_if::value, Mat::P, is_dim3::Q>>::type - __inline cross(const Mat& p2) const + cross(const Mat& p2) const { return Mat({y() * p2.z() - p2.y() * z(), p2.x() * z() - x() * p2.z(), -- cgit v1.2.3 From a2c881e36e8522d94831f5486f7408dc58321a42 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 18 Aug 2015 05:50:32 +0200 Subject: simple-mat: __inline -> inline for C++ --- opentrack/simple-mat.hpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/opentrack/simple-mat.hpp b/opentrack/simple-mat.hpp index af23d01e..9f0911cb 100755 --- a/opentrack/simple-mat.hpp +++ b/opentrack/simple-mat.hpp @@ -52,40 +52,40 @@ struct Mat // removing them causes a compile-time error -sh 20150811 template typename std::enable_if::value, num>::type - __inline operator()(int i) const { return data[i][0]; } + inline operator()(int i) const { return data[i][0]; } template typename std::enable_if::value, num>::type - __inline operator()(int i) const { return data[0][i]; } + inline operator()(int i) const { return data[0][i]; } template typename std::enable_if::value, num&>::type - __inline operator()(int i) { return data[i][0]; } + inline operator()(int i) { return data[i][0]; } template typename std::enable_if::value, num&>::type - __inline operator()(int i) { return data[0][i]; } + inline operator()(int i) { return data[0][i]; } template typename std::enable_if::value, num>::type - __inline x() const { return operator()(0); } + inline x() const { return operator()(0); } template typename std::enable_if::value, num>::type - __inline y() const { return operator()(1); } + inline y() const { return operator()(1); } template typename std::enable_if::value, num>::type - __inline z() const { return operator()(2); } + inline z() const { return operator()(2); } template typename std::enable_if::value, num>::type - __inline w() const { return operator()(3); } + inline w() const { return operator()(3); } template typename std::enable_if::value, num&>::type - __inline x() { return operator()(0); } + inline x() { return operator()(0); } template typename std::enable_if::value, num&>::type - __inline y() { return operator()(1); } + inline y() { return operator()(1); } template typename std::enable_if::value, num&>::type - __inline z() { return operator()(2); } + inline z() { return operator()(2); } template typename std::enable_if::value, num&>::type - __inline w() { return operator()(3); } + inline w() { return operator()(3); } template typename std::enable_if::value, num>::type @@ -169,8 +169,8 @@ struct Mat return ret; } - __inline num operator()(int j, int i) const { return data[j][i]; } - __inline num& operator()(int j, int i) { return data[j][i]; } + inline num operator()(int j, int i) const { return data[j][i]; } + inline num& operator()(int j, int i) { return data[j][i]; } Mat(std::initializer_list&& list) { -- cgit v1.2.3 From e6eb0bb0bc3f766953affe28cda7f8afbaab0985 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 18 Aug 2015 05:52:26 +0200 Subject: pt, aruco: another take at focal length formula Aspect ratio is meant to be viewport's ratio, not diagonal to axis. --- ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 9 +++++---- ftnoir_tracker_pt/ftnoir_tracker_pt.cpp | 5 +++-- 2 files changed, 8 insertions(+), 6 deletions(-) mode change 100644 => 100755 ftnoir_tracker_pt/ftnoir_tracker_pt.cpp diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp index 84f20a61..fa783fe9 100755 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -154,10 +154,11 @@ void Tracker::run() static constexpr double pi = 3.1415926f; const int w = grayscale.cols, h = grayscale.rows; - const double diag = sqrt(w * w + h * h)/w, diag_fov = static_cast(s.fov) * pi / 180.; - const double fov = 2.*atan(tan(diag_fov/2.)/sqrt(1. + diag*diag)); - const float focal_length_w = .5 * w / tan(.5 * fov); - const float focal_length_h = focal_length_w; + const double diag_fov = static_cast(s.fov) * pi / 180.; + const double fov_w = 2.*atan(tan(diag_fov/2.)/sqrt(1. + h/(double)w * h/(double)w)); + const double fov_h = 2.*atan(tan(diag_fov/2.)/sqrt(1. + w/(double)h * w/(double)h)); + const float focal_length_w = .5 * w / tan(.5 * fov_w); + const float focal_length_h = .5 * h / tan(.5 * fov_h); intrinsics.at (0, 0) = focal_length_w; intrinsics.at (1, 1) = focal_length_h; diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp b/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp old mode 100644 new mode 100755 index e10cfea0..4fa70ccf --- a/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp +++ b/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp @@ -57,8 +57,9 @@ bool Tracker_PT::get_focal_length(float& ret) { static constexpr double pi = 3.14159265359; const int w = info.res_x, h = info.res_y; - const double diag = sqrt(w * w + h * h)/w, diag_fov = static_cast(s.fov) * pi / 180.; - const double fov = 2.*atan(tan(diag_fov/2.0)/sqrt(1. + diag*diag)); + const double diag = sqrt(1. + h/(double)w * h/(double)w); + const double diag_fov = static_cast(s.fov) * pi / 180.; + const double fov = 2.*atan(tan(diag_fov/2.0)/diag); ret = .5 / tan(.5 * fov); return true; } -- cgit v1.2.3 From cfed344344b996aea1e6388031dc20b1d15a25f3 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 18 Aug 2015 08:51:28 +0200 Subject: simple-mat: replace initializer_list with variadic ctor Gives us type safety rather than argument count mismatch. Also there's no more narrowing conversion issue. Replace usages. Explicitly delete initializer_list ctor. --- opentrack/simple-mat.hpp | 70 ++++++++++++++++++++++++++++++++++++++---------- opentrack/tracker.cpp | 4 +-- pose-widget/glwidget.cpp | 40 +++++++++++++-------------- 3 files changed, 76 insertions(+), 38 deletions(-) diff --git a/opentrack/simple-mat.hpp b/opentrack/simple-mat.hpp index 9f0911cb..2b4cb72e 100755 --- a/opentrack/simple-mat.hpp +++ b/opentrack/simple-mat.hpp @@ -41,13 +41,43 @@ namespace { enum { P = a == 1 ? 1 : 3 }; enum { Q = a == 1 ? 3 : 1 }; }; + + template struct assignable; + + template + struct assignable { + enum { value = true }; + }; + + template + struct assignable { + enum { value = std::is_assignable::value && assignable::value }; + }; + + template + struct is_arglist_correct + { + enum { value = h * w == sizeof...(ts) && assignable::value }; + }; } template -struct Mat +class Mat { num data[h_][w_]; + static_assert(h_ > 0 && w_ > 0, "must have positive mat dimensions"); + + struct cast + { + template + static num _(u x) { return static_cast(x); } + }; + + Mat(std::initializer_list&& xs) = delete; + +public: + // parameters w_ and h_ are rebound so that SFINAE occurs // removing them causes a compile-time error -sh 20150811 @@ -101,9 +131,9 @@ struct Mat typename std::enable_if::value, Mat::P, is_dim3::Q>>::type cross(const Mat& p2) const { - return Mat({y() * p2.z() - p2.y() * z(), - p2.x() * z() - x() * p2.z(), - x() * p2.y() - y() * p2.x()}); + return Mat(y() * p2.z() - p2.y() * z(), + p2.x() * z() - x() * p2.z(), + x() * p2.y() - y() * p2.x()); } Mat operator+(const Mat& other) const @@ -161,9 +191,9 @@ struct Mat num sum = num(0); for (int k = 0; k < h_; k++) - sum += data[j][k]*other.data[k][i]; + sum += data[j][k]*other(k, i); - ret.data[j][i] = sum; + ret(j, i) = sum; } return ret; @@ -172,19 +202,29 @@ struct Mat inline num operator()(int j, int i) const { return data[j][i]; } inline num& operator()(int j, int i) { return data[j][i]; } - Mat(std::initializer_list&& list) + template::value>> + Mat(ts const&... xs) { - auto iter = list.begin(); - for (int i = 0; i < h_; i++) - for (int j = 0; j < w_; j++) - data[i][j] = *iter++; + const std::initializer_list init = { cast::_(xs)... }; + auto iter = init.begin(); + for (int j = 0; j < h_; j++) + for (int i = 0; i < w_; i++) + data[j][i] = *iter++; + } + + template + Mat(const t* xs) + { + for (int j = 0; j < h_; j++) + for (int i = 0; i < w_; i++) + data[j][i] = num(*xs++); } Mat() { for (int j = 0; j < h_; j++) for (int i = 0; i < w_; i++) - data[j][i] = 0; + data[j][i] = num(0); } Mat(const num* mem) @@ -194,6 +234,8 @@ struct Mat data[j][i] = mem[i*h_+j]; } + Mat(num* mem) : Mat(const_cast(mem)) {} + // XXX add more operators as needed, third-party dependencies mostly // not needed merely for matrix algebra -sh 20141030 @@ -237,10 +279,10 @@ struct Mat if (std::abs(pitch_1) + std::abs(roll_1) + std::abs(yaw_1) > std::abs(pitch_2) + std::abs(roll_2) + std::abs(yaw_2)) { bool fix_neg_pitch = pitch_1 < 0; - return dmat<3, 1>({yaw_2, std::fmod(fix_neg_pitch ? -pi - pitch_1 : pitch_2, pi), roll_2}); + return dmat<3, 1>(yaw_2, std::fmod(fix_neg_pitch ? -pi - pitch_1 : pitch_2, pi), roll_2); } else - return dmat<3, 1>({yaw_1, pitch_1, roll_1}); + return dmat<3, 1>(yaw_1, pitch_1, roll_1); } // tait-bryan angles, not euler diff --git a/opentrack/tracker.cpp b/opentrack/tracker.cpp index 22a8933c..403e87c5 100755 --- a/opentrack/tracker.cpp +++ b/opentrack/tracker.cpp @@ -52,7 +52,7 @@ double Tracker::map(double pos, Mapping& axis) void Tracker::t_compensate(const rmat& rmat, const double* xyz, double* output, bool rz) { // TY is really yaw axis. need swapping accordingly. - dmat<3, 1> tvec({ xyz[2], -xyz[0], -xyz[1] }); + dmat<3, 1> tvec( xyz[2], -xyz[0], -xyz[1] ); const dmat<3, 1> ret = rmat * tvec; if (!rz) output[2] = ret(0); @@ -107,7 +107,7 @@ void Tracker::logic() }; const rmat cam = rmat::euler_to_rmat(off); rmat r = rmat::euler_to_rmat(&value[Yaw]); - dmat<3, 1> t { value(0), value(1), value(2) }; + dmat<3, 1> t(value(0), value(1), value(2)); r = cam * r; diff --git a/pose-widget/glwidget.cpp b/pose-widget/glwidget.cpp index 6c04c4e6..334c845b 100755 --- a/pose-widget/glwidget.cpp +++ b/pose-widget/glwidget.cpp @@ -45,14 +45,10 @@ void GLWidget::rotateBy(float xAngle, float yAngle, float zAngle, float x, float float c3 = cos(zAngle / 57.295781); float s3 = sin(zAngle / 57.295781); - float foo[] = { - c2*c3, -c2*s3, s2, - c1*s3+c3*s1*s2, c1*c3-s1*s2*s3, -c2*s1, - s1*s3-c1*c3*s2, c3*s1+c1*s2*s3, c1*c2, - }; - - rotation = rmat(foo); - translation = vec3({x, y, z}); + rotation = rmat(c2*c3, -c2*s3, s2, + c1*s3+c3*s1*s2, c1*c3-s1*s2*s3, -c2*s1, + s1*s3-c1*c3*s2, c3*s1+c1*s2*s3, c1*c2); + translation = vec3(x, y, z); update(); } @@ -68,8 +64,8 @@ public: const vec2& p3) { origin = p1; - v0 = vec2({ p3.x() - p1.x(), p3.y() - p1.y() }); - v1 = vec2({ p2.x() - p1.x(), p2.y() - p1.y() }); + v0 = vec2(p3.x() - p1.x(), p3.y() - p1.y()); + v1 = vec2(p2.x() - p1.x(), p2.y() - p1.y()); dot00 = v0.dot(v0); dot01 = v0.dot(v1); dot11 = v1.dot(v1); @@ -82,7 +78,7 @@ public: const num dot02 = v0.dot(v2); const num u = (dot11 * dot02 - dot01 * dot12) * invDenom; const num v = (dot00 * dot12 - dot01 * dot02) * invDenom; - uv = vec2({u, v}); + uv = vec2(u, v); return (u >= 0) && (v >= 0) && (u + v <= 1); } @@ -107,19 +103,19 @@ void GLWidget::project_quad_texture() { const int sx = width(), sy = height(); vec2 pt[4]; const vec3 corners[] = { - vec3({0., 0, 0}), - vec3({sx-1, 0, 0}), - vec3({0, sy-1, 0}), - vec3({sx-1, sy-1, 0.}) + vec3(0., 0, 0), + vec3(sx-1, 0, 0), + vec3(0, sy-1, 0), + vec3(sx-1, sy-1, 0.) }; for (int i = 0; i < 4; i++) { - pt[i] = project(vec3({corners[i].x() - sx/2, corners[i].y() - sy/2, 0})); + pt[i] = project(vec3(corners[i].x() - sx/2, corners[i].y() - sy/2, 0)); pt[i].x() += sx/2.; pt[i].y() += sy/2.; } - vec3 normal1({0, 0, 1}); + vec3 normal1(0, 0, 1); vec3 normal2; { vec3 foo[3]; @@ -137,15 +133,15 @@ void GLWidget::project_quad_texture() { vec2 p2[4]; for (int i = 0; i < 4; i++) - p2[i] = vec2({pt[i].x(), pt[i].y()}); + p2[i] = vec2(pt[i].x(), pt[i].y()); QImage texture(QSize(sx, sy), QImage::Format_RGB888); QColor bgColor = palette().color(QPalette::Current, QPalette::Window); texture.fill(bgColor); const vec2 projected[2][3] = { { p2[0], p2[1], p2[2] }, { p2[3], p2[1], p2[2] } }; const vec2 origs[2][3] = { - { vec2({0, 0}), vec2({ow-1, 0}), vec2({0, oh-1}) }, - { vec2({ow-1, oh-1}), vec2({ow-1, 0}), vec2({0, oh-1}) } + { vec2(0, 0), vec2(ow-1, 0), vec2(0, oh-1) }, + { vec2(ow-1, oh-1), vec2(ow-1, 0), vec2(0, oh-1) } }; const Triangle triangles[2] = { Triangle(projected[0][0], projected[0][1], projected[0][2]), @@ -167,7 +163,7 @@ void GLWidget::project_quad_texture() { for (int y = 0; y < sy; y++) for (int x = 0; x < sx; x++) { - vec2 pos({x, y}); + vec2 pos(x, y); for (int i = 0; i < 2; i++) { vec2 uv; if (triangles[i].barycentric_coords(pos, uv)) @@ -205,7 +201,7 @@ GLWidget::vec2 GLWidget::project(const vec3 &point) num y = h * translation.y() / 2 / -40; if (std::abs(y) > h/2) y = y > 0 ? h/2 : h/-2; - return vec2 { z * (ret.x() + x), z * (ret.y() + y) }; + return vec2(z * (ret.x() + x), z * (ret.y() + y)); } GLWidget::vec3 GLWidget::project2(const vec3 &point) -- cgit v1.2.3 From 4d0bbe2df4228e767ef1402268181fd4483b792b Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 18 Aug 2015 08:56:00 +0200 Subject: nix -Wnarrowing, not needed since previous commit --- pose-widget/glwidget.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/pose-widget/glwidget.cpp b/pose-widget/glwidget.cpp index 334c845b..74f12c27 100755 --- a/pose-widget/glwidget.cpp +++ b/pose-widget/glwidget.cpp @@ -12,10 +12,6 @@ #include #include -#ifdef __GNUC__ -#pragma GCC diagnostic ignored "-Wnarrowing" -#endif - GLWidget::GLWidget(QWidget *parent) : QWidget(parent) { Q_INIT_RESOURCE(posewidget); -- cgit v1.2.3 From c5b69772be6c56c1317d3e5d36a9e4aac9f92d62 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 21 Aug 2015 02:21:19 +0200 Subject: csv: use unsigned char in scanf --- csv/csv.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) mode change 100644 => 100755 csv/csv.cpp diff --git a/csv/csv.cpp b/csv/csv.cpp old mode 100644 new mode 100755 index e55b429c..4c754542 --- a/csv/csv.cpp +++ b/csv/csv.cpp @@ -122,14 +122,14 @@ 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(); - unsigned int tmp[8]; - unsigned int fuzz[3]; + unsigned char tmp[8]; + unsigned char fuzz[3]; if (gameLine.at(3) == QString("V160")) { qDebug() << "no table"; } else if (sscanf(id.constData(), - "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", + "%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx", fuzz + 2, fuzz + 0, tmp + 3, -- cgit v1.2.3 From bf9d97d17b6e9ecc70d8d48f52aca3ade60fc7e4 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 21 Aug 2015 02:22:03 +0200 Subject: pose-widget: use unsigned char, sprinkle const --- pose-widget/glwidget.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pose-widget/glwidget.cpp b/pose-widget/glwidget.cpp index 74f12c27..8bf169df 100755 --- a/pose-widget/glwidget.cpp +++ b/pose-widget/glwidget.cpp @@ -171,9 +171,9 @@ void GLWidget::project_quad_texture() { + uv.x() * (origs[i][2].y() - origs[i][0].y()) + uv.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]; + const unsigned char r = orig[py * orig_pitch + px * orig_depth + 2]; + const unsigned char g = orig[py * orig_pitch + px * orig_depth + 1]; + const unsigned char b = orig[py * orig_pitch + px * orig_depth + 0]; dest[y * dest_pitch + x * dest_depth + 0] = r; dest[y * dest_pitch + x * dest_depth + 1] = g; -- cgit v1.2.3 From cf8641217e85ef99df0f6093f4edadeea938cda8 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 21 Aug 2015 02:51:27 +0200 Subject: close fsuipc handle before unloading dll --- ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp index 8b92055d..486224c9 100755 --- a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp +++ b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp @@ -39,7 +39,8 @@ FTNoIR_Protocol::FTNoIR_Protocol() FTNoIR_Protocol::~FTNoIR_Protocol() { - FSUIPCLib.unload(); + FSUIPC_Close(); + FSUIPCLib.unload(); } int FTNoIR_Protocol::scale2AnalogLimits( float x, float min_x, float max_x ) { -- cgit v1.2.3 From 88f3a9e7f6bc7d54fa98a63166eaf55e4762224e Mon Sep 17 00:00:00 2001 From: Xavier Hallade Date: Fri, 21 Aug 2015 20:22:52 +0200 Subject: added a tracker that uses the RealSense SDK --- .gitignore | 3 + CMakeLists.txt | 9 ++ ftnoir_tracker_rs/README.md | 16 +++ ftnoir_tracker_rs/ftnoir_tracker_rs.cpp | 111 +++++++++++++++ ftnoir_tracker_rs/ftnoir_tracker_rs.h | 46 +++++++ ftnoir_tracker_rs/ftnoir_tracker_rs_controls.cpp | 40 ++++++ ftnoir_tracker_rs/ftnoir_tracker_rs_controls.h | 23 ++++ ftnoir_tracker_rs/ftnoir_tracker_rs_controls.ui | 67 +++++++++ ftnoir_tracker_rs/images/RS.png | Bin 0 -> 4287 bytes .../intel_rs_sdk_runtime_websetup_6.0.21.6598.exe | Bin 0 -> 780456 bytes .../rs_impl/bin/opentrack-tracker-rs-impl.exe | Bin 0 -> 83968 bytes ftnoir_tracker_rs/rs_impl/build.bat | 2 + .../rs_impl/ftnoir_tracker_rs_impl.cpp | 151 +++++++++++++++++++++ ftnoir_tracker_rs/rs_impl/ftnoir_tracker_rs_impl.h | 19 +++ ftnoir_tracker_rs/rs_impl/udp_sender.cpp | 53 ++++++++ ftnoir_tracker_rs/rs_tracker.qrc | 5 + 16 files changed, 545 insertions(+) create mode 100644 ftnoir_tracker_rs/README.md create mode 100644 ftnoir_tracker_rs/ftnoir_tracker_rs.cpp create mode 100644 ftnoir_tracker_rs/ftnoir_tracker_rs.h create mode 100644 ftnoir_tracker_rs/ftnoir_tracker_rs_controls.cpp create mode 100644 ftnoir_tracker_rs/ftnoir_tracker_rs_controls.h create mode 100644 ftnoir_tracker_rs/ftnoir_tracker_rs_controls.ui create mode 100644 ftnoir_tracker_rs/images/RS.png create mode 100644 ftnoir_tracker_rs/redist/intel_rs_sdk_runtime_websetup_6.0.21.6598.exe create mode 100644 ftnoir_tracker_rs/rs_impl/bin/opentrack-tracker-rs-impl.exe create mode 100644 ftnoir_tracker_rs/rs_impl/build.bat create mode 100644 ftnoir_tracker_rs/rs_impl/ftnoir_tracker_rs_impl.cpp create mode 100644 ftnoir_tracker_rs/rs_impl/ftnoir_tracker_rs_impl.h create mode 100644 ftnoir_tracker_rs/rs_impl/udp_sender.cpp create mode 100644 ftnoir_tracker_rs/rs_tracker.qrc diff --git a/.gitignore b/.gitignore index 7aef1021..d3ccc990 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,6 @@ # merely git cola saves there /patches/ .DS_Store +*.obj +*.exp +*.pdb \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 54fbfed5..c54b1780 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -360,6 +360,10 @@ endif() opentrack_library(opentrack-tracker-udp ftnoir_tracker_udp) opentrack_library(opentrack-tracker-freepie-udp ftnoir_tracker_freepie-udp) +if(WIN32) + opentrack_library(opentrack-tracker-rs ftnoir_tracker_rs) +endif() + if(OpenCV_FOUND) opentrack_library(opentrack-tracker-pt ftnoir_tracker_pt) target_link_libraries(opentrack-tracker-pt ${OpenCV_LIBS}) @@ -553,6 +557,11 @@ if(WIN32) install(FILES "${CMAKE_SOURCE_DIR}/bin/cleye.config" DESTINATION .) endif() +if(WIN32) + install(FILES "${CMAKE_SOURCE_DIR}/ftnoir_tracker_rs/rs_impl/bin/opentrack-tracker-rs-impl.exe" DESTINATION . ${opentrack-perms}) + install(FILES "${CMAKE_SOURCE_DIR}/ftnoir_tracker_rs/redist/intel_rs_sdk_runtime_websetup_6.0.21.6598.exe" DESTINATION ./clientfiles/ ${opentrack-perms}) +endif() + if(APPLE) install(CODE " execute_process(COMMAND /bin/sh \"${CMAKE_SOURCE_DIR}/macosx/make-app-bundle.sh\" diff --git a/ftnoir_tracker_rs/README.md b/ftnoir_tracker_rs/README.md new file mode 100644 index 00000000..5fca4392 --- /dev/null +++ b/ftnoir_tracker_rs/README.md @@ -0,0 +1,16 @@ +# Intel® RealSense™ plugin for opentrack +This is a tracker providing markerless 3D head tracking using the Intel® RealSense™ SDK and the Intel® RealSense™ front-facing cameras. + +More information on RealSense can be found on [Intel.com](http://www.intel.com/content/www/us/en/architecture-and-technology/realsense-overview.html) + +This tracker uses a separate process that gets data from the SDK. Its sources are under rs_impl and can be recompiled by calling build.bat, which depends on +Microsoft Visual C++ Compiler and the [Intel® RealSense™ SDK R4](https://software.intel.com/en-us/intel-realsense-sdk) + +# ISC License +Copyright (c) 2015, Intel Corporation + + Author: Xavier Hallade + +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. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/ftnoir_tracker_rs/ftnoir_tracker_rs.cpp b/ftnoir_tracker_rs/ftnoir_tracker_rs.cpp new file mode 100644 index 00000000..deae3bca --- /dev/null +++ b/ftnoir_tracker_rs/ftnoir_tracker_rs.cpp @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2015, Intel Corporation + * Author: Xavier Hallade + * 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. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include "ftnoir_tracker_rs.h" +#include "ftnoir_tracker_rs_controls.h" + +#include "opentrack/plugin-api.hpp" +#include + +RSTracker::RSTracker() : mPose{ 0,0,0, 0,0,0 } { + mThread.setObjectName("RSTrackerWorkerThread"); + + mRealSenseImplProcess.moveToThread(&mThread); + mSocket.moveToThread(&mThread); + + connect(&mRealSenseImplProcess, SIGNAL(finished(int)), + this, SLOT(rsImplProcessFinished(int)), Qt::QueuedConnection); + + qRegisterMetaType("QProcess::ProcessError"); + connect(&mRealSenseImplProcess, SIGNAL(error(QProcess::ProcessError)), + this, SLOT(rsImplProcessError(QProcess::ProcessError)), Qt::QueuedConnection); + + connect(&mSocket, SIGNAL(readyRead()), + this, SLOT(readPendingUdpPoseData()), Qt::DirectConnection); + + connect(&mThread, &QThread::started, + &mThread, [this]{ + mSocket.bind(QHostAddress::LocalHost, 4242, QUdpSocket::DontShareAddress); + mRealSenseImplProcess.start("clientfiles\\opentrack-tracker-rs-impl.exe", QProcess::NotOpen); + }, Qt::DirectConnection); + + connect(&mThread, &QThread::finished, + &mThread, [this]{ + mRealSenseImplProcess.kill(); + mRealSenseImplProcess.waitForFinished(); + }, Qt::DirectConnection); +} + +void RSTracker::start_tracker(QFrame*) +{ + mThread.start(); +} + +void RSTracker::readPendingUdpPoseData(){ + double pose[6]; + + while(mSocket.hasPendingDatagrams()) { + mSocket.readDatagram((char*)pose, sizeof(pose)); + QMutexLocker foo(&mMutex); + memcpy(mPose, pose, sizeof(pose)); + } +} + +void RSTracker::rsImplProcessError(QProcess::ProcessError error){ + if(error == QProcess::FailedToStart){ + QMessageBox::warning(NULL, "RealSense Tracking Error", "Couldn't start the RealSense tracking module.\nMaybe clientfiles\\opentrack-tracker-rs-impl.exe is missing.", QMessageBox::Ok); + } + else if(error == QProcess::Crashed){ + QMessageBox::warning(NULL, "RealSense Tracking Error", "The RealSense tracking module has crashed.", QMessageBox::Ok); + } +} + + +void RSTracker::rsImplProcessFinished(int exitCode){ + if(exitCode!=0){ + QMessageBox msgBox; + msgBox.setIcon(QMessageBox::Critical); + msgBox.setText("RealSense Tracking Error"); + if(exitCode==-101){ //The implementation got an invalid handle from the RealSense SDK session/modules + msgBox.setInformativeText("Couldn't initialize RealSense tracking. Please install SDK Runtime R4."); + } + else { + msgBox.setInformativeText("Status code: " + QString::number(exitCode) + ".\n\nNote that you need the latest camera drivers and the SDK runtime R4 to be installed."); + } + QPushButton* triggerSdkInstallation = msgBox.addButton("Install Runtime", QMessageBox::ActionRole); + msgBox.addButton(QMessageBox::Ok); + msgBox.exec(); + + if(msgBox.clickedButton() == triggerSdkInstallation){ + bool pStarted = QProcess::startDetached("clientfiles\\intel_rs_sdk_runtime_websetup_6.0.21.6598.exe --finstall=core,face3d --fnone=all"); + if(!pStarted){ + QMessageBox::warning(0, "Intel® RealSenseTM Runtime Installation", "Installation process failed to start.", QMessageBox::Ok); + } + } + } +} + +void RSTracker::data(double *data) +{ + QMutexLocker foo(&mMutex); + memcpy(data, mPose, sizeof(mPose)); +} + +RSTracker::~RSTracker() { + mThread.quit(); + mThread.wait(); +} + +QString RSTrackerMetaData::name() { + return QString("RealSense 3D Face Tracking"); +} + +QIcon RSTrackerMetaData::icon() { + return QIcon(":/images/RS.png"); +} + +OPENTRACK_DECLARE_TRACKER(RSTracker, RSTrackerControls, RSTrackerMetaData) diff --git a/ftnoir_tracker_rs/ftnoir_tracker_rs.h b/ftnoir_tracker_rs/ftnoir_tracker_rs.h new file mode 100644 index 00000000..7cda7370 --- /dev/null +++ b/ftnoir_tracker_rs/ftnoir_tracker_rs.h @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2015, Intel Corporation + * Author: Xavier Hallade + * 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. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#pragma once + +#include "ui_ftnoir_tracker_rs_controls.h" +#include "opentrack/plugin-api.hpp" +#include +#include +#include +#include + +class RSTracker : protected QObject, public ITracker +{ + Q_OBJECT + +public: + RSTracker(); + ~RSTracker(); + void start_tracker(QFrame *) override; + void data(double *data) override; + +private: + QMutex mMutex; + QThread mThread; + QProcess mRealSenseImplProcess; + QUdpSocket mSocket; + double mPose[6]; + +private slots: + void rsImplProcessError(QProcess::ProcessError); + void rsImplProcessFinished(int); + void readPendingUdpPoseData(); + +}; + +class RSTrackerMetaData : public Metadata +{ +public: + QString name(); + QIcon icon(); +}; diff --git a/ftnoir_tracker_rs/ftnoir_tracker_rs_controls.cpp b/ftnoir_tracker_rs/ftnoir_tracker_rs_controls.cpp new file mode 100644 index 00000000..e5187bd1 --- /dev/null +++ b/ftnoir_tracker_rs/ftnoir_tracker_rs_controls.cpp @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2015, Intel Corporation + * Author: Xavier Hallade + * 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. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include "ftnoir_tracker_rs_controls.h" + +#include +#include + +RSTrackerControls::RSTrackerControls() +{ + ui.setupUi(this); + connect(ui.triggerSDKInstallButton, SIGNAL(clicked(bool)), this, SLOT(doInstallRSRuntime())); + connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); + connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); +} + +void RSTrackerControls::doInstallRSRuntime() +{ + bool processStarted = QProcess::startDetached("clientfiles\\intel_rs_sdk_runtime_websetup_6.0.21.6598.exe --finstall=core,face3d --fnone=all"); + if(processStarted){ + this->close(); + } + else{ + QMessageBox::warning(0, "Intel® RealSenseTM Runtime Installation", "Installation process failed to start.", QMessageBox::Ok); + } +} + +void RSTrackerControls::doOK() +{ + this->close(); +} + +void RSTrackerControls::doCancel() +{ + this->close(); +} diff --git a/ftnoir_tracker_rs/ftnoir_tracker_rs_controls.h b/ftnoir_tracker_rs/ftnoir_tracker_rs_controls.h new file mode 100644 index 00000000..010dac99 --- /dev/null +++ b/ftnoir_tracker_rs/ftnoir_tracker_rs_controls.h @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2015, Intel Corporation + * Author: Xavier Hallade + * 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. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include "ftnoir_tracker_rs.h" + +class RSTrackerControls : public ITrackerDialog +{ + Q_OBJECT +public: + RSTrackerControls(); + void register_tracker(ITracker *) {} + void unregister_tracker() {} +private: + Ui::UIRSControls ui; + private slots: + void doOK(); + void doCancel(); + void doInstallRSRuntime(); +}; diff --git a/ftnoir_tracker_rs/ftnoir_tracker_rs_controls.ui b/ftnoir_tracker_rs/ftnoir_tracker_rs_controls.ui new file mode 100644 index 00000000..834803d1 --- /dev/null +++ b/ftnoir_tracker_rs/ftnoir_tracker_rs_controls.ui @@ -0,0 +1,67 @@ + + + UIRSControls + + + Qt::NonModal + + + + 0 + 0 + 378 + 193 + + + + RealSense 3D Tracker settings + + + + images/RS.pngimages/RS.png + + + Qt::LeftToRight + + + false + + + + + + There is no configuration available at the moment. + +The application will activate your camera for face tracking by the +Intel® RealSense™ SDK. By design, the application has no direct access +to any camera images. + +In order to use this tracker, you need a PC equipped with +an Intel® RealSense™ R200 camera and the RealSense™ SDK R4 runtime. + + + + + + + Install SDK Runtime R4 + + + + + + + QDialogButtonBox::Ok + + + + + + + + + startEngineClicked() + stopEngineClicked() + cameraSettingsClicked() + + diff --git a/ftnoir_tracker_rs/images/RS.png b/ftnoir_tracker_rs/images/RS.png new file mode 100644 index 00000000..bc1dfc11 Binary files /dev/null and b/ftnoir_tracker_rs/images/RS.png differ diff --git a/ftnoir_tracker_rs/redist/intel_rs_sdk_runtime_websetup_6.0.21.6598.exe b/ftnoir_tracker_rs/redist/intel_rs_sdk_runtime_websetup_6.0.21.6598.exe new file mode 100644 index 00000000..34ecc9df Binary files /dev/null and b/ftnoir_tracker_rs/redist/intel_rs_sdk_runtime_websetup_6.0.21.6598.exe differ diff --git a/ftnoir_tracker_rs/rs_impl/bin/opentrack-tracker-rs-impl.exe b/ftnoir_tracker_rs/rs_impl/bin/opentrack-tracker-rs-impl.exe new file mode 100644 index 00000000..1e2a57f1 Binary files /dev/null and b/ftnoir_tracker_rs/rs_impl/bin/opentrack-tracker-rs-impl.exe differ diff --git a/ftnoir_tracker_rs/rs_impl/build.bat b/ftnoir_tracker_rs/rs_impl/build.bat new file mode 100644 index 00000000..15206431 --- /dev/null +++ b/ftnoir_tracker_rs/rs_impl/build.bat @@ -0,0 +1,2 @@ +cd "%VS120COMNTOOLS%\..\..\VC" +vcvarsall x64 && cd %~dp0 && CL /nologo /Ox /DUNICODE /D_UNICODE /MT /I"%RSSDK_DIR%\opensource\include" ftnoir_tracker_rs_impl.cpp udp_sender.cpp "%RSSDK_DIR%\opensource\src\libpxc\libpxc.cpp" /link ADVAPI32.LIB Ws2_32.lib /SUBSYSTEM:CONSOLE /OUT:bin\opentrack-tracker-rs-impl.exe \ No newline at end of file diff --git a/ftnoir_tracker_rs/rs_impl/ftnoir_tracker_rs_impl.cpp b/ftnoir_tracker_rs/rs_impl/ftnoir_tracker_rs_impl.cpp new file mode 100644 index 00000000..c1ba5c75 --- /dev/null +++ b/ftnoir_tracker_rs/rs_impl/ftnoir_tracker_rs_impl.cpp @@ -0,0 +1,151 @@ +/* + * Copyright (c) 2015, Intel Corporation + * Author: Xavier Hallade + * 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. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include "ftnoir_tracker_rs_impl.h" +#include +#include + +PXCSenseManager* g_senseManager = NULL; +PXCFaceData* g_faceData = NULL; + +pxcStatus rs_tracker_set_configuration(PXCFaceModule *faceModule){ + pxcStatus retStatus; + PXCFaceConfiguration *faceConfig = NULL; + + if (faceModule == NULL) + return PXC_STATUS_HANDLE_INVALID; + + faceConfig = faceModule->CreateActiveConfiguration(); + if (faceConfig == NULL){ + return PXC_STATUS_HANDLE_INVALID; + } + + faceConfig->pose.isEnabled = true; + faceConfig->pose.maxTrackedFaces = 1; + faceConfig->pose.smoothingLevel = PXCFaceConfiguration::SmoothingLevelType::SMOOTHING_DISABLED; + faceConfig->strategy = PXCFaceConfiguration::STRATEGY_CLOSEST_TO_FARTHEST; + faceConfig->detection.isEnabled = false; + faceConfig->landmarks.isEnabled = false; + faceConfig->DisableAllAlerts(); + faceConfig->SetTrackingMode(PXCFaceConfiguration::FACE_MODE_COLOR_PLUS_DEPTH); + + retStatus = faceConfig->ApplyChanges(); + if (retStatus != PXC_STATUS_NO_ERROR){ + faceConfig->Release(); + return retStatus; + } + + faceConfig->Release(); + return PXC_STATUS_NO_ERROR; +} + +int rs_tracker_impl_start(){ + pxcStatus retStatus; + PXCFaceModule *faceModule = NULL; + + g_senseManager = PXCSenseManager::CreateInstance(); + if (g_senseManager == NULL){ + rs_tracker_impl_end(); + return PXC_STATUS_HANDLE_INVALID; + } + + retStatus = g_senseManager->EnableFace(); + if (retStatus != PXC_STATUS_NO_ERROR){ + rs_tracker_impl_end(); + return retStatus; + } + + faceModule = g_senseManager->QueryFace(); + if (faceModule == NULL){ + rs_tracker_impl_end(); + return PXC_STATUS_HANDLE_INVALID; + } + + retStatus = rs_tracker_set_configuration(faceModule); + if (retStatus != PXC_STATUS_NO_ERROR){ + rs_tracker_impl_end(); + return PXC_STATUS_HANDLE_INVALID; + } + + retStatus = g_senseManager->Init(); + if (retStatus != PXC_STATUS_NO_ERROR){ + rs_tracker_impl_end(); + return retStatus; + } + + g_faceData = faceModule->CreateOutput(); + if (g_faceData == NULL){ + rs_tracker_impl_end(); + return PXC_STATUS_HANDLE_INVALID; + } + + return PXC_STATUS_NO_ERROR; +} + +int rs_tracker_impl_update_pose(double *data){ + pxcStatus retStatus; + PXCFaceData::PoseEulerAngles angles; + PXCFaceData::HeadPosition headPosition; + PXCFaceData::Face *face = NULL; + PXCFaceData::PoseData *pose = NULL; + bool poseAnglesAvailable = false; + bool headPositionAvailable = false; + + if (g_senseManager != NULL && g_faceData != NULL + && (retStatus = g_senseManager->AcquireFrame(true, 16)) == PXC_STATUS_NO_ERROR){ + + retStatus = g_faceData->Update(); + if (retStatus != PXC_STATUS_NO_ERROR){ + rs_tracker_impl_end(); + return retStatus; + } + + pxcI32 numberOfDetectedFaces = g_faceData->QueryNumberOfDetectedFaces(); + for (pxcI32 i = 0; i < numberOfDetectedFaces; ++i) { + face = g_faceData->QueryFaceByIndex(0); + if (face == NULL) continue; + + pose = face->QueryPose(); + if (pose == NULL) continue; + + poseAnglesAvailable = pose->QueryPoseAngles(&angles); + if (!poseAnglesAvailable) continue; + + headPositionAvailable = pose->QueryHeadPosition(&headPosition); + if (!headPositionAvailable) continue; + + //TODO: use pxcI32 pose->QueryConfidence(); ? for data[6] or to filter here ? + + //x, y, z: cm + data[0] = headPosition.headCenter.x / 10.; + data[1] = headPosition.headCenter.y / 10.; + data[2] = headPosition.headCenter.z / 10.; + + //yaw, pitch, roll: degrees + data[3] = -angles.yaw; + data[4] = angles.pitch; + data[5] = -angles.roll; + } + + g_senseManager->ReleaseFrame(); + } + + return retStatus; +} + +int rs_tracker_impl_end(){ + if (g_faceData != NULL){ + g_faceData->Release(); + g_faceData = NULL; + } + + if (g_senseManager != NULL){ + g_senseManager->Release(); + g_senseManager = NULL; + } + return PXC_STATUS_NO_ERROR; +} diff --git a/ftnoir_tracker_rs/rs_impl/ftnoir_tracker_rs_impl.h b/ftnoir_tracker_rs/rs_impl/ftnoir_tracker_rs_impl.h new file mode 100644 index 00000000..0e4073d0 --- /dev/null +++ b/ftnoir_tracker_rs/rs_impl/ftnoir_tracker_rs_impl.h @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2015, Intel Corporation + * Author: Xavier Hallade + * 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. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#pragma once +#ifdef EXPORT_RS_IMPL +#define RSTRACKERIMPL_VISIBILITY __declspec( dllexport ) +#else +#define RSTRACKERIMPL_VISIBILITY +#endif + +extern "C" { + RSTRACKERIMPL_VISIBILITY int rs_tracker_impl_start(); + RSTRACKERIMPL_VISIBILITY int rs_tracker_impl_update_pose(double *pose); + RSTRACKERIMPL_VISIBILITY int rs_tracker_impl_end(); +} diff --git a/ftnoir_tracker_rs/rs_impl/udp_sender.cpp b/ftnoir_tracker_rs/rs_impl/udp_sender.cpp new file mode 100644 index 00000000..095edd8f --- /dev/null +++ b/ftnoir_tracker_rs/rs_impl/udp_sender.cpp @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2015, Intel Corporation + * Author: Xavier Hallade + * 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. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include "ftnoir_tracker_rs_impl.h" +#include +#include +#include +#include + +#define UDP_PORT 4242 + +int main(){ + double pose[6] = { 0., 0., 0., 0., 0., 0. }; + struct sockaddr_in socketInfo; + SOCKET s = 0; + WSADATA wsa; + + int retStatus = rs_tracker_impl_start(); + if (retStatus != 0){ + exit(retStatus); + } + + if (WSAStartup(MAKEWORD(2, 2), &wsa) != 0) //init winsocketapi + exit(EXIT_FAILURE); + + memset(&socketInfo, 0, sizeof(socketInfo)); + socketInfo.sin_family = AF_INET; + socketInfo.sin_port = htons(UDP_PORT); + InetPton(AF_INET, L"127.0.0.1", &socketInfo.sin_addr.S_un.S_addr); + + if ((s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == SOCKET_ERROR) //create UDP socket + exit(EXIT_FAILURE); + + for(;;) { + retStatus = rs_tracker_impl_update_pose(pose); + if(retStatus == 0){ //no error + if (sendto(s, (char*)&pose, sizeof(pose), 0, (struct sockaddr *) &socketInfo, sizeof(socketInfo)) == SOCKET_ERROR) //send new data + exit(EXIT_FAILURE); + } + + if(retStatus != 0 && retStatus != -303)// -303=timeout and 0 are ok, else we've got to stop. + break; + } + + closesocket(s); + WSACleanup(); + + return retStatus; +} diff --git a/ftnoir_tracker_rs/rs_tracker.qrc b/ftnoir_tracker_rs/rs_tracker.qrc new file mode 100644 index 00000000..ccdda669 --- /dev/null +++ b/ftnoir_tracker_rs/rs_tracker.qrc @@ -0,0 +1,5 @@ + + + images/RS.png + + -- cgit v1.2.3 From a464a6cb1e3fee602f273706172b3d71d02cffbe Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 21 Aug 2015 21:03:26 +0200 Subject: document new tracker + credit for author --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 4abcdf07..0600f4a6 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,7 @@ Not to be confused with railway planning software <> - Tablet-like mouse output (Windows) - FlightGear Nasal script - FSUIPC for Microsoft Flight Simulator 2002/2004 (Windows) +- Intel RealSense 3D cameras (Windows) *** @@ -60,6 +61,7 @@ Don't be afraid to submit an issue/feature request if need arises. - Ryan Spicer (OSX tester, contributor) - Patrick Ruoff (PT tracker) - Ulf Schreiber (PT tracker) +- Xavier Hallade (RealSense tracker) - furax49 (hatire tracker) - Andrzej Czarnowski (quality assurance) - uglyDwarf (high CON) -- cgit v1.2.3 From 7c481f956431886cddd1eba7b4f1271d88e14b71 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 21 Aug 2015 21:39:59 +0200 Subject: oops, move to correct block --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0600f4a6..7276681e 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,7 @@ Not to be confused with railway planning software <> - Joystick analog axes (Windows, Linux) - Windows Phone [tracker](http://www.windowsphone.com/en-us/store/app/opentrack-head-tracking/1c604f32-6d68-40ef-aa44-3163e30f547f) over opentrack UDP protocol - Arduino with custom firmware +- Intel RealSense 3D cameras (Windows) # Output @@ -40,7 +41,6 @@ Not to be confused with railway planning software <> - Tablet-like mouse output (Windows) - FlightGear Nasal script - FSUIPC for Microsoft Flight Simulator 2002/2004 (Windows) -- Intel RealSense 3D cameras (Windows) *** -- cgit v1.2.3 From 12973a386f313ca363d0b37ea3a6c42922894a19 Mon Sep 17 00:00:00 2001 From: Xavier Hallade Date: Fri, 21 Aug 2015 21:44:24 +0200 Subject: fixed path to opentrack-tracker-rs-impl.exe (RealSense tracker) --- ftnoir_tracker_rs/ftnoir_tracker_rs.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ftnoir_tracker_rs/ftnoir_tracker_rs.cpp b/ftnoir_tracker_rs/ftnoir_tracker_rs.cpp index deae3bca..8fa46df2 100644 --- a/ftnoir_tracker_rs/ftnoir_tracker_rs.cpp +++ b/ftnoir_tracker_rs/ftnoir_tracker_rs.cpp @@ -30,7 +30,7 @@ RSTracker::RSTracker() : mPose{ 0,0,0, 0,0,0 } { connect(&mThread, &QThread::started, &mThread, [this]{ mSocket.bind(QHostAddress::LocalHost, 4242, QUdpSocket::DontShareAddress); - mRealSenseImplProcess.start("clientfiles\\opentrack-tracker-rs-impl.exe", QProcess::NotOpen); + mRealSenseImplProcess.start("opentrack-tracker-rs-impl.exe", QProcess::NotOpen); }, Qt::DirectConnection); connect(&mThread, &QThread::finished, @@ -57,7 +57,7 @@ void RSTracker::readPendingUdpPoseData(){ void RSTracker::rsImplProcessError(QProcess::ProcessError error){ if(error == QProcess::FailedToStart){ - QMessageBox::warning(NULL, "RealSense Tracking Error", "Couldn't start the RealSense tracking module.\nMaybe clientfiles\\opentrack-tracker-rs-impl.exe is missing.", QMessageBox::Ok); + QMessageBox::warning(NULL, "RealSense Tracking Error", "Couldn't start the RealSense tracking module.\nMaybe opentrack-tracker-rs-impl.exe is missing.", QMessageBox::Ok); } else if(error == QProcess::Crashed){ QMessageBox::warning(NULL, "RealSense Tracking Error", "The RealSense tracking module has crashed.", QMessageBox::Ok); -- cgit v1.2.3 From 6296a266c6c4c468c9d35117b31651c065b62dad Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 22 Aug 2015 10:11:17 +0200 Subject: nix header --- facetracknoir/ui.cpp | 1 - 1 file changed, 1 deletion(-) mode change 100644 => 100755 facetracknoir/ui.cpp diff --git a/facetracknoir/ui.cpp b/facetracknoir/ui.cpp old mode 100644 new mode 100755 index 698d4a1a..7d8ae302 --- a/facetracknoir/ui.cpp +++ b/facetracknoir/ui.cpp @@ -34,7 +34,6 @@ #include "opentrack/tracker.h" #include "opentrack/options.hpp" #include -#include #ifndef _WIN32 # include -- cgit v1.2.3 From e02d939c269d0a1b0d387b74f1d767e7c65c14b8 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 22 Aug 2015 11:04:33 +0200 Subject: close dialogs on switch to new module Don't preemptively close dialog on tracking stop, that's annoying for users. --- facetracknoir/ui.cpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/facetracknoir/ui.cpp b/facetracknoir/ui.cpp index 7d8ae302..3f87ca2f 100755 --- a/facetracknoir/ui.cpp +++ b/facetracknoir/ui.cpp @@ -80,6 +80,18 @@ MainWindow::MainWindow() : tie_setting(s.protocol_dll, ui.iconcomboProtocol); tie_setting(s.filter_dll, ui.iconcomboFilter); + connect(ui.iconcomboTrackerSource, + static_cast(&QComboBox::currentIndexChanged), + [&](int) -> void { if (pTrackerDialog) pTrackerDialog = nullptr; }); + + connect(ui.iconcomboProtocol, + static_cast(&QComboBox::currentIndexChanged), + [&](int) -> void { if (pProtocolDialog) pProtocolDialog = nullptr; }); + + connect(ui.iconcomboFilter, + static_cast(&QComboBox::currentIndexChanged), + [&](int) -> void { if (pFilterDialog) pFilterDialog = nullptr; }); + connect(ui.btnStartTracker, SIGNAL(clicked()), this, SLOT(startTracker())); connect(ui.btnStopTracker, SIGNAL(clicked()), this, SLOT(stopTracker())); connect(ui.iconcomboProfile, SIGNAL(currentIndexChanged(int)), this, SLOT(profileSelected(int))); @@ -270,22 +282,13 @@ void MainWindow::stopTracker( ) { ui.pose_display->rotateBy(0, 0, 0, 0, 0, 0); if (pTrackerDialog) - { pTrackerDialog->unregister_tracker(); - pTrackerDialog = nullptr; - } if (pProtocolDialog) - { pProtocolDialog->unregister_protocol(); - pProtocolDialog = nullptr; - } if (pFilterDialog) - { pFilterDialog->unregister_filter(); - pFilterDialog = nullptr; - } work = nullptr; libs = SelectedLibraries(); -- cgit v1.2.3 From 05203f39e6314c09f65d69c028b9f9d864de3f7b Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 22 Aug 2015 12:10:10 +0200 Subject: pt: show extracted points' areas and success count --- ftnoir_tracker_pt/point_extractor.cpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/ftnoir_tracker_pt/point_extractor.cpp b/ftnoir_tracker_pt/point_extractor.cpp index 7174d719..65ac653a 100644 --- a/ftnoir_tracker_pt/point_extractor.cpp +++ b/ftnoir_tracker_pt/point_extractor.cpp @@ -64,6 +64,18 @@ std::vector PointExtractor::extract_points(cv::Mat& frame) ret *= 1./norm; return ret; } + + double effective_area() const + { + double norm = 0, ret = 0; + for (unsigned i = 0; i < areas.size(); i++) + { + const double w = confids[i]; + norm += w; + ret += w * areas[i]; + } + return ret/norm; + } }; struct simple_blob @@ -82,7 +94,7 @@ std::vector PointExtractor::extract_points(cv::Mat& frame) cv::Vec2d tmp = pos - other.pos; return tmp.dot(tmp) < radius_2; } - static std::vector merge(std::vector& blobs) + static std::vector merge(cv::Mat& frame, std::vector& blobs) { #ifdef DEBUG_EXTRACTION static Timer t; @@ -117,6 +129,11 @@ std::vector PointExtractor::extract_points(cv::Mat& frame) } if (b_.pos.size() >= successes) ret.push_back(b_); + + char buf[64]; + sprintf(buf, "%d%% %d px", b_.pos.size()*100/successes, (int)(2.*sqrt(b_.effective_area()) / sqrt(3.14))); + const auto pos = b_.effective_pos(); + cv::putText(frame, buf, cv::Point(pos[0]+30, pos[1]+20), cv::FONT_HERSHEY_DUPLEX, 1, cv::Scalar(0, 0, 255), 1); } #ifdef DEBUG_EXTRACTION if (debug) @@ -204,7 +221,7 @@ std::vector PointExtractor::extract_points(cv::Mat& frame) // clear old points points.clear(); - for (auto& b : simple_blob::merge(blobs)) + for (auto& b : simple_blob::merge(frame, blobs)) { auto pos = b.effective_pos(); cv::Vec2f p((pos[0] - W/2)/W, -(pos[1] - H/2)/W); -- cgit v1.2.3 From 4ab33fdfbb23fdfed5327d402989fd53d79f5380 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 22 Aug 2015 19:02:25 +0200 Subject: main, ui: store config files in a predefined directory Settings files are now stored in Documents/opentrack-version. The transition path is to copy all .ini files into that directory, accessible through the "Profile" menu dropdown. Issue: #179 --- facetracknoir/main.ui | 1900 ++++++++++---------- facetracknoir/new_config.ui | 45 + facetracknoir/new_file_dialog.h | 48 + facetracknoir/ui.cpp | 172 +- facetracknoir/ui.h | 15 +- .../ftnoir_tracker_hat_settings.cpp | 21 +- opentrack/options.hpp | 53 +- 7 files changed, 1207 insertions(+), 1047 deletions(-) create mode 100644 facetracknoir/new_config.ui create mode 100644 facetracknoir/new_file_dialog.h mode change 100755 => 100644 facetracknoir/ui.cpp diff --git a/facetracknoir/main.ui b/facetracknoir/main.ui index 2328be40..f240a510 100644 --- a/facetracknoir/main.ui +++ b/facetracknoir/main.ui @@ -7,8 +7,8 @@ 0 0 - 708 - 504 + 707 + 492 @@ -53,13 +53,7 @@ 0 - - - 0 - - - 0 - + 0 @@ -72,728 +66,755 @@ 0 + + 0 + - - - - 0 - 0 - - - - - 480 - 360 - - - - - 480 - 360 - - - - - - 0 - 0 - 480 - 360 - - - - - 0 - 0 - - - - - - 0 - 0 - 480 - 360 - - - - - 0 - 0 - - - - - 480 - 360 - - - - - 480 - 360 - - - - - - - - - - - + QFrame::NoFrame - - 0 - - + - 12 + 0 - 6 + 0 - 12 + 0 - 8 + 0 - 4 + 0 - + - + 0 0 - + - 80 - 90 + 480 + 360 - - - - - - - 0 - 0 - - - - Raw tracker data + + + 480 + 360 + - - - 0 - - - 0 + + + + 0 + 0 + 480 + 360 + - - 0 - - - 0 + + + 0 + 0 + - - 3 - - - 2 - - - - - true - - - - 0 - 0 - - - - QFrame::NoFrame - - - QFrame::Plain - - - 1 - - - true - - - 4 - - - QLCDNumber::Outline - - - - - - - - 0 - 0 - - - - QFrame::Raised - - - yaw - - - - - - - - 0 - 0 - - - - QFrame::Raised - - - roll - - - - - - - true - - - - 0 - 0 - - - - false - - - QFrame::Raised - - - TZ - - - - - - - - 0 - 0 - - - - QFrame::Raised - - - pitch - - - - - - - true - - - - 0 - 0 - - - - QFrame::NoFrame - - - QFrame::Plain - - - 1 - - - true - - - 4 - - - QLCDNumber::Outline - - - - - - - true - - - - 0 - 0 - - - - QFrame::NoFrame - - - QFrame::Plain - - - 1 - - - true - - - 4 - - - QLCDNumber::Outline - - - - - - - true - - - - 0 - 0 - - - - QFrame::NoFrame - - - QFrame::Plain - - - 1 - - - true - - - 4 - - - QLCDNumber::Outline - - - - - - - true - - - - 0 - 0 - - - - QFrame::NoFrame - - - QFrame::Plain - - - 1 - - - true - - - 4 - - - QLCDNumber::Outline - - - - - - - - 0 - 0 - - - - QFrame::Raised - - - TX - - - - - - - true - - - - 0 - 0 - - - - QFrame::NoFrame - - - QFrame::Plain - - - 1 - - - true - - - 4 - - - QLCDNumber::Outline - - - - - - - true - - - - 0 - 0 - - - - false - - - QFrame::Raised - - - TY - - - - + + + + 0 + 0 + 480 + 360 + + + + + 0 + 0 + + + + + 480 + 360 + + + + + 480 + 360 + + + + + + + - - - - 0 - 0 - + + + QFrame::NoFrame - - Game data + + 0 - + + + 12 + - 0 + 6 - 0 - - - 0 - - - 0 - - - 3 - - - 2 - - - - - true - - - - 0 - 0 - - - - false - - - QFrame::Raised - - - TY - - - - - - - - 0 - 0 - - - - QFrame::Raised - - - pitch - - - - - - - true - - - - 0 - 0 - - - - QFrame::NoFrame - - - true - - - 4 - - - QLCDNumber::Flat - - - - - - - - 0 - 0 - - - - QFrame::Raised - - - yaw - - - - - - - - 0 - 0 - - - - QFrame::Raised - - - roll - - - - - - - true - - - - 0 - 0 - - - - false - - - QFrame::Raised - - - TZ - - - - - - - true - - - - 0 - 0 - - - - QFrame::NoFrame - - - true - - - 4 - - - QLCDNumber::Flat - - - - - - - true - - - - 0 - 0 - - - - QFrame::NoFrame - - - true - - - 4 - - - QLCDNumber::Flat - - - - - - - true - - - - 0 - 0 - - - - QFrame::NoFrame - - - true - - - 4 - - - QLCDNumber::Flat - - - - - - - true - + 12 + + + 8 + + + 4 + + + - + 0 0 - - QFrame::NoFrame - - - true - - - 4 - - - QLCDNumber::Flat + + + 80 + 90 + - - + + - + 0 0 - - QFrame::Raised - - - TX - + + Raw tracker data + + + + 0 + + + 0 + + + 0 + + + 0 + + + 3 + + + 2 + + + + + true + + + + 0 + 0 + + + + QFrame::NoFrame + + + QFrame::Plain + + + 1 + + + true + + + 4 + + + QLCDNumber::Outline + + + + + + + + 0 + 0 + + + + QFrame::Raised + + + yaw + + + + + + + + 0 + 0 + + + + QFrame::Raised + + + roll + + + + + + + true + + + + 0 + 0 + + + + false + + + QFrame::Raised + + + TZ + + + + + + + + 0 + 0 + + + + QFrame::Raised + + + pitch + + + + + + + true + + + + 0 + 0 + + + + QFrame::NoFrame + + + QFrame::Plain + + + 1 + + + true + + + 4 + + + QLCDNumber::Outline + + + + + + + true + + + + 0 + 0 + + + + QFrame::NoFrame + + + QFrame::Plain + + + 1 + + + true + + + 4 + + + QLCDNumber::Outline + + + + + + + true + + + + 0 + 0 + + + + QFrame::NoFrame + + + QFrame::Plain + + + 1 + + + true + + + 4 + + + QLCDNumber::Outline + + + + + + + true + + + + 0 + 0 + + + + QFrame::NoFrame + + + QFrame::Plain + + + 1 + + + true + + + 4 + + + QLCDNumber::Outline + + + + + + + + 0 + 0 + + + + QFrame::Raised + + + TX + + + + + + + true + + + + 0 + 0 + + + + QFrame::NoFrame + + + QFrame::Plain + + + 1 + + + true + + + 4 + + + QLCDNumber::Outline + + + + + + + true + + + + 0 + 0 + + + + false + + + QFrame::Raised + + + TY + + + + - - - - true - + + - + 0 0 - - QFrame::NoFrame - - - true - - - 4 - - - QLCDNumber::Flat - + + Game data + + + + 0 + + + 0 + + + 0 + + + 0 + + + 3 + + + 2 + + + + + true + + + + 0 + 0 + + + + false + + + QFrame::Raised + + + TY + + + + + + + + 0 + 0 + + + + QFrame::Raised + + + pitch + + + + + + + true + + + + 0 + 0 + + + + QFrame::NoFrame + + + true + + + 4 + + + QLCDNumber::Flat + + + + + + + + 0 + 0 + + + + QFrame::Raised + + + yaw + + + + + + + + 0 + 0 + + + + QFrame::Raised + + + roll + + + + + + + true + + + + 0 + 0 + + + + false + + + QFrame::Raised + + + TZ + + + + + + + true + + + + 0 + 0 + + + + QFrame::NoFrame + + + true + + + 4 + + + QLCDNumber::Flat + + + + + + + true + + + + 0 + 0 + + + + QFrame::NoFrame + + + true + + + 4 + + + QLCDNumber::Flat + + + + + + + true + + + + 0 + 0 + + + + QFrame::NoFrame + + + true + + + 4 + + + QLCDNumber::Flat + + + + + + + true + + + + 0 + 0 + + + + QFrame::NoFrame + + + true + + + 4 + + + QLCDNumber::Flat + + + + + + + + 0 + 0 + + + + QFrame::Raised + + + TX + + + + + + + true + + + + 0 + 0 + + + + QFrame::NoFrame + + + true + + + 4 + + + QLCDNumber::Flat + + + + @@ -802,112 +823,142 @@ - + + + + 0 + 0 + + + + 4 + - 0 + 8 + + + 10 0 - 6 + 4 0 - - + + + + + 4 + 0 + + - Controls + Settings true - + + + 3 + 4 - 12 + 2 - 4 + 0 - 12 + 6 - - - - false - - - - 0 - 0 - - - - Stop - - - - - + + - + 0 - 0 + 2 - - Start - + + + 0 + + + 0 + + + 2 + + + 2 + + + + + true + + + + 0 + 0 + + + + Profile + + + QToolButton::InstantPopup + + + Qt::ToolButtonTextBesideIcon + + + true + + + Qt::DownArrow + + + + + + + + 0 + 0 + + + + 10 + + + + - - - - - - - Settings - - - true - - - - 4 - - - 0 - - - 4 - - - 4 - - - 2 - - - + + - + 0 - 0 + 3 - Options + Mapping - :/images/tools.png:/images/tools.png + :/images/curves.png:/images/curves.png @@ -917,20 +968,20 @@ - - + + - + 0 - 0 + 3 - Mapping + Options - :/images/curves.png:/images/curves.png + :/images/tools.png:/images/tools.png @@ -943,230 +994,225 @@ - - + + + + + 3 + 0 + + - Filter + Controls true - + + + 8 + - 4 + 0 - 0 + 8 - 4 + 0 - 4 - - - 3 - - - 2 + 9 - - - - - - - true + + + + + 0 + 0 + - ... - - - false + Start - - - - - - - Tracker - - - true - - - - 4 - - - 0 - - - 4 - - - 4 - - - 3 - - - 2 - - - - - - + + - true - - - ... - - false - - - - - - - - - Protocol - - - true - - - - 4 - - - 0 - - - 4 - - - 4 - - - 3 - - - 2 - - - - - true + + + 0 + 0 + - ... - - - false + Stop - - - - + - - 0 + + 4 0 - - Profile + + QFrame::NoFrame - - true + + QFrame::Raised - + + + 2 + - 4 + 3 - 0 + 2 - 4 + 3 - 4 + 8 - - 2 - - - - - - 0 - 0 - - - - 10 - - - - - - - - 0 - 0 - - - - Load - + + + + Tracker + + + + 4 + + + 0 + + + 4 + + + 0 + + + 3 + + + 0 + + + + + + + + true + + + ... + + + false + + + + - - - - true - - - - 0 - 0 - - - - Save - + + + + Protocol + + + + 4 + + + 0 + + + 4 + + + 0 + + + 3 + + + 0 + + + + + + + + true + + + ... + + + false + + + + - - - - true - - - - 0 - 0 - - - - Save... - + + + + Filter + + + + 4 + + + 0 + + + 4 + + + 0 + + + 3 + + + 0 + + + + + + + + true + + + ... + + + false + + + + @@ -1197,10 +1243,6 @@ btnShowServerControls iconcomboFilter btnShowFilterControls - iconcomboProfile - btnLoad - btnSave - btnSaveAs btnEditCurves btnShortcuts diff --git a/facetracknoir/new_config.ui b/facetracknoir/new_config.ui new file mode 100644 index 00000000..27dce0f8 --- /dev/null +++ b/facetracknoir/new_config.ui @@ -0,0 +1,45 @@ + + + UI_new_config + + + Qt::ApplicationModal + + + + 0 + 0 + 269 + 67 + + + + Config filename + + + + images/facetracknoir.pngimages/facetracknoir.png + + + + + + New file name: + + + + + + + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + diff --git a/facetracknoir/new_file_dialog.h b/facetracknoir/new_file_dialog.h new file mode 100644 index 00000000..dc821592 --- /dev/null +++ b/facetracknoir/new_file_dialog.h @@ -0,0 +1,48 @@ +#pragma once + +#include "ui_new_config.h" +#include "opentrack/options.hpp" +#include +#include +#include +#include + +class new_file_dialog : public QDialog +{ + Q_OBJECT +public: + new_file_dialog(QWidget* parent = 0) : QDialog(parent), ok(false) + { + ui.setupUi(this); + connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(ok_clicked())); + connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(cancel_clicked())); + setFixedSize(size()); + } + bool is_ok(QString& name_) + { + name_ = name; + return ok; + } +private: + Ui::UI_new_config ui; + bool ok; + QString name; +private slots: + void cancel_clicked() { close(); } + void ok_clicked() + { + QString text = ui.lineEdit->text(); + text = text.replace('/', ""); + text = text.replace('\\', ""); + if (text == "" || QFile(options::group::ini_directory() + "/" + text).exists()) + { + QMessageBox::warning(this, + "File exists", "This file already exists. Pick another name.", + QMessageBox::Ok, QMessageBox::NoButton); + return; + } + ok = true; + close(); + name = text; + } +}; diff --git a/facetracknoir/ui.cpp b/facetracknoir/ui.cpp old mode 100755 new mode 100644 index 3f87ca2f..958a2439 --- a/facetracknoir/ui.cpp +++ b/facetracknoir/ui.cpp @@ -33,7 +33,10 @@ #include "ui.h" #include "opentrack/tracker.h" #include "opentrack/options.hpp" +#include "facetracknoir/new_file_dialog.h" #include +#include +#include #ifndef _WIN32 # include @@ -53,10 +56,6 @@ MainWindow::MainWindow() : updateButtonState(false, false); ui.video_frame_label->setPixmap(no_feed_pixmap); - 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())); @@ -74,7 +73,7 @@ MainWindow::MainWindow() : for (auto x : modules.filters()) ui.iconcomboFilter->addItem(x->icon, x->name); - fill_profile_combobox(); + refresh_config_list(); tie_setting(s.tracker_dll, ui.iconcomboTrackerSource); tie_setting(s.protocol_dll, ui.iconcomboProtocol); @@ -82,15 +81,15 @@ MainWindow::MainWindow() : connect(ui.iconcomboTrackerSource, static_cast(&QComboBox::currentIndexChanged), - [&](int) -> void { if (pTrackerDialog) pTrackerDialog = nullptr; }); + [&](int) -> void { if (pTrackerDialog) pTrackerDialog = nullptr; save(); }); connect(ui.iconcomboProtocol, static_cast(&QComboBox::currentIndexChanged), - [&](int) -> void { if (pProtocolDialog) pProtocolDialog = nullptr; }); + [&](int) -> void { if (pProtocolDialog) pProtocolDialog = nullptr; save(); }); connect(ui.iconcomboFilter, static_cast(&QComboBox::currentIndexChanged), - [&](int) -> void { if (pFilterDialog) pFilterDialog = nullptr; }); + [&](int) -> void { if (pFilterDialog) pFilterDialog = nullptr; save(); }); connect(ui.btnStartTracker, SIGNAL(clicked()), this, SLOT(startTracker())); connect(ui.btnStopTracker, SIGNAL(clicked()), this, SLOT(stopTracker())); @@ -98,14 +97,46 @@ MainWindow::MainWindow() : connect(&pose_update_timer, SIGNAL(timeout()), this, SLOT(showHeadPose())); connect(&kbd_quit, SIGNAL(activated()), this, SLOT(exit())); + + auto menu = new QMenu; + menu->addAction("Create new empty config", this, SLOT(make_empty_config())); + menu->addAction("Create new copied config", this, SLOT(make_copied_config())); + menu->addAction("Open configuration directory", this, SLOT(open_config_directory())); + menu->addAction("Refresh configuration list", this, SLOT(refresh_config_list())); + ui.profile_button->setMenu(menu); + kbd_quit.setEnabled(true); connect(&det_timer, SIGNAL(timeout()), this, SLOT(maybe_start_profile_from_executable())); det_timer.start(1000); ensure_tray(); - set_working_directory(); + + if (!QFile(group::ini_pathname()).exists()) + { + set_profile(OPENTRACK_DEFAULT_CONFIG); + if (!QFile(group::ini_pathname()).exists()) + { + const auto pathname = group::ini_pathname(); + QFile file(pathname); + if (file.open(QFile::ReadWrite)) + { + QTextStream stream(&file); + stream << "\n"; + } + } + } +} + +bool MainWindow::get_new_config_name_from_dialog(QString& ret) +{ + new_file_dialog dlg; + dlg.exec(); + bool b = dlg.is_ok(ret); + if (b && !ret.endsWith(".ini")) + ret += ".ini"; + return b; } MainWindow::~MainWindow() @@ -121,27 +152,6 @@ void MainWindow::set_working_directory() QDir::setCurrent(QCoreApplication::applicationDirPath()); } -void MainWindow::open() { - QFileDialog dialog(this); - dialog.setFileMode(QFileDialog::ExistingFile); - QString dir_path = QFileInfo(group::ini_pathname()).absolutePath(); - QString fileName = dialog.getOpenFileName( - this, - tr("Open the settings file"), - dir_path, - tr("Settings file (*.ini);;All Files (*)")); - set_working_directory(); - - if (!fileName.isEmpty()) { - { - QSettings settings(OPENTRACK_ORG); - settings.setValue(OPENTRACK_CONFIG_FILENAME_KEY, remove_app_path(fileName)); - } - fill_profile_combobox(); - load_settings(); - } -} - void MainWindow::save_mappings() { pose.save_mappings(); } @@ -164,29 +174,6 @@ void MainWindow::save() { #endif } -void MainWindow::saveAs() -{ - QString oldFile = group::ini_pathname(); - QString fileName = QFileDialog::getSaveFileName(this, tr("Save file"), - oldFile, - tr("Settings file (*.ini);;All Files (*)")); - set_working_directory(); - - if (fileName.isEmpty()) - return; - - (void) QFile::remove(fileName); - - { - (void) QFile::copy(oldFile, fileName); - QSettings settings(OPENTRACK_ORG); - settings.setValue (OPENTRACK_CONFIG_FILENAME_KEY, remove_app_path(fileName)); - } - - save(); - fill_profile_combobox(); -} - void MainWindow::load_mappings() { pose.load_mappings(); } @@ -196,10 +183,59 @@ void MainWindow::load_settings() { load_mappings(); } +void MainWindow::make_empty_config() +{ + QString name; + const QString dir = group::ini_directory(); + if (dir != "" && get_new_config_name_from_dialog(name)) + { + QFile filename(dir + "/" + name); + if (filename.open(QFile::ReadWrite)) + { + QTextStream stream(&filename); + stream << "\n"; + refresh_config_list(); + } + } +} + +void MainWindow::make_copied_config() +{ + const QString dir = group::ini_directory(); + const QString cur = group::ini_pathname(); + QString name; + if (cur != "" && dir != "" && get_new_config_name_from_dialog(name)) + { + const QString new_name = dir + "/" + name; + (void) QFile::remove(new_name); + (void) QFile::copy(cur, new_name); + refresh_config_list(); + } +} + +void MainWindow::open_config_directory() +{ + const QString path = group::ini_directory(); + if (path != "") + { + QDesktopServices::openUrl("file:///" + QDir::toNativeSeparators(path)); + } +} + extern "C" volatile const char* opentrack_version; -void MainWindow::fill_profile_combobox() +void MainWindow::refresh_config_list() { + if (group::ini_list().size() == 0) + { + QFile filename(group::ini_directory() + "/" OPENTRACK_DEFAULT_CONFIG); + if (filename.open(QFile::ReadWrite)) + { + QTextStream stream(&filename); + stream << "\n"; + } + } + QStringList ini_list = group::ini_list(); set_title(); QString current = QFileInfo(group::ini_pathname()).fileName(); @@ -219,8 +255,7 @@ void MainWindow::updateButtonState(bool running, bool inertialp) ui.iconcomboFilter->setEnabled ( not_running ); ui.iconcomboTrackerSource->setEnabled(not_running); ui.video_frame_label->setVisible(not_running || inertialp); - ui.btnSaveAs->setEnabled(not_running); - ui.btnLoad->setEnabled(not_running); + ui.profile_button->setEnabled(not_running); } void MainWindow::bindKeyboardShortcuts() @@ -440,26 +475,6 @@ void MainWindow::exit() { QCoreApplication::exit(0); } -QString MainWindow::remove_app_path(const QString full_path) -{ - QFileInfo path_info(full_path); - QString path = path_info.absolutePath(); - - QFileInfo app_path(QCoreApplication::applicationDirPath()); - QString app_prefix(app_path.absoluteFilePath()); - - if (path == app_prefix) - { - path = "."; - } - else if (path.startsWith(app_prefix + "/")) - { - path = "./" + path.mid(app_prefix.size() + 1); - } - - return path + "/" + path_info.fileName(); -} - void MainWindow::profileSelected(int index) { if (index == -1) @@ -467,8 +482,7 @@ void MainWindow::profileSelected(int index) { QSettings settings(OPENTRACK_ORG); - settings.setValue (OPENTRACK_CONFIG_FILENAME_KEY, remove_app_path(QFileInfo(group::ini_pathname()).absolutePath() + "/" + - ui.iconcomboProfile->itemText(index))); + settings.setValue (OPENTRACK_CONFIG_FILENAME_KEY, ui.iconcomboProfile->itemText(index)); } set_title(); @@ -550,5 +564,5 @@ void MainWindow::maybe_start_profile_from_executable() void MainWindow::set_profile(const QString &profile) { QSettings settings(OPENTRACK_ORG); - settings.setValue(OPENTRACK_CONFIG_FILENAME_KEY, MainWindow::remove_app_path(profile)); + settings.setValue(OPENTRACK_CONFIG_FILENAME_KEY, profile); } diff --git a/facetracknoir/ui.h b/facetracknoir/ui.h index 097b2439..0c3063d4 100644 --- a/facetracknoir/ui.h +++ b/facetracknoir/ui.h @@ -93,22 +93,20 @@ class MainWindow : public QMainWindow, private State void changeEvent(QEvent* e) override; - void createIconGroupBox(); void load_settings(); void updateButtonState(bool running, bool inertialp); - void fill_profile_combobox(); void display_pose(const double* mapped, const double* raw); void ensure_tray(); void set_title(const QString& game_title = QStringLiteral("")); + void save(); + static bool get_new_config_name_from_dialog(QString &ret); + static void set_profile(const QString& profile); public slots: void shortcutRecentered(); void shortcutToggled(); void shortcutZeroed(); void bindKeyboardShortcuts(); private slots: - void open(); - void save(); - void saveAs(); void exit(); void profileSelected(int index); @@ -121,6 +119,11 @@ private slots: void restore_from_tray(QSystemTrayIcon::ActivationReason); void maybe_start_profile_from_executable(); + + void make_empty_config(); + void make_copied_config(); + void open_config_directory(); + void refresh_config_list(); public slots: void startTracker(); void stopTracker(); @@ -129,7 +132,5 @@ public: ~MainWindow(); void save_mappings(); void load_mappings(); - static QString remove_app_path(const QString full_path); static void set_working_directory(); - static void set_profile(const QString& profile); }; diff --git a/ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.cpp b/ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.cpp index 80543e7a..0a4454e4 100644 --- a/ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.cpp +++ b/ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.cpp @@ -35,15 +35,11 @@ void TrackerSettings::load_ini() { -#ifdef OPENTRACK_API +#ifndef OPENTRACK_API QSettings settings(OPENTRACK_ORG); // Registry settings (in HK_USER) + QString currentFile = settings.value( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); #else - QSettings settings("opentrack"); // Registry settings (in HK_USER) -#endif -#ifdef OPENTRACK_API - QString currentFile = settings.value( OPENTRACK_CONFIG_FILENAME_KEY, QCoreApplication::applicationDirPath() + OPENTRACK_DEFAULT_CONFIG_PATH ).toString(); -#else - QString currentFile = settings.value( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + QString currentFile = options::group::ini_pathname(); #endif QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) @@ -101,19 +97,14 @@ void TrackerSettings::load_ini() iniFile.endGroup(); } - void TrackerSettings::save_ini() const { -#ifdef OPENTRACK_API +#ifndef OPENTRACK_API QSettings settings(OPENTRACK_ORG); // Registry settings (in HK_USER) + QString currentFile = settings.value( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); #else - QSettings settings("opentrack"); // Registry settings (in HK_USER) -#endif -#ifdef OPENTRACK_API - QString currentFile = settings.value( OPENTRACK_CONFIG_FILENAME_KEY, QCoreApplication::applicationDirPath() + OPENTRACK_DEFAULT_CONFIG_PATH ).toString(); -#else - QString currentFile = settings.value( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + QString currentFile = options::group::ini_pathname(); #endif QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) diff --git a/opentrack/options.hpp b/opentrack/options.hpp index f4deb8a1..8e623092 100644 --- a/opentrack/options.hpp +++ b/opentrack/options.hpp @@ -30,6 +30,7 @@ #include #include #include +#include #include @@ -38,8 +39,8 @@ #include template using mem = std::shared_ptr; -#define OPENTRACK_CONFIG_FILENAME_KEY "settings-file" -#define OPENTRACK_DEFAULT_CONFIG_PATH "/settings/default.ini" +#define OPENTRACK_CONFIG_FILENAME_KEY "settings-filename" +#define OPENTRACK_DEFAULT_CONFIG "default.ini" #define OPENTRACK_ORG "opentrack-2.3" namespace options { @@ -90,30 +91,30 @@ namespace options { public: group(const string& name) : name(name) { - QSettings conf(ini_pathname(), QSettings::IniFormat); + auto conf = ini_file(); auto q_name = QString::fromStdString(name); - conf.beginGroup(q_name); - for (auto& k_ : conf.childKeys()) + conf->beginGroup(q_name); + for (auto& k_ : conf->childKeys()) { auto tmp = k_.toUtf8(); string k(tmp); - kvs[k] = conf.value(k_); + kvs[k] = conf->value(k_); } - conf.endGroup(); + conf->endGroup(); } void save() { - QSettings s(ini_pathname(), QSettings::IniFormat); + auto s = ini_file(); auto q_name = QString::fromStdString(name); - s.beginGroup(q_name); + s->beginGroup(q_name); for (auto& i : kvs) { auto k = QString::fromStdString(i.first); - s.setValue(k, i.second); + s->setValue(k, i.second); } - s.endGroup(); - s.sync(); + s->endGroup(); + s->sync(); } template @@ -132,22 +133,40 @@ namespace options { return kvs.count(s) != 0; } - static const QString ini_pathname() + static QString ini_directory() { + const auto dirs = QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation); + if (dirs.size() == 0) + return ""; + if (QDir(dirs[0]).mkpath(OPENTRACK_ORG)) + return dirs[0] + "/" OPENTRACK_ORG; + return ""; + } + + static QString ini_pathname() + { + const auto dir = ini_directory(); + if (dir == "") + return ""; QSettings settings(OPENTRACK_ORG); - return settings.value(OPENTRACK_CONFIG_FILENAME_KEY, QCoreApplication::applicationDirPath() + OPENTRACK_DEFAULT_CONFIG_PATH).toString(); + return dir + "/" + settings.value(OPENTRACK_CONFIG_FILENAME_KEY, OPENTRACK_DEFAULT_CONFIG).toString(); } static const QStringList ini_list() { - QFileInfo info(group::ini_pathname()); - QDir settings_dir(info.dir()); + const auto dirname = ini_directory(); + if (dirname == "") + return QStringList(); + QDir settings_dir(dirname); return settings_dir.entryList( QStringList { "*.ini" } , QDir::Files, QDir::Name ); } static const mem ini_file() { - return std::make_shared(ini_pathname(), QSettings::IniFormat); + const auto pathname = ini_pathname(); + if (pathname != "") + return std::make_shared(ini_pathname(), QSettings::IniFormat); + return std::make_shared(); } }; -- cgit v1.2.3 From 21cd2c012ef23ec3f4b374d82056f1fa1694d904 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 22 Aug 2015 19:02:57 +0200 Subject: props changed only Some source files had executable bit on. Remove it. --- CMakeLists.txt | 0 bin/NPClient.dll | Bin bin/NPClient64.dll | Bin bin/freetrackclient.dll | Bin clientfiles/make-csv.pl | 0 csv/csv.cpp | 0 facetracknoir/keyboard.h | 0 facetracknoir/process_detector.cpp | 0 facetracknoir/process_detector.h | 0 ftnoir_filter_kalman/ftnoir_filter_kalman.h | 0 ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp | 0 ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp | 0 ftnoir_tracker_aruco/include/markerdetector.h | 0 ftnoir_tracker_pt/ftnoir_tracker_pt.cpp | 0 ftnoir_tracker_udp/ftnoir_tracker_udp.cpp | 0 opentrack-compat/process-list.hpp | 0 opentrack/simple-mat.hpp | 0 opentrack/tracker.cpp | 0 opentrack/win32-shortcuts.cpp | 0 opentrack/win32-shortcuts.h | 0 pose-widget/glwidget.cpp | 0 pose-widget/glwidget.h | 0 qfunctionconfigurator/functionconfig.cpp | 0 23 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 CMakeLists.txt mode change 100755 => 100644 bin/NPClient.dll mode change 100755 => 100644 bin/NPClient64.dll mode change 100755 => 100644 bin/freetrackclient.dll mode change 100755 => 100644 clientfiles/make-csv.pl mode change 100755 => 100644 csv/csv.cpp mode change 100755 => 100644 facetracknoir/keyboard.h mode change 100755 => 100644 facetracknoir/process_detector.cpp mode change 100755 => 100644 facetracknoir/process_detector.h mode change 100755 => 100644 ftnoir_filter_kalman/ftnoir_filter_kalman.h mode change 100755 => 100644 ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp mode change 100755 => 100644 ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp mode change 100755 => 100644 ftnoir_tracker_aruco/include/markerdetector.h mode change 100755 => 100644 ftnoir_tracker_pt/ftnoir_tracker_pt.cpp mode change 100755 => 100644 ftnoir_tracker_udp/ftnoir_tracker_udp.cpp mode change 100755 => 100644 opentrack-compat/process-list.hpp mode change 100755 => 100644 opentrack/simple-mat.hpp mode change 100755 => 100644 opentrack/tracker.cpp mode change 100755 => 100644 opentrack/win32-shortcuts.cpp mode change 100755 => 100644 opentrack/win32-shortcuts.h mode change 100755 => 100644 pose-widget/glwidget.cpp mode change 100755 => 100644 pose-widget/glwidget.h mode change 100755 => 100644 qfunctionconfigurator/functionconfig.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt old mode 100755 new mode 100644 diff --git a/bin/NPClient.dll b/bin/NPClient.dll old mode 100755 new mode 100644 diff --git a/bin/NPClient64.dll b/bin/NPClient64.dll old mode 100755 new mode 100644 diff --git a/bin/freetrackclient.dll b/bin/freetrackclient.dll old mode 100755 new mode 100644 diff --git a/clientfiles/make-csv.pl b/clientfiles/make-csv.pl old mode 100755 new mode 100644 diff --git a/csv/csv.cpp b/csv/csv.cpp old mode 100755 new mode 100644 diff --git a/facetracknoir/keyboard.h b/facetracknoir/keyboard.h old mode 100755 new mode 100644 diff --git a/facetracknoir/process_detector.cpp b/facetracknoir/process_detector.cpp old mode 100755 new mode 100644 diff --git a/facetracknoir/process_detector.h b/facetracknoir/process_detector.h old mode 100755 new mode 100644 diff --git a/ftnoir_filter_kalman/ftnoir_filter_kalman.h b/ftnoir_filter_kalman/ftnoir_filter_kalman.h old mode 100755 new mode 100644 diff --git a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp old mode 100755 new mode 100644 diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp old mode 100755 new mode 100644 diff --git a/ftnoir_tracker_aruco/include/markerdetector.h b/ftnoir_tracker_aruco/include/markerdetector.h old mode 100755 new mode 100644 diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp b/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp old mode 100755 new mode 100644 diff --git a/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp b/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp old mode 100755 new mode 100644 diff --git a/opentrack-compat/process-list.hpp b/opentrack-compat/process-list.hpp old mode 100755 new mode 100644 diff --git a/opentrack/simple-mat.hpp b/opentrack/simple-mat.hpp old mode 100755 new mode 100644 diff --git a/opentrack/tracker.cpp b/opentrack/tracker.cpp old mode 100755 new mode 100644 diff --git a/opentrack/win32-shortcuts.cpp b/opentrack/win32-shortcuts.cpp old mode 100755 new mode 100644 diff --git a/opentrack/win32-shortcuts.h b/opentrack/win32-shortcuts.h old mode 100755 new mode 100644 diff --git a/pose-widget/glwidget.cpp b/pose-widget/glwidget.cpp old mode 100755 new mode 100644 diff --git a/pose-widget/glwidget.h b/pose-widget/glwidget.h old mode 100755 new mode 100644 diff --git a/qfunctionconfigurator/functionconfig.cpp b/qfunctionconfigurator/functionconfig.cpp old mode 100755 new mode 100644 -- cgit v1.2.3 From afe5e0290e361a7f46289b428c7b865694cee520 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 22 Aug 2015 19:12:43 +0200 Subject: ui: simplify condition --- facetracknoir/ui.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/facetracknoir/ui.cpp b/facetracknoir/ui.cpp index 958a2439..258a0e15 100644 --- a/facetracknoir/ui.cpp +++ b/facetracknoir/ui.cpp @@ -116,9 +116,9 @@ MainWindow::MainWindow() : if (!QFile(group::ini_pathname()).exists()) { set_profile(OPENTRACK_DEFAULT_CONFIG); - if (!QFile(group::ini_pathname()).exists()) + const auto pathname = group::ini_pathname(); + if (!QFile(pathname).exists()) { - const auto pathname = group::ini_pathname(); QFile file(pathname); if (file.open(QFile::ReadWrite)) { -- cgit v1.2.3 From 8833ef44c0c359812299d5be25ecdd41d7c1b4e4 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 22 Aug 2015 19:14:13 +0200 Subject: ui: remove GNU GPL Nothing copyrightable under GNU GPL remains. We can FINALLY remove previous copyright statement and GNU GPL terms. Issue: #226 --- facetracknoir/ui.cpp | 24 ------------------------ facetracknoir/ui.h | 24 ------------------------ 2 files changed, 48 deletions(-) diff --git a/facetracknoir/ui.cpp b/facetracknoir/ui.cpp index 258a0e15..a204f36d 100644 --- a/facetracknoir/ui.cpp +++ b/facetracknoir/ui.cpp @@ -1,27 +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) 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 . -*********************************************************************************/ - /* Copyright (c) 2013-2015, Stanislaw Halik * Permission to use, copy, modify, and/or distribute this diff --git a/facetracknoir/ui.h b/facetracknoir/ui.h index 0c3063d4..94b52491 100644 --- a/facetracknoir/ui.h +++ b/facetracknoir/ui.h @@ -1,27 +1,3 @@ -/******************************************************************************* -* MainWindow 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 . -*********************************************************************************/ - /* Copyright (c) 2014-2015, Stanislaw Halik * Permission to use, copy, modify, and/or distribute this -- cgit v1.2.3 From dbefcb3910665cb9a896c7073ae79200ceb67085 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 22 Aug 2015 19:17:34 +0200 Subject: ui: nix wrong headers --- facetracknoir/ui.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/facetracknoir/ui.h b/facetracknoir/ui.h index 94b52491..9fefa2f4 100644 --- a/facetracknoir/ui.h +++ b/facetracknoir/ui.h @@ -16,12 +16,6 @@ #include #include -#if !defined(_WIN32) -# include "qxt-mini/QxtGlobalShortcut" -#else -# include -#endif - #include "ui_main.h" #include "opentrack/options.hpp" -- cgit v1.2.3 From b531e71bb9f86990eaa4a01bc6b51c0079f7db3e Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 22 Aug 2015 19:19:55 +0200 Subject: ui: these aren't qt slots --- facetracknoir/ui.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/facetracknoir/ui.h b/facetracknoir/ui.h index 9fefa2f4..4e89b143 100644 --- a/facetracknoir/ui.h +++ b/facetracknoir/ui.h @@ -69,13 +69,12 @@ class MainWindow : public QMainWindow, private State void ensure_tray(); void set_title(const QString& game_title = QStringLiteral("")); void save(); - static bool get_new_config_name_from_dialog(QString &ret); - static void set_profile(const QString& profile); -public slots: void shortcutRecentered(); void shortcutToggled(); void shortcutZeroed(); void bindKeyboardShortcuts(); + static bool get_new_config_name_from_dialog(QString &ret); + static void set_profile(const QString& profile); private slots: void exit(); void profileSelected(int index); -- cgit v1.2.3 From 85c24dd0e030c2a2af44fdcf323a02a1dfae512e Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 22 Aug 2015 19:38:55 +0200 Subject: nix default empty config. it gets created on its own. --- bin/settings/default.ini | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 bin/settings/default.ini diff --git a/bin/settings/default.ini b/bin/settings/default.ini deleted file mode 100644 index e69de29b..00000000 -- cgit v1.2.3 From 48339aa148200f0f9cdf8ff61b17413ff1dacc87 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 22 Aug 2015 20:23:35 +0200 Subject: simple-mat: can use static_cast here --- opentrack/simple-mat.hpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/opentrack/simple-mat.hpp b/opentrack/simple-mat.hpp index 2b4cb72e..ca60c54d 100644 --- a/opentrack/simple-mat.hpp +++ b/opentrack/simple-mat.hpp @@ -68,12 +68,6 @@ class Mat static_assert(h_ > 0 && w_ > 0, "must have positive mat dimensions"); - struct cast - { - template - static num _(u x) { return static_cast(x); } - }; - Mat(std::initializer_list&& xs) = delete; public: @@ -205,7 +199,7 @@ public: template::value>> Mat(ts const&... xs) { - const std::initializer_list init = { cast::_(xs)... }; + const std::initializer_list init = { static_cast(xs)... }; auto iter = init.begin(); for (int j = 0; j < h_; j++) for (int i = 0; i < w_; i++) -- cgit v1.2.3 From 9cd5ab67dbe347d1f4dcf4a6eb3f4fd7e3d89dab Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 22 Aug 2015 20:25:32 +0200 Subject: simple-mat: fix arglist SFINAE Constructor was always available, enable_if faultily allowed it to accept an arbitrary amount of parameters. The `assignable' bit is redundant and broken, anyway static_cast(x)... takes care of type compatibility. --- opentrack/simple-mat.hpp | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/opentrack/simple-mat.hpp b/opentrack/simple-mat.hpp index ca60c54d..c603a2cb 100644 --- a/opentrack/simple-mat.hpp +++ b/opentrack/simple-mat.hpp @@ -42,22 +42,10 @@ namespace { enum { Q = a == 1 ? 3 : 1 }; }; - template struct assignable; - - template - struct assignable { - enum { value = true }; - }; - - template - struct assignable { - enum { value = std::is_assignable::value && assignable::value }; - }; - template struct is_arglist_correct { - enum { value = h * w == sizeof...(ts) && assignable::value }; + enum { value = h * w == sizeof...(ts) }; }; } @@ -196,7 +184,8 @@ public: inline num operator()(int j, int i) const { return data[j][i]; } inline num& operator()(int j, int i) { return data[j][i]; } - template::value>> + template::value>::type> Mat(ts const&... xs) { const std::initializer_list init = { static_cast(xs)... }; -- cgit v1.2.3 From c15a456ac6df79a001250fc5b877751db4a30875 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 22 Aug 2015 23:00:59 +0200 Subject: ui: append extension in the right place Otherwise, file can be overwritten accidentally --- facetracknoir/new_file_dialog.h | 2 ++ facetracknoir/ui.cpp | 5 +---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/facetracknoir/new_file_dialog.h b/facetracknoir/new_file_dialog.h index dc821592..d72b8741 100644 --- a/facetracknoir/new_file_dialog.h +++ b/facetracknoir/new_file_dialog.h @@ -34,6 +34,8 @@ private slots: QString text = ui.lineEdit->text(); text = text.replace('/', ""); text = text.replace('\\', ""); + if (text != "" && !text.endsWith(".ini")) + text += ".ini"; if (text == "" || QFile(options::group::ini_directory() + "/" + text).exists()) { QMessageBox::warning(this, diff --git a/facetracknoir/ui.cpp b/facetracknoir/ui.cpp index a204f36d..e22fee7a 100644 --- a/facetracknoir/ui.cpp +++ b/facetracknoir/ui.cpp @@ -109,10 +109,7 @@ bool MainWindow::get_new_config_name_from_dialog(QString& ret) { new_file_dialog dlg; dlg.exec(); - bool b = dlg.is_ok(ret); - if (b && !ret.endsWith(".ini")) - ret += ".ini"; - return b; + return dlg.is_ok(ret); } MainWindow::~MainWindow() -- cgit v1.2.3 From 5871f5fb0d7aac67bbac7055d22a59f80576621b Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 23 Aug 2015 11:58:41 +0200 Subject: game-data: chomp newlines in extractor Some of the XML data is malformed. Chomp newlines to ease Perl's job. --- .../important-stuff/game_data.c | 34 ++++++++++++++++------ 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/clientfiles/very-important-source-code/important-stuff/game_data.c b/clientfiles/very-important-source-code/important-stuff/game_data.c index f80a7d44..48774187 100644 --- a/clientfiles/very-important-source-code/important-stuff/game_data.c +++ b/clientfiles/very-important-source-code/important-stuff/game_data.c @@ -114,6 +114,20 @@ static void game_data_close() #define ltr_int_log_message(...) fprintf(stderr, __VA_ARGS__) +static void remove_newlines(const char* str, char* out, int out_len) +{ + int i, j; + int len = strlen(str); + for (i = 0, j = 0; str[i] && j + 1 < out_len; i++) + { + if (str[i] == '\r' || str[i] == '\n') + continue; + out[j++] = str[i]; + } + if (j < out_len) + out[j] = '\0'; +} + bool get_game_data(const char *input_fname, const char *output_fname, bool from_update) { FILE *outfile = NULL; @@ -129,19 +143,21 @@ bool get_game_data(const char *input_fname, const char *output_fname, bool from_ mxml_node_t *game; const char *name; const char *id; - for(game = mxmlFindElement(tree, tree, "Game", NULL, NULL, MXML_DESCEND); + for(game = mxmlFindElement(tree, tree, "Game", NULL, NULL, MXML_DESCEND); game != NULL; - game = mxmlFindElement(game, tree, "Game", NULL, NULL, MXML_DESCEND)){ + game = mxmlFindElement(game, tree, "Game", NULL, NULL, MXML_DESCEND)) + { name = mxmlElementGetAttr(game, "Name"); id = mxmlElementGetAttr(game, "Id"); - + mxml_node_t *appid = mxmlFindElement(game, game, "ApplicationID", NULL, NULL, MXML_DESCEND); - if(appid == NULL){ - fprintf(outfile, "%s \"%s\"\n", id, name); - }else{ - fprintf(outfile, "%s \"%s\" (%s)\n", id, name, appid->child->value.text.string); - } - } + char name_[256]; + remove_newlines(name, name_, sizeof(name_)); + if(appid == NULL) + fprintf(outfile, "%s \"%s\"\n", id, name_); + else + fprintf(outfile, "%s \"%s\" (%s)\n", id, name_, appid->child->value.text.string); + } fclose(outfile); game_data_close(); return true; -- cgit v1.2.3 From 1b8a80c2694c025ecf2a3bd0d1c0a934f91451ec Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 23 Aug 2015 11:58:49 +0200 Subject: ft: new game support --- bin/settings/facetracknoir supported games.csv | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bin/settings/facetracknoir supported games.csv b/bin/settings/facetracknoir supported games.csv index 98dba166..ad6f1393 100644 --- a/bin/settings/facetracknoir supported games.csv +++ b/bin/settings/facetracknoir supported games.csv @@ -66,6 +66,7 @@ No;Game Name;Game protocol;Supported since;Verified;By;INTERNATIONAL_ID;FTN_ID 57;Caterpillar Simulators;FreeTrack20;V160;;;23080;0039F52E4221742FA63100 58;CCG Metamedia;FreeTrack20;V160;;;20009;003A6FA8A8DD86FE8BDB00 547;CDF Ghostship;FreeTrack20;V160;;;4150;02230A04C45292CC5DA400 +568;CDF Starfighter;FreeTrack20;V160;;;4153;0238E7D9A14B2A1AE98900 59;CEWIT Immersive Cabin;FreeTrack20;V160;;;20370;003B90B5780C90078DEE00 60;Chopper;FreeTrack20;V160;;;3150;003CC166C8632A32EA2300 61;Clearbox;FreeTrack20;V160;;;20565;003D5C1FDE74279D1DB800 @@ -75,6 +76,7 @@ No;Game Name;Game protocol;Supported since;Verified;By;INTERNATIONAL_ID;FTN_ID 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 +569;Combat Air Patrol 2;FreeTrack20;V160;;;4425;02399AAA88F5062AB14500 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 -- cgit v1.2.3 From 6319cc457adf63c55920963a7a7cbb1398b8bbac Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 24 Aug 2015 08:44:48 +0200 Subject: ui: avoid potential memory leak While not having tested with valgrind, setMenu() doesn't seem to take ownership of QMenu. Ensure it's not leaked. --- facetracknoir/ui.cpp | 12 +++++------- facetracknoir/ui.h | 2 ++ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/facetracknoir/ui.cpp b/facetracknoir/ui.cpp index e22fee7a..bd1b88f7 100644 --- a/facetracknoir/ui.cpp +++ b/facetracknoir/ui.cpp @@ -12,7 +12,6 @@ #include "facetracknoir/new_file_dialog.h" #include #include -#include #ifndef _WIN32 # include @@ -74,12 +73,11 @@ MainWindow::MainWindow() : connect(&pose_update_timer, SIGNAL(timeout()), this, SLOT(showHeadPose())); connect(&kbd_quit, SIGNAL(activated()), this, SLOT(exit())); - auto menu = new QMenu; - menu->addAction("Create new empty config", this, SLOT(make_empty_config())); - menu->addAction("Create new copied config", this, SLOT(make_copied_config())); - menu->addAction("Open configuration directory", this, SLOT(open_config_directory())); - menu->addAction("Refresh configuration list", this, SLOT(refresh_config_list())); - ui.profile_button->setMenu(menu); + profile_menu.addAction("Create new empty config", this, SLOT(make_empty_config())); + profile_menu.addAction("Create new copied config", this, SLOT(make_copied_config())); + profile_menu.addAction("Open configuration directory", this, SLOT(open_config_directory())); + profile_menu.addAction("Refresh configuration list", this, SLOT(refresh_config_list())); + ui.profile_button->setMenu(&profile_menu); kbd_quit.setEnabled(true); diff --git a/facetracknoir/ui.h b/facetracknoir/ui.h index 4e89b143..9ecc0db9 100644 --- a/facetracknoir/ui.h +++ b/facetracknoir/ui.h @@ -15,6 +15,7 @@ #include #include #include +#include #include "ui_main.h" @@ -47,6 +48,7 @@ class MainWindow : public QMainWindow, private State mem pProtocolDialog; mem pTrackerDialog; process_detector_worker det; + QMenu profile_menu; mem current_tracker() { -- cgit v1.2.3 From c0d1d315a7a62f8d8453a037073b8e95565cf482 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 24 Aug 2015 08:46:50 +0200 Subject: ui: no need to write anything to new empty config --- facetracknoir/ui.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/facetracknoir/ui.cpp b/facetracknoir/ui.cpp index bd1b88f7..c77c35b6 100644 --- a/facetracknoir/ui.cpp +++ b/facetracknoir/ui.cpp @@ -96,8 +96,10 @@ MainWindow::MainWindow() : QFile file(pathname); if (file.open(QFile::ReadWrite)) { +#if 0 QTextStream stream(&file); stream << "\n"; +#endif } } } @@ -163,8 +165,10 @@ void MainWindow::make_empty_config() QFile filename(dir + "/" + name); if (filename.open(QFile::ReadWrite)) { +#if 0 QTextStream stream(&filename); stream << "\n"; +#endif refresh_config_list(); } } -- cgit v1.2.3 From 588231e71f08df223a54d15391d8263b4bbf5fea Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 24 Aug 2015 08:56:53 +0200 Subject: ui, shortcuts: these are slots, actually --- facetracknoir/ui.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/facetracknoir/ui.h b/facetracknoir/ui.h index 9ecc0db9..f5ce6980 100644 --- a/facetracknoir/ui.h +++ b/facetracknoir/ui.h @@ -71,10 +71,6 @@ class MainWindow : public QMainWindow, private State void ensure_tray(); void set_title(const QString& game_title = QStringLiteral("")); void save(); - void shortcutRecentered(); - void shortcutToggled(); - void shortcutZeroed(); - void bindKeyboardShortcuts(); static bool get_new_config_name_from_dialog(QString &ret); static void set_profile(const QString& profile); private slots: @@ -96,6 +92,10 @@ private slots: void open_config_directory(); void refresh_config_list(); public slots: + void shortcutRecentered(); + void shortcutToggled(); + void shortcutZeroed(); + void bindKeyboardShortcuts(); void startTracker(); void stopTracker(); public: -- cgit v1.2.3 From 3390f15bfafc5f6021856fe822abb49f97acd0f7 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 24 Aug 2015 09:01:50 +0200 Subject: ui: move some slots to private --- facetracknoir/ui.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/facetracknoir/ui.h b/facetracknoir/ui.h index f5ce6980..b05fa81b 100644 --- a/facetracknoir/ui.h +++ b/facetracknoir/ui.h @@ -91,13 +91,14 @@ private slots: void make_copied_config(); void open_config_directory(); void refresh_config_list(); + + void startTracker(); + void stopTracker(); + void bindKeyboardShortcuts(); public slots: void shortcutRecentered(); void shortcutToggled(); void shortcutZeroed(); - void bindKeyboardShortcuts(); - void startTracker(); - void stopTracker(); public: MainWindow(); ~MainWindow(); -- cgit v1.2.3 From 872acf11a851a3250f2c668af5f30dc3d48ef477 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 24 Aug 2015 09:58:07 +0200 Subject: ui: rename symbol to reflect current usage --- facetracknoir/ui.cpp | 14 +++++++------- facetracknoir/ui.h | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/facetracknoir/ui.cpp b/facetracknoir/ui.cpp index c77c35b6..d13fff1c 100644 --- a/facetracknoir/ui.cpp +++ b/facetracknoir/ui.cpp @@ -32,7 +32,7 @@ MainWindow::MainWindow() : ui.video_frame_label->setPixmap(no_feed_pixmap); connect(ui.btnEditCurves, SIGNAL(clicked()), this, SLOT(showCurveConfiguration())); - connect(ui.btnShortcuts, SIGNAL(clicked()), this, SLOT(showKeyboardShortcuts())); + connect(ui.btnShortcuts, SIGNAL(clicked()), this, SLOT(show_options_dialog())); connect(ui.btnShowEngineControls, SIGNAL(clicked()), this, SLOT(showTrackerSettings())); connect(ui.btnShowServerControls, SIGNAL(clicked()), this, SLOT(showProtocolSettings())); connect(ui.btnShowFilterControls, SIGNAL(clicked()), this, SLOT(showFilterSettings())); @@ -233,7 +233,7 @@ void MainWindow::updateButtonState(bool running, bool inertialp) ui.profile_button->setEnabled(not_running); } -void MainWindow::bindKeyboardShortcuts() +void MainWindow::reload_options() { if (work) work->reload_shortcuts(); @@ -266,8 +266,8 @@ void MainWindow::startTracker() { work = std::make_shared(s, pose, libs, this, winId()); - bindKeyboardShortcuts(); - + reload_options(); + if (pTrackerDialog) pTrackerDialog->register_tracker(libs.pTracker.get()); @@ -437,9 +437,9 @@ bool mk_window(mem* place, Args... params) } } -void MainWindow::showKeyboardShortcuts() { - if (mk_window(&shortcuts_widget)) - connect(shortcuts_widget.get(), SIGNAL(reload()), this, SLOT(bindKeyboardShortcuts())); +void MainWindow::show_options_dialog() { + if (mk_window(&options_widget)) + connect(options_widget.get(), SIGNAL(reload()), this, SLOT(reload_options())); } void MainWindow::showCurveConfiguration() { diff --git a/facetracknoir/ui.h b/facetracknoir/ui.h index b05fa81b..6d15e496 100644 --- a/facetracknoir/ui.h +++ b/facetracknoir/ui.h @@ -40,7 +40,7 @@ class MainWindow : public QMainWindow, private State mem tray; QTimer pose_update_timer; QTimer det_timer; - mem shortcuts_widget; + mem options_widget; mem mapping_widget; QShortcut kbd_quit; QPixmap no_feed_pixmap; @@ -80,7 +80,7 @@ private slots: void showTrackerSettings(); void showProtocolSettings(); void showFilterSettings(); - void showKeyboardShortcuts(); + void show_options_dialog(); void showCurveConfiguration(); void showHeadPose(); @@ -94,7 +94,7 @@ private slots: void startTracker(); void stopTracker(); - void bindKeyboardShortcuts(); + void reload_options(); public slots: void shortcutRecentered(); void shortcutToggled(); -- cgit v1.2.3 From 8f61232b36e5988e3bb89ad42b821c89c57073d7 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 24 Aug 2015 10:05:27 +0200 Subject: plugin-support: free modules from address space when needed This is groundwork for #226, even though modules still need not to load all at once and persist till program stop. This issue only affects Linux. --- opentrack/plugin-support.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opentrack/plugin-support.hpp b/opentrack/plugin-support.hpp index ec8bb3c8..c2c1b048 100644 --- a/opentrack/plugin-support.hpp +++ b/opentrack/plugin-support.hpp @@ -103,7 +103,7 @@ struct dylib { # if defined(__APPLE__) RTLD_LOCAL|RTLD_FIRST|RTLD_NOW # else - RTLD_NOW|RTLD_GLOBAL|RTLD_NODELETE + RTLD_NOW|RTLD_GLOBAL # endif ); -- cgit v1.2.3 From 0d9427dd929ca51d65a1ab08b26710647769793c Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 24 Aug 2015 10:07:46 +0200 Subject: plugin-support: set more sane RTLD flags We might need RTLD_DEEPBIND if there are symbol-related crashes. --- opentrack/plugin-support.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opentrack/plugin-support.hpp b/opentrack/plugin-support.hpp index c2c1b048..a9008840 100644 --- a/opentrack/plugin-support.hpp +++ b/opentrack/plugin-support.hpp @@ -103,7 +103,7 @@ struct dylib { # if defined(__APPLE__) RTLD_LOCAL|RTLD_FIRST|RTLD_NOW # else - RTLD_NOW|RTLD_GLOBAL + RTLD_LOCAL|RTLD_NOW|RTLD_NOW // XXX RTLD_DEEPBIND on Linux? # endif ); -- cgit v1.2.3 From b1c4466ddeb84ec9b6c19f64906458754f68b135 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 24 Aug 2015 10:11:29 +0200 Subject: plugin-support: fix typo --- opentrack/plugin-support.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opentrack/plugin-support.hpp b/opentrack/plugin-support.hpp index a9008840..8b9cf58a 100644 --- a/opentrack/plugin-support.hpp +++ b/opentrack/plugin-support.hpp @@ -103,7 +103,7 @@ struct dylib { # if defined(__APPLE__) RTLD_LOCAL|RTLD_FIRST|RTLD_NOW # else - RTLD_LOCAL|RTLD_NOW|RTLD_NOW // XXX RTLD_DEEPBIND on Linux? + RTLD_LOCAL|RTLD_NOW // XXX RTLD_DEEPBIND on Linux? # endif ); -- cgit v1.2.3 From a5aaad74a8b14533eb4faabceb137d074d59b929 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 25 Aug 2015 06:12:19 +0200 Subject: udp-tracker: silence harmless warning Reported-by: many --- ftnoir_tracker_udp/ftnoir_tracker_udp.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp b/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp index f03e75aa..1610f917 100644 --- a/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp +++ b/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp @@ -37,6 +37,7 @@ void FTNoIR_Tracker::run() { void FTNoIR_Tracker::start_tracker(QFrame*) { start(); + sock.moveToThread(this); } void FTNoIR_Tracker::data(double *data) -- cgit v1.2.3 From d54481e409d632a7fa29c6ffddc33ebbec089bf7 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 25 Aug 2015 06:14:30 +0200 Subject: ui: create an empty config properly in another code branch Missed in c0d1d315a7a62f8d8453a037073b8e95565cf482 --- facetracknoir/ui.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/facetracknoir/ui.cpp b/facetracknoir/ui.cpp index d13fff1c..9fd4a91d 100644 --- a/facetracknoir/ui.cpp +++ b/facetracknoir/ui.cpp @@ -206,8 +206,10 @@ void MainWindow::refresh_config_list() QFile filename(group::ini_directory() + "/" OPENTRACK_DEFAULT_CONFIG); if (filename.open(QFile::ReadWrite)) { +#if 0 QTextStream stream(&filename); stream << "\n"; +#endif } } -- cgit v1.2.3 From d85bc9cab41a05c5f64b0e11831287a7626263e3 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 26 Aug 2015 08:39:12 +0200 Subject: ui: display up to 20 profiles w/o scrolling --- facetracknoir/main.ui | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/facetracknoir/main.ui b/facetracknoir/main.ui index f240a510..7bcf09e4 100644 --- a/facetracknoir/main.ui +++ b/facetracknoir/main.ui @@ -8,7 +8,7 @@ 0 0 707 - 492 + 494 @@ -938,7 +938,7 @@ - 10 + 20 -- cgit v1.2.3 From 4559bdb44ef9b48d74cbc2e38ecdccd5e92d48e3 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 26 Aug 2015 08:39:41 +0200 Subject: ui: auto-refresh config list --- facetracknoir/ui.cpp | 6 +++++- facetracknoir/ui.h | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/facetracknoir/ui.cpp b/facetracknoir/ui.cpp index 9fd4a91d..3d768d8b 100644 --- a/facetracknoir/ui.cpp +++ b/facetracknoir/ui.cpp @@ -49,6 +49,8 @@ MainWindow::MainWindow() : ui.iconcomboFilter->addItem(x->icon, x->name); refresh_config_list(); + connect(&config_list_timer, SIGNAL(timeout()), this, SLOT(refresh_config_list())); + config_list_timer.start(1000 * 3); tie_setting(s.tracker_dll, ui.iconcomboTrackerSource); tie_setting(s.protocol_dll, ui.iconcomboProtocol); @@ -76,7 +78,6 @@ MainWindow::MainWindow() : profile_menu.addAction("Create new empty config", this, SLOT(make_empty_config())); profile_menu.addAction("Create new copied config", this, SLOT(make_copied_config())); profile_menu.addAction("Open configuration directory", this, SLOT(open_config_directory())); - profile_menu.addAction("Refresh configuration list", this, SLOT(refresh_config_list())); ui.profile_button->setMenu(&profile_menu); kbd_quit.setEnabled(true); @@ -201,6 +202,9 @@ extern "C" volatile const char* opentrack_version; void MainWindow::refresh_config_list() { + if (work) + return; + if (group::ini_list().size() == 0) { QFile filename(group::ini_directory() + "/" OPENTRACK_DEFAULT_CONFIG); diff --git a/facetracknoir/ui.h b/facetracknoir/ui.h index 6d15e496..46a97b3f 100644 --- a/facetracknoir/ui.h +++ b/facetracknoir/ui.h @@ -40,6 +40,7 @@ class MainWindow : public QMainWindow, private State mem tray; QTimer pose_update_timer; QTimer det_timer; + QTimer config_list_timer; mem options_widget; mem mapping_widget; QShortcut kbd_quit; -- cgit v1.2.3 From df9c024b596d74b02341387577fd0ea1d95d6c78 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 26 Aug 2015 08:39:59 +0200 Subject: ui: also bail on new config if its name is ".ini" --- facetracknoir/new_file_dialog.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/facetracknoir/new_file_dialog.h b/facetracknoir/new_file_dialog.h index d72b8741..3a35cf71 100644 --- a/facetracknoir/new_file_dialog.h +++ b/facetracknoir/new_file_dialog.h @@ -36,7 +36,7 @@ private slots: text = text.replace('\\', ""); if (text != "" && !text.endsWith(".ini")) text += ".ini"; - if (text == "" || QFile(options::group::ini_directory() + "/" + text).exists()) + if (text == "" || text == ".ini" || QFile(options::group::ini_directory() + "/" + text).exists()) { QMessageBox::warning(this, "File exists", "This file already exists. Pick another name.", -- cgit v1.2.3 From fa374bca7b8e034987e96fa3d3f87c63d36a407f Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 26 Aug 2015 08:40:07 +0200 Subject: ui: decruft --- facetracknoir/ui.cpp | 33 +++------------------------------ 1 file changed, 3 insertions(+), 30 deletions(-) diff --git a/facetracknoir/ui.cpp b/facetracknoir/ui.cpp index 3d768d8b..9e1d477c 100644 --- a/facetracknoir/ui.cpp +++ b/facetracknoir/ui.cpp @@ -95,13 +95,7 @@ MainWindow::MainWindow() : if (!QFile(pathname).exists()) { QFile file(pathname); - if (file.open(QFile::ReadWrite)) - { -#if 0 - QTextStream stream(&file); - stream << "\n"; -#endif - } + (void) file.open(QFile::ReadWrite); } } } @@ -164,14 +158,7 @@ void MainWindow::make_empty_config() if (dir != "" && get_new_config_name_from_dialog(name)) { QFile filename(dir + "/" + name); - if (filename.open(QFile::ReadWrite)) - { -#if 0 - QTextStream stream(&filename); - stream << "\n"; -#endif - refresh_config_list(); - } + (void) filename.open(QFile::ReadWrite); } } @@ -208,13 +195,7 @@ void MainWindow::refresh_config_list() if (group::ini_list().size() == 0) { QFile filename(group::ini_directory() + "/" OPENTRACK_DEFAULT_CONFIG); - if (filename.open(QFile::ReadWrite)) - { -#if 0 - QTextStream stream(&filename); - stream << "\n"; -#endif - } + (void) filename.open(QFile::ReadWrite); } QStringList ini_list = group::ini_list(); @@ -370,14 +351,6 @@ void MainWindow::showHeadPose() work->tracker->get_raw_and_mapped_poses(mapped, raw); display_pose(mapped, raw); - -#if 0 - if (libs.pProtocol) - { - const QString name = libs.pProtocol->game_name(); - ui.game_name->setText(name); - } -#endif } template -- cgit v1.2.3 From 7e7691f67e4e276a40a52f80735ff6875351a218 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 26 Aug 2015 09:41:11 +0200 Subject: ui: switch to newly-created config --- facetracknoir/ui.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/facetracknoir/ui.cpp b/facetracknoir/ui.cpp index 9e1d477c..6aa47fb6 100644 --- a/facetracknoir/ui.cpp +++ b/facetracknoir/ui.cpp @@ -159,6 +159,8 @@ void MainWindow::make_empty_config() { QFile filename(dir + "/" + name); (void) filename.open(QFile::ReadWrite); + refresh_config_list(); + ui.iconcomboProfile->setCurrentText(name); } } @@ -173,6 +175,7 @@ void MainWindow::make_copied_config() (void) QFile::remove(new_name); (void) QFile::copy(cur, new_name); refresh_config_list(); + ui.iconcomboProfile->setCurrentText(name); } } -- cgit v1.2.3 From b942fcf2224a3e59ea3dabb3d5c9eca9ba68d16f Mon Sep 17 00:00:00 2001 From: Xavier Hallade Date: Wed, 26 Aug 2015 15:10:30 +0200 Subject: tracker_rs: prevent potential thread starvation --- ftnoir_tracker_rs/ftnoir_tracker_rs.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ftnoir_tracker_rs/ftnoir_tracker_rs.cpp b/ftnoir_tracker_rs/ftnoir_tracker_rs.cpp index 8fa46df2..a9a50963 100644 --- a/ftnoir_tracker_rs/ftnoir_tracker_rs.cpp +++ b/ftnoir_tracker_rs/ftnoir_tracker_rs.cpp @@ -50,8 +50,10 @@ void RSTracker::readPendingUdpPoseData(){ while(mSocket.hasPendingDatagrams()) { mSocket.readDatagram((char*)pose, sizeof(pose)); - QMutexLocker foo(&mMutex); - memcpy(mPose, pose, sizeof(pose)); + { + QMutexLocker foo(&mMutex); + memcpy(mPose, pose, sizeof(pose)); + } } } -- cgit v1.2.3 From 4b9e2b009fbc290d5108b8a83010dcbf2c5841e2 Mon Sep 17 00:00:00 2001 From: Xavier Hallade Date: Wed, 26 Aug 2015 17:36:04 +0200 Subject: tracker_rs: more readable icon --- ftnoir_tracker_rs/ftnoir_tracker_rs.cpp | 10 +++++----- ftnoir_tracker_rs/images/RS.png | Bin 4287 -> 4770 bytes ftnoir_tracker_rs/images/intel-16x16.png | Bin 0 -> 637 bytes ftnoir_tracker_rs/rs_tracker.qrc | 1 + 4 files changed, 6 insertions(+), 5 deletions(-) create mode 100644 ftnoir_tracker_rs/images/intel-16x16.png diff --git a/ftnoir_tracker_rs/ftnoir_tracker_rs.cpp b/ftnoir_tracker_rs/ftnoir_tracker_rs.cpp index a9a50963..fee56fd1 100644 --- a/ftnoir_tracker_rs/ftnoir_tracker_rs.cpp +++ b/ftnoir_tracker_rs/ftnoir_tracker_rs.cpp @@ -35,8 +35,8 @@ RSTracker::RSTracker() : mPose{ 0,0,0, 0,0,0 } { connect(&mThread, &QThread::finished, &mThread, [this]{ - mRealSenseImplProcess.kill(); - mRealSenseImplProcess.waitForFinished(); + mRealSenseImplProcess.kill(); + mRealSenseImplProcess.waitForFinished(); }, Qt::DirectConnection); } @@ -85,7 +85,7 @@ void RSTracker::rsImplProcessFinished(int exitCode){ if(msgBox.clickedButton() == triggerSdkInstallation){ bool pStarted = QProcess::startDetached("clientfiles\\intel_rs_sdk_runtime_websetup_6.0.21.6598.exe --finstall=core,face3d --fnone=all"); if(!pStarted){ - QMessageBox::warning(0, "Intel® RealSenseTM Runtime Installation", "Installation process failed to start.", QMessageBox::Ok); + QMessageBox::warning(0, "Intel® RealSense™ Runtime Installation", "Installation process failed to start.", QMessageBox::Ok); } } } @@ -103,11 +103,11 @@ RSTracker::~RSTracker() { } QString RSTrackerMetaData::name() { - return QString("RealSense 3D Face Tracking"); + return QString("RealSense™ 3D Face Tracking"); } QIcon RSTrackerMetaData::icon() { - return QIcon(":/images/RS.png"); + return QIcon(":/images/intel-16x16.png"); } OPENTRACK_DECLARE_TRACKER(RSTracker, RSTrackerControls, RSTrackerMetaData) diff --git a/ftnoir_tracker_rs/images/RS.png b/ftnoir_tracker_rs/images/RS.png index bc1dfc11..4ca11aac 100644 Binary files a/ftnoir_tracker_rs/images/RS.png and b/ftnoir_tracker_rs/images/RS.png differ diff --git a/ftnoir_tracker_rs/images/intel-16x16.png b/ftnoir_tracker_rs/images/intel-16x16.png new file mode 100644 index 00000000..e985ace1 Binary files /dev/null and b/ftnoir_tracker_rs/images/intel-16x16.png differ diff --git a/ftnoir_tracker_rs/rs_tracker.qrc b/ftnoir_tracker_rs/rs_tracker.qrc index ccdda669..155a5bd1 100644 --- a/ftnoir_tracker_rs/rs_tracker.qrc +++ b/ftnoir_tracker_rs/rs_tracker.qrc @@ -1,5 +1,6 @@ images/RS.png + images/intel-16x16.png -- cgit v1.2.3 From 8adcd7acc7280c84a959db0da2d79a0ed918a1ca Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 26 Aug 2015 19:53:40 +0200 Subject: options: return .ini basename easier --- facetracknoir/ui.cpp | 4 ++-- opentrack/options.hpp | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/facetracknoir/ui.cpp b/facetracknoir/ui.cpp index 6aa47fb6..15c94bd7 100644 --- a/facetracknoir/ui.cpp +++ b/facetracknoir/ui.cpp @@ -203,7 +203,7 @@ void MainWindow::refresh_config_list() QStringList ini_list = group::ini_list(); set_title(); - QString current = QFileInfo(group::ini_pathname()).fileName(); + QString current = group::ini_filename(); ui.iconcomboProfile->clear(); for (auto x : ini_list) ui.iconcomboProfile->addItem(QIcon(":/images/settings16.png"), x); @@ -343,7 +343,7 @@ void MainWindow::set_title(const QString& game_title_) QString game_title; if (game_title_ != "") game_title = " :: " + game_title_; - QString current = QFileInfo(group::ini_pathname()).fileName(); + QString current = group::ini_filename(); setWindowTitle(const_cast(opentrack_version) + QStringLiteral(" :: ") + current + game_title); } diff --git a/opentrack/options.hpp b/opentrack/options.hpp index 8e623092..f8475877 100644 --- a/opentrack/options.hpp +++ b/opentrack/options.hpp @@ -143,6 +143,12 @@ namespace options { return ""; } + static QString ini_filename() + { + QSettings settings(OPENTRACK_ORG); + return settings.value(OPENTRACK_CONFIG_FILENAME_KEY, OPENTRACK_DEFAULT_CONFIG).toString(); + } + static QString ini_pathname() { const auto dir = ini_directory(); -- cgit v1.2.3 From a220e0af0fb7f9a8efdf24d325e5188f14d386f6 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 26 Aug 2015 19:54:02 +0200 Subject: ui: save everything before switching profiles --- facetracknoir/ui.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/facetracknoir/ui.cpp b/facetracknoir/ui.cpp index 15c94bd7..0befd813 100644 --- a/facetracknoir/ui.cpp +++ b/facetracknoir/ui.cpp @@ -195,6 +195,8 @@ void MainWindow::refresh_config_list() if (work) return; + save(); + if (group::ini_list().size() == 0) { QFile filename(group::ini_directory() + "/" OPENTRACK_DEFAULT_CONFIG); -- cgit v1.2.3 From 844d9a6f4d62227fbf22e65614c84693438080bf Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 26 Aug 2015 19:55:01 +0200 Subject: ui: don't reload settings if config wasn't changed Since combobox is reloaded on a timer, the "current" config changes all the time. --- facetracknoir/ui.cpp | 21 +++++++++++++-------- facetracknoir/ui.h | 2 +- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/facetracknoir/ui.cpp b/facetracknoir/ui.cpp index 0befd813..3c2d8db6 100644 --- a/facetracknoir/ui.cpp +++ b/facetracknoir/ui.cpp @@ -70,7 +70,7 @@ MainWindow::MainWindow() : connect(ui.btnStartTracker, SIGNAL(clicked()), this, SLOT(startTracker())); connect(ui.btnStopTracker, SIGNAL(clicked()), this, SLOT(stopTracker())); - connect(ui.iconcomboProfile, SIGNAL(currentIndexChanged(int)), this, SLOT(profileSelected(int))); + connect(ui.iconcomboProfile, SIGNAL(currentIndexChanged(int)), this, SLOT(profileSelected(int)), Qt::QueuedConnection); connect(&pose_update_timer, SIGNAL(timeout()), this, SLOT(showHeadPose())); connect(&kbd_quit, SIGNAL(activated()), this, SLOT(exit())); @@ -438,15 +438,20 @@ void MainWindow::profileSelected(int index) { if (index == -1) return; - - { - QSettings settings(OPENTRACK_ORG); - settings.setValue (OPENTRACK_CONFIG_FILENAME_KEY, ui.iconcomboProfile->itemText(index)); - } - set_title(); + const auto old_name = group::ini_filename(); + const auto new_name = ui.iconcomboProfile->itemText(index); - load_settings(); + if (old_name != new_name) + { + { + QSettings settings(OPENTRACK_ORG); + settings.setValue (OPENTRACK_CONFIG_FILENAME_KEY, new_name); + } + + set_title(); + load_settings(); + } } void MainWindow::shortcutRecentered() diff --git a/facetracknoir/ui.h b/facetracknoir/ui.h index 46a97b3f..021f327d 100644 --- a/facetracknoir/ui.h +++ b/facetracknoir/ui.h @@ -73,7 +73,7 @@ class MainWindow : public QMainWindow, private State void set_title(const QString& game_title = QStringLiteral("")); void save(); static bool get_new_config_name_from_dialog(QString &ret); - static void set_profile(const QString& profile); + void set_profile(const QString& profile); private slots: void exit(); void profileSelected(int index); -- cgit v1.2.3 From 574c13260fa00f4e55541763880284f63752e747 Mon Sep 17 00:00:00 2001 From: Xavier Hallade Date: Thu, 27 Aug 2015 09:40:51 +0200 Subject: tracker_rs: adjusted tracker's name --- ftnoir_tracker_rs/ftnoir_tracker_rs.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ftnoir_tracker_rs/ftnoir_tracker_rs.cpp b/ftnoir_tracker_rs/ftnoir_tracker_rs.cpp index fee56fd1..12330fd2 100644 --- a/ftnoir_tracker_rs/ftnoir_tracker_rs.cpp +++ b/ftnoir_tracker_rs/ftnoir_tracker_rs.cpp @@ -103,7 +103,7 @@ RSTracker::~RSTracker() { } QString RSTrackerMetaData::name() { - return QString("RealSense™ 3D Face Tracking"); + return QString("Intel® RealSense™ Technology"); } QIcon RSTrackerMetaData::icon() { -- cgit v1.2.3 From 8aac02ae5e90fe39b44f86d17098828aaea29ee8 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 27 Aug 2015 09:51:01 +0200 Subject: ui: save prior to switching configs --- facetracknoir/ui.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/facetracknoir/ui.cpp b/facetracknoir/ui.cpp index 3c2d8db6..04baaf5a 100644 --- a/facetracknoir/ui.cpp +++ b/facetracknoir/ui.cpp @@ -195,8 +195,6 @@ void MainWindow::refresh_config_list() if (work) return; - save(); - if (group::ini_list().size() == 0) { QFile filename(group::ini_directory() + "/" OPENTRACK_DEFAULT_CONFIG); @@ -444,6 +442,8 @@ void MainWindow::profileSelected(int index) if (old_name != new_name) { + save(); + { QSettings settings(OPENTRACK_ORG); settings.setValue (OPENTRACK_CONFIG_FILENAME_KEY, new_name); -- cgit v1.2.3 From 418c2f4f98ecac56098153e61e38d9694c4eb32c Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 27 Aug 2015 09:57:17 +0200 Subject: pt: fix type mismatch --- ftnoir_tracker_pt/point_extractor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ftnoir_tracker_pt/point_extractor.cpp b/ftnoir_tracker_pt/point_extractor.cpp index 65ac653a..c1dd9a54 100644 --- a/ftnoir_tracker_pt/point_extractor.cpp +++ b/ftnoir_tracker_pt/point_extractor.cpp @@ -131,7 +131,7 @@ std::vector PointExtractor::extract_points(cv::Mat& frame) ret.push_back(b_); char buf[64]; - sprintf(buf, "%d%% %d px", b_.pos.size()*100/successes, (int)(2.*sqrt(b_.effective_area()) / sqrt(3.14))); + sprintf(buf, "%d%% %d px", (int)(b_.pos.size()*100/successes), (int)(2.*sqrt(b_.effective_area()) / sqrt(3.14))); const auto pos = b_.effective_pos(); cv::putText(frame, buf, cv::Point(pos[0]+30, pos[1]+20), cv::FONT_HERSHEY_DUPLEX, 1, cv::Scalar(0, 0, 255), 1); } -- cgit v1.2.3 From 5dd01a9a8ba94a61462340446031904629d12792 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 28 Aug 2015 09:04:43 +0200 Subject: ui: really don't switch profiles while refreshing combobox --- facetracknoir/ui.cpp | 9 ++++++--- facetracknoir/ui.h | 1 + 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/facetracknoir/ui.cpp b/facetracknoir/ui.cpp index 04baaf5a..89b25fe4 100644 --- a/facetracknoir/ui.cpp +++ b/facetracknoir/ui.cpp @@ -22,7 +22,8 @@ MainWindow::MainWindow() : pose_update_timer(this), kbd_quit(QKeySequence("Ctrl+Q"), this), - no_feed_pixmap(":/images/no-feed.png") + no_feed_pixmap(":/images/no-feed.png"), + is_refreshing_profiles(false) { ui.setupUi(this); @@ -70,7 +71,7 @@ MainWindow::MainWindow() : connect(ui.btnStartTracker, SIGNAL(clicked()), this, SLOT(startTracker())); connect(ui.btnStopTracker, SIGNAL(clicked()), this, SLOT(stopTracker())); - connect(ui.iconcomboProfile, SIGNAL(currentIndexChanged(int)), this, SLOT(profileSelected(int)), Qt::QueuedConnection); + connect(ui.iconcomboProfile, SIGNAL(currentIndexChanged(int)), this, SLOT(profileSelected(int))); connect(&pose_update_timer, SIGNAL(timeout()), this, SLOT(showHeadPose())); connect(&kbd_quit, SIGNAL(activated()), this, SLOT(exit())); @@ -204,9 +205,11 @@ void MainWindow::refresh_config_list() QStringList ini_list = group::ini_list(); set_title(); QString current = group::ini_filename(); + is_refreshing_profiles = true; ui.iconcomboProfile->clear(); for (auto x : ini_list) ui.iconcomboProfile->addItem(QIcon(":/images/settings16.png"), x); + is_refreshing_profiles = false; ui.iconcomboProfile->setCurrentText(current); } @@ -434,7 +437,7 @@ void MainWindow::exit() { void MainWindow::profileSelected(int index) { - if (index == -1) + if (index == -1 || is_refreshing_profiles) return; const auto old_name = group::ini_filename(); diff --git a/facetracknoir/ui.h b/facetracknoir/ui.h index 021f327d..5d81507f 100644 --- a/facetracknoir/ui.h +++ b/facetracknoir/ui.h @@ -50,6 +50,7 @@ class MainWindow : public QMainWindow, private State mem pTrackerDialog; process_detector_worker det; QMenu profile_menu; + bool is_refreshing_profiles; mem current_tracker() { -- cgit v1.2.3 From e8a00bc862d3231824d08a5b6adcd7c0113f174e Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 28 Aug 2015 09:07:19 +0200 Subject: cmake: don't say "opentrack" twice for osx build --- macosx/make-app-bundle.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/macosx/make-app-bundle.sh b/macosx/make-app-bundle.sh index d0588ae2..1001af4a 100644 --- a/macosx/make-app-bundle.sh +++ b/macosx/make-app-bundle.sh @@ -34,7 +34,7 @@ iconutil -c icns -o "$tmp/$APPNAME.app/Contents/Resources/$APPNAME.icns" "$tmp/$ rm -r "$tmp/$APPNAME.iconset" cd "$tmp" || exit 1 -rm -f "$output_dir/$APPNAME-$version.zip" -zip -9r "$output_dir/$APPNAME-$version.zip" "$APPNAME.app" || exit 1 +rm -f "$output_dir/$version-macosx.zip" +zip -9r "$output_dir/$version-macosx.zip" "$APPNAME.app" || exit 1 rm -rf "$tmp" -ls -lh "$output_dir/$APPNAME-$version.zip" +ls -lh "$output_dir/$version-macosx.zip" -- cgit v1.2.3 From c5463fcedf2ed6e6cf75c7056071b26a3f3da08f Mon Sep 17 00:00:00 2001 From: Stanisław Halik Date: Fri, 28 Aug 2015 10:20:08 +0200 Subject: fix typo --- opentrack/plugin-api.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opentrack/plugin-api.hpp b/opentrack/plugin-api.hpp index 572b7f31..732dbb3d 100644 --- a/opentrack/plugin-api.hpp +++ b/opentrack/plugin-api.hpp @@ -42,7 +42,7 @@ signals: } // implement this in all plugins -// also you must link against "opentrack-api" in CMakeList.txt to avoid vtable link errors +// also you must link against "opentrack-api" in CMakeLists.txt to avoid vtable link errors struct Metadata { // plugin name to be displayed in the interface -- cgit v1.2.3 From e07a72493f6145b55efb305c955032ffd73e94c3 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 28 Aug 2015 12:28:29 +0200 Subject: tracker: change centering order again Needs more testing with PT and other non-inertial trackers. Issue: #227 --- opentrack/tracker.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opentrack/tracker.cpp b/opentrack/tracker.cpp index 403e87c5..c9e34c2d 100644 --- a/opentrack/tracker.cpp +++ b/opentrack/tracker.cpp @@ -134,7 +134,7 @@ void Tracker::logic() { double tmp[3] = { t(0) - t_b[0], t(1) - t_b[1], t(2) - t_b[2] }; t_compensate(cam, tmp, tmp, false); - const rmat m_ = r_b.t() * r; + const rmat m_ = r * r_b.t(); const dmat<3, 1> euler = rmat::rmat_to_euler(m_); for (int i = 0; i < 3; i++) { -- cgit v1.2.3 From f3708cf6a85f4447e2333642453a4a0232986942 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 28 Aug 2015 13:49:29 +0200 Subject: save axis opts, not just spline control points This caused the "invert axis got switched on" bug. --- opentrack/main-settings.hpp | 2 ++ opentrack/mappings.hpp | 3 +++ 2 files changed, 5 insertions(+) diff --git a/opentrack/main-settings.hpp b/opentrack/main-settings.hpp index 8c49f86a..b973e7af 100644 --- a/opentrack/main-settings.hpp +++ b/opentrack/main-settings.hpp @@ -15,10 +15,12 @@ using namespace options; struct axis_opts { + pbundle b; value zero; value invert, altp; value src; axis_opts(pbundle b, QString pfx, int idx) : + b(b), zero(b, n(pfx, "zero-pos"), 0), invert(b, n(pfx, "invert-sign"), false), altp(b, n(pfx, "alt-axis-sign"), false), diff --git a/opentrack/mappings.hpp b/opentrack/mappings.hpp index 85d9900c..2391efd1 100644 --- a/opentrack/mappings.hpp +++ b/opentrack/mappings.hpp @@ -62,6 +62,7 @@ public: { axes[i].curve.loadSettings(*iniFile, axes[i].name1); axes[i].curveAlt.loadSettings(*iniFile, axes[i].name2); + axes[i].opts.b->reload(); } } void save_mappings() @@ -72,6 +73,7 @@ public: { axes[i].curve.saveSettings(*iniFile, axes[i].name1); axes[i].curveAlt.saveSettings(*iniFile, axes[i].name2); + axes[i].opts.b->save(); } } @@ -81,6 +83,7 @@ public: { axes[i].curve.invalidate_unsaved_settings(); axes[i].curveAlt.invalidate_unsaved_settings(); + axes[i].opts.b->reload(); } } }; -- cgit v1.2.3 From 303f621e3091e2bbe12f6a5e2e35310f6e9b0701 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 28 Aug 2015 13:51:41 +0200 Subject: no need to save on tracking start anymore --- facetracknoir/ui.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/facetracknoir/ui.cpp b/facetracknoir/ui.cpp index 89b25fe4..a600543c 100644 --- a/facetracknoir/ui.cpp +++ b/facetracknoir/ui.cpp @@ -234,7 +234,6 @@ void MainWindow::reload_options() } void MainWindow::startTracker() { - s.b->save(); load_settings(); // tracker dtor needs run first -- cgit v1.2.3 From 5090466908ddf92b7566f4215985c2e7d7dc93d7 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 28 Aug 2015 14:24:41 +0200 Subject: qfc: also draw line from function start while moving --- qfunctionconfigurator/qfunctionconfigurator.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/qfunctionconfigurator/qfunctionconfigurator.cpp b/qfunctionconfigurator/qfunctionconfigurator.cpp index a977af77..d9cf6d52 100644 --- a/qfunctionconfigurator/qfunctionconfigurator.cpp +++ b/qfunctionconfigurator/qfunctionconfigurator.cpp @@ -162,6 +162,8 @@ void QFunctionConfigurator::paintEvent(QPaintEvent *e) QPen pen(Qt::white, 1, Qt::SolidLine); QList points = _config->getPoints(); if (points.size() && moving_control_point_idx >= 0 && moving_control_point_idx < points.size()) { + if (points[0].x() > 1e-2) + points.prepend(QPointF(0, 0)); QPointF prev = point_to_pixel(points[0]); for (int i = 1; i < points.size(); i++) { auto tmp = point_to_pixel(points[i]); -- cgit v1.2.3 From 6c5c26e914c2f515f1ca678fa32ab78750b8a4b5 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 30 Aug 2015 06:26:03 +0200 Subject: win32-joystick: allow for unique selection of joysticks Distinguish joystick GUIDs to allow selecting one of several with the same name. Issue: #230 --- .../ftnoir_tracker_joystick.cpp | 34 ++++++++++++++++++++-- ftnoir_tracker_joystick/ftnoir_tracker_joystick.h | 16 +++++++++- .../ftnoir_tracker_joystick_dialog.cpp | 4 ++- 3 files changed, 50 insertions(+), 4 deletions(-) diff --git a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp index 45cf2f10..ac374aa8 100644 --- a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp +++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp @@ -82,6 +82,17 @@ static BOOL CALLBACK EnumJoysticksCallback( const DIDEVICEINSTANCE* pdidInstance if (stop) { + if (self->guid_to_check.size()) + { + QString guid = guid_to_string(pdidInstance->guidInstance); + if (guid != self->guid_to_check) + { + return DIENUM_CONTINUE; + } + else + qDebug() << "guid ok" << self->guid_to_check; + } + (void) self->g_pDI->CreateDevice( pdidInstance->guidInstance, &self->g_pJoystick, NULL); qDebug() << "device" << static_cast(self->s.joyid); } @@ -103,13 +114,32 @@ void FTNoIR_Tracker::start_tracker(QFrame* frame) goto fail; } + guid_to_check = s.guid; + if( FAILED( hr = g_pDI->EnumDevices( DI8DEVCLASS_GAMECTRL, EnumJoysticksCallback, this, DIEDFL_ATTACHEDONLY))) { - qDebug() << "enum2"; - goto fail; + if (guid_to_check.isEmpty()) + { + qDebug() << "enum1"; + goto fail; + } + } + + if (!g_pJoystick && guid_to_check.size()) + { + guid_to_check = ""; + + if( FAILED( hr = g_pDI->EnumDevices( DI8DEVCLASS_GAMECTRL, + EnumJoysticksCallback, + this, + DIEDFL_ATTACHEDONLY))) + { + qDebug() << "enum2"; + goto fail; + } } if (!g_pJoystick) diff --git a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h index 0958246a..ab32ec56 100644 --- a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h +++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h @@ -30,11 +30,12 @@ using namespace options; struct settings : opts { - value joyid; + value joyid, guid; value joy_1, joy_2, joy_3, joy_4, joy_5, joy_6; settings() : opts("tracker-joystick"), joyid(b, "joy-id", ""), + guid(b, "joy-guid", ""), joy_1(b, "axis-map-1", 1), joy_2(b, "axis-map-2", 2), joy_3(b, "axis-map-3", 3), @@ -44,6 +45,18 @@ struct settings : opts { {} }; +template +QString guid_to_string(const GUID guid) +{ + char buf[40] = {0}; + wchar_t szGuidW[40] = {0}; + + StringFromGUID2(guid, szGuidW, 40); + WideCharToMultiByte(0, 0, szGuidW, -1, buf, 40, NULL, NULL); + + return QString(buf); +} + class FTNoIR_Tracker : public ITracker { public: @@ -59,6 +72,7 @@ public: DIDEVICEINSTANCE def; int iter; // XXX bad style settings s; + QString guid_to_check; static constexpr int AXIS_MAX = 65535; }; diff --git a/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp b/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp index 7200003c..88074fef 100644 --- a/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp +++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp @@ -6,7 +6,8 @@ static BOOL CALLBACK EnumJoysticksCallback( const DIDEVICEINSTANCE* pdidInstance auto self = ( TrackerControls* )pContext; self->guids.push_back(pdidInstance->guidInstance); - self->ui.joylist->addItem(QString(pdidInstance->tszInstanceName)); + self->ui.joylist->addItem(QString(pdidInstance->tszInstanceName), + guid_to_string(pdidInstance->guidInstance)); return DIENUM_CONTINUE; } @@ -49,6 +50,7 @@ fin: } void TrackerControls::doOK() { + s.guid = ui.joylist->currentData().toString(); s.b->save(); if (tracker) tracker->reload(); -- cgit v1.2.3 From a224ffabfedd0f90f8412c63a95bcdefaa6897d9 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 30 Aug 2015 06:41:29 +0200 Subject: win32-joystick: nix unused variable --- ftnoir_tracker_joystick/ftnoir_tracker_joystick.h | 1 - ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp | 1 - 2 files changed, 2 deletions(-) diff --git a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h index ab32ec56..76bafbd4 100644 --- a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h +++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h @@ -83,7 +83,6 @@ public: TrackerControls(); void register_tracker(ITracker *) {} void unregister_tracker() {} - QList guids; Ui::UIJoystickControls ui; FTNoIR_Tracker* tracker; settings s; diff --git a/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp b/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp index 88074fef..f3b7077c 100644 --- a/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp +++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp @@ -5,7 +5,6 @@ static BOOL CALLBACK EnumJoysticksCallback( const DIDEVICEINSTANCE* pdidInstance { auto self = ( TrackerControls* )pContext; - self->guids.push_back(pdidInstance->guidInstance); self->ui.joylist->addItem(QString(pdidInstance->tszInstanceName), guid_to_string(pdidInstance->guidInstance)); -- cgit v1.2.3 From 22bde7a4fd6eb48cdcdde61d86ca193abd054699 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 30 Aug 2015 06:49:10 +0200 Subject: win32-joystick: fix COM failure path Device enumeration only fails for internal reasons. Not finding the device is not one of them. --- ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp index ac374aa8..77fd7241 100644 --- a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp +++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp @@ -121,11 +121,8 @@ void FTNoIR_Tracker::start_tracker(QFrame* frame) this, DIEDFL_ATTACHEDONLY))) { - if (guid_to_check.isEmpty()) - { - qDebug() << "enum1"; - goto fail; - } + qDebug() << "enum1"; + goto fail; } if (!g_pJoystick && guid_to_check.size()) -- cgit v1.2.3 From be000a8a9aad1d6804ee27b02b12b531029427cb Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 30 Aug 2015 08:46:03 +0200 Subject: ui: save current tracker/filter/proto, not last Current tracker/filter/proto name depends on the currentTextChanged() slot. currentIndexChanged() runs before currentText() is updated, causing the old name to be saved. --- facetracknoir/ui.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/facetracknoir/ui.cpp b/facetracknoir/ui.cpp index a600543c..7b84de72 100644 --- a/facetracknoir/ui.cpp +++ b/facetracknoir/ui.cpp @@ -58,16 +58,16 @@ MainWindow::MainWindow() : tie_setting(s.filter_dll, ui.iconcomboFilter); connect(ui.iconcomboTrackerSource, - static_cast(&QComboBox::currentIndexChanged), - [&](int) -> void { if (pTrackerDialog) pTrackerDialog = nullptr; save(); }); + &QComboBox::currentTextChanged, + [&](QString) -> void { if (pTrackerDialog) pTrackerDialog = nullptr; save(); }); connect(ui.iconcomboProtocol, - static_cast(&QComboBox::currentIndexChanged), - [&](int) -> void { if (pProtocolDialog) pProtocolDialog = nullptr; save(); }); + &QComboBox::currentTextChanged, + [&](QString) -> void { if (pProtocolDialog) pProtocolDialog = nullptr; save(); }); connect(ui.iconcomboFilter, - static_cast(&QComboBox::currentIndexChanged), - [&](int) -> void { if (pFilterDialog) pFilterDialog = nullptr; save(); }); + &QComboBox::currentTextChanged, + [&](QString) -> void { if (pFilterDialog) pFilterDialog = nullptr; save(); }); connect(ui.btnStartTracker, SIGNAL(clicked()), this, SLOT(startTracker())); connect(ui.btnStopTracker, SIGNAL(clicked()), this, SLOT(stopTracker())); -- cgit v1.2.3 From 8b08d5800354a5dcedfd7811447ea76e09c31d03 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 30 Aug 2015 08:48:24 +0200 Subject: ui: save profile when combobox text changes, not merely index --- facetracknoir/ui.cpp | 8 ++++---- facetracknoir/ui.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/facetracknoir/ui.cpp b/facetracknoir/ui.cpp index 7b84de72..0c104553 100644 --- a/facetracknoir/ui.cpp +++ b/facetracknoir/ui.cpp @@ -71,7 +71,7 @@ MainWindow::MainWindow() : connect(ui.btnStartTracker, SIGNAL(clicked()), this, SLOT(startTracker())); connect(ui.btnStopTracker, SIGNAL(clicked()), this, SLOT(stopTracker())); - connect(ui.iconcomboProfile, SIGNAL(currentIndexChanged(int)), this, SLOT(profileSelected(int))); + connect(ui.iconcomboProfile, SIGNAL(currentTextChanged(QString)), this, SLOT(profileSelected(QString))); connect(&pose_update_timer, SIGNAL(timeout()), this, SLOT(showHeadPose())); connect(&kbd_quit, SIGNAL(activated()), this, SLOT(exit())); @@ -434,13 +434,13 @@ void MainWindow::exit() { QCoreApplication::exit(0); } -void MainWindow::profileSelected(int index) +void MainWindow::profileSelected(QString name) { - if (index == -1 || is_refreshing_profiles) + if (name == "" || is_refreshing_profiles) return; const auto old_name = group::ini_filename(); - const auto new_name = ui.iconcomboProfile->itemText(index); + const auto new_name = name; if (old_name != new_name) { diff --git a/facetracknoir/ui.h b/facetracknoir/ui.h index 5d81507f..65a7647a 100644 --- a/facetracknoir/ui.h +++ b/facetracknoir/ui.h @@ -77,7 +77,7 @@ class MainWindow : public QMainWindow, private State void set_profile(const QString& profile); private slots: void exit(); - void profileSelected(int index); + void profileSelected(QString name); void showTrackerSettings(); void showProtocolSettings(); -- cgit v1.2.3 From 1dae49c90d62d7f0f627e1ac2401b94a2c67775a Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 30 Aug 2015 08:46:18 +0200 Subject: ui: no need to reset settings on tracking start --- facetracknoir/ui.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/facetracknoir/ui.cpp b/facetracknoir/ui.cpp index 0c104553..32ca3e4b 100644 --- a/facetracknoir/ui.cpp +++ b/facetracknoir/ui.cpp @@ -234,8 +234,6 @@ void MainWindow::reload_options() } void MainWindow::startTracker() { - load_settings(); - // tracker dtor needs run first work = nullptr; -- cgit v1.2.3 From 4ad662d67bb12feed12095cd9a41a46bfac16d1c Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 30 Aug 2015 08:52:59 +0200 Subject: win32-joystick: fix duplicate device name selection logic Tested-by: @nanospork Closes #230 --- ftnoir_tracker_joystick/ftnoir_tracker_joystick.h | 6 ++++ .../ftnoir_tracker_joystick_controls.ui | 38 +++++++++++++++++++++- .../ftnoir_tracker_joystick_dialog.cpp | 15 ++++++--- 3 files changed, 53 insertions(+), 6 deletions(-) diff --git a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h index 76bafbd4..75305f07 100644 --- a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h +++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h @@ -14,6 +14,7 @@ #include #include #include +#include #include #include "opentrack/plugin-api.hpp" #ifndef DIRECTINPUT_VERSION @@ -86,6 +87,11 @@ public: Ui::UIJoystickControls ui; FTNoIR_Tracker* tracker; settings s; + struct joys { + QString name; + QString guid; + }; + QList _joys; private slots: void doOK(); void doCancel(); diff --git a/ftnoir_tracker_joystick/ftnoir_tracker_joystick_controls.ui b/ftnoir_tracker_joystick/ftnoir_tracker_joystick_controls.ui index 3533f93d..88737023 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 - 251 + 498 303 @@ -79,6 +79,12 @@ + + + 0 + 0 + + 1 @@ -131,6 +137,12 @@ + + + 0 + 0 + + 2 @@ -183,6 +195,12 @@ + + + 0 + 0 + + 3 @@ -235,6 +253,12 @@ + + + 0 + 0 + + 4 @@ -287,6 +311,12 @@ + + + 0 + 0 + + 5 @@ -339,6 +369,12 @@ + + + 0 + 0 + + 6 diff --git a/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp b/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp index f3b7077c..0463933f 100644 --- a/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp +++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp @@ -4,9 +4,12 @@ static BOOL CALLBACK EnumJoysticksCallback( const DIDEVICEINSTANCE* pdidInstance, VOID* pContext ) { auto self = ( TrackerControls* )pContext; + auto name = QString(pdidInstance->tszInstanceName); + auto guid = guid_to_string(pdidInstance->guidInstance); + TrackerControls::joys cur { name, guid }; + self->_joys.append(cur); - self->ui.joylist->addItem(QString(pdidInstance->tszInstanceName), - guid_to_string(pdidInstance->guidInstance)); + self->ui.joylist->addItem(name + " " + guid); return DIENUM_CONTINUE; } @@ -38,8 +41,6 @@ fin: g_pDI->Release(); } - tie_setting(s.joyid, ui.joylist); - tie_setting(s.joy_1, ui.joy_1); tie_setting(s.joy_2, ui.joy_2); tie_setting(s.joy_3, ui.joy_3); @@ -49,7 +50,11 @@ fin: } void TrackerControls::doOK() { - s.guid = ui.joylist->currentData().toString(); + int idx = ui.joylist->currentIndex(); + joys def { "", "" }; + auto val = _joys.value(idx, def); + s.guid = val.guid; + s.joyid = val.name; s.b->save(); if (tracker) tracker->reload(); -- cgit v1.2.3 From 427bb340f62de2dd9924ced702e7ed140357b5e6 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 30 Aug 2015 08:53:42 +0200 Subject: aruco: tune min/max marker size False detections are a problem sometimes. --- 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 fa783fe9..570c2e0d 100644 --- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp +++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp @@ -167,8 +167,8 @@ void Tracker::run() std::vector< aruco::Marker > markers; - const double size_min = 0.02; - const double size_max = 0.4; + const double size_min = 0.05; + const double size_max = 0.3; bool roi_valid = false; -- cgit v1.2.3 From f281b514b060a2225702b2e7c9420b73d0b2bb72 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 30 Aug 2015 09:27:33 +0200 Subject: ui: show a warning if configuration directory can't be used --- facetracknoir/ui.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/facetracknoir/ui.cpp b/facetracknoir/ui.cpp index 32ca3e4b..0876c848 100644 --- a/facetracknoir/ui.cpp +++ b/facetracknoir/ui.cpp @@ -99,6 +99,12 @@ MainWindow::MainWindow() : (void) file.open(QFile::ReadWrite); } } + + if (group::ini_directory() == "") + QMessageBox::warning(this, + "Configuration not saved.", + "Can't create configuration directory! Expect major malfunction.", + QMessageBox::Ok, QMessageBox::NoButton); } bool MainWindow::get_new_config_name_from_dialog(QString& ret) -- cgit v1.2.3 From 77542be46d3b56c48735f72d7345a1f1034a0a90 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 30 Aug 2015 09:28:22 +0200 Subject: ui: save settings on a timer The QSettings IO is damn slow on Windows. Save only after five seconds have elapsed with nothing being changed. --- facetracknoir/ui.cpp | 15 +++++++++++++-- facetracknoir/ui.h | 4 +++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/facetracknoir/ui.cpp b/facetracknoir/ui.cpp index 0876c848..6437b9d1 100644 --- a/facetracknoir/ui.cpp +++ b/facetracknoir/ui.cpp @@ -76,6 +76,9 @@ MainWindow::MainWindow() : connect(&pose_update_timer, SIGNAL(timeout()), this, SLOT(showHeadPose())); connect(&kbd_quit, SIGNAL(activated()), this, SLOT(exit())); + save_timer.setSingleShot(true); + connect(&save_timer, SIGNAL(timeout()), this, SLOT(_save())); + profile_menu.addAction("Create new empty config", this, SLOT(make_empty_config())); profile_menu.addAction("Create new copied config", this, SLOT(make_copied_config())); profile_menu.addAction("Open configuration directory", this, SLOT(open_config_directory())); @@ -116,10 +119,12 @@ bool MainWindow::get_new_config_name_from_dialog(QString& ret) MainWindow::~MainWindow() { + save_timer.stop(); + if (tray) tray->hide(); stopTracker(); - save(); + _save(); } void MainWindow::set_working_directory() @@ -131,7 +136,13 @@ void MainWindow::save_mappings() { pose.save_mappings(); } -void MainWindow::save() { +void MainWindow::save() +{ + save_timer.stop(); + save_timer.start(5000); +} + +void MainWindow::_save() { s.b->save(); save_mappings(); mem settings = group::ini_file(); diff --git a/facetracknoir/ui.h b/facetracknoir/ui.h index 65a7647a..cfaf47cb 100644 --- a/facetracknoir/ui.h +++ b/facetracknoir/ui.h @@ -51,6 +51,7 @@ class MainWindow : public QMainWindow, private State process_detector_worker det; QMenu profile_menu; bool is_refreshing_profiles; + QTimer save_timer; mem current_tracker() { @@ -72,10 +73,11 @@ class MainWindow : public QMainWindow, private State void display_pose(const double* mapped, const double* raw); void ensure_tray(); void set_title(const QString& game_title = QStringLiteral("")); - void save(); static bool get_new_config_name_from_dialog(QString &ret); void set_profile(const QString& profile); private slots: + void _save(); + void save(); void exit(); void profileSelected(QString name); -- cgit v1.2.3 From b9df697d6de0bd1ba4e9fbb40a7b3a5ab8e7cfdd Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 31 Aug 2015 05:12:23 +0200 Subject: simple-mat: add __restrict for GNU --- opentrack/simple-mat.hpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/opentrack/simple-mat.hpp b/opentrack/simple-mat.hpp index c603a2cb..e462812b 100644 --- a/opentrack/simple-mat.hpp +++ b/opentrack/simple-mat.hpp @@ -52,6 +52,9 @@ namespace { template class Mat { +#ifdef __GNUC__ + __restrict +#endif num data[h_][w_]; static_assert(h_ > 0 && w_ > 0, "must have positive mat dimensions"); -- cgit v1.2.3 From 530debcb9e55dfbbb83dee215d28bbdc7e7f4af9 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 31 Aug 2015 05:45:57 +0200 Subject: pose-widget: add comment --- pose-widget/glwidget.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pose-widget/glwidget.cpp b/pose-widget/glwidget.cpp index 8bf169df..61b88b80 100644 --- a/pose-widget/glwidget.cpp +++ b/pose-widget/glwidget.cpp @@ -162,6 +162,8 @@ void GLWidget::project_quad_texture() { vec2 pos(x, y); for (int i = 0; i < 2; i++) { vec2 uv; + // XXX knowing center of the lookup pos, + // we have symmetry so only one lookup is needed -sh 20150831 if (triangles[i].barycentric_coords(pos, uv)) { const int px = origs[i][0].x() -- cgit v1.2.3 From a96479b20513716114cffbd414c7868118304a71 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 31 Aug 2015 07:34:29 +0200 Subject: freepie-udp: nix harmless warning --- ftnoir_tracker_freepie-udp/ftnoir_tracker_freepie-udp.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/ftnoir_tracker_freepie-udp/ftnoir_tracker_freepie-udp.cpp b/ftnoir_tracker_freepie-udp/ftnoir_tracker_freepie-udp.cpp index 1525e3c4..12cf9bca 100644 --- a/ftnoir_tracker_freepie-udp/ftnoir_tracker_freepie-udp.cpp +++ b/ftnoir_tracker_freepie-udp/ftnoir_tracker_freepie-udp.cpp @@ -104,6 +104,7 @@ void TrackerImpl::run() { void TrackerImpl::start_tracker(QFrame*) { start(); + sock.moveToThread(this); } void TrackerImpl::data(double *data) -- cgit v1.2.3 From ade85a7c5cd9ece75e0f1dbadf6417b71198fb38 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 31 Aug 2015 07:34:52 +0200 Subject: pose-widget: simplify --- pose-widget/glwidget.cpp | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/pose-widget/glwidget.cpp b/pose-widget/glwidget.cpp index 61b88b80..2cb858d7 100644 --- a/pose-widget/glwidget.cpp +++ b/pose-widget/glwidget.cpp @@ -105,11 +105,8 @@ void GLWidget::project_quad_texture() { vec3(sx-1, sy-1, 0.) }; - for (int i = 0; i < 4; i++) { - pt[i] = project(vec3(corners[i].x() - sx/2, corners[i].y() - sy/2, 0)); - pt[i].x() += sx/2.; - pt[i].y() += sy/2.; - } + for (int i = 0; i < 4; i++) + pt[i] = project(vec3(corners[i].x() - sx/2, corners[i].y() - sy/2, 0)) + vec2(sx/2, sy/2); vec3 normal1(0, 0, 1); vec3 normal2; @@ -126,15 +123,11 @@ void GLWidget::project_quad_texture() { int ow = tex.width(), oh = tex.height(); - vec2 p2[4]; - - for (int i = 0; i < 4; i++) - p2[i] = vec2(pt[i].x(), pt[i].y()); QImage texture(QSize(sx, sy), QImage::Format_RGB888); QColor bgColor = palette().color(QPalette::Current, QPalette::Window); texture.fill(bgColor); - const vec2 projected[2][3] = { { p2[0], p2[1], p2[2] }, { p2[3], p2[1], p2[2] } }; + const vec2 projected[2][3] = { { pt[0], pt[1], pt[2] }, { pt[3], pt[1], pt[2] } }; const vec2 origs[2][3] = { { vec2(0, 0), vec2(ow-1, 0), vec2(0, oh-1) }, { vec2(ow-1, oh-1), vec2(ow-1, 0), vec2(0, oh-1) } -- cgit v1.2.3 From 9a8fde2d6dbd4aad8fa15b50fb4f8483202dbcb4 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Mon, 31 Aug 2015 07:54:58 +0200 Subject: accela: slightly more linear function --- 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 cb5f1fa5..0f367fca 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela.cpp @@ -13,7 +13,7 @@ static constexpr double rot_gains[][2] = { { 2.66, 110 }, - { 2.0, 50 }, + { 2.0, 52 }, { 1.66, 29 }, { 1.33, 15 }, { 1, 6 }, -- cgit v1.2.3 From 66054ee6ccd0e86534c42167d9e93704f7995db8 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 3 Sep 2015 09:33:19 +0200 Subject: ui: force saving if saving timer is pending Force saving when tracking is stopping at least. Due to "struct work" being destroyed, unsaved settings revert to last saved. So before "struct work" destruction need to save if save is pending. Issue: #179 --- facetracknoir/ui.cpp | 13 ++++++++++++- facetracknoir/ui.h | 1 + 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/facetracknoir/ui.cpp b/facetracknoir/ui.cpp index 6437b9d1..4d93f3b2 100644 --- a/facetracknoir/ui.cpp +++ b/facetracknoir/ui.cpp @@ -124,7 +124,7 @@ MainWindow::~MainWindow() if (tray) tray->hide(); stopTracker(); - _save(); + maybe_save(); } void MainWindow::set_working_directory() @@ -142,6 +142,15 @@ void MainWindow::save() save_timer.start(5000); } +void MainWindow::maybe_save() +{ + if (save_timer.isActive()) + { + save_timer.stop(); + _save(); + } +} + void MainWindow::_save() { s.b->save(); save_mappings(); @@ -307,6 +316,8 @@ void MainWindow::stopTracker( ) { if (pFilterDialog) pFilterDialog->unregister_filter(); + maybe_save(); + work = nullptr; libs = SelectedLibraries(); diff --git a/facetracknoir/ui.h b/facetracknoir/ui.h index cfaf47cb..91e4ebbf 100644 --- a/facetracknoir/ui.h +++ b/facetracknoir/ui.h @@ -75,6 +75,7 @@ class MainWindow : public QMainWindow, private State void set_title(const QString& game_title = QStringLiteral("")); static bool get_new_config_name_from_dialog(QString &ret); void set_profile(const QString& profile); + void maybe_save(); private slots: void _save(); void save(); -- cgit v1.2.3 From 3bce28ee28b3266c2a8cd871a3a891d477621ce2 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 3 Sep 2015 09:35:22 +0200 Subject: also save if save pending when start tracking Just to be safe. Issue: #179 --- facetracknoir/ui.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/facetracknoir/ui.cpp b/facetracknoir/ui.cpp index 4d93f3b2..984901f6 100644 --- a/facetracknoir/ui.cpp +++ b/facetracknoir/ui.cpp @@ -299,6 +299,8 @@ void MainWindow::startTracker() { // trackers take care of layout state updates const bool is_inertial = ui.video_frame->layout() == nullptr; updateButtonState(true, is_inertial); + + maybe_save(); } void MainWindow::stopTracker( ) { -- cgit v1.2.3 From 3c2c4488b167ee3eb469532b327901fd6c5b42db Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 3 Sep 2015 09:52:31 +0200 Subject: accela: revert to more quadratic spline at start Users report increased need for deadzone since last change. Issue: #231 --- 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 0f367fca..deb2678b 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela.cpp @@ -16,7 +16,7 @@ static constexpr double rot_gains[][2] = { { 2.0, 52 }, { 1.66, 29 }, { 1.33, 15 }, - { 1, 6 }, + { 1, 4.5 }, { .66, 1.4 }, { .33, .4 }, { 0, 0 }, -- cgit v1.2.3 From 94730c375ed347173abf927e7e05d01e7a74b668 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 3 Sep 2015 09:52:40 +0200 Subject: accela: add helpful comment --- ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp b/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp index 67f15457..3400ac92 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp @@ -43,7 +43,7 @@ FilterControls::FilterControls() : void FilterControls::register_filter(IFilter* filter) { accela_filter = static_cast(filter); - +//#define LEAKING_DEBUG #ifdef LEAKING_DEBUG auto d = new QDialog(); auto r = new QFunctionConfigurator(d); -- cgit v1.2.3 From e4f4edb4cdcb66c4c95edfa6c75911327690fd87 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 3 Sep 2015 09:53:49 +0200 Subject: accela: try more complex deadzone algorithm Submitted-by: @FlyingCircus- Issue: #231 --- ftnoir_filter_accela/ftnoir_filter_accela.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.cpp b/ftnoir_filter_accela/ftnoir_filter_accela.cpp index deb2678b..e9f60036 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela.cpp @@ -83,18 +83,31 @@ void FTNoIR_Filter::filter(const double* input, double *output) const double alpha = dt/(dt+RC); const double rot_dz = s.rot_deadzone * s.mult_rot_dz; const double trans_dz = s.trans_deadzone * s.mult_trans_dz; + + double rot_dist = 0, trans_dist = 0; + + for (int i = 3; i < 6; i++) + { + smoothed_input[i] = smoothed_input[i] * (1.-alpha) + input[i] * alpha; + rot_dist += (last_output[i] - smoothed_input[i]) * (last_output[i] - smoothed_input[i]); + } + + for (int i = 0; i < 3; i++) + { + smoothed_input[i] = smoothed_input[i] * (1.-alpha) + input[i] * alpha; + trans_dist += (last_output[i] - smoothed_input[i]) * (last_output[i] - smoothed_input[i]); + } for (int i = 0; i < 6; i++) { Map& m = i >= 3 ? rot : trans; - smoothed_input[i] = smoothed_input[i] * (1.-alpha) + input[i] * alpha; - const double in = smoothed_input[i]; const double vec = in - last_output[i]; const double dz = i >= 3 ? rot_dz : trans_dz; - const double vec_ = std::max(0., fabs(vec) - dz); + const bool use_dz = dz*dz > (i >= 3 ? rot_dist : trans_dist); + const double vec_ = use_dz ? 0. : std::max(0., fabs(vec) - dz); const double thres = i >= 3 ? rot_t : trans_t; const double val = m.getValue(vec_ / thres); const double result = last_output[i] + (vec < 0 ? -1 : 1) * dt * val; -- cgit v1.2.3 From 522c53e0f48c10fd51b9dcda195d2089b7bfd2a8 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 4 Sep 2015 06:01:58 +0200 Subject: freepie-udp: update Performance improvements in the new version --- .../freepie-udp/com.freepie.android.imu.apk | Bin 167874 -> 167989 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/clientfiles/freepie-udp/com.freepie.android.imu.apk b/clientfiles/freepie-udp/com.freepie.android.imu.apk index 11934d67..b1f052aa 100644 Binary files a/clientfiles/freepie-udp/com.freepie.android.imu.apk and b/clientfiles/freepie-udp/com.freepie.android.imu.apk differ -- cgit v1.2.3 From b853b4877632ee16d3ba3226edcfa371398e8cb0 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 4 Sep 2015 08:28:13 +0200 Subject: freepie-udp: add license --- clientfiles/freepie-udp/license.txt | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 clientfiles/freepie-udp/license.txt diff --git a/clientfiles/freepie-udp/license.txt b/clientfiles/freepie-udp/license.txt new file mode 100644 index 00000000..c40094f2 --- /dev/null +++ b/clientfiles/freepie-udp/license.txt @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright (c) 2012-2015 Anders Malmgren +Copyright (c) 2014-2015 Stanislaw Halik + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +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. -- cgit v1.2.3 From 19ccb520c0216f3e98e8d8f0ed4c504fb1c24f10 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 4 Sep 2015 10:13:25 +0200 Subject: pt: change extraction code Point size is now specified by its radius. Points are extracted in one pass, using multiple passes caused missed detection for some users. Circularity is now displayed as part of overlay. Points are now sorted by circularity, which is our confidence metric. Tracker code ignores additional points, keeping only those with the highest confidence metric. --- ftnoir_tracker_pt/ftnoir_tracker_pt.cpp | 4 + ftnoir_tracker_pt/point_extractor.cpp | 234 ++++++++++---------------------- 2 files changed, 73 insertions(+), 165 deletions(-) diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp b/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp index 4fa70ccf..19d1bd7f 100644 --- a/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp +++ b/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp @@ -93,6 +93,10 @@ void Tracker_PT::run() QMutexLocker lock(&mutex); std::vector points = point_extractor.extract_points(frame); + + // blobs are sorted in order of circularity + if (points.size() > PointModel::N_POINTS) + points.resize(PointModel::N_POINTS); bool success = points.size() == PointModel::N_POINTS; diff --git a/ftnoir_tracker_pt/point_extractor.cpp b/ftnoir_tracker_pt/point_extractor.cpp index c1dd9a54..fcdbbaed 100644 --- a/ftnoir_tracker_pt/point_extractor.cpp +++ b/ftnoir_tracker_pt/point_extractor.cpp @@ -28,215 +28,119 @@ std::vector PointExtractor::extract_points(cv::Mat& frame) cv::Mat frame_gray; cv::cvtColor(frame, frame_gray, cv::COLOR_RGB2GRAY); - int min_size = s.min_point_size; - int max_size = s.max_point_size; + const int region_size_min = s.min_point_size; + const int region_size_max = s.max_point_size; - 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; - - // testing indicates threshold difference of 45 from lowest to highest - // that's applicable to poor lighting conditions. - - static constexpr int diff = 20; - static constexpr int steps = 5; - static constexpr int successes = 5; - - int thres = s.threshold; - - struct blob { - std::vector pos; - std::vector confids; - std::vector areas; - - cv::Vec2d effective_pos() const - { - double x = 0; - double y = 0; - double norm = 0; - for (unsigned i = 0; i < pos.size(); i++) - { - const double w = confids[i] * areas[i]; - x += pos[i][0] * w; - y += pos[i][1] * w; - norm += w; - } - cv::Vec2d ret(x, y); - ret *= 1./norm; - return ret; - } - - double effective_area() const - { - double norm = 0, ret = 0; - for (unsigned i = 0; i < areas.size(); i++) - { - const double w = confids[i]; - norm += w; - ret += w * areas[i]; - } - return ret/norm; - } - }; + const int thres = s.threshold; struct simple_blob { - double radius_2; + double radius; cv::Vec2d pos; double confid; bool taken; double area; - simple_blob(double radius, const cv::Vec2d& pos, double confid, double area) : radius_2(radius*radius), pos(pos), confid(confid), taken(false), area(area) + simple_blob(double radius, const cv::Vec2d& pos, double confid, double area) : radius(radius), pos(pos), confid(confid), taken(false), area(area) { //qDebug() << "radius" << radius << "pos" << pos[0] << pos[1] << "confid" << confid; } bool inside(const simple_blob& other) { cv::Vec2d tmp = pos - other.pos; - return tmp.dot(tmp) < radius_2; - } - static std::vector merge(cv::Mat& frame, std::vector& blobs) - { -#ifdef DEBUG_EXTRACTION - static Timer t; - bool debug = t.elapsed_ms() > 100; - if (debug) t.start(); -#endif - - std::vector ret; - for (unsigned i = 0; i < blobs.size(); i++) - { - auto& b = blobs[i]; - if (b.taken) - continue; - b.taken = true; - blob b_; - b_.pos.push_back(b.pos); - b_.confids.push_back(b.confid); - b_.areas.push_back(b.area); - - for (unsigned j = i+1; j < blobs.size(); j++) - { - auto& b2 = blobs[j]; - if (b2.taken) - continue; - if (b.inside(b2) || b2.inside(b)) - { - b2.taken = true; - b_.pos.push_back(b2.pos); - b_.confids.push_back(b2.confid); - b_.areas.push_back(b2.area); - } - } - if (b_.pos.size() >= successes) - ret.push_back(b_); - - char buf[64]; - sprintf(buf, "%d%% %d px", (int)(b_.pos.size()*100/successes), (int)(2.*sqrt(b_.effective_area()) / sqrt(3.14))); - const auto pos = b_.effective_pos(); - cv::putText(frame, buf, cv::Point(pos[0]+30, pos[1]+20), cv::FONT_HERSHEY_DUPLEX, 1, cv::Scalar(0, 0, 255), 1); - } -#ifdef DEBUG_EXTRACTION - if (debug) - { - double diff = 0; - for (unsigned j = 0; j < ret.size(); j++) - { - auto& b = ret[j]; - cv::Vec2d pos = b.effective_pos(); - for (unsigned i = 0; i < b.pos.size(); i++) - { - auto tmp = pos - b.pos[i]; - diff += std::abs(tmp.dot(tmp)); - } - } - qDebug() << "diff" << diff; - } -#endif - return ret; + return sqrt(tmp.dot(tmp)) < radius; } }; // mask for everything that passes the threshold (or: the upper threshold of the hysteresis) cv::Mat frame_bin = cv::Mat::zeros(H, W, CV_8U); - const int min = std::max(0, thres - diff/2); - const int max = std::min(255, thres + diff/2); - const int step = std::max(1, diff / steps); - std::vector blobs; - - // this code is based on OpenCV SimpleBlobDetector - for (int i = min; i < max; i += step) + std::vector> contours; { cv::Mat frame_bin_; - cv::threshold(frame_gray, frame_bin_, i, 255, cv::THRESH_BINARY); + cv::threshold(frame_gray, frame_bin_, thres, 255, cv::THRESH_BINARY); frame_bin.setTo(170, frame_bin_); - - std::vector> contours; cv::findContours(frame_bin_, contours, CV_RETR_LIST, CV_CHAIN_APPROX_SIMPLE); - - int cnt = 0; - - for (auto& c : contours) + } + + int cnt = 0; + + for (auto& c : contours) + { + if (cnt++ > 30) + break; + + const auto m = cv::moments(cv::Mat(c)); + const double area = m.m00; + if (area == 0.) + continue; + const cv::Vec2d pos(m.m10 / m.m00, m.m01 / m.m00); + + double radius; +// following based on OpenCV SimpleBlobDetector { - if (cnt++ > 30) - break; - - auto m = cv::moments(cv::Mat(c)); - const double area = m.m00; - if (area == 0.) - continue; - cv::Vec2d pos(m.m10 / m.m00, m.m01 / m.m00); - if (area < region_size_min || area > region_size_max) - continue; - - double radius = 0; - + std::vector dists; for (auto& k : c) { - cv::Vec2d pos_(k.x, k.y); - cv::Vec2d tmp = pos_ - pos; - radius = std::max(radius, sqrt(1e-2 + tmp.dot(tmp))); + dists.push_back(cv::norm(pos - cv::Vec2d(k.x, k.y))); } - double confid = 1; + std::sort(dists.begin(), dists.end()); + radius = (dists[(dists.size() - 1)/2] + dists[dists.size()/2])/2; + } + + if (radius < region_size_min || radius > region_size_max) + continue; + + double confid = 1; + { + double denominator = std::sqrt(std::pow(2 * m.mu11, 2) + std::pow(m.mu20 - m.mu02, 2)); + const double eps = 1e-2; + if (denominator > eps) { - double denominator = std::sqrt(std::pow(2 * m.mu11, 2) + std::pow(m.mu20 - m.mu02, 2)); - const double eps = 1e-2; - if (denominator > eps) - { - double cosmin = (m.mu20 - m.mu02) / denominator; - double sinmin = 2 * m.mu11 / denominator; - double cosmax = -cosmin; - double sinmax = -sinmin; - - double imin = 0.5 * (m.mu20 + m.mu02) - 0.5 * (m.mu20 - m.mu02) * cosmin - m.mu11 * sinmin; - double imax = 0.5 * (m.mu20 + m.mu02) - 0.5 * (m.mu20 - m.mu02) * cosmax - m.mu11 * sinmax; - confid = imin / imax; - } + double cosmin = (m.mu20 - m.mu02) / denominator; + double sinmin = 2 * m.mu11 / denominator; + double cosmax = -cosmin; + double sinmax = -sinmin; + + double imin = 0.5 * (m.mu20 + m.mu02) - 0.5 * (m.mu20 - m.mu02) * cosmin - m.mu11 * sinmin; + double imax = 0.5 * (m.mu20 + m.mu02) - 0.5 * (m.mu20 - m.mu02) * cosmax - m.mu11 * sinmax; + confid = imin / imax; } - blobs.push_back(simple_blob(radius, pos, confid, area)); } +// end SimpleBlobDetector + + { + char buf[64]; + sprintf(buf, "%.2fpx %.2fc", radius, confid); + cv::putText(frame, buf, cv::Point(pos[0]+30, pos[1]+20), cv::FONT_HERSHEY_DUPLEX, 1, cv::Scalar(0, 0, 255), 1); + } + + blobs.push_back(simple_blob(radius, pos, confid, area)); } // clear old points points.clear(); + + using b = const simple_blob; + std::sort(blobs.begin(), blobs.end(), [](b& b1, b& b2) {return b1.confid > b2.confid;}); - for (auto& b : simple_blob::merge(frame, blobs)) + for (auto& b : blobs) { - auto pos = b.effective_pos(); - cv::Vec2f p((pos[0] - W/2)/W, -(pos[1] - H/2)/W); + cv::Vec2f p((b.pos[0] - W/2)/W, -(b.pos[1] - H/2)/W); points.push_back(p); } + // draw output image std::vector channels_; cv::split(frame, channels_); - // draw output image - cv::Mat frame_bin_ = frame_bin * .5; std::vector channels; - channels.push_back(channels_[0] + frame_bin_); - channels.push_back(channels_[1] - frame_bin_); - channels.push_back(channels_[2] - frame_bin_); - cv::merge(channels, frame); + { + cv::Mat frame_bin__ = frame_bin * .5; + channels.push_back(channels_[0] + frame_bin__); + channels.push_back(channels_[1] - frame_bin__); + channels.push_back(channels_[2] - frame_bin__); + cv::merge(channels, frame); + } return points; } -- cgit v1.2.3 From 1f8907d4a7239cf42be0135735179b8da2d414f1 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 4 Sep 2015 10:13:54 +0200 Subject: accela: change rotation gain The gain is now smaller at the start. --- ftnoir_filter_accela/ftnoir_filter_accela.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.cpp b/ftnoir_filter_accela/ftnoir_filter_accela.cpp index e9f60036..f892483e 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela.cpp @@ -12,12 +12,12 @@ #include "opentrack/plugin-api.hpp" static constexpr double rot_gains[][2] = { - { 2.66, 110 }, - { 2.0, 52 }, - { 1.66, 29 }, - { 1.33, 15 }, - { 1, 4.5 }, - { .66, 1.4 }, + { 2.66, 105 }, + { 2.0, 47 }, + { 1.66, 25 }, + { 1.33, 12 }, + { 1, 3.5 }, + { .66, 1 }, { .33, .4 }, { 0, 0 }, { -1, 0 } -- cgit v1.2.3 From e355edfab17d931d63106fb0afc7f57dfdceeb6d Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 4 Sep 2015 10:14:17 +0200 Subject: accela: change translation gain The gain is now more even throughout. It was too staircase-like. --- ftnoir_filter_accela/ftnoir_filter_accela.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.cpp b/ftnoir_filter_accela/ftnoir_filter_accela.cpp index f892483e..bf27e916 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela.cpp @@ -24,13 +24,12 @@ static constexpr double rot_gains[][2] = { }; static constexpr double trans_gains[][2] = { - { 2.33, 400 }, - { 2, 150 }, - { 1.66, 60 }, - { 1.33, 20 }, - { 1, 2 }, - { .66, .6 }, - { .33, .2 }, + { 2, 400 }, + { 1.66, 120 }, + { 1.33, 40 }, + { 1, 10 }, + { .66, 2 }, + { .33, .6 }, { 0, 0 }, { -1, 0 } }; -- cgit v1.2.3 From bed620cc85b71e5c02c86613d22624a5c12189ce Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 5 Sep 2015 07:46:47 +0200 Subject: plugin-support: workaround multiple copies of modules TrackHat dist contained two copies of every module by packaging error. Workaround similar errors by not loading more than one copy of a module at a time. Sponsored-by: TrackHat --- opentrack/plugin-support.hpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/opentrack/plugin-support.hpp b/opentrack/plugin-support.hpp index 8b9cf58a..8efda800 100644 --- a/opentrack/plugin-support.hpp +++ b/opentrack/plugin-support.hpp @@ -187,6 +187,14 @@ struct dylib { std::cout.flush(); if (!get_metadata(lib, longName, icon)) continue; + using d = const mem&; + if (std::any_of(ret.cbegin(), + ret.cend(), + [&](d a) {return a->type == lib->type && a->name == lib->name;})) + { + qDebug() << "Duplicate lib" << lib->filename; + continue; + } ret.push_back(lib); } } -- cgit v1.2.3 From 590ed20fe73848607ff40f2620c413f8ec5ac0ee Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 5 Sep 2015 08:09:50 +0200 Subject: qfc: don't allow editing when disabled Sponsored-by: TrackHat --- qfunctionconfigurator/qfunctionconfigurator.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/qfunctionconfigurator/qfunctionconfigurator.cpp b/qfunctionconfigurator/qfunctionconfigurator.cpp index d9cf6d52..144b69e1 100644 --- a/qfunctionconfigurator/qfunctionconfigurator.cpp +++ b/qfunctionconfigurator/qfunctionconfigurator.cpp @@ -40,6 +40,8 @@ void QFunctionConfigurator::drawBackground() painter.fillRect(rect(), QColor::fromRgb(204, 204, 204)); QColor bg_color(112, 154, 209); + if (!isEnabled()) + bg_color = QColor(176,176,180); painter.fillRect(pixel_bounds, bg_color); QFont font; @@ -205,7 +207,7 @@ void QFunctionConfigurator::drawLine(QPainter *painter, const QPointF &start, co void QFunctionConfigurator::mousePressEvent(QMouseEvent *e) { - if (!_config) + if (!_config || !isEnabled()) return; QList points = _config->getPoints(); if (e->button() == Qt::LeftButton) { @@ -262,7 +264,7 @@ void QFunctionConfigurator::mousePressEvent(QMouseEvent *e) void QFunctionConfigurator::mouseMoveEvent(QMouseEvent *e) { - if (!_config) + if (!_config || !isEnabled()) return; QList points = _config->getPoints(); @@ -337,7 +339,7 @@ void QFunctionConfigurator::mouseMoveEvent(QMouseEvent *e) void QFunctionConfigurator::mouseReleaseEvent(QMouseEvent *e) { - if (!_config) + if (!_config || !isEnabled()) return; if (e->button() == Qt::LeftButton) { -- cgit v1.2.3 From a1783d425448394e6962f75f7aadd22b85318c59 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 5 Sep 2015 08:10:29 +0200 Subject: qfc, mapping: disallow editing and change color when checkbox disabled Sponsored-by: TrackHat --- facetracknoir/curve-config.cpp | 36 +++++++++++++++---------- qfunctionconfigurator/qfunctionconfigurator.cpp | 3 +++ qfunctionconfigurator/qfunctionconfigurator.h | 5 ++++ 3 files changed, 30 insertions(+), 14 deletions(-) diff --git a/facetracknoir/curve-config.cpp b/facetracknoir/curve-config.cpp index e199d005..2e9065b4 100644 --- a/facetracknoir/curve-config.cpp +++ b/facetracknoir/curve-config.cpp @@ -20,23 +20,24 @@ MapWidget::MapWidget(Mappings& m, main_settings& s) : struct { QFunctionConfigurator* qfc; Axis axis; + QCheckBox* checkbox; bool altp; } qfcs[] = { - { ui.rxconfig, Yaw, false }, - { ui.ryconfig, Pitch, false}, - { ui.rzconfig, Roll, false }, - { ui.txconfig, TX, false }, - { ui.tyconfig, TY, false }, - { ui.tzconfig, TZ, false }, + { ui.rxconfig, Yaw, nullptr, false }, + { ui.ryconfig, Pitch, nullptr, false }, + { ui.rzconfig, Roll, nullptr, false }, + { ui.txconfig, TX, nullptr, false }, + { ui.tyconfig, TY, nullptr, false }, + { ui.tzconfig, TZ, nullptr, false }, - { ui.rxconfig_alt, Yaw, true }, - { ui.ryconfig_alt, Pitch, true}, - { ui.rzconfig_alt, Roll, true }, - { ui.txconfig_alt, TX, true }, - { ui.tyconfig_alt, TY, true }, - { ui.tzconfig_alt, TZ, true }, - { nullptr, Yaw, false } + { ui.rxconfig_alt, Yaw, ui.rx_altp, true }, + { ui.ryconfig_alt, Pitch, ui.ry_altp, true }, + { ui.rzconfig_alt, Roll, ui.rz_altp, true }, + { ui.txconfig_alt, TX, ui.tx_altp, true }, + { ui.tyconfig_alt, TY, ui.ty_altp, true }, + { ui.tzconfig_alt, TZ, ui.tz_altp, true }, + { nullptr, Yaw, nullptr, false } }; for (int i = 0; qfcs[i].qfc; i++) @@ -45,7 +46,14 @@ MapWidget::MapWidget(Mappings& m, main_settings& s) : Mapping& axis = m(qfcs[i].axis); Map* conf = altp ? &axis.curveAlt : &axis.curve; const auto& name = qfcs[i].altp ? axis.name2 : axis.name1; - + if (altp) + { + QFunctionConfigurator& qfc = *qfcs[i].qfc; + connect(qfcs[i].checkbox, &QCheckBox::toggled, + [&](bool f) -> void {qfc.setEnabled(f); qfc.force_redraw();}); + qfc.setEnabled(qfcs[i].checkbox->isChecked()); + qfc.force_redraw(); + } qfcs[i].qfc->setConfig(conf, name); } } diff --git a/qfunctionconfigurator/qfunctionconfigurator.cpp b/qfunctionconfigurator/qfunctionconfigurator.cpp index 144b69e1..8a61c8f6 100644 --- a/qfunctionconfigurator/qfunctionconfigurator.cpp +++ b/qfunctionconfigurator/qfunctionconfigurator.cpp @@ -151,7 +151,10 @@ void QFunctionConfigurator::paintEvent(QPaintEvent *e) QPainter p(this); if (_background.isNull()) + { + _draw_function = true; drawBackground(); + } if (_draw_function) { _draw_function = false; diff --git a/qfunctionconfigurator/qfunctionconfigurator.h b/qfunctionconfigurator/qfunctionconfigurator.h index 59c8ffeb..845dd29c 100644 --- a/qfunctionconfigurator/qfunctionconfigurator.h +++ b/qfunctionconfigurator/qfunctionconfigurator.h @@ -34,6 +34,11 @@ public: spline_color = color; update(); } + void force_redraw() + { + _background = QPixmap(); + update(); + } protected slots: void paintEvent(QPaintEvent *e); void mousePressEvent(QMouseEvent *e); -- cgit v1.2.3 From d822e4f94df79b83040660c0be7eabaa4e90b577 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 5 Sep 2015 08:26:51 +0200 Subject: qfc: more gray colors when graph is disabled Sponsored-by: TrackHat --- qfunctionconfigurator/qfunctionconfigurator.cpp | 31 ++++++++++++++++++++----- qfunctionconfigurator/qfunctionconfigurator.h | 2 +- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/qfunctionconfigurator/qfunctionconfigurator.cpp b/qfunctionconfigurator/qfunctionconfigurator.cpp index 8a61c8f6..e62049db 100644 --- a/qfunctionconfigurator/qfunctionconfigurator.cpp +++ b/qfunctionconfigurator/qfunctionconfigurator.cpp @@ -49,7 +49,12 @@ void QFunctionConfigurator::drawBackground() painter.setFont(font); QFontMetrics metrics(font); - QPen pen(QColor(55, 104, 170, 127), 1, Qt::SolidLine); + QColor color__(176, 190, 209, 127); + + if (!isEnabled()) + color__ = QColor(70, 90, 100, 96); + + QPen pen(color__, 1, Qt::SolidLine); const int xstep = 10, ystep = 10; const double maxx = _config->maxInput(); @@ -126,13 +131,27 @@ void QFunctionConfigurator::drawFunction() QList points = _config->getPoints(); + const int alpha = !isEnabled() ? 64 : 120; for (int i = 0; i < points.size(); i++) { drawPoint(&painter, point_to_pixel(points[i]), - QColor(200, 200, 210, 120)); + QColor(200, 200, 210, alpha), + isEnabled() ? QColor(50, 100, 120, 200) : QColor(200, 200, 200, 96)); + } + + QColor color = spline_color; + + if (!isEnabled()) + { + const int avg = 176; + auto color_ = color; + color = QColor(color_.red() * .5 + avg * .5, + color_.green() * .5 + avg * .5, + color_.blue() * .5 + avg * .5, + 96); } - QPen pen(spline_color, 1.2, Qt::SolidLine); + QPen pen(color, 1.2, Qt::SolidLine); const double max = _config->maxInput(); const double step = std::max(1e-2, max / 1000.); @@ -181,17 +200,17 @@ void QFunctionConfigurator::paintEvent(QPaintEvent *e) // Show that point on the graph, with some lines to assist. // This new feature is very handy for tweaking the curves! QPointF last; - if (_config->getLastPoint(last)) { + if (_config->getLastPoint(last) && isEnabled()) { QPointF pixel_pos = point_to_pixel(last); drawPoint(&p, pixel_pos, QColor(255, 0, 0, 120)); } } } -void QFunctionConfigurator::drawPoint(QPainter *painter, const QPointF &pos, QColor colBG ) +void QFunctionConfigurator::drawPoint(QPainter *painter, const QPointF &pos, QColor colBG, QColor border) { painter->save(); - painter->setPen(QColor(50, 100, 120, 200)); + painter->setPen(border); painter->setBrush( colBG ); painter->drawEllipse(QRectF(pos.x() - pointSize, pos.y() - pointSize, diff --git a/qfunctionconfigurator/qfunctionconfigurator.h b/qfunctionconfigurator/qfunctionconfigurator.h index 845dd29c..fab452a7 100644 --- a/qfunctionconfigurator/qfunctionconfigurator.h +++ b/qfunctionconfigurator/qfunctionconfigurator.h @@ -47,7 +47,7 @@ protected slots: private: void drawBackground(); void drawFunction(); - void drawPoint(QPainter *painter, const QPointF &pt, QColor colBG ); + void drawPoint(QPainter *painter, const QPointF &pt, QColor colBG, QColor border = QColor(50, 100, 120, 200)); void drawLine(QPainter *painter, const QPointF &start, const QPointF &end, QPen& pen); bool point_within_pixel(const QPointF& pt, const QPointF& pixel); protected: -- cgit v1.2.3 From 806b5a7ceb405f94bbc4bc318af2a530c1a2a0ac Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 5 Sep 2015 11:59:53 +0200 Subject: pt: add wiki link for calibration instructions --- ftnoir_tracker_pt/FTNoIR_PT_Controls.ui | 46 +++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/ftnoir_tracker_pt/FTNoIR_PT_Controls.ui b/ftnoir_tracker_pt/FTNoIR_PT_Controls.ui index 928b1374..62add856 100644 --- a/ftnoir_tracker_pt/FTNoIR_PT_Controls.ui +++ b/ftnoir_tracker_pt/FTNoIR_PT_Controls.ui @@ -1024,23 +1024,38 @@ - - - <html><head/><body><p>Only pitch and yaw during calibration.</p><p>Don't roll and don't translate.</p></body></html> - - - - - - - false - - - Toggle calibration + + + QFrame::NoFrame - - true + + QFrame::Raised + + + + + <html><head/><body><p><a href="https://github.com/opentrack/opentrack/wiki/model-calibration-for-PT-and-Aruco-trackers"><span style=" text-decoration: underline; color:#0000ff;">Instructions on the opentrack wiki</span></a></p></body></html> + + + true + + + + + + + false + + + Toggle calibration + + + true + + + + @@ -1172,7 +1187,6 @@ tx_spin ty_spin tz_spin - tcalib_button -- cgit v1.2.3 From eb7703b4ecea5540a4c4a65faa1ff4c53fe97631 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 5 Sep 2015 12:00:43 +0200 Subject: Revert "accela: try more complex deadzone algorithm" This reverts commit e4f4edb4cdcb66c4c95edfa6c75911327690fd87. --- ftnoir_filter_accela/ftnoir_filter_accela.cpp | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.cpp b/ftnoir_filter_accela/ftnoir_filter_accela.cpp index bf27e916..b9f7434f 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela.cpp @@ -82,31 +82,18 @@ void FTNoIR_Filter::filter(const double* input, double *output) const double alpha = dt/(dt+RC); const double rot_dz = s.rot_deadzone * s.mult_rot_dz; const double trans_dz = s.trans_deadzone * s.mult_trans_dz; - - double rot_dist = 0, trans_dist = 0; - - for (int i = 3; i < 6; i++) - { - smoothed_input[i] = smoothed_input[i] * (1.-alpha) + input[i] * alpha; - rot_dist += (last_output[i] - smoothed_input[i]) * (last_output[i] - smoothed_input[i]); - } - - for (int i = 0; i < 3; i++) - { - smoothed_input[i] = smoothed_input[i] * (1.-alpha) + input[i] * alpha; - trans_dist += (last_output[i] - smoothed_input[i]) * (last_output[i] - smoothed_input[i]); - } for (int i = 0; i < 6; i++) { Map& m = i >= 3 ? rot : trans; + smoothed_input[i] = smoothed_input[i] * (1.-alpha) + input[i] * alpha; + const double in = smoothed_input[i]; const double vec = in - last_output[i]; const double dz = i >= 3 ? rot_dz : trans_dz; - const bool use_dz = dz*dz > (i >= 3 ? rot_dist : trans_dist); - const double vec_ = use_dz ? 0. : std::max(0., fabs(vec) - dz); + const double vec_ = std::max(0., fabs(vec) - dz); const double thres = i >= 3 ? rot_t : trans_t; const double val = m.getValue(vec_ / thres); const double result = last_output[i] + (vec < 0 ? -1 : 1) * dt * val; -- cgit v1.2.3