From 5c5c710d03016618a971d7ff20477a90893fbc48 Mon Sep 17 00:00:00 2001 From: Wim Vriend Date: Thu, 18 Oct 2012 16:25:18 +0000 Subject: Started work on incorporating two headtracker at once. git-svn-id: svn+ssh://svn.code.sf.net/p/facetracknoir/code@189 19e81ba0-9b1a-49c3-bd6c-561e1906d5fb --- FaceTrackNoIR/FaceTrackNoIR.cpp | 108 ++++++++++++++++--- FaceTrackNoIR/FaceTrackNoIR.h | 6 +- FaceTrackNoIR/FaceTrackNoIR.ui | 233 +++++++++++++++++++++++++++------------- FaceTrackNoIR/tracker.cpp | 2 +- FaceTrackNoIR/tracker.h | 4 +- 5 files changed, 266 insertions(+), 87 deletions(-) (limited to 'FaceTrackNoIR') diff --git a/FaceTrackNoIR/FaceTrackNoIR.cpp b/FaceTrackNoIR/FaceTrackNoIR.cpp index d9fffdff..e4907284 100644 --- a/FaceTrackNoIR/FaceTrackNoIR.cpp +++ b/FaceTrackNoIR/FaceTrackNoIR.cpp @@ -23,6 +23,7 @@ *********************************************************************************/ /* Modifications (last one on top): + 20121014 - WVR: Added second Tracker Source for Arduino solution. The two will be mutually exclusive. 20120929 - WVR: Disable button Filter-settings when StartTracker. 20120918 - WVR: When AutoStart is TRUE, the program is not directly minimized any more. This now depends on the AutoMinimize time. Fixed the 'not showing' of the MIB. @@ -53,6 +54,7 @@ FaceTrackNoIR::FaceTrackNoIR(QWidget *parent, Qt::WFlags flags) : QMainWindow(parent, flags), pTrackerDialog(NULL), +pSecondTrackerDialog(NULL), pProtocolDialog(NULL), pFilterDialog(NULL) { @@ -129,7 +131,8 @@ void FaceTrackNoIR::setupFaceTrackNoIR() { connect(ui.actionVideoWidget, SIGNAL(triggered()), this, SLOT(showVideoWidget())); connect(ui.actionHeadPoseWidget, SIGNAL(triggered()), this, SLOT(showHeadPoseWidget())); - connect(ui.btnShowEngineControls, SIGNAL(clicked()), this, SLOT(showEngineControls())); + connect(ui.btnShowEngineControls, SIGNAL(clicked()), this, SLOT(showTrackerSettings())); + connect(ui.btnShowSecondTrackerSettings, SIGNAL(clicked()), this, SLOT(showSecondTrackerSettings())); connect(ui.btnShowServerControls, SIGNAL(clicked()), this, SLOT(showServerControls())); connect(ui.btnShowFilterControls, SIGNAL(clicked()), this, SLOT(showFilterControls())); @@ -261,6 +264,19 @@ QString FaceTrackNoIR::getCurrentTrackerName() return trackerFileList.at(ui.iconcomboTrackerSource->currentIndex()); } +// +// Return the name of the second Tracker-DLL +// +QString FaceTrackNoIR::getSecondTrackerName() +{ + if (ui.cbxSecondTrackerSource->currentIndex() <= 0) { + return QString("None"); + } + else { + return trackerFileList.at(ui.cbxSecondTrackerSource->currentIndex() - 1 ); + } +} + /** read the name of the first video-capturing device at start up **/ /** FaceAPI can only use this first one... **/ void FaceTrackNoIR::GetCameraNameDX() { @@ -381,6 +397,7 @@ void FaceTrackNoIR::save() { iniFile.beginGroup ( "TrackerSource" ); iniFile.setValue ( "Selection", ui.iconcomboTrackerSource->currentIndex() ); iniFile.setValue ( "DLL", getCurrentTrackerName() ); + iniFile.setValue ( "2ndDLL", getSecondTrackerName() ); iniFile.endGroup (); // @@ -461,7 +478,7 @@ void FaceTrackNoIR::loadSettings() { // Put the filename in the window-title. // QFileInfo pathInfo ( currentFile ); - setWindowTitle ( "FaceTrackNoIR (1.7 alpha 4) - " + pathInfo.fileName() ); + setWindowTitle ( "FaceTrackNoIR (1.7 alpha 5) - " + pathInfo.fileName() ); // // Get a List of all the INI-files in the (currently active) Settings-folder. @@ -581,15 +598,23 @@ void FaceTrackNoIR::loadSettings() { break; } } + QString secondTrackerName = iniFile.value ( "2ndDLL", "None" ).toString(); + qDebug() << "loadSettings says: secondTrackerName = " << secondTrackerName; + iniFile.endGroup (); disconnect(ui.iconcomboTrackerSource, SIGNAL(currentIndexChanged(int)), this, SLOT(trackingSourceSelected(int))); + disconnect(ui.cbxSecondTrackerSource, SIGNAL(currentIndexChanged(int)), this, SLOT(trackingSourceSelected(int))); for ( int i = 0; i < trackerFileList.size(); i++) { if (trackerFileList.at(i) == selectedTrackerName) { ui.iconcomboTrackerSource->setCurrentIndex( i ); } + if (trackerFileList.at(i) == secondTrackerName) { + ui.cbxSecondTrackerSource->setCurrentIndex( i + 1 ); // The first value = "None", so add 1 + } } connect(ui.iconcomboTrackerSource, SIGNAL(currentIndexChanged(int)), this, SLOT(trackingSourceSelected(int))); + connect(ui.cbxSecondTrackerSource, SIGNAL(currentIndexChanged(int)), this, SLOT(trackingSourceSelected(int))); // // Read the currently selected Filter from the INI-file. @@ -688,6 +713,7 @@ void FaceTrackNoIR::startTracker( ) { // Enable/disable Protocol-server Settings ui.iconcomboTrackerSource->setEnabled ( false ); + ui.cbxSecondTrackerSource->setEnabled ( false ); ui.iconcomboProtocol->setEnabled ( false ); ui.btnShowServerControls->setEnabled ( false ); ui.iconcomboFilter->setEnabled ( false ); @@ -785,6 +811,7 @@ void FaceTrackNoIR::stopTracker( ) { // ui.btnShowEngineControls->setEnabled ( false ); ui.iconcomboProtocol->setEnabled ( true ); ui.iconcomboTrackerSource->setEnabled ( true ); + ui.cbxSecondTrackerSource->setEnabled ( true ); ui.iconcomboFilter->setEnabled ( true ); // Enable/disable Protocol-server Settings @@ -941,12 +968,12 @@ void FaceTrackNoIR::showHeadPoseWidget() { } /** toggles Engine Controls Dialog **/ -void FaceTrackNoIR::showEngineControls() { +void FaceTrackNoIR::showTrackerSettings() { importGetTrackerDialog getIT; QLibrary *trackerLib; QString libName; - qDebug() << "FaceTrackNoIR::showEngineControls started."; + qDebug() << "FaceTrackNoIR::showTrackerSettings started."; // // Delete the existing QDialog @@ -966,22 +993,74 @@ QString libName; if (!libName.isEmpty()) { trackerLib = new QLibrary(libName); -// qDebug() << "FaceTrackNoIR::showEngineControls Loaded trackerLib." << trackerLib; +// qDebug() << "FaceTrackNoIR::showTrackerSettings Loaded trackerLib." << trackerLib; getIT = (importGetTrackerDialog) trackerLib->resolve("GetTrackerDialog"); -// qDebug() << "FaceTrackNoIR::showEngineControls resolved." << getIT; +// qDebug() << "FaceTrackNoIR::showTrackerSettings resolved." << getIT; if (getIT) { ITrackerDialog *ptrXyz(getIT()); if (ptrXyz) { pTrackerDialog = ptrXyz; - pTrackerDialog->Initialize( this ); -// qDebug() << "FaceTrackNoIR::showEngineControls GetTrackerDialog Function Resolved!"; + pTrackerDialog->Initialize( this, 1 ); +// qDebug() << "FaceTrackNoIR::showTrackerSettings GetTrackerDialog Function Resolved!"; if (tracker) { pTrackerDialog->registerTracker( tracker->getTrackerPtr() ); -// qDebug() << "FaceTrackNoIR::showEngineControls RegisterTracker Function Executed"; +// qDebug() << "FaceTrackNoIR::showTrackerSettings RegisterTracker Function Executed"; + } + } + } + else { + QMessageBox::warning(0,"FaceTrackNoIR Error", "DLL not loaded",QMessageBox::Ok,QMessageBox::NoButton); + } + } + +} + +// Show the Settings dialog for the secondary Tracker +void FaceTrackNoIR::showSecondTrackerSettings() { +importGetTrackerDialog getIT; +QLibrary *trackerLib; +QString libName; + + qDebug() << "FaceTrackNoIR::showSecondTrackerSettings started."; + + // + // Delete the existing QDialog + // + if (pSecondTrackerDialog) { + delete pSecondTrackerDialog; + pSecondTrackerDialog = NULL; + } + + // Show the appropriate Tracker Settings + libName.clear(); + libName = getSecondTrackerName(); + + // + // Load the Server-settings dialog (if any) and show it. + // + if ((!libName.isEmpty()) && (libName != "None")) { + trackerLib = new QLibrary(libName); + +// qDebug() << "FaceTrackNoIR::showTrackerSettings Loaded trackerLib." << trackerLib; + + getIT = (importGetTrackerDialog) trackerLib->resolve("GetTrackerDialog"); + +// qDebug() << "FaceTrackNoIR::showTrackerSettings resolved." << getIT; + + if (getIT) { + ITrackerDialog *ptrXyz(getIT()); + if (ptrXyz) + { + pSecondTrackerDialog = ptrXyz; + pSecondTrackerDialog->Initialize( this, 2 ); +// qDebug() << "FaceTrackNoIR::showTrackerSettings GetTrackerDialog Function Resolved!"; + if (tracker) { + pSecondTrackerDialog->registerTracker( tracker->getSecondTrackerPtr() ); +// qDebug() << "FaceTrackNoIR::showTrackerSettings RegisterTracker Function Executed"; } } } @@ -1259,10 +1338,15 @@ ITrackerDll *pTrackerDll; // Pointer to Tracker info instance (in DLL) trackerFileList = settingsDir.entryList( filters, QDir::Files, QDir::Name ); // - // Add strings to the Listbox. + // Add strings to the Listbox(es). // disconnect(ui.iconcomboTrackerSource, SIGNAL(currentIndexChanged(int)), this, SLOT(trackingSourceSelected(int))); ui.iconcomboTrackerSource->clear(); + + disconnect(ui.cbxSecondTrackerSource, SIGNAL(currentIndexChanged(int)), this, SLOT(trackingSourceSelected(int))); + ui.cbxSecondTrackerSource->clear(); + ui.cbxSecondTrackerSource->addItem("None"); + for ( int i = 0; i < trackerFileList.size(); i++) { // qDebug() << "createIconGroupBox says: TrackerName = " << trackerFileList.at(i); @@ -1291,10 +1375,10 @@ ITrackerDll *pTrackerDll; // Pointer to Tracker info instance (in DLL) } ui.iconcomboTrackerSource->addItem(*trackerIcon, *trackerName ); + ui.cbxSecondTrackerSource->addItem(*trackerIcon, *trackerName ); } connect(ui.iconcomboTrackerSource, SIGNAL(currentIndexChanged(int)), this, SLOT(trackingSourceSelected(int))); - - + connect(ui.cbxSecondTrackerSource, SIGNAL(currentIndexChanged(int)), this, SLOT(trackingSourceSelected(int))); } // diff --git a/FaceTrackNoIR/FaceTrackNoIR.h b/FaceTrackNoIR/FaceTrackNoIR.h index a7992bbb..52ea8418 100644 --- a/FaceTrackNoIR/FaceTrackNoIR.h +++ b/FaceTrackNoIR/FaceTrackNoIR.h @@ -72,6 +72,7 @@ public: QString getCurrentProtocolName(); // Get the name of the selected protocol QString getCurrentFilterName(); // Get the name of the selected filter QString getCurrentTrackerName(); // Get the name of the selected face-tracker + QString getSecondTrackerName(); // Get the name of the second face-tracker ("None" if no selection) private: Ui::FaceTrackNoIRClass ui; @@ -84,6 +85,7 @@ private: QStringList trackerFileList; // List of Tracker-DLL-files, that are present in the program-folder ITrackerDialogPtr pTrackerDialog; // Pointer to Tracker dialog instance (in DLL) + ITrackerDialogPtr pSecondTrackerDialog; // Pointer to the second Tracker dialog instance (in DLL) IProtocolDialogPtr pProtocolDialog; // Pointer to Protocol dialog instance (in DLL) IFilterDialogPtr pFilterDialog; // Pointer to Filter dialog instance (in DLL) @@ -139,7 +141,9 @@ private: void showVideoWidget(); void showHeadPoseWidget(); - void showEngineControls(); + void showTrackerSettings(); + void showSecondTrackerSettings(); + void showServerControls(); void showFilterControls(); void showPreferences(); diff --git a/FaceTrackNoIR/FaceTrackNoIR.ui b/FaceTrackNoIR/FaceTrackNoIR.ui index bd4356c3..eec447bc 100644 --- a/FaceTrackNoIR/FaceTrackNoIR.ui +++ b/FaceTrackNoIR/FaceTrackNoIR.ui @@ -11,7 +11,7 @@ 0 0 925 - 428 + 411 @@ -1173,7 +1173,7 @@ color: rgb(0, 255, 0); - 206 + 420 120 @@ -1591,6 +1591,19 @@ background:none; + + + + Qt::Horizontal + + + + 40 + 20 + + + + @@ -1739,33 +1752,30 @@ background:none; - - - - 10 - - - 10 + + + + 1 - + 200 - 120 + 80 - 16777215 - 120 + 200 + 80 - Tracker Source + Tracker Source(1st) @@ -1793,7 +1803,7 @@ background:none; 10 - 80 + 50 180 23 @@ -1808,70 +1818,92 @@ background:none; Settings - + + + + + + + 200 + 70 + + + + + 200 + 80 + + + + + + + Filter + + 10 - 50 - 81 - 23 + 20 + 180 + 22 - - Start the Tracker - - - Start + + -1 + + + 7 - + - false + true - 109 + 10 50 - 81 + 180 23 - Stop the Tracker + Change game protocol settings - Stop + Settings - - + + - 190 - 120 + 200 + 80 - 16777215 - 120 + 200 + 80 - Filter + Game protocol - + 10 @@ -1890,14 +1922,14 @@ background:none; 7 - + true 10 - 80 + 50 180 23 @@ -1914,59 +1946,97 @@ background:none; - - + + - 190 - 120 + 200 + 80 16777215 - 120 + 80 - - - - Game protocol + GO! - + 10 20 - 180 - 22 + 81 + 23 + + Start the Tracker + - - -1 + + Start - - 7 + + + + false + + + + 100 + 20 + 81 + 23 + + + + Stop the Tracker + + + + + + Stop - + + + + + + + 200 + 80 + + + + + 200 + 80 + + + + Tracker Source (2nd) + + true 10 - 80 + 50 180 23 - Change game protocol settings + Change tracker settings @@ -1975,23 +2045,42 @@ background:none; Settings + + + + 10 + 20 + 180 + 22 + + + + + + + -1 + + + 5 + + + + + + Qt::Vertical + + + + 20 + 30 + + + + - - - - Qt::Vertical - - - - 20 - 30 - - - - diff --git a/FaceTrackNoIR/tracker.cpp b/FaceTrackNoIR/tracker.cpp index 6153433f..80080df7 100644 --- a/FaceTrackNoIR/tracker.cpp +++ b/FaceTrackNoIR/tracker.cpp @@ -171,7 +171,7 @@ QFrame *video_frame; if (ptrXyz) { pTracker = ptrXyz; - pTracker->Initialize( video_frame ); + pTracker->Initialize( video_frame, 1 ); qDebug() << "Tracker::setup Function Resolved!"; } } diff --git a/FaceTrackNoIR/tracker.h b/FaceTrackNoIR/tracker.h index 4b52e438..03d517c6 100644 --- a/FaceTrackNoIR/tracker.h +++ b/FaceTrackNoIR/tracker.h @@ -173,7 +173,8 @@ private: static T6DOF new_camera; static T6DOF output_camera; - ITrackerPtr pTracker; // Pointer to Tracker instance (in DLL) + ITrackerPtr pTracker; // Pointer to Tracker instance (in DLL) + ITrackerPtr pSecondTracker; // Pointer to second Tracker instance (in DLL) static IProtocolPtr pProtocol; // Pointer to Protocol instance (in DLL) static IFilterPtr pFilter; // Pointer to Filter instance (in DLL) @@ -254,6 +255,7 @@ public: static void getOutputHeadPose(THeadPoseData *data); // Return the current (processed) headpose data static IFilterPtr getFilterPtr() { return pFilter; } // Return the pointer for the active Filter ITracker *getTrackerPtr() { return pTracker; } // Return the pointer for the active Tracker + ITracker *getSecondTrackerPtr() { return pSecondTracker; } // Return the pointer for the secondary Tracker void doRefreshVideo() { // Call the face-tracker-function RefreshVideo if (pTracker) { -- cgit v1.2.3