From a774441fde00f0ce6c8387339c786e9e2f42f088 Mon Sep 17 00:00:00 2001 From: Stéphane Lenclud Date: Thu, 31 Jan 2019 10:32:17 +0100 Subject: Kinect: First draft. --- tracker-kinect-face/lang/ru_RU.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 tracker-kinect-face/lang/ru_RU.ts (limited to 'tracker-kinect-face/lang/ru_RU.ts') diff --git a/tracker-kinect-face/lang/ru_RU.ts b/tracker-kinect-face/lang/ru_RU.ts new file mode 100644 index 00000000..52aab9f3 --- /dev/null +++ b/tracker-kinect-face/lang/ru_RU.ts @@ -0,0 +1,22 @@ + + + + + test_metadata + + Kinect Face + + + + + test_ui + + Sine wave + + + + Pressing "Abort" will immediately crash the application. + + + + -- cgit v1.2.3 From 388a876b68a83956b687100007aab7afafbb08ab Mon Sep 17 00:00:00 2001 From: Stéphane Lenclud Date: Sat, 2 Feb 2019 02:50:04 +0100 Subject: Kinect: Adding tracker icon. --- tracker-kinect-face/images/kinect.png | Bin 0 -> 217 bytes tracker-kinect-face/kinect.qrc | 5 +++++ tracker-kinect-face/lang/nl_NL.ts | 2 +- tracker-kinect-face/lang/ru_RU.ts | 2 +- tracker-kinect-face/lang/stub.ts | 2 +- tracker-kinect-face/lang/zh_CN.ts | 2 +- tracker-kinect-face/test.h | 4 ++-- 7 files changed, 11 insertions(+), 6 deletions(-) create mode 100644 tracker-kinect-face/images/kinect.png create mode 100644 tracker-kinect-face/kinect.qrc (limited to 'tracker-kinect-face/lang/ru_RU.ts') diff --git a/tracker-kinect-face/images/kinect.png b/tracker-kinect-face/images/kinect.png new file mode 100644 index 00000000..fd8f5f77 Binary files /dev/null and b/tracker-kinect-face/images/kinect.png differ diff --git a/tracker-kinect-face/kinect.qrc b/tracker-kinect-face/kinect.qrc new file mode 100644 index 00000000..8b27c81e --- /dev/null +++ b/tracker-kinect-face/kinect.qrc @@ -0,0 +1,5 @@ + + + images/kinect.png + + diff --git a/tracker-kinect-face/lang/nl_NL.ts b/tracker-kinect-face/lang/nl_NL.ts index b6139882..dec7a177 100644 --- a/tracker-kinect-face/lang/nl_NL.ts +++ b/tracker-kinect-face/lang/nl_NL.ts @@ -4,7 +4,7 @@ test_metadata - Kinect Face + Kinect Face - v0.1 diff --git a/tracker-kinect-face/lang/ru_RU.ts b/tracker-kinect-face/lang/ru_RU.ts index 52aab9f3..1634c0c2 100644 --- a/tracker-kinect-face/lang/ru_RU.ts +++ b/tracker-kinect-face/lang/ru_RU.ts @@ -4,7 +4,7 @@ test_metadata - Kinect Face + Kinect Face - v0.1 diff --git a/tracker-kinect-face/lang/stub.ts b/tracker-kinect-face/lang/stub.ts index 84a3c6af..bb36fb1e 100644 --- a/tracker-kinect-face/lang/stub.ts +++ b/tracker-kinect-face/lang/stub.ts @@ -4,7 +4,7 @@ test_metadata - Kinect Face + Kinect Face - v0.1 diff --git a/tracker-kinect-face/lang/zh_CN.ts b/tracker-kinect-face/lang/zh_CN.ts index 84a3c6af..bb36fb1e 100644 --- a/tracker-kinect-face/lang/zh_CN.ts +++ b/tracker-kinect-face/lang/zh_CN.ts @@ -4,7 +4,7 @@ test_metadata - Kinect Face + Kinect Face - v0.1 diff --git a/tracker-kinect-face/test.h b/tracker-kinect-face/test.h index 2e105ae3..1af0409b 100644 --- a/tracker-kinect-face/test.h +++ b/tracker-kinect-face/test.h @@ -22,7 +22,7 @@ class test_metadata : public Metadata { Q_OBJECT - QString name() { return tr("Kinect Face"); } - QIcon icon() { return QIcon(":/images/opentrack.png"); } + QString name() { return tr("Kinect Face - v0.1"); } + QIcon icon() { return QIcon(":/images/kinect.png"); } }; -- cgit v1.2.3 From ba8796acda06c9ae5f528dbbf655c714844d5429 Mon Sep 17 00:00:00 2001 From: Stéphane Lenclud Date: Sat, 2 Feb 2019 17:36:05 +0100 Subject: Various fixes from code review. --- tracker-kinect-face/CMakeLists.txt | 51 ++++++++++++++++++++------------------ tracker-kinect-face/lang/nl_NL.ts | 2 +- tracker-kinect-face/lang/ru_RU.ts | 2 +- tracker-kinect-face/lang/stub.ts | 2 +- tracker-kinect-face/lang/zh_CN.ts | 2 +- tracker-kinect-face/test.h | 2 +- tracker-kinect-face/tracker.cpp | 11 +++----- 7 files changed, 36 insertions(+), 36 deletions(-) (limited to 'tracker-kinect-face/lang/ru_RU.ts') diff --git a/tracker-kinect-face/CMakeLists.txt b/tracker-kinect-face/CMakeLists.txt index 9a37f2d8..fca1e495 100644 --- a/tracker-kinect-face/CMakeLists.txt +++ b/tracker-kinect-face/CMakeLists.txt @@ -1,29 +1,32 @@ +# Kinect SDK is Windows only +if (WIN32) + # Setup cache variable to Kinect SDK path + if(DEFINED ENV{KINECTSDK20_DIR}) + set(KINECTSDK20_DIR $ENV{KINECTSDK20_DIR} CACHE PATH $ENV{KINECTSDK20_DIR}) + else() + set(KINECTSDK20_DIR $ENV{KINECTSDK20_DIR} CACHE PATH "") + endif() -# Setup cache variable to Kinect SDK path -if(DEFINED ENV{KINECTSDK20_DIR}) - set(KINECTSDK20_DIR $ENV{KINECTSDK20_DIR} CACHE PATH $ENV{KINECTSDK20_DIR}) -else() - set(KINECTSDK20_DIR $ENV{KINECTSDK20_DIR} CACHE PATH "") -endif() + # If we have a valid SDK path, try build that tracker + if(EXISTS ${KINECTSDK20_DIR}) + # Register our module + otr_module(tracker-kinect-face) -# If we have a valid SDK path, try build that tracker -if(EXISTS ${KINECTSDK20_DIR}) - # Register our module - otr_module(tracker-kinect-face) - - # Add include path to Kinect SDK - target_include_directories(opentrack-tracker-kinect-face SYSTEM PUBLIC ${KINECTSDK20_DIR}/inc) + # Add include path to Kinect SDK + target_include_directories(opentrack-tracker-kinect-face SYSTEM PUBLIC ${KINECTSDK20_DIR}/inc) - # Check processor architecture - if(CMAKE_SIZEOF_VOID_P EQUAL 4) - # 32 bits - set (kinect-arch-dir "x86") - elseif(CMAKE_SIZEOF_VOID_P EQUAL 8) - # 64 bits - set (kinect-arch-dir "x64") - endif() + # Check processor architecture + if(CMAKE_SIZEOF_VOID_P EQUAL 4) + # 32 bits + set (kinect-arch-dir "x86") + elseif(CMAKE_SIZEOF_VOID_P EQUAL 8) + # 64 bits + set (kinect-arch-dir "x64") + endif() - # Link against Kinect SDK libraries - target_link_libraries(opentrack-tracker-kinect-face ${KINECTSDK20_DIR}/lib/${kinect-arch-dir}/kinect20.lib ${KINECTSDK20_DIR}/lib/${kinect-arch-dir}/kinect20.face.lib) + # Link against Kinect SDK libraries + target_link_libraries(opentrack-tracker-kinect-face ${KINECTSDK20_DIR}/lib/${kinect-arch-dir}/kinect20.lib ${KINECTSDK20_DIR}/lib/${kinect-arch-dir}/kinect20.face.lib) + + endif() -endif() +endif() \ No newline at end of file diff --git a/tracker-kinect-face/lang/nl_NL.ts b/tracker-kinect-face/lang/nl_NL.ts index dec7a177..f4fe07d8 100644 --- a/tracker-kinect-face/lang/nl_NL.ts +++ b/tracker-kinect-face/lang/nl_NL.ts @@ -4,7 +4,7 @@ test_metadata - Kinect Face - v0.1 + Kinect Face 0.1 diff --git a/tracker-kinect-face/lang/ru_RU.ts b/tracker-kinect-face/lang/ru_RU.ts index 1634c0c2..d4108ed3 100644 --- a/tracker-kinect-face/lang/ru_RU.ts +++ b/tracker-kinect-face/lang/ru_RU.ts @@ -4,7 +4,7 @@ test_metadata - Kinect Face - v0.1 + Kinect Face 0.1 diff --git a/tracker-kinect-face/lang/stub.ts b/tracker-kinect-face/lang/stub.ts index bb36fb1e..f82903a3 100644 --- a/tracker-kinect-face/lang/stub.ts +++ b/tracker-kinect-face/lang/stub.ts @@ -4,7 +4,7 @@ test_metadata - Kinect Face - v0.1 + Kinect Face 0.1 diff --git a/tracker-kinect-face/lang/zh_CN.ts b/tracker-kinect-face/lang/zh_CN.ts index bb36fb1e..f82903a3 100644 --- a/tracker-kinect-face/lang/zh_CN.ts +++ b/tracker-kinect-face/lang/zh_CN.ts @@ -4,7 +4,7 @@ test_metadata - Kinect Face - v0.1 + Kinect Face 0.1 diff --git a/tracker-kinect-face/test.h b/tracker-kinect-face/test.h index 1af0409b..0f8c170b 100644 --- a/tracker-kinect-face/test.h +++ b/tracker-kinect-face/test.h @@ -22,7 +22,7 @@ class test_metadata : public Metadata { Q_OBJECT - QString name() { return tr("Kinect Face - v0.1"); } + QString name() { return tr("Kinect Face 0.1"); } QIcon icon() { return QIcon(":/images/kinect.png"); } }; diff --git a/tracker-kinect-face/tracker.cpp b/tracker-kinect-face/tracker.cpp index 407557f0..c5517f89 100644 --- a/tracker-kinect-face/tracker.cpp +++ b/tracker-kinect-face/tracker.cpp @@ -38,7 +38,7 @@ bool IsNullVetor(const Vector4& aVector) return false; } - if (aVector.y != 0) + if (aVector.x != 0) { return false; } @@ -74,7 +74,6 @@ bool IsNullPoint(const CameraSpacePoint& aPoint) return false; } - return true; } @@ -150,9 +149,9 @@ module_status KinectFaceTracker::start_tracker(QFrame* aFrame) bool KinectFaceTracker::center() { + // Mark our center iFacePositionCenter = iFacePosition; iFaceRotationCenter = iFaceRotation; - //TODO: Rotation center too return true; } @@ -181,11 +180,9 @@ void KinectFaceTracker::data(double *data) data[2] = (iLastFacePosition.Z - iFacePositionCenter.Z) * 100; // Yaw, Picth, Roll - data[3] = 0-(iLastFaceRotation.X - iFaceRotationCenter.X); // Invert to be compatible with ED out-of-the-box + data[3] = -(iLastFaceRotation.X - iFaceRotationCenter.X); // Invert to be compatible with ED out-of-the-box data[4] = (iLastFaceRotation.Y - iFaceRotationCenter.Y); data[5] = (iLastFaceRotation.Z - iFaceRotationCenter.Z); - - } @@ -463,7 +460,7 @@ void KinectFaceTracker::ProcessFaces() { if (bFaceTracked) { - OutputDebugStringA("Tracking face!\n"); + //OutputDebugStringA("Tracking face!\n"); //IFaceFrameResult* pFaceFrameResult = nullptr; IFaceAlignment* pFaceAlignment = nullptr; -- cgit v1.2.3 From 4508be24ef4adc4dac0c40ef316b07da75765b77 Mon Sep 17 00:00:00 2001 From: Stéphane Lenclud Date: Sun, 3 Feb 2019 15:03:57 +0100 Subject: Kinect: Limit actual frame rate to 30Hz. Fixing settings dialog. --- tracker-kinect-face/kinect_face_settings.cpp | 16 +++++++------ tracker-kinect-face/kinect_face_settings.h | 10 ++++---- tracker-kinect-face/kinect_face_settings.ui | 10 ++++---- tracker-kinect-face/kinect_face_tracker.cpp | 35 +++++++++++++++++----------- tracker-kinect-face/kinect_face_tracker.h | 4 +++- tracker-kinect-face/lang/nl_NL.ts | 8 +++---- tracker-kinect-face/lang/ru_RU.ts | 8 +++---- tracker-kinect-face/lang/stub.ts | 8 +++---- tracker-kinect-face/lang/zh_CN.ts | 8 +++---- 9 files changed, 59 insertions(+), 48 deletions(-) (limited to 'tracker-kinect-face/lang/ru_RU.ts') diff --git a/tracker-kinect-face/kinect_face_settings.cpp b/tracker-kinect-face/kinect_face_settings.cpp index 53aada06..238a3da6 100644 --- a/tracker-kinect-face/kinect_face_settings.cpp +++ b/tracker-kinect-face/kinect_face_settings.cpp @@ -17,29 +17,31 @@ #include -test_dialog::test_dialog() +KinectFaceSettings::KinectFaceSettings() { ui.setupUi(this); connect(ui.buttonBox, &QDialogButtonBox::clicked, [this](QAbstractButton* btn) { - if (btn == ui.buttonBox->button(QDialogButtonBox::Abort)) - // NOLINTNEXTLINE - *(volatile int*)nullptr = 0; + if (btn == ui.buttonBox->button(QDialogButtonBox::Abort)) + { + // NOLINTNEXTLINE + //*(volatile int*)nullptr = 0; + } }); connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK())); connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel())); } -void test_dialog::doOK() +void KinectFaceSettings::doOK() { //s.b->save(); close(); } -void test_dialog::doCancel() +void KinectFaceSettings::doCancel() { close(); } -OPENTRACK_DECLARE_TRACKER(KinectFaceTracker, test_dialog, test_metadata) +OPENTRACK_DECLARE_TRACKER(KinectFaceTracker, KinectFaceSettings, KinectFaceMetadata) diff --git a/tracker-kinect-face/kinect_face_settings.h b/tracker-kinect-face/kinect_face_settings.h index 0f8c170b..647aa754 100644 --- a/tracker-kinect-face/kinect_face_settings.h +++ b/tracker-kinect-face/kinect_face_settings.h @@ -1,16 +1,16 @@ #pragma once -#include "ui_test.h" +#include "ui_kinect_face_settings.h" #include "compat/macros.hpp" #include "api/plugin-api.hpp" -class test_dialog : public ITrackerDialog +class KinectFaceSettings : public ITrackerDialog { Q_OBJECT - Ui::test_ui ui; + Ui::KinectFaceUi ui; public: - test_dialog(); + KinectFaceSettings(); void register_tracker(ITracker *) override {} void unregister_tracker() override {} private slots: @@ -18,7 +18,7 @@ private slots: void doCancel(); }; -class test_metadata : public Metadata +class KinectFaceMetadata : public Metadata { Q_OBJECT diff --git a/tracker-kinect-face/kinect_face_settings.ui b/tracker-kinect-face/kinect_face_settings.ui index 509eb819..a6192d9b 100644 --- a/tracker-kinect-face/kinect_face_settings.ui +++ b/tracker-kinect-face/kinect_face_settings.ui @@ -1,7 +1,7 @@ - test_ui - + KinectFaceUi + Qt::NonModal @@ -14,11 +14,11 @@ - Sine wave + Kinect Face Tracker - ../gui/images/opentrack.png../gui/images/opentrack.png + :/images/kinect.png:/images/kinect.png Qt::LeftToRight @@ -36,7 +36,7 @@ - Pressing "Abort" will immediately crash the application. + Start OpenTrack to check if Kinect Face Tracker is working. diff --git a/tracker-kinect-face/kinect_face_tracker.cpp b/tracker-kinect-face/kinect_face_tracker.cpp index 40571a28..ab568f1e 100644 --- a/tracker-kinect-face/kinect_face_tracker.cpp +++ b/tracker-kinect-face/kinect_face_tracker.cpp @@ -170,25 +170,32 @@ bool KinectFaceTracker::center() void KinectFaceTracker::data(double *data) { const double dt = t.elapsed_seconds(); - t.start(); - - Update(); - - ExtractFaceRotationInDegrees(&iFaceRotationQuaternion, &iFaceRotation.X, &iFaceRotation.Y, &iFaceRotation.Z); - //Check if data is valid - if (IsValidRect(iFaceBox)) + const double KMinDelayInSeconds = 1.0 / 30.0; // Pointless running faster than Kinect hardware itself + if (dt > KMinDelayInSeconds) { - // We have valid tracking retain position and rotation - iLastFacePosition = iFacePosition; - iLastFaceRotation = iFaceRotation; + t.start(); // Reset our timer + //OutputDebugStringA("Updating frame!\n"); + Update(); + ExtractFaceRotationInDegrees(&iFaceRotationQuaternion, &iFaceRotation.X, &iFaceRotation.Y, &iFaceRotation.Z); + //Check if data is valid + if (IsValidRect(iFaceBox)) + { + // We have valid tracking retain position and rotation + iLastFacePosition = iFacePosition; + iLastFaceRotation = iFaceRotation; + } + else + { + //TODO: after like 5s without tracking reset position to zero + //TODO: Instead of hardcoding that delay add it to our settings + } } else { - //TODO: after like 5s without tracking reset position to zero - //TODO: Instead of hardcoding that delay add it to our settings + //OutputDebugStringA("Skipping frame!\n"); } - + // Feed our framework our last valid position and rotation data[0] = (iLastFacePosition.X - iFacePositionCenter.X) * 100; // Convert to centimer to be in a range that suites OpenTrack. data[1] = (iLastFacePosition.Y - iFacePositionCenter.Y) * 100; @@ -344,7 +351,7 @@ void KinectFaceTracker::Update() if (SUCCEEDED(hr)) { hr = pColorFrame->get_RawColorImageFormat(&imageFormat); - } + } if (SUCCEEDED(hr)) { diff --git a/tracker-kinect-face/kinect_face_tracker.h b/tracker-kinect-face/kinect_face_tracker.h index de71f081..9f75507d 100644 --- a/tracker-kinect-face/kinect_face_tracker.h +++ b/tracker-kinect-face/kinect_face_tracker.h @@ -51,7 +51,9 @@ private: }; - +// +// +// class KinectFaceTracker : public ITracker { public: diff --git a/tracker-kinect-face/lang/nl_NL.ts b/tracker-kinect-face/lang/nl_NL.ts index f4fe07d8..a0a737ee 100644 --- a/tracker-kinect-face/lang/nl_NL.ts +++ b/tracker-kinect-face/lang/nl_NL.ts @@ -2,20 +2,20 @@ - test_metadata + KinectFaceMetadata Kinect Face 0.1 - test_ui + KinectFaceUi - Sine wave + Kinect Face Tracker - Pressing "Abort" will immediately crash the application. + Start OpenTrack to check if Kinect Face Tracker is working. diff --git a/tracker-kinect-face/lang/ru_RU.ts b/tracker-kinect-face/lang/ru_RU.ts index d4108ed3..72f91367 100644 --- a/tracker-kinect-face/lang/ru_RU.ts +++ b/tracker-kinect-face/lang/ru_RU.ts @@ -2,20 +2,20 @@ - test_metadata + KinectFaceMetadata Kinect Face 0.1 - test_ui + KinectFaceUi - Sine wave + Kinect Face Tracker - Pressing "Abort" will immediately crash the application. + Start OpenTrack to check if Kinect Face Tracker is working. diff --git a/tracker-kinect-face/lang/stub.ts b/tracker-kinect-face/lang/stub.ts index f82903a3..055ec4e1 100644 --- a/tracker-kinect-face/lang/stub.ts +++ b/tracker-kinect-face/lang/stub.ts @@ -2,20 +2,20 @@ - test_metadata + KinectFaceMetadata Kinect Face 0.1 - test_ui + KinectFaceUi - Sine wave + Kinect Face Tracker - Pressing "Abort" will immediately crash the application. + Start OpenTrack to check if Kinect Face Tracker is working. diff --git a/tracker-kinect-face/lang/zh_CN.ts b/tracker-kinect-face/lang/zh_CN.ts index f82903a3..055ec4e1 100644 --- a/tracker-kinect-face/lang/zh_CN.ts +++ b/tracker-kinect-face/lang/zh_CN.ts @@ -2,20 +2,20 @@ - test_metadata + KinectFaceMetadata Kinect Face 0.1 - test_ui + KinectFaceUi - Sine wave + Kinect Face Tracker - Pressing "Abort" will immediately crash the application. + Start OpenTrack to check if Kinect Face Tracker is working. -- cgit v1.2.3