summaryrefslogtreecommitdiffhomepage
path: root/tracker-pt/point_extractor.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2017-07-16 16:57:59 +0200
committerStanislaw Halik <sthalik@misaki.pl>2017-07-16 16:57:59 +0200
commite016dca372bf69f3bb4967a8aba374bc04aea3b4 (patch)
tree73249375dc7a666acee8c7349e56c095cd6e4369 /tracker-pt/point_extractor.cpp
parent1ac33e5d5aea97448c71ea58b12492ae219e88f1 (diff)
compat/math-imports: use it
Diffstat (limited to 'tracker-pt/point_extractor.cpp')
-rw-r--r--tracker-pt/point_extractor.cpp19
1 files changed, 7 insertions, 12 deletions
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;