From 69a16a5bb45eafe185fa708f572788908ce9ebff Mon Sep 17 00:00:00 2001 From: Stéphane Lenclud Date: Sun, 14 Apr 2019 14:26:26 +0200 Subject: Easy Tracker: Fixing issues with preview head point cross. --- tracker-easy/preview.cpp | 4 ++-- tracker-easy/tracker-easy.cpp | 31 +++++++++++++++---------------- tracker-easy/tracker-easy.h | 3 +-- 3 files changed, 18 insertions(+), 20 deletions(-) diff --git a/tracker-easy/preview.cpp b/tracker-easy/preview.cpp index 7f245ae4..a44ab143 100644 --- a/tracker-easy/preview.cpp +++ b/tracker-easy/preview.cpp @@ -109,11 +109,11 @@ namespace EasyTracker cv::line(iFrameRgb, cv::Point(px - len, py), cv::Point(px + len, py), - color, 1); + color, 2); cv::line(iFrameRgb, cv::Point(px, py - len), cv::Point(px, py + len), - color, 1); + color, 2); } void Preview::ensure_size(cv::Mat& frame, int w, int h, int type) diff --git a/tracker-easy/tracker-easy.cpp b/tracker-easy/tracker-easy.cpp index acedc379..7850a23e 100644 --- a/tracker-easy/tracker-easy.cpp +++ b/tracker-easy/tracker-easy.cpp @@ -36,7 +36,7 @@ namespace EasyTracker Tracker::Tracker() : s{ KModuleName }, - point_extractor{ std::make_unique() }, + iPointExtractor{ std::make_unique() }, iPreview{ preview_width, preview_height } { cv::setBreakOnError(true); @@ -58,7 +58,7 @@ namespace EasyTracker wait(); QMutexLocker l(&camera_mtx); - camera->stop(); + camera->stop(); } @@ -138,21 +138,9 @@ namespace EasyTracker } iPoints.clear(); - point_extractor->extract_points(iMatFrame, (preview_visible ? &iPreview.iFrameRgb : nullptr), iPoints); + iPointExtractor->extract_points(iMatFrame, (preview_visible ? &iPreview.iFrameRgb : nullptr), iPoints); point_count.store(iPoints.size(), std::memory_order_relaxed); - - if (preview_visible) - { - //iPreview = iMatFrame; - cv::imshow("Preview", iPreview.iFrameRgb); - cv::waitKey(1); - } - else - { - cv::destroyWindow("Preview"); - } - const bool success = iPoints.size() >= KPointCount; int topPointIndex = -1; @@ -307,13 +295,19 @@ namespace EasyTracker } if (preview_visible) - { + { + // if (topPointIndex != -1) { // Render a cross to indicate which point is the head iPreview.draw_head_center(iPoints[topPointIndex][0], iPoints[topPointIndex][1]); } + // Show full size preview pop-up + cv::imshow("Preview", iPreview.iFrameRgb); + cv::waitKey(1); + + // Update preview widget widget->update_image(iPreview.get_bitmap()); auto[w, h] = widget->preview_size(); @@ -324,6 +318,11 @@ namespace EasyTracker iPreview = Preview(w, h); } } + else + { + // No preview, destroy preview pop-up + cv::destroyWindow("Preview"); + } } } } diff --git a/tracker-easy/tracker-easy.h b/tracker-easy/tracker-easy.h index 57419c1c..fe7fece7 100644 --- a/tracker-easy/tracker-easy.h +++ b/tracker-easy/tracker-easy.h @@ -38,7 +38,6 @@ namespace EasyTracker { friend class Dialog; - explicit Tracker(); ~Tracker() override; module_status start_tracker(QFrame* parent_window) override; @@ -63,7 +62,7 @@ namespace EasyTracker int preview_width = 320, preview_height = 240; - std::unique_ptr point_extractor; + std::unique_ptr iPointExtractor; std::unique_ptr camera; video::impl::camera::info iCameraInfo; std::unique_ptr widget; -- cgit v1.2.3