summaryrefslogtreecommitdiffhomepage
path: root/tracker-pt
diff options
context:
space:
mode:
Diffstat (limited to 'tracker-pt')
-rw-r--r--tracker-pt/pt_video_widget.cpp14
-rw-r--r--tracker-pt/pt_video_widget.h11
2 files changed, 17 insertions, 8 deletions
diff --git a/tracker-pt/pt_video_widget.cpp b/tracker-pt/pt_video_widget.cpp
index 38d7a5e8..749eca0b 100644
--- a/tracker-pt/pt_video_widget.cpp
+++ b/tracker-pt/pt_video_widget.cpp
@@ -13,7 +13,8 @@
PTVideoWidget::PTVideoWidget(QWidget* parent) :
QWidget(parent),
- freshp(false)
+ freshp(false),
+ visible(true)
{
connect(&timer, SIGNAL(timeout()), this, SLOT(update_and_repaint()));
timer.start(50);
@@ -44,9 +45,16 @@ void PTVideoWidget::paintEvent(QPaintEvent* e)
void PTVideoWidget::update_and_repaint()
{
- if (is_window_visible(this))
+ QMutexLocker l(&mtx);
+
+ if (window_check_timer.elapsed_ms() > 2000)
+ {
+ visible = is_window_visible(this);
+ window_check_timer.start();
+ }
+
+ if (visible)
{
- QMutexLocker foo(&mtx);
if (_frame.empty() || !freshp)
return;
cv::cvtColor(_frame, _frame2, cv::COLOR_RGB2BGR);
diff --git a/tracker-pt/pt_video_widget.h b/tracker-pt/pt_video_widget.h
index c2957876..82de3eab 100644
--- a/tracker-pt/pt_video_widget.h
+++ b/tracker-pt/pt_video_widget.h
@@ -8,10 +8,11 @@
#pragma once
-#include <QObject>
-#include <QWidget>
+#include "opentrack-compat/timer.hpp"
#include <opencv2/core/core.hpp>
#include <memory>
+#include <QObject>
+#include <QWidget>
#include <QPainter>
#include <QPaintEvent>
#include <QTimer>
@@ -22,17 +23,17 @@
class PTVideoWidget final : public QWidget
{
Q_OBJECT
-
public:
PTVideoWidget(QWidget *parent);
void update_image(const cv::Mat &frame);
protected slots:
- void paintEvent(QPaintEvent* e) override;
+ void paintEvent(QPaintEvent*) override;
void update_and_repaint();
private:
QMutex mtx;
QImage texture;
QTimer timer;
+ Timer window_check_timer;
cv::Mat _frame, _frame2, _frame3;
- bool freshp;
+ bool freshp, visible;
};