summaryrefslogtreecommitdiffhomepage
path: root/ftnoir_tracker_pt
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2015-08-18 05:52:26 +0200
committerStanislaw Halik <sthalik@misaki.pl>2015-08-18 05:52:26 +0200
commite6eb0bb0bc3f766953affe28cda7f8afbaab0985 (patch)
treefc4f2709ceeb95f7c558818e20ddf4aab6295203 /ftnoir_tracker_pt
parenta2c881e36e8522d94831f5486f7408dc58321a42 (diff)
pt, aruco: another take at focal length formula
Aspect ratio is meant to be viewport's ratio, not diagonal to axis.
Diffstat (limited to 'ftnoir_tracker_pt')
-rwxr-xr-x[-rw-r--r--]ftnoir_tracker_pt/ftnoir_tracker_pt.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp b/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp
index e10cfea0..4fa70ccf 100644..100755
--- a/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp
+++ b/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp
@@ -57,8 +57,9 @@ bool Tracker_PT::get_focal_length(float& ret)
{
static constexpr double pi = 3.14159265359;
const int w = info.res_x, h = info.res_y;
- const double diag = sqrt(w * w + h * h)/w, diag_fov = static_cast<int>(s.fov) * pi / 180.;
- const double fov = 2.*atan(tan(diag_fov/2.0)/sqrt(1. + diag*diag));
+ const double diag = sqrt(1. + h/(double)w * h/(double)w);
+ const double diag_fov = static_cast<int>(s.fov) * pi / 180.;
+ const double fov = 2.*atan(tan(diag_fov/2.0)/diag);
ret = .5 / tan(.5 * fov);
return true;
}