summaryrefslogtreecommitdiffhomepage
path: root/video-opencv/impl-metadata.cpp
blob: ffc517731733ea11e1d10fe3f7987745c08f1f1e (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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include "impl.hpp"
#include "compat/camera-names.hpp"
#include "video-property-page.hpp"

namespace opencv_camera_impl {

metadata::metadata() = default;

std::unique_ptr<camera> metadata::make_camera(const QString& name)
{
    int idx = camera_name_to_index(name);
    if (idx != -1)
        return std::make_unique<cam>(idx);
    else
        return nullptr;
}

std::vector<QString> metadata::camera_names() const
{
    std::vector<std::tuple<QString, int>> names = get_camera_names();
    std::vector<QString> ret;
    for (const auto& t : names)
    {
        const auto& [str, idx] = t;
        ret.push_back(str);
    }
    return ret;
}

bool metadata::can_show_dialog(const QString& camera_name)
{
    return camera_name_to_index(camera_name) != -1;
}

bool metadata::show_dialog(const QString& camera_name)
{
    int idx = camera_name_to_index(camera_name);
    if (idx != -1)
    {
        video_property_page::show(idx);
        return true;
    }
    else
        return false;
}

OTR_REGISTER_CAMERA(metadata)

} // ns opencv_camera_impl