summaryrefslogtreecommitdiffhomepage
path: root/FaceTrackNoIR
diff options
context:
space:
mode:
Diffstat (limited to 'FaceTrackNoIR')
-rw-r--r--FaceTrackNoIR/FaceTrackNoIR.cpp42
-rw-r--r--FaceTrackNoIR/FaceTrackNoIR.h10
-rw-r--r--FaceTrackNoIR/tracker.cpp69
-rw-r--r--FaceTrackNoIR/tracker.h3
4 files changed, 115 insertions, 9 deletions
diff --git a/FaceTrackNoIR/FaceTrackNoIR.cpp b/FaceTrackNoIR/FaceTrackNoIR.cpp
index 895e6aac..d3511c16 100644
--- a/FaceTrackNoIR/FaceTrackNoIR.cpp
+++ b/FaceTrackNoIR/FaceTrackNoIR.cpp
@@ -176,6 +176,15 @@ void FaceTrackNoIR::getGameProgramName() {
}
}
+//
+// Get the ProgramName from a connected game and display it.
+//
+void FaceTrackNoIR::updateSettings() {
+ if ( tracker != NULL ) {
+ tracker->loadSettings();
+ }
+}
+
/** read the name of the first video-capturing device at start up **/
/** FaceAPI can only use this first one... **/
void FaceTrackNoIR::GetCameraNameDX() {
@@ -705,7 +714,7 @@ void FaceTrackNoIR::showPreferences() {
// Create if new
if (!_preferences)
{
- _preferences = new PreferencesDialog( this, Qt::Dialog );
+ _preferences = new PreferencesDialog( this, this, Qt::Dialog );
}
// Show if already created
@@ -721,7 +730,7 @@ void FaceTrackNoIR::showKeyboardShortcuts() {
// Create if new
if (!_keyboard_shortcuts)
{
- _keyboard_shortcuts = new KeyboardShortcutDialog( this, Qt::Dialog );
+ _keyboard_shortcuts = new KeyboardShortcutDialog( this, this, Qt::Dialog );
}
// Show if already created
@@ -737,7 +746,7 @@ void FaceTrackNoIR::showCurveConfiguration() {
// Create if new
if (!_curve_config)
{
- _curve_config = new CurveConfigurationDialog( this, Qt::Dialog );
+ _curve_config = new CurveConfigurationDialog( this, this, Qt::Dialog );
}
// Show if already created
@@ -884,7 +893,7 @@ void FaceTrackNoIR::trackingSourceSelected(int index)
//
// Constructor for FaceTrackNoIR=Preferences-dialog
//
-PreferencesDialog::PreferencesDialog( QWidget *parent, Qt::WindowFlags f ) :
+PreferencesDialog::PreferencesDialog( FaceTrackNoIR *ftnoir, QWidget *parent, Qt::WindowFlags f ) :
QWidget( parent , f)
{
ui.setupUi( this );
@@ -892,6 +901,8 @@ QWidget( parent , f)
QPoint offsetpos(100, 100);
this->move(parent->pos() + offsetpos);
+ mainApp = ftnoir; // Preserve a pointer to FTNoIR
+
// Connect Qt signals to member-functions
connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK()));
connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel()));
@@ -975,6 +986,11 @@ void PreferencesDialog::save() {
QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // Registry settings (in HK_USER)
settings.setValue( "AutoMinimizeTime", ui.slideAutoMinimizeTime->value() );
+ //
+ // Send a message to the main program, to update the Settings (for the tracker)
+ //
+ mainApp->updateSettings();
+
settingsDirty = false;
}
@@ -983,7 +999,7 @@ void PreferencesDialog::save() {
//
// Constructor for Keyboard-shortcuts-dialog
//
-KeyboardShortcutDialog::KeyboardShortcutDialog( QWidget *parent, Qt::WindowFlags f ) :
+KeyboardShortcutDialog::KeyboardShortcutDialog( FaceTrackNoIR *ftnoir, QWidget *parent, Qt::WindowFlags f ) :
QWidget( parent , f)
{
ui.setupUi( this );
@@ -991,6 +1007,8 @@ QWidget( parent , f)
QPoint offsetpos(100, 100);
this->move(parent->pos() + offsetpos);
+ mainApp = ftnoir; // Preserve a pointer to FTNoIR
+
// Connect Qt signals to member-functions
connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK()));
connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel()));
@@ -1273,6 +1291,11 @@ void KeyboardShortcutDialog::save() {
iniFile.endGroup ();
settingsDirty = false;
+
+ //
+ // Send a message to the main program, to update the Settings (for the tracker)
+ //
+ mainApp->updateSettings();
}
//**************************************************************************************************//
@@ -1280,7 +1303,7 @@ void KeyboardShortcutDialog::save() {
//
// Constructor for Curve-configuration-dialog
//
-CurveConfigurationDialog::CurveConfigurationDialog( QWidget *parent, Qt::WindowFlags f ) :
+CurveConfigurationDialog::CurveConfigurationDialog( FaceTrackNoIR *ftnoir, QWidget *parent, Qt::WindowFlags f ) :
QWidget( parent , f)
{
ui.setupUi( this );
@@ -1288,6 +1311,8 @@ QWidget( parent , f)
QPoint offsetpos(100, 100);
this->move(parent->pos() + offsetpos);
+ mainApp = ftnoir; // Preserve a pointer to FTNoIR
+
// Connect Qt signals to member-functions
connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK()));
connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel()));
@@ -1471,6 +1496,11 @@ void CurveConfigurationDialog::save() {
iniFile.endGroup ();
settingsDirty = false;
+
+ //
+ // Send a message to the main program, to update the Settings (for the tracker)
+ //
+ mainApp->updateSettings();
}
void getCurvePoints(QSettings *iniFile, QString prefix, QPointF *point1, QPointF *point2, QPointF *point3, QPointF *point4, int NeutralZone, int Sensitivity, int MaxInput, int MaxOutput) {
diff --git a/FaceTrackNoIR/FaceTrackNoIR.h b/FaceTrackNoIR/FaceTrackNoIR.h
index 410547e2..c14d4e16 100644
--- a/FaceTrackNoIR/FaceTrackNoIR.h
+++ b/FaceTrackNoIR/FaceTrackNoIR.h
@@ -58,6 +58,7 @@ public:
~FaceTrackNoIR();
void getGameProgramName(); // Get the ProgramName from the game and display it.
+ void updateSettings(); // Update the settings (let Tracker read INI-file).
private:
Ui::FaceTrackNoIRClass ui;
@@ -158,7 +159,7 @@ class PreferencesDialog: public QWidget, public Ui::UICPreferencesDialog
Q_OBJECT
public:
- explicit PreferencesDialog( QWidget *parent=0, Qt::WindowFlags f=0 );
+ explicit PreferencesDialog( FaceTrackNoIR *ftnoir, QWidget *parent=0, Qt::WindowFlags f=0 );
virtual ~PreferencesDialog();
void showEvent ( QShowEvent * event );
@@ -169,6 +170,7 @@ private:
/** helper **/
bool settingsDirty;
+ FaceTrackNoIR *mainApp;
private slots:
void doOK();
@@ -182,7 +184,7 @@ class KeyboardShortcutDialog: public QWidget, public Ui::UICKeyboardShortcutDial
Q_OBJECT
public:
- explicit KeyboardShortcutDialog( QWidget *parent=0, Qt::WindowFlags f=0 );
+ explicit KeyboardShortcutDialog( FaceTrackNoIR *ftnoir, QWidget *parent=0, Qt::WindowFlags f=0 );
virtual ~KeyboardShortcutDialog();
void showEvent ( QShowEvent * event );
@@ -193,6 +195,7 @@ private:
/** helper **/
bool settingsDirty;
+ FaceTrackNoIR *mainApp;
QList<QString> stringList; // List of strings, that describe the keyboard-keys
QList<BYTE> keyList; // List of keys, with the values of the keyboard-keys
@@ -208,7 +211,7 @@ class CurveConfigurationDialog: public QWidget, public Ui::UICCurveConfiguration
Q_OBJECT
public:
- explicit CurveConfigurationDialog( QWidget *parent=0, Qt::WindowFlags f=0 );
+ explicit CurveConfigurationDialog( FaceTrackNoIR *ftnoir, QWidget *parent=0, Qt::WindowFlags f=0 );
virtual ~CurveConfigurationDialog();
void showEvent ( QShowEvent * event );
@@ -219,6 +222,7 @@ private:
/** helper **/
bool settingsDirty;
+ FaceTrackNoIR *mainApp;
private slots:
void doOK();
diff --git a/FaceTrackNoIR/tracker.cpp b/FaceTrackNoIR/tracker.cpp
index c7a2fadb..ce928d66 100644
--- a/FaceTrackNoIR/tracker.cpp
+++ b/FaceTrackNoIR/tracker.cpp
@@ -432,6 +432,12 @@ void Tracker::run() {
Pitch.newPos = getSmoothFromList( &Pitch.rawList ) - Pitch.offset_headPos;
}
+ QFile data("output.txt");
+ if (data.open(QFile::WriteOnly | QFile::Append)) {
+ QTextStream out(&data);
+ out << "Input = " << getDegreesFromRads(Pitch.newPos) << " Output = " << getOutputFromCurve(&Pitch.curve, getDegreesFromRads(Pitch.newPos)) << '\n';
+ }
+
// Yaw
if (Tracker::useFilter) {
Yaw.newPos = lowPassFilter ( getSmoothFromList( &Yaw.rawList ) - Yaw.offset_headPos,
@@ -765,9 +771,20 @@ float clamped_value = 0.0f;
}
//
+// Get the output from the curve.
+//
+float Tracker::getOutputFromCurve ( QPainterPath *curve, float input ) {
+ return curve->pointAtPercent(input/100.0f).x();
+}
+
+//
// Load the current Settings from the currently 'active' INI-file.
//
void Tracker::loadSettings() {
+int NeutralZone;
+int sensYaw, sensPitch, sensRoll;
+int sensX, sensY, sensZ;
+QPointF point1, point2, point3, point4;
qDebug() << "Tracker::loadSettings says: Starting ";
QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // Registry settings (in HK_USER)
@@ -777,6 +794,58 @@ void Tracker::loadSettings() {
qDebug() << "loadSettings says: iniFile = " << currentFile;
+ //
+ // Read the Tracking settings, to fill the curves.
+ //
+ iniFile.beginGroup ( "Tracking" );
+ NeutralZone = iniFile.value ( "NeutralZone", 5 ).toInt();
+ sensYaw = iniFile.value ( "sensYaw", 100 ).toInt();
+ sensPitch = iniFile.value ( "sensPitch", 100 ).toInt();
+ sensRoll = iniFile.value ( "sensRoll", 100 ).toInt();
+ sensX = iniFile.value ( "sensX", 100 ).toInt();
+ sensY = iniFile.value ( "sensY", 100 ).toInt();
+ sensZ = iniFile.value ( "sensZ", 100 ).toInt();
+ iniFile.endGroup ();
+
+ //
+ // Read the curve-settings from the file. Use the (deprecated) settings, if the curves are not there.
+ //
+ iniFile.beginGroup ( "Curves" );
+ getCurvePoints( &iniFile, "Yaw_", &point1, &point2, &point3, &point4, NeutralZone, sensYaw, 50, 180 );
+ Yaw.curve.moveTo( QPointF(0,0) );
+ Yaw.curve.lineTo(point1);
+ Yaw.curve.cubicTo(point2, point3, point4);
+
+ getCurvePoints( &iniFile, "Pitch_", &point1, &point2, &point3, &point4, NeutralZone, sensPitch, 50, 180 );
+ Pitch.curve.moveTo( QPointF(0,0) );
+ Pitch.curve.lineTo(point1);
+ Pitch.curve.cubicTo(point2, point3, point4);
+
+ getCurvePoints( &iniFile, "Roll_", &point1, &point2, &point3, &point4, NeutralZone, sensRoll, 50, 180 );
+ Roll.curve.moveTo( QPointF(0,0) );
+ Roll.curve.lineTo(point1);
+ Roll.curve.cubicTo(point2, point3, point4);
+
+ getCurvePoints( &iniFile, "X_", &point1, &point2, &point3, &point4, NeutralZone, sensX, 50, 180 );
+ X.curve.moveTo( QPointF(0,0) );
+ X.curve.lineTo(point1);
+ X.curve.cubicTo(point2, point3, point4);
+
+ getCurvePoints( &iniFile, "Y_", &point1, &point2, &point3, &point4, NeutralZone, sensY, 50, 180 );
+ Y.curve.moveTo( QPointF(0,0) );
+ Y.curve.lineTo(point1);
+ Y.curve.cubicTo(point2, point3, point4);
+
+ getCurvePoints( &iniFile, "Z_", &point1, &point2, &point3, &point4, NeutralZone, sensZ, 50, 180 );
+ Z.curve.moveTo( QPointF(0,0) );
+ Z.curve.lineTo(point1);
+ Z.curve.cubicTo(point2, point3, point4);
+
+ iniFile.endGroup ();
+
+ //
+ // Read the keyboard shortcuts.
+ //
iniFile.beginGroup ( "KB_Shortcuts" );
// Center key
diff --git a/FaceTrackNoIR/tracker.h b/FaceTrackNoIR/tracker.h
index 0b0abe7f..51d83f41 100644
--- a/FaceTrackNoIR/tracker.h
+++ b/FaceTrackNoIR/tracker.h
@@ -31,6 +31,7 @@
#include <QPoint>
#include <QWaitCondition>
#include <QList>
+#include <QPainterPath>
#define DIRECTINPUT_VERSION 0x0800
#include <Dinput.h>
@@ -81,6 +82,7 @@ struct THeadPoseDOF {
float newPos; // New Position (used locally)
float prevPos; // Previous Position
float prevRawPos; // Previous Raw Position
+ QPainterPath curve; // Bezier curve to translate input -> output
};
//
@@ -217,6 +219,7 @@ public:
float getSmoothFromList ( QList<float> *rawList );
float getDegreesFromRads ( float rads ) { return (rads * 57.295781f); }
+ float getOutputFromCurve ( QPainterPath *curve, float input );
// For now, use one slider for all
void setSmoothing(int x) {