From a3500eef8d37a644df41c5c232a1a53aea783181 Mon Sep 17 00:00:00 2001 From: Wim Vriend Date: Sat, 21 Jul 2012 13:15:16 +0000 Subject: BezierConfigurator replaced bt FunctionConfig git-svn-id: svn+ssh://svn.code.sf.net/p/facetracknoir/code@114 19e81ba0-9b1a-49c3-bd6c-561e1906d5fb --- FaceTrackNoIR/FTNoIR_Curves.ui | 701 ++++++--------------- FaceTrackNoIR/FaceTrackNoIR.cpp | 120 ++-- FaceTrackNoIR/FaceTrackNoIR.vcproj | 16 +- .../FaceTrackNoIR.vcproj.VRIEND200810.Wim.user | 65 -- FaceTrackNoIR/tracker.cpp | 224 ++----- FaceTrackNoIR/tracker.h | 47 +- 6 files changed, 310 insertions(+), 863 deletions(-) delete mode 100644 FaceTrackNoIR/FaceTrackNoIR.vcproj.VRIEND200810.Wim.user (limited to 'FaceTrackNoIR') diff --git a/FaceTrackNoIR/FTNoIR_Curves.ui b/FaceTrackNoIR/FTNoIR_Curves.ui index c13565e2..d7ed1fe5 100644 --- a/FaceTrackNoIR/FTNoIR_Curves.ui +++ b/FaceTrackNoIR/FTNoIR_Curves.ui @@ -6,8 +6,8 @@ 0 0 - 757 - 603 + 858 + 605 @@ -97,7 +97,7 @@ color: rgb(255, 255, 255); - 0 + 1 @@ -112,24 +112,30 @@ color: rgb(255, 255, 255); 10 10 - 708 - 511 + 794 + 488 - - - - 50 - - - 180 + + + + + 260 + 240 + + + + + 260 + 240 + - 255 - 170 - 0 + 0 + 255 + 255 @@ -140,41 +146,32 @@ color: rgb(255, 255, 255); - Input Yaw (degr.) + Input Pitch Up (degr.) - Output Yaw (degr.) - - - Yaw (left and right) - - - - 0.000000000000000 - 0.000000000000000 - - - - - 90.000000000000000 - 0.000000000000000 - + Output Pitch Up (degr.) - - - - 50 - - - 180 + + + + + 260 + 240 + + + + + 260 + 240 + 0 255 - 255 + 0 @@ -185,40 +182,31 @@ color: rgb(255, 255, 255); - Input Pitch (degr.) + Input Roll (degr.) - Output Pitch (degr.) - - - Pitch (forward and backward) - - - - 0.000000000000000 - 0.000000000000000 - - - - - 90.000000000000000 - 0.000000000000000 - + Output Roll (degr.) - - - - 50 - - - 180 + + + + + 260 + 240 + + + + + 260 + 240 + - 0 - 255 + 255 + 170 0 @@ -230,140 +218,78 @@ color: rgb(255, 255, 255); - Input Roll (degr.) + Input Yaw (degr.) - Output Roll (degr.) + Output Yaw (degr.) - - Roll (left and right) + + + + + + + 260 + 240 + + + + + 260 + 240 + - - - 0.000000000000000 - 0.000000000000000 - + + + 0 + 255 + 255 + - - - 90.000000000000000 - 0.000000000000000 - + + + 192 + 192 + 192 + - - - - - - 50 + + Input Pitch Down (degr.) - - - - - - NeutralZone + + Output Pitch Down (degr.) - - - - NeutralZone + + + + + 16777215 + 25 + - - - - - NeutralZone + Left-click the graph to place a new point, right-click a point to remove. Left-click and drag to move a point. + + + true - - - 50 + + + + 170 + 140 + - - - - - - 50 + + image: url(:/images/rotation_DOFs.png); - - - - - - - 170 - 140 - - - - - 170 - 140 - - - - image: url(:/images/rotation_DOFs.png); -background-color: rgb(255, 255, 255); - - - - - - - - - - - Qt::Vertical - - - QSizePolicy::Maximum - - - - 20 - 115 - - - - - - - - - 16777215 - 25 - - - - Use the circular handles to change - - - - - - - - 16777215 - 25 - - - - the curve(s). - - - - - @@ -378,26 +304,32 @@ background-color: rgb(255, 255, 255); - 10 + 30 10 - 708 - 491 + 794 + 388 - - - - 50 - - - 180 + + + + + 260 + 240 + + + + + 260 + 240 + - 0 - 0 - 255 + 255 + 255 + 0 @@ -408,41 +340,32 @@ background-color: rgb(255, 255, 255); - Input Move (cm) + Left/Right Input X (cm.) - Output Move (cm) - - - Move (up and down) - - - - 0.000000000000000 - 0.000000000000000 - - - - - 90.000000000000000 - 0.000000000000000 - + Output X (cm.) - - - - 50 - - - 180 + + + + + 260 + 240 + + + + + 260 + 240 + - 255 + 85 0 - 0 + 255 @@ -453,40 +376,31 @@ background-color: rgb(255, 255, 255); - Input Move (cm) + Up/Down Input Y (cm.) - Output Move (cm) - - - Move (forward and backward) - - - - 0.000000000000000 - 0.000000000000000 - - - - - 90.000000000000000 - 0.000000000000000 - + Output Y (cm.) - - - - 50 - - - 180 + + + + + 260 + 240 + + + + + 260 + 240 + 255 - 255 + 0 0 @@ -498,87 +412,53 @@ background-color: rgb(255, 255, 255); - Input Move (cm) + Forward/Backward Input Z (cm.) - Output Move (cm) - - - Move (left and right) - - - - 0.000000000000000 - 0.000000000000000 - - - - - 90.000000000000000 - 0.000000000000000 - - - - - - - - NeutralZone + Output Z (cm.) - - - - 50 + + + + + 16777215 + 25 + - - - - - NeutralZone + Left-click the graph to place a new point, right-click a point to remove. Left-click and drag to move a point. - - - - - - NeutralZone + + true - - - 50 - + + + + 170 + 140 + + + + image: url(:/images/translation_DOFs.png); + + + + + -40 + 0 + 260 + 140 + + + + - - - - 50 - - - - - - - - - - 170 - 140 - - - - image: url(:/images/translation_DOFs.png); - - - - - @@ -680,208 +560,15 @@ background-color: rgb(255, 255, 255); - QBezierConfigurator + QFunctionConfigurator QWidget -
qbezierconfigurator.h
+
qfunctionconfigurator.h
- - - curveYaw - valueNeutralZoneChanged(int) - spinNZ_Yaw - setValue(int) - - - 268 - 114 - - - 593 - 125 - - - - - spinNZ_Yaw - valueChanged(int) - curveYaw - setNeutralZone(int) - - - 588 - 115 - - - 296 - 110 - - - - - curvePitch - valueNeutralZoneChanged(int) - spinNZ_Pitch - setValue(int) - - - 321 - 280 - - - 576 - 289 - - - - - spinNZ_Pitch - valueChanged(int) - curvePitch - setNeutralZone(int) - - - 629 - 287 - - - 334 - 285 - - - - - curveRoll - valueNeutralZoneChanged(int) - spinNZ_Roll - setValue(int) - - - 322 - 423 - - - 589 - 447 - - - - - spinNZ_Roll - valueChanged(int) - curveRoll - setNeutralZone(int) - - - 618 - 446 - - - 257 - 464 - - - - - curveX - valueNeutralZoneChanged(int) - spinNZ_X - setValue(int) - - - 312 - 107 - - - 568 - 126 - - - - - spinNZ_X - valueChanged(int) - curveX - setNeutralZone(int) - - - 548 - 125 - - - 322 - 142 - - - - - curveY - valueNeutralZoneChanged(int) - spinNZ_Y - setValue(int) - - - 282 - 261 - - - 569 - 286 - - - - - spinNZ_Y - valueChanged(int) - curveY - setNeutralZone(int) - - - 549 - 282 - - - 342 - 292 - - - - - curveZ - valueNeutralZoneChanged(int) - spinNZ_Z - setValue(int) - - - 363 - 417 - - - 571 - 445 - - - - - spinNZ_Z - valueChanged(int) - curveZ - setNeutralZone(int) - - - 546 - 444 - - - 316 - 447 - - - - + startEngineClicked() stopEngineClicked() diff --git a/FaceTrackNoIR/FaceTrackNoIR.cpp b/FaceTrackNoIR/FaceTrackNoIR.cpp index afa5f9ef..3e0d6628 100644 --- a/FaceTrackNoIR/FaceTrackNoIR.cpp +++ b/FaceTrackNoIR/FaceTrackNoIR.cpp @@ -23,6 +23,7 @@ *********************************************************************************/ /* Modifications (last one on top): + 20120717 - WVR: FunctionConfig is now used for the Curves, instead of BezierConfig. 20120427 - WVR: The Protocol-code was already in separate DLLs, but the ListBox was still filled ´statically´. Now, a Dir() of the EXE-folder is done, to locate Protocol-DLLs. The Icons were also moved to the DLLs 20120317 - WVR: The Filter and Tracker-code was moved to separate DLLs. The calling-method @@ -38,6 +39,7 @@ */ #include "FaceTrackNoIR.h" #include "tracker.h" +//#include "FunctionConfig.h" //#define USE_VISAGE @@ -709,7 +711,7 @@ void FaceTrackNoIR::startTracker( ) { // // Start the timer to update the head-pose (digits and 'man in black') // - timUpdateHeadPose->start(10); + timUpdateHeadPose->start(50); ui.lblX->setVisible(true); ui.lblY->setVisible(true); @@ -1126,7 +1128,7 @@ importGetTrackerDialog getTracker; ui.iconcomboProtocol->clear(); for ( int i = 0; i < protocolFileList.size(); i++) { - qDebug() << "createIconGroupBox says: ProtocolName = " << protocolFileList.at(i); +// qDebug() << "createIconGroupBox says: ProtocolName = " << protocolFileList.at(i); // // Delete the existing QDialog @@ -1148,7 +1150,7 @@ importGetTrackerDialog getTracker; pProtocolDialog = ptrXyz; pProtocolDialog->getFullName( protocolName ); pProtocolDialog->getIcon( protocolIcon ); - qDebug() << "FaceTrackNoIR::showServerControls GetProtocolDialog Function Resolved!"; +// qDebug() << "FaceTrackNoIR::showServerControls GetProtocolDialog Function Resolved!"; } else { qDebug() << "FaceTrackNoIR::showServerControls Function NOT Resolved!"; @@ -1177,7 +1179,7 @@ importGetTrackerDialog getTracker; ui.iconcomboFilter->clear(); for ( int i = 0; i < filterFileList.size(); i++) { - qDebug() << "createIconGroupBox says: FilterName = " << filterFileList.at(i); +// qDebug() << "createIconGroupBox says: FilterName = " << filterFileList.at(i); // // Delete the existing QDialog @@ -1199,7 +1201,7 @@ importGetTrackerDialog getTracker; pFilterDialog = ptrXyz; pFilterDialog->getFullName( filterName ); pFilterDialog->getIcon( filterIcon ); - qDebug() << "FaceTrackNoIR::showServerControls GetFilterDialog Function Resolved!"; +// qDebug() << "FaceTrackNoIR::showServerControls GetFilterDialog Function Resolved!"; } else { qDebug() << "FaceTrackNoIR::showServerControls Function NOT Resolved!"; @@ -1228,7 +1230,7 @@ importGetTrackerDialog getTracker; ui.iconcomboTrackerSource->clear(); for ( int i = 0; i < trackerFileList.size(); i++) { - qDebug() << "createIconGroupBox says: TrackerName = " << trackerFileList.at(i); +// qDebug() << "createIconGroupBox says: TrackerName = " << trackerFileList.at(i); // // Delete the existing QDialog @@ -1250,7 +1252,7 @@ importGetTrackerDialog getTracker; pTrackerDialog = ptrXyz; pTrackerDialog->getFullName( trackerName ); pTrackerDialog->getIcon( trackerIcon ); - qDebug() << "FaceTrackNoIR::showServerControls GetTrackerDialog Function Resolved!"; +// qDebug() << "FaceTrackNoIR::showServerControls GetTrackerDialog Function Resolved!"; } else { qDebug() << "FaceTrackNoIR::showServerControls Function NOT Resolved!"; @@ -1911,12 +1913,25 @@ QWidget( parent , f) connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); - connect(ui.curveYaw, SIGNAL(BezierCurveChanged(bool)), this, SLOT(curveChanged(bool))); - connect(ui.curvePitch, SIGNAL(BezierCurveChanged(bool)), this, SLOT(curveChanged(bool))); - connect(ui.curveRoll, SIGNAL(BezierCurveChanged(bool)), this, SLOT(curveChanged(bool))); - connect(ui.curveX, SIGNAL(BezierCurveChanged(bool)), this, SLOT(curveChanged(bool))); - connect(ui.curveY, SIGNAL(BezierCurveChanged(bool)), this, SLOT(curveChanged(bool))); - connect(ui.curveZ, SIGNAL(BezierCurveChanged(bool)), this, SLOT(curveChanged(bool))); + ui.qFunctionX->setConfig(Tracker::X.curvePtr); + connect(ui.qFunctionX, SIGNAL(CurveChanged(bool)), this, SLOT(curveChanged(bool))); + ui.qFunctionY->setConfig(Tracker::Y.curvePtr); + connect(ui.qFunctionY, SIGNAL(CurveChanged(bool)), this, SLOT(curveChanged(bool))); + ui.qFunctionZ->setConfig(Tracker::Z.curvePtr); + connect(ui.qFunctionZ, SIGNAL(CurveChanged(bool)), this, SLOT(curveChanged(bool))); + + ui.qFunctionYaw->setConfig(Tracker::Yaw.curvePtr); + 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); + connect(ui.qFunctionPitch, SIGNAL(CurveChanged(bool)), this, SLOT(curveChanged(bool))); + ui.qFunctionPitchDown->setConfig(Tracker::Pitch.curvePtrAlt); + connect(ui.qFunctionPitchDown, SIGNAL(CurveChanged(bool)), this, SLOT(curveChanged(bool))); + + ui.qFunctionRoll->setConfig(Tracker::Roll.curvePtr); + connect(ui.qFunctionRoll, SIGNAL(CurveChanged(bool)), this, SLOT(curveChanged(bool))); // Load the settings from the current .INI-file loadSettings(); @@ -1982,7 +1997,6 @@ void CurveConfigurationDialog::loadSettings() { int NeutralZone; int sensYaw, sensPitch, sensRoll; int sensX, sensY, sensZ; -QPointF point1, point2, point3, point4; qDebug() << "loadSettings says: Starting "; QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // Registry settings (in HK_USER) @@ -2003,43 +2017,10 @@ QPointF point1, point2, point3, point4; iniFile.endGroup (); - iniFile.beginGroup ( "Curves" ); - getCurvePoints( &iniFile, "Yaw_", &point1, &point2, &point3, &point4, NeutralZone, sensYaw, 50, 180 ); - ui.curveYaw->setPointOne( point1 ); - ui.curveYaw->setPointTwo( point2 ); - ui.curveYaw->setPointThree( point3 ); - ui.curveYaw->setPointFour( point4 ); - - getCurvePoints( &iniFile, "Pitch_", &point1, &point2, &point3, &point4, NeutralZone, sensPitch, 50, 180 ); - ui.curvePitch->setPointOne( point1 ); - ui.curvePitch->setPointTwo( point2 ); - ui.curvePitch->setPointThree( point3 ); - ui.curvePitch->setPointFour( point4 ); - - getCurvePoints( &iniFile, "Roll_", &point1, &point2, &point3, &point4, NeutralZone, sensRoll, 50, 180 ); - ui.curveRoll->setPointOne( point1 ); - ui.curveRoll->setPointTwo( point2 ); - ui.curveRoll->setPointThree( point3 ); - ui.curveRoll->setPointFour( point4 ); - - getCurvePoints( &iniFile, "X_", &point1, &point2, &point3, &point4, NeutralZone, sensX, 50, 180 ); - ui.curveX->setPointOne( point1 ); - ui.curveX->setPointTwo( point2 ); - ui.curveX->setPointThree( point3 ); - ui.curveX->setPointFour( point4 ); - - getCurvePoints( &iniFile, "Y_", &point1, &point2, &point3, &point4, NeutralZone, sensY, 50, 180 ); - ui.curveY->setPointOne( point1 ); - ui.curveY->setPointTwo( point2 ); - ui.curveY->setPointThree( point3 ); - ui.curveY->setPointFour( point4 ); - - getCurvePoints( &iniFile, "Z_", &point1, &point2, &point3, &point4, NeutralZone, sensZ, 50, 180 ); - ui.curveZ->setPointOne( point1 ); - ui.curveZ->setPointTwo( point2 ); - ui.curveZ->setPointThree( point3 ); - ui.curveZ->setPointFour( point4 ); - iniFile.endGroup (); + ui.qFunctionYaw->loadSettings(iniFile); + ui.qFunctionPitch->loadSettings(iniFile); + ui.qFunctionPitchDown->loadSettings(iniFile); + ui.qFunctionRoll->loadSettings(iniFile); settingsDirty = false; @@ -2057,38 +2038,11 @@ void CurveConfigurationDialog::save() { QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) - iniFile.beginGroup ( "Curves" ); - iniFile.setValue ("Yaw_point1", ui.curveYaw->getPointOne() ); - iniFile.setValue ("Yaw_point2", ui.curveYaw->getPointTwo() ); - iniFile.setValue ("Yaw_point3", ui.curveYaw->getPointThree() ); - iniFile.setValue ("Yaw_point4", ui.curveYaw->getPointFour() ); - - iniFile.setValue ("Pitch_point1", ui.curvePitch->getPointOne() ); - iniFile.setValue ("Pitch_point2", ui.curvePitch->getPointTwo() ); - iniFile.setValue ("Pitch_point3", ui.curvePitch->getPointThree() ); - iniFile.setValue ("Pitch_point4", ui.curvePitch->getPointFour() ); - - iniFile.setValue ("Roll_point1", ui.curveRoll->getPointOne() ); - iniFile.setValue ("Roll_point2", ui.curveRoll->getPointTwo() ); - iniFile.setValue ("Roll_point3", ui.curveRoll->getPointThree() ); - iniFile.setValue ("Roll_point4", ui.curveRoll->getPointFour() ); - - iniFile.setValue ("X_point1", ui.curveX->getPointOne() ); - iniFile.setValue ("X_point2", ui.curveX->getPointTwo() ); - iniFile.setValue ("X_point3", ui.curveX->getPointThree() ); - iniFile.setValue ("X_point4", ui.curveX->getPointFour() ); - - iniFile.setValue ("Y_point1", ui.curveY->getPointOne() ); - iniFile.setValue ("Y_point2", ui.curveY->getPointTwo() ); - iniFile.setValue ("Y_point3", ui.curveY->getPointThree() ); - iniFile.setValue ("Y_point4", ui.curveY->getPointFour() ); - - iniFile.setValue ("Z_point1", ui.curveZ->getPointOne() ); - iniFile.setValue ("Z_point2", ui.curveZ->getPointTwo() ); - iniFile.setValue ("Z_point3", ui.curveZ->getPointThree() ); - iniFile.setValue ("Z_point4", ui.curveZ->getPointFour() ); - - iniFile.endGroup (); + ui.qFunctionYaw->saveSettings(iniFile); + ui.qFunctionPitch->saveSettings(iniFile); + ui.qFunctionPitchDown->saveSettings(iniFile); + ui.qFunctionRoll->saveSettings(iniFile); + settingsDirty = false; // diff --git a/FaceTrackNoIR/FaceTrackNoIR.vcproj b/FaceTrackNoIR/FaceTrackNoIR.vcproj index e682f785..c6732a93 100644 --- a/FaceTrackNoIR/FaceTrackNoIR.vcproj +++ b/FaceTrackNoIR/FaceTrackNoIR.vcproj @@ -47,7 +47,7 @@ OmitFramePointers="false" EnableFiberSafeOptimizations="false" WholeProgramOptimization="false" - AdditionalIncludeDirectories=".\GeneratedFiles;"$(QTDIR)\include";".\GeneratedFiles\$(ConfigurationName)";"$(QTDIR)\include\QtCore";"$(QTDIR)\include\QtNetwork";"$(QTDIR)\include\QtGui";"$(QTDIR)\include\QtOpenGL";"$(QTDIR)\include\QtWebKit";"$(QTDIR)\include\QtTest";"$(SolutionDir)\FTNoIR_Tracker_UDP";"$(SolutionDir)\FTNoIR_Tracker_UDP\GeneratedFiles";"$(SolutionDir)\FTNoIR_Filter_EWMA2";"C:\Program Files (x86)\Microsoft DirectX SDK (February 2010)\Include";C:\Project\FaceTrackNoIR\VS2005\QBezierConfigurator\QBezierConfigurator" + AdditionalIncludeDirectories=".\GeneratedFiles;"$(QTDIR)\include";".\GeneratedFiles\$(ConfigurationName)";"$(QTDIR)\include\QtCore";"$(QTDIR)\include\QtNetwork";"$(QTDIR)\include\QtGui";"$(QTDIR)\include\QtOpenGL";"$(QTDIR)\include\QtWebKit";"$(QTDIR)\include\QtTest";"$(SolutionDir)\FTNoIR_Tracker_UDP";"$(SolutionDir)\FTNoIR_Tracker_UDP\GeneratedFiles";"$(SolutionDir)\FTNoIR_Filter_EWMA2";"C:\Program Files (x86)\Microsoft DirectX SDK (February 2010)\Include"" PreprocessorDefinitions="UNICODE;WIN32;QT_LARGEFILE_SUPPORT;QT_THREAD_SUPPORT;QT_NO_DEBUG;QT_CORE_LIB;QT_GUI_LIB;QT_OPENGL_LIB;QT_NETWORK_LIB;QT_DLL" RuntimeLibrary="2" FloatingPointModel="2" @@ -70,7 +70,7 @@ /> @@ -264,7 +264,7 @@ @@ -290,7 +290,7 @@ @@ -316,7 +316,7 @@ @@ -342,7 +342,7 @@ @@ -372,7 +372,7 @@ diff --git a/FaceTrackNoIR/FaceTrackNoIR.vcproj.VRIEND200810.Wim.user b/FaceTrackNoIR/FaceTrackNoIR.vcproj.VRIEND200810.Wim.user deleted file mode 100644 index aaaa8518..00000000 --- a/FaceTrackNoIR/FaceTrackNoIR.vcproj.VRIEND200810.Wim.user +++ /dev/null @@ -1,65 +0,0 @@ - - - - - - - - - - - diff --git a/FaceTrackNoIR/tracker.cpp b/FaceTrackNoIR/tracker.cpp index 49417733..2d4c5917 100644 --- a/FaceTrackNoIR/tracker.cpp +++ b/FaceTrackNoIR/tracker.cpp @@ -91,12 +91,12 @@ T6DOF Tracker::target_camera(0,0,0,0,0,0); T6DOF Tracker::new_camera(0,0,0,0,0,0); T6DOF Tracker::output_camera(0,0,0,0,0,0); // Position sent to game protocol -THeadPoseDOF Tracker::Pitch; // One structure for each of 6DOF's -THeadPoseDOF Tracker::Yaw; -THeadPoseDOF Tracker::Roll; -THeadPoseDOF Tracker::X; -THeadPoseDOF Tracker::Y; -THeadPoseDOF Tracker::Z; +THeadPoseDOF Tracker::Pitch("PitchUp", "PitchDown"); // One structure for each of 6DOF's +THeadPoseDOF Tracker::Yaw("Yaw", ""); +THeadPoseDOF Tracker::Roll("Roll", ""); +THeadPoseDOF Tracker::X("X",""); +THeadPoseDOF Tracker::Y("Y",""); +THeadPoseDOF Tracker::Z("Z",""); TShortKey Tracker::CenterKey; // ShortKey to Center headposition TShortKey Tracker::StartStopKey; // ShortKey to Start/stop tracking @@ -234,6 +234,12 @@ Tracker::~Tracker() { ::WaitForSingleObject(m_WaitThread, INFINITE); } + // + // Remove the Tracker + // 20120615, WVR: As suggested by Stanislaw + if (pTracker) + pTracker.Release(); + // Close handles ::CloseHandle(m_StopThread); ::CloseHandle(m_WaitThread); @@ -516,12 +522,23 @@ T6DOF gameoutput_camera(0,0,0,0,0,0); new_camera.position.yaw = getSmoothFromList( &Yaw.rawList ) - Yaw.offset_headPos; new_camera.position.roll = getSmoothFromList( &Roll.rawList ) - Roll.offset_headPos; } - output_camera.position.x = X.invert * getOutputFromCurve(&X.curve, new_camera.position.x, X.NeutralZone, X.MaxInput); - output_camera.position.y = Y.invert * getOutputFromCurve(&Y.curve, new_camera.position.y, Y.NeutralZone, Y.MaxInput); - output_camera.position.z = Z.invert * getOutputFromCurve(&Z.curve, new_camera.position.z, Z.NeutralZone, Z.MaxInput); - output_camera.position.pitch = Pitch.invert * getOutputFromCurve(&Pitch.curve, new_camera.position.pitch, Pitch.NeutralZone, Pitch.MaxInput); - output_camera.position.yaw = Yaw.invert * getOutputFromCurve(&Yaw.curve, new_camera.position.yaw, Yaw.NeutralZone, Yaw.MaxInput); - output_camera.position.roll = Roll.invert * getOutputFromCurve(&Roll.curve, new_camera.position.roll, Roll.NeutralZone, Roll.MaxInput); + output_camera.position.x = X.invert * X.curvePtr->getValue(new_camera.position.x); + output_camera.position.y = Y.invert * Y.curvePtr->getValue(new_camera.position.y); + output_camera.position.z = Z.invert * Z.curvePtr->getValue(new_camera.position.z); + int altp = new_camera.position.pitch < 0; + output_camera.position.pitch = Pitch.invert * (altp ? Pitch.curvePtrAlt : Pitch.curvePtr)->getValue(new_camera.position.pitch); + ///output_camera.position.pitch = Pitch.invert * Pitch.curvePtr->getValue(new_camera.position.pitch); + output_camera.position.yaw = Yaw.invert * Yaw.curvePtr->getValue(new_camera.position.yaw); + output_camera.position.roll = Roll.invert * Roll.curvePtr->getValue(new_camera.position.roll); + + + X.curvePtr->setTrackingActive( true ); + Y.curvePtr->setTrackingActive( true ); + Z.curvePtr->setTrackingActive( true ); + Yaw.curvePtr->setTrackingActive( true ); + Pitch.curvePtr->setTrackingActive( true ); + Pitch.curvePtrAlt->setTrackingActive( true ); + Roll.curvePtr->setTrackingActive( true ); // // Reverse Axis. @@ -583,6 +600,13 @@ T6DOF gameoutput_camera(0,0,0,0,0,0); gameoutput_camera = output_camera + gamezero_camera; pProtocol->sendHeadposeToGame( &gameoutput_camera ); // degrees & centimeters } + X.curvePtr->setTrackingActive( false ); + Y.curvePtr->setTrackingActive( false ); + Z.curvePtr->setTrackingActive( false ); + Yaw.curvePtr->setTrackingActive( false ); + Pitch.curvePtr->setTrackingActive( false ); + Pitch.curvePtrAlt->setTrackingActive( false ); + Roll.curvePtr->setTrackingActive( false ); } } @@ -731,104 +755,6 @@ float sum = 0; return sum / rawList->size(); } -// -// Correct the Raw value, with the Neutral Zone supplied -// -//float Tracker::getCorrectedNewRaw ( float NewRaw, float rotNeutral ) { -// -// // -// // Return 0, if NewRaw is within the Neutral Zone -// // -// if ( fabs( NewRaw ) < rotNeutral ) { -// return 0.0f; -// } -// -// // -// // NewRaw is outside the zone. -// // Substract rotNeutral from the NewRaw -// // -// if ( NewRaw > 0.0f ) { -// return (NewRaw - rotNeutral); -// } -// else { -// return (NewRaw + rotNeutral); // Makes sense? -// } -// -//} - -// -// Implementation of an Exponentially Weighted Moving Average, used to serve as a low-pass filter. -// The code was adopted from Melchior Franz, who created it for FlightGear (aircraft.nas). -// -// The function takes the new value, the delta-time (sec) and a weighing coefficient (>0 and <1) -// All previous values are taken into account, the weight of this is determined by 'coeff'. -// -//float Tracker::lowPassFilter ( float newvalue, float *oldvalue, float dt, float coeff) { -//float c = 0.0f; -//float fil = 0.0f; -// -// c = dt / (coeff + dt); -// fil = (newvalue * c) + (*oldvalue * (1 - c)); -// *oldvalue = fil; -// -// return fil; -//} - -// -// Implementation of a Rate Limiter, used to eliminate spikes in the raw data. -// -// The function takes the new value, the delta-time (sec) and the positive max. slew-rate (engineering units/sec) -// -//float Tracker::rateLimiter ( float newvalue, float *oldvalue, float dt, float max_rate) { -//float rate = 0.0f; -//float clamped_value = 0.0f; -// -// rate = (newvalue - *oldvalue) / dt; -// clamped_value = newvalue; // If all is well, the newvalue is returned -// -// // -// // One max-rate is used for ramp-up and ramp-down -// // If the rate exceeds max_rate, return the maximum value that the max_rate allows -// // -// if (fabs(rate) > max_rate) { -// // -// // For ramp-down, apply a factor -1 to the max_rate -// // -// if (rate < 0.0f) { -// clamped_value = (-1.0f * dt * max_rate) + *oldvalue; -// } -// else { -// clamped_value = (dt * max_rate) + *oldvalue; -// } -// } -// *oldvalue = clamped_value; -// -// return clamped_value; -//} - -// -// Get the output from the curve. -// -float Tracker::getOutputFromCurve ( QPainterPath *curve, float input, float neutralzone, float maxinput ) { -float sign; - - sign = 1.0f; - if (input < 0.0f) { - sign = -1.0f; - } - - // - // Always return 0 inside the NeutralZone - // Always return max. when input larger than expected - // - if (fabs(input) > maxinput) return sign * curve->pointAtPercent(1.0).x(); - - // - // Return the value, derived from the Bezier-curve - // - return sign * curve->pointAtPercent((fabs(input))/maxinput).x(); -} - // // Load the current Settings from the currently 'active' INI-file. // @@ -836,7 +762,6 @@ 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) @@ -859,83 +784,6 @@ QPointF point1, point2, point3, point4; 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" ); - - // - // Create a new path and assign it to the curve. - // - getCurvePoints( &iniFile, "Yaw_", &point1, &point2, &point3, &point4, NeutralZone, sensYaw, 50, 180 ); - QPainterPath newYawCurve; - newYawCurve.moveTo( QPointF(0,0) ); - newYawCurve.lineTo( point1 ); - newYawCurve.cubicTo(point2, point3, point4); - - Yaw.NeutralZone = point1.y(); // Get the Neutral Zone - Yaw.MaxInput = point4.y(); // Get Maximum Input - Yaw.curve = newYawCurve; - - qDebug() << "loadSettings says: curve-elementcount = " << Yaw.curve.elementCount(); - - // Pitch - getCurvePoints( &iniFile, "Pitch_", &point1, &point2, &point3, &point4, NeutralZone, sensPitch, 50, 180 ); - QPainterPath newPitchCurve; - newPitchCurve.moveTo( QPointF(0,0) ); - newPitchCurve.lineTo( point1 ); - newPitchCurve.cubicTo(point2, point3, point4); - - Pitch.NeutralZone = point1.y(); // Get the Neutral Zone - Pitch.MaxInput = point4.y(); // Get Maximum Input - Pitch.curve = newPitchCurve; - - // Roll - getCurvePoints( &iniFile, "Roll_", &point1, &point2, &point3, &point4, NeutralZone, sensRoll, 50, 180 ); - QPainterPath newRollCurve; - newRollCurve.moveTo( QPointF(0,0) ); - newRollCurve.lineTo( point1 ); - newRollCurve.cubicTo(point2, point3, point4); - - Roll.NeutralZone = point1.y(); // Get the Neutral Zone - Roll.MaxInput = point4.y(); // Get Maximum Input - Roll.curve = newRollCurve; - - // X - getCurvePoints( &iniFile, "X_", &point1, &point2, &point3, &point4, NeutralZone, sensX, 50, 180 ); - QPainterPath newXCurve; - newXCurve.moveTo( QPointF(0,0) ); - newXCurve.lineTo( point1 ); - newXCurve.cubicTo(point2, point3, point4); - - X.NeutralZone = point1.y(); // Get the Neutral Zone - X.MaxInput = point4.y(); // Get Maximum Input - X.curve = newXCurve; - - // Y - getCurvePoints( &iniFile, "Y_", &point1, &point2, &point3, &point4, NeutralZone, sensY, 50, 180 ); - QPainterPath newYCurve; - newYCurve.moveTo( QPointF(0,0) ); - newYCurve.lineTo( point1 ); - newYCurve.cubicTo(point2, point3, point4); - - Y.NeutralZone = point1.y(); // Get the Neutral Zone - Y.MaxInput = point4.y(); // Get Maximum Input - Y.curve = newYCurve; - - // Z - getCurvePoints( &iniFile, "Z_", &point1, &point2, &point3, &point4, NeutralZone, sensZ, 50, 180 ); - QPainterPath newZCurve; - newZCurve.moveTo( QPointF(0,0) ); - newZCurve.lineTo( point1 ); - newZCurve.cubicTo(point2, point3, point4); - - Z.NeutralZone = point1.y(); // Get the Neutral Zone - Z.MaxInput = point4.y(); // Get Maximum Input - Z.curve = newZCurve; - - iniFile.endGroup (); - // // Read the keyboard shortcuts. // diff --git a/FaceTrackNoIR/tracker.h b/FaceTrackNoIR/tracker.h index a69218a1..c1eb61c6 100644 --- a/FaceTrackNoIR/tracker.h +++ b/FaceTrackNoIR/tracker.h @@ -3,8 +3,8 @@ * gamers from Holland, who don't like to pay much for * * head-tracking. * * * -* Copyright (C) 2010 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * +* Copyright (C) 2010 - 2012 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * * * * Homepage * * * This program is free software; you can redistribute it and/or modify it * @@ -20,6 +20,10 @@ * You should have received a copy of the GNU General Public License along * * with this program; if not, see . * *********************************************************************************/ +/* + Modifications (last one on top): + 20120717 - WVR: FunctionConfig is now used for the Curves, instead of BezierConfig. +*/ #ifndef __TRACKER_H__ #define __TRACKER_H__ @@ -37,6 +41,7 @@ #include "ExcelServer.h" // Excel-server (for analysing purposes) #include "FTNoIR_cxx_protocolserver.h" +#include "FunctionConfig.h" #include "..\ftnoir_tracker_base\FTNoIR_Tracker_base.h" #include "..\ftnoir_protocol_base\FTNoIR_Protocol_base.h" @@ -94,6 +99,20 @@ class FaceTrackNoIR; // pre-define parent-class to avoid circular includes // class THeadPoseDOF { public: + + THeadPoseDOF(QString primary, QString secondary = "") { + 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) + + curvePtr = new FunctionConfig(primary); // Create the Function-config for input-output translation + curvePtr->loadSettings(iniFile); // Load the settings from the INI-file + if (secondary != "") { + curvePtrAlt = new FunctionConfig(secondary); + curvePtrAlt->loadSettings(iniFile); + } + } + void initHeadPoseData(){ headPos = 0.0f; offset_headPos = 0.0f; @@ -116,7 +135,11 @@ public: int maxItems; // Maximum number of elements in rawList float prevPos; // Previous Position float prevRawPos; // Previous Raw Position - QPainterPath curve; // Bezier curve to translate input -> output +// QPainterPath curve; // Bezier curve to translate input -> output + + FunctionConfig* curvePtr; // Function to translate input -> output + FunctionConfig* curvePtrAlt; + int NeutralZone; // Neutral zone int MaxInput; // Maximum raw input float confidence; // Current confidence @@ -162,14 +185,6 @@ private: static void addHeadPose( THeadPoseData head_pose ); static void addRaw2List ( QList *rawList, float maxIndex, float raw ); - /** static member variables for saving the head pose **/ - static THeadPoseDOF Pitch; // Head-rotation X-direction (Up/Down) - static THeadPoseDOF Yaw; // Head-rotation Y-direction () - static THeadPoseDOF Roll; // Head-rotation Z-direction () - static THeadPoseDOF X; // Head-movement X-direction (Left/Right) - static THeadPoseDOF Y; // Head-movement Y-direction (Up/Down) - static THeadPoseDOF Z; // Head-movement Z-direction (To/From camera) - static TShortKey CenterKey; // ShortKey to Center headposition static TShortKey StartStopKey; // ShortKey to Start/stop tracking static TShortKey InhibitKey; // ShortKey to disable one or more axis during tracking @@ -207,6 +222,14 @@ public: Tracker( FaceTrackNoIR *parent ); ~Tracker(); + /** static member variables for saving the head pose **/ + static THeadPoseDOF Pitch; // Head-rotation X-direction (Up/Down) + static THeadPoseDOF Yaw; // Head-rotation Y-direction () + static THeadPoseDOF Roll; // Head-rotation Z-direction () + static THeadPoseDOF X; // Head-movement X-direction (Left/Right) + static THeadPoseDOF Y; // Head-movement Y-direction (Up/Down) + static THeadPoseDOF Z; // Head-movement Z-direction (To/From camera) + void setup(); // void registerHeadPoseCallback(); @@ -240,7 +263,7 @@ public: static float getSmoothFromList ( QList *rawList ); static float getDegreesFromRads ( float rads ) { return (rads * 57.295781f); } static float getRadsFromDegrees ( float degrees ) { return (degrees * 0.017453f); } - static float getOutputFromCurve ( QPainterPath *curve, float input, float neutralzone, float maxinput ); +// static float getOutputFromCurve ( QPainterPath *curve, float input, float neutralzone, float maxinput ); // For now, use one slider for all void setSmoothing(int x) { -- cgit v1.2.3