summaryrefslogtreecommitdiffhomepage
path: root/FaceTrackNoIR
diff options
context:
space:
mode:
authorWim Vriend <facetracknoir@gmail.com>2010-06-01 20:12:59 +0000
committerWim Vriend <facetracknoir@gmail.com>2010-06-01 20:12:59 +0000
commit49d80a3e2497bdc75fa5d8b24cea7a02e4e2f96e (patch)
tree333a53c86351012d90689b3e3a6883a003a3c4a3 /FaceTrackNoIR
parent2625fe5af6bf71a627dcf10ff813574f8a61f994 (diff)
Added Start/stop/reset, started with anti-jitter-campaign
git-svn-id: svn+ssh://svn.code.sf.net/p/facetracknoir/code@4 19e81ba0-9b1a-49c3-bd6c-561e1906d5fb
Diffstat (limited to 'FaceTrackNoIR')
-rw-r--r--FaceTrackNoIR/FTServer.cpp4
-rw-r--r--FaceTrackNoIR/FaceTrackNoIR.cpp66
-rw-r--r--FaceTrackNoIR/FaceTrackNoIR.h11
-rw-r--r--FaceTrackNoIR/FaceTrackNoIR.ui4
-rw-r--r--FaceTrackNoIR/GeneratedFiles/ui_FaceTrackNoIR.h6
-rw-r--r--FaceTrackNoIR/tracker.cpp170
-rw-r--r--FaceTrackNoIR/tracker.h30
7 files changed, 245 insertions, 46 deletions
diff --git a/FaceTrackNoIR/FTServer.cpp b/FaceTrackNoIR/FTServer.cpp
index 854b091a..578317a1 100644
--- a/FaceTrackNoIR/FTServer.cpp
+++ b/FaceTrackNoIR/FTServer.cpp
@@ -40,6 +40,7 @@
//
/*
Modifications (last one on top):
+ 20100601 - WVR: Added Mutex-bit in run(). Thought it wasn't so important (still do...).
20100523 - WVR: Implemented the Freetrack-protocol just like Freetrack does. Earlier
FaceTrackNoIR only worked with an adapted DLL, with a putdata function.
Now it works direcly in shared memory!
@@ -99,7 +100,7 @@ void FTServer::run() {
return;
}
- if (pMemData != NULL) {
+ if ( (pMemData != NULL) && (WaitForSingleObject(hFTMutex, 100) == WAIT_OBJECT_0) ) {
//
// Copy the Raw measurements directly to the client.
@@ -135,6 +136,7 @@ void FTServer::run() {
qDebug() << "FTServer says: pMemData.DataID =" << pMemData->data.DataID;
qDebug() << "FTServer says: ProgramName =" << pMemData->ProgramName;
+ ReleaseMutex(hFTMutex);
}
// just for lower cpu load
diff --git a/FaceTrackNoIR/FaceTrackNoIR.cpp b/FaceTrackNoIR/FaceTrackNoIR.cpp
index c9e1e76d..f68dcfe1 100644
--- a/FaceTrackNoIR/FaceTrackNoIR.cpp
+++ b/FaceTrackNoIR/FaceTrackNoIR.cpp
@@ -82,6 +82,14 @@ void FaceTrackNoIR::setupFaceTrackNoIR() {
connect(ui.chkInvertY, SIGNAL(stateChanged(int)), this, SLOT(setInvertY(int)));
connect(ui.chkInvertZ, SIGNAL(stateChanged(int)), this, SLOT(setInvertZ(int)));
+ // Connect sliders for threshold
+ connect(ui.thresYaw, SIGNAL(valueChanged(int)), this, SLOT(setThreshYaw(int)));
+ connect(ui.thresRoll, SIGNAL(valueChanged(int)), this, SLOT(setThreshRoll(int)));
+ connect(ui.thresPitch, SIGNAL(valueChanged(int)), this, SLOT(setThreshPitch(int)));
+ connect(ui.thresX, SIGNAL(valueChanged(int)), this, SLOT(setThreshX(int)));
+ connect(ui.thresY, SIGNAL(valueChanged(int)), this, SLOT(setThreshY(int)));
+ connect(ui.thresZ, SIGNAL(valueChanged(int)), this, SLOT(setThreshZ(int)));
+
connect(ui.slideNeutralZone, SIGNAL(valueChanged(int)), this, SLOT(setNeutralZone(int)));
// Connect slider for smoothing
@@ -261,6 +269,12 @@ void FaceTrackNoIR::save() {
iniFile.setValue ( "invertX", ui.chkInvertX->isChecked() );
iniFile.setValue ( "invertY", ui.chkInvertY->isChecked() );
iniFile.setValue ( "invertZ", ui.chkInvertZ->isChecked() );
+ iniFile.setValue ( "thresYaw", ui.thresYaw->value() );
+ iniFile.setValue ( "thresPitch", ui.thresPitch->value() );
+ iniFile.setValue ( "thresRoll", ui.thresRoll->value() );
+ iniFile.setValue ( "thresX", ui.thresX->value() );
+ iniFile.setValue ( "thresY", ui.thresY->value() );
+ iniFile.setValue ( "thresZ", ui.thresZ->value() );
iniFile.endGroup ();
iniFile.beginGroup ( "GameProtocol" );
@@ -317,6 +331,12 @@ void FaceTrackNoIR::loadSettings() {
ui.chkInvertX->setChecked (iniFile.value ( "invertX", 0 ).toBool());
ui.chkInvertY->setChecked (iniFile.value ( "invertY", 0 ).toBool());
ui.chkInvertZ->setChecked (iniFile.value ( "invertZ", 0 ).toBool());
+ ui.thresYaw->setValue (iniFile.value ( "thresYaw", 100 ).toInt());
+ ui.thresPitch->setValue (iniFile.value ( "thresPitch", 100 ).toInt());
+ ui.thresRoll->setValue (iniFile.value ( "thresRoll", 100 ).toInt());
+ ui.thresX->setValue (iniFile.value ( "thresX", 100 ).toInt());
+ ui.thresY->setValue (iniFile.value ( "thresY", 100 ).toInt());
+ ui.thresZ->setValue (iniFile.value ( "thresZ", 100 ).toInt());
iniFile.endGroup ();
iniFile.beginGroup ( "GameProtocol" );
@@ -365,8 +385,18 @@ void FaceTrackNoIR::startTracker( ) {
l->setSpacing(0);
l->addWidget(_display);
+ //
+ // Setup the Tracker and send the settings, just to be sure...
+ //
tracker->setup( ui.headPoseWidget , this);
tracker->setSmoothing ( ui.slideSmoothing->value() );
+ tracker->setNeutralZone ( ui.slideNeutralZone->value() );
+ tracker->setSensYaw (ui.sensYaw->value() );
+ tracker->setSensPitch (ui.sensPitch->value() );
+ tracker->setSensRoll (ui.sensRoll->value() );
+ tracker->setSensX (ui.sensX->value() );
+ tracker->setSensY (ui.sensY->value() );
+ tracker->setSensZ (ui.sensZ->value() );
ui.headPoseWidget->show();
@@ -480,6 +510,42 @@ void FaceTrackNoIR::setInvertZ( int invert ) {
settingsDirty = true;
}
+/** set the threshold from the slider **/
+void FaceTrackNoIR::setThreshYaw( int thresh ) {
+ Tracker::setThresYaw ( thresh );
+ settingsDirty = true;
+}
+
+/** set the threshold from the slider **/
+void FaceTrackNoIR::setThreshPitch( int thresh ) {
+ Tracker::setThresPitch ( thresh );
+ settingsDirty = true;
+}
+
+/** set the threshold from the slider **/
+void FaceTrackNoIR::setThreshRoll( int thresh ) {
+ Tracker::setThresRoll ( thresh );
+ settingsDirty = true;
+}
+
+/** set the threshold from the slider **/
+void FaceTrackNoIR::setThreshX( int thresh ) {
+ Tracker::setThresX ( thresh );
+ settingsDirty = true;
+}
+
+/** set the threshold from the slider **/
+void FaceTrackNoIR::setThreshY( int thresh ) {
+ Tracker::setThresY ( thresh );
+ settingsDirty = true;
+}
+
+/** set the threshold from the slider **/
+void FaceTrackNoIR::setThreshZ( int thresh ) {
+ Tracker::setThresZ ( thresh );
+ settingsDirty = true;
+}
+
/** set the Neutral Zone for rotations from the slider **/
void FaceTrackNoIR::setNeutralZone( int angle ) {
Tracker::setNeutralZone ( angle );
diff --git a/FaceTrackNoIR/FaceTrackNoIR.h b/FaceTrackNoIR/FaceTrackNoIR.h
index 16a432a3..f5f87fc9 100644
--- a/FaceTrackNoIR/FaceTrackNoIR.h
+++ b/FaceTrackNoIR/FaceTrackNoIR.h
@@ -102,7 +102,7 @@ private:
void showHeadPoseWidget();
void showEngineControls();
- //sensibility sliders
+ // sensibility sliders
void setSensYaw( int sens );
void setSensPitch( int sens );
void setSensRoll( int sens );
@@ -110,6 +110,7 @@ private:
void setSensY( int sens );
void setSensZ( int sens );
+ // invert checkboxes
void setInvertYaw( int invert );
void setInvertPitch( int invert );
void setInvertRoll( int invert );
@@ -117,6 +118,14 @@ private:
void setInvertY( int invert );
void setInvertZ( int invert );
+ // threshold sliders
+ void setThreshYaw( int thresh );
+ void setThreshPitch( int thresh );
+ void setThreshRoll( int thresh );
+ void setThreshX( int thresh );
+ void setThreshY( int thresh );
+ void setThreshZ( int thresh );
+
void setNeutralZone( int angle );
//smoothing slider
diff --git a/FaceTrackNoIR/FaceTrackNoIR.ui b/FaceTrackNoIR/FaceTrackNoIR.ui
index 13a0aac8..47f6475c 100644
--- a/FaceTrackNoIR/FaceTrackNoIR.ui
+++ b/FaceTrackNoIR/FaceTrackNoIR.ui
@@ -1211,7 +1211,7 @@ opacity:100;</string>
<widget class="QLabel" name="lblSensitivity">
<property name="minimumSize">
<size>
- <width>100</width>
+ <width>110</width>
<height>0</height>
</size>
</property>
@@ -2034,7 +2034,7 @@ background:none;</string>
<widget class="QLabel" name="lblSensitivity_4">
<property name="minimumSize">
<size>
- <width>100</width>
+ <width>110</width>
<height>0</height>
</size>
</property>
diff --git a/FaceTrackNoIR/GeneratedFiles/ui_FaceTrackNoIR.h b/FaceTrackNoIR/GeneratedFiles/ui_FaceTrackNoIR.h
index 4a3a78b1..1f36d463 100644
--- a/FaceTrackNoIR/GeneratedFiles/ui_FaceTrackNoIR.h
+++ b/FaceTrackNoIR/GeneratedFiles/ui_FaceTrackNoIR.h
@@ -1,7 +1,7 @@
/********************************************************************************
** Form generated from reading UI file 'FaceTrackNoIR.ui'
**
-** Created: Fri 28. May 20:44:32 2010
+** Created: Tue 1. Jun 21:00:16 2010
** by: Qt User Interface Compiler version 4.6.2
**
** WARNING! All changes made in this file will be lost when recompiling UI file!
@@ -654,7 +654,7 @@ public:
gridLayout->setObjectName(QString::fromUtf8("gridLayout"));
lblSensitivity = new QLabel(bubbleBigWidget);
lblSensitivity->setObjectName(QString::fromUtf8("lblSensitivity"));
- lblSensitivity->setMinimumSize(QSize(100, 0));
+ lblSensitivity->setMinimumSize(QSize(110, 0));
lblSensitivity->setMaximumSize(QSize(150, 16777215));
lblSensitivity->setStyleSheet(QString::fromUtf8("color:#ccc;\n"
"background:none;"));
@@ -1023,7 +1023,7 @@ public:
lblSensitivity_4 = new QLabel(bubbleBigWidget);
lblSensitivity_4->setObjectName(QString::fromUtf8("lblSensitivity_4"));
- lblSensitivity_4->setMinimumSize(QSize(100, 0));
+ lblSensitivity_4->setMinimumSize(QSize(110, 0));
lblSensitivity_4->setMaximumSize(QSize(150, 16777215));
lblSensitivity_4->setStyleSheet(QString::fromUtf8("color:#ccc;\n"
"background:none;"));
diff --git a/FaceTrackNoIR/tracker.cpp b/FaceTrackNoIR/tracker.cpp
index 30247cd9..c22961bd 100644
--- a/FaceTrackNoIR/tracker.cpp
+++ b/FaceTrackNoIR/tracker.cpp
@@ -23,6 +23,8 @@
*********************************************************************************/
/*
Modifications (last one on top):
+ 20100601 - WVR: Added DirectInput keyboard-handling. '=' used for center,
+ 'BACK' for start (+center)/stop.
20100517 - WVR: Added upstream command(s) from FlightGear
20100523 - WVR: Checkboxes to invert 6DOF's was implemented. Multiply by
1 or (-1).
@@ -30,10 +32,6 @@
#include "tracker.h"
#include "FaceTrackNoIR.h"
-void initDInput(HINSTANCE hInstance, HWND hWnd); // sets up and initializes DirectInput
-void detect_input(void); // gets the current input state
-void cleanDInput(void); // closes DirectInput and releases memory
-
using namespace sm::faceapi;
using namespace sm::faceapi::qt;
@@ -45,8 +43,21 @@ float Tracker::initial_headPosZ = 0.0f;
float Tracker::headRotX = 0.0f;
float Tracker::headRotY = 0.0f;
float Tracker::headRotZ = 0.0f;
+
+// Offsets, to center headpos while tracking
+float Tracker::offset_headPosX = 0.0f;
+float Tracker::offset_headPosY = 0.0f;
+float Tracker::offset_headPosZ = 0.0f;
+
+float Tracker::offset_headRotX = 0.0f;
+float Tracker::offset_headRotY = 0.0f;
+float Tracker::offset_headRotZ = 0.0f;
+
+// Flags
bool Tracker::confid = false;
bool Tracker::set_initial = false;
+bool Tracker::do_tracking = true;
+bool Tracker::do_center = false;
float Tracker::sensYaw = 1.0f;
float Tracker::sensPitch = 1.0f;
@@ -62,6 +73,13 @@ float Tracker::invertX = 1.0f;
float Tracker::invertY = 1.0f;
float Tracker::invertZ = 1.0f;
+float Tracker::thresYaw = 1.0f;
+float Tracker::thresPitch = 1.0f;
+float Tracker::thresRoll = 1.0f;
+float Tracker::thresX = 1.0f;
+float Tracker::thresY = 1.0f;
+float Tracker::thresZ = 1.0f;
+
float Tracker::rotNeutralZone = 0.087f; // Neutral Zone for rotations (rad)
/** constructor empty **/
@@ -165,6 +183,22 @@ void Tracker::run() {
LPDIRECTINPUTDEVICE8 dinkeyboard; // the pointer to the keyboard device
BYTE keystate[256]; // the storage for the key-information
HRESULT retAcquire;
+ bool lastMinusKey = false; // Remember state, to detect rising edge
+ bool lastEqualsKey = false;
+
+ float prevYaw = 0.0f; // Remember previous Raw, to filter jitter
+ float prevPitch = 0.0f;
+ float prevRoll = 0.0f;
+ float prevX = 0.0f;
+ float prevY = 0.0f;
+ float prevZ = 0.0f;
+
+ float newYaw = 0.0f; // Local new Raw, to filter jitter
+ float newPitch = 0.0f;
+ float newRoll = 0.0f;
+ float newX = 0.0f;
+ float newY = 0.0f;
+ float newZ = 0.0f;
//
// Setup the DirectInput for keyboard strokes
@@ -174,33 +208,21 @@ void Tracker::run() {
(void**)&din, NULL) != DI_OK) { // COM stuff, so we'll set it to NULL
qDebug() << "Tracker::setup DirectInput8 Creation failed!" << GetLastError();
}
- else {
- qDebug() << "Tracker::setup DirectInput8 Creation OK!";
- }
// create the keyboard device
if (din->CreateDevice(GUID_SysKeyboard, &dinkeyboard, NULL) != DI_OK) {
qDebug() << "Tracker::setup CreateDevice function failed!" << GetLastError();
}
- else {
- qDebug() << "Tracker::setup CreateDevice function OK!";
- }
// set the data format to keyboard format
if (dinkeyboard->SetDataFormat(&c_dfDIKeyboard) != DI_OK) {
qDebug() << "Tracker::setup SetDataFormat function failed!" << GetLastError();
}
- else {
- qDebug() << "Tracker::setup SetDataFormat function OK!";
- }
// set the control you will have over the keyboard
if (dinkeyboard->SetCooperativeLevel(mainApp->winId(), DISCL_NONEXCLUSIVE | DISCL_BACKGROUND) != DI_OK) {
qDebug() << "Tracker::setup SetCooperativeLevel function failed!" << GetLastError();
}
- else {
- qDebug() << "Tracker::setup SetCooperativeLevel function OK!";
- }
forever
{
@@ -227,15 +249,32 @@ void Tracker::run() {
qDebug() << "Tracker::run GetDeviceState function failed!" << GetLastError();
}
else {
- qDebug() << "Tracker::run GetDeviceState function OK!";
- if(keystate[DIK_HOME] & 0x80) {
- qDebug() << "Tracker::run() says HOME pressed";
+ //
+ // Check the state of the MINUS key (= Start/Stop tracking) and EQUALS key (= Center)
+ //
+ if ( (keystate[DIK_BACK] & 0x80) && (!lastMinusKey) ) {
+ Tracker::do_tracking = !Tracker::do_tracking;
+
+ //
+ // To start tracking again and be '0', execute Center command too
+ //
+ if (Tracker::do_tracking) {
+ Tracker::do_center = true;
+ }
+ qDebug() << "Tracker::run() says BACK pressed, do_tracking =" << Tracker::do_tracking;
}
+ lastMinusKey = (keystate[DIK_BACK] & 0x80); // Remember
+
+ if ( (keystate[DIK_EQUALS] & 0x80) && (!lastEqualsKey) ) {
+ Tracker::do_center = true;
+ qDebug() << "Tracker::run() says EQUALS pressed";
+ }
+ lastEqualsKey = (keystate[DIK_EQUALS] & 0x80); // Remember
}
}
//if the confidence is good enough the headpose will be updated **/
- if(Tracker::confid) {
+ if (Tracker::confid) {
//
// Most games need an offset to the initial position and NOT the
@@ -268,30 +307,87 @@ void Tracker::run() {
// Add the raw values to the QList, so they can be smoothed.
// The raw value that enters the QList is first (evt.) inverted and corrected for Neutral Zone.
//
- addRaw2List ( &rawPitchList, intMaxPitchItems, getCorrectedNewRaw ( Tracker::invertPitch * Tracker::headRotX , Tracker::rotNeutralZone ) );
- addRaw2List ( &rawYawList, intMaxYawItems, getCorrectedNewRaw ( Tracker::invertYaw * Tracker::headRotY , Tracker::rotNeutralZone ) );
- addRaw2List ( &rawRollList, intMaxRollItems, getCorrectedNewRaw ( Tracker::invertRoll * Tracker::headRotZ , Tracker::rotNeutralZone ) );
+ newPitch = Tracker::headRotX;
+ if ( (fabs (newPitch - prevPitch) ) < Tracker::thresPitch ) { // delta smaller than threshold?
+ newPitch = prevPitch;
+ }
+ else {
+ prevPitch = newPitch;
+ }
+ addRaw2List ( &rawPitchList, intMaxPitchItems, getCorrectedNewRaw ( Tracker::invertPitch * newPitch , Tracker::rotNeutralZone ) );
+
+ newYaw = Tracker::headRotY;
+ if ( (fabs (newYaw - prevYaw) ) < Tracker::thresYaw ) { // delta smaller than threshold?
+ newYaw = prevYaw;
+ }
+ else {
+ prevYaw = newYaw;
+ }
+ addRaw2List ( &rawYawList, intMaxYawItems, getCorrectedNewRaw ( Tracker::invertYaw * newYaw, Tracker::rotNeutralZone ) );
+
+ newRoll = Tracker::headRotZ;
+ if ( (fabs (newRoll - prevRoll) ) < Tracker::thresRoll ) { // delta smaller than threshold?
+ newRoll = prevRoll;
+ }
+ else {
+ prevRoll = newRoll;
+ }
+ addRaw2List ( &rawRollList, intMaxRollItems, getCorrectedNewRaw ( Tracker::invertRoll * newRoll , Tracker::rotNeutralZone ) );
+
addRaw2List ( &rawXList, intMaxXItems, Tracker::invertX * Tracker::headPosX * 1000.0f );
addRaw2List ( &rawYList, intMaxYItems, Tracker::invertY * Tracker::headPosY * 1000.0f );
addRaw2List ( &rawZList, intMaxZItems, ( Tracker::invertZ * Tracker::headPosZ - Tracker::initial_headPosZ ) * 1000.0f );
}
//
- // Also send the Virtual Pose to FT-server
+ // If Center is pressed, copy the current values to the offsets.
//
- server_FT->setVirtRotX( Tracker::sensPitch * getSmoothFromList( &rawPitchList ) );
- server_FT->setVirtRotY( Tracker::sensYaw * getSmoothFromList( &rawYawList ) );
- server_FT->setVirtRotZ( Tracker::sensRoll * getSmoothFromList( &rawRollList ) );
- server_FT->setVirtPosX ( Tracker::sensX * getSmoothFromList( &rawXList ) );
- server_FT->setVirtPosY ( Tracker::sensY * getSmoothFromList( &rawYList ) );
- server_FT->setVirtPosZ ( Tracker::sensZ * getSmoothFromList( &rawZList ) );
-
- server_FG->setVirtRotX( getDegreesFromRads ( Tracker::sensPitch * getSmoothFromList( &rawPitchList ) ) );
- server_FG->setVirtRotY( getDegreesFromRads ( Tracker::sensYaw * getSmoothFromList( &rawYawList ) ) );
- server_FG->setVirtRotZ( getDegreesFromRads ( Tracker::sensRoll * getSmoothFromList( &rawRollList ) ) );
- server_FG->setVirtPosX ( ( Tracker::sensX * getSmoothFromList( &rawXList ) ) / 1000.0f );
- server_FG->setVirtPosY ( ( Tracker::sensY * getSmoothFromList( &rawYList ) ) / 1000.0f );
- server_FG->setVirtPosZ ( ( Tracker::sensZ * getSmoothFromList( &rawZList ) ) / 1000.0f );
+ if (Tracker::do_center) {
+ offset_headRotX = getSmoothFromList( &rawPitchList );
+ offset_headRotY = getSmoothFromList( &rawYawList );
+ offset_headRotZ = getSmoothFromList( &rawRollList );
+ offset_headPosX = getSmoothFromList( &rawXList );
+ offset_headPosY = getSmoothFromList( &rawYList );
+ offset_headPosZ = getSmoothFromList( &rawZList );
+ Tracker::do_center = false;
+ }
+
+ if (Tracker::do_tracking) {
+ //
+ // Also send the Virtual Pose to FT-server and FG-server
+ //
+ server_FT->setVirtRotX ( Tracker::sensPitch * getSmoothFromList( &rawPitchList ) - offset_headRotX );
+ server_FT->setVirtRotY ( Tracker::sensYaw * getSmoothFromList( &rawYawList ) - offset_headRotY );
+ server_FT->setVirtRotZ ( Tracker::sensRoll * getSmoothFromList( &rawRollList ) - offset_headRotZ );
+ server_FT->setVirtPosX ( Tracker::sensX * getSmoothFromList( &rawXList ) - offset_headPosX );
+ server_FT->setVirtPosY ( Tracker::sensY * getSmoothFromList( &rawYList ) - offset_headPosY );
+ server_FT->setVirtPosZ ( Tracker::sensZ * getSmoothFromList( &rawZList ) - offset_headPosZ );
+
+ server_FG->setVirtRotX ( getDegreesFromRads ( Tracker::sensPitch * getSmoothFromList( &rawPitchList ) - offset_headRotX ) );
+ server_FG->setVirtRotY ( getDegreesFromRads ( Tracker::sensYaw * getSmoothFromList( &rawYawList ) - offset_headRotY ) );
+ server_FG->setVirtRotZ ( getDegreesFromRads ( Tracker::sensRoll * getSmoothFromList( &rawRollList ) - offset_headRotZ ) );
+ server_FG->setVirtPosX ( ( Tracker::sensX * getSmoothFromList( &rawXList ) - offset_headPosX ) / 1000.0f );
+ server_FG->setVirtPosY ( ( Tracker::sensY * getSmoothFromList( &rawYList ) - offset_headPosY ) / 1000.0f );
+ server_FG->setVirtPosZ ( ( Tracker::sensZ * getSmoothFromList( &rawZList ) - offset_headPosZ ) / 1000.0f );
+ }
+ else {
+ //
+ // Go to initial position
+ //
+ server_FT->setVirtRotX ( 0.0f );
+ server_FT->setVirtRotY ( 0.0f );
+ server_FT->setVirtRotZ ( 0.0f );
+ server_FT->setVirtPosX ( 0.0f );
+ server_FT->setVirtPosY ( 0.0f );
+ server_FT->setVirtPosZ ( 0.0f );
+
+ server_FG->setVirtRotX( 0.0f );
+ server_FG->setVirtRotY( 0.0f );
+ server_FG->setVirtRotZ( 0.0f );
+ server_FG->setVirtPosX ( 0.0f );
+ server_FG->setVirtPosY ( 0.0f );
+ server_FG->setVirtPosZ ( 0.0f );
+ }
//for lower cpu load
msleep(50);
diff --git a/FaceTrackNoIR/tracker.h b/FaceTrackNoIR/tracker.h
index a5126818..0103e8f2 100644
--- a/FaceTrackNoIR/tracker.h
+++ b/FaceTrackNoIR/tracker.h
@@ -39,8 +39,6 @@
#include "FGServer.h" // FlightGear-server
// include the DirectX Library files
-//#pragma comment (lib, "d3d9.lib")
-//#pragma comment (lib, "d3dx9.lib")
#pragma comment (lib, "dinput8.lib")
#pragma comment (lib, "dxguid.lib")
@@ -75,8 +73,21 @@ private:
static float headRotX;
static float headRotY;
static float headRotZ;
+
+ // Offsets, used to center view while tracking
+ static float offset_headPosX;
+ static float offset_headPosY;
+ static float offset_headPosZ; // Distance from camera
+
+ static float offset_headRotX;
+ static float offset_headRotY;
+ static float offset_headRotZ;
+
+ // Flags to start/stop/reset tracking
static bool confid;
static bool set_initial; // initial headpose is set
+ static bool do_tracking; // Start/stop tracking, using MINUS key on keyboard
+ static bool do_center; // Center head-position, using EQUALS key on keyboard
/** static member varables for calculating the virtual head pose **/
static float sensYaw;
@@ -93,6 +104,14 @@ private:
static float invertY;
static float invertZ;
+ /** Thresholds to remove jitter **/
+ static float thresYaw;
+ static float thresPitch;
+ static float thresRoll;
+ static float thresX;
+ static float thresY;
+ static float thresZ;
+
static float rotNeutralZone; // Neutral Zone for rotations (rad).
//
@@ -177,6 +196,13 @@ public:
static void setInvertY(bool invert) { invertY = invert?-1.0f:+1.0f; }
static void setInvertZ(bool invert) { invertZ = invert?-1.0f:+1.0f; }
+ static void setThresYaw(int x) { thresYaw = x/100.0f; }
+ static void setThresPitch(int x) { thresPitch = x/100.0f; }
+ static void setThresRoll(int x) { thresRoll = x/100.0f; }
+ static void setThresX(int x) { thresX = x/100.0f; }
+ static void setThresY(int x) { thresY = x/100.0f; }
+ static void setThresZ(int x) { thresZ = x/100.0f; }
+
static void setNeutralZone(int x) { rotNeutralZone = (x * 2.0f * 3.14159)/360.0f; }
void addRaw2List ( QList<float> *rawList, float maxIndex, float raw );