From 30a7bbb84e563d07e1b4ef598f5b57041d5e4a8b Mon Sep 17 00:00:00 2001 From: Wim Vriend Date: Wed, 5 Sep 2012 17:26:20 +0000 Subject: Modified 4 Arduino Tracker git-svn-id: svn+ssh://svn.code.sf.net/p/facetracknoir/code@124 19e81ba0-9b1a-49c3-bd6c-561e1906d5fb --- FaceTrackNoIR/FaceTrackNoIR.cpp | 67 +++++++++++++++++++++-------------------- FaceTrackNoIR/FaceTrackNoIR.h | 5 ++- FaceTrackNoIR/tracker.cpp | 22 ++++++++++---- FaceTrackNoIR/tracker.h | 6 ++-- 4 files changed, 55 insertions(+), 45 deletions(-) (limited to 'FaceTrackNoIR') diff --git a/FaceTrackNoIR/FaceTrackNoIR.cpp b/FaceTrackNoIR/FaceTrackNoIR.cpp index 6ed3a64a..09f7e3bb 100644 --- a/FaceTrackNoIR/FaceTrackNoIR.cpp +++ b/FaceTrackNoIR/FaceTrackNoIR.cpp @@ -875,7 +875,7 @@ THeadPoseData newdata; // Update the video-widget. // Requested by Stanislaw // - Tracker::doRefreshVideo(); +// Tracker::doRefreshVideo(); } @@ -1111,11 +1111,9 @@ void FaceTrackNoIR::exit() { void FaceTrackNoIR::createIconGroupBox() { importGetProtocolDialog getProtocol; -importGetFilterDialog getFilter; +importGetFilterDll getFilter; +IFilterDllPtr pFilterDll; // Pointer to Filter dialog instance (in DLL) importGetTrackerDialog getTracker; -//QLibrary *filterLib; -//QString *filterName; -//QIcon *filterIcon; QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // Registry settings (in HK_USER) @@ -1123,7 +1121,7 @@ importGetTrackerDialog getTracker; QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) // - // Get a List of all the Filter-DLL-files in the Program-folder. + // Get a List of all the Protocol-DLL-files in the Program-folder. // QDir settingsDir( QCoreApplication::applicationDirPath() ); QStringList filters; @@ -1192,26 +1190,26 @@ importGetTrackerDialog getTracker; // qDebug() << "createIconGroupBox says: FilterName = " << filterFileList.at(i); - // - // Delete the existing QDialog - // - if (pFilterDialog) { - pFilterDialog.Release(); - } + //// + //// Delete the existing QDialog + //// + //if (pFilterDll) { + // pFilterDialog.Release(); + //} // Show the appropriate Protocol-server Settings QLibrary *filterLib = new QLibrary(filterFileList.at(i)); QString *filterName = new QString(""); QIcon *filterIcon = new QIcon(); - getFilter = (importGetFilterDialog) filterLib->resolve("GetFilterDialog"); + getFilter = (importGetFilterDll) filterLib->resolve("GetFilterDll"); if (getFilter) { - IFilterDialogPtr ptrXyz(getFilter()); + IFilterDllPtr ptrXyz(getFilter()); if (ptrXyz) { - pFilterDialog = ptrXyz; - pFilterDialog->getFullName( filterName ); - pFilterDialog->getIcon( filterIcon ); + pFilterDll = ptrXyz; + pFilterDll->getFullName( filterName ); + pFilterDll->getIcon( filterIcon ); // qDebug() << "FaceTrackNoIR::showServerControls GetFilterDialog Function Resolved!"; } else { @@ -1227,7 +1225,7 @@ importGetTrackerDialog getTracker; connect(ui.iconcomboFilter, SIGNAL(currentIndexChanged(int)), this, SLOT(filterSelected(int))); // - // Get a List of all the Filter-DLL-files in the Program-folder. + // Get a List of all the Tracker-DLL-files in the Program-folder. // filters.clear(); filters << "FTNoIR_Tracker_*.dll"; @@ -1924,24 +1922,27 @@ QWidget( parent , f) connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); - ui.qFunctionX->setConfig(Tracker::X.curvePtr); + QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // Registry settings (in HK_USER) + QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + + ui.qFunctionX->setConfig(Tracker::X.curvePtr, currentFile); connect(ui.qFunctionX, SIGNAL(CurveChanged(bool)), this, SLOT(curveChanged(bool))); - ui.qFunctionY->setConfig(Tracker::Y.curvePtr); + ui.qFunctionY->setConfig(Tracker::Y.curvePtr, currentFile); connect(ui.qFunctionY, SIGNAL(CurveChanged(bool)), this, SLOT(curveChanged(bool))); - ui.qFunctionZ->setConfig(Tracker::Z.curvePtr); + ui.qFunctionZ->setConfig(Tracker::Z.curvePtr, currentFile); connect(ui.qFunctionZ, SIGNAL(CurveChanged(bool)), this, SLOT(curveChanged(bool))); - ui.qFunctionYaw->setConfig(Tracker::Yaw.curvePtr); + ui.qFunctionYaw->setConfig(Tracker::Yaw.curvePtr, currentFile); connect(ui.qFunctionYaw, SIGNAL(CurveChanged(bool)), this, SLOT(curveChanged(bool))); // // There are 2 curves for Pitch: Up and Down. Users have indicated that, to be able to use visual Flight controls, it is necessary to have a 'slow' curve for Down... // - ui.qFunctionPitch->setConfig(Tracker::Pitch.curvePtr); + ui.qFunctionPitch->setConfig(Tracker::Pitch.curvePtr, currentFile); connect(ui.qFunctionPitch, SIGNAL(CurveChanged(bool)), this, SLOT(curveChanged(bool))); - ui.qFunctionPitchDown->setConfig(Tracker::Pitch.curvePtrAlt); + ui.qFunctionPitchDown->setConfig(Tracker::Pitch.curvePtrAlt, currentFile); connect(ui.qFunctionPitchDown, SIGNAL(CurveChanged(bool)), this, SLOT(curveChanged(bool))); - ui.qFunctionRoll->setConfig(Tracker::Roll.curvePtr); + ui.qFunctionRoll->setConfig(Tracker::Roll.curvePtr, currentFile); connect(ui.qFunctionRoll, SIGNAL(CurveChanged(bool)), this, SLOT(curveChanged(bool))); // Load the settings from the current .INI-file @@ -2028,10 +2029,10 @@ int sensX, sensY, sensZ; iniFile.endGroup (); - ui.qFunctionYaw->loadSettings(iniFile); - ui.qFunctionPitch->loadSettings(iniFile); - ui.qFunctionPitchDown->loadSettings(iniFile); - ui.qFunctionRoll->loadSettings(iniFile); + ui.qFunctionYaw->loadSettings(currentFile); + ui.qFunctionPitch->loadSettings(currentFile); + ui.qFunctionPitchDown->loadSettings(currentFile); + ui.qFunctionRoll->loadSettings(currentFile); settingsDirty = false; @@ -2049,10 +2050,10 @@ void CurveConfigurationDialog::save() { QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) - ui.qFunctionYaw->saveSettings(iniFile); - ui.qFunctionPitch->saveSettings(iniFile); - ui.qFunctionPitchDown->saveSettings(iniFile); - ui.qFunctionRoll->saveSettings(iniFile); + ui.qFunctionYaw->saveSettings(currentFile); + ui.qFunctionPitch->saveSettings(currentFile); + ui.qFunctionPitchDown->saveSettings(currentFile); + ui.qFunctionRoll->saveSettings(currentFile); settingsDirty = false; diff --git a/FaceTrackNoIR/FaceTrackNoIR.h b/FaceTrackNoIR/FaceTrackNoIR.h index ff64bc96..bd969174 100644 --- a/FaceTrackNoIR/FaceTrackNoIR.h +++ b/FaceTrackNoIR/FaceTrackNoIR.h @@ -58,14 +58,13 @@ typedef IProtocolDialog *(WINAPI *importGetProtocolDialog)(void); typedef AutoClosePtr IFilterDialogPtr; typedef IFilterDialog *(WINAPI *importGetFilterDialog)(void); +typedef AutoClosePtr IFilterDllPtr; +typedef IFilterDll *(WINAPI *importGetFilterDll)(void); #include class Tracker; // pre-define class to avoid circular includes -//void getCurvePoints(QSettings *iniFile, QString prefix, QPointF *one, QPointF *two, QPointF *three, QPointF *four, -// int NeutralZone, int Sensitivity, int MaxInput, int MaxOutput); - class FaceTrackNoIR : public QMainWindow { Q_OBJECT diff --git a/FaceTrackNoIR/tracker.cpp b/FaceTrackNoIR/tracker.cpp index 74fa2df5..9d2ee19a 100644 --- a/FaceTrackNoIR/tracker.cpp +++ b/FaceTrackNoIR/tracker.cpp @@ -108,7 +108,7 @@ TShortKey Tracker::InhibitKey; // ShortKey to inhibit axis while tracking TShortKey Tracker::GameZeroKey; // ShortKey to Set Game Zero //TShortKey Tracker::AxisReverseKey; // ShortKey to start/stop axis reverse while tracking -ITrackerPtr Tracker::pTracker; // Pointer to Tracker instance (in DLL) +//ITrackerPtr Tracker::pTracker; // Pointer to Tracker instance (in DLL) IProtocolPtr Tracker::pProtocol; // Pointer to Protocol instance (in DLL) IFilterPtr Tracker::pFilter; // Pointer to Filter instance (in DLL) @@ -153,13 +153,14 @@ QFrame *video_frame; // // Load the Tracker-engine DLL, get the tracker-class from it and do stuff... // + pTracker = NULL; libName = mainApp->getCurrentTrackerName(); if (!libName.isEmpty()) { trackerLib = new QLibrary(libName); getIT = (importGetTracker) trackerLib->resolve("GetTracker"); if (getIT) { - ITrackerPtr ptrXyz(getIT()); // Get the Class + ITracker *ptrXyz(getIT()); // Get the Class if (ptrXyz) { pTracker = ptrXyz; @@ -227,7 +228,9 @@ Tracker::~Tracker() { // Stop the Tracker if (pTracker) { + qDebug() << "Tracker::~Tracker Calling pTracker->StopTracker()..."; pTracker->StopTracker( true ); + qDebug() << "Tracker::~Tracker After Calling pTracker->StopTracker()..."; } // Trigger thread to stop @@ -241,8 +244,15 @@ Tracker::~Tracker() { // // Remove the Tracker // 20120615, WVR: As suggested by Stanislaw - if (pTracker) - pTracker.Release(); + if (pTracker) { + QString name; + pTracker->getShortName(&name); + qDebug() << "Tracker::~Tracker Calling pTracker->Release()..." << name; + delete pTracker; + pTracker = NULL; +// pTracker.Release(); + qDebug() << "Tracker::~Tracker After Calling pTracker->Release()..."; + } // Close handles ::CloseHandle(m_StopThread); @@ -321,8 +331,8 @@ T6DOF gameoutput_camera(0,0,0,0,0,0); // if (pFilter) { QString filterName; - pFilter->getFullName(&filterName); - qDebug() << "Tracker::run() FilterName = " << filterName; + //pFilter->getFullName(&filterName); + //qDebug() << "Tracker::run() FilterName = " << filterName; } // diff --git a/FaceTrackNoIR/tracker.h b/FaceTrackNoIR/tracker.h index 56fe51fd..721d150e 100644 --- a/FaceTrackNoIR/tracker.h +++ b/FaceTrackNoIR/tracker.h @@ -51,7 +51,7 @@ // 1a. COM-Like usage with smart pointer. // No need to call `ITracker::Release'; the instance will // be released automatically in destructor of the smart pointer. -typedef AutoClosePtr ITrackerPtr; +//typedef AutoClosePtr ITrackerPtr; typedef ITracker *(WINAPI *importGetTracker)(void); typedef AutoClosePtr IProtocolPtr; typedef IProtocol *(WINAPI *importGetProtocol)(void); @@ -182,7 +182,7 @@ private: static T6DOF new_camera; static T6DOF output_camera; - static ITrackerPtr pTracker; // Pointer to Tracker instance (in DLL) + ITracker *pTracker; // Pointer to Tracker instance (in DLL) static IProtocolPtr pProtocol; // Pointer to Protocol instance (in DLL) static IFilterPtr pFilter; // Pointer to Filter instance (in DLL) @@ -258,7 +258,7 @@ public: static void getHeadPose(THeadPoseData *data); // Return the current headpose data static void getOutputHeadPose(THeadPoseData *data); // Return the current (processed) headpose data static IFilterPtr getFilterPtr() { return pFilter; } - static void doRefreshVideo() { // Call the face-tracker-function RefreshVideo + void doRefreshVideo() { // Call the face-tracker-function RefreshVideo if (pTracker) { pTracker->refreshVideo(); } -- cgit v1.2.3