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 --- FTNoIR_PoseWidget/PoseWidget.qrc | 10 ++ FTNoIR_PoseWidget/glwidget.cpp | 210 ++++++++++++++++++++++++++ FTNoIR_PoseWidget/glwidget.h | 72 +++++++++ FTNoIR_PoseWidget/images/side1.bmp | Bin 0 -> 44950 bytes FTNoIR_PoseWidget/images/side1.png | Bin 0 -> 9018 bytes FTNoIR_PoseWidget/images/side2.png | Bin 0 -> 2922 bytes FTNoIR_PoseWidget/images/side3.png | Bin 0 -> 2922 bytes FTNoIR_PoseWidget/images/side4.png | Bin 0 -> 2922 bytes FTNoIR_PoseWidget/images/side5.png | Bin 0 -> 2922 bytes FTNoIR_PoseWidget/images/side6.png | Bin 0 -> 4768 bytes FTNoIR_Tracker_Base/ftnoir_tracker_base.h | 16 ++ FaceTrackNoIR.suo | Bin 360960 -> 367104 bytes FaceTrackNoIR/FaceTrackNoIR.cpp | 47 +++++- FaceTrackNoIR/FaceTrackNoIR.h | 6 +- FaceTrackNoIR/FaceTrackNoIR.ui | 98 +++++++++---- FaceTrackNoIR/FaceTrackNoIR.vcproj | 235 +++++++++++++++++++++++++++++- FaceTrackNoIR/tracker.cpp | 156 ++++++++++---------- FaceTrackNoIR/tracker.h | 6 + bin/FaceTrackNoIR.exe | Bin 626688 -> 663552 bytes bin/Settings/Wings of Prey.ini | 8 +- faceAPI/main.cpp | 3 + 21 files changed, 749 insertions(+), 118 deletions(-) create mode 100644 FTNoIR_PoseWidget/PoseWidget.qrc create mode 100644 FTNoIR_PoseWidget/glwidget.cpp create mode 100644 FTNoIR_PoseWidget/glwidget.h create mode 100644 FTNoIR_PoseWidget/images/side1.bmp create mode 100644 FTNoIR_PoseWidget/images/side1.png create mode 100644 FTNoIR_PoseWidget/images/side2.png create mode 100644 FTNoIR_PoseWidget/images/side3.png create mode 100644 FTNoIR_PoseWidget/images/side4.png create mode 100644 FTNoIR_PoseWidget/images/side5.png create mode 100644 FTNoIR_PoseWidget/images/side6.png diff --git a/FTNoIR_PoseWidget/PoseWidget.qrc b/FTNoIR_PoseWidget/PoseWidget.qrc new file mode 100644 index 00000000..65038eba --- /dev/null +++ b/FTNoIR_PoseWidget/PoseWidget.qrc @@ -0,0 +1,10 @@ + + + images/side1.png + images/side2.png + images/side3.png + images/side4.png + images/side5.png + images/side6.png + + diff --git a/FTNoIR_PoseWidget/glwidget.cpp b/FTNoIR_PoseWidget/glwidget.cpp new file mode 100644 index 00000000..55b65619 --- /dev/null +++ b/FTNoIR_PoseWidget/glwidget.cpp @@ -0,0 +1,210 @@ +/******************************************************************************** +* FaceTrackNoIR This program is a private project of the some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2010 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* Adopted this widget from the 'textures' sample of the Nokia Qt toolkit. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +*********************************************************************************/ + +#include +#include + +#include "glwidget.h" + +GLWidget::GLWidget(QWidget *parent, QGLWidget *shareWidget) + : QGLWidget(parent, shareWidget) +{ + clearColor = Qt::black; + xRot = 0; + yRot = 0; + zRot = 0; + +#ifdef QT_OPENGL_ES_2 + program = 0; +#endif +} + +GLWidget::~GLWidget() +{ +} + +QSize GLWidget::minimumSizeHint() const +{ + return QSize(60, 60); +} + +QSize GLWidget::sizeHint() const +{ + return QSize(90, 90); +} + +void GLWidget::rotateBy(int xAngle, int yAngle, int zAngle) +{ + xRot = xAngle; + yRot = yAngle; + zRot = zAngle; + updateGL(); +} + +void GLWidget::setClearColor(const QColor &color) +{ + clearColor = color; + updateGL(); +} + +void GLWidget::initializeGL() +{ + makeObject(); + + glEnable(GL_DEPTH_TEST); + glEnable(GL_CULL_FACE); +#ifndef QT_OPENGL_ES_2 + glEnable(GL_TEXTURE_2D); +#endif + +#ifdef QT_OPENGL_ES_2 + +#define PROGRAM_VERTEX_ATTRIBUTE 0 +#define PROGRAM_TEXCOORD_ATTRIBUTE 1 + + QGLShader *vshader = new QGLShader(QGLShader::Vertex, this); + const char *vsrc = + "attribute highp vec4 vertex;\n" + "attribute mediump vec4 texCoord;\n" + "varying mediump vec4 texc;\n" + "uniform mediump mat4 matrix;\n" + "void main(void)\n" + "{\n" + " gl_Position = matrix * vertex;\n" + " texc = texCoord;\n" + "}\n"; + vshader->compileSourceCode(vsrc); + + QGLShader *fshader = new QGLShader(QGLShader::Fragment, this); + const char *fsrc = + "uniform sampler2D texture;\n" + "varying mediump vec4 texc;\n" + "void main(void)\n" + "{\n" + " gl_FragColor = texture2D(texture, texc.st);\n" + "}\n"; + fshader->compileSourceCode(fsrc); + + program = new QGLShaderProgram(this); + program->addShader(vshader); + program->addShader(fshader); + program->bindAttributeLocation("vertex", PROGRAM_VERTEX_ATTRIBUTE); + program->bindAttributeLocation("texCoord", PROGRAM_TEXCOORD_ATTRIBUTE); + program->link(); + + program->bind(); + program->setUniformValue("texture", 0); + +#endif +} + +void GLWidget::paintGL() +{ + qglClearColor(clearColor); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + +#if !defined(QT_OPENGL_ES_2) + + glLoadIdentity(); + glTranslatef(0.0f, 0.0f, -10.0f); + + glRotatef(xRot, 1.0f, 0.0f, 0.0f); + glRotatef(yRot, 0.0f, 1.0f, 0.0f); + glRotatef(-1.0f * zRot, 0.0f, 0.0f, 1.0f); + + glVertexPointer(3, GL_FLOAT, 0, vertices.constData()); + glTexCoordPointer(2, GL_FLOAT, 0, texCoords.constData()); + glEnableClientState(GL_VERTEX_ARRAY); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + +#else + + QMatrix4x4 m; + m.ortho(-0.5f, +0.5f, +0.5f, -0.5f, 4.0f, 15.0f); + m.translate(0.0f, 0.0f, -10.0f); + m.rotate(xRot / 16.0f, 1.0f, 0.0f, 0.0f); + m.rotate(yRot / 16.0f, 0.0f, 1.0f, 0.0f); + m.rotate(zRot / 16.0f, 0.0f, 0.0f, 1.0f); + + program->setUniformValue("matrix", m); + program->enableAttributeArray(PROGRAM_VERTEX_ATTRIBUTE); + program->enableAttributeArray(PROGRAM_TEXCOORD_ATTRIBUTE); + program->setAttributeArray + (PROGRAM_VERTEX_ATTRIBUTE, vertices.constData()); + program->setAttributeArray + (PROGRAM_TEXCOORD_ATTRIBUTE, texCoords.constData()); + +#endif + + for (int i = 0; i < 6; ++i) { + glBindTexture(GL_TEXTURE_2D, textures[i]); + glDrawArrays(GL_TRIANGLE_FAN, i * 4, 4); + } +} + +void GLWidget::resizeGL(int width, int height) +{ + int side = qMin(width, height); + glViewport((width - side) / 2, (height - side) / 2, side, side); + +#if !defined(QT_OPENGL_ES_2) + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); +#ifndef QT_OPENGL_ES + glOrtho(-0.5, +0.5, +0.5, -0.5, 4.0, 15.0); +#else + glOrthof(-0.5, +0.5, +0.5, -0.5, 4.0, 15.0); +#endif + glMatrixMode(GL_MODELVIEW); +#endif +} + +void GLWidget::makeObject() +{ + static const int coords[6][4][3] = { + { { +1, -1, -1 }, { -1, -1, -1 }, { -1, +1, -1 }, { +1, +1, -1 } }, + { { +1, +1, -1 }, { -1, +1, -1 }, { -1, +1, +1 }, { +1, +1, +1 } }, + { { +1, -1, +1 }, { +1, -1, -1 }, { +1, +1, -1 }, { +1, +1, +1 } }, + { { -1, -1, -1 }, { -1, -1, +1 }, { -1, +1, +1 }, { -1, +1, -1 } }, + { { +1, -1, +1 }, { -1, -1, +1 }, { -1, -1, -1 }, { +1, -1, -1 } }, + { { -1, -1, +1 }, { +1, -1, +1 }, { +1, +1, +1 }, { -1, +1, +1 } } + }; + + for (int j=0; j < 6; ++j) { + textures[j] = bindTexture + (QPixmap(QString(":/images/side%1.png").arg(j + 1)), GL_TEXTURE_2D); + } + + for (int i = 0; i < 6; ++i) { + for (int j = 0; j < 4; ++j) { + texCoords.append + (QVector2D(j == 0 || j == 3, j == 0 || j == 1)); + vertices.append + (QVector3D(0.4 * coords[i][j][0], 0.4 * coords[i][j][1], + 0.02 * coords[i][j][2])); + } + } +} diff --git a/FTNoIR_PoseWidget/glwidget.h b/FTNoIR_PoseWidget/glwidget.h new file mode 100644 index 00000000..cff8cb83 --- /dev/null +++ b/FTNoIR_PoseWidget/glwidget.h @@ -0,0 +1,72 @@ +/******************************************************************************** +* FaceTrackNoIR This program is a private project of the some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2010 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* Adopted this widget from the 'textures' sample of the Nokia Qt toolkit. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +*********************************************************************************/ + +#ifndef GLWIDGET_H +#define GLWIDGET_H + +#include +#include + +class QGLShaderProgram; + +class GLWidget : public QGLWidget +{ + Q_OBJECT + +public: + GLWidget(QWidget *parent = 0, QGLWidget *shareWidget = 0); + ~GLWidget(); + + QSize minimumSizeHint() const; + QSize sizeHint() const; + void rotateBy(int xAngle, int yAngle, int zAngle); + void setClearColor(const QColor &color); + +signals: + void clicked(); + +protected: + void initializeGL(); + void paintGL(); + void resizeGL(int width, int height); + +private: + void makeObject(); + + QColor clearColor; + QPoint lastPos; + int xRot; + int yRot; + int zRot; + GLuint textures[6]; + QVector vertices; + QVector texCoords; +#ifdef QT_OPENGL_ES_2 + QGLShaderProgram *program; +#endif +}; + +#endif diff --git a/FTNoIR_PoseWidget/images/side1.bmp b/FTNoIR_PoseWidget/images/side1.bmp new file mode 100644 index 00000000..29c28d80 Binary files /dev/null and b/FTNoIR_PoseWidget/images/side1.bmp differ diff --git a/FTNoIR_PoseWidget/images/side1.png b/FTNoIR_PoseWidget/images/side1.png new file mode 100644 index 00000000..e0315b77 Binary files /dev/null and b/FTNoIR_PoseWidget/images/side1.png differ diff --git a/FTNoIR_PoseWidget/images/side2.png b/FTNoIR_PoseWidget/images/side2.png new file mode 100644 index 00000000..67eb060b Binary files /dev/null and b/FTNoIR_PoseWidget/images/side2.png differ diff --git a/FTNoIR_PoseWidget/images/side3.png b/FTNoIR_PoseWidget/images/side3.png new file mode 100644 index 00000000..67eb060b Binary files /dev/null and b/FTNoIR_PoseWidget/images/side3.png differ diff --git a/FTNoIR_PoseWidget/images/side4.png b/FTNoIR_PoseWidget/images/side4.png new file mode 100644 index 00000000..67eb060b Binary files /dev/null and b/FTNoIR_PoseWidget/images/side4.png differ diff --git a/FTNoIR_PoseWidget/images/side5.png b/FTNoIR_PoseWidget/images/side5.png new file mode 100644 index 00000000..67eb060b Binary files /dev/null and b/FTNoIR_PoseWidget/images/side5.png differ diff --git a/FTNoIR_PoseWidget/images/side6.png b/FTNoIR_PoseWidget/images/side6.png new file mode 100644 index 00000000..f4160001 Binary files /dev/null and b/FTNoIR_PoseWidget/images/side6.png differ diff --git a/FTNoIR_Tracker_Base/ftnoir_tracker_base.h b/FTNoIR_Tracker_Base/ftnoir_tracker_base.h index 93fd5140..df7ec2c4 100644 --- a/FTNoIR_Tracker_Base/ftnoir_tracker_base.h +++ b/FTNoIR_Tracker_Base/ftnoir_tracker_base.h @@ -14,6 +14,22 @@ struct THeadPoseData { }; #pragma pack(pop) +// +// Structure to hold all 6 DOF's +// +class T6DOF { +public: + void initHeadPoseData(){ + position.x = 0.0f; + position.y = 0.0f; + position.z = 0.0f; + position.yaw = 0.0f; + position.pitch = 0.0f; + position.roll = 0.0f; + } + THeadPoseData position; +}; + // COM-Like abstract interface. // This interface doesn't require __declspec(dllexport/dllimport) specifier. // Method calls are dispatched via virtual table. diff --git a/FaceTrackNoIR.suo b/FaceTrackNoIR.suo index 9e3ca2db..982e6626 100644 Binary files a/FaceTrackNoIR.suo and b/FaceTrackNoIR.suo differ 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); } diff --git a/bin/FaceTrackNoIR.exe b/bin/FaceTrackNoIR.exe index 8231caf5..75adfa6f 100644 Binary files a/bin/FaceTrackNoIR.exe and b/bin/FaceTrackNoIR.exe differ diff --git a/bin/Settings/Wings of Prey.ini b/bin/Settings/Wings of Prey.ini index 75ed83bb..57b16b37 100644 --- a/bin/Settings/Wings of Prey.ini +++ b/bin/Settings/Wings of Prey.ini @@ -54,10 +54,10 @@ Yaw_point1=@Variant(\0\0\0\x1a@\x10\0\0\0\0\0\0@\x14\0\0\0\0\0\0) Yaw_point2=@Variant(\0\0\0\x1a@`\xe0\0\0\0\0\0@A\x80\0\0\0\0\0) Yaw_point3=@Variant(\0\0\0\x1a@f\0\0\0\0\0\0@:\0\0\0\0\0\0) Yaw_point4=@Variant(\0\0\0\x1a@f\x80\0\0\0\0\0@I\0\0\0\0\0\0) -Pitch_point1=@Variant(\0\0\0\x1a@\x16\0\0\0\0\0\0@\x16\0\0\0\0\0\0) -Pitch_point2=@Variant(\0\0\0\x1a@X\x80\0\0\0\0\0@:\0\0\0\0\0\0) -Pitch_point3=@Variant(\0\0\0\x1a@e\x80\0\0\0\0\0@3\0\0\0\0\0\0) -Pitch_point4=@Variant(\0\0\0\x1a@f\x80\0\0\0\0\0@I\0\0\0\0\0\0) +Pitch_point1=@Variant(\0\0\0\x1a@\x18\0\0\0\0\0\0@\x18\0\0\0\0\0\0) +Pitch_point2=@Variant(\0\0\0\x1a@M@\0\0\0\0\0@0\0\0\0\0\0\0) +Pitch_point3=@Variant(\0\0\0\x1a@R\x80\0\0\0\0\0@7\0\0\0\0\0\0) +Pitch_point4=@Variant(\0\0\0\x1a@W \0\0\0\0\0@I\0\0\0\0\0\0) Roll_point1=@Variant(\0\0\0\x1a@\x10\0\0\0\0\0\0@\x14\0\0\0\0\0\0) Roll_point2=@Variant(\0\0\0\x1a@^\xc0\0\0\0\0\0@?\0\0\0\0\0\0) Roll_point3=@Variant(\0\0\0\x1a@d@\0\0\0\0\0@B\0\0\0\0\0\0) diff --git a/faceAPI/main.cpp b/faceAPI/main.cpp index e60535fe..6d02b355 100644 --- a/faceAPI/main.cpp +++ b/faceAPI/main.cpp @@ -383,6 +383,9 @@ void run() THROW_ON_ERROR(smEngineStart(engine_handle)); // Start tracking } pMemData->command = 0; // Reset + + THROW_ON_ERROR(smEngineShowCameraControlPanel(engine_handle)); + break; case FT_SM_STOP: -- cgit v1.2.3