summaryrefslogtreecommitdiffhomepage
path: root/tracker-eyeware-beam
diff options
context:
space:
mode:
Diffstat (limited to 'tracker-eyeware-beam')
-rw-r--r--tracker-eyeware-beam/CMakeLists.txt27
-rw-r--r--tracker-eyeware-beam/eyeware_beam.cpp116
-rw-r--r--tracker-eyeware-beam/eyeware_beam.h70
-rw-r--r--tracker-eyeware-beam/eyeware_beam.qrc5
-rw-r--r--tracker-eyeware-beam/eyeware_beam.ui90
-rw-r--r--tracker-eyeware-beam/eyeware_beam_logo.pngbin0 -> 2032 bytes
-rw-r--r--tracker-eyeware-beam/lang/nl_NL.ts20
-rw-r--r--tracker-eyeware-beam/lang/ru_RU.ts20
-rw-r--r--tracker-eyeware-beam/lang/stub.ts20
-rw-r--r--tracker-eyeware-beam/lang/zh_CN.ts20
10 files changed, 388 insertions, 0 deletions
diff --git a/tracker-eyeware-beam/CMakeLists.txt b/tracker-eyeware-beam/CMakeLists.txt
new file mode 100644
index 00000000..e041c131
--- /dev/null
+++ b/tracker-eyeware-beam/CMakeLists.txt
@@ -0,0 +1,27 @@
+# The Eyeware Beam SDK can be found at https://beam.eyeware.tech/developers/
+# The latest version can be downloaded at https://eyewarecistorage.blob.core.windows.net/beam-sdk/BeamSDK-Windows64-1.1.0.zip
+set(SDK_EYEWARE_BEAM "" CACHE PATH "Eyeware Beam SDK path")
+if(WIN32 AND SDK_EYEWARE_BEAM)
+ if(MSVC)
+ add_compile_options(-EHsc)
+ endif()
+ otr_module(tracker-eyeware-beam)
+
+ if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "4")
+ set(arch "x86")
+ else()
+ set(arch "x64")
+ endif()
+
+ target_include_directories(${self} SYSTEM PRIVATE "${SDK_EYEWARE_BEAM}/API/cpp/include")
+ target_link_directories(${self} PRIVATE "${SDK_EYEWARE_BEAM}/API/cpp/lib/${arch}")
+ set(dll "${SDK_EYEWARE_BEAM}/API/cpp/lib/${arch}/tracker_client.dll")
+ set(lib tracker_client.lib)
+
+ #message(${self})
+ #message(${dll})
+ #message(${lib})
+
+ target_link_libraries(${self} ${lib})
+ install(FILES ${dll} DESTINATION ${opentrack-libexec})
+endif()
diff --git a/tracker-eyeware-beam/eyeware_beam.cpp b/tracker-eyeware-beam/eyeware_beam.cpp
new file mode 100644
index 00000000..f48b5d4d
--- /dev/null
+++ b/tracker-eyeware-beam/eyeware_beam.cpp
@@ -0,0 +1,116 @@
+/* Copyright (c) 2023 Eyeware Tech SA https://www.eyeware.tech
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ */
+
+#include "eyeware_beam.h"
+
+#include <QMutexLocker>
+
+static constexpr double rad_to_deg = 180.0 / M_PI;
+static constexpr double m_to_cm = 100.0;
+static constexpr double epsilon = 0.000001;
+
+eyeware_beam_tracker::eyeware_beam_tracker()
+{
+}
+
+eyeware_beam_tracker::~eyeware_beam_tracker()
+{
+ QMutexLocker lck(&mtx);
+ release_tracker_instance(tracker_client);
+ tracker_client = nullptr;
+}
+
+module_status eyeware_beam_tracker::start_tracker(QFrame* videoframe)
+{
+ QMutexLocker lck(&mtx);
+ try
+ {
+ tracker_client = create_tracker_instance("127.0.0.1", 12010);
+ }
+ catch (...)
+ {
+ return error("Eyeware Beam initialization has failed");
+ }
+
+ return status_ok();
+}
+
+void eyeware_beam_tracker::extract_translation(const eyeware::Vector3D& t,
+ double& translation_x_cm,
+ double& translation_y_cm,
+ double& translation_z_cm)
+{
+ translation_x_cm = +t.x * m_to_cm;
+ translation_y_cm = -t.y * m_to_cm;
+ translation_z_cm = +t.z * m_to_cm;
+}
+
+void eyeware_beam_tracker::extract_rotation_angles(const eyeware::Matrix3x3& R,
+ double& pitch_deg,
+ double& roll_deg,
+ double& yaw_deg)
+{
+ double r00 = static_cast<double>(R[0][0]);
+ double r01 = static_cast<double>(R[0][1]);
+ double r02 = static_cast<double>(R[0][2]);
+ double r10 = static_cast<double>(R[1][0]);
+ double r11 = static_cast<double>(R[1][1]);
+ double r12 = static_cast<double>(R[1][2]);
+ double r20 = static_cast<double>(R[2][0]);
+ double r21 = static_cast<double>(R[2][1]);
+ double r22 = static_cast<double>(R[2][2]);
+
+ double dy = std::sqrt(r00 * r00 + r10 * r10);
+ last_yaw_deg = -std::atan2(-r20, dy) * rad_to_deg;
+ last_roll_deg = 0.0;
+ if (dy > epsilon)
+ {
+ last_pitch_deg = -std::atan2(r21, r22) * rad_to_deg;
+ last_roll_deg = +std::atan2(r10, r00) * rad_to_deg;
+ }
+ else
+ {
+ last_pitch_deg = -std::atan2(-r12, r11) * rad_to_deg;
+ }
+}
+
+void eyeware_beam_tracker::data(double *data)
+{
+ QMutexLocker lck(&mtx);
+
+ if (connected(tracker_client))
+ {
+ eyeware::HeadPoseInfo head_pose_info = get_head_pose_info(tracker_client);
+ if (!head_pose_info.is_lost)
+ {
+ extract_translation(head_pose_info.transform.translation, last_translation_x_cm,
+ last_translation_y_cm, last_translation_z_cm);
+ extract_rotation_angles(head_pose_info.transform.rotation, last_pitch_deg, last_roll_deg, last_yaw_deg);
+ }
+ }
+
+ data[TX] = last_translation_x_cm;
+ data[TY] = last_translation_y_cm;
+ data[TZ] = last_translation_z_cm;
+ data[Yaw] = last_yaw_deg;
+ data[Pitch] = last_pitch_deg;
+ data[Roll] = last_roll_deg;
+}
+
+eyeware_beam_dialog::eyeware_beam_dialog()
+{
+ ui.setupUi(this);
+
+ connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK()));
+}
+
+void eyeware_beam_dialog::doOK()
+{
+ close();
+}
+
+OPENTRACK_DECLARE_TRACKER(eyeware_beam_tracker, eyeware_beam_dialog, eyeware_beam_metadata)
diff --git a/tracker-eyeware-beam/eyeware_beam.h b/tracker-eyeware-beam/eyeware_beam.h
new file mode 100644
index 00000000..9ebf1f3c
--- /dev/null
+++ b/tracker-eyeware-beam/eyeware_beam.h
@@ -0,0 +1,70 @@
+/* Copyright (c) 2023 Eyeware Tech SA https://www.eyeware.tech
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ */
+
+#pragma once
+
+#include "api/plugin-api.hpp"
+
+#include "ui_eyeware_beam.h"
+
+#include "eyeware/tracker_client.h"
+
+#include <QObject>
+#include <QMutex>
+
+class eyeware_beam_tracker : public QObject, public ITracker
+{
+ Q_OBJECT
+
+public:
+ eyeware_beam_tracker();
+ ~eyeware_beam_tracker() override;
+ module_status start_tracker(QFrame* frame) override;
+ void data(double *data) override;
+
+private:
+ void extract_translation(const eyeware::Vector3D& t,
+ double& translation_x_cm,
+ double& translation_y_cm,
+ double& translation_z_cm);
+ void extract_rotation_angles(const eyeware::Matrix3x3& R, double& pitch_deg, double& roll_deg, double& yaw_deg);
+
+ eyeware::TrackerClient* tracker_client = nullptr;
+
+ QMutex mtx;
+
+ double last_pitch_deg = 0.0;
+ double last_roll_deg = 0.0;
+ double last_yaw_deg = 0.0;
+ double last_translation_x_cm = 0.0;
+ double last_translation_y_cm = 0.0;
+ double last_translation_z_cm = 0.0;
+};
+
+class eyeware_beam_dialog : public ITrackerDialog
+{
+ Q_OBJECT
+
+public:
+ eyeware_beam_dialog();
+ void register_tracker(ITracker * x) override { tracker = static_cast<eyeware_beam_tracker*>(x); }
+ void unregister_tracker() override { tracker = nullptr; }
+
+private:
+ Ui::eyeware_beam_ui ui;
+ eyeware_beam_tracker* tracker = nullptr;
+
+private Q_SLOTS:
+ void doOK();
+};
+
+class eyeware_beam_metadata : public Metadata
+{
+ Q_OBJECT
+ QString name() override { return QString("Eyeware Beam"); }
+ QIcon icon() override { return QIcon(":/images/eyeware_beam_logo.png"); }
+};
diff --git a/tracker-eyeware-beam/eyeware_beam.qrc b/tracker-eyeware-beam/eyeware_beam.qrc
new file mode 100644
index 00000000..ae20865e
--- /dev/null
+++ b/tracker-eyeware-beam/eyeware_beam.qrc
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource prefix="/images">
+ <file>eyeware_beam_logo.png</file>
+ </qresource>
+</RCC>
diff --git a/tracker-eyeware-beam/eyeware_beam.ui b/tracker-eyeware-beam/eyeware_beam.ui
new file mode 100644
index 00000000..475db6a0
--- /dev/null
+++ b/tracker-eyeware-beam/eyeware_beam.ui
@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>eyeware_beam_ui</class>
+ <widget class="QWidget" name="eyeware_beam_ui">
+ <property name="windowModality">
+ <enum>Qt::NonModal</enum>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>433</width>
+ <height>180</height>
+ </rect>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Maximum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="windowTitle">
+ <string>Eyeware Beam</string>
+ </property>
+ <property name="windowIcon">
+ <iconset resource="eyeware_beam.qrc">
+ <normaloff>:/images/eyeware_beam_logo.png</normaloff>:/images/eyeware_beam_logo.png</iconset>
+ </property>
+ <property name="layoutDirection">
+ <enum>Qt::LeftToRight</enum>
+ </property>
+ <property name="autoFillBackground">
+ <bool>false</bool>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QFrame" name="frame_2">
+ <property name="frameShadow">
+ <enum>QFrame::Raised</enum>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <widget class="QLabel" name="label">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Maximum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
+&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
+p, li { white-space: pre-wrap; }
+&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8pt; font-weight:400; font-style:normal;&quot;&gt;
+&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Please make sure the Eyeware Beam application is running and tracking is active.&lt;/p&gt;
+&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;To download, visit &lt;a href=&quot;https://beam.eyeware.tech/opentrack&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;https://beam.eyeware.tech/opentrack&lt;/span&gt;&lt;/a&gt;.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+ </property>
+ <property name="openExternalLinks">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Maximum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources>
+ <include location="eyeware_beam.qrc"/>
+ </resources>
+ <connections/>
+ <slots>
+ <slot>startEngineClicked()</slot>
+ <slot>stopEngineClicked()</slot>
+ <slot>cameraSettingsClicked()</slot>
+ </slots>
+</ui>
diff --git a/tracker-eyeware-beam/eyeware_beam_logo.png b/tracker-eyeware-beam/eyeware_beam_logo.png
new file mode 100644
index 00000000..6a611cac
--- /dev/null
+++ b/tracker-eyeware-beam/eyeware_beam_logo.png
Binary files differ
diff --git a/tracker-eyeware-beam/lang/nl_NL.ts b/tracker-eyeware-beam/lang/nl_NL.ts
new file mode 100644
index 00000000..d70f58ed
--- /dev/null
+++ b/tracker-eyeware-beam/lang/nl_NL.ts
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.1" language="nl_NL">
+<context>
+ <name>eyeware_beam_ui</name>
+ <message>
+ <source>Eyeware Beam</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
+&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
+p, li { white-space: pre-wrap; }
+&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:&apos;MS Shell Dlg 2&apos;; font-size:8pt; font-weight:400; font-style:normal;&quot;&gt;
+&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Please make sure the Eyeware Beam application is running and tracking is active.&lt;/p&gt;
+&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;To download, visit &lt;a href=&quot;https://beam.eyeware.tech/opentrack&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;https://beam.eyeware.tech/opentrack&lt;/span&gt;&lt;/a&gt;.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+</TS>
diff --git a/tracker-eyeware-beam/lang/ru_RU.ts b/tracker-eyeware-beam/lang/ru_RU.ts
new file mode 100644
index 00000000..0bff47ae
--- /dev/null
+++ b/tracker-eyeware-beam/lang/ru_RU.ts
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.1" language="ru_RU">
+<context>
+ <name>eyeware_beam_ui</name>
+ <message>
+ <source>Eyeware Beam</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
+&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
+p, li { white-space: pre-wrap; }
+&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:&apos;MS Shell Dlg 2&apos;; font-size:8pt; font-weight:400; font-style:normal;&quot;&gt;
+&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Please make sure the Eyeware Beam application is running and tracking is active.&lt;/p&gt;
+&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;To download, visit &lt;a href=&quot;https://beam.eyeware.tech/opentrack&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;https://beam.eyeware.tech/opentrack&lt;/span&gt;&lt;/a&gt;.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+</TS>
diff --git a/tracker-eyeware-beam/lang/stub.ts b/tracker-eyeware-beam/lang/stub.ts
new file mode 100644
index 00000000..c64ff83e
--- /dev/null
+++ b/tracker-eyeware-beam/lang/stub.ts
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.1">
+<context>
+ <name>eyeware_beam_ui</name>
+ <message>
+ <source>Eyeware Beam</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
+&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
+p, li { white-space: pre-wrap; }
+&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:&apos;MS Shell Dlg 2&apos;; font-size:8pt; font-weight:400; font-style:normal;&quot;&gt;
+&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Please make sure the Eyeware Beam application is running and tracking is active.&lt;/p&gt;
+&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;To download, visit &lt;a href=&quot;https://beam.eyeware.tech/opentrack&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;https://beam.eyeware.tech/opentrack&lt;/span&gt;&lt;/a&gt;.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+</TS>
diff --git a/tracker-eyeware-beam/lang/zh_CN.ts b/tracker-eyeware-beam/lang/zh_CN.ts
new file mode 100644
index 00000000..aed44317
--- /dev/null
+++ b/tracker-eyeware-beam/lang/zh_CN.ts
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.1" language="zh_CN">
+<context>
+ <name>eyeware_beam_ui</name>
+ <message>
+ <source>Eyeware Beam</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
+&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
+p, li { white-space: pre-wrap; }
+&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:&apos;MS Shell Dlg 2&apos;; font-size:8pt; font-weight:400; font-style:normal;&quot;&gt;
+&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Please make sure the Eyeware Beam application is running and tracking is active.&lt;/p&gt;
+&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;To download, visit &lt;a href=&quot;https://beam.eyeware.tech/opentrack&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;https://beam.eyeware.tech/opentrack&lt;/span&gt;&lt;/a&gt;.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+</TS>