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 --- 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 +- 6 files changed, 250 insertions(+), 258 deletions(-) (limited to 'FaceTrackNoIR') 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); } -- cgit v1.2.3