summaryrefslogtreecommitdiffhomepage
path: root/opentrack/opencv-camera-dialog.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'opentrack/opencv-camera-dialog.hpp')
-rw-r--r--opentrack/opencv-camera-dialog.hpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/opentrack/opencv-camera-dialog.hpp b/opentrack/opencv-camera-dialog.hpp
new file mode 100644
index 00000000..3b700a70
--- /dev/null
+++ b/opentrack/opencv-camera-dialog.hpp
@@ -0,0 +1,32 @@
+#pragma once
+
+#include <QMutex>
+#include <QMutexLocker>
+#include <opencv2/videoio.hpp>
+#include "opentrack/camera-names.hpp"
+
+template<typename tracker>
+class camera_dialog
+{
+ cv::VideoCapture fake_capture;
+public:
+ void open_camera_settings(cv::VideoCapture* cap, const QString& camera_name, QMutex* camera_mtx)
+ {
+ if (cap)
+ {
+ QMutexLocker l(camera_mtx);
+
+ if (cap->isOpened())
+ {
+ cap->set(cv::CAP_PROP_SETTINGS, 1);
+ return;
+ }
+ }
+
+ 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("");
+ }
+};
+