diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2021-10-18 12:22:44 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2021-10-18 12:29:46 +0200 |
commit | ec6de4132a65ae845e82389d3ba46c324f714859 (patch) | |
tree | c476286859d348accde31020e1d2da707b7f2dac /tracker-pt | |
parent | eda160a0db364c5a4ce19124e9c533aab2d4b667 (diff) |
tracker/pt: remove camera_mtx
Diffstat (limited to 'tracker-pt')
-rw-r--r-- | tracker-pt/ftnoir_tracker_pt.cpp | 27 | ||||
-rw-r--r-- | tracker-pt/ftnoir_tracker_pt.h | 4 | ||||
-rw-r--r-- | tracker-pt/ftnoir_tracker_pt_dialog.cpp | 6 |
3 files changed, 11 insertions, 26 deletions
diff --git a/tracker-pt/ftnoir_tracker_pt.cpp b/tracker-pt/ftnoir_tracker_pt.cpp index f980c30d..b209a938 100644 --- a/tracker-pt/ftnoir_tracker_pt.cpp +++ b/tracker-pt/ftnoir_tracker_pt.cpp @@ -6,6 +6,7 @@ * copyright notice and this permission notice appear in all copies. */ +#undef NDEBUG #include "ftnoir_tracker_pt.h" #include "pt-api.hpp" #include "cv/init.hpp" @@ -15,6 +16,7 @@ #include "compat/thread-name.hpp" #include "compat/qt-dpi.hpp" +#include <cassert> #include <QHBoxLayout> #include <QDebug> #include <QFile> @@ -40,7 +42,6 @@ Tracker_PT::~Tracker_PT() requestInterruption(); wait(); - QMutexLocker l(&camera_mtx); if (camera) camera->stop(); } @@ -50,22 +51,15 @@ bool Tracker_PT::check_camera() if (reopen_camera_flag) { reopen_camera_flag = false; - if (!camera || last_camera_name != s.camera_name) - { - // deadlock avoidance - decltype(camera) camera_; - { - QMutexLocker l(&camera_mtx); - camera_ = std::move(camera); - } - camera_ = traits->make_camera(); - if (!camera_ || !camera_->start(s)) - return false; - camera = std::move(camera_); - last_camera_name = s.camera_name; - } + camera = nullptr; + camera = traits->make_camera(); + if (!camera || !camera->start(s)) + return false; } + assert(camera); + if (progn(bool x = true; return open_camera_dialog_flag.compare_exchange_strong(x, false);)) + camera->show_camera_settings(); return true; } @@ -82,7 +76,6 @@ void Tracker_PT::run() bool new_frame = false; { - QMutexLocker l(&camera_mtx); camera->set_fov(s.fov); std::tie(new_frame, info) = camera->get_frame(*frame); } @@ -135,7 +128,6 @@ void Tracker_PT::run() module_status Tracker_PT::start_tracker(QFrame* video_frame) { { - QMutexLocker l(&camera_mtx); auto camera = traits->make_camera(); if (!camera || !camera->start(s)) return error(tr("Failed to open camera '%1'").arg(s.camera_name)); @@ -218,7 +210,6 @@ int Tracker_PT::get_n_points() bool Tracker_PT::get_cam_info(pt_camera_info& info) { - QMutexLocker l(&camera_mtx); bool ret = false; if (camera) diff --git a/tracker-pt/ftnoir_tracker_pt.h b/tracker-pt/ftnoir_tracker_pt.h index bb388d5c..416b0ebe 100644 --- a/tracker-pt/ftnoir_tracker_pt.h +++ b/tracker-pt/ftnoir_tracker_pt.h @@ -53,9 +53,6 @@ private: pointer<pt_runtime_traits> traits; - mutable QRecursiveMutex camera_mtx; - QString last_camera_name; - PointTracker point_tracker; pt_settings s; @@ -74,6 +71,7 @@ private: std::atomic<unsigned> point_count { 0 }; std::atomic<bool> ever_success = false; std::atomic<bool> reopen_camera_flag = true; + std::atomic<bool> open_camera_dialog_flag = false; mutable QMutex center_lock, data_lock; point_filter filter{s}; }; diff --git a/tracker-pt/ftnoir_tracker_pt_dialog.cpp b/tracker-pt/ftnoir_tracker_pt_dialog.cpp index ce300e27..f71e13a5 100644 --- a/tracker-pt/ftnoir_tracker_pt_dialog.cpp +++ b/tracker-pt/ftnoir_tracker_pt_dialog.cpp @@ -235,11 +235,7 @@ void TrackerDialog_PT::set_camera_settings_available(const QString& /* camera_na void TrackerDialog_PT::show_camera_settings() { if (tracker) - { - QMutexLocker l(&tracker->camera_mtx); - if (tracker->camera) - tracker->camera->show_camera_settings(); - } + tracker->open_camera_dialog_flag = true; else (void)video::show_dialog(s.camera_name); } |