summaryrefslogtreecommitdiffhomepage
path: root/video
diff options
context:
space:
mode:
Diffstat (limited to 'video')
-rw-r--r--video/camera.cpp14
-rw-r--r--video/camera.hpp19
-rw-r--r--video/lang/de_DE.ts4
-rw-r--r--video/lang/nl_NL.ts2
-rw-r--r--video/lang/ru_RU.ts2
-rw-r--r--video/lang/zh_CN.ts2
-rw-r--r--video/video-widget.cpp9
-rw-r--r--video/video-widget.hpp5
8 files changed, 43 insertions, 14 deletions
diff --git a/video/camera.cpp b/video/camera.cpp
index 42320402..a66d8a59 100644
--- a/video/camera.cpp
+++ b/video/camera.cpp
@@ -4,8 +4,12 @@
#include <utility>
#include <QMutex>
-static std::vector<std::unique_ptr<video::impl::camera_>> metadata;
-static QMutex mtx;
+std::pair<std::vector<std::unique_ptr<video::impl::camera_>>&, QMutex&> get_metadata()
+{
+ static std::vector<std::unique_ptr<video::impl::camera_>> metadata;
+ static QMutex mtx;
+ return { metadata, mtx };
+}
namespace video::impl {
@@ -17,6 +21,7 @@ camera::~camera() = default;
void register_camera(std::unique_ptr<impl::camera_> camera)
{
+ auto [metadata, mtx] = get_metadata();
QMutexLocker l(&mtx);
metadata.push_back(std::move(camera));
}
@@ -27,6 +32,7 @@ namespace video {
bool show_dialog(const QString& camera_name)
{
+ auto [metadata, mtx] = get_metadata();
QMutexLocker l(&mtx);
for (auto& camera : metadata)
@@ -39,6 +45,7 @@ bool show_dialog(const QString& camera_name)
std::unique_ptr<camera_impl> make_camera_(const QString& name)
{
+ auto [metadata, mtx] = get_metadata();
QMutexLocker l(&mtx);
for (auto& camera : metadata)
@@ -54,6 +61,7 @@ std::unique_ptr<camera_impl> make_camera(const QString& name)
if (auto ret = make_camera_(name))
return ret;
+ auto [metadata, mtx] = get_metadata();
for (auto& camera : metadata)
for (const QString& name_ : camera->camera_names())
if (auto ret = camera->make_camera(name_))
@@ -64,6 +72,8 @@ std::unique_ptr<camera_impl> make_camera(const QString& name)
std::vector<QString> camera_names()
{
+ auto [metadata, mtx] = get_metadata();
+
QMutexLocker l(&mtx);
std::vector<QString> names; names.reserve(32);
diff --git a/video/camera.hpp b/video/camera.hpp
index a0fe0adb..6181dbf3 100644
--- a/video/camera.hpp
+++ b/video/camera.hpp
@@ -48,11 +48,14 @@ struct OTR_VIDEO_EXPORT camera
{
struct info final
{
+ enum : unsigned char { channels_gray = 1, channels_bgr = 3 };
// TODO: expose FOV-based focal length for regular webcams
int width = 0, height = 0, fps = 0;
double fx = 0, fy = 0; // focal length
double P_x = 0, P_y = 0; // principal point
double dist_c[8] {}; // distortion coefficients
+ bool use_mjpeg = false;
+ int num_channels = channels_bgr;
};
camera();
@@ -75,12 +78,22 @@ void register_camera(std::unique_ptr<impl::camera_> metadata);
static const char init_ ## ctr = \
(::video::impl::register_camera(std::make_unique<type>()), 0);
-#define OTR_REGISTER_CAMERA2(type, ctr) \
- OTR_REGISTER_CAMERA3(type, ctr)
+#ifdef _MSC_VER
+ // shared library targets without any symbols break cmake build
+# define OTR_REGISTER_CAMERA_IMPL(type) \
+ extern "C" [[maybe_unused]] __declspec(dllexport) \
+ void _opentrack_module_video_ ##type (void) {}
+# define OTR_REGISTER_CAMERA_IMPL2(type) \
+ OTR_REGISTER_CAMERA_IMPL(type)
+#else
+# define OTR_REGISTER_CAMERA_IMPL2(type)
+#endif
+#define OTR_REGISTER_CAMERA2(type, ctr) \
+ OTR_REGISTER_CAMERA3(type, ctr) \
+ OTR_REGISTER_CAMERA_IMPL2(type)
#define OTR_REGISTER_CAMERA(type) \
OTR_REGISTER_CAMERA2(type, __COUNTER__)
-
namespace video
{
using camera_impl = impl::camera;
diff --git a/video/lang/de_DE.ts b/video/lang/de_DE.ts
new file mode 100644
index 00000000..1552582e
--- /dev/null
+++ b/video/lang/de_DE.ts
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.1" language="de_DE">
+</TS>
diff --git a/video/lang/nl_NL.ts b/video/lang/nl_NL.ts
index 6401616d..9e739505 100644
--- a/video/lang/nl_NL.ts
+++ b/video/lang/nl_NL.ts
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
-<TS version="2.1">
+<TS version="2.1" language="nl_NL">
</TS>
diff --git a/video/lang/ru_RU.ts b/video/lang/ru_RU.ts
index 6401616d..f62cf2e1 100644
--- a/video/lang/ru_RU.ts
+++ b/video/lang/ru_RU.ts
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
-<TS version="2.1">
+<TS version="2.1" language="ru_RU">
</TS>
diff --git a/video/lang/zh_CN.ts b/video/lang/zh_CN.ts
index 6401616d..e5ca8aa9 100644
--- a/video/lang/zh_CN.ts
+++ b/video/lang/zh_CN.ts
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
-<TS version="2.1">
+<TS version="2.1" language="zh_CN">
</TS>
diff --git a/video/video-widget.cpp b/video/video-widget.cpp
index 8262a380..3018a3c4 100644
--- a/video/video-widget.cpp
+++ b/video/video-widget.cpp
@@ -11,15 +11,19 @@
void video_widget::init_image_nolock()
{
- double dpi = screen_dpi();
+ double dpi = devicePixelRatioF();
size_.store({ iround(width() * dpi), iround(height() * dpi) }, std::memory_order_release);
}
video_widget::video_widget(QWidget* parent) : QWidget(parent)
{
+ if (parent)
+ setFixedSize(parent->size());
+ else
+ setFixedSize(320, 240);
init_image_nolock();
connect(&timer, &QTimer::timeout, this, &video_widget::draw_image, Qt::DirectConnection);
- timer.start(65);
+ timer.start(15);
}
void video_widget::update_image(const QImage& img)
@@ -84,4 +88,3 @@ void video_widget::set_fresh(bool x)
{
fresh_.store(x, std::memory_order_release);
}
-
diff --git a/video/video-widget.hpp b/video/video-widget.hpp
index 9218643b..4f54b2b9 100644
--- a/video/video-widget.hpp
+++ b/video/video-widget.hpp
@@ -7,7 +7,6 @@
#pragma once
-#include "compat/qt-dpi.hpp"
#include "compat/math.hpp"
#include "export.hpp"
@@ -21,7 +20,7 @@
#include <QMutex>
-struct OTR_VIDEO_EXPORT video_widget : QWidget, public screen_dpi_mixin<video_widget>
+struct OTR_VIDEO_EXPORT video_widget : QWidget
{
video_widget(QWidget* parent = nullptr);
@@ -30,12 +29,12 @@ struct OTR_VIDEO_EXPORT video_widget : QWidget, public screen_dpi_mixin<video_wi
void resizeEvent(QResizeEvent*) override;
void paintEvent(QPaintEvent*) override;
void draw_image();
+ bool fresh() const;
protected:
mutable QMutex mtx { QMutex::NonRecursive };
QImage texture;
std::vector<unsigned char> vec;
- bool fresh() const;
void set_fresh(bool x);
void set_image(const unsigned char* src, int width, int height, int stride, QImage::Format fmt);