summaryrefslogtreecommitdiffhomepage
path: root/tracker-pt
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2016-11-23 10:42:04 +0100
committerStanislaw Halik <sthalik@misaki.pl>2016-11-23 10:42:04 +0100
commite565e1ad05dd4e68314f16eb71eb819217c68739 (patch)
treee4c9a1a523566eb68eabcc805924d23dbda83d4f /tracker-pt
parentda9c3080111b0cd31b48696c3c67ac46e4843ee8 (diff)
tracker/pt: add failed focal length formula
Diffstat (limited to 'tracker-pt')
-rw-r--r--tracker-pt/ftnoir_tracker_pt.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/tracker-pt/ftnoir_tracker_pt.cpp b/tracker-pt/ftnoir_tracker_pt.cpp
index d13c5545..ca25e858 100644
--- a/tracker-pt/ftnoir_tracker_pt.cpp
+++ b/tracker-pt/ftnoir_tracker_pt.cpp
@@ -65,12 +65,21 @@ bool Tracker_PT::get_focal_length(f& ret)
using std::tan;
using std::atan;
using std::sqrt;
-
+#if 1
const double w = info.res_x, h = info.res_y;
const double diag = sqrt(w/h*w/h + h/w*h/w);
const double diag_fov = static_cast<int>(s.fov) * M_PI / 180.;
const double fov = 2.*atan(tan(diag_fov/2.)/diag);
ret = .5 / tan(.5 * fov);
+#else
+ // the formula looks correct but doesn't work right regardless
+
+ const double diag_fov = s.fov * M_PI/180;
+ const double aspect = w / sqrt(w*w + h*h);
+ const double fov = 2*atan(tan(diag_fov*.5) * aspect);
+ ret = .5 / tan(fov * .5);
+ static bool once = false; if (!once) { once = true; qDebug() << "f" << ret << "fov" << (fov * 180/M_PI); }
+#endif
return true;
}
return false;