summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rwxr-xr-xftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp9
-rwxr-xr-x[-rw-r--r--]ftnoir_tracker_pt/ftnoir_tracker_pt.cpp5
2 files changed, 8 insertions, 6 deletions
diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp
index 84f20a61..fa783fe9 100755
--- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp
+++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp
@@ -154,10 +154,11 @@ void Tracker::run()
static constexpr double pi = 3.1415926f;
const int w = grayscale.cols, h = grayscale.rows;
- 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.)/sqrt(1. + diag*diag));
- const float focal_length_w = .5 * w / tan(.5 * fov);
- const float focal_length_h = focal_length_w;
+ const double diag_fov = static_cast<int>(s.fov) * pi / 180.;
+ const double fov_w = 2.*atan(tan(diag_fov/2.)/sqrt(1. + h/(double)w * h/(double)w));
+ const double fov_h = 2.*atan(tan(diag_fov/2.)/sqrt(1. + w/(double)h * w/(double)h));
+ const float focal_length_w = .5 * w / tan(.5 * fov_w);
+ const float focal_length_h = .5 * h / tan(.5 * fov_h);
intrinsics.at<float> (0, 0) = focal_length_w;
intrinsics.at<float> (1, 1) = focal_length_h;
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;
}