diff options
author | Stéphane Lenclud <github@lenclud.com> | 2019-04-13 10:36:47 +0200 |
---|---|---|
committer | Stéphane Lenclud <github@lenclud.com> | 2019-04-24 18:46:12 +0200 |
commit | 547f3314f2a4e75a5d2c540a5f1221e9c59277ae (patch) | |
tree | cc3f11d40bb4a73d219eff03559cd4cc0335a9af /tracker-easy/tracker-easy.cpp | |
parent | 12e7ec5bdac206a3072f24577e897c79d6b0189f (diff) |
Easy Tracker: OpenCV point extractor.
Diffstat (limited to 'tracker-easy/tracker-easy.cpp')
-rw-r--r-- | tracker-easy/tracker-easy.cpp | 38 |
1 files changed, 26 insertions, 12 deletions
diff --git a/tracker-easy/tracker-easy.cpp b/tracker-easy/tracker-easy.cpp index 1783ef51..425979ef 100644 --- a/tracker-easy/tracker-easy.cpp +++ b/tracker-easy/tracker-easy.cpp @@ -19,13 +19,13 @@ #include <QFile> #include <QCoreApplication> -#include <opencv2\calib3d.hpp> +#include <opencv2/calib3d.hpp> +#include <opencv2/highgui/highgui.hpp> #include <iostream> using namespace options; -namespace pt_impl { EasyTracker::EasyTracker(pointer<pt_runtime_traits> const& traits) : traits { traits }, @@ -45,11 +45,14 @@ EasyTracker::EasyTracker(pointer<pt_runtime_traits> const& traits) : EasyTracker::~EasyTracker() { + // + cv::destroyWindow("Preview"); + requestInterruption(); wait(); QMutexLocker l(&camera_mtx); - camera->stop(); + camera->stop(); } @@ -120,19 +123,30 @@ void EasyTracker::run() //TODO: We should not assume channel size of 1 byte iMatFrame = cv::Mat(iFrame.height, iFrame.width, CV_MAKETYPE(CV_8U,iFrame.channels), iFrame.data, iFrame.stride); - const bool preview_visible = check_is_visible(); + const bool preview_visible = check_is_visible(); if (preview_visible) { - iPreview = iMatFrame; + iPreview = iMatFrame; } - iImagePoints.clear(); - point_extractor->extract_points(iMatFrame, iPreview, points, iImagePoints); + point_extractor->extract_points(iMatFrame, iPreview.iFrameRgb, points, iImagePoints); point_count.store(points.size(), std::memory_order_relaxed); - const bool success = points.size() >= KPointCount; + + if (preview_visible) + { + //iPreview = iMatFrame; + cv::imshow("Preview", iPreview.iFrameRgb); + cv::waitKey(1); + } + else + { + cv::destroyWindow("Preview"); + } + + const bool success = points.size() >= KPointCount || iImagePoints.size() >= KPointCount; int topPointIndex = -1; @@ -290,7 +304,10 @@ void EasyTracker::run() if (topPointIndex != -1) { // Render a cross to indicate which point is the head - iPreview.draw_head_center(points[topPointIndex][0], points[topPointIndex][1]); + if (points.size() >= 3) + { + iPreview.draw_head_center(points[topPointIndex][0], points[topPointIndex][1]); + } } widget->update_image(iPreview.get_bitmap()); @@ -367,6 +384,3 @@ int EasyTracker::get_n_points() return (int)point_count.load(std::memory_order_relaxed); } - - -} // ns pt_impl |