summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--tracker-pt/camera.cpp4
-rw-r--r--tracker-pt/camera.h2
-rw-r--r--tracker-pt/ftnoir_tracker_pt.cpp12
-rw-r--r--tracker-pt/ftnoir_tracker_pt.h15
-rw-r--r--tracker-pt/module.cpp22
-rw-r--r--tracker-pt/pt-api.cpp1
-rw-r--r--tracker-pt/pt-api.hpp10
7 files changed, 37 insertions, 29 deletions
diff --git a/tracker-pt/camera.cpp b/tracker-pt/camera.cpp
index 20acf27a..ba4583da 100644
--- a/tracker-pt/camera.cpp
+++ b/tracker-pt/camera.cpp
@@ -18,7 +18,9 @@
using namespace pt_module;
-Camera::Camera(const QString& module_name) : dt_mean(0), fov(0), s(module_name) {}
+Camera::Camera(const QString& module_name) : s { module_name }
+{
+}
QString Camera::get_desired_name() const
{
diff --git a/tracker-pt/camera.h b/tracker-pt/camera.h
index 35e887ad..030861c7 100644
--- a/tracker-pt/camera.h
+++ b/tracker-pt/camera.h
@@ -46,7 +46,7 @@ struct Camera final : pt_camera
private:
warn_result_unused bool _get_frame(cv::Mat& Frame);
- double dt_mean, fov;
+ double dt_mean = 0, fov = 30;
Timer t;
diff --git a/tracker-pt/ftnoir_tracker_pt.cpp b/tracker-pt/ftnoir_tracker_pt.cpp
index bded07d3..467334de 100644
--- a/tracker-pt/ftnoir_tracker_pt.cpp
+++ b/tracker-pt/ftnoir_tracker_pt.cpp
@@ -13,7 +13,6 @@
#include "pt-api.hpp"
#include <cmath>
-#include <utility>
#include <opencv2/imgproc.hpp>
@@ -27,11 +26,11 @@ using namespace types;
static constexpr inline int preview_width = 320, preview_height = 240;
Tracker_PT::Tracker_PT(const pt_runtime_traits& traits) :
- s(traits.get_module_name()),
- point_extractor(std::move(traits.make_point_extractor())),
- camera(std::move(traits.make_camera())),
- frame(std::move(traits.make_frame())),
- preview_frame(std::move(traits.make_preview(preview_width, preview_height)))
+ s { traits.get_module_name() },
+ point_extractor { traits.make_point_extractor() },
+ camera { traits.make_camera() },
+ frame { traits.make_frame() },
+ preview_frame { traits.make_preview(preview_width, preview_height) }
{
cv::setBreakOnError(true);
@@ -139,7 +138,6 @@ void Tracker_PT::set_fov(int value)
module_status Tracker_PT::start_tracker(QFrame* video_frame)
{
//video_frame->setAttribute(Qt::WA_NativeWindow);
- preview_size = video_frame->size();
video_widget = std::make_unique<cv_video_widget>(video_frame);
layout = std::make_unique<QHBoxLayout>(video_frame);
diff --git a/tracker-pt/ftnoir_tracker_pt.h b/tracker-pt/ftnoir_tracker_pt.h
index deddeea8..c9c15bc7 100644
--- a/tracker-pt/ftnoir_tracker_pt.h
+++ b/tracker-pt/ftnoir_tracker_pt.h
@@ -59,20 +59,21 @@ private:
QMutex camera_mtx;
QMutex data_mtx;
- std::unique_ptr<pt_point_extractor> point_extractor;
- std::unique_ptr<pt_camera> camera;
+ template<typename t>
+ using pointer = typename pt_runtime_traits::pointer<t>;
+
PointTracker point_tracker;
pt_settings s;
- std::unique_ptr<cv_video_widget> video_widget;
std::unique_ptr<QLayout> layout;
-
std::vector<vec2> points;
- std::unique_ptr<pt_frame> frame;
- std::unique_ptr<pt_preview> preview_frame;
- QSize preview_size;
+ pointer<pt_point_extractor> point_extractor;
+ pointer<pt_camera> camera;
+ pointer<cv_video_widget> video_widget;
+ pointer<pt_frame> frame;
+ pointer<pt_preview> preview_frame;
std::atomic<unsigned> point_count = 0;
std::atomic<bool> ever_success = false;
diff --git a/tracker-pt/module.cpp b/tracker-pt/module.cpp
index d977aa16..c73b771e 100644
--- a/tracker-pt/module.cpp
+++ b/tracker-pt/module.cpp
@@ -16,14 +16,14 @@ using namespace pt_module;
struct pt_module_traits final : pt_runtime_traits
{
- std::unique_ptr<pt_camera> make_camera() const override
+ pointer<pt_camera> make_camera() const override
{
- return std::unique_ptr<pt_camera>(new Camera(module_name));
+ return pointer<pt_camera>(new Camera(module_name));
}
- std::unique_ptr<pt_point_extractor> make_point_extractor() const override
+ pointer<pt_point_extractor> make_point_extractor() const override
{
- return std::unique_ptr<pt_point_extractor>(new PointExtractor(module_name));
+ return pointer<pt_point_extractor>(new PointExtractor(module_name));
}
QString get_module_name() const override
@@ -31,14 +31,14 @@ struct pt_module_traits final : pt_runtime_traits
return module_name;
}
- std::unique_ptr<pt_frame> make_frame() const override
+ pointer<pt_frame> make_frame() const override
{
- return std::unique_ptr<pt_frame>(new Frame);
+ return pointer<pt_frame>(new Frame);
}
- std::unique_ptr<pt_preview> make_preview(int w, int h) const override
+ pointer<pt_preview> make_preview(int w, int h) const override
{
- return std::unique_ptr<pt_preview>(new Preview(w, h));
+ return pointer<pt_preview>(new Preview(w, h));
}
};
@@ -51,7 +51,7 @@ struct tracker_pt : Tracker_PT
struct dialog_pt : TrackerDialog_PT
{
- dialog_pt() : TrackerDialog_PT(module_name) {}
+ dialog_pt();
};
class metadata_pt : public Metadata
@@ -64,4 +64,8 @@ class metadata_pt : public Metadata
using namespace pt_module;
+
+
+dialog_pt::dialog_pt() : TrackerDialog_PT(module_name) {}
+
OPENTRACK_DECLARE_TRACKER(tracker_pt, dialog_pt, metadata_pt)
diff --git a/tracker-pt/pt-api.cpp b/tracker-pt/pt-api.cpp
index 0a6c8e2b..f64b1d81 100644
--- a/tracker-pt/pt-api.cpp
+++ b/tracker-pt/pt-api.cpp
@@ -69,6 +69,7 @@ std::tuple<double, double> pt_pixel_pos_mixin::to_pixel_pos(double x, double y,
std::tuple<double, double> pt_pixel_pos_mixin::to_screen_pos(double px, double py, int w, int h)
{
+ px *= w/(w-1.), py *= h/(h-1.);
return std::make_tuple((px - w/2.)/w, -(py - h/2.)/w);
}
diff --git a/tracker-pt/pt-api.hpp b/tracker-pt/pt-api.hpp
index 833a640e..0156fdd7 100644
--- a/tracker-pt/pt-api.hpp
+++ b/tracker-pt/pt-api.hpp
@@ -148,12 +148,14 @@ struct OTR_PT_EXPORT pt_settings final : options::opts
struct OTR_PT_EXPORT pt_runtime_traits
{
+ template<typename t> using pointer = std::shared_ptr<t>;
+
pt_runtime_traits();
virtual ~pt_runtime_traits();
- virtual std::unique_ptr<pt_camera> make_camera() const = 0;
- virtual std::unique_ptr<pt_point_extractor> make_point_extractor() const = 0;
- virtual std::unique_ptr<pt_frame> make_frame() const = 0;
- virtual std::unique_ptr<pt_preview> make_preview(int w, int h) const = 0;
+ virtual pointer<pt_camera> make_camera() const = 0;
+ virtual pointer<pt_point_extractor> make_point_extractor() const = 0;
+ virtual pointer<pt_frame> make_frame() const = 0;
+ virtual pointer<pt_preview> make_preview(int w, int h) const = 0;
virtual QString get_module_name() const = 0;
};