summaryrefslogtreecommitdiffhomepage
path: root/ftnoir_tracker_pt
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2014-12-15 21:51:54 +0100
committerStanislaw Halik <sthalik@misaki.pl>2014-12-15 21:51:54 +0100
commit5d0ef7070a6338262f22397d6f492e6ddc6c4dbf (patch)
tree799e9a7e1c467df8d0d68db76df0858139b2e7cb /ftnoir_tracker_pt
parent0383bd9685bce8528c7ae7bd42762037552b6803 (diff)
pt: visualize model center as another point
Diffstat (limited to 'ftnoir_tracker_pt')
-rw-r--r--ftnoir_tracker_pt/ftnoir_tracker_pt.cpp20
-rw-r--r--ftnoir_tracker_pt/point_extractor.cpp2
-rw-r--r--ftnoir_tracker_pt/point_extractor.h2
3 files changed, 19 insertions, 5 deletions
diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp b/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp
index 61216000..cfeefe38 100644
--- a/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp
+++ b/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp
@@ -74,7 +74,22 @@ void Tracker::run()
{
QMutexLocker lock(&mutex);
- const std::vector<cv::Vec2f>& points = point_extractor.extract_points(frame);
+ std::vector<cv::Vec2f> points = point_extractor.extract_points(frame);
+
+ if (points.size() == PointModel::N_POINTS)
+ point_tracker.track(points, PointModel(s), get_focal_length());
+
+ {
+ Affine CM;
+ pose(&CM);
+ cv::Vec3f MH(s.t_MH_x, s.t_MH_y, s.t_MH_z);
+ cv::Vec3f p = CM.t - MH;
+ float fx = get_focal_length();
+ cv::Vec2f p_(p[0] / p[2] * fx, p[1] / p[2] * fx);
+
+ points.push_back(p_);
+ }
+
for (auto p : points)
{
auto p2 = cv::Point(p[0] * frame.cols + frame.cols/2, -p[1] * frame.cols + frame.rows/2);
@@ -90,8 +105,7 @@ void Tracker::run()
color,
4);
}
- if (points.size() == PointModel::N_POINTS)
- point_tracker.track(points, PointModel(s), get_focal_length());
+
video_widget->update_image(frame);
}
#ifdef PT_PERF_LOG
diff --git a/ftnoir_tracker_pt/point_extractor.cpp b/ftnoir_tracker_pt/point_extractor.cpp
index f4eefb0f..949fd58f 100644
--- a/ftnoir_tracker_pt/point_extractor.cpp
+++ b/ftnoir_tracker_pt/point_extractor.cpp
@@ -20,7 +20,7 @@ PointExtractor::PointExtractor(){
//freopen("CON", "w", stderr);
}
// ----------------------------------------------------------------------------
-const vector<Vec2f>& PointExtractor::extract_points(Mat& frame)
+std::vector<Vec2f> PointExtractor::extract_points(Mat& frame)
{
const int W = frame.cols;
const int H = frame.rows;
diff --git a/ftnoir_tracker_pt/point_extractor.h b/ftnoir_tracker_pt/point_extractor.h
index 2cac29a9..06d148d6 100644
--- a/ftnoir_tracker_pt/point_extractor.h
+++ b/ftnoir_tracker_pt/point_extractor.h
@@ -21,7 +21,7 @@ public:
// extracts points from frame and draws some processing info into frame, if draw_output is set
// dt: time since last call in seconds
// WARNING: returned reference is valid as long as object
- const std::vector<cv::Vec2f>& extract_points(cv::Mat &frame);
+ std::vector<cv::Vec2f> extract_points(cv::Mat &frame);
const std::vector<cv::Vec2f>& get_points() { return points; }
PointExtractor();