diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2018-01-03 14:10:14 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2018-01-03 14:35:57 +0100 |
commit | 69575c27d57c84100bcf5e41ea5f4d9e6b2626c6 (patch) | |
tree | aa2cefe5baef436bc314da44652585427203ed15 | |
parent | 12bc32c4216541dc6d560dec2434e78de3f0e6e7 (diff) |
tracker/pt: more accurate dynamic threshold
-rw-r--r-- | tracker-pt/point_extractor.cpp | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/tracker-pt/point_extractor.cpp b/tracker-pt/point_extractor.cpp index 64fce324..5c8dc7d7 100644 --- a/tracker-pt/point_extractor.cpp +++ b/tracker-pt/point_extractor.cpp @@ -178,7 +178,7 @@ void PointExtractor::threshold_image(const cv::Mat& frame_gray, cv::Mat1b& outpu const f radius = (f) threshold_radius_value(frame_gray.cols, frame_gray.rows, threshold_slider_value); - auto ptr = (float const* restrict_ptr) hist.ptr(0); + auto ptr = (float const* const restrict_ptr) hist.ptr(0); const unsigned area = uround(3 * M_PI * radius*radius); const unsigned sz = unsigned(hist.cols * hist.rows); unsigned thres = 32; @@ -186,10 +186,8 @@ void PointExtractor::threshold_image(const cv::Mat& frame_gray, cv::Mat1b& outpu { cnt += ptr[i]; if (cnt >= area) - { - thres = i; break; - } + thres = i; } cv::threshold(frame_gray, output, thres, 255, CV_THRESH_BINARY); @@ -203,7 +201,7 @@ double PointExtractor::threshold_radius_value(int w, int h, int threshold) const double min_radius = 1.75 * cx; const double max_radius = 15 * cy; - const double radius = std::fmax(0., (max_radius-min_radius) * threshold / 255 + min_radius); + const double radius = std::fmax(0., (max_radius-min_radius) * threshold / f(255) + min_radius); return radius; } @@ -253,8 +251,8 @@ void PointExtractor::extract_points(const cv::Mat& frame, cv::Mat& preview_frame for (int i=rect.y; i < ymax; i++) { - unsigned char* restrict_ptr ptr_blobs = frame_blobs.ptr(i); - unsigned char const* restrict_ptr ptr_gray = frame_gray.ptr(i); + unsigned char const* const restrict_ptr ptr_blobs = frame_blobs.ptr(i); + unsigned char const* const restrict_ptr ptr_gray = frame_gray.ptr(i); for (int j=rect.x; j < xmax; j++) { if (ptr_blobs[j] != idx) |