diff options
-rw-r--r-- | compat/euler.cpp | 10 | ||||
-rw-r--r-- | compat/math-imports.hpp | 23 | ||||
-rw-r--r-- | filter-accela/ftnoir_filter_accela.cpp | 2 | ||||
-rw-r--r-- | tracker-aruco/ftnoir_tracker_aruco.cpp | 9 | ||||
-rw-r--r-- | tracker-pt/camera.cpp | 5 | ||||
-rw-r--r-- | tracker-pt/ftnoir_tracker_pt.cpp | 7 | ||||
-rw-r--r-- | tracker-pt/point_extractor.cpp | 19 | ||||
-rw-r--r-- | tracker-pt/point_tracker.cpp | 7 | ||||
-rw-r--r-- | tracker-test/test.cpp | 6 |
9 files changed, 26 insertions, 62 deletions
diff --git a/compat/euler.cpp b/compat/euler.cpp index f02365c9..a868478e 100644 --- a/compat/euler.cpp +++ b/compat/euler.cpp @@ -1,13 +1,11 @@ #include "euler.hpp" +#include "math-imports.hpp" #include <cmath> namespace euler { euler_t OTR_COMPAT_EXPORT rmat_to_euler(const rmat& R) { - using std::atan2; - using std::sqrt; - const double cy = sqrt(R(2,2)*R(2, 2) + R(2, 1)*R(2, 1)); const bool large_enough = cy > 1e-10; if (large_enough) @@ -31,9 +29,6 @@ rmat OTR_COMPAT_EXPORT euler_to_rmat(const euler_t& input) const double P = -input(1); const double B = -input(2); - using std::cos; - using std::sin; - const auto c1 = cos(H); const auto s1 = sin(H); const auto c2 = cos(P); @@ -63,9 +58,6 @@ void OTR_COMPAT_EXPORT tait_bryan_to_matrices(const euler_t& input, rmat& r_pitch, rmat& r_yaw) { - using std::cos; - using std::sin; - { const double phi = -input(2); const double sin_phi = sin(phi); diff --git a/compat/math-imports.hpp b/compat/math-imports.hpp index ad70f361..e4175b16 100644 --- a/compat/math-imports.hpp +++ b/compat/math-imports.hpp @@ -1,10 +1,12 @@ #pragma once -#include <cmath> -#include <cinttypes> - -namespace otr_math +template <typename T> +static inline constexpr auto signum(T x) { + return (T() < x) - (x < T()); +} + +#include <cmath> using std::copysign; @@ -27,19 +29,20 @@ using std::tan; using std::round; using std::fmod; +#include <cinttypes> + using std::uintptr_t; using std::intptr_t; using std::int64_t; using std::int32_t; +using std::int8_t; using std::uint64_t; using std::uint32_t; +using std::uint8_t; -template <typename T> -static inline constexpr auto signum(T x) -{ - return (T() < x) - (x < T()); -} +#include <algorithm> -} // ns otr_math +using std::min; +using std::max; diff --git a/filter-accela/ftnoir_filter_accela.cpp b/filter-accela/ftnoir_filter_accela.cpp index 92b9e197..5eac439a 100644 --- a/filter-accela/ftnoir_filter_accela.cpp +++ b/filter-accela/ftnoir_filter_accela.cpp @@ -13,8 +13,6 @@ #include "compat/math-imports.hpp" -using namespace otr_math; - constexpr settings_accela::gains settings_accela::rot_gains[16]; constexpr settings_accela::gains settings_accela::pos_gains[16]; diff --git a/tracker-aruco/ftnoir_tracker_aruco.cpp b/tracker-aruco/ftnoir_tracker_aruco.cpp index 388eebe6..aa12175d 100644 --- a/tracker-aruco/ftnoir_tracker_aruco.cpp +++ b/tracker-aruco/ftnoir_tracker_aruco.cpp @@ -10,6 +10,7 @@ #include "cv/video-property-page.hpp" #include "compat/camera-names.hpp" #include "compat/sleep.hpp" +#include "compat/math-imports.hpp" #include <opencv2/core.hpp> #include <opencv2/imgproc.hpp> @@ -224,9 +225,6 @@ cv::Point3f aruco_tracker::rotate_model(float x, float y, settings::rot mode) if (mode) { - using std::cos; - using std::sin; - const double theta = int(mode) * 90/4. * M_PI/180; pt.x = x * cos(theta) - y * sin(theta); pt.y = y * cos(theta) + x * sin(theta); @@ -365,11 +363,6 @@ void aruco_tracker::run() { cv::setNumThreads(0); - using std::fabs; - using std::atan; - using std::tan; - using std::sqrt; - if (!open_camera()) return; diff --git a/tracker-pt/camera.cpp b/tracker-pt/camera.cpp index b68fd107..28c95bf4 100644 --- a/tracker-pt/camera.cpp +++ b/tracker-pt/camera.cpp @@ -8,6 +8,7 @@ #include "camera.h" #include "compat/sleep.hpp" #include "compat/camera-names.hpp" +#include "compat/math-imports.hpp" constexpr double Camera::dt_eps; @@ -23,10 +24,6 @@ QString Camera::get_active_name() const void CamInfo::get_focal_length(double& fx) const { - using std::tan; - using std::atan; - using std::sqrt; - const double diag_len = 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; diff --git a/tracker-pt/ftnoir_tracker_pt.cpp b/tracker-pt/ftnoir_tracker_pt.cpp index 938acc1c..83ea094c 100644 --- a/tracker-pt/ftnoir_tracker_pt.cpp +++ b/tracker-pt/ftnoir_tracker_pt.cpp @@ -8,6 +8,7 @@ #include "ftnoir_tracker_pt.h" #include "compat/camera-names.hpp" +#include "compat/math-imports.hpp" #include <QHBoxLayout> #include <cmath> #include <QDebug> @@ -190,12 +191,6 @@ void Tracker_PT::data(double *data) 0, 1, 0); mat33 R = R_EG * X_GH.R * R_EG.t(); - using std::atan2; - using std::sqrt; - using std::atan; - using std::fabs; - using std::copysign; - // get translation(s) const vec3& t = X_GH.t; diff --git a/tracker-pt/point_extractor.cpp b/tracker-pt/point_extractor.cpp index fbd84799..babba294 100644 --- a/tracker-pt/point_extractor.cpp +++ b/tracker-pt/point_extractor.cpp @@ -8,6 +8,7 @@ #include "point_extractor.h" #include "compat/util.hpp" +#include "compat/math-imports.hpp" #include "point_tracker.h" #include <QDebug> @@ -20,10 +21,6 @@ #include <vector> #include <array> -using std::sqrt; -using std::fmax; -using std::min; - using namespace pt_extractor_impl; /* @@ -51,7 +48,7 @@ static cv::Vec2d MeanShiftIteration(const cv::Mat &frame_gray, const vec2 &curre vec2 com(0, 0); for (int i = 0; i < frame_gray.rows; i++) { - const auto frame_ptr = (const std::uint8_t*)frame_gray.ptr(i); + const auto frame_ptr = (const uint8_t*)frame_gray.ptr(i); for (int j = 0; j < frame_gray.cols; j++) { f val = frame_ptr[j]; @@ -145,7 +142,7 @@ void PointExtractor::extract_points(const cv::Mat& frame, cv::Mat& preview_frame contours.clear(); cv::findContours(frame_bin, contours, cv::RETR_LIST, cv::CHAIN_APPROX_SIMPLE); - const unsigned cnt = std::min<unsigned>(max_blobs, contours.size()); + const unsigned cnt = min(max_blobs, int(contours.size())); for (unsigned k = 0; k < cnt; k++) { @@ -155,14 +152,12 @@ void PointExtractor::extract_points(const cv::Mat& frame, cv::Mat& preview_frame cv::Moments moments = cv::moments(contours[k]); const double area = moments.m00; - const double radius = std::sqrt(area) / std::sqrt(M_PI); + const double radius = sqrt(area) / sqrt(M_PI); - if (radius < std::fmax(2.5, region_size_min) || (radius > region_size_max)) + if (radius < fmax(2.5, region_size_min) || (radius > region_size_max)) continue; - cv::Rect rect = cv::boundingRect(contours[k]) & cv::Rect(0, 0, frame.cols, frame.rows); - - rect &= cv::Rect(0, 0, frame.cols, frame.rows); // crop at frame boundaries + const cv::Rect rect = cv::boundingRect(contours[k]) & cv::Rect(0, 0, frame.cols, frame.rows); if (rect.width == 0 || rect.height == 0) continue; @@ -240,7 +235,7 @@ void PointExtractor::extract_points(const cv::Mat& frame, cv::Mat& preview_frame } #if defined DEBUG_MEANSHIFT - meanshift_total += std::sqrt((pos_ - pos).dot(pos_ - pos)); + meanshift_total += sqrt((pos_ - pos).dot(pos_ - pos)); #endif b.pos[0] = pos[0] + rect.x; diff --git a/tracker-pt/point_tracker.cpp b/tracker-pt/point_tracker.cpp index 73745d8f..dfc7a8a5 100644 --- a/tracker-pt/point_tracker.cpp +++ b/tracker-pt/point_tracker.cpp @@ -7,6 +7,7 @@ #include "point_tracker.h" #include "compat/nan.hpp" +#include "compat/math-imports.hpp" using namespace types; @@ -280,12 +281,6 @@ int PointTracker::POSIT(const PointModel& model, const PointOrder& order, f foca static constexpr int max_iter = 100; - using std::sqrt; - using std::atan; - using std::cos; - using std::sin; - using std::fabs; - int i=1; for (; i<max_iter; ++i) { diff --git a/tracker-test/test.cpp b/tracker-test/test.cpp index c0bc4ef3..86ad4495 100644 --- a/tracker-test/test.cpp +++ b/tracker-test/test.cpp @@ -8,6 +8,7 @@ #include "test.h" #include "api/plugin-api.hpp" +#include "compat/math-imports.hpp" #include <QPushButton> @@ -40,11 +41,6 @@ void test_tracker::start_tracker(QFrame*) void test_tracker::data(double *data) { - using std::fmod; - using std::sin; - using std::fabs; - using std::copysign; - const double dt = t.elapsed_seconds(); t.start(); |