From a9ca349966dde20a8e9030c35c4a79f42c6e642b Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 10 Jan 2018 07:49:44 +0100 Subject: tracker/pt: cleanup --- tracker-pt/ftnoir_tracker_pt.cpp | 27 +++++++-------------------- tracker-pt/ftnoir_tracker_pt.h | 18 ++++++------------ 2 files changed, 13 insertions(+), 32 deletions(-) diff --git a/tracker-pt/ftnoir_tracker_pt.cpp b/tracker-pt/ftnoir_tracker_pt.cpp index 1fbd4373..ca81ff40 100644 --- a/tracker-pt/ftnoir_tracker_pt.cpp +++ b/tracker-pt/ftnoir_tracker_pt.cpp @@ -9,17 +9,16 @@ #include "ftnoir_tracker_pt.h" #include "compat/camera-names.hpp" #include "compat/math-imports.hpp" -#include + #include +#include + +#include #include #include #include -#include -Tracker_PT::Tracker_PT() : - point_count(0), - commands(0), - ever_success(false) +Tracker_PT::Tracker_PT() { cv::setBreakOnError(true); @@ -30,25 +29,13 @@ Tracker_PT::Tracker_PT() : Tracker_PT::~Tracker_PT() { - set_command(ABORT); + requestInterruption(); wait(); QMutexLocker l(&camera_mtx); camera.stop(); } -void Tracker_PT::set_command(Command command) -{ - //QMutexLocker lock(&mutex); - commands |= command; -} - -void Tracker_PT::reset_command(Command command) -{ - //QMutexLocker lock(&mutex); - commands &= ~command; -} - void Tracker_PT::run() { cv::setNumThreads(1); @@ -59,7 +46,7 @@ void Tracker_PT::run() QTextStream log_stream(&log_file); #endif - while((commands & ABORT) == 0) + while(!isInterruptionRequested()) { CamInfo cam_info; bool new_frame = false; diff --git a/tracker-pt/ftnoir_tracker_pt.h b/tracker-pt/ftnoir_tracker_pt.h index 35da957b..8274d62e 100644 --- a/tracker-pt/ftnoir_tracker_pt.h +++ b/tracker-pt/ftnoir_tracker_pt.h @@ -23,6 +23,8 @@ #include #include +#include + #include #include #include @@ -60,17 +62,10 @@ public slots: protected: void run() override; private: - // thread commands - enum Command : unsigned char - { - ABORT = 1<<0 - }; - void set_command(Command command); - void reset_command(Command command); - QMutex camera_mtx; QMutex data_mtx; - Camera camera; + Camera camera; + PointExtractor point_extractor; PointTracker point_tracker; @@ -83,9 +78,8 @@ private: QSize preview_size; - std::atomic point_count; - std::atomic commands; - std::atomic ever_success; + std::atomic point_count = 0; + std::atomic ever_success = false; static constexpr f rad2deg = f(180/M_PI); //static constexpr float deg2rad = float(M_PI/180); -- cgit v1.2.3