From 9ae8a2212d0c85cfa904ea3bf03c0631f6c1369a Mon Sep 17 00:00:00 2001 From: Wim Vriend Date: Fri, 16 Mar 2012 14:30:06 +0000 Subject: Filter added. git-svn-id: svn+ssh://svn.code.sf.net/p/facetracknoir/code@103 19e81ba0-9b1a-49c3-bd6c-561e1906d5fb --- FTNoIR_Filter_Accela/FTNoIR_FilterControls.ui | 441 +++++++++++++++++++++ FTNoIR_Filter_Accela/FTNoIR_Filter_accela.h | 105 +++++ FTNoIR_Filter_Accela/FTNoIR_Filter_accela.vcproj | 378 ++++++++++++++++++ FTNoIR_Filter_Accela/ftnoir_filter_accela.cpp | 162 ++++++++ .../ftnoir_filter_accela_dialog.cpp | 235 +++++++++++ FTNoIR_Filter_Accela/images/filter-16-ac.png | Bin 0 -> 725 bytes 6 files changed, 1321 insertions(+) create mode 100644 FTNoIR_Filter_Accela/FTNoIR_FilterControls.ui create mode 100644 FTNoIR_Filter_Accela/FTNoIR_Filter_accela.h create mode 100644 FTNoIR_Filter_Accela/FTNoIR_Filter_accela.vcproj create mode 100644 FTNoIR_Filter_Accela/ftnoir_filter_accela.cpp create mode 100644 FTNoIR_Filter_Accela/ftnoir_filter_accela_dialog.cpp create mode 100644 FTNoIR_Filter_Accela/images/filter-16-ac.png diff --git a/FTNoIR_Filter_Accela/FTNoIR_FilterControls.ui b/FTNoIR_Filter_Accela/FTNoIR_FilterControls.ui new file mode 100644 index 00000000..f753df0c --- /dev/null +++ b/FTNoIR_Filter_Accela/FTNoIR_FilterControls.ui @@ -0,0 +1,441 @@ + + + UICFilterControls + + + Qt::ApplicationModal + + + + 0 + 0 + 350 + 473 + + + + Filter settings + + + + images/FaceTrackNoIR.icoimages/FaceTrackNoIR.ico + + + Qt::LeftToRight + + + false + + + + + + + + + + + QLayout::SetNoConstraint + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">c</span><span style=" font-size:10pt; vertical-align:sub;">4 </span><span style=" font-size:8pt;">=</span></p></body></html> + + + + + + + 3 + + + 1000000.000000000000000 + + + 0.100000000000000 + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">factor</span><span style=" font-size:12pt; vertical-align:sub;">rotation</span><span style=" font-size:8pt;"> =</span></p></body></html> + + + + + + + 3 + + + 5.000000000000000 + + + 1000000.000000000000000 + + + 0.500000000000000 + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">c</span><span style=" font-size:10pt; vertical-align:sub;">3 </span><span style=" font-size:8pt;">=</span></p></body></html> + + + + + + + 3 + + + 1000000.000000000000000 + + + 0.100000000000000 + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">c</span><span style=" font-size:10pt; vertical-align:sub;">2</span><span style=" font-size:10pt;"> </span><span style=" font-size:8pt;">=</span></p></body></html> + + + + + + + 3 + + + 1000000.000000000000000 + + + 0.075000000000000 + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">c</span><span style=" font-size:10pt; vertical-align:sub;">1 </span><span style=" font-size:8pt;">=</span></p></body></html> + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">sensitivity</span><span style=" font-size:12pt; vertical-align:sub;">rotation</span><span style=" font-size:8pt;"> = </span></p></body></html> + + + + + + + 3 + + + 1000000.000000000000000 + + + 0.050000000000000 + + + + + + + 3 + + + 1000000.000000000000000 + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">c</span><span style=" font-size:10pt; vertical-align:sub;">0</span><span style=" font-size:8pt;"> =</span></p></body></html> + + + + + + + 3 + + + 1000000.000000000000000 + + + 0.005000000000000 + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">factor</span><span style=" font-size:12pt; vertical-align:sub;">translation</span><span style=" font-size:10pt;"> =</span></p></body></html> + + + + + + + 3 + + + 5.000000000000000 + + + 1000000.000000000000000 + + + 0.500000000000000 + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">sensitivity</span><span style=" font-size:12pt; vertical-align:sub;">translation</span><span style=" font-size:8pt;"> =</span></p></body></html> + + + + + + + 3 + + + 1000000.000000000000000 + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">%</span></p></body></html> + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">%</span></p></body></html> + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + background-color: rgb(214, 214, 214); +border-color: rgb(0, 0, 0); + + + QFrame::Box + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">The Accela-filter uses a polynomial to calculate the</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">'next value' of the filtered output. The maths:</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10pt;"></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt; font-style:italic;">let x = input / factor (behold: smaller than 1!)</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt; font-style:italic;">let y' = c</span><span style=" font-size:12pt; font-style:italic; vertical-align:sub;">4</span><span style=" font-size:10pt; font-style:italic; vertical-align:sub;"> * </span><span style=" font-size:10pt; font-style:italic;">x</span><span style=" font-size:12pt; font-style:italic; vertical-align:super;">4</span><span style=" font-size:10pt; font-style:italic;"> + c</span><span style=" font-size:12pt; font-style:italic; vertical-align:sub;">3 *</span><span style=" font-size:10pt; font-style:italic;"> x</span><span style=" font-size:11pt; font-style:italic; vertical-align:super;">3</span><span style=" font-size:10pt; font-style:italic;"> + c</span><span style=" font-size:12pt; font-style:italic; vertical-align:sub;">2 *</span><span style=" font-size:10pt; font-style:italic;"> x</span><span style=" font-size:12pt; font-style:italic; vertical-align:super;">2</span><span style=" font-size:10pt; font-style:italic;"> + c</span><span style=" font-size:12pt; font-style:italic; vertical-align:sub;">1 *</span><span style=" font-size:10pt; font-style:italic;"> x</span><span style=" font-size:12pt; font-style:italic; vertical-align:super;">1</span><span style=" font-size:10pt; font-style:italic;"> + c</span><span style=" font-size:12pt; font-style:italic; vertical-align:sub;">0 </span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt; font-style:italic;">y = y' * sensitivity</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10pt; font-style:italic;"></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">Higher values for c</span><span style=" font-size:12pt; vertical-align:sub;">0 </span><span style=" font-size:10pt;">to</span><span style=" font-size:12pt; vertical-align:sub;"> </span><span style=" font-size:10pt;">c</span><span style=" font-size:12pt; vertical-align:sub;">4 </span><span style=" font-size:10pt;">: more responsive, less stable</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">Lower values for c</span><span style=" font-size:12pt; vertical-align:sub;">0 </span><span style=" font-size:10pt;">to</span><span style=" font-size:12pt; vertical-align:sub;"> </span><span style=" font-size:10pt;">c</span><span style=" font-size:12pt; vertical-align:sub;">4 </span><span style=" font-size:10pt;">: less responsive, more stable</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">Remark: c</span><span style=" font-size:12pt; vertical-align:sub;">0 </span><span style=" font-size:10pt;">has the strongest influence, c</span><span style=" font-size:12pt; vertical-align:sub;">4 </span><span style=" font-size:10pt;">the weakest.</span></p></body></html> + + + 5 + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 10 + 20 + + + + + + + + QLayout::SetDefaultConstraint + + + + + + 0 + 0 + + + + + 52 + 0 + + + + + 100 + 16777215 + + + + OK + + + + + + + + 0 + 0 + + + + + 52 + 0 + + + + + 100 + 16777215 + + + + Cancel + + + + + + + + + + + btnOK + btnCancel + + + + + startEngineClicked() + stopEngineClicked() + cameraSettingsClicked() + + diff --git a/FTNoIR_Filter_Accela/FTNoIR_Filter_accela.h b/FTNoIR_Filter_Accela/FTNoIR_Filter_accela.h new file mode 100644 index 00000000..884da3a9 --- /dev/null +++ b/FTNoIR_Filter_Accela/FTNoIR_Filter_accela.h @@ -0,0 +1,105 @@ +/******************************************************************************** +* FaceTrackNoIR This program is a private project of some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2012 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. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +********************************************************************************/ +#pragma once +#ifndef INCLUDED_FTN_FILTER_H +#define INCLUDED_FTN_FILTER_H + +#include "..\ftnoir_filter_base\ftnoir_filter_base.h" +#include "ui_FTNoIR_FilterControls.h" + +class FTNoIR_Filter : public IFilter +{ +public: + FTNoIR_Filter(); + ~FTNoIR_Filter(); + + void Release(); + void Initialize(); + void StartFilter(); + void FilterHeadPoseData(THeadPoseData *current_camera_position, THeadPoseData *target_camera_position, THeadPoseData *new_camera_position, bool newTarget); + + void getFullName(QString *strToBeFilled); + void getShortName(QString *strToBeFilled); + void getDescription(QString *strToBeFilled); + +private: + void loadSettings(); // Load the settings from the INI-file + THeadPoseData newHeadPose; // Structure with new headpose + + bool first_run; + double kFactor, kFactorTranslation; + double kSensitivity, kSensitivityTranslation; + double kC1, kC2, kC3, kC4, kC0; + + QString filterFullName; // Filters' name and description + QString filterShortName; + QString filterDescription; +}; + +//******************************************************************************************************* +// FaceTrackNoIR Filter Settings-dialog. +//******************************************************************************************************* + +// Widget that has controls for FTNoIR protocol filter-settings. +class FilterControls: public QWidget, Ui::UICFilterControls, public IFilterDialog +{ + Q_OBJECT +public: + + explicit FilterControls(); + virtual ~FilterControls(); + void showEvent ( QShowEvent * event ); + + void Release(); // Member functions which are accessible from outside the DLL + void Initialize(QWidget *parent, IFilterPtr ptr); + void getFullName(QString *strToBeFilled); + void getShortName(QString *strToBeFilled); + void getDescription(QString *strToBeFilled); + void getIcon(QIcon *icon); + +private: + Ui::UICFilterControls ui; + void loadSettings(); + void save(); + + /** helper **/ + bool settingsDirty; + + QString filterFullName; // Filters' name and description + QString filterShortName; + QString filterDescription; + IFilterPtr pFilter; // If the filter was active when the dialog was opened, this will hold a pointer to the Filter instance + +private slots: + void doOK(); + void doCancel(); + void settingChanged() { settingsDirty = true; }; + void settingChanged( int ) { settingsDirty = true; }; + void settingChanged( double ) { settingsDirty = true; }; +}; + +#endif //INCLUDED_FTN_FILTER_H +//END + diff --git a/FTNoIR_Filter_Accela/FTNoIR_Filter_accela.vcproj b/FTNoIR_Filter_Accela/FTNoIR_Filter_accela.vcproj new file mode 100644 index 00000000..6d2ca558 --- /dev/null +++ b/FTNoIR_Filter_Accela/FTNoIR_Filter_accela.vcproj @@ -0,0 +1,378 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/FTNoIR_Filter_Accela/ftnoir_filter_accela.cpp b/FTNoIR_Filter_Accela/ftnoir_filter_accela.cpp new file mode 100644 index 00000000..7a81d211 --- /dev/null +++ b/FTNoIR_Filter_Accela/ftnoir_filter_accela.cpp @@ -0,0 +1,162 @@ +/* Copyright (c) 2012 Stanislaw Halik + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + */ +#include "ftnoir_filter_Accela.h" +#include "math.h" +#include + +FTNoIR_Filter::FTNoIR_Filter() +{ + //populate the description strings + filterFullName = "Accela Filter"; + filterShortName = "Accela"; + filterDescription = "Accela filter"; + + first_run = true; + loadSettings(); // Load the Settings + +} + +FTNoIR_Filter::~FTNoIR_Filter() +{ + +} + +void FTNoIR_Filter::Release() +{ + delete this; +} + +void FTNoIR_Filter::Initialize() +{ + loadSettings(); + return; +} + +void FTNoIR_Filter::loadSettings() { + 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) + + qDebug() << "FTNoIR_Filter::loadSettings says: iniFile = " << currentFile; + + iniFile.beginGroup ( "Filter_Accela" ); + kFactor = iniFile.value ( "factor", 8.0 ).toDouble(); + kSensitivity = iniFile.value("sensitivity", 12.0).toDouble(); + kC0 = iniFile.value("c0", 0.005).toDouble(); + kC1 = iniFile.value("c1", 0.125).toDouble(); + kC2 = iniFile.value("c2", 0.33333).toDouble(); + kC3 = iniFile.value("c3", 0.75).toDouble(); + kC4 = iniFile.value("c4", 1.0).toDouble(); + kFactorTranslation = iniFile.value("factor_translation", 1.0).toDouble(); + kSensitivityTranslation = iniFile.value("sensitivity_translation", 1.0).toDouble(); + + iniFile.endGroup (); +} + +void FTNoIR_Filter::FilterHeadPoseData(THeadPoseData *current_camera_position, THeadPoseData *target_camera_position, THeadPoseData *new_camera_position, bool newTarget) +{ + double target[6]; + double prev_output[6]; + float output[6]; + int i=0; + + prev_output[0]=current_camera_position->x; + prev_output[1]=current_camera_position->y; + prev_output[2]=current_camera_position->z; + prev_output[3]=current_camera_position->yaw; + prev_output[4]=current_camera_position->pitch; + prev_output[5]=current_camera_position->roll; + + target[0]=target_camera_position->x; + target[1]=target_camera_position->y; + target[2]=target_camera_position->z; + target[3]=target_camera_position->yaw; + target[4]=target_camera_position->pitch; + target[5]=target_camera_position->roll; + + if (first_run) + { + new_camera_position->x=target[0]; + new_camera_position->y=target[1]; + new_camera_position->z=target[2]; + new_camera_position->yaw=target[3]; + new_camera_position->pitch=target[4]; + new_camera_position->roll=target[5]; + + first_run=false; + return; + } + + for (i=0;i<6;i++) + { + double e2 = target[i]; + double start = prev_output[i]; + double vec = e2 - start; + int sign = vec < 0 ? -1 : 1; + double max = i >= 3 ? kFactor : kFactorTranslation; + double x = fabs(vec) / max; + double foo = kC4 * x * x * x * x + kC3 * x * x * x + kC2 * x * x + kC1 * x + kC0; + // the idea is that "empty" updates without new head pose data are still + // useful for filtering, as skipping them would result in jerky output. + // the magic "100" is the amount of calls to the filter by FTNOIR per sec. + double velocity = foo * (i >= 3 ? kSensitivity : kSensitivityTranslation) / 100.0; + double sum = start + velocity * sign; + bool done = sign > 0 ? sum >= e2 : sum <= e2; + if (done) { + output[i] = e2; + } else { + output[i] = sum; + } + } + +end: + new_camera_position->x=output[0]; + new_camera_position->y=output[1]; + new_camera_position->z=output[2]; + new_camera_position->yaw=output[3]; + new_camera_position->pitch=output[4]; + new_camera_position->roll=output[5]; + + current_camera_position->x=output[0]; + current_camera_position->y=output[1]; + current_camera_position->z=output[2]; + current_camera_position->yaw=output[3]; + current_camera_position->pitch=output[4]; + current_camera_position->roll=output[5]; +} + +void FTNoIR_Filter::getFullName(QString *strToBeFilled) +{ + *strToBeFilled = filterFullName; +}; + + +void FTNoIR_Filter::getShortName(QString *strToBeFilled) +{ + *strToBeFilled = filterShortName; +}; + + +void FTNoIR_Filter::getDescription(QString *strToBeFilled) +{ + *strToBeFilled = filterDescription; +}; + +//////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Filter object. + +// Export both decorated and undecorated names. +// GetFilter - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetFilter@0 - Common name decoration for __stdcall functions in C language. +#pragma comment(linker, "/export:GetFilter=_GetFilter@0") + +FTNOIR_FILTER_BASE_EXPORT FILTERHANDLE __stdcall GetFilter() +{ + return new FTNoIR_Filter; +} diff --git a/FTNoIR_Filter_Accela/ftnoir_filter_accela_dialog.cpp b/FTNoIR_Filter_Accela/ftnoir_filter_accela_dialog.cpp new file mode 100644 index 00000000..a77a32fa --- /dev/null +++ b/FTNoIR_Filter_Accela/ftnoir_filter_accela_dialog.cpp @@ -0,0 +1,235 @@ +/******************************************************************************** +* FaceTrackNoIR This program is a private project of some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2012 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. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +********************************************************************************/ +#include "ftnoir_filter_Accela.h" +#include "math.h" +#include + +//******************************************************************************************************* +// FaceTrackNoIR Filter Settings-dialog. +//******************************************************************************************************* +// +// Constructor for server-settings-dialog +// +FilterControls::FilterControls() : +QWidget() +{ + ui.setupUi( this ); + + //populate the description strings + filterFullName = "Accela Filter"; + filterShortName = "Accela"; + filterDescription = "Accela Filter"; + + // Load the settings from the current .INI-file + loadSettings(); + + QPoint offsetpos(100, 100); + //if (parent) { + // this->move(parent->pos() + offsetpos); + //} + + // Connect Qt signals to member-functions + connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); + connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); + + // Connect sliders for reduction factor + connect(ui.sensitivity, SIGNAL(valueChanged(double)), this, SLOT(settingChanged(double))); + connect(ui.factor, SIGNAL(valueChanged(double)), this, SLOT(settingChanged(double))); + connect(ui.sensitivity_translation, SIGNAL(valueChanged(double)), this, SLOT(settingChanged(double))); + connect(ui.factor_translation, SIGNAL(valueChanged(double)), this, SLOT(settingChanged(double))); + connect(ui.c_0, SIGNAL(valueChanged(double)), this, SLOT(settingChanged(double))); + connect(ui.c_1, SIGNAL(valueChanged(double)), this, SLOT(settingChanged(double))); + connect(ui.c_2, SIGNAL(valueChanged(double)), this, SLOT(settingChanged(double))); + connect(ui.c_3, SIGNAL(valueChanged(double)), this, SLOT(settingChanged(double))); + connect(ui.c_4, SIGNAL(valueChanged(double)), this, SLOT(settingChanged(double))); + + qDebug() << "FilterControls() says: started"; +} + +// +// Destructor for server-dialog +// +FilterControls::~FilterControls() { + qDebug() << "~FilterControls() says: started"; +} + +void FilterControls::Release() +{ + delete this; +} + +// +// Initialize tracker-client-dialog +// +void FilterControls::Initialize(QWidget *parent, IFilterPtr ptr) { + + // + // The dialog can be opened, while the Tracker is running. + // In that case, ptr will point to the active Filter-instance. + // This can be used to update settings, while Tracking and may also be handy to display logging-data and such... + // + pFilter = ptr; + + QPoint offsetpos(100, 100); + if (parent) { + this->move(parent->pos() + offsetpos); + } + show(); +} + +// +// OK clicked on server-dialog +// +void FilterControls::doOK() { + save(); + if (pFilter) { + pFilter->Initialize(); + } + this->close(); +} + +// override show event +void FilterControls::showEvent ( QShowEvent * event ) { + loadSettings(); +} + +// +// Cancel clicked on server-dialog +// +void FilterControls::doCancel() { + // + // Ask if changed Settings should be saved + // + if (settingsDirty) { + int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard ); + + qDebug() << "doCancel says: answer =" << ret; + + switch (ret) { + case QMessageBox::Save: + save(); + this->close(); + break; + case QMessageBox::Discard: + this->close(); + break; + case QMessageBox::Cancel: + // Cancel was clicked + break; + default: + // should never be reached + break; + } + } + else { + this->close(); + } +} + +// +// Load the current Settings from the currently 'active' INI-file. +// +void FilterControls::loadSettings() { + 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) + + qDebug() << "FTNoIR_Filter::loadSettings says: iniFile = " << currentFile; + + iniFile.beginGroup ( "Filter_Accela" ); + ui.factor->setValue(iniFile.value ("factor", 8.0).toDouble()); + ui.sensitivity->setValue(iniFile.value("sensitivity", 12.0).toDouble()); + ui.factor_translation->setValue(iniFile.value ("factor_translation", 1.0).toDouble()); + ui.sensitivity_translation->setValue(iniFile.value("sensitivity_translation", 1.0).toDouble()); + ui.c_0->setValue(iniFile.value("c0", 0.005).toDouble()); + ui.c_1->setValue(iniFile.value("c1", 0.125).toDouble()); + ui.c_2->setValue(iniFile.value("c2", 0.33333).toDouble()); + ui.c_3->setValue(iniFile.value("c3", 0.75).toDouble()); + ui.c_4->setValue(iniFile.value("c4", 1.0).toDouble()); + iniFile.endGroup (); + + settingsDirty = false; +} + +// +// Save the current Settings to the currently 'active' INI-file. +// +void FilterControls::save() { + 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) + + iniFile.beginGroup ( "Filter_Accela" ); + iniFile.setValue ( "sensitivity", ui.sensitivity->value() ); + iniFile.setValue("factor", ui.factor->value()); + iniFile.setValue ( "sensitivity_translation", ui.sensitivity_translation->value() ); + iniFile.setValue("factor_translation", ui.factor_translation->value()); + iniFile.setValue("c0", ui.c_0->value()); + iniFile.setValue("c1", ui.c_1->value()); + iniFile.setValue("c2", ui.c_2->value()); + iniFile.setValue("c3", ui.c_3->value()); + iniFile.setValue("c4", ui.c_4->value()); + iniFile.endGroup (); + + settingsDirty = false; +} + +void FilterControls::getFullName(QString *strToBeFilled) +{ + *strToBeFilled = filterFullName; +}; + + +void FilterControls::getShortName(QString *strToBeFilled) +{ + *strToBeFilled = filterShortName; +}; + + +void FilterControls::getDescription(QString *strToBeFilled) +{ + *strToBeFilled = filterDescription; +}; + +void FilterControls::getIcon(QIcon *icon) +{ + *icon = QIcon(":/images/filter-16-ac.png"); +}; + +//////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Filter-settings dialog object. + +// Export both decorated and undecorated names. +// GetFilterDialog - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetFilterDialog@0 - Common name decoration for __stdcall functions in C language. +#pragma comment(linker, "/export:GetFilterDialog=_GetFilterDialog@0") + +FTNOIR_FILTER_BASE_EXPORT FILTERDIALOGHANDLE __stdcall GetFilterDialog( ) +{ + return new FilterControls; +} diff --git a/FTNoIR_Filter_Accela/images/filter-16-ac.png b/FTNoIR_Filter_Accela/images/filter-16-ac.png new file mode 100644 index 00000000..d263db2d Binary files /dev/null and b/FTNoIR_Filter_Accela/images/filter-16-ac.png differ -- cgit v1.2.3