From c88d7897eec259ea7c649467e01590a08faa2dcb Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 20 Dec 2015 17:44:21 +0100 Subject: tracker/pt: only show widget if the frame is visible --- tracker-pt/pt_video_widget.cpp | 27 +++++++++++++++------------ tracker-pt/pt_video_widget.h | 1 + 2 files changed, 16 insertions(+), 12 deletions(-) (limited to 'tracker-pt') diff --git a/tracker-pt/pt_video_widget.cpp b/tracker-pt/pt_video_widget.cpp index 608f754a..99f86eb2 100644 --- a/tracker-pt/pt_video_widget.cpp +++ b/tracker-pt/pt_video_widget.cpp @@ -29,17 +29,20 @@ void PTVideoWidget::update_image(const cv::Mat& frame) void PTVideoWidget::update_and_repaint() { - QMutexLocker foo(&mtx); - if (_frame.empty() || !freshp) - return; - cv::cvtColor(_frame, _frame2, cv::COLOR_RGB2BGR); - - if (_frame3.cols != width() || _frame3.rows != height()) - _frame3 = cv::Mat(height(), width(), CV_8U); - - cv::resize(_frame2, _frame3, cv::Size(width(), height()), 0, 0, cv::INTER_NEAREST); - - freshp = false; - update(); + if (static_cast(parent())->isEnabled()) + { + QMutexLocker foo(&mtx); + if (_frame.empty() || !freshp) + return; + cv::cvtColor(_frame, _frame2, cv::COLOR_RGB2BGR); + + if (_frame3.cols != width() || _frame3.rows != height()) + _frame3 = cv::Mat(height(), width(), CV_8U); + + cv::resize(_frame2, _frame3, cv::Size(width(), height()), 0, 0, cv::INTER_NEAREST); + texture = QImage((const unsigned char*) _frame3.data, _frame3.cols, _frame3.rows, QImage::Format_RGB888); + freshp = false; + update(); + } } diff --git a/tracker-pt/pt_video_widget.h b/tracker-pt/pt_video_widget.h index 073b2e93..d9144ac0 100644 --- a/tracker-pt/pt_video_widget.h +++ b/tracker-pt/pt_video_widget.h @@ -17,6 +17,7 @@ #include #include #include +#include class PTVideoWidget : public QWidget { -- cgit v1.2.3