summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2016-12-09 18:45:48 +0100
committerStanislaw Halik <sthalik@misaki.pl>2016-12-09 18:45:48 +0100
commita26f0a51ccc21067dbacf6f9f5bcd8d4fe6dd15e (patch)
tree631fdc8a57db6cbaba89a30eba528125b303fac5
parentaa6b0e3841991272668ea02b1a7166c03e59e84a (diff)
tracker/pt: show right overlay wrt frame size
-rw-r--r--tracker-pt/ftnoir_tracker_pt.cpp15
-rw-r--r--tracker-pt/point_extractor.cpp12
2 files changed, 19 insertions, 8 deletions
diff --git a/tracker-pt/ftnoir_tracker_pt.cpp b/tracker-pt/ftnoir_tracker_pt.cpp
index 9b78a16a..d0f65e7b 100644
--- a/tracker-pt/ftnoir_tracker_pt.cpp
+++ b/tracker-pt/ftnoir_tracker_pt.cpp
@@ -135,16 +135,23 @@ void Tracker_PT::run()
auto fun = [&](const vec2& p, const cv::Scalar& color)
{
using std::round;
+ using std::sqrt;
+ using std::max;
+
+ static constexpr int frame_size = 400;
+ const int size = max(1, iround(sqrt(frame.rows*frame.rows + frame.cols*frame.cols) / frame_size));
+ const int len = size * 10;
+
cv::Point p2(int(round(p[0] * frame_.cols + frame_.cols/2)),
int(round(-p[1] * frame_.cols + frame_.rows/2)));
cv::line(frame_,
- cv::Point(p2.x - 20, p2.y),
- cv::Point(p2.x + 20, p2.y),
+ cv::Point(p2.x - len, p2.y),
+ cv::Point(p2.x + len, p2.y),
color,
2);
cv::line(frame_,
- cv::Point(p2.x, p2.y - 20),
- cv::Point(p2.x, p2.y + 20),
+ cv::Point(p2.x, p2.y - len),
+ cv::Point(p2.x, p2.y + len),
color,
2);
};
diff --git a/tracker-pt/point_extractor.cpp b/tracker-pt/point_extractor.cpp
index 272e73c0..d18ba513 100644
--- a/tracker-pt/point_extractor.cpp
+++ b/tracker-pt/point_extractor.cpp
@@ -195,16 +195,20 @@ void PointExtractor::extract_points(cv::Mat& frame, std::vector<vec2>& points)
blob b(radius, cv::Vec2d(m10 / N, m01 / N), N/sqrt(double(cnt)), rect);
blobs.push_back(b);
+
+ static constexpr int frame_size = 400;
+ const int size = std::max(1, iround(std::sqrt(frame.rows*frame.rows + frame.cols*frame.cols) / frame_size));
+
{
char buf[64];
sprintf(buf, "%.2fpx", radius);
cv::putText(frame,
buf,
- cv::Point((int)round(b.pos[0]+30), (int)round(b.pos[1]+20)),
- cv::FONT_HERSHEY_DUPLEX,
- 1,
+ cv::Point((int)round(b.pos[0]+15*size), (int)round(b.pos[1]+10*size)),
+ cv::FONT_HERSHEY_PLAIN,
+ size,
cv::Scalar(0, 0, 255),
- 1);
+ 2);
}
if (idx >= max_blobs) goto end;