summaryrefslogtreecommitdiffhomepage
path: root/tracker-aruco/pt_video_widget.cpp
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/pt_video_widget.cpp
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/pt_video_widget.cpp')
-rw-r--r--tracker-aruco/pt_video_widget.cpp14
1 files changed, 11 insertions, 3 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);