summaryrefslogtreecommitdiffhomepage
path: root/FTNoIR_Tracker_PT
diff options
context:
space:
mode:
Diffstat (limited to 'FTNoIR_Tracker_PT')
-rw-r--r--FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp22
-rw-r--r--FTNoIR_Tracker_PT/ftnoir_tracker_pt.h6
2 files changed, 22 insertions, 6 deletions
diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp
index cbc1f1dc..787a5128 100644
--- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp
+++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp
@@ -26,7 +26,9 @@ Tracker::Tracker()
: commands(0),
video_widget(NULL),
video_frame(NULL),
- tracking_valid(false)
+ tracking_valid(false),
+ need_apply(false),
+ new_settings(nullptr)
{
qDebug()<<"Tracker::Tracker";
}
@@ -73,7 +75,7 @@ void Tracker::run()
if (commands & ABORT) break;
if (commands & PAUSE) continue;
commands = 0;
-
+ apply_inner();
dt = time.start() / 1000.0;
new_frame = camera.get_frame(dt, &frame);
@@ -111,11 +113,23 @@ void Tracker::run()
qDebug()<<"Tracker:: Thread stopping";
}
-
void Tracker::apply(settings& s)
{
- qDebug()<<"Tracker:: Applying settings";
QMutexLocker lock(&mutex);
+ need_apply = true;
+ // caller guarantees object lifetime
+ new_settings = &s;
+}
+
+void Tracker::apply_inner()
+{
+ QMutexLocker lock(&mutex);
+ if (!need_apply)
+ return;
+ qDebug()<<"Tracker:: Applying settings";
+ auto& s = *new_settings;
+ new_settings = nullptr;
+ need_apply = false;
camera.set_device_index(s.cam_index);
camera.set_res(s.cam_res_x, s.cam_res_y);
camera.set_fps(s.cam_fps);
diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h
index 80abbc6a..47a9987b 100644
--- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h
+++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h
@@ -44,6 +44,7 @@ public:
virtual void refreshVideo();
void apply(settings& s);
+ void apply_inner();
void center();
void reset(); // reset the trackers internal state variables
void run();
@@ -81,9 +82,10 @@ protected:
PTVideoWidget* video_widget;
QFrame* video_frame;
- bool tracking_valid;
-
+ bool tracking_valid, need_apply;
+
settings s;
+ settings* new_settings;
Timer time;
};