diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2017-07-26 11:31:01 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2017-07-26 11:31:01 +0200 |
commit | 7a8d24eb7a003e9709939fb6470445e1f0c1034d (patch) | |
tree | 5933a07909d0307d1c43f39f890f3601012368a4 /tracker-pt | |
parent | bb798c188b2fc1b368e91ac5d813d805e2d17e72 (diff) |
tracker/pt: scale min/max radius with resolution
For 320x240 frames auto threshold min value of 2.5 was
too big. Scale it linearly with frame size.
Diffstat (limited to 'tracker-pt')
-rw-r--r-- | tracker-pt/point_extractor.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/tracker-pt/point_extractor.cpp b/tracker-pt/point_extractor.cpp index 5339f982..f5df30a9 100644 --- a/tracker-pt/point_extractor.cpp +++ b/tracker-pt/point_extractor.cpp @@ -125,16 +125,18 @@ void PointExtractor::extract_points(const cv::Mat& frame, cv::Mat& preview_frame hist_ranges, false); - static constexpr double min_radius = 2.5; - static constexpr double max_radius = 15; + const double cx = frame.cols / 640., cy = frame.rows / 480.; + + const double min_radius = 1.75 * cx; + const double max_radius = 15 * cy; const float* restrict ptr = reinterpret_cast<const float*>(hist.data); - const double radius = fmax(0., (max_radius-min_radius) * s.threshold / 255 + min_radius); + const double radius = (max_radius-min_radius) * s.threshold / 255 + min_radius; const unsigned area = uround(3 * M_PI * radius * radius); - unsigned thres = 255; + unsigned thres = 32; unsigned accum = 0; - for (unsigned k = 255; k != 16; k--) + for (unsigned k = 255; k != 32; k--) { accum += ptr[k]; if (accum >= area) @@ -173,7 +175,7 @@ void PointExtractor::extract_points(const cv::Mat& frame, cv::Mat& preview_frame const double radius = sqrt(area) / sqrt(M_PI); - if (radius < fmax(2.5, region_size_min) || (radius > region_size_max)) + if (radius < region_size_min || radius > region_size_max) continue; const cv::Rect rect = cv::boundingRect(contours[k]) & cv::Rect(0, 0, frame.cols, frame.rows); |