summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2018-01-21 09:37:13 +0100
committerStanislaw Halik <sthalik@misaki.pl>2018-01-21 09:37:13 +0100
commit1ccc6bb7888865b38fcd6234040345a0be66ec1d (patch)
tree9392da03fe704ffb328b1419794149a069e0a26c
parentd9bef40680c5613397b61cae213f616d3e09f2f1 (diff)
tracker/pt-base: add static pt_camera_info::get_focal_length
For the Wiimote tracker. Adjust usages in tracker/pt. Issue: #718
-rw-r--r--tracker-pt/ftnoir_tracker_pt.cpp8
-rw-r--r--tracker-pt/point_tracker.cpp4
-rw-r--r--tracker-pt/pt-api.cpp2
-rw-r--r--tracker-pt/pt-api.hpp20
4 files changed, 18 insertions, 16 deletions
diff --git a/tracker-pt/ftnoir_tracker_pt.cpp b/tracker-pt/ftnoir_tracker_pt.cpp
index 05959066..af086e5c 100644
--- a/tracker-pt/ftnoir_tracker_pt.cpp
+++ b/tracker-pt/ftnoir_tracker_pt.cpp
@@ -59,14 +59,14 @@ void Tracker_PT::run()
while(!isInterruptionRequested())
{
- pt_camera_info cam_info;
+ pt_camera_info info;
bool new_frame = false;
{
QMutexLocker l(&camera_mtx);
if (camera)
- std::tie(new_frame, cam_info) = camera->get_frame(*frame);
+ std::tie(new_frame, info) = camera->get_frame(*frame);
}
if (new_frame)
@@ -76,7 +76,7 @@ void Tracker_PT::run()
point_extractor->extract_points(*frame, *preview_frame, points);
point_count = points.size();
- const double fx = cam_info.get_focal_length();
+ const double fx = pt_camera_info::get_focal_length(info.fov, info.res_x, info.res_y);
const bool success = points.size() >= PointModel::N_POINTS;
@@ -84,7 +84,7 @@ void Tracker_PT::run()
{
point_tracker.track(points,
PointModel(s),
- cam_info,
+ info,
s.dynamic_pose ? s.init_phase_timeout : 0);
ever_success = true;
}
diff --git a/tracker-pt/point_tracker.cpp b/tracker-pt/point_tracker.cpp
index 57641d1a..56a029fe 100644
--- a/tracker-pt/point_tracker.cpp
+++ b/tracker-pt/point_tracker.cpp
@@ -92,7 +92,7 @@ PointTracker::PointOrder PointTracker::find_correspondences_previous(const vec2*
const PointModel& model,
const pt_camera_info& info)
{
- const double fx = info.get_focal_length();
+ const double fx = pt_camera_info::get_focal_length(info.fov, info.res_x, info.res_y);
PointTracker::PointOrder p;
p[0] = project(vec3(0,0,0), fx);
p[1] = project(model.M01, fx);
@@ -205,7 +205,7 @@ void PointTracker::track(const std::vector<vec2>& points,
const pt_camera_info& info,
int init_phase_timeout)
{
- const double fx = info.get_focal_length();
+ const double fx = pt_camera_info::get_focal_length(info.fov, info.res_x, info.res_y);
PointOrder order;
if (init_phase_timeout > 0 && t.elapsed_ms() > init_phase_timeout)
diff --git a/tracker-pt/pt-api.cpp b/tracker-pt/pt-api.cpp
index d86ef0c6..298f405a 100644
--- a/tracker-pt/pt-api.cpp
+++ b/tracker-pt/pt-api.cpp
@@ -7,7 +7,7 @@ pt_camera_info::pt_camera_info()
{
}
-double pt_camera_info::get_focal_length() const
+double pt_camera_info::get_focal_length(f fov, int res_x, int res_y)
{
const double diag_len = std::sqrt(double(res_x*res_x + res_y*res_y));
const double aspect_x = res_x / diag_len;
diff --git a/tracker-pt/pt-api.hpp b/tracker-pt/pt-api.hpp
index f2a200d6..1b50bc15 100644
--- a/tracker-pt/pt-api.hpp
+++ b/tracker-pt/pt-api.hpp
@@ -17,8 +17,10 @@
struct OTR_PT_EXPORT pt_camera_info final
{
+ using f = typename types::f;
+
pt_camera_info();
- virtual double get_focal_length() const;
+ static double get_focal_length(f fov, int res_x, int res_y);
double fov = 0;
double fps = 0;
@@ -30,7 +32,13 @@ struct OTR_PT_EXPORT pt_camera_info final
enum pt_camera_open_status : unsigned { cam_open_error, cam_open_ok_no_change, cam_open_ok_change };
-struct OTR_PT_EXPORT pt_frame
+struct OTR_PT_EXPORT pt_pixel_pos_mixin
+{
+ static std::tuple<double, double> to_pixel_pos(double x, double y, int w, int h);
+ static std::tuple<double, double> to_screen_pos(double px, double py, int w, int h);
+};
+
+struct OTR_PT_EXPORT pt_frame : pt_pixel_pos_mixin
{
pt_frame();
virtual ~pt_frame();
@@ -51,13 +59,7 @@ struct OTR_PT_EXPORT pt_frame
}
};
-struct OTR_PT_EXPORT pt_pixel_pos_mixin
-{
- static std::tuple<double, double> to_pixel_pos(double x, double y, int w, int h);
- static std::tuple<double, double> to_screen_pos(double px, double py, int w, int h);
-};
-
-struct OTR_PT_EXPORT pt_preview : pt_frame, pt_pixel_pos_mixin
+struct OTR_PT_EXPORT pt_preview : pt_frame
{
virtual pt_preview& operator=(const pt_frame&) = 0;
virtual QImage get_bitmap() = 0;