From e5fbf0ed808cc530bd411251d32159c9f04522d8 Mon Sep 17 00:00:00 2001 From: Wim Vriend Date: Sat, 4 Jun 2011 12:38:20 +0000 Subject: Eagle Dynamics API implemented, added some 'nice to haves'. git-svn-id: svn+ssh://svn.code.sf.net/p/facetracknoir/code@88 19e81ba0-9b1a-49c3-bd6c-561e1906d5fb --- FaceTrackNoIR/FaceTrackNoIR.cpp | 84 ++++++++++++++++++++++------------------- FaceTrackNoIR/FaceTrackNoIR.h | 2 +- FaceTrackNoIR/FaceTrackNoIR.ui | 67 ++++++++++++++++++++++---------- FaceTrackNoIR/tracker.cpp | 56 ++++++++++++--------------- FaceTrackNoIR/tracker.h | 5 ++- 5 files changed, 122 insertions(+), 92 deletions(-) diff --git a/FaceTrackNoIR/FaceTrackNoIR.cpp b/FaceTrackNoIR/FaceTrackNoIR.cpp index 79c3969b..14cb6a9a 100644 --- a/FaceTrackNoIR/FaceTrackNoIR.cpp +++ b/FaceTrackNoIR/FaceTrackNoIR.cpp @@ -32,6 +32,8 @@ #include "FaceTrackNoIR.h" #include "tracker.h" +//#define USE_VISAGE + // // Setup the Main Dialog // @@ -43,7 +45,6 @@ QMainWindow(parent, flags) // // Initialize Widget handles, to prevent memory-access errors. // - _engine_controls = 0; _keyboard_shortcuts = 0; _preferences = 0; _keyboard_shortcuts = 0; @@ -155,6 +156,7 @@ void FaceTrackNoIR::setupFaceTrackNoIR() { connect(timUpdateHeadPose, SIGNAL(timeout()), this, SLOT(showHeadPose())); ui.txtTracking->setVisible(false); ui.txtAxisReverse->setVisible(false); + ui.gameName->setText(""); } /** destructor stops the engine and quits the faceapi **/ @@ -193,7 +195,7 @@ FaceTrackNoIR::~FaceTrackNoIR() { // void FaceTrackNoIR::getGameProgramName() { if ( tracker != NULL ) { - ui.cameraName->setText( tracker->getGameProgramName() ); + ui.gameName->setText( tracker->getGameProgramName() ); } } @@ -539,6 +541,7 @@ void FaceTrackNoIR::startTracker( ) { } // Enable/disable Protocol-server Settings + ui.iconcomboTrackerSource->setEnabled ( false ); ui.iconcomboBox->setEnabled ( false ); ui.btnShowServerControls->setEnabled ( false ); @@ -604,6 +607,7 @@ void FaceTrackNoIR::stopTracker( ) { ui.btnStopTracker->setEnabled ( false ); ui.btnShowEngineControls->setEnabled ( false ); ui.iconcomboBox->setEnabled ( true ); + ui.iconcomboTrackerSource->setEnabled ( true ); // Enable/disable Protocol-server Settings ui.btnShowServerControls->setEnabled ( true ); @@ -753,63 +757,61 @@ void FaceTrackNoIR::showHeadPoseWidget() { void FaceTrackNoIR::showEngineControls() { importGetTrackerDialog getIT; QLibrary *trackerLib; - +QString libName; qDebug() << "FaceTrackNoIR::showEngineControls started."; // // Delete the existing QDialog // - if (_engine_controls) { - delete _engine_controls; - _engine_controls = 0; + if (pTrackerDialog) { + pTrackerDialog.Release(); } - qDebug() << "FaceTrackNoIR::showEngineControls after remove engine_controls."; + // Show the appropriate Tracker Settings + libName.clear(); - // Create new - if (!_engine_controls) - { - switch (ui.iconcomboTrackerSource->currentIndex()) { + switch (ui.iconcomboTrackerSource->currentIndex()) { case FT_SM_FACEAPI: // Face API -// _engine_controls = new EngineControls( tracker->getEngine(), true, false, this, Qt::Dialog ); + qDebug() << "FaceTrackNoIR::showEngineControls case FT_SM_FACEAPI."; + libName = QString("FTNoIR_Tracker_SM.dll"); break; + case FT_FTNOIR: // FTNoir server qDebug() << "FaceTrackNoIR::showEngineControls case FT_FTNOIR."; + libName = QString("FTNoIR_Tracker_UDP.dll"); + break; - trackerLib = new QLibrary("FTNoIR_Tracker_UDP.dll"); + default: + break; + } - qDebug() << "FaceTrackNoIR::showEngineControls Loaded trackerLib." << trackerLib; + // + // Load the Server-settings dialog (if any) and show it. + // + if (!libName.isEmpty()) { + trackerLib = new QLibrary(libName); - getIT = (importGetTrackerDialog) trackerLib->resolve("GetTrackerDialog"); + qDebug() << "FaceTrackNoIR::showEngineControls Loaded trackerLib." << trackerLib; - qDebug() << "FaceTrackNoIR::showEngineControls resolved?." << getIT; + getIT = (importGetTrackerDialog) trackerLib->resolve("GetTrackerDialog"); - if (getIT) { - ITrackerDialogPtr ptrXyz(getIT()); - if (ptrXyz) - { - pTrackerDialog = ptrXyz; - pTrackerDialog->Initialize( this ); - qDebug() << "FaceTrackNoIR::showEngineControls GetTrackerDialog Function Resolved!"; - } - } - else { - QMessageBox::warning(0,"FaceTrackNoIR Error", "DLL not loaded",QMessageBox::Ok,QMessageBox::NoButton); - } + qDebug() << "FaceTrackNoIR::showEngineControls resolved?." << getIT; - break; - default: - break; + if (getIT) { + ITrackerDialogPtr ptrXyz(getIT()); + if (ptrXyz) + { + pTrackerDialog = ptrXyz; + pTrackerDialog->Initialize( this ); + qDebug() << "FaceTrackNoIR::showEngineControls GetTrackerDialog Function Resolved!"; + } + } + else { + QMessageBox::warning(0,"FaceTrackNoIR Error", "DLL not loaded",QMessageBox::Ok,QMessageBox::NoButton); } - - } - - // Show if already created - if (_engine_controls) { - _engine_controls->show(); - _engine_controls->raise(); } + } /** toggles Server Controls Dialog **/ @@ -954,6 +956,12 @@ void FaceTrackNoIR::createIconGroupBox() ui.iconcomboTrackerSource->addItem(QIcon(":/images/SeeingMachines.ico"), tr("Face API")); ui.iconcomboTrackerSource->addItem(QIcon(":/images/FaceTrackNoIR.ico"), tr("FTNoir server")); + +# ifdef USE_VISAGE + ui.iconcomboTrackerSource->addItem(QIcon(":/images/Visage.ico"), tr("Visage Tracker")); +# endif + + } // diff --git a/FaceTrackNoIR/FaceTrackNoIR.h b/FaceTrackNoIR/FaceTrackNoIR.h index 5ad2a348..9dc38071 100644 --- a/FaceTrackNoIR/FaceTrackNoIR.h +++ b/FaceTrackNoIR/FaceTrackNoIR.h @@ -88,7 +88,7 @@ private: /** Widget variables **/ QVBoxLayout *l; - QWidget *_engine_controls; +// QWidget *_engine_controls; // QWidget *_server_controls; QWidget *_preferences; QWidget *_keyboard_shortcuts; diff --git a/FaceTrackNoIR/FaceTrackNoIR.ui b/FaceTrackNoIR/FaceTrackNoIR.ui index c4c6b228..ef21ab82 100644 --- a/FaceTrackNoIR/FaceTrackNoIR.ui +++ b/FaceTrackNoIR/FaceTrackNoIR.ui @@ -1965,27 +1965,54 @@ opacity:100; - - - - 420 - 30 - - - - - 600 - 30 - - - - color:#ccc; + + + + + + 420 + 25 + + + + + 600 + 30 + + + + color:#ccc; background:none; - - - Camera Name - - + + + Camera Name + + + + + + + + 420 + 20 + + + + + 600 + 30 + + + + color:#ccc; +background:none; + + + Game Name + + + + diff --git a/FaceTrackNoIR/tracker.cpp b/FaceTrackNoIR/tracker.cpp index 7beb1aa5..799c274e 100644 --- a/FaceTrackNoIR/tracker.cpp +++ b/FaceTrackNoIR/tracker.cpp @@ -152,6 +152,10 @@ QFrame *video_frame; libName = QString("FTNoIR_Tracker_UDP.dll"); break; + case FT_VISAGE: + libName = QString("FTNoIR_Tracker_Visage.dll"); + break; + default: break; } @@ -342,6 +346,7 @@ bool lastGameZeroKey = false; bool waitAxisReverse = false; bool waitThroughZero = false; double actualYaw = 0.0f; +double actualZ = 0.0f; T6DOF offset_camera(0,0,0,0,0,0); T6DOF gamezero_camera(0,0,0,0,0,0); T6DOF gameoutput_camera(0,0,0,0,0,0); @@ -494,21 +499,24 @@ T6DOF gameoutput_camera(0,0,0,0,0,0); // // Check the state of the Axis Reverse key // - if ( isShortKeyPressed( &AxisReverseKey, &keystate[0] ) ) { - if ((fabs(actualYaw) > 90.0f) && (!waitAxisReverse)) { - Tracker::do_axis_reverse = !Tracker::do_axis_reverse; - waitAxisReverse = true; - } - } + ////if ( isShortKeyPressed( &AxisReverseKey, &keystate[0] ) ) { + //// if ((fabs(actualYaw) > 90.0f) && (!waitAxisReverse)) { + //// Tracker::do_axis_reverse = !Tracker::do_axis_reverse; + //// waitAxisReverse = true; + //// } + ////} } } // // Reset the 'wait' flag. Moving above 90 with the key pressed, will (de-)activate Axis Reverse. // - if (fabs(actualYaw) < 85.0f) { - waitAxisReverse = false; - } + //////if (fabs(actualYaw) < 85.0f) { + ////// waitAxisReverse = false; + //////} + //// if { +// qDebug() << "Tracker::run() says actualZ = " << actualZ; + Tracker::do_axis_reverse = ((fabs(actualYaw) > 90.0f) && (actualZ < -20.0f)); if (WaitForSingleObject(Tracker::hTrackMutex, 100) == WAIT_OBJECT_0) { @@ -576,27 +584,9 @@ T6DOF gameoutput_camera(0,0,0,0,0,0); // Reverse Axis. // actualYaw = output_camera.position.yaw; // Save the actual Yaw, otherwise we can't check for +90 + actualZ = output_camera.position.z; // Also the Z if (Tracker::do_axis_reverse) { - if (fabs(actualYaw) < 5.0f) { - waitThroughZero = true; - } - if (waitThroughZero) { - output_camera.position.yaw *= -1.0f; - } - if (output_camera.position.yaw > 0.0f) { - output_camera.position.yaw = 180.0f - output_camera.position.yaw; - } - else { - output_camera.position.yaw = -180.0f - output_camera.position.yaw; - } - } - else { - if (fabs(actualYaw) < 5.0f) { - waitThroughZero = false; - } - if (waitThroughZero) { - output_camera.position.yaw *= -1.0f; - } + output_camera.position.z = 100; // Max. } // @@ -707,9 +697,13 @@ void Tracker::addHeadPose( THeadPoseData head_pose ) // QString Tracker::getGameProgramName() { QString str; +char dest[100]; -// str = server_Game->GetProgramName(); - str = QString(""); + str = QString("No protocol active?"); + if (pProtocol) { + pProtocol->getNameFromGame( dest ); + str = QString( dest ); + } return str; } diff --git a/FaceTrackNoIR/tracker.h b/FaceTrackNoIR/tracker.h index 924f5542..79af07a1 100644 --- a/FaceTrackNoIR/tracker.h +++ b/FaceTrackNoIR/tracker.h @@ -79,7 +79,8 @@ enum FTNoIR_Client { enum FTNoIR_Face_Tracker { FT_SM_FACEAPI = 0, - FT_FTNOIR = 1 + FT_FTNOIR = 1, + FT_VISAGE = 2 }; enum FTNoIR_Tracker_Status { @@ -213,7 +214,7 @@ public: void loadSettings(); // Load settings from the INI-file bool isShortKeyPressed( TShortKey *key, BYTE *keystate ); - static bool getTrackingActive() { return do_tracking; } + static bool getTrackingActive() { return do_tracking && confid; } static bool getAxisReverse() { return do_axis_reverse; } static bool getConfid() { return confid; } -- cgit v1.2.3