diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2015-12-20 17:44:21 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2015-12-20 18:16:43 +0100 |
commit | c88d7897eec259ea7c649467e01590a08faa2dcb (patch) | |
tree | ed0c403471b040a7e3f1827a35dba1956e27964d | |
parent | 778b82aee0b6f41bb4bafdaf6d079221306d942c (diff) |
tracker/pt: only show widget if the frame is visible
-rw-r--r-- | tracker-pt/pt_video_widget.cpp | 27 | ||||
-rw-r--r-- | tracker-pt/pt_video_widget.h | 1 |
2 files changed, 16 insertions, 12 deletions
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<QWidget*>(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 <QTimer> #include <QMutex> #include <QMutexLocker> +#include <QDebug> class PTVideoWidget : public QWidget { |