diff options
author | Davide Mameli <davide@eyeware.tech> | 2023-03-07 12:51:23 +0100 |
---|---|---|
committer | Davide Mameli <davide@eyeware.tech> | 2023-03-07 16:15:16 +0100 |
commit | c8cccf1a21b600efd89258f48ef6dacaf187e96b (patch) | |
tree | 33ef0c896af5dbc9092354bf6e91cabc9b2bbdcb | |
parent | e8c0b30ff2db91c60b26b90054c16b22dca28956 (diff) |
Initial commit
-rw-r--r-- | tracker-eyeware-beam/CMakeLists.txt | 16 | ||||
-rw-r--r-- | tracker-eyeware-beam/eyeware_beam.cpp | 111 | ||||
-rw-r--r-- | tracker-eyeware-beam/eyeware_beam.h | 74 | ||||
-rw-r--r-- | tracker-eyeware-beam/eyeware_beam.qrc | 5 | ||||
-rw-r--r-- | tracker-eyeware-beam/eyeware_beam.ui | 90 | ||||
-rw-r--r-- | tracker-eyeware-beam/eyeware_beam_logo.png | bin | 0 -> 2032 bytes | |||
-rw-r--r-- | tracker-eyeware-beam/lang/nl_NL.ts | 20 | ||||
-rw-r--r-- | tracker-eyeware-beam/lang/ru_RU.ts | 20 | ||||
-rw-r--r-- | tracker-eyeware-beam/lang/stub.ts | 20 | ||||
-rw-r--r-- | tracker-eyeware-beam/lang/zh_CN.ts | 20 |
10 files changed, 376 insertions, 0 deletions
diff --git a/tracker-eyeware-beam/CMakeLists.txt b/tracker-eyeware-beam/CMakeLists.txt new file mode 100644 index 00000000..b9e85f0d --- /dev/null +++ b/tracker-eyeware-beam/CMakeLists.txt @@ -0,0 +1,16 @@ +set(SDK_EYEWARE_BEAM "" CACHE PATH "Eyeware Beam SDK path") +if(WIN32 AND SDK_EYEWARE_BEAM) + otr_module(tracker-eyeware-beam) + + target_include_directories(${self} SYSTEM PRIVATE "${SDK_EYEWARE_BEAM}/API/cpp/include") + target_link_directories(${self} SYSTEM PRIVATE "${SDK_EYEWARE_BEAM}/API/cpp/lib") + set(dll "${SDK_EYEWARE_BEAM}/API/cpp/lib/tracker_client.dll" "${SDK_EYEWARE_BEAM}/API/cpp/lib/libsodium.dll") + set(lib tracker_client) + + 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..6762b1bf --- /dev/null +++ b/tracker-eyeware-beam/eyeware_beam.cpp @@ -0,0 +1,111 @@ +/* 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> + +eyeware_beam_tracker::eyeware_beam_tracker() +{ +} + +eyeware_beam_tracker::~eyeware_beam_tracker() +{ + QMutexLocker lck(&mtx); + tracker_client.reset(nullptr); +} + +module_status eyeware_beam_tracker::start_tracker(QFrame* videoframe) +{ + QMutexLocker lck(&mtx); + try + { + tracker_client = std::make_unique<eyeware::TrackerClient>(); + } + 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 (tracker_client && tracker_client->connected()) + { + eyeware::HeadPoseInfo head_pose_info = tracker_client->get_head_pose_info(); + 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..b30703bc --- /dev/null +++ b/tracker-eyeware-beam/eyeware_beam.h @@ -0,0 +1,74 @@ +/* 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); + + std::unique_ptr<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; + + const double rad_to_deg = 180.0 / M_PI; + const double m_to_cm = 100.0; + const double epsilon = 0.000001; +}; + +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><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Please make sure the Eyeware Beam application is running and tracking is active.</p> +<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">To download, visit <a href="https://beam.eyeware.tech/opentrack"><span style=" text-decoration: underline; color:#0000ff;">https://beam.eyeware.tech/opentrack</span></a>.</p></body></html></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 Binary files differnew file mode 100644 index 00000000..6a611cac --- /dev/null +++ b/tracker-eyeware-beam/eyeware_beam_logo.png 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><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Please make sure the Eyeware Beam application is running and tracking is active.</p> +<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">To download, visit <a href="https://beam.eyeware.tech/opentrack"><span style=" text-decoration: underline; color:#0000ff;">https://beam.eyeware.tech/opentrack</span></a>.</p></body></html></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><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Please make sure the Eyeware Beam application is running and tracking is active.</p> +<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">To download, visit <a href="https://beam.eyeware.tech/opentrack"><span style=" text-decoration: underline; color:#0000ff;">https://beam.eyeware.tech/opentrack</span></a>.</p></body></html></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><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Please make sure the Eyeware Beam application is running and tracking is active.</p> +<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">To download, visit <a href="https://beam.eyeware.tech/opentrack"><span style=" text-decoration: underline; color:#0000ff;">https://beam.eyeware.tech/opentrack</span></a>.</p></body></html></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><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Please make sure the Eyeware Beam application is running and tracking is active.</p> +<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">To download, visit <a href="https://beam.eyeware.tech/opentrack"><span style=" text-decoration: underline; color:#0000ff;">https://beam.eyeware.tech/opentrack</span></a>.</p></body></html></source> + <translation type="unfinished"></translation> + </message> +</context> +</TS> |