From c8cccf1a21b600efd89258f48ef6dacaf187e96b Mon Sep 17 00:00:00 2001 From: Davide Mameli Date: Tue, 7 Mar 2023 12:51:23 +0100 Subject: Initial commit --- tracker-eyeware-beam/CMakeLists.txt | 16 +++++ tracker-eyeware-beam/eyeware_beam.cpp | 111 +++++++++++++++++++++++++++++ tracker-eyeware-beam/eyeware_beam.h | 74 +++++++++++++++++++ tracker-eyeware-beam/eyeware_beam.qrc | 5 ++ tracker-eyeware-beam/eyeware_beam.ui | 90 +++++++++++++++++++++++ tracker-eyeware-beam/eyeware_beam_logo.png | Bin 0 -> 2032 bytes tracker-eyeware-beam/lang/nl_NL.ts | 20 ++++++ tracker-eyeware-beam/lang/ru_RU.ts | 20 ++++++ tracker-eyeware-beam/lang/stub.ts | 20 ++++++ tracker-eyeware-beam/lang/zh_CN.ts | 20 ++++++ 10 files changed, 376 insertions(+) create mode 100644 tracker-eyeware-beam/CMakeLists.txt create mode 100644 tracker-eyeware-beam/eyeware_beam.cpp create mode 100644 tracker-eyeware-beam/eyeware_beam.h create mode 100644 tracker-eyeware-beam/eyeware_beam.qrc create mode 100644 tracker-eyeware-beam/eyeware_beam.ui create mode 100644 tracker-eyeware-beam/eyeware_beam_logo.png create mode 100644 tracker-eyeware-beam/lang/nl_NL.ts create mode 100644 tracker-eyeware-beam/lang/ru_RU.ts create mode 100644 tracker-eyeware-beam/lang/stub.ts create mode 100644 tracker-eyeware-beam/lang/zh_CN.ts 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 + +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(); + } + 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(R[0][0]); + double r01 = static_cast(R[0][1]); + double r02 = static_cast(R[0][2]); + double r10 = static_cast(R[1][0]); + double r11 = static_cast(R[1][1]); + double r12 = static_cast(R[1][2]); + double r20 = static_cast(R[2][0]); + double r21 = static_cast(R[2][1]); + double r22 = static_cast(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 +#include + +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 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(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 @@ + + + eyeware_beam_logo.png + + 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 @@ + + + eyeware_beam_ui + + + Qt::NonModal + + + + 0 + 0 + 433 + 180 + + + + + 0 + 0 + + + + Eyeware Beam + + + + :/images/eyeware_beam_logo.png:/images/eyeware_beam_logo.png + + + Qt::LeftToRight + + + false + + + + + + QFrame::Raised + + + + + + + 0 + 0 + + + + <!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> + + + true + + + + + + + + + + + 0 + 0 + + + + QDialogButtonBox::Ok + + + + + + + + + + + startEngineClicked() + stopEngineClicked() + cameraSettingsClicked() + + 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 Binary files /dev/null and b/tracker-eyeware-beam/eyeware_beam_logo.png 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 @@ + + + + + eyeware_beam_ui + + Eyeware Beam + + + + <!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> + + + + 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 @@ + + + + + eyeware_beam_ui + + Eyeware Beam + + + + <!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> + + + + 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 @@ + + + + + eyeware_beam_ui + + Eyeware Beam + + + + <!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> + + + + 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 @@ + + + + + eyeware_beam_ui + + Eyeware Beam + + + + <!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> + + + + -- cgit v1.2.3