From 63ce1b5dc62e5c1a079f8a675c0a4371adb27d29 Mon Sep 17 00:00:00 2001 From: Wim Vriend Date: Sat, 12 Feb 2011 16:13:30 +0000 Subject: Displaying headpose-data seemed to cause crashes. Update is now done in FaceTrackNoIR.cpp, using a timer. git-svn-id: svn+ssh://svn.code.sf.net/p/facetracknoir/code@51 19e81ba0-9b1a-49c3-bd6c-561e1906d5fb --- FTNoIR_Tracker_UDP/FTNoIR_FTNClientControls.ui | 199 +++++++++++++ FTNoIR_Tracker_UDP/FTNoIR_Tracker_UDP.h | 80 ++++++ FTNoIR_Tracker_UDP/FTNoIR_Tracker_UDP.vcproj | 114 ++++++++ FTNoIR_Tracker_UDP/ftnoir_tracker_base.h | 26 +- FTNoIR_Tracker_UDP/ftnoir_tracker_udp.cpp | 261 ++++++++++++----- FaceTrackNoIR.suo | Bin 347136 -> 347136 bytes FaceTrackNoIR/FTNoIR_FGcontrols.ui | 8 +- FaceTrackNoIR/FaceTrackNoIR.cpp | 19 ++ FaceTrackNoIR/FaceTrackNoIR.h | 6 +- FaceTrackNoIR/FaceTrackNoIR.ui | 384 +++++++++++-------------- FaceTrackNoIR/tracker.cpp | 79 ++--- FaceTrackNoIR/tracker.h | 12 +- bin/FaceTrackNoIR.exe | Bin 761856 -> 761856 bytes bin/Settings/FlightGear.ini | 6 +- bin/Settings/SimConnect.ini | 10 +- 15 files changed, 872 insertions(+), 332 deletions(-) create mode 100644 FTNoIR_Tracker_UDP/FTNoIR_FTNClientControls.ui create mode 100644 FTNoIR_Tracker_UDP/FTNoIR_Tracker_UDP.h diff --git a/FTNoIR_Tracker_UDP/FTNoIR_FTNClientControls.ui b/FTNoIR_Tracker_UDP/FTNoIR_FTNClientControls.ui new file mode 100644 index 00000000..11e07cf3 --- /dev/null +++ b/FTNoIR_Tracker_UDP/FTNoIR_FTNClientControls.ui @@ -0,0 +1,199 @@ + + + UICFTNClientControls + + + + 0 + 0 + 411 + 129 + + + + FTNoIR tracker settings FaceTrackNoIR + + + + images/FaceTrackNoIR.icoimages/FaceTrackNoIR.ico + + + Qt::LeftToRight + + + false + + + + + + + + Port-number + + + + + + + 5550 + + + 10000 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + Enter the port-number for the remote PC. + + + true + + + + + + + Remember: you may have to change firewall-settings too! + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + QLayout::SetDefaultConstraint + + + + + + 0 + 0 + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + OK + + + + + + + + 0 + 0 + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + Cancel + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 10 + 20 + + + + + + + + + + spinPortNumber + btnOK + btnCancel + + + + + startEngineClicked() + stopEngineClicked() + cameraSettingsClicked() + + diff --git a/FTNoIR_Tracker_UDP/FTNoIR_Tracker_UDP.h b/FTNoIR_Tracker_UDP/FTNoIR_Tracker_UDP.h new file mode 100644 index 00000000..b3467341 --- /dev/null +++ b/FTNoIR_Tracker_UDP/FTNoIR_Tracker_UDP.h @@ -0,0 +1,80 @@ +#include "ftnoir_tracker_base.h" +#include "ui_FTNoIR_FTNClientcontrols.h" +#include +#include +#include +#include +#include "Windows.h" +#include "math.h" + +class FTNoIR_Tracker_UDP : public ITracker, QThread +{ +public: + FTNoIR_Tracker_UDP(); + ~FTNoIR_Tracker_UDP(); + + void Release(); + void Initialize(); + void StartTracker(); + void GiveHeadPoseData(THeadPoseData *data); + void loadSettings(); + + bool setParameterValue(const int index, const float newvalue); + +protected: + void run(); // qthread override run method + +private: + // Handles to neatly terminate thread... + HANDLE m_StopThread; + HANDLE m_WaitThread; + + // UDP socket-variables + QUdpSocket *inSocket; // Receive from ... + QUdpSocket *outSocket; // Send to ... + QHostAddress destIP; // Destination IP-address + int destPort; // Destination port-number + QHostAddress srcIP; // Source IP-address + int srcPort; // Source port-number + + THeadPoseData newHeadPose; // Structure with new headpose + + //parameter list for the filter-function(s) + enum + { + kPortAddress=0, // Index in QList + kNumFilterParameters // Indicate number of parameters used + }; + QList> parameterRange; + QList parameterValueAsFloat; + +}; + +// Widget that has controls for FTNoIR protocol client-settings. +class FTNClientControls: public QWidget, Ui::UICFTNClientControls, public ITrackerDialog +{ + Q_OBJECT +public: + + explicit FTNClientControls( QWidget *parent=0, Qt::WindowFlags f=0 ); + virtual ~FTNClientControls(); + void showEvent ( QShowEvent * event ); + + void Release(); // Member functions which are accessible from outside the DLL + void Initialize(QWidget *parent); + +private: + Ui::UICFTNClientControls ui; + void loadSettings(); + void save(); + + /** helper **/ + bool settingsDirty; + +private slots: + void doOK(); + void doCancel(); + void settingChanged() { settingsDirty = true; }; +}; + + diff --git a/FTNoIR_Tracker_UDP/FTNoIR_Tracker_UDP.vcproj b/FTNoIR_Tracker_UDP/FTNoIR_Tracker_UDP.vcproj index 55e6d66b..ae299ed2 100644 --- a/FTNoIR_Tracker_UDP/FTNoIR_Tracker_UDP.vcproj +++ b/FTNoIR_Tracker_UDP/FTNoIR_Tracker_UDP.vcproj @@ -180,17 +180,91 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/FTNoIR_Tracker_UDP/ftnoir_tracker_base.h b/FTNoIR_Tracker_UDP/ftnoir_tracker_base.h index 60f0caf3..f39a8b4d 100644 --- a/FTNoIR_Tracker_UDP/ftnoir_tracker_base.h +++ b/FTNoIR_Tracker_UDP/ftnoir_tracker_base.h @@ -2,6 +2,7 @@ #define FTNOIR_TRACKER_BASE_H #include "ftnoir_tracker_base_global.h" +#include // // x,y,z position in centimetres, yaw, pitch and roll in degrees... @@ -19,7 +20,7 @@ struct THeadPoseData { // Instances are obtained via factory function. struct ITracker { - virtual void Release() = 0; + virtual void Release() = 0; // Member required to enable Auto-remove virtual void Initialize() = 0; virtual void StartTracker() = 0; virtual void GiveHeadPoseData(THeadPoseData *data) = 0; @@ -44,4 +45,27 @@ __stdcall GetTracker( void); + +// COM-Like abstract interface. +// This interface doesn't require __declspec(dllexport/dllimport) specifier. +// Method calls are dispatched via virtual table. +// Any C++ compiler can use it. +// Instances are obtained via factory function. +struct ITrackerDialog +{ + virtual void Release() = 0; // Member required to enable Auto-remove + virtual void Initialize(QWidget *parent) = 0; +}; + +// Handle type. In C++ language the iterface type is used. +typedef ITrackerDialog* TRACKERDIALOGHANDLE; + +// Factory function that creates instances of the Tracker object. +EXTERN_C +FTNOIR_TRACKER_BASE_EXPORT +TRACKERDIALOGHANDLE +__stdcall +GetTrackerDialog(void); + + #endif // FTNOIR_TRACKER_BASE_H diff --git a/FTNoIR_Tracker_UDP/ftnoir_tracker_udp.cpp b/FTNoIR_Tracker_UDP/ftnoir_tracker_udp.cpp index 9dfb26a7..93ef60b6 100644 --- a/FTNoIR_Tracker_UDP/ftnoir_tracker_udp.cpp +++ b/FTNoIR_Tracker_UDP/ftnoir_tracker_udp.cpp @@ -1,51 +1,4 @@ -#include "ftnoir_tracker_base.h" -#include -#include -#include -#include "Windows.h" -#include "math.h" - -class FTNoIR_Tracker_UDP : public ITracker, QThread -{ -public: - FTNoIR_Tracker_UDP(); - ~FTNoIR_Tracker_UDP(); - - void Release(); - void Initialize(); - void StartTracker(); - void GiveHeadPoseData(THeadPoseData *data); - - bool setParameterValue(const int index, const float newvalue); - -protected: - void run(); // qthread override run method - -private: - // Handles to neatly terminate thread... - HANDLE m_StopThread; - HANDLE m_WaitThread; - - // UDP socket-variables - QUdpSocket *inSocket; // Receive from ... - QUdpSocket *outSocket; // Send to ... - QHostAddress destIP; // Destination IP-address - int destPort; // Destination port-number - QHostAddress srcIP; // Source IP-address - int srcPort; // Source port-number - - THeadPoseData newHeadPose; // Structure with new headpose - - //parameter list for the filter-function(s) - enum - { - kPortAddress=0, // Index in QList - kNumFilterParameters // Indicate number of parameters used - }; - QList> parameterRange; - QList parameterValueAsFloat; - -}; +#include "ftnoir_tracker_udp.h" FTNoIR_Tracker_UDP::FTNoIR_Tracker_UDP() { @@ -71,23 +24,6 @@ FTNoIR_Tracker_UDP::FTNoIR_Tracker_UDP() newHeadPose.yaw = 0.0f; newHeadPose.pitch = 0.0f; newHeadPose.roll = 0.0f; - - // - // Create UDP-sockets if they don't exist already. - // They must be created here, because they must be in the new thread (FTNoIR_Tracker_UDP::run()) - // - if (inSocket == 0) { - qDebug() << "FTNoIR_Tracker_UDP::run() creating insocket"; - inSocket = new QUdpSocket(); - // Connect the inSocket to the port, to receive messages - - if (!inSocket->bind(QHostAddress::Any, (int) parameterValueAsFloat[kPortAddress], QUdpSocket::ShareAddress )) { - QMessageBox::warning(0,"FaceTrackNoIR Error", "Unable to bind UDP-port",QMessageBox::Ok,QMessageBox::NoButton); - delete inSocket; - inSocket = 0; - } - } - } FTNoIR_Tracker_UDP::~FTNoIR_Tracker_UDP() @@ -163,6 +99,25 @@ void FTNoIR_Tracker_UDP::Release() void FTNoIR_Tracker_UDP::Initialize() { + qDebug() << "FTNoIR_Tracker_UDP::Initialize says: Starting "; + loadSettings(); + + // + // Create UDP-sockets if they don't exist already. + // They must be created here, because they must be in the new thread (FTNoIR_Tracker_UDP::run()) + // + if (inSocket == 0) { + qDebug() << "FTNoIR_Tracker_UDP::Initialize() creating insocket"; + inSocket = new QUdpSocket(); + // Connect the inSocket to the port, to receive messages + + if (!inSocket->bind(QHostAddress::Any, (int) parameterValueAsFloat[kPortAddress], QUdpSocket::ShareAddress )) { + QMessageBox::warning(0,"FaceTrackNoIR Error", "Unable to bind UDP-port",QMessageBox::Ok,QMessageBox::NoButton); + delete inSocket; + inSocket = 0; + } + } + return; } @@ -211,6 +166,24 @@ bool FTNoIR_Tracker_UDP::setParameterValue(const int index, const float newvalue } }; +// +// Load the current Settings from the currently 'active' INI-file. +// +void FTNoIR_Tracker_UDP::loadSettings() { + + qDebug() << "FTNoIR_Tracker_UDP::loadSettings says: Starting "; + QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // Registry settings (in HK_USER) + + QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) + + qDebug() << "FTNoIR_Tracker_UDP::loadSettings says: iniFile = " << currentFile; + + iniFile.beginGroup ( "FTNClient" ); + setParameterValue(kPortAddress, (float) iniFile.value ( "PortNumber", 5550 ).toInt()); + iniFile.endGroup (); +} + //////////////////////////////////////////////////////////////////////////////// // Factory function that creates instances if the Tracker object. @@ -226,3 +199,161 @@ FTNOIR_TRACKER_BASE_EXPORT TRACKERHANDLE __stdcall GetTracker() return new FTNoIR_Tracker_UDP; } +//******************************************************************************************************* +// FaceTrackNoIR Client Settings-dialog. +//******************************************************************************************************* + +// +// Constructor for server-settings-dialog +// +FTNClientControls::FTNClientControls( QWidget *parent, Qt::WindowFlags f ) : +QWidget( parent , f) +{ + ui.setupUi( this ); + + QPoint offsetpos(100, 100); + if (parent) { + this->move(parent->pos() + offsetpos); + } + + // Connect Qt signals to member-functions + connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); + connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); + //connect(ui.spinIPFirstNibble, SIGNAL(valueChanged(int)), this, SLOT(settingChanged())); + //connect(ui.spinIPSecondNibble, SIGNAL(valueChanged(int)), this, SLOT(settingChanged())); + //connect(ui.spinIPThirdNibble, SIGNAL(valueChanged(int)), this, SLOT(settingChanged())); + //connect(ui.spinIPFourthNibble, SIGNAL(valueChanged(int)), this, SLOT(settingChanged())); + connect(ui.spinPortNumber, SIGNAL(valueChanged(int)), this, SLOT(settingChanged())); + + // Load the settings from the current .INI-file + loadSettings(); +} + +// +// Destructor for server-dialog +// +FTNClientControls::~FTNClientControls() { + qDebug() << "~FTNClientControls() says: started"; +} + +void FTNClientControls::Release() +{ + delete this; +} + +// +// Initialize tracker-client-dialog +// +void FTNClientControls::Initialize(QWidget *parent) { + + QPoint offsetpos(100, 100); + if (parent) { + this->move(parent->pos() + offsetpos); + } + show(); +} + +// +// OK clicked on server-dialog +// +void FTNClientControls::doOK() { + save(); + this->close(); +} + +// override show event +void FTNClientControls::showEvent ( QShowEvent * event ) { + loadSettings(); +} + +// +// Cancel clicked on server-dialog +// +void FTNClientControls::doCancel() { + // + // Ask if changed Settings should be saved + // + if (settingsDirty) { + int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard ); + + qDebug() << "doCancel says: answer =" << ret; + + switch (ret) { + case QMessageBox::Save: + save(); + this->close(); + break; + case QMessageBox::Discard: + this->close(); + break; + case QMessageBox::Cancel: + // Cancel was clicked + break; + default: + // should never be reached + break; + } + } + else { + this->close(); + } +} + +// +// Load the current Settings from the currently 'active' INI-file. +// +void FTNClientControls::loadSettings() { + +// qDebug() << "loadSettings says: Starting "; + QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // Registry settings (in HK_USER) + + QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) + +// qDebug() << "loadSettings says: iniFile = " << currentFile; + + iniFile.beginGroup ( "FTNClient" ); + //ui.spinIPFirstNibble->setValue( iniFile.value ( "IP-1", 192 ).toInt() ); + //ui.spinIPSecondNibble->setValue( iniFile.value ( "IP-2", 168 ).toInt() ); + //ui.spinIPThirdNibble->setValue( iniFile.value ( "IP-3", 2 ).toInt() ); + //ui.spinIPFourthNibble->setValue( iniFile.value ( "IP-4", 1 ).toInt() ); + + ui.spinPortNumber->setValue( iniFile.value ( "PortNumber", 5550 ).toInt() ); + iniFile.endGroup (); + + settingsDirty = false; +} + +// +// Save the current Settings to the currently 'active' INI-file. +// +void FTNClientControls::save() { + + QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // Registry settings (in HK_USER) + + QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) + + iniFile.beginGroup ( "FTNClient" ); + //iniFile.setValue ( "IP-1", ui.spinIPFirstNibble->value() ); + //iniFile.setValue ( "IP-2", ui.spinIPSecondNibble->value() ); + //iniFile.setValue ( "IP-3", ui.spinIPThirdNibble->value() ); + //iniFile.setValue ( "IP-4", ui.spinIPFourthNibble->value() ); + iniFile.setValue ( "PortNumber", ui.spinPortNumber->value() ); + iniFile.endGroup (); + + settingsDirty = false; +} +//////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Tracker-settings dialog object. + +// Export both decorated and undecorated names. +// GetTrackerDialog - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetTrackerDialog@0 - Common name decoration for __stdcall functions in C language. +#pragma comment(linker, "/export:GetTrackerDialog=_GetTrackerDialog@0") + +FTNOIR_TRACKER_BASE_EXPORT TRACKERDIALOGHANDLE __stdcall GetTrackerDialog( ) +{ + return new FTNClientControls; +} diff --git a/FaceTrackNoIR.suo b/FaceTrackNoIR.suo index 2d013289..006a6e0c 100644 Binary files a/FaceTrackNoIR.suo and b/FaceTrackNoIR.suo differ diff --git a/FaceTrackNoIR/FTNoIR_FGcontrols.ui b/FaceTrackNoIR/FTNoIR_FGcontrols.ui index 5f5d1563..c5f81c29 100644 --- a/FaceTrackNoIR/FTNoIR_FGcontrols.ui +++ b/FaceTrackNoIR/FTNoIR_FGcontrols.ui @@ -38,7 +38,7 @@ 255 - 5 + 1 @@ -54,7 +54,7 @@ 255 - 5 + 1 @@ -70,7 +70,7 @@ 255 - 5 + 1 @@ -86,7 +86,7 @@ 255 - 5 + 1 diff --git a/FaceTrackNoIR/FaceTrackNoIR.cpp b/FaceTrackNoIR/FaceTrackNoIR.cpp index e9a0c8be..7197a5f7 100644 --- a/FaceTrackNoIR/FaceTrackNoIR.cpp +++ b/FaceTrackNoIR/FaceTrackNoIR.cpp @@ -147,6 +147,11 @@ void FaceTrackNoIR::setupFaceTrackNoIR() { //Setup the timer for automatically minimizing after StartTracker. timMinimizeFTN = new QTimer(this); connect(timMinimizeFTN, SIGNAL(timeout()), this, SLOT(showMinimized())); + + //Setup the timer for showing the headpose. + timUpdateHeadPose = new QTimer(this); + connect(timUpdateHeadPose, SIGNAL(timeout()), this, SLOT(showHeadPose())); + timUpdateHeadPose->start(10); } /** destructor stops the engine and quits the faceapi **/ @@ -654,6 +659,20 @@ void FaceTrackNoIR::setUseFilter( int set ) { settingsDirty = true; } +/** Show the headpose in the widget (triggered by timer) **/ +void FaceTrackNoIR::showHeadPose() { +THeadPoseData newdata; + + Tracker::getHeadPose(&newdata); + ui.lcdNumX->display((double) (((int)(newdata.x * 10.0f))/10.0f)); + ui.lcdNumY->display((double) (((int)(newdata.y * 10.0f))/10.0f)); + ui.lcdNumZ->display((double) (((int)(newdata.z * 10.0f))/10.0f)); + + ui.lcdNumRotX->display((double) (((int)(newdata.yaw * 10.0f))/10.0f)); + ui.lcdNumRotY->display((double) (((int)(newdata.pitch * 10.0f))/10.0f)); + ui.lcdNumRotZ->display((double) (((int)(newdata.roll * 10.0f))/10.0f)); +} + /** set the redhold from the slider **/ void FaceTrackNoIR::setMinSmooth( int redh ) { Tracker::setMinSmooth ( redh ); diff --git a/FaceTrackNoIR/FaceTrackNoIR.h b/FaceTrackNoIR/FaceTrackNoIR.h index 0498770a..7518d896 100644 --- a/FaceTrackNoIR/FaceTrackNoIR.h +++ b/FaceTrackNoIR/FaceTrackNoIR.h @@ -75,7 +75,8 @@ public: private: Ui::FaceTrackNoIRClass ui; Tracker *tracker; - QTimer *timMinimizeFTN; + QTimer *timMinimizeFTN; // Timer to Auto-minimize + QTimer *timUpdateHeadPose; // Timer to display headpose QStringList iniFileList; // List of INI-files, that are present in the Settings folder ITrackerDialogPtr pTrackerDialog; // Pointer to Tracker dialog instance (in DLL) @@ -147,8 +148,9 @@ private: void setInvertZ( int invert ); void setUseFilter( int set ); + void showHeadPose(); - // reduction factor sliders + // EWMA filter sliders void setMinSmooth( int redh ); void setMaxSmooth( int redh ); void setPowCurve( int redh ); diff --git a/FaceTrackNoIR/FaceTrackNoIR.ui b/FaceTrackNoIR/FaceTrackNoIR.ui index 25adf15f..b030f18b 100644 --- a/FaceTrackNoIR/FaceTrackNoIR.ui +++ b/FaceTrackNoIR/FaceTrackNoIR.ui @@ -154,6 +154,134 @@ QGroupBox { 6 + + + + + 250 + 150 + + + + + + 0 + 0 + 250 + 170 + + + + + 250 + 150 + + + + + 500 + 500 + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + + + + + 0 + 90 + + + + + 16777215 + 90 + + + + + + 100 + 20 + 145 + 34 + + + + Please help us: make gaming fun... + + + Click here to +Support FaceTrackNoIR! + + + + :/UIElements/Donate.png:/UIElements/Donate.png + + + + 18 + 18 + + + + + + + 0 + 0 + 90 + 90 + + + + + 0 + 0 + + + + + 90 + 90 + + + + + 16777215 + 90 + + + + QFrame#logoInstitute { + background:#595959 url(UIElements/logoFaceTrackNoIR.png) no-repeat; +border:none; +} + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + @@ -171,60 +299,6 @@ QGroupBox { - - - - 151 - 40 - 80 - 20 - - - - border:1px solid #ccc; -background:white; -color:#000; - - - N/A - - - - - - 151 - 10 - 81 - 20 - - - - border:1px solid #ccc; -background:white; -color:#000; - - - N/A - - - - - - 150 - 70 - 81 - 20 - - - - border:1px solid #ccc; -background:white; -color:#000; - - - N/A - - @@ -327,190 +401,86 @@ color:white; rotX - + 30 - 70 - 81 - 20 + 10 + 71 + 23 - - border:1px solid #ccc; -background:white; -color:#000; - - - N/A + + QFrame::NoFrame - + 30 40 - 81 - 20 + 71 + 23 - - border:1px solid #ccc; -background:white; -color:#000; - - - N/A + + QFrame::NoFrame - + 30 - 10 - 81 - 20 + 70 + 71 + 23 - - border:1px solid #ccc; -background:white; -color:#000; - - - N/A + + QFrame::NoFrame - - - - - - - 250 - 150 - - - + - 0 - 0 - 250 - 170 + 150 + 10 + 71 + 23 - - - 250 - 150 - - - - - 500 - 500 - + + QFrame::NoFrame - - + + + + + 150 + 40 + 71 + 23 + - QFrame::StyledPanel + QFrame::NoFrame - - QFrame::Raised + + + + + 150 + 70 + 71 + 23 + + + + QFrame::NoFrame - - - - - - - 0 - 90 - - - - - 16777215 - 90 - - - - - - 100 - 20 - 145 - 34 - - - - Please help us: make gaming fun... - - - Click here to -Support FaceTrackNoIR! - - - - :/UIElements/Donate.png:/UIElements/Donate.png - - - - 18 - 18 - - - - - - - 0 - 0 - 90 - 90 - - - - - 0 - 0 - - - - - 90 - 90 - - - - - 16777215 - 90 - - - - QFrame#logoInstitute { - background:#595959 url(UIElements/logoFaceTrackNoIR.png) no-repeat; -border:none; -} - - - QFrame::StyledPanel - - - QFrame::Raised - - - - - - @@ -2181,12 +2151,6 @@ background:none; btnStopTracker btnShowEngineControls iconcomboBox - headXLine - headRotXLine - headYLine - headRotYLine - headZLine - headRotZLine diff --git a/FaceTrackNoIR/tracker.cpp b/FaceTrackNoIR/tracker.cpp index c8208023..6455f9b6 100644 --- a/FaceTrackNoIR/tracker.cpp +++ b/FaceTrackNoIR/tracker.cpp @@ -258,7 +258,7 @@ void Tracker::setup(QWidget *head, FaceTrackNoIR *parent) { bool DLL_Ok; // retrieve pointers to the User Interface and the main Application - headPoseWidget = head; +// headPoseWidget = head; mainApp = parent; if (selectedTracker == FT_SM_FACEAPI) { @@ -277,15 +277,6 @@ void Tracker::setup(QWidget *head, FaceTrackNoIR *parent) { pTracker->StartTracker(); } - // set up the line edits for calling - headXLine = headPoseWidget->findChild("headXLine"); - headYLine = headPoseWidget->findChild("headYLine"); - headZLine = headPoseWidget->findChild("headZLine"); - - headRotXLine = headPoseWidget->findChild("headRotXLine"); - headRotYLine = headPoseWidget->findChild("headRotYLine"); - headRotZLine = headPoseWidget->findChild("headRotZLine"); - // // Check if the Protocol-server files were installed OK. // Some servers also create a memory-mapping, for Inter Process Communication. @@ -320,9 +311,6 @@ void Tracker::run() { bool lastStartStopKey = false; bool lastInhibitKey = false; - float rawrotX, rawrotY, rawrotZ; // Locals... - float rawposX, rawposY, rawposZ; - SYSTEMTIME now; long newHeadPoseTime; float dT; @@ -336,6 +324,27 @@ void Tracker::run() { smEngineHeadPoseData temp_head_pose; // headpose from faceAPI # endif + current_camera_position.x = 0.0f; + current_camera_position.y = 0.0f; + current_camera_position.z = 0.0f; + current_camera_position.yaw = 0.0f; + current_camera_position.pitch = 0.0f; + current_camera_position.roll = 0.0f; + + target_camera_position.x = 0.0f; + target_camera_position.y = 0.0f; + target_camera_position.z = 0.0f; + target_camera_position.yaw = 0.0f; + target_camera_position.pitch = 0.0f; + target_camera_position.roll = 0.0f; + + new_camera_position.x = 0.0f; + new_camera_position.y = 0.0f; + new_camera_position.z = 0.0f; + new_camera_position.yaw = 0.0f; + new_camera_position.pitch = 0.0f; + new_camera_position.roll = 0.0f; + // // Test some Filter-stuff // @@ -533,22 +542,6 @@ void Tracker::run() { MessageBeep (MB_ICONASTERISK); Tracker::set_initial = true; } - - rawrotX = Tracker::Pitch.headPos- Tracker::Pitch.initial_headPos; // degrees - rawrotY = Tracker::Yaw.headPos- Tracker::Yaw.initial_headPos; - rawrotZ = Tracker::Roll.headPos - Tracker::Roll.initial_headPos; - rawposX = Tracker::X.headPos - Tracker::X.initial_headPos; // centimeters - rawposY = Tracker::Y.headPos - Tracker::Y.initial_headPos; - rawposZ = Tracker::Z.headPos - Tracker::Z.initial_headPos; - - headRotXLine->setText(QString("%1").arg( rawrotX, 0, 'f', 1)); // show degrees - headRotYLine->setText(QString("%1").arg( rawrotY, 0, 'f', 1)); - headRotZLine->setText(QString("%1").arg( rawrotZ, 0, 'f', 1)); - - headXLine->setText(QString("%1").arg( rawposX, 0, 'f', 1)); // show centimeters - headYLine->setText(QString("%1").arg( rawposY, 0, 'f', 1)); - headZLine->setText(QString("%1").arg( rawposZ, 0, 'f', 1)); - } // @@ -614,21 +607,30 @@ void Tracker::run() { server_Game->setHeadRotY( new_camera_position.yaw ); server_Game->setHeadRotZ( new_camera_position.roll ); - server_Game->setHeadPosX( new_camera_position.x ); // centimeters + server_Game->setHeadPosX( new_camera_position.x ); // centimeters server_Game->setHeadPosY( new_camera_position.y ); server_Game->setHeadPosZ( new_camera_position.z ); } // All Protocol server(s) if (server_Game) { - server_Game->setVirtRotX ( new_camera_position.pitch ); // degrees + server_Game->setVirtRotX ( new_camera_position.pitch ); // degrees server_Game->setVirtRotY ( new_camera_position.yaw ); server_Game->setVirtRotZ ( new_camera_position.roll ); - server_Game->setVirtPosX ( new_camera_position.x ); // centimeters + server_Game->setVirtPosX ( new_camera_position.x ); // centimeters server_Game->setVirtPosY ( new_camera_position.y ); server_Game->setVirtPosZ ( new_camera_position.z ); } +// headRotXLine->setText(QString("%1").arg( new_camera_position.pitch, 0, 'f', 1)); // show degrees +// headRotYLine->setText(QString("%1").arg( new_camera_position.yaw, 0, 'f', 1)); +// headRotZLine->setText(QString("%1").arg( new_camera_position.roll, 0, 'f', 1)); +// +//// headXLine->setText(QString("%1").arg( new_camera_position.x, 0, 'f', 1)); // show centimeters +// headYLine->setText(QString("%1").arg( new_camera_position.y, 0, 'f', 1)); +// headZLine->setText(QString("%1").arg( new_camera_position.z, 0, 'f', 1)); + + # ifdef USE_DEBUG_CLIENT debug_Client->setHeadRotX( Tracker::Pitch.headPos ); // degrees debug_Client->setHeadRotY( Tracker::Yaw.headPos ); @@ -847,6 +849,19 @@ void Tracker::setPowCurve( int x ) { } } +// +// Set the filter-value from the GUI. +// +void Tracker::getHeadPose( THeadPoseData *data ) { + data->x = Tracker::X.headPos - Tracker::X.initial_headPos; // centimeters + data->y = Tracker::Y.headPos - Tracker::Y.initial_headPos; + data->z = Tracker::Z.headPos - Tracker::Z.initial_headPos; + + data->pitch = Tracker::Pitch.headPos- Tracker::Pitch.initial_headPos; // degrees + data->yaw = Tracker::Yaw.headPos- Tracker::Yaw.initial_headPos; + data->roll = Tracker::Roll.headPos - Tracker::Roll.initial_headPos; +} + // // Get the Smoothed value from the QList. // diff --git a/FaceTrackNoIR/tracker.h b/FaceTrackNoIR/tracker.h index 56be4771..3eeae2f2 100644 --- a/FaceTrackNoIR/tracker.h +++ b/FaceTrackNoIR/tracker.h @@ -181,16 +181,6 @@ private: static bool setEngineStop; // Stop tracker->engine, when OFF static long prevHeadPoseTime; // Time from previous sample - /** QT objects **/ - QLineEdit *headXLine; - QLineEdit *headYLine; - QLineEdit *headZLine; - - QLineEdit *headRotXLine; - QLineEdit *headRotYLine; - QLineEdit *headRotZLine; - - QWidget *headPoseWidget; FaceTrackNoIR *mainApp; QSharedPointer server_Game; // Protocol Server to communicate headpose-data to the Game! @@ -228,6 +218,8 @@ public: static void setMaxSmooth(int x); static void setPowCurve(int x); + static void getHeadPose(THeadPoseData *data); // Return the current headpose data + static float getSmoothFromList ( QList *rawList ); static float getDegreesFromRads ( float rads ) { return (rads * 57.295781f); } static float getRadsFromDegrees ( float degrees ) { return (degrees * 0.017453f); } diff --git a/bin/FaceTrackNoIR.exe b/bin/FaceTrackNoIR.exe index 17fbe3db..389124a0 100644 Binary files a/bin/FaceTrackNoIR.exe and b/bin/FaceTrackNoIR.exe differ diff --git a/bin/Settings/FlightGear.ini b/bin/Settings/FlightGear.ini index 0b3d6235..75a8f9b6 100644 --- a/bin/Settings/FlightGear.ini +++ b/bin/Settings/FlightGear.ini @@ -1,5 +1,5 @@ [Tracking] -Smooth=4 +Smooth=6 invertYaw=false invertPitch=false invertRoll=false @@ -13,9 +13,9 @@ redRoll=70 redX=70 redY=70 redZ=70 -minSmooth=15 +minSmooth=25 powCurve=10 -maxSmooth=50 +maxSmooth=70 [GameProtocol] Selection=1 diff --git a/bin/Settings/SimConnect.ini b/bin/Settings/SimConnect.ini index d7654904..95b6202b 100644 --- a/bin/Settings/SimConnect.ini +++ b/bin/Settings/SimConnect.ini @@ -1,5 +1,5 @@ [Tracking] -Smooth=10 +Smooth=4 invertYaw=false invertPitch=false invertRoll=false @@ -13,9 +13,9 @@ redRoll=90 redX=90 redY=90 redZ=90 -minSmooth=15 -powCurve=2 -maxSmooth=80 +minSmooth=10 +powCurve=12 +maxSmooth=70 [GameProtocol] Selection=5 @@ -69,7 +69,7 @@ Inhibit_Roll=false Inhibit_X=false Inhibit_Y=false Inhibit_Z=false -SetEngineStop=false +SetEngineStop=true [FTN] LocalPCOnly=true -- cgit v1.2.3