summaryrefslogtreecommitdiffhomepage
path: root/tracker-aruco
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2016-07-21 14:31:31 +0200
committerStanislaw Halik <sthalik@misaki.pl>2016-07-23 11:05:33 +0200
commit42c687b8adb54d3c446483ad085b06d2caf0f1c8 (patch)
tree115ed3e86f73a7fd718da1dfc25778b3af28f8b0 /tracker-aruco
parent72f7a1b07d393e6cfdbac1ecb168a703919fd03e (diff)
tracker/{aruco,pt}: only check window visibility once every two seconds
The check is becoming more expensive with more positions checked.
Diffstat (limited to 'tracker-aruco')
-rw-r--r--tracker-aruco/pt_video_widget.cpp14
-rw-r--r--tracker-aruco/pt_video_widget.h11
2 files changed, 17 insertions, 8 deletions
diff --git a/tracker-aruco/pt_video_widget.cpp b/tracker-aruco/pt_video_widget.cpp
index 38d7a5e8..749eca0b 100644
--- a/tracker-aruco/pt_video_widget.cpp
+++ b/tracker-aruco/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-aruco/pt_video_widget.h b/tracker-aruco/pt_video_widget.h
index c2957876..82de3eab 100644
--- a/tracker-aruco/pt_video_widget.h
+++ b/tracker-aruco/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;
};