summaryrefslogtreecommitdiffhomepage
path: root/tracker-pt
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2017-10-22 07:58:42 +0200
committerStanislaw Halik <sthalik@misaki.pl>2017-10-22 07:58:42 +0200
commitb253d56527365a729c0249918f6c9477893a717e (patch)
treeee10ce89c268c0566005d25fa4d49ba5cc51da41 /tracker-pt
parent4e03f244450cbfd8a5a1cf429515ce0194f66262 (diff)
tracker/pt: return focal length directly
Diffstat (limited to 'tracker-pt')
-rw-r--r--tracker-pt/camera.cpp5
-rw-r--r--tracker-pt/camera.h2
-rw-r--r--tracker-pt/ftnoir_tracker_pt.cpp3
-rw-r--r--tracker-pt/point_extractor.cpp2
-rw-r--r--tracker-pt/point_tracker.cpp5
5 files changed, 8 insertions, 9 deletions
diff --git a/tracker-pt/camera.cpp b/tracker-pt/camera.cpp
index 5e00499c..263d6617 100644
--- a/tracker-pt/camera.cpp
+++ b/tracker-pt/camera.cpp
@@ -22,7 +22,7 @@ QString Camera::get_active_name() const
return active_name;
}
-void CamInfo::get_focal_length(double& fx) const
+double CamInfo::get_focal_length() const
{
const double diag_len = sqrt(double(res_x*res_x + res_y*res_y));
const double aspect_x = res_x / diag_len;
@@ -30,7 +30,8 @@ void CamInfo::get_focal_length(double& fx) const
const double diag_fov = fov * M_PI/180;
const double fov_x = 2*atan(tan(diag_fov*.5) * aspect_x);
//const double fov_y = 2*atan(tan(diag_fov*.5) * aspect_y);
- fx = .5 / tan(fov_x * .5);
+ const double fx = .5 / 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); }
}
diff --git a/tracker-pt/camera.h b/tracker-pt/camera.h
index 449a2d3f..388b9234 100644
--- a/tracker-pt/camera.h
+++ b/tracker-pt/camera.h
@@ -25,7 +25,7 @@
struct CamInfo final
{
CamInfo() : fov(0), fps(0), res_x(0), res_y(0), idx(-1) {}
- void get_focal_length(double& fx) const;
+ double get_focal_length() const;
double fov;
double fps;
diff --git a/tracker-pt/ftnoir_tracker_pt.cpp b/tracker-pt/ftnoir_tracker_pt.cpp
index befb2d84..7b573060 100644
--- a/tracker-pt/ftnoir_tracker_pt.cpp
+++ b/tracker-pt/ftnoir_tracker_pt.cpp
@@ -80,8 +80,7 @@ void Tracker_PT::run()
point_extractor.extract_points(frame, preview_frame, points);
point_count = points.size();
- double fx;
- cam_info.get_focal_length(fx);
+ const double fx = cam_info.get_focal_length();
const bool success = points.size() >= PointModel::N_POINTS;
diff --git a/tracker-pt/point_extractor.cpp b/tracker-pt/point_extractor.cpp
index d17bd6cd..e68aa132 100644
--- a/tracker-pt/point_extractor.cpp
+++ b/tracker-pt/point_extractor.cpp
@@ -382,7 +382,7 @@ void PointExtractor::extract_points(const cv::Mat& frame, cv::Mat& preview_frame
}
end:
- std::sort(blobs.begin(), blobs.end(), [](const blob& b1, const blob& b2) -> bool { return b2.brightness < b1.brightness; });
+ std::sort(blobs.begin(), blobs.end(), [](const blob& b1, const blob& b2) { return b2.brightness < b1.brightness; });
const int W = frame.cols;
const int H = frame.rows;
diff --git a/tracker-pt/point_tracker.cpp b/tracker-pt/point_tracker.cpp
index ae873ef6..b87c38d1 100644
--- a/tracker-pt/point_tracker.cpp
+++ b/tracker-pt/point_tracker.cpp
@@ -92,7 +92,7 @@ PointTracker::PointOrder PointTracker::find_correspondences_previous(const vec2*
const PointModel& model,
const CamInfo& info)
{
- double fx; info.get_focal_length(fx);
+ const double fx = info.get_focal_length();
PointTracker::PointOrder p;
p[0] = project(vec3(0,0,0), fx);
p[1] = project(model.M01, fx);
@@ -205,8 +205,7 @@ void PointTracker::track(const std::vector<vec2>& points,
const CamInfo& info,
int init_phase_timeout)
{
- double fx;
- info.get_focal_length(fx);
+ const double fx = info.get_focal_length();
PointOrder order;
if (init_phase_timeout > 0 && t.elapsed_ms() > init_phase_timeout)