summaryrefslogtreecommitdiffhomepage
path: root/tracker-pt
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2018-01-10 07:49:44 +0100
committerStanislaw Halik <sthalik@misaki.pl>2018-01-10 07:49:44 +0100
commita9ca349966dde20a8e9030c35c4a79f42c6e642b (patch)
tree2e75f801a7ede208a839069b45121280f41e8e8a /tracker-pt
parent9560aa09d5a8adcf2f72d5056821b5a75c0bfc6a (diff)
tracker/pt: cleanup
Diffstat (limited to 'tracker-pt')
-rw-r--r--tracker-pt/ftnoir_tracker_pt.cpp27
-rw-r--r--tracker-pt/ftnoir_tracker_pt.h18
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 <QHBoxLayout>
+
#include <cmath>
+#include <functional>
+
+#include <QHBoxLayout>
#include <QDebug>
#include <QFile>
#include <QCoreApplication>
-#include <functional>
-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 <memory>
#include <vector>
+#include <opencv2/core.hpp>
+
#include <QCoreApplication>
#include <QThread>
#include <QMutex>
@@ -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<unsigned> point_count;
- std::atomic<unsigned char> commands;
- std::atomic<bool> ever_success;
+ std::atomic<unsigned> point_count = 0;
+ std::atomic<bool> ever_success = false;
static constexpr f rad2deg = f(180/M_PI);
//static constexpr float deg2rad = float(M_PI/180);