summaryrefslogtreecommitdiffhomepage
path: root/opentrack
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2015-07-08 05:55:32 +0200
committerStanislaw Halik <sthalik@misaki.pl>2015-07-08 05:55:59 +0200
commit527eef2a2f0e68b286e1b782ba148ecdfafbb89c (patch)
tree2be0f0b96df712f7b12534291db3c36564be62ca /opentrack
parent3a54a111567370ecf903704d702d12736b693a8e (diff)
parentab47eac174db02710a7fa6c194e00c31cef755a4 (diff)
Merge branch 'unstable' into trackhat-ui
Diffstat (limited to 'opentrack')
-rw-r--r--opentrack/mappings.hpp9
-rw-r--r--opentrack/opencv-camera-dialog.hpp23
-rw-r--r--opentrack/options.hpp2
-rw-r--r--opentrack/plugin-support.hpp13
-rw-r--r--opentrack/selected-libraries.cpp11
-rw-r--r--opentrack/selected-libraries.hpp8
-rw-r--r--opentrack/shortcuts.h8
-rw-r--r--opentrack/simple-mat.hpp8
-rw-r--r--opentrack/state.hpp8
-rw-r--r--opentrack/thread.hpp8
-rw-r--r--opentrack/timer.hpp8
-rw-r--r--opentrack/tracker.cpp1
-rw-r--r--opentrack/tracker.h10
-rw-r--r--opentrack/work.hpp8
14 files changed, 107 insertions, 18 deletions
diff --git a/opentrack/mappings.hpp b/opentrack/mappings.hpp
index 3336dcd8..85d9900c 100644
--- a/opentrack/mappings.hpp
+++ b/opentrack/mappings.hpp
@@ -1,9 +1,16 @@
+/* Copyright (c) 2014-2015 Stanislaw Halik
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ */
+
#pragma once
#include <QSettings>
#include "options.hpp"
using namespace options;
-#include "../qfunctionconfigurator/functionconfig.h"
+#include "qfunctionconfigurator/functionconfig.h"
#include "main-settings.hpp"
class Mapping {
diff --git a/opentrack/opencv-camera-dialog.hpp b/opentrack/opencv-camera-dialog.hpp
index 3b700a70..6218f125 100644
--- a/opentrack/opencv-camera-dialog.hpp
+++ b/opentrack/opencv-camera-dialog.hpp
@@ -1,5 +1,6 @@
#pragma once
+#include <QTimer>
#include <QMutex>
#include <QMutexLocker>
#include <opencv2/videoio.hpp>
@@ -9,6 +10,14 @@ template<typename tracker>
class camera_dialog
{
cv::VideoCapture fake_capture;
+ QTimer t;
+
+private:
+ void delete_capture()
+ {
+ fake_capture.open("");
+ }
+
public:
void open_camera_settings(cv::VideoCapture* cap, const QString& camera_name, QMutex* camera_mtx)
{
@@ -23,10 +32,20 @@ public:
}
}
+ if (t.isActive())
+ return;
+
+ // don't hog the camera capture
+ if (!t.isSingleShot())
+ QObject::connect(&t, &QTimer::timeout, [&]() -> void { delete_capture(); });
+
+ t.setSingleShot(true);
+ t.setInterval(3000);
+
fake_capture = cv::VideoCapture(camera_name_to_index(camera_name));
fake_capture.set(cv::CAP_PROP_SETTINGS, 1);
- // don't hog the camera capture
- fake_capture.open("");
+ // HACK: we're not notified when it's safe to close the capture
+ t.start();
}
};
diff --git a/opentrack/options.hpp b/opentrack/options.hpp
index c2fe8705..9768bc43 100644
--- a/opentrack/options.hpp
+++ b/opentrack/options.hpp
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2014 Stanislaw Halik
+/* Copyright (c) 2013-2015 Stanislaw Halik
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
diff --git a/opentrack/plugin-support.hpp b/opentrack/plugin-support.hpp
index 7f2734af..78443cae 100644
--- a/opentrack/plugin-support.hpp
+++ b/opentrack/plugin-support.hpp
@@ -1,5 +1,3 @@
-#pragma once
-
/* Copyright (c) 2015 Stanislaw Halik
*
* Permission to use, copy, modify, and/or distribute this software for any
@@ -7,6 +5,8 @@
* copyright notice and this permission notice appear in all copies.
*/
+#pragma once
+
#include "plugin-api.hpp"
#include "options.hpp"
@@ -242,3 +242,12 @@ private:
return ret;
}
};
+
+template<typename t>
+mem<t> make_dylib_instance(mem<dylib> lib)
+{
+ mem<t> ret;
+ if (lib != nullptr && lib->Constructor)
+ ret = mem<t>(reinterpret_cast<t*>(reinterpret_cast<OPENTRACK_CTOR_FUNPTR>(lib->Constructor)()));
+ return ret;
+}
diff --git a/opentrack/selected-libraries.cpp b/opentrack/selected-libraries.cpp
index d76c0111..630b7db2 100644
--- a/opentrack/selected-libraries.cpp
+++ b/opentrack/selected-libraries.cpp
@@ -5,15 +5,6 @@ SelectedLibraries::~SelectedLibraries()
{
}
-template<typename t>
-static mem<t> make_instance(mem<dylib> lib)
-{
- mem<t> ret;
- if (lib != nullptr && lib->Constructor)
- ret = mem<t>(reinterpret_cast<t*>(reinterpret_cast<OPENTRACK_CTOR_FUNPTR>(lib->Constructor)()));
- return ret;
-}
-
SelectedLibraries::SelectedLibraries(QFrame* frame, mem<ITracker> t, dylibptr p, mem<IFilter> f) :
pTracker(nullptr),
pFilter(nullptr),
@@ -21,7 +12,7 @@ SelectedLibraries::SelectedLibraries(QFrame* frame, mem<ITracker> t, dylibptr p,
correct(false)
{
pTracker = t;
- pProtocol = make_instance<IProtocol>(p);
+ pProtocol = make_dylib_instance<IProtocol>(p);
pFilter = f;
if (!pTracker || !pProtocol)
diff --git a/opentrack/selected-libraries.hpp b/opentrack/selected-libraries.hpp
index 07ea419b..547f5f54 100644
--- a/opentrack/selected-libraries.hpp
+++ b/opentrack/selected-libraries.hpp
@@ -1,3 +1,11 @@
+/* Copyright (c) 2014-2015, Stanislaw Halik <sthalik@misaki.pl>
+
+ * Permission to use, copy, modify, and/or distribute this
+ * software for any purpose with or without fee is hereby granted,
+ * provided that the above copyright notice and this permission
+ * notice appear in all copies.
+ */
+
#pragma once
#include "opentrack/plugin-support.hpp"
diff --git a/opentrack/shortcuts.h b/opentrack/shortcuts.h
index ee0d9777..520042f0 100644
--- a/opentrack/shortcuts.h
+++ b/opentrack/shortcuts.h
@@ -1,3 +1,11 @@
+/* Copyright (c) 2014-2015, Stanislaw Halik <sthalik@misaki.pl>
+
+ * Permission to use, copy, modify, and/or distribute this
+ * software for any purpose with or without fee is hereby granted,
+ * provided that the above copyright notice and this permission
+ * notice appear in all copies.
+ */
+
#pragma once
#include <QObject>
#include <QWidget>
diff --git a/opentrack/simple-mat.hpp b/opentrack/simple-mat.hpp
index 1cea967e..e111305a 100644
--- a/opentrack/simple-mat.hpp
+++ b/opentrack/simple-mat.hpp
@@ -1,3 +1,11 @@
+/* Copyright (c) 2014-2015, Stanislaw Halik <sthalik@misaki.pl>
+
+ * Permission to use, copy, modify, and/or distribute this
+ * software for any purpose with or without fee is hereby granted,
+ * provided that the above copyright notice and this permission
+ * notice appear in all copies.
+ */
+
#pragma once
#include <algorithm>
#include <initializer_list>
diff --git a/opentrack/state.hpp b/opentrack/state.hpp
index bfbf113e..e4cb0f04 100644
--- a/opentrack/state.hpp
+++ b/opentrack/state.hpp
@@ -1,3 +1,11 @@
+/* Copyright (c) 2014-2015, Stanislaw Halik <sthalik@misaki.pl>
+
+ * Permission to use, copy, modify, and/or distribute this
+ * software for any purpose with or without fee is hereby granted,
+ * provided that the above copyright notice and this permission
+ * notice appear in all copies.
+ */
+
#pragma once
#include <vector>
diff --git a/opentrack/thread.hpp b/opentrack/thread.hpp
index b1db9158..946f2972 100644
--- a/opentrack/thread.hpp
+++ b/opentrack/thread.hpp
@@ -1,3 +1,11 @@
+/* Copyright (c) 2014-2015, Stanislaw Halik <sthalik@misaki.pl>
+
+ * Permission to use, copy, modify, and/or distribute this
+ * software for any purpose with or without fee is hereby granted,
+ * provided that the above copyright notice and this permission
+ * notice appear in all copies.
+ */
+
#pragma once
#include <QDebug>
diff --git a/opentrack/timer.hpp b/opentrack/timer.hpp
index eb956213..fd710499 100644
--- a/opentrack/timer.hpp
+++ b/opentrack/timer.hpp
@@ -1,3 +1,11 @@
+/* Copyright (c) 2014-2015, Stanislaw Halik <sthalik@misaki.pl>
+
+ * Permission to use, copy, modify, and/or distribute this
+ * software for any purpose with or without fee is hereby granted,
+ * provided that the above copyright notice and this permission
+ * notice appear in all copies.
+ */
+
#pragma once
#include <ctime>
#if defined (_WIN32)
diff --git a/opentrack/tracker.cpp b/opentrack/tracker.cpp
index e39e54dd..38d95f84 100644
--- a/opentrack/tracker.cpp
+++ b/opentrack/tracker.cpp
@@ -106,7 +106,6 @@ void Tracker::logic()
dmat<3, 1> t { value(0), value(1), value(2) };
r = cam * r;
- t = cam * t;
bool can_center = false;
diff --git a/opentrack/tracker.h b/opentrack/tracker.h
index d4dc149f..453357c4 100644
--- a/opentrack/tracker.h
+++ b/opentrack/tracker.h
@@ -1,3 +1,11 @@
+/* Copyright (c) 2014-2015, Stanislaw Halik <sthalik@misaki.pl>
+
+ * Permission to use, copy, modify, and/or distribute this
+ * software for any purpose with or without fee is hereby granted,
+ * provided that the above copyright notice and this permission
+ * notice appear in all copies.
+ */
+
#pragma once
#include <vector>
@@ -9,7 +17,7 @@
#include "simple-mat.hpp"
#include "selected-libraries.hpp"
-#include "../qfunctionconfigurator/functionconfig.h"
+#include "qfunctionconfigurator/functionconfig.h"
#include "main-settings.hpp"
#include "options.hpp"
diff --git a/opentrack/work.hpp b/opentrack/work.hpp
index eb5bd4ff..39eb12fb 100644
--- a/opentrack/work.hpp
+++ b/opentrack/work.hpp
@@ -1,3 +1,11 @@
+/* Copyright (c) 2014-2015, Stanislaw Halik <sthalik@misaki.pl>
+
+ * Permission to use, copy, modify, and/or distribute this
+ * software for any purpose with or without fee is hereby granted,
+ * provided that the above copyright notice and this permission
+ * notice appear in all copies.
+ */
+
#pragma once
#include "opentrack/main-settings.hpp"