summaryrefslogtreecommitdiffhomepage
path: root/tracker-kinect-face
diff options
context:
space:
mode:
authorStéphane Lenclud <github@lenclud.com>2019-02-03 15:03:57 +0100
committerStéphane Lenclud <github@lenclud.com>2019-02-07 13:24:14 +0100
commit4508be24ef4adc4dac0c40ef316b07da75765b77 (patch)
tree9cd408b7954a6cbb9f58200179d1b25a584ef415 /tracker-kinect-face
parent7397242cb156ae0d1e942fba9d209b8627a2072e (diff)
Kinect: Limit actual frame rate to 30Hz.
Fixing settings dialog.
Diffstat (limited to 'tracker-kinect-face')
-rw-r--r--tracker-kinect-face/kinect_face_settings.cpp16
-rw-r--r--tracker-kinect-face/kinect_face_settings.h10
-rw-r--r--tracker-kinect-face/kinect_face_settings.ui10
-rw-r--r--tracker-kinect-face/kinect_face_tracker.cpp35
-rw-r--r--tracker-kinect-face/kinect_face_tracker.h4
-rw-r--r--tracker-kinect-face/lang/nl_NL.ts8
-rw-r--r--tracker-kinect-face/lang/ru_RU.ts8
-rw-r--r--tracker-kinect-face/lang/stub.ts8
-rw-r--r--tracker-kinect-face/lang/zh_CN.ts8
9 files changed, 59 insertions, 48 deletions
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 <QDebug>
-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 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
- <class>test_ui</class>
- <widget class="QWidget" name="test_ui">
+ <class>KinectFaceUi</class>
+ <widget class="QWidget" name="KinectFaceUi">
<property name="windowModality">
<enum>Qt::NonModal</enum>
</property>
@@ -14,11 +14,11 @@
</rect>
</property>
<property name="windowTitle">
- <string>Sine wave</string>
+ <string>Kinect Face Tracker</string>
</property>
<property name="windowIcon">
<iconset>
- <normaloff>../gui/images/opentrack.png</normaloff>../gui/images/opentrack.png</iconset>
+ <normaloff>:/images/kinect.png</normaloff>:/images/kinect.png</iconset>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
@@ -36,7 +36,7 @@
</sizepolicy>
</property>
<property name="text">
- <string>Pressing &quot;Abort&quot; will immediately crash the application.</string>
+ <string>Start OpenTrack to check if Kinect Face Tracker is working.</string>
</property>
</widget>
</item>
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 @@
<!DOCTYPE TS>
<TS version="2.1" language="nl_NL">
<context>
- <name>test_metadata</name>
+ <name>KinectFaceMetadata</name>
<message>
<source>Kinect Face 0.1</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
- <name>test_ui</name>
+ <name>KinectFaceUi</name>
<message>
- <source>Sine wave</source>
+ <source>Kinect Face Tracker</source>
<translation type="unfinished"></translation>
</message>
<message>
- <source>Pressing &quot;Abort&quot; will immediately crash the application.</source>
+ <source>Start OpenTrack to check if Kinect Face Tracker is working.</source>
<translation type="unfinished"></translation>
</message>
</context>
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 @@
<!DOCTYPE TS>
<TS version="2.1" language="ru_RU">
<context>
- <name>test_metadata</name>
+ <name>KinectFaceMetadata</name>
<message>
<source>Kinect Face 0.1</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
- <name>test_ui</name>
+ <name>KinectFaceUi</name>
<message>
- <source>Sine wave</source>
+ <source>Kinect Face Tracker</source>
<translation type="unfinished"></translation>
</message>
<message>
- <source>Pressing &quot;Abort&quot; will immediately crash the application.</source>
+ <source>Start OpenTrack to check if Kinect Face Tracker is working.</source>
<translation type="unfinished"></translation>
</message>
</context>
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 @@
<!DOCTYPE TS>
<TS version="2.1">
<context>
- <name>test_metadata</name>
+ <name>KinectFaceMetadata</name>
<message>
<source>Kinect Face 0.1</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
- <name>test_ui</name>
+ <name>KinectFaceUi</name>
<message>
- <source>Sine wave</source>
+ <source>Kinect Face Tracker</source>
<translation type="unfinished"></translation>
</message>
<message>
- <source>Pressing &quot;Abort&quot; will immediately crash the application.</source>
+ <source>Start OpenTrack to check if Kinect Face Tracker is working.</source>
<translation type="unfinished"></translation>
</message>
</context>
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 @@
<!DOCTYPE TS>
<TS version="2.1">
<context>
- <name>test_metadata</name>
+ <name>KinectFaceMetadata</name>
<message>
<source>Kinect Face 0.1</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
- <name>test_ui</name>
+ <name>KinectFaceUi</name>
<message>
- <source>Sine wave</source>
+ <source>Kinect Face Tracker</source>
<translation type="unfinished"></translation>
</message>
<message>
- <source>Pressing &quot;Abort&quot; will immediately crash the application.</source>
+ <source>Start OpenTrack to check if Kinect Face Tracker is working.</source>
<translation type="unfinished"></translation>
</message>
</context>