From 1a95ca4dc340c246636aba1d1d8c8a7d7cd86e24 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 20 Jul 2016 08:17:57 +0200 Subject: tracker/pt: fix wrong input to flood fill The binary frame needs to be used, not grayscale. v2: Use brightness for sorting points. --- tracker-pt/point_extractor.cpp | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) (limited to 'tracker-pt/point_extractor.cpp') diff --git a/tracker-pt/point_extractor.cpp b/tracker-pt/point_extractor.cpp index b12c139a..c8ed261e 100644 --- a/tracker-pt/point_extractor.cpp +++ b/tracker-pt/point_extractor.cpp @@ -80,21 +80,21 @@ void PointExtractor::extract_points(cv::Mat& frame, std::vector max_blobs) break; - const unsigned char* ptr_bin = frame_bin.ptr(y); - for (int x=0; x < frame_gray.cols; x++) + const unsigned char* ptr_bin = frame_blobs.ptr(y); + for (int x=0; x < frame_blobs.cols; x++) { if (idx > max_blobs) break; if (ptr_bin[x] != 255) continue; - idx = blobs.size(); + idx = blobs.size() + 1; cv::Rect rect; cv::floodFill(frame_blobs, cv::Point(x,y), @@ -102,24 +102,26 @@ void PointExtractor::extract_points(cv::Mat& frame, std::vector region_size_max || radius < region_size_min) continue; const double norm = double(m00); - blob b(radius, cv::Vec2d(m10 / norm, m01 / norm)); + blob b(radius, cv::Vec2d(m10 / norm, m01 / norm), vals/(double)cnt); blobs.push_back(b); { char buf[64]; @@ -146,7 +148,7 @@ void PointExtractor::extract_points(cv::Mat& frame, std::vector bool { return b2.radius < b1.radius; }); + std::sort(blobs.begin(), blobs.end(), [](const blob& b1, const blob& b2) -> bool { return b2.brightness < b1.brightness; }); points.reserve(max_blobs); points.clear(); -- cgit v1.2.3