diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2018-01-11 19:03:10 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2018-01-11 19:03:10 +0100 |
commit | fbd961775001228f6ffd9cc3bf09aa2de610aeae (patch) | |
tree | b54c35357ea0ec0fbf2d78d14a17bcf4047c9488 /tracker-pt/pt-api.cpp | |
parent | 71374d0b5cd456e25252775fdec89fe3cf2aa5e6 (diff) |
tracker/pt: allow for reuse
Issue: #718
This allows for replacing the camera and point extractor code. See
`module.cpp' and `pt-api.hpp`.
Diffstat (limited to 'tracker-pt/pt-api.cpp')
-rw-r--r-- | tracker-pt/pt-api.cpp | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/tracker-pt/pt-api.cpp b/tracker-pt/pt-api.cpp new file mode 100644 index 00000000..c11f372f --- /dev/null +++ b/tracker-pt/pt-api.cpp @@ -0,0 +1,62 @@ +#include "pt-api.hpp" +#include "cv/numeric.hpp" + +using namespace types; + +pt_camera_info::pt_camera_info() +{ +} + +double pt_camera_info::get_focal_length() const +{ + const double diag_len = std::sqrt(double(res_x*res_x + res_y*res_y)); + const double aspect_x = res_x / diag_len; + //const double aspect_y = res_y / diag_len; + const double diag_fov = fov * M_PI/180; + const double fov_x = 2*std::atan(std::tan(diag_fov*.5) * aspect_x); + //const double fov_y = 2*atan(tan(diag_fov*.5) * aspect_y); + const double fx = .5 / std::tan(fov_x * .5); + return fx; + //fy = .5 / tan(fov_y * .5); + //static bool once = false; if (!once) { once = true; qDebug() << "f" << ret << "fov" << (fov * 180/M_PI); } +} + +pt_settings::pt_settings(const QString& name) : opts(name) +{ +} + +pt_camera::pt_camera() +{ +} + +pt_camera::~pt_camera() +{ +} + +pt_runtime_traits::pt_runtime_traits() +{ +} + +pt_runtime_traits::~pt_runtime_traits() +{ +} + +pt_point_extractor::pt_point_extractor() +{ +} + +pt_point_extractor::~pt_point_extractor() +{ +} + +double pt_point_extractor::threshold_radius_value(int w, int h, int threshold) +{ + double cx = w / 640., cy = h / 480.; + + const double min_radius = 1.75 * cx; + const double max_radius = 15 * cy; + + const double radius = std::fmax(0., (max_radius-min_radius) * threshold / f(255) + min_radius); + + return radius; +} |