summaryrefslogtreecommitdiffhomepage
path: root/tracker-pt/module
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2019-01-07 11:01:19 +0100
committerStanislaw Halik <sthalik@misaki.pl>2019-01-16 07:48:46 +0100
commit22d3ded34963e663f289c181aa94b54f00693b34 (patch)
treeaad6c435cc1c04609315c8a03c3aa65e09451f26 /tracker-pt/module
parent442c6251669a387b1b8b75b9cb90eec6ee9a8b9b (diff)
tracker/{pt,wii}: allow float/double in cv/numeric
Diffstat (limited to 'tracker-pt/module')
-rw-r--r--tracker-pt/module/camera.cpp6
-rw-r--r--tracker-pt/module/camera.h6
-rw-r--r--tracker-pt/module/frame.cpp2
-rw-r--r--tracker-pt/module/frame.hpp2
-rw-r--r--tracker-pt/module/point_extractor.cpp22
5 files changed, 19 insertions, 19 deletions
diff --git a/tracker-pt/module/camera.cpp b/tracker-pt/module/camera.cpp
index 86cffd72..1afecc92 100644
--- a/tracker-pt/module/camera.cpp
+++ b/tracker-pt/module/camera.cpp
@@ -60,12 +60,12 @@ Camera::result Camera::get_frame(pt_frame& frame_)
if (new_frame)
{
- const double dt = t.elapsed_seconds();
+ const f dt = (f)t.elapsed_seconds();
t.start();
// measure fps of valid frames
- constexpr double RC = .1; // seconds
- const double alpha = dt/(dt + RC);
+ constexpr f RC = f{1}/10; // seconds
+ const f alpha = dt/(dt + RC);
if (dt_mean < dt_eps)
dt_mean = dt;
diff --git a/tracker-pt/module/camera.h b/tracker-pt/module/camera.h
index 8abe6cf0..69b2f860 100644
--- a/tracker-pt/module/camera.h
+++ b/tracker-pt/module/camera.h
@@ -33,13 +33,13 @@ struct Camera final : pt_camera
QString get_desired_name() const override;
QString get_active_name() const override;
- void set_fov(double value) override { fov = value; }
+ void set_fov(f value) override { fov = value; }
void show_camera_settings() override;
private:
[[nodiscard]] bool get_frame_(cv::Mat& frame);
- double dt_mean = 0, fov = 30;
+ f dt_mean = 0, fov = 30;
Timer t;
pt_camera_info cam_info;
pt_camera_info cam_desired;
@@ -56,7 +56,7 @@ private:
pt_settings s;
- static constexpr inline double dt_eps = 1./256;
+ static constexpr inline f dt_eps = f{1}/256;
};
} // ns pt_module
diff --git a/tracker-pt/module/frame.cpp b/tracker-pt/module/frame.cpp
index 7dd8c92f..c88099f1 100644
--- a/tracker-pt/module/frame.cpp
+++ b/tracker-pt/module/frame.cpp
@@ -52,7 +52,7 @@ QImage Preview::get_bitmap()
QImage::Format_ARGB32);
}
-void Preview::draw_head_center(double x, double y)
+void Preview::draw_head_center(f x, f y)
{
auto [px_, py_] = to_pixel_pos(x, y, frame_copy.cols, frame_copy.rows);
diff --git a/tracker-pt/module/frame.hpp b/tracker-pt/module/frame.hpp
index d440bd67..89334599 100644
--- a/tracker-pt/module/frame.hpp
+++ b/tracker-pt/module/frame.hpp
@@ -26,7 +26,7 @@ struct Preview final : pt_preview
Preview& operator=(const pt_frame& frame) override;
QImage get_bitmap() override;
- void draw_head_center(double x, double y) override;
+ void draw_head_center(f x, f y) override;
operator cv::Mat&() { return frame_copy; }
operator cv::Mat const&() const { return frame_copy; }
diff --git a/tracker-pt/module/point_extractor.cpp b/tracker-pt/module/point_extractor.cpp
index 0f7af939..1d5d4a06 100644
--- a/tracker-pt/module/point_extractor.cpp
+++ b/tracker-pt/module/point_extractor.cpp
@@ -52,7 +52,7 @@ algorithm for tracking single particles with variable size and shape." (2008).
static cv::Vec2d MeanShiftIteration(const cv::Mat &frame_gray, const vec2 &current_center, f filter_width)
{
// Most amazingly this function runs faster with doubles than with floats.
- const f s = 1.0 / filter_width;
+ const f s = 1 / filter_width;
f m = 0;
vec2 com { 0, 0 };
@@ -62,12 +62,12 @@ static cv::Vec2d MeanShiftIteration(const cv::Mat &frame_gray, const vec2 &curre
for (int j = 0; j < frame_gray.cols; j++)
{
f val = frame_ptr[j];
- val = val * val; // taking the square wights brighter parts of the image stronger.
+ val = val * val; // taking the square weighs brighter parts of the image stronger.
{
f dx = (j - current_center[0])*s;
f dy = (i - current_center[1])*s;
- f f = std::fmax(0, 1 - dx*dx - dy*dy);
- val *= f;
+ f max = std::fmax(f{0}, 1 - dx*dx - dy*dy);
+ val *= max;
}
m += val;
com[0] += j * val;
@@ -76,7 +76,7 @@ static cv::Vec2d MeanShiftIteration(const cv::Mat &frame_gray, const vec2 &curre
}
if (m > f(.1))
{
- com *= f(1) / m;
+ com *= 1 / m;
return com;
}
else
@@ -93,7 +93,7 @@ PointExtractor::PointExtractor(const QString& module_name) : s(module_name)
void PointExtractor::ensure_channel_buffers(const cv::Mat& orig_frame)
{
if (ch[0].rows != orig_frame.rows || ch[0].cols != orig_frame.cols)
- for (unsigned k = 0; k < 3; k++)
+ for (unsigned k = 0; k < 3; k++) // NOLINT(modernize-loop-convert)
ch[k] = cv::Mat1b(orig_frame.rows, orig_frame.cols);
}
@@ -176,7 +176,7 @@ void PointExtractor::threshold_image(const cv::Mat& frame_gray, cv::Mat1b& outpu
cv::noArray(),
hist,
1,
- (int const*) &hist_size,
+ &hist_size,
&ranges);
const f radius = (f) threshold_radius_value(frame_gray.cols, frame_gray.rows, threshold_slider_value);
@@ -217,8 +217,8 @@ void PointExtractor::extract_points(const pt_frame& frame_, pt_preview& preview_
threshold_image(frame_gray_unmasked, frame_bin);
frame_gray_unmasked.copyTo(frame_gray, frame_bin);
- const f region_size_min = s.min_point_size;
- const f region_size_max = s.max_point_size;
+ const f region_size_min = (f)s.min_point_size;
+ const f region_size_max = (f)s.max_point_size;
unsigned idx = 0;
@@ -309,7 +309,7 @@ end:
static constexpr f radius_c = f(1.75);
const f kernel_radius = b.radius * radius_c;
- vec2 pos(rect.width/2., rect.height/2.); // position relative to ROI.
+ vec2 pos(rect.width/f{2}, rect.height/f{2}); // position relative to ROI.
for (int iter = 0; iter < 10; ++iter)
{
@@ -329,7 +329,7 @@ end:
blob& b = blobs[k];
const f dpi = preview_frame.cols / f(320);
- const f offx = 10 * dpi, offy = 7.5 * dpi;
+ const f offx = 10 * dpi, offy = f{7.5} * dpi;
const f cx = preview_frame.cols / f(frame.cols),
cy = preview_frame.rows / f(frame.rows),