summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--tracker-pt/ftnoir_tracker_pt.cpp37
-rw-r--r--tracker-pt/point_extractor.cpp27
2 files changed, 38 insertions, 26 deletions
diff --git a/tracker-pt/ftnoir_tracker_pt.cpp b/tracker-pt/ftnoir_tracker_pt.cpp
index 5c3e338a..8ed17a4f 100644
--- a/tracker-pt/ftnoir_tracker_pt.cpp
+++ b/tracker-pt/ftnoir_tracker_pt.cpp
@@ -92,12 +92,24 @@ void Tracker_PT::run()
ever_success = true;
}
- auto fun = [&](const vec2& p, const cv::Scalar& color)
{
+ Affine X_CM;
+ {
+ QMutexLocker l(&data_mtx);
+ X_CM = point_tracker.pose();
+ }
+
+ Affine X_MH(mat33::eye(), vec3(s.t_MH_x, s.t_MH_y, s.t_MH_z)); // just copy pasted these lines from below
+ Affine X_GH = X_CM * X_MH;
+ vec3 p = X_GH.t; // head (center?) position in global space
+ vec2 p_(p[0] / p[2] * fx, p[1] / p[2] * fx); // projected to screen
+
static constexpr int len = 9;
+ static const cv::Scalar(0, 0, 255);
- cv::Point p2(iround(p[0] * preview_frame.cols + preview_frame.cols/2),
- iround(-p[1] * preview_frame.cols + preview_frame.rows/2));
+ cv::Point p2(iround(p_[0] * preview_frame.cols + preview_frame.cols/2),
+ iround(-p_[1] * preview_frame.cols + preview_frame.rows/2));
+ static const cv::Scalar color(0, 0, 255);
cv::line(preview_frame,
cv::Point(p2.x - len, p2.y),
cv::Point(p2.x + len, p2.y),
@@ -108,25 +120,6 @@ void Tracker_PT::run()
cv::Point(p2.x, p2.y + len),
color,
1);
- };
-
- for (unsigned i = 0; i < points.size(); i++)
- {
- fun(points[i], cv::Scalar(0, 255, 0));
- }
-
- {
- Affine X_CM;
- {
- QMutexLocker l(&data_mtx);
- X_CM = point_tracker.pose();
- }
-
- Affine X_MH(mat33::eye(), vec3(s.t_MH_x, s.t_MH_y, s.t_MH_z)); // just copy pasted these lines from below
- Affine X_GH = X_CM * X_MH;
- vec3 p = X_GH.t; // head (center?) position in global space
- vec2 p_(p[0] / p[2] * fx, p[1] / p[2] * fx); // projected to screen
- fun(p_, cv::Scalar(0, 0, 255));
}
video_widget->update_image(preview_frame);
diff --git a/tracker-pt/point_extractor.cpp b/tracker-pt/point_extractor.cpp
index 8cd4e1f3..4bd92d44 100644
--- a/tracker-pt/point_extractor.cpp
+++ b/tracker-pt/point_extractor.cpp
@@ -194,14 +194,33 @@ void PointExtractor::extract_points(const cv::Mat& frame, cv::Mat& preview_frame
blobs.push_back(b);
{
- char buf[64];
- sprintf(buf, "%.2fpx", radius);
- static const vec2 off(10, 7.5);
+ static const f offx = 10, offy = 7.5;
const f cx = preview_frame.cols / f(frame.cols),
cy = preview_frame.rows / f(frame.rows);
+ cv::Point p(iround(b.pos[0] * cx), iround(b.pos[1] * cy));
+
+ static const cv::Scalar color(0, 255, 0);
+
+ cv::circle(preview_frame, p, b.radius, color);
+
+ {
+ const int len = iround(b.radius * 1.25) + 1;
+ cv::line(preview_frame,
+ cv::Point(p.x - len, p.y),
+ cv::Point(p.x + len, p.y),
+ color);
+ cv::line(preview_frame,
+ cv::Point(p.x, p.y - len),
+ cv::Point(p.x, p.y + len),
+ color);
+ }
+
+ char buf[64];
+ sprintf(buf, "%.2fpx", radius);
+
cv::putText(preview_frame,
buf,
- cv::Point(iround(b.pos[0]*cx+off[0]), iround(b.pos[1]*cy+off[1])),
+ cv::Point(iround(b.pos[0]*cx+offx), iround(b.pos[1]*cy+offy)),
cv::FONT_HERSHEY_PLAIN,
1,
cv::Scalar(0, 0, 255),