diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2015-07-06 11:41:16 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2015-07-06 11:41:16 +0200 |
commit | 3a54a111567370ecf903704d702d12736b693a8e (patch) | |
tree | 1981d1bb3a97165d954ed8856061bb44d88fdd7c /opentrack | |
parent | f58efb5c2c51e5866d4640036865792b822641f6 (diff) | |
parent | fcb8ca75c0c274be2321f0ba91e9f129ae63e354 (diff) |
Merge branch 'unstable' into trackhat-ui
Diffstat (limited to 'opentrack')
-rw-r--r-- | opentrack/camera-names.hpp | 2 | ||||
-rw-r--r-- | opentrack/opencv-camera-dialog.hpp | 32 |
2 files changed, 34 insertions, 0 deletions
diff --git a/opentrack/camera-names.hpp b/opentrack/camera-names.hpp index 3d3948fa..6f82ba34 100644 --- a/opentrack/camera-names.hpp +++ b/opentrack/camera-names.hpp @@ -13,6 +13,7 @@ # include <unistd.h> #endif +template<typename = void> QList<QString> get_camera_names() { QList<QString> ret; #if defined(_WIN32) @@ -82,6 +83,7 @@ QList<QString> get_camera_names() { return ret; } +template<typename = void> int camera_name_to_index(const QString &name) { auto list = get_camera_names(); 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(""); + } +}; + |