summaryrefslogtreecommitdiffhomepage
path: root/opentrack/opencv-camera-dialog.hpp
blob: 3b700a700ca07f045a33709184f9905acc8d5146 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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("");
    }
};