From f3fc96424dfc31576917e39db555cc5d68ddc4af Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 1 Feb 2015 03:48:14 +0100 Subject: bring back dynamic pose resolution following user outrage Uses a simpler method without computing point velocities. Issues: #112, #126 --- ftnoir_tracker_pt/FTNoIR_PT_Controls.ui | 86 ++++++++++++++++---------- ftnoir_tracker_pt/ftnoir_tracker_pt.cpp | 2 +- ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.cpp | 2 + ftnoir_tracker_pt/ftnoir_tracker_pt_settings.h | 5 +- ftnoir_tracker_pt/point_tracker.cpp | 54 +++++++++++++++- ftnoir_tracker_pt/point_tracker.h | 15 ++++- 6 files changed, 124 insertions(+), 40 deletions(-) (limited to 'ftnoir_tracker_pt') diff --git a/ftnoir_tracker_pt/FTNoIR_PT_Controls.ui b/ftnoir_tracker_pt/FTNoIR_PT_Controls.ui index 4342cfac..0e6048c3 100644 --- a/ftnoir_tracker_pt/FTNoIR_PT_Controls.ui +++ b/ftnoir_tracker_pt/FTNoIR_PT_Controls.ui @@ -83,21 +83,30 @@ - - + + 0 0 - + + Desired capture width + + + px + + + 2000 + + 10 - - + + 0 @@ -105,34 +114,38 @@ - Width + Height - - + + 0 0 - - Desired capture width - - - px + + 10 - - 2000 + + + + + + + 0 + 0 + - - 10 + + Width - - + + 0 @@ -140,7 +153,7 @@ - Height + Field of view @@ -201,19 +214,6 @@ - - - - - 0 - 0 - - - - Field of view - - - @@ -230,6 +230,26 @@ + + + + + 0 + 0 + + + + Dynamic pose resolution + + + + + + + + + + diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp b/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp index fc5e5b99..23cc72c7 100644 --- a/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp +++ b/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp @@ -77,7 +77,7 @@ void Tracker::run() std::vector points = point_extractor.extract_points(frame); if (points.size() == PointModel::N_POINTS) - point_tracker.track(points, PointModel(s), get_focal_length()); + point_tracker.track(points, PointModel(s), get_focal_length(), s.dynamic_pose); { Affine CM = pose(); diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.cpp b/ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.cpp index 2c1ec5d8..7be05bb7 100644 --- a/ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.cpp +++ b/ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.cpp @@ -69,6 +69,8 @@ TrackerDialog::TrackerDialog() tie_setting(s.fov, ui.fov); tie_setting(s.active_model_panel, ui.model_tabs); + + tie_setting(s.dynamic_pose, ui.dynamic_pose); connect( ui.tcalib_button,SIGNAL(toggled(bool)), this,SLOT(startstop_trans_calib(bool)) ); diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt_settings.h b/ftnoir_tracker_pt/ftnoir_tracker_pt_settings.h index bce89058..57752ed6 100644 --- a/ftnoir_tracker_pt/ftnoir_tracker_pt_settings.h +++ b/ftnoir_tracker_pt/ftnoir_tracker_pt_settings.h @@ -34,6 +34,8 @@ struct settings value active_model_panel, cap_x, cap_y, cap_z; value fov; + + value dynamic_pose; settings() : b(bundle("tracker-pt")), @@ -62,7 +64,8 @@ struct settings cap_x(b, "cap-x", 0), cap_y(b, "cap-y", 0), cap_z(b, "cap-z", 0), - fov(b, "camera-fov", 56) + fov(b, "camera-fov", 56), + dynamic_pose(b, "dynamic-pose-resolution", false) {} }; diff --git a/ftnoir_tracker_pt/point_tracker.cpp b/ftnoir_tracker_pt/point_tracker.cpp index 0f996316..324119a9 100644 --- a/ftnoir_tracker_pt/point_tracker.cpp +++ b/ftnoir_tracker_pt/point_tracker.cpp @@ -67,9 +67,53 @@ PointTracker::PointTracker() X_CM.t[2] = 1000; // default position: 1 m away from cam; } -void PointTracker::track(const vector& points, const PointModel& model, float f) +PointTracker::PointOrder PointTracker::find_correspondences_previous(const vector& points, const PointModel& model, float f) { - const PointOrder& order = find_correspondences(points, model); + PointTracker::PointOrder p; + p.points[0] = project(Vec3f(0,0,0), f); + p.points[1] = project(model.M01, f); + p.points[2] = project(model.M02, f); + + // set correspondences by minimum distance to projected model point + bool point_taken[PointModel::N_POINTS]; + for (int i=0; i& points, const PointModel& model, float f, bool dynamic_pose) +{ + PointOrder order; + + if (!dynamic_pose) + order = find_correspondences(points, model); + else + order = find_correspondences_previous(points, model, f); + POSIT(model, order, f); } @@ -222,3 +266,9 @@ int PointTracker::POSIT(const PointModel& model, const PointOrder& order_, float // //qDebug()<<"r: "<& projected_points, const PointModel& model, float f); + void track(const std::vector& projected_points, const PointModel& model, float f, bool dynamic_pose); Affine pose() const { return X_CM; } - + cv::Vec2f project(const cv::Vec3f& v_M, float f); private: // the points in model order - typedef struct { cv::Vec2f points[PointModel::N_POINTS]; } PointOrder; + struct PointOrder + { + cv::Vec2f points[PointModel::N_POINTS]; + PointOrder() + { + for (int i = 0; i < PointModel::N_POINTS; i++) + points[i] = cv::Vec2f(0, 0); + } + }; PointOrder find_correspondences(const std::vector& projected_points, const PointModel &model); + PointOrder find_correspondences_previous(const std::vector& points, const PointModel &model, float f); int POSIT(const PointModel& point_model, const PointOrder& order, float focal_length); // The POSIT algorithm, returns the number of iterations Affine X_CM; // trafo from model to camera -- cgit v1.2.3