summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2015-08-22 12:10:10 +0200
committerStanislaw Halik <sthalik@misaki.pl>2015-08-22 12:45:29 +0200
commit05203f39e6314c09f65d69c028b9f9d864de3f7b (patch)
tree58cb2d169f2965d4261ed5a4617fc312d0cb7836
parente02d939c269d0a1b0d387b74f1d767e7c65c14b8 (diff)
pt: show extracted points' areas and success count
-rw-r--r--ftnoir_tracker_pt/point_extractor.cpp21
1 files changed, 19 insertions, 2 deletions
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<cv::Vec2f> 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<cv::Vec2f> PointExtractor::extract_points(cv::Mat& frame)
cv::Vec2d tmp = pos - other.pos;
return tmp.dot(tmp) < radius_2;
}
- static std::vector<blob> merge(std::vector<simple_blob>& blobs)
+ static std::vector<blob> merge(cv::Mat& frame, std::vector<simple_blob>& blobs)
{
#ifdef DEBUG_EXTRACTION
static Timer t;
@@ -117,6 +129,11 @@ std::vector<cv::Vec2f> 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<cv::Vec2f> 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);