diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2014-01-12 19:53:59 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2014-01-12 19:53:59 +0100 |
commit | 302dfd055bd368752216701a0d0e963d5bf6d3e9 (patch) | |
tree | 15f0400936871e59cc5a159221e6a7118c102600 /FTNoIR_Tracker_PT | |
parent | 0d2a44867c9f5c31789152e8f5735dc85987554e (diff) |
Revert "remove hack of passing fov/w/h as member vars"
This reverts commit 6e1610667fb33517299997e628652fd91380e762.
Diffstat (limited to 'FTNoIR_Tracker_PT')
-rw-r--r-- | FTNoIR_Tracker_PT/point_tracker.cpp | 19 | ||||
-rw-r--r-- | FTNoIR_Tracker_PT/point_tracker.h | 8 |
2 files changed, 19 insertions, 8 deletions
diff --git a/FTNoIR_Tracker_PT/point_tracker.cpp b/FTNoIR_Tracker_PT/point_tracker.cpp index a881da62..cce327e9 100644 --- a/FTNoIR_Tracker_PT/point_tracker.cpp +++ b/FTNoIR_Tracker_PT/point_tracker.cpp @@ -91,7 +91,10 @@ PointTracker::PointTracker() dt_reset(1),
v_t(0,0,0),
v_r(0,0,0),
- dynamic_pose_resolution(true)
+ dynamic_pose_resolution(true),
+ fov(0),
+ _w(0),
+ _h(0)
{
}
@@ -141,7 +144,7 @@ bool PointTracker::track(const vector<Vec2f>& points, float fov, float dt, int w predict(dt_valid);
// if there is a point correspondence problem something has gone wrong, do a reset
- if (!find_correspondences(points, fov, w, h))
+ if (!find_correspondences(points))
{
//qDebug()<<"Error in finding point correspondences!";
X_CM = X_CM_old; // undo prediction
@@ -178,7 +181,7 @@ void PointTracker::update_velocities(float dt) v_t = (X_CM.t - X_CM_old.t)/dt;
}
-bool PointTracker::find_correspondences(const vector<Vec2f>& points, float fov, int w, int h)
+bool PointTracker::find_correspondences(const vector<Vec2f>& points)
{
if (init_phase) {
// We do a simple freetrack-like sorting in the init phase...
@@ -195,9 +198,9 @@ bool PointTracker::find_correspondences(const vector<Vec2f>& points, float fov, else {
// ... otherwise we look at the distance to the projection of the expected model points
// project model points under current pose
- p_exp[0] = project(Vec3f(0,0,0), fov, w, h);
- p_exp[1] = project(point_model->M01, fov, w, h);
- p_exp[2] = project(point_model->M02, fov, w, h);
+ p_exp[0] = project(Vec3f(0,0,0));
+ p_exp[1] = project(point_model->M01);
+ p_exp[2] = project(point_model->M02);
// set correspondences by minimum distance to projected model point
bool point_taken[PointModel::N_POINTS];
@@ -233,6 +236,10 @@ bool PointTracker::find_correspondences(const vector<Vec2f>& points, float fov, void PointTracker::POSIT(float fov, int w, int h)
{
+ // XXX hack
+ this->fov = fov;
+ _w = w;
+ _h = h;
std::vector<cv::Point3f> obj_points;
std::vector<cv::Point2f> img_points;
diff --git a/FTNoIR_Tracker_PT/point_tracker.h b/FTNoIR_Tracker_PT/point_tracker.h index 741d5af4..ac43489e 100644 --- a/FTNoIR_Tracker_PT/point_tracker.h +++ b/FTNoIR_Tracker_PT/point_tracker.h @@ -98,12 +98,16 @@ public: FrameTrafo get_pose() const { return X_CM; }
void reset();
+ float fov;
+ int _w, _h;
+
protected:
- cv::Vec2f project(const cv::Vec3f& v_M, float fov, int w, int h)
+ cv::Vec2f project(const cv::Vec3f& v_M)
{
if (!rvec.empty() && !tvec.empty() && fov > 0)
{
const float HT_PI = 3.1415926535;
+ const int w = _w, h = _h;
const float focal_length_w = 0.5 * w / tan(fov * HT_PI / 180);
const float focal_length_h = 0.5 * h / tan(fov * h / w * HT_PI / 180.0);
@@ -122,7 +126,7 @@ protected: return cv::Vec2f();
}
- bool find_correspondences(const std::vector<cv::Vec2f>& points, float fov, int w, int h);
+ bool find_correspondences(const std::vector<cv::Vec2f>& points);
cv::Vec2f p[PointModel::N_POINTS]; // the points in model order
cv::Vec2f p_exp[PointModel::N_POINTS]; // the expected point positions
|