summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2016-09-16 16:10:52 +0200
committerStanislaw Halik <sthalik@misaki.pl>2016-09-16 18:04:36 +0200
commitb3476cc5f25c6039ebec6174c9e719f0ca37d24f (patch)
tree37bc982a87495cad0f466d93c966032e8b8ee0be
parent707edf55646b62d74a3ff3de9acc274687c13e05 (diff)
tracker/pt: get rid of pt_types class
-rw-r--r--tracker-pt/ftnoir_tracker_pt.cpp2
-rw-r--r--tracker-pt/ftnoir_tracker_pt.h7
-rw-r--r--tracker-pt/ftnoir_tracker_pt_settings.cpp8
-rw-r--r--tracker-pt/ftnoir_tracker_pt_settings.h13
-rw-r--r--tracker-pt/point_extractor.cpp4
-rw-r--r--tracker-pt/point_extractor.h7
-rw-r--r--tracker-pt/point_tracker.cpp12
-rw-r--r--tracker-pt/point_tracker.h17
8 files changed, 47 insertions, 23 deletions
diff --git a/tracker-pt/ftnoir_tracker_pt.cpp b/tracker-pt/ftnoir_tracker_pt.cpp
index eaf1de0d..fa3fbb46 100644
--- a/tracker-pt/ftnoir_tracker_pt.cpp
+++ b/tracker-pt/ftnoir_tracker_pt.cpp
@@ -18,6 +18,8 @@
//#define PT_PERF_LOG //log performance
+constexpr f Tracker_PT::pi;
+
//-----------------------------------------------------------------------------
Tracker_PT::Tracker_PT() :
video_widget(nullptr),
diff --git a/tracker-pt/ftnoir_tracker_pt.h b/tracker-pt/ftnoir_tracker_pt.h
index 29902260..047aedda 100644
--- a/tracker-pt/ftnoir_tracker_pt.h
+++ b/tracker-pt/ftnoir_tracker_pt.h
@@ -11,12 +11,13 @@
#include "api/plugin-api.hpp"
#include "ftnoir_tracker_pt_settings.h"
+using namespace pt_types;
+
#include "camera.h"
#include "point_extractor.h"
#include "point_tracker.h"
#include "compat/timer.hpp"
#include "cv/video-widget.hpp"
-#include "compat/pi-constant.hpp"
#include <QThread>
#include <QMutex>
@@ -30,9 +31,9 @@ class TrackerDialog_PT;
//-----------------------------------------------------------------------------
// Constantly processes the tracking chain in a separate thread
-class Tracker_PT : public QThread, public ITracker, private pt_types
+class Tracker_PT : public QThread, public ITracker
{
- static constexpr double pi = OPENTRACK_PI;
+ static constexpr f pi = constants::pi;
Q_OBJECT
friend class camera_dialog;
diff --git a/tracker-pt/ftnoir_tracker_pt_settings.cpp b/tracker-pt/ftnoir_tracker_pt_settings.cpp
new file mode 100644
index 00000000..e685960c
--- /dev/null
+++ b/tracker-pt/ftnoir_tracker_pt_settings.cpp
@@ -0,0 +1,8 @@
+#include "ftnoir_tracker_pt_settings.h"
+
+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 8c86fc14..b3f9e402 100644
--- a/tracker-pt/ftnoir_tracker_pt_settings.h
+++ b/tracker-pt/ftnoir_tracker_pt_settings.h
@@ -12,12 +12,15 @@
#include <limits>
#include <opencv2/core.hpp>
-struct pt_types
-{
+namespace pt_types {
using f = double;
- static constexpr f eps = std::numeric_limits<f>::epsilon();
- static constexpr f pi = f(OPENTRACK_PI);
+ struct constants final
+ {
+ 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>;
using vec2 = vec<2>;
@@ -26,7 +29,7 @@ struct pt_types
template<int y, int x> using mat = cv::Matx<f, y, x>;
using mat33 = mat<3, 3>;
using mat22 = mat<2, 2>;
-};
+}
#include "options/options.hpp"
using namespace options;
diff --git a/tracker-pt/point_extractor.cpp b/tracker-pt/point_extractor.cpp
index 5e72c3be..6411fcef 100644
--- a/tracker-pt/point_extractor.cpp
+++ b/tracker-pt/point_extractor.cpp
@@ -19,12 +19,14 @@
#include <algorithm>
#include <cinttypes>
+constexpr double PointExtractor::pi;
+
PointExtractor::PointExtractor()
{
blobs.reserve(max_blobs);
}
-void PointExtractor::extract_points(cv::Mat& frame, std::vector<PointExtractor::vec2>& points)
+void PointExtractor::extract_points(cv::Mat& frame, std::vector<vec2>& points)
{
using std::sqrt;
using std::max;
diff --git a/tracker-pt/point_extractor.h b/tracker-pt/point_extractor.h
index 0a019ec0..5ebd8056 100644
--- a/tracker-pt/point_extractor.h
+++ b/tracker-pt/point_extractor.h
@@ -13,11 +13,12 @@
#include <opencv2/imgproc/imgproc.hpp>
#include "ftnoir_tracker_pt_settings.h"
-#include "compat/pi-constant.hpp"
#include <vector>
-class PointExtractor final : private pt_types
+using namespace pt_types;
+
+class PointExtractor final
{
public:
// extracts points from frame and draws some processing info into frame, if draw_output is set
@@ -28,7 +29,7 @@ public:
settings_pt s;
private:
- static constexpr double pi = OPENTRACK_PI;
+ 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 701c1961..96a75ea8 100644
--- a/tracker-pt/point_tracker.cpp
+++ b/tracker-pt/point_tracker.cpp
@@ -6,6 +6,10 @@
*/
#include "point_tracker.h"
+
+#include "ftnoir_tracker_pt_settings.h"
+using namespace pt_types;
+
#include "compat/nan.hpp"
#include <vector>
@@ -14,9 +18,6 @@
#include <QDebug>
-using mat33 = pt_types::mat33;
-using vec3 = pt_types::vec3;
-using f = pt_types::f;
constexpr unsigned PointModel::N_POINTS;
static void get_row(const mat33& m, int i, vec3& v)
@@ -206,6 +207,9 @@ 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);
@@ -349,7 +353,7 @@ int PointTracker::POSIT(const PointModel& model, const PointOrder& order_, f foc
return i;
}
-pt_types::vec2 PointTracker::project(const vec3& v_M, f focal_length)
+vec2 PointTracker::project(const vec3& v_M, f focal_length)
{
vec3 v_C = X_CM * v_M;
return vec2(focal_length*v_C[0]/v_C[2], focal_length*v_C[1]/v_C[2]);
diff --git a/tracker-pt/point_tracker.h b/tracker-pt/point_tracker.h
index 6ed91069..3d2c9645 100644
--- a/tracker-pt/point_tracker.h
+++ b/tracker-pt/point_tracker.h
@@ -9,13 +9,16 @@
#define POINTTRACKER_H
#include "compat/timer.hpp"
+
#include "ftnoir_tracker_pt_settings.h"
+using namespace pt_types;
+
#include <opencv2/core/core.hpp>
#include <memory>
#include <vector>
#include <QObject>
-class Affine final : private pt_types
+class Affine final
{
public:
Affine() : R(mat33::eye()), t(0,0,0) {}
@@ -30,17 +33,17 @@ inline Affine operator*(const Affine& X, const Affine& Y)
return Affine(X.R*Y.R, X.R*Y.t + X.t);
}
-inline Affine operator*(const pt_types::mat33& X, const Affine& Y)
+inline Affine operator*(const mat33& X, const Affine& Y)
{
return Affine(X*Y.R, X*Y.t);
}
-inline Affine operator*(const Affine& X, const pt_types::mat33& Y)
+inline Affine operator*(const Affine& X, const mat33& Y)
{
return Affine(X.R*Y, X.t);
}
-inline pt_types::vec3 operator*(const Affine& X, const pt_types::vec3& v)
+inline vec3 operator*(const Affine& X, const vec3& v)
{
return X.R*v + X.t;
}
@@ -49,7 +52,7 @@ inline pt_types::vec3 operator*(const Affine& X, const pt_types::vec3& v)
// Describes a 3-point model
// nomenclature as in
// [Denis Oberkampf, Daniel F. DeMenthon, Larry S. Davis: "Iterative Pose Estimation Using Coplanar Feature Points"]
-class PointModel final : private pt_types
+class PointModel final
{
friend class PointTracker;
public:
@@ -73,7 +76,7 @@ public:
// Tracks a 3-point model
// implementing the POSIT algorithm for coplanar points as presented in
// [Denis Oberkampf, Daniel F. DeMenthon, Larry S. Davis: "Iterative Pose Estimation Using Coplanar Feature Points"]
-class PointTracker final : private pt_types
+class PointTracker final
{
public:
PointTracker();
@@ -82,7 +85,7 @@ public:
// dt : time since last call
void track(const std::vector<vec2>& projected_points, const PointModel& model, f focal_length, bool dynamic_pose, int init_phase_timeout, int w, int h);
Affine pose() { return X_CM; }
- vec2 project(const vec3& v_M, PointTracker::f focal_length);
+ vec2 project(const vec3& v_M, f focal_length);
private:
// the points in model order