summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2017-04-18 08:52:34 +0200
committerStanislaw Halik <sthalik@misaki.pl>2017-04-18 08:52:34 +0200
commit7df7c40a5d5eaed89fb89445348c3c7cdc8632e9 (patch)
tree49633cc6d74f4f46bb1cd9057570c6b34baa64db
parent39acca95501fa7b0d77f8e6d2cbf97f45cff4ebf (diff)
many: use std::f{max,min} for floating-point values
-rw-r--r--filter-accela/ftnoir_filter_accela.cpp1
-rw-r--r--filter-ewma2/ftnoir_filter_ewma2.cpp4
-rw-r--r--filter-ewma2/ftnoir_filter_ewma2_dialog.cpp3
-rw-r--r--filter-kalman/kalman.cpp2
-rw-r--r--gui/mapping-window.cpp2
-rw-r--r--pose-widget/pose-widget.cpp2
-rw-r--r--spline/spline.cpp2
-rw-r--r--tracker-aruco/ftnoir_tracker_aruco.cpp2
-rw-r--r--tracker-pt/point_extractor.cpp13
9 files changed, 13 insertions, 18 deletions
diff --git a/filter-accela/ftnoir_filter_accela.cpp b/filter-accela/ftnoir_filter_accela.cpp
index ea4dfcbd..1761dc45 100644
--- a/filter-accela/ftnoir_filter_accela.cpp
+++ b/filter-accela/ftnoir_filter_accela.cpp
@@ -15,7 +15,6 @@ using std::fabs;
using std::sqrt;
using std::pow;
using std::copysign;
-using std::max;
constexpr double settings_accela::rot_gains[16][2];
constexpr double settings_accela::pos_gains[16][2];
diff --git a/filter-ewma2/ftnoir_filter_ewma2.cpp b/filter-ewma2/ftnoir_filter_ewma2.cpp
index 687b5589..c79596ef 100644
--- a/filter-ewma2/ftnoir_filter_ewma2.cpp
+++ b/filter-ewma2/ftnoir_filter_ewma2.cpp
@@ -51,7 +51,7 @@ void ewma::filter(const double *input, double *output)
const double smoothing_scale_curve = static_cast<slider_value>(s.kSmoothingScaleCurve);
// min/max smoothing .01->1
const double min_smoothing = static_cast<slider_value>(s.kMinSmoothing);
- const double max_smoothing = std::max(min_smoothing, static_cast<slider_value>(s.kMaxSmoothing).cur());
+ const double max_smoothing = std::fmax(min_smoothing, static_cast<slider_value>(s.kMaxSmoothing));
// Calculate the new camera position.
for (int i=0;i<6;i++)
@@ -65,7 +65,7 @@ void ewma::filter(const double *input, double *output)
double noise = last_delta[i]*last_delta[i];
last_noise[i] = noise_alpha*noise + (1.0-noise_alpha)*last_noise[i];
// Normalise the noise between 0->1 for 0->9 variances (0->3 stddevs).
- double norm_noise = last_noise[i] < 1e-10 ? 0 : std::min<double>(noise/(9.0*last_noise[i]), 1.0);
+ double norm_noise = last_noise[i] < 1e-10 ? 0 : std::fmin(noise/(9.0*last_noise[i]), 1.0);
// Calculate the smoothing 0.0->1.0 from the normalized noise.
double smoothing = 1.0 - pow(norm_noise, smoothing_scale_curve);
double RC = (min_smoothing + smoothing*(max_smoothing - min_smoothing));
diff --git a/filter-ewma2/ftnoir_filter_ewma2_dialog.cpp b/filter-ewma2/ftnoir_filter_ewma2_dialog.cpp
index 5372767d..ad07737b 100644
--- a/filter-ewma2/ftnoir_filter_ewma2_dialog.cpp
+++ b/filter-ewma2/ftnoir_filter_ewma2_dialog.cpp
@@ -20,9 +20,6 @@ dialog_ewma::dialog_ewma()
connect(ui.minSmooth, &QSlider::valueChanged, this, &dialog_ewma::update_labels);
connect(ui.maxSmooth, &QSlider::valueChanged, this, &dialog_ewma::update_labels);
- using std::min;
- using std::max;
-
connect(ui.minSmooth, &QSlider::valueChanged, this,
[&](int v) -> void { if (ui.maxSmooth->value() < v) ui.maxSmooth->setValue(v); });
diff --git a/filter-kalman/kalman.cpp b/filter-kalman/kalman.cpp
index 5bd520ee..559f1ea5 100644
--- a/filter-kalman/kalman.cpp
+++ b/filter-kalman/kalman.cpp
@@ -76,7 +76,7 @@ void KalmanProcessNoiseScaler::update(KalmanFilter &kf, double dt)
{
alpha = T1 / T2;
alpha = std::sqrt(alpha);
- alpha = std::min(1000., std::max(0.001, alpha));
+ alpha = std::fmin(1000., std::fmax(0.001, alpha));
}
kf.process_noise_cov = alpha * base_cov;
//qDebug() << "alpha = " << alpha;
diff --git a/gui/mapping-window.cpp b/gui/mapping-window.cpp
index 71282d84..64e2dd48 100644
--- a/gui/mapping-window.cpp
+++ b/gui/mapping-window.cpp
@@ -96,7 +96,7 @@ void MapWidget::load()
qfc.set_snap(1, 2.5);
else
{
- const double x_snap = std::max(.5, conf.max_input() / 100.);
+ const double x_snap = std::fmax(.5, conf.max_input() / 100.);
qfc.set_snap(x_snap, 1);
}
});
diff --git a/pose-widget/pose-widget.cpp b/pose-widget/pose-widget.cpp
index 976bd981..aee2d628 100644
--- a/pose-widget/pose-widget.cpp
+++ b/pose-widget/pose-widget.cpp
@@ -355,7 +355,7 @@ vec2 pose_transform::project(const vec3 &point)
using std::fabs;
vec3 ret = rotation * point;
- num z = std::max<num>(.5, 1 + translation.z()/-80);
+ num z = std::fmax(num(.5), 1 + translation.z()/-80);
num w = width, h = height;
num x = w * translation.x() / 2 / -80;
if (fabs(x) > w/2)
diff --git a/spline/spline.cpp b/spline/spline.cpp
index 2db23c14..0f606173 100644
--- a/spline/spline.cpp
+++ b/spline/spline.cpp
@@ -111,7 +111,7 @@ float spline::get_value_no_save_internal(double x)
QMutexLocker foo(&_mutex);
if (max_x > 0)
- x = std::min(max_x, x);
+ x = std::fmin(max_x, x);
float q = float(x * precision(s->points));
int xi = (int)q;
diff --git a/tracker-aruco/ftnoir_tracker_aruco.cpp b/tracker-aruco/ftnoir_tracker_aruco.cpp
index edb6ffcc..7a19b0d3 100644
--- a/tracker-aruco/ftnoir_tracker_aruco.cpp
+++ b/tracker-aruco/ftnoir_tracker_aruco.cpp
@@ -410,7 +410,7 @@ void aruco_tracker::run()
const double dt = last_detection_timer.elapsed_seconds();
last_detection_timer.start();
no_detection_timeout -= dt * timeout_backoff_c;
- no_detection_timeout = std::max(0., no_detection_timeout);
+ no_detection_timeout = std::fmax(0., no_detection_timeout);
}
set_last_roi();
diff --git a/tracker-pt/point_extractor.cpp b/tracker-pt/point_extractor.cpp
index 4bd92d44..11818334 100644
--- a/tracker-pt/point_extractor.cpp
+++ b/tracker-pt/point_extractor.cpp
@@ -54,7 +54,7 @@ static cv::Vec2d MeanShiftIteration(const cv::Mat &frame_gray, const cv::Vec2d &
{
double dx = (j - current_center[0])*s;
double dy = (i - current_center[1])*s;
- double f = std::max(0.0, 1.0 - dx*dx - dy*dy);
+ double f = std::fmax(0.0, 1.0 - dx*dx - dy*dy);
val *= f;
}
m += val;
@@ -79,7 +79,7 @@ PointExtractor::PointExtractor()
void PointExtractor::extract_points(const cv::Mat& frame, cv::Mat& preview_frame, std::vector<vec2>& points)
{
using std::sqrt;
- using std::max;
+ using std::fmax;
using std::round;
using std::sort;
@@ -114,7 +114,7 @@ void PointExtractor::extract_points(const cv::Mat& frame, cv::Mat& preview_frame
static constexpr double min_radius = 2.5;
static constexpr double max_radius = 15;
- const double radius = max(0., (max_radius-min_radius) * s.threshold / 255 + min_radius);
+ const double radius = fmax(0., (max_radius-min_radius) * s.threshold / 255 + min_radius);
const float* ptr = reinterpret_cast<const float*>(hist.ptr(0));
const unsigned area = unsigned(round(3 * M_PI * radius*radius));
const unsigned sz = unsigned(hist.cols * hist.rows);
@@ -196,15 +196,14 @@ void PointExtractor::extract_points(const cv::Mat& frame, cv::Mat& preview_frame
{
static const f offx = 10, offy = 7.5;
const f cx = preview_frame.cols / f(frame.cols),
- cy = preview_frame.rows / f(frame.rows);
+ cy = preview_frame.rows / f(frame.rows),
+ c_ = (cx+cy)/2;
cv::Point p(iround(b.pos[0] * cx), iround(b.pos[1] * cy));
static const cv::Scalar color(0, 255, 0);
- cv::circle(preview_frame, p, b.radius, color);
-
{
- const int len = iround(b.radius * 1.25) + 1;
+ const int len = iround(b.radius * 1.25 * c_) + 1;
cv::line(preview_frame,
cv::Point(p.x - len, p.y),
cv::Point(p.x + len, p.y),