From 43734bf0f9fa8531b817943756157a2c459886a8 Mon Sep 17 00:00:00 2001 From: Wim Vriend Date: Mon, 28 Mar 2011 21:15:30 +0000 Subject: Added the display for the output-pose, with the 'man in black'. git-svn-id: svn+ssh://svn.code.sf.net/p/facetracknoir/code@59 19e81ba0-9b1a-49c3-bd6c-561e1906d5fb --- FaceTrackNoIR/FaceTrackNoIR.cpp | 47 +++++++- FaceTrackNoIR/FaceTrackNoIR.h | 6 +- FaceTrackNoIR/FaceTrackNoIR.ui | 98 +++++++++++----- FaceTrackNoIR/FaceTrackNoIR.vcproj | 235 ++++++++++++++++++++++++++++++++++++- FaceTrackNoIR/tracker.cpp | 156 ++++++++++++------------ FaceTrackNoIR/tracker.h | 6 + 6 files changed, 434 insertions(+), 114 deletions(-) (limited to 'FaceTrackNoIR') diff --git a/FaceTrackNoIR/FaceTrackNoIR.cpp b/FaceTrackNoIR/FaceTrackNoIR.cpp index 029ed5b7..51acf6ec 100644 --- a/FaceTrackNoIR/FaceTrackNoIR.cpp +++ b/FaceTrackNoIR/FaceTrackNoIR.cpp @@ -23,6 +23,7 @@ *********************************************************************************/ /* Modifications (last one on top): + 20110328 - WVR: Added the display for output-pose. 20110207 - WVR: RadioButtons for 'Stop engine' added. It is now possible to choose Stop or Keep tracking. 20110109 - WVR: Added minimizeTaskBar option added. It is now possible to choose minimized or tray. */ @@ -34,6 +35,7 @@ #include "FGServer.h" #include "FTNServer.h" + // // Setup the Main Dialog // @@ -67,6 +69,14 @@ QMainWindow(parent, flags) startTracker(); showMinimized(); } + + Q_INIT_RESOURCE(PoseWidget); + _pose_display = new GLWidget(ui.widget4logo, 0); + _pose_display->rotateBy(0, 0, 0); + + ui.lcdNumOutputRotX->setVisible(false); + ui.lcdNumOutputRotY->setVisible(false); + ui.lcdNumOutputRotZ->setVisible(false); } /** sets up all objects and connections to buttons */ @@ -148,7 +158,6 @@ void FaceTrackNoIR::setupFaceTrackNoIR() { //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 **/ @@ -180,7 +189,6 @@ FaceTrackNoIR::~FaceTrackNoIR() { break; } } - } // @@ -562,16 +570,31 @@ void FaceTrackNoIR::startTracker( ) { timMinimizeFTN->setSingleShot( true ); timMinimizeFTN->start(timevalue); } + + // + // Start the timer to update the head-pose (digits and 'man in black') + // + timUpdateHeadPose->start(10); + ui.lcdNumOutputRotX->setVisible(true); + ui.lcdNumOutputRotY->setVisible(true); + ui.lcdNumOutputRotZ->setVisible(true); } /** stop tracking the face **/ void FaceTrackNoIR::stopTracker( ) { // - // Delete the video-display. + // Stop displaying the head-pose. // -// ui.video_frame->hide(); + timUpdateHeadPose->stop(); + _pose_display->rotateBy(0, 0, 0); + ui.lcdNumOutputRotX->setVisible(false); + ui.lcdNumOutputRotY->setVisible(false); + ui.lcdNumOutputRotZ->setVisible(false); + // + // Delete the tracker (after stopping things and all). + // if ( tracker ) { qDebug() << "stopTracker says: Deleting tracker!"; delete tracker; @@ -651,6 +674,10 @@ void FaceTrackNoIR::setUseFilter( int set ) { void FaceTrackNoIR::showHeadPose() { THeadPoseData newdata; + // + // Get the pose and also display it. + // Updating the pose from within the Tracker-class caused crashes... + // 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)); @@ -659,6 +686,18 @@ THeadPoseData newdata; 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)); + + // + // Get the output-pose and also display it. + // + if (_pose_display) { + Tracker::getOutputHeadPose(&newdata); + _pose_display->rotateBy(newdata.pitch, newdata.yaw, newdata.roll); + + ui.lcdNumOutputRotX->display((double) (((int)(newdata.yaw * 10.0f))/10.0f)); + ui.lcdNumOutputRotY->display((double) (((int)(newdata.pitch * 10.0f))/10.0f)); + ui.lcdNumOutputRotZ->display((double) (((int)(newdata.roll * 10.0f))/10.0f)); + } } /** set the redhold from the slider **/ diff --git a/FaceTrackNoIR/FaceTrackNoIR.h b/FaceTrackNoIR/FaceTrackNoIR.h index 7f73b5af..68c9a744 100644 --- a/FaceTrackNoIR/FaceTrackNoIR.h +++ b/FaceTrackNoIR/FaceTrackNoIR.h @@ -35,6 +35,8 @@ #include #include +#include "../FTNoIR_PoseWidget/glwidget.h" + #include "ui_FaceTrackNoIR.h" #include "ui_FTNoIR_KeyboardShortcuts.h" #include "ui_FTNoIR_Preferences.h" @@ -83,14 +85,14 @@ private: ITrackerDialogPtr pTrackerDialog; // Pointer to Tracker dialog instance (in DLL) - /** face api variables **/ -// VideoDisplayWidget *_display; + /** Widget variables **/ QVBoxLayout *l; QWidget *_engine_controls; QWidget *_server_controls; QWidget *_preferences; QWidget *_keyboard_shortcuts; QWidget *_curve_config; + GLWidget *_pose_display; /** QT objects **/ QDialog aboutDialog; diff --git a/FaceTrackNoIR/FaceTrackNoIR.ui b/FaceTrackNoIR/FaceTrackNoIR.ui index dd307544..48d231ac 100644 --- a/FaceTrackNoIR/FaceTrackNoIR.ui +++ b/FaceTrackNoIR/FaceTrackNoIR.ui @@ -11,7 +11,7 @@ 0 0 925 - 398 + 396 @@ -238,45 +238,89 @@ Support FaceTrackNoIR! - + - 0 - 0 - 90 - 90 + 100 + 60 + 41 + 21 - - - 0 - 0 - + + false - - - 90 - 90 - + + color: rgb(0, 255, 0); - - - 16777215 - 90 - + + QFrame::NoFrame + + + QFrame::Raised + + + 3 + + + QLCDNumber::Flat + + + + + + 150 + 60 + 41 + 21 + + + + false - QFrame#logoInstitute { - background:#595959 url(UIElements/logoFaceTrackNoIR.png) no-repeat; -border:none; -} + color: rgb(0, 255, 0); - QFrame::StyledPanel + QFrame::NoFrame QFrame::Raised + + 3 + + + QLCDNumber::Flat + + + + + + 200 + 60 + 41 + 21 + + + + false + + + color: rgb(0, 255, 0); + + + QFrame::NoFrame + + + QFrame::Raised + + + 3 + + + QLCDNumber::Flat + @@ -1019,7 +1063,7 @@ color:white; - + diff --git a/FaceTrackNoIR/FaceTrackNoIR.vcproj b/FaceTrackNoIR/FaceTrackNoIR.vcproj index 10245e4b..10d2f8c7 100644 --- a/FaceTrackNoIR/FaceTrackNoIR.vcproj +++ b/FaceTrackNoIR/FaceTrackNoIR.vcproj @@ -70,7 +70,7 @@ /> + + @@ -499,6 +503,32 @@ RelativePath=".\FTTypes.h" > + + + + + + + + @@ -872,6 +902,26 @@ /> + + + + + + + + @@ -1021,6 +1071,18 @@ /> + + + + + @@ -1204,6 +1266,29 @@ /> + + + + + + + + @@ -1301,10 +1386,156 @@ RelativePath=".\images\Freetrack.ico" > + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + StartTracker( mainApp->winId() ); } @@ -503,41 +488,41 @@ void Tracker::run() { if (Tracker::do_tracking && Tracker::confid) { // Pitch - target_camera_position.x = getSmoothFromList( &X.rawList ) - X.offset_headPos; - target_camera_position.y = getSmoothFromList( &Y.rawList ) - Y.offset_headPos; - target_camera_position.z = getSmoothFromList( &Z.rawList ) - Z.offset_headPos; - target_camera_position.pitch = getSmoothFromList( &Pitch.rawList ) - Pitch.offset_headPos; - target_camera_position.yaw = getSmoothFromList( &Yaw.rawList ) - Yaw.offset_headPos; - target_camera_position.roll = getSmoothFromList( &Roll.rawList ) - Roll.offset_headPos; + target_camera.position.x = getSmoothFromList( &X.rawList ) - X.offset_headPos; + target_camera.position.y = getSmoothFromList( &Y.rawList ) - Y.offset_headPos; + target_camera.position.z = getSmoothFromList( &Z.rawList ) - Z.offset_headPos; + target_camera.position.pitch = getSmoothFromList( &Pitch.rawList ) - Pitch.offset_headPos; + target_camera.position.yaw = getSmoothFromList( &Yaw.rawList ) - Yaw.offset_headPos; + target_camera.position.roll = getSmoothFromList( &Roll.rawList ) - Roll.offset_headPos; if (Tracker::useFilter && pFilter) { - pFilter->FilterHeadPoseData(¤t_camera_position, &target_camera_position, &new_camera_position, Tracker::Pitch.newSample); + pFilter->FilterHeadPoseData(¤t_camera.position, &target_camera.position, &new_camera.position, Tracker::Pitch.newSample); } else { - new_camera_position.x = getSmoothFromList( &X.rawList ) - X.offset_headPos; - new_camera_position.y = getSmoothFromList( &Y.rawList ) - Y.offset_headPos; - new_camera_position.z = getSmoothFromList( &Z.rawList ) - Z.offset_headPos; - new_camera_position.pitch = getSmoothFromList( &Pitch.rawList ) - Pitch.offset_headPos; - new_camera_position.yaw = getSmoothFromList( &Yaw.rawList ) - Yaw.offset_headPos; - new_camera_position.roll = getSmoothFromList( &Roll.rawList ) - Roll.offset_headPos; + output_camera.position.x = getSmoothFromList( &X.rawList ) - X.offset_headPos; + output_camera.position.y = getSmoothFromList( &Y.rawList ) - Y.offset_headPos; + output_camera.position.z = getSmoothFromList( &Z.rawList ) - Z.offset_headPos; + output_camera.position.pitch = getSmoothFromList( &Pitch.rawList ) - Pitch.offset_headPos; + output_camera.position.yaw = getSmoothFromList( &Yaw.rawList ) - Yaw.offset_headPos; + output_camera.position.roll = getSmoothFromList( &Roll.rawList ) - Roll.offset_headPos; } - new_camera_position.x = X.invert * getOutputFromCurve(&X.curve, new_camera_position.x, X.NeutralZone, X.MaxInput); - new_camera_position.y = Y.invert * getOutputFromCurve(&Y.curve, new_camera_position.y, Y.NeutralZone, Y.MaxInput); - new_camera_position.z = Z.invert * getOutputFromCurve(&Z.curve, new_camera_position.z, Z.NeutralZone, Z.MaxInput); - new_camera_position.pitch = Pitch.invert * getOutputFromCurve(&Pitch.curve, new_camera_position.pitch, Pitch.NeutralZone, Pitch.MaxInput); - new_camera_position.yaw = Yaw.invert * getOutputFromCurve(&Yaw.curve, new_camera_position.yaw, Yaw.NeutralZone, Yaw.MaxInput); - new_camera_position.roll = Roll.invert * getOutputFromCurve(&Roll.curve, new_camera_position.roll, Roll.NeutralZone, Roll.MaxInput); + 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); // // Reset value for the selected axis, if inhibition is active // if (Tracker::do_inhibit) { - if (InhibitKey.doPitch) new_camera_position.pitch = 0.0f; - if (InhibitKey.doYaw) new_camera_position.yaw = 0.0f; - if (InhibitKey.doRoll) new_camera_position.roll = 0.0f; - if (InhibitKey.doX) new_camera_position.x = 0.0f; - if (InhibitKey.doY) new_camera_position.y = 0.0f; - if (InhibitKey.doZ) new_camera_position.z = 0.0f; + if (InhibitKey.doPitch) output_camera.position.pitch = 0.0f; + if (InhibitKey.doYaw) output_camera.position.yaw = 0.0f; + if (InhibitKey.doRoll) output_camera.position.roll = 0.0f; + if (InhibitKey.doX) output_camera.position.x = 0.0f; + if (InhibitKey.doY) output_camera.position.y = 0.0f; + if (InhibitKey.doZ) output_camera.position.z = 0.0f; } // @@ -545,32 +530,32 @@ void Tracker::run() { // // Free-track if (selectedClient == FREE_TRACK) { - server_Game->setHeadRotX( new_camera_position.pitch ); // degrees - server_Game->setHeadRotY( new_camera_position.yaw ); - server_Game->setHeadRotZ( new_camera_position.roll ); + server_Game->setHeadRotX( output_camera.position.pitch ); // degrees + server_Game->setHeadRotY( output_camera.position.yaw ); + server_Game->setHeadRotZ( output_camera.position.roll ); - server_Game->setHeadPosX( new_camera_position.x ); // centimeters - server_Game->setHeadPosY( new_camera_position.y ); - server_Game->setHeadPosZ( new_camera_position.z ); + server_Game->setHeadPosX( output_camera.position.x ); // centimeters + server_Game->setHeadPosY( output_camera.position.y ); + server_Game->setHeadPosZ( output_camera.position.z ); } // All Protocol server(s) if (server_Game) { - 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->setVirtPosY ( new_camera_position.y ); - server_Game->setVirtPosZ ( new_camera_position.z ); + server_Game->setVirtRotX ( output_camera.position.pitch ); // degrees + server_Game->setVirtRotY ( output_camera.position.yaw ); + server_Game->setVirtRotZ ( output_camera.position.roll ); + server_Game->setVirtPosX ( output_camera.position.x ); // centimeters + server_Game->setVirtPosY ( output_camera.position.y ); + server_Game->setVirtPosZ ( output_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)); +// 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)); +//// 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 @@ -582,12 +567,12 @@ void Tracker::run() { debug_Client->setHeadPosY( Tracker::Y.headPos ); debug_Client->setHeadPosZ( Tracker::Z.headPos ); - debug_Client->setVirtRotX ( new_camera_position.pitch ); // degrees - debug_Client->setVirtRotY ( new_camera_position.yaw ); - debug_Client->setVirtRotZ ( new_camera_position.roll ); - debug_Client->setVirtPosX ( new_camera_position.x ); // centimeters - debug_Client->setVirtPosY ( new_camera_position.y ); - debug_Client->setVirtPosZ ( new_camera_position.z ); + debug_Client->setVirtRotX ( new_camera.position.pitch ); // degrees + debug_Client->setVirtRotY ( new_camera.position.yaw ); + debug_Client->setVirtRotZ ( new_camera.position.roll ); + debug_Client->setVirtPosX ( new_camera.position.x ); // centimeters + debug_Client->setVirtPosY ( new_camera.position.y ); + debug_Client->setVirtPosZ ( new_camera.position.z ); # endif @@ -748,6 +733,19 @@ void Tracker::getHeadPose( THeadPoseData *data ) { data->roll = Tracker::Roll.headPos - Tracker::Roll.offset_headPos; } +// +// Set the filter-value from the GUI. +// +void Tracker::getOutputHeadPose( THeadPoseData *data ) { + data->x = output_camera.position.x; // centimeters + data->y = output_camera.position.y; + data->z = output_camera.position.z; + + data->pitch = output_camera.position.pitch; // degrees + data->yaw = output_camera.position.yaw; + data->roll = output_camera.position.roll; +} + // // Get the Smoothed value from the QList. // diff --git a/FaceTrackNoIR/tracker.h b/FaceTrackNoIR/tracker.h index bd29bf9f..3b7d7ca8 100644 --- a/FaceTrackNoIR/tracker.h +++ b/FaceTrackNoIR/tracker.h @@ -151,6 +151,11 @@ private: FTNoIR_Client selectedClient; FTNoIR_Face_Tracker selectedTracker; + static T6DOF current_camera; // Used for filtering + static T6DOF target_camera; + static T6DOF new_camera; + static T6DOF output_camera; + static ITrackerPtr pTracker; // Pointer to Tracker instance (in DLL) static IFilterPtr pFilter; // Pointer to Filter instance (in DLL) @@ -222,6 +227,7 @@ public: static void setPowCurve(int x); static void getHeadPose(THeadPoseData *data); // Return the current headpose data + static void getOutputHeadPose(THeadPoseData *data); // Return the current (processed) headpose data static float getSmoothFromList ( QList *rawList ); static float getDegreesFromRads ( float rads ) { return (rads * 57.295781f); } -- cgit v1.2.3