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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
#ifdef _WIN32
#include "migration.hpp"
#include "options/options.hpp"
#include "compat/camera-names.hpp"
using namespace migrations;
using namespace options;
#include "api/plugin-support.hpp"
#include "compat/library-path.hpp"
#include <tuple>
#include <QString>
static const std::tuple<const char*, const char*> modules[] = {
{ "tracker-aruco", "camera-name" },
{ "tracker-easy", "camera-name" },
{ "neuralnet-tracker", "camera-name" },
{ "tracker-pt", "camera-name" },
};
struct win32_camera_name : migration
{
QString unique_date() const override
{
return "20220126_00";
}
QString name() const override
{
return "camera name";
}
bool should_run() const override
{
for (const auto& [name, prop] : modules)
{
bundle b { make_bundle(name) };
QString str = b->get_variant(prop).toString();
if (!str.isEmpty() && !str.contains(" ["))
return true;
}
return false;
}
void run() override
{
auto cameras = get_camera_names();
for (const auto& [bundle_name, prop] : modules)
{
bundle b { make_bundle(bundle_name) };
QString name = b->get_variant(prop).toString();
if (name.isEmpty() || name.contains(" ["))
continue;
auto full_name_of = [&](const QString& str) {
QString ret = str;
auto prefix = str + " [";
for (const auto& [x, _] : cameras)
{
if (x == str)
return str;
if (x.startsWith(prefix))
ret = x;
}
return ret;
};
auto full_name = full_name_of(name);
if (name != full_name)
{
b->store_kv(prop, full_name);
b->save();
}
}
}
};
OPENTRACK_MIGRATION(win32_camera_name)
#endif
|