From 05203f39e6314c09f65d69c028b9f9d864de3f7b Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 22 Aug 2015 12:10:10 +0200 Subject: pt: show extracted points' areas and success count --- ftnoir_tracker_pt/point_extractor.cpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'ftnoir_tracker_pt') diff --git a/ftnoir_tracker_pt/point_extractor.cpp b/ftnoir_tracker_pt/point_extractor.cpp index 7174d719..65ac653a 100644 --- a/ftnoir_tracker_pt/point_extractor.cpp +++ b/ftnoir_tracker_pt/point_extractor.cpp @@ -64,6 +64,18 @@ std::vector PointExtractor::extract_points(cv::Mat& frame) ret *= 1./norm; return ret; } + + double effective_area() const + { + double norm = 0, ret = 0; + for (unsigned i = 0; i < areas.size(); i++) + { + const double w = confids[i]; + norm += w; + ret += w * areas[i]; + } + return ret/norm; + } }; struct simple_blob @@ -82,7 +94,7 @@ std::vector PointExtractor::extract_points(cv::Mat& frame) cv::Vec2d tmp = pos - other.pos; return tmp.dot(tmp) < radius_2; } - static std::vector merge(std::vector& blobs) + static std::vector merge(cv::Mat& frame, std::vector& blobs) { #ifdef DEBUG_EXTRACTION static Timer t; @@ -117,6 +129,11 @@ std::vector PointExtractor::extract_points(cv::Mat& frame) } if (b_.pos.size() >= successes) ret.push_back(b_); + + char buf[64]; + sprintf(buf, "%d%% %d px", b_.pos.size()*100/successes, (int)(2.*sqrt(b_.effective_area()) / sqrt(3.14))); + const auto pos = b_.effective_pos(); + cv::putText(frame, buf, cv::Point(pos[0]+30, pos[1]+20), cv::FONT_HERSHEY_DUPLEX, 1, cv::Scalar(0, 0, 255), 1); } #ifdef DEBUG_EXTRACTION if (debug) @@ -204,7 +221,7 @@ std::vector PointExtractor::extract_points(cv::Mat& frame) // clear old points points.clear(); - for (auto& b : simple_blob::merge(blobs)) + for (auto& b : simple_blob::merge(frame, blobs)) { auto pos = b.effective_pos(); cv::Vec2f p((pos[0] - W/2)/W, -(pos[1] - H/2)/W); -- cgit v1.2.3