summaryrefslogtreecommitdiffhomepage
path: root/tracker-pt
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2018-08-04 15:36:51 +0200
committerStanislaw Halik <sthalik@misaki.pl>2018-08-04 13:40:26 +0000
commita1356d3811ec57161f48e586f21c618f99a0b841 (patch)
tree770ec149eb429e71b1b1ef7d7550bb129a18f64d /tracker-pt
parent299fb737fe711d00654ec5afe4cc2afdc742f279 (diff)
tracker/pt: fix center with dynamic pose set
It was necessary to center _twice_ in order to reset dynamic pose. Put a spinlock around the code.
Diffstat (limited to 'tracker-pt')
-rw-r--r--tracker-pt/ftnoir_tracker_pt.cpp15
-rw-r--r--tracker-pt/ftnoir_tracker_pt.h5
2 files changed, 16 insertions, 4 deletions
diff --git a/tracker-pt/ftnoir_tracker_pt.cpp b/tracker-pt/ftnoir_tracker_pt.cpp
index 5f88786a..0d99ccd0 100644
--- a/tracker-pt/ftnoir_tracker_pt.cpp
+++ b/tracker-pt/ftnoir_tracker_pt.cpp
@@ -20,7 +20,7 @@
#include <QFile>
#include <QCoreApplication>
-using namespace types;
+namespace pt_module {
Tracker_PT::Tracker_PT(pointer<pt_runtime_traits> const& traits) :
traits { traits },
@@ -69,6 +69,9 @@ void Tracker_PT::run()
if (new_frame)
{
+ while (center_flag.test_and_set())
+ (void)0;
+
*preview_frame = *frame;
point_extractor->extract_points(*frame, *preview_frame, points);
@@ -113,6 +116,8 @@ void Tracker_PT::run()
preview_frame = traits->make_preview(w, h);
}
}
+
+ center_flag.clear();
}
}
qDebug() << "pt: thread stopped";
@@ -192,7 +197,13 @@ void Tracker_PT::data(double *data)
bool Tracker_PT::center()
{
+ while (center_flag.test_and_set())
+ (void)0;
+
point_tracker.reset_state();
+
+ center_flag.clear();
+
return false;
}
@@ -217,4 +228,4 @@ bool Tracker_PT::get_cam_info(pt_camera_info* info)
return ret;
}
-
+} // ns pt_module
diff --git a/tracker-pt/ftnoir_tracker_pt.h b/tracker-pt/ftnoir_tracker_pt.h
index 31bdc6bb..8cf609c3 100644
--- a/tracker-pt/ftnoir_tracker_pt.h
+++ b/tracker-pt/ftnoir_tracker_pt.h
@@ -39,7 +39,7 @@ class Tracker_PT : public QThread, public ITracker
public:
template<typename t> using pointer = pt_pointer<t>;
- Tracker_PT(pointer<pt_runtime_traits> const& pt_runtime_traits);
+ explicit Tracker_PT(pointer<pt_runtime_traits> const& pt_runtime_traits);
~Tracker_PT() override;
module_status start_tracker(QFrame* parent_window) override;
void data(double* data) override;
@@ -76,6 +76,7 @@ private:
std::atomic<unsigned> point_count { 0 };
std::atomic<bool> ever_success { false };
+ std::atomic_flag center_flag = ATOMIC_FLAG_INIT;
static constexpr inline f rad2deg = f(180/M_PI);
//static constexpr float deg2rad = float(M_PI/180);
@@ -83,4 +84,4 @@ private:
} // ns pt_impl
-using pt_module::Tracker_PT;
+using Tracker_PT = pt_module::Tracker_PT;