summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-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);