summaryrefslogtreecommitdiffhomepage
path: root/tracker-pt
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2016-09-21 12:01:43 +0200
committerStanislaw Halik <sthalik@misaki.pl>2016-09-21 12:01:43 +0200
commit107570e6288d266825724010a6f0149eaaac40db (patch)
treeab357889f6cd009e6e6a89e89657c377d4bb05ab /tracker-pt
parent1c22f4a19a0cfa6b593b72754acb9ea97fbded13 (diff)
many: remove compat/pi-constant.hpp
With -D_USE_MATH_DEFINES MSVC defines the standard M_PI and friends. Since this preprocessor definition is now always passed as part of the build system for MSVC. We can use M_PI as if on a mission.
Diffstat (limited to 'tracker-pt')
-rw-r--r--tracker-pt/ftnoir_tracker_pt.cpp4
-rw-r--r--tracker-pt/ftnoir_tracker_pt.h6
-rw-r--r--tracker-pt/ftnoir_tracker_pt_settings.cpp1
-rw-r--r--tracker-pt/ftnoir_tracker_pt_settings.h4
-rw-r--r--tracker-pt/point_extractor.cpp4
-rw-r--r--tracker-pt/point_extractor.h1
-rw-r--r--tracker-pt/point_tracker.cpp9
7 files changed, 9 insertions, 20 deletions
diff --git a/tracker-pt/ftnoir_tracker_pt.cpp b/tracker-pt/ftnoir_tracker_pt.cpp
index 20327020..ce19d592 100644
--- a/tracker-pt/ftnoir_tracker_pt.cpp
+++ b/tracker-pt/ftnoir_tracker_pt.cpp
@@ -18,8 +18,6 @@
//#define PT_PERF_LOG //log performance
-constexpr f Tracker_PT::pi;
-
//-----------------------------------------------------------------------------
Tracker_PT::Tracker_PT() :
video_widget(nullptr),
@@ -72,7 +70,7 @@ bool Tracker_PT::get_focal_length(f& ret)
const int w = info.res_x, h = info.res_y;
const double diag = sqrt(1. + h/(double)w * h/(double)w);
- const double diag_fov = static_cast<int>(s.fov) * pi / 180.;
+ const double diag_fov = static_cast<int>(s.fov) * M_PI / 180.;
const double fov = 2.*atan(tan(diag_fov/2.0)/diag);
ret = .5 / tan(.5 * fov);
return true;
diff --git a/tracker-pt/ftnoir_tracker_pt.h b/tracker-pt/ftnoir_tracker_pt.h
index 047aedda..513c9b2c 100644
--- a/tracker-pt/ftnoir_tracker_pt.h
+++ b/tracker-pt/ftnoir_tracker_pt.h
@@ -33,8 +33,6 @@ class TrackerDialog_PT;
// Constantly processes the tracking chain in a separate thread
class Tracker_PT : public QThread, public ITracker
{
- static constexpr f pi = constants::pi;
-
Q_OBJECT
friend class camera_dialog;
friend class TrackerDialog_PT;
@@ -80,8 +78,8 @@ private:
volatile unsigned char commands;
volatile bool ever_success;
- static constexpr f rad2deg = f(180/OPENTRACK_PI);
- //static constexpr float deg2rad = float(OPENTRACK_PI/180);
+ static constexpr f rad2deg = f(180/M_PI);
+ //static constexpr float deg2rad = float(M_PI/180);
};
class TrackerDll : public Metadata
diff --git a/tracker-pt/ftnoir_tracker_pt_settings.cpp b/tracker-pt/ftnoir_tracker_pt_settings.cpp
index e685960c..5d4b598f 100644
--- a/tracker-pt/ftnoir_tracker_pt_settings.cpp
+++ b/tracker-pt/ftnoir_tracker_pt_settings.cpp
@@ -3,6 +3,5 @@
namespace pt_types {
constexpr f constants::eps;
-constexpr f constants::pi;
}
diff --git a/tracker-pt/ftnoir_tracker_pt_settings.h b/tracker-pt/ftnoir_tracker_pt_settings.h
index b3f9e402..e742fbbc 100644
--- a/tracker-pt/ftnoir_tracker_pt_settings.h
+++ b/tracker-pt/ftnoir_tracker_pt_settings.h
@@ -8,10 +8,11 @@
#pragma once
-#include "compat/pi-constant.hpp"
#include <limits>
#include <opencv2/core.hpp>
+#include <cmath>
+
namespace pt_types {
using f = double;
@@ -19,7 +20,6 @@ namespace pt_types {
{
constants() = delete;
static constexpr f eps = std::numeric_limits<f>::epsilon();
- static constexpr f pi = OPENTRACK_PI;
};
template<int n> using vec = cv::Vec<f, n>;
diff --git a/tracker-pt/point_extractor.cpp b/tracker-pt/point_extractor.cpp
index 6411fcef..0fd177e0 100644
--- a/tracker-pt/point_extractor.cpp
+++ b/tracker-pt/point_extractor.cpp
@@ -19,8 +19,6 @@
#include <algorithm>
#include <cinttypes>
-constexpr double PointExtractor::pi;
-
PointExtractor::PointExtractor()
{
blobs.reserve(max_blobs);
@@ -132,7 +130,7 @@ void PointExtractor::extract_points(cv::Mat& frame, std::vector<vec2>& points)
}
if (m00 > 0)
{
- const double radius = sqrt(cnt / pi);
+ const double radius = sqrt(cnt / M_PI);
if (radius > region_size_max || radius < region_size_min)
continue;
const double norm = double(m00);
diff --git a/tracker-pt/point_extractor.h b/tracker-pt/point_extractor.h
index 5ebd8056..9ac2d695 100644
--- a/tracker-pt/point_extractor.h
+++ b/tracker-pt/point_extractor.h
@@ -29,7 +29,6 @@ public:
settings_pt s;
private:
- static constexpr double pi = constants::pi;
static constexpr int max_blobs = 16;
cv::Mat frame_gray;
diff --git a/tracker-pt/point_tracker.cpp b/tracker-pt/point_tracker.cpp
index 4c7ca4be..24edca45 100644
--- a/tracker-pt/point_tracker.cpp
+++ b/tracker-pt/point_tracker.cpp
@@ -207,9 +207,6 @@ int PointTracker::POSIT(const PointModel& model, const PointOrder& order_, f foc
// In every iteration step the rotation closer to R_expected is taken
mat33 R_expected = mat33::eye();
- static constexpr f pi = constants::pi;
- static constexpr f eps = constants::eps;
-
// initial pose = last (predicted) pose
vec3 k;
get_row(R_expected, 2, k);
@@ -263,14 +260,14 @@ int PointTracker::POSIT(const PointModel& model, const PointOrder& order_, f foc
// CAVEAT don't change to comparison with an epsilon -sh 20160423
if (JJ0 == II0) {
rho = sqrt(fabs(2*IJ0));
- theta = -pi/4;
+ theta = -M_PI/4;
if (IJ0<0) theta *= -1;
}
else {
rho = sqrt(sqrt( (JJ0-II0)*(JJ0-II0) + 4*IJ0*IJ0 ));
theta = atan( -2*IJ0 / (JJ0-II0) );
// avoid branch misprediction
- theta += (JJ0 - II0 < 0) * pi;
+ theta += (JJ0 - II0 < 0) * M_PI;
theta *= f(.5);
}
@@ -313,7 +310,7 @@ int PointTracker::POSIT(const PointModel& model, const PointOrder& order_, f foc
// check for convergence condition
const f delta = fabs(epsilon_1 - old_epsilon_1) + fabs(epsilon_2 - old_epsilon_2);
- if (!(delta > eps))
+ if (!(delta > constants::eps))
break;
old_epsilon_1 = epsilon_1;