From e88c7b29ea9ec9fcd6ac6b15c965085152100d2e Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 18 Jun 2017 18:19:17 +0200 Subject: get rid of "volatile" abuse We heavily used "volatile bool" to check if the thread loop should stop. But this functionality is already provided by Qt5's QThread::requestInterruption. In other cases, "volatile" is wonderfully underspecified so it's better to ditch its usage in favor of std::atomic. At the time we don't appear to be using the "volatile" keyword except when calling win32's Interlocked*() family of functions as necessary. In freetrackclient's header the "volatile" qualifier was used as part of a typedef. This doesn't work. Use it as part of data declaration. --- tracker-pt/ftnoir_tracker_pt.h | 8 +++++--- tracker-pt/point_tracker.cpp | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'tracker-pt') diff --git a/tracker-pt/ftnoir_tracker_pt.h b/tracker-pt/ftnoir_tracker_pt.h index b7b0019a..65e367f5 100644 --- a/tracker-pt/ftnoir_tracker_pt.h +++ b/tracker-pt/ftnoir_tracker_pt.h @@ -11,6 +11,8 @@ #include "api/plugin-api.hpp" #include "ftnoir_tracker_pt_settings.h" +#include + #include "numeric.hpp" #include "camera.h" @@ -79,9 +81,9 @@ private: QSize preview_size; - volatile unsigned point_count; - volatile unsigned char commands; - volatile bool ever_success; + std::atomic point_count; + std::atomic commands; + std::atomic ever_success; static constexpr f rad2deg = f(180/M_PI); //static constexpr float deg2rad = float(M_PI/180); diff --git a/tracker-pt/point_tracker.cpp b/tracker-pt/point_tracker.cpp index 8e0c28de..4022cbb2 100644 --- a/tracker-pt/point_tracker.cpp +++ b/tracker-pt/point_tracker.cpp @@ -37,7 +37,7 @@ PointModel::PointModel(settings_pt& s) set_model(s); // calculate u u = M01.cross(M02); - u /= norm(u); + u = cv::normalize(u); // calculate projection matrix on M01,M02 plane f s11 = M01.dot(M01); -- cgit v1.2.3