summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--FTNoIR_Filter_Base/ftnoir_filter_base.h4
-rw-r--r--FTNoIR_Filter_DZ1/FTNoIR_FilterControls.ui772
-rw-r--r--FTNoIR_Filter_DZ1/FTNoIR_Filter_DZ1.h147
-rw-r--r--FTNoIR_Filter_DZ1/FTNoIR_Filter_DZ1.vcproj377
-rw-r--r--FTNoIR_Filter_DZ1/Filter.qrc5
-rw-r--r--FTNoIR_Filter_DZ1/ftnoir_filter_dz1.cpp251
-rw-r--r--FTNoIR_Filter_DZ1/ftnoir_filter_dz1_dialog.cpp228
-rw-r--r--FTNoIR_Filter_DZ1/images/filter-16.pngbin0 -> 642 bytes
-rw-r--r--FTNoIR_Filter_EWMA2/FTNoIR_Filter_EWMA2.h32
-rw-r--r--FTNoIR_Filter_EWMA2/FTNoIR_Filter_EWMA2.vcproj46
-rw-r--r--FTNoIR_Filter_EWMA2/ftnoir_filter_ewma2.cpp93
-rw-r--r--FTNoIR_Filter_EWMA2/ftnoir_filter_ewma2_dialog.cpp5
-rw-r--r--FaceTrackNoIR/FaceTrackNoIR.cpp69
-rw-r--r--FaceTrackNoIR/FaceTrackNoIR.h2
-rw-r--r--FaceTrackNoIR/tracker.cpp15
15 files changed, 1910 insertions, 136 deletions
diff --git a/FTNoIR_Filter_Base/ftnoir_filter_base.h b/FTNoIR_Filter_Base/ftnoir_filter_base.h
index 8e949553..e7dcd6bc 100644
--- a/FTNoIR_Filter_Base/ftnoir_filter_base.h
+++ b/FTNoIR_Filter_Base/ftnoir_filter_base.h
@@ -26,9 +26,6 @@ struct IFilter
virtual void getFilterFullName(QString *strToBeFilled) = 0;
virtual void getFilterShortName(QString *strToBeFilled) = 0;
virtual void getFilterDescription(QString *strToBeFilled) = 0;
-
- //parameter value get/set - returns true if successful, false if not
- virtual bool setParameterValue(const int index, const float newvalue) = 0;
};
// Handle type. In C++ language the interface type is used.
@@ -65,6 +62,7 @@ struct IFilterDialog
virtual void getFilterFullName(QString *strToBeFilled) = 0;
virtual void getFilterShortName(QString *strToBeFilled) = 0;
virtual void getFilterDescription(QString *strToBeFilled) = 0;
+ virtual void getIcon(QIcon *icon) = 0;
};
// Handle type. In C++ language the interface type is used.
diff --git a/FTNoIR_Filter_DZ1/FTNoIR_FilterControls.ui b/FTNoIR_Filter_DZ1/FTNoIR_FilterControls.ui
new file mode 100644
index 00000000..7de21537
--- /dev/null
+++ b/FTNoIR_Filter_DZ1/FTNoIR_FilterControls.ui
@@ -0,0 +1,772 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>UICFilterControls</class>
+ <widget class="QWidget" name="UICFilterControls">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>411</width>
+ <height>366</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>DZ1 Filter settings FaceTrackNoIR</string>
+ </property>
+ <property name="windowIcon">
+ <iconset>
+ <normaloff>images/FaceTrackNoIR.ico</normaloff>images/FaceTrackNoIR.ico</iconset>
+ </property>
+ <property name="layoutDirection">
+ <enum>Qt::LeftToRight</enum>
+ </property>
+ <property name="autoFillBackground">
+ <bool>false</bool>
+ </property>
+ <property name="styleSheet">
+ <string notr="true"/>
+ </property>
+ <layout class="QVBoxLayout" name="_vertical_layout">
+ <item>
+ <widget class="QGroupBox" name="groupGeneral">
+ <property name="minimumSize">
+ <size>
+ <width>0</width>
+ <height>45</height>
+ </size>
+ </property>
+ <property name="title">
+ <string>General Settings</string>
+ </property>
+ <widget class="QWidget" name="gridLayoutWidget">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>10</y>
+ <width>371</width>
+ <height>31</height>
+ </rect>
+ </property>
+ <layout class="QGridLayout" name="gridLayout_2">
+ <item row="0" column="0">
+ <widget class="QLabel" name="lblInvert1_6">
+ <property name="minimumSize">
+ <size>
+ <width>123</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>120</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="styleSheet">
+ <string notr="true"/>
+ </property>
+ <property name="text">
+ <string>Camera frequency</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QSlider" name="slideHz">
+ <property name="minimumSize">
+ <size>
+ <width>45</width>
+ <height>15</height>
+ </size>
+ </property>
+ <property name="minimum">
+ <number>5</number>
+ </property>
+ <property name="maximum">
+ <number>200</number>
+ </property>
+ <property name="singleStep">
+ <number>5</number>
+ </property>
+ <property name="pageStep">
+ <number>10</number>
+ </property>
+ <property name="value">
+ <number>30</number>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="tickPosition">
+ <enum>QSlider::TicksAbove</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="2">
+ <widget class="QSpinBox" name="spinHz">
+ <property name="minimumSize">
+ <size>
+ <width>50</width>
+ <height>22</height>
+ </size>
+ </property>
+ <property name="styleSheet">
+ <string notr="true">background:none;</string>
+ </property>
+ <property name="minimum">
+ <number>5</number>
+ </property>
+ <property name="maximum">
+ <number>200</number>
+ </property>
+ <property name="singleStep">
+ <number>5</number>
+ </property>
+ <property name="value">
+ <number>30</number>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="3">
+ <widget class="QLabel" name="lblInvert1">
+ <property name="minimumSize">
+ <size>
+ <width>35</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>30</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="styleSheet">
+ <string notr="true"/>
+ </property>
+ <property name="text">
+ <string>Hz</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="groupBox">
+ <property name="minimumSize">
+ <size>
+ <width>0</width>
+ <height>90</height>
+ </size>
+ </property>
+ <property name="title">
+ <string>High sensitivity settings</string>
+ </property>
+ <widget class="QWidget" name="gridLayoutWidget_2">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>10</y>
+ <width>371</width>
+ <height>61</height>
+ </rect>
+ </property>
+ <layout class="QGridLayout" name="gridLayout_3">
+ <item row="0" column="0">
+ <widget class="QLabel" name="lblInvert1_7">
+ <property name="minimumSize">
+ <size>
+ <width>90</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>110</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="styleSheet">
+ <string notr="true"/>
+ </property>
+ <property name="text">
+ <string>Deadzone</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="4">
+ <widget class="QLabel" name="lblInvert1_4">
+ <property name="minimumSize">
+ <size>
+ <width>35</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>100</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="styleSheet">
+ <string notr="true"/>
+ </property>
+ <property name="text">
+ <string>degrees</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="lblInvert1_8">
+ <property name="minimumSize">
+ <size>
+ <width>110</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>130</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="styleSheet">
+ <string notr="true"/>
+ </property>
+ <property name="text">
+ <string>Move toward last position</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QSlider" name="slideMoveLast">
+ <property name="minimumSize">
+ <size>
+ <width>45</width>
+ <height>15</height>
+ </size>
+ </property>
+ <property name="minimum">
+ <number>1</number>
+ </property>
+ <property name="maximum">
+ <number>100</number>
+ </property>
+ <property name="singleStep">
+ <number>5</number>
+ </property>
+ <property name="pageStep">
+ <number>10</number>
+ </property>
+ <property name="value">
+ <number>24</number>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="tickPosition">
+ <enum>QSlider::TicksAbove</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="3">
+ <widget class="QSpinBox" name="spinMoveLast">
+ <property name="minimumSize">
+ <size>
+ <width>40</width>
+ <height>22</height>
+ </size>
+ </property>
+ <property name="styleSheet">
+ <string notr="true">background:none;</string>
+ </property>
+ <property name="minimum">
+ <number>1</number>
+ </property>
+ <property name="maximum">
+ <number>100</number>
+ </property>
+ <property name="singleStep">
+ <number>5</number>
+ </property>
+ <property name="value">
+ <number>24</number>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="4">
+ <widget class="QLabel" name="lblInvert1_5">
+ <property name="minimumSize">
+ <size>
+ <width>0</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>30</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="styleSheet">
+ <string notr="true"/>
+ </property>
+ <property name="text">
+ <string>%</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="3">
+ <widget class="QDoubleSpinBox" name="spinDeadZone">
+ <property name="minimumSize">
+ <size>
+ <width>50</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="maximum">
+ <double>10.000000000000000</double>
+ </property>
+ <property name="singleStep">
+ <double>0.100000000000000</double>
+ </property>
+ <property name="value">
+ <double>0.240000000000000</double>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="groupBox_2">
+ <property name="minimumSize">
+ <size>
+ <width>0</width>
+ <height>90</height>
+ </size>
+ </property>
+ <property name="title">
+ <string>Low sensitivity settings</string>
+ </property>
+ <widget class="QWidget" name="gridLayoutWidget_3">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>10</y>
+ <width>371</width>
+ <height>61</height>
+ </rect>
+ </property>
+ <layout class="QGridLayout" name="gridLayout_4">
+ <item row="0" column="0">
+ <widget class="QLabel" name="lblInvert1_9">
+ <property name="minimumSize">
+ <size>
+ <width>90</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>110</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="styleSheet">
+ <string notr="true"/>
+ </property>
+ <property name="text">
+ <string>Maximum difference</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="4">
+ <widget class="QLabel" name="lblInvert1_10">
+ <property name="minimumSize">
+ <size>
+ <width>35</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>100</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="styleSheet">
+ <string notr="true"/>
+ </property>
+ <property name="text">
+ <string>degrees</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="lblInvert1_11">
+ <property name="minimumSize">
+ <size>
+ <width>123</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>130</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="styleSheet">
+ <string notr="true"/>
+ </property>
+ <property name="text">
+ <string>Move toward saved pos.</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QSlider" name="slideMoveSaved">
+ <property name="minimumSize">
+ <size>
+ <width>45</width>
+ <height>15</height>
+ </size>
+ </property>
+ <property name="minimum">
+ <number>1</number>
+ </property>
+ <property name="maximum">
+ <number>100</number>
+ </property>
+ <property name="singleStep">
+ <number>5</number>
+ </property>
+ <property name="pageStep">
+ <number>10</number>
+ </property>
+ <property name="value">
+ <number>35</number>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="tickPosition">
+ <enum>QSlider::TicksAbove</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="3">
+ <widget class="QSpinBox" name="spinMoveSaved">
+ <property name="minimumSize">
+ <size>
+ <width>40</width>
+ <height>22</height>
+ </size>
+ </property>
+ <property name="styleSheet">
+ <string notr="true">background:none;</string>
+ </property>
+ <property name="minimum">
+ <number>1</number>
+ </property>
+ <property name="maximum">
+ <number>100</number>
+ </property>
+ <property name="singleStep">
+ <number>5</number>
+ </property>
+ <property name="value">
+ <number>35</number>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="4">
+ <widget class="QLabel" name="lblInvert1_12">
+ <property name="minimumSize">
+ <size>
+ <width>0</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>30</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="styleSheet">
+ <string notr="true"/>
+ </property>
+ <property name="text">
+ <string>%</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="3">
+ <widget class="QDoubleSpinBox" name="spinMaxDiff">
+ <property name="minimumSize">
+ <size>
+ <width>50</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="maximum">
+ <double>10.000000000000000</double>
+ </property>
+ <property name="singleStep">
+ <double>0.100000000000000</double>
+ </property>
+ <property name="value">
+ <double>1.750000000000000</double>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </widget>
+ </item>
+ <item>
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>The filter-settings may need some explanation...</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Maybe Stanislaw can make one in laymans terms?</string>
+ </property>
+ <property name="wordWrap">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="label_3">
+ <property name="text">
+ <string>...</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <spacer name="horizontalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <property name="sizeConstraint">
+ <enum>QLayout::SetDefaultConstraint</enum>
+ </property>
+ <item>
+ <widget class="QPushButton" name="btnOK">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>52</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>100</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>OK</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="btnCancel">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>52</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>100</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>Cancel</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Fixed</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>10</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <tabstops>
+ <tabstop>btnOK</tabstop>
+ <tabstop>btnCancel</tabstop>
+ </tabstops>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>slideHz</sender>
+ <signal>valueChanged(int)</signal>
+ <receiver>spinHz</receiver>
+ <slot>setValue(int)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>291</x>
+ <y>45</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>347</x>
+ <y>44</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>spinHz</sender>
+ <signal>valueChanged(int)</signal>
+ <receiver>slideHz</receiver>
+ <slot>setValue(int)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>347</x>
+ <y>44</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>291</x>
+ <y>45</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>slideMoveLast</sender>
+ <signal>valueChanged(int)</signal>
+ <receiver>spinMoveLast</receiver>
+ <slot>setValue(int)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>287</x>
+ <y>126</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>343</x>
+ <y>125</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>spinMoveLast</sender>
+ <signal>valueChanged(int)</signal>
+ <receiver>slideMoveLast</receiver>
+ <slot>setValue(int)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>343</x>
+ <y>125</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>287</x>
+ <y>126</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>slideMoveSaved</sender>
+ <signal>valueChanged(int)</signal>
+ <receiver>spinMoveSaved</receiver>
+ <slot>setValue(int)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>202</x>
+ <y>213</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>312</x>
+ <y>212</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>spinMoveSaved</sender>
+ <signal>valueChanged(int)</signal>
+ <receiver>slideMoveSaved</receiver>
+ <slot>setValue(int)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>309</x>
+ <y>203</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>260</x>
+ <y>203</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+ <slots>
+ <slot>startEngineClicked()</slot>
+ <slot>stopEngineClicked()</slot>
+ <slot>cameraSettingsClicked()</slot>
+ </slots>
+</ui>
diff --git a/FTNoIR_Filter_DZ1/FTNoIR_Filter_DZ1.h b/FTNoIR_Filter_DZ1/FTNoIR_Filter_DZ1.h
new file mode 100644
index 00000000..35a5fcb6
--- /dev/null
+++ b/FTNoIR_Filter_DZ1/FTNoIR_Filter_DZ1.h
@@ -0,0 +1,147 @@
+/********************************************************************************
+* 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 <http://www.gnu.org/licenses/>. *
+* *
+********************************************************************************/
+#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"
+
+static int compare_double(const void *one, const void *two) {
+ double foo = (*((double*) one) - *((double*) two));
+ if (foo > 0)
+ return 1;
+ if (foo < 0)
+ return -1;
+ return 0;
+}
+
+//#define HZ 30
+
+//#define DEADZONE 0.1
+//#define MOVE_LAST 0.24
+//#define MOVE_SAVED (0.35 / HZ)
+#define SLOW_SPEED 0.1
+
+//#define MAXDIFF 1.75
+#define INITIAL_SMOOTH_SPEED 0.00834
+#define SMOOTH_FACTOR 2.5
+#define REMEMBER_SMOOTHNESS 5 // Changed from HZ/5
+
+#define MULT_Y_POS 1.7
+#define MULT_Y_NEG 0.8
+#define MULT_X 1.5
+
+#define COCKPIT_PITCH 8.7
+
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// DZ1 Filter: Stanislaw wrote a new filter, which makes the view more stable, when not moving your face.
+//
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+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 getFilterFullName(QString *strToBeFilled);
+ void getFilterShortName(QString *strToBeFilled);
+ void getFilterDescription(QString *strToBeFilled);
+
+private:
+ void loadSettings(); // Load the settings from the INI-file
+ THeadPoseData newHeadPose; // Structure with new headpose
+
+ bool first_run;
+ double last_positions[6];
+ double saved_positions[6];
+ double prev_positions[6];
+ bool smoothing[6];
+ double smooth_start[6];
+ double smooth_speed[6];
+ int smooth_remember[6];
+
+ float kCameraHz; // Hz
+ float kDeadZone; // degrees
+ float kMoveLast; // %
+ float kMaxDiff; // degrees
+ float kMoveSaved; // %
+
+ 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 getFilterFullName(QString *strToBeFilled);
+ void getFilterShortName(QString *strToBeFilled);
+ void getFilterDescription(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_DZ1/FTNoIR_Filter_DZ1.vcproj b/FTNoIR_Filter_DZ1/FTNoIR_Filter_DZ1.vcproj
new file mode 100644
index 00000000..a09aa9bd
--- /dev/null
+++ b/FTNoIR_Filter_DZ1/FTNoIR_Filter_DZ1.vcproj
@@ -0,0 +1,377 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="8,00"
+ Name="FTNoIR_Filter_dz1"
+ ProjectGUID="{2212857A-7634-4E30-BA83-539EC70176E6}"
+ Keyword="Qt4VSv1.0"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)/bin"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories=".\GeneratedFiles;&quot;$(QTDIR)\include&quot;;&quot;.\GeneratedFiles\$(ConfigurationName)&quot;;&quot;$(QTDIR)\include\qtmain&quot;;&quot;$(QTDIR)\include\QtCore&quot;;&quot;$(QTDIR)\include\QtGui&quot;;.\"
+ PreprocessorDefinitions="UNICODE;WIN32;QT_LARGEFILE_SUPPORT;QT_THREAD_SUPPORT;QT_NO_DEBUG;NDEBUG;QT_CORE_LIB;FTNOIR_FILTER_BASE_LIB;QT_DLL"
+ RuntimeLibrary="2"
+ TreatWChar_tAsBuiltInType="false"
+ DebugInformationFormat="0"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="qtmain.lib QtCore4.lib QtGui4.lib QtNetwork4.lib"
+ OutputFile="$(OutDir)\$(ProjectName).dll"
+ AdditionalLibraryDirectories="$(QTDIR)\lib"
+ GenerateDebugInformation="false"
+ SubSystem="2"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=".\GeneratedFiles;$(QTDIR)\include;.\GeneratedFiles\$(ConfigurationName);$(QTDIR)\include\qtmain;$(QTDIR)\include\QtCore;.\"
+ PreprocessorDefinitions="UNICODE,WIN32,QT_LARGEFILE_SUPPORT,QT_THREAD_SUPPORT,QT_CORE_LIB,FTNOIR_FILTER_dz1_LIB;QT_DLL"
+ RuntimeLibrary="3"
+ TreatWChar_tAsBuiltInType="false"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="qtmaind.lib QtCored4.lib"
+ OutputFile="$(OutDir)\$(ProjectName).dll"
+ AdditionalLibraryDirectories="$(QTDIR)\lib"
+ GenerateDebugInformation="true"
+ SubSystem="2"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;cxx;c;def"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath=".\ftnoir_filter_dz1.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\ftnoir_filter_dz1_dialog.cpp"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ <File
+ RelativePath="..\FTNoIR_Filter_Base\ftnoir_filter_base.h"
+ >
+ </File>
+ <File
+ RelativePath="..\FTNoIR_Filter_Base\ftnoir_filter_base_global.h"
+ >
+ </File>
+ <File
+ RelativePath=".\FTNoIR_Filter_dz1.h"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Moc&apos;ing $(InputFileName)..."
+ CommandLine="&quot;$(QTDIR)\bin\moc.exe&quot; &quot;$(InputPath)&quot; -o &quot;.\GeneratedFiles\$(ConfigurationName)\moc_$(InputName).cpp&quot; -D_WINDLL -DFTNOIR_FILTER_BASE_LIB -DNDEBUG -DQT_CORE_LIB -DQT_DLL -DQT_LARGEFILE_SUPPORT -DQT_NO_DEBUG -DQT_THREAD_SUPPORT -DUNICODE -DWIN32 -I&quot;$(QTDIR)\include\.&quot; -I&quot;$(QTDIR)\include\QtCore\.&quot; -I&quot;$(QTDIR)\include\QtGui\.&quot; -I&quot;$(QTDIR)\include\qtmain\.&quot; -I&quot;.\.&quot; -I&quot;.\GeneratedFiles\$(ConfigurationName)\.&quot; -I&quot;.\GeneratedFiles\.&quot;&#x0D;&#x0A;"
+ AdditionalDependencies="&quot;$(QTDIR)\bin\moc.exe&quot;;$(InputPath)"
+ Outputs="&quot;.\GeneratedFiles\$(ConfigurationName)\moc_$(InputName).cpp&quot;"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Moc&apos;ing $(InputFileName)..."
+ CommandLine="&quot;$(QTDIR)\bin\moc.exe&quot; &quot;$(InputPath)&quot; -o &quot;.\GeneratedFiles\$(ConfigurationName)\moc_$(InputName).cpp&quot; -D_WINDLL -DFTNOIR_FILTER_dz1_LIB -DQT_CORE_LIB -DQT_DLL -DQT_LARGEFILE_SUPPORT -DQT_THREAD_SUPPORT -DUNICODE -DWIN32 -I&quot;$(QTDIR)\include\.&quot; -I&quot;$(QTDIR)\include\QtCore\.&quot; -I&quot;$(QTDIR)\include\qtmain\.&quot; -I&quot;.\.&quot; -I&quot;.\GeneratedFiles\$(ConfigurationName)\.&quot; -I&quot;.\GeneratedFiles\.&quot;&#x0D;&#x0A;"
+ AdditionalDependencies="&quot;$(QTDIR)\bin\moc.exe&quot;;$(InputPath)"
+ Outputs="&quot;.\GeneratedFiles\$(ConfigurationName)\moc_$(InputName).cpp&quot;"
+ />
+ </FileConfiguration>
+ </File>
+ </Filter>
+ <Filter
+ Name="Form Files"
+ Filter="ui"
+ UniqueIdentifier="{99349809-55BA-4b9d-BF79-8FDBB0286EB3}"
+ >
+ <File
+ RelativePath=".\FTNoIR_FilterControls.ui"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Uic&apos;ing $(InputFileName)..."
+ CommandLine="&quot;$(QTDIR)\bin\uic.exe&quot; -o &quot;.\GeneratedFiles\ui_$(InputName).h&quot; &quot;$(InputPath)&quot;&#x0D;&#x0A;"
+ AdditionalDependencies="$(QTDIR)\bin\uic.exe"
+ Outputs="&quot;.\GeneratedFiles\ui_$(InputName).h&quot;"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Uic&apos;ing $(InputFileName)..."
+ CommandLine="&quot;$(QTDIR)\bin\uic.exe&quot; -o &quot;.\GeneratedFiles\ui_$(InputName).h&quot; &quot;$(InputPath)&quot;&#x0D;&#x0A;"
+ AdditionalDependencies="$(QTDIR)\bin\uic.exe"
+ Outputs="&quot;.\GeneratedFiles\ui_$(InputName).h&quot;"
+ />
+ </FileConfiguration>
+ </File>
+ </Filter>
+ <Filter
+ Name="Resource Files"
+ Filter="qrc;*"
+ UniqueIdentifier="{D9D6E242-F8AF-46E4-B9FD-80ECBC20BA3E}"
+ ParseFiles="false"
+ >
+ <File
+ RelativePath=".\Filter.qrc"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Rcc&apos;ing $(InputFileName)..."
+ CommandLine="&quot;$(QTDIR)\bin\rcc.exe&quot; -name &quot;$(InputName)&quot; -no-compress &quot;$(InputPath)&quot; -o .\GeneratedFiles\qrc_$(InputName).cpp&#x0D;&#x0A;"
+ AdditionalDependencies="$(InputPath);.\images\Settings16.png;.\images\SettingsOpen16.png;.\UIElements\Donate.png;.\UIElements\Curves.png;.\images\rotation_DOFs.png;.\images\translation_DOFs.png;.\images\FlightGear.ico;.\images\330px-6DOF_en.png;.\images\Freetrack.ico;.\images\FaceTrackNoIR.ico;.\images\SeeingMachines.ico;.\images\Mouse.ico;.\images\FS9.ico;.\images\FSX.ico;.\images\PPJoy.ico;.\images\TrackIR.ico;.\UIElements\aboutFaceTrackNoIR.png"
+ Outputs=".\GeneratedFiles\qrc_$(InputName).cpp"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Rcc&apos;ing $(InputFileName)..."
+ CommandLine="&quot;$(QTDIR)\bin\rcc.exe&quot; -name &quot;$(InputName)&quot; -no-compress &quot;$(InputPath)&quot; -o .\GeneratedFiles\qrc_$(InputName).cpp&#x0D;&#x0A;"
+ AdditionalDependencies="$(InputPath);.\images\Settings16.png;.\images\SettingsOpen16.png;.\UIElements\Donate.png;.\UIElements\Curves.png;.\images\rotation_DOFs.png;.\images\translation_DOFs.png;.\images\FlightGear.ico;.\images\330px-6DOF_en.png;.\images\Freetrack.ico;.\images\FaceTrackNoIR.ico;.\images\SeeingMachines.ico;.\images\Mouse.ico;.\images\FS9.ico;.\images\FSX.ico;.\images\PPJoy.ico;.\images\TrackIR.ico;.\UIElements\aboutFaceTrackNoIR.png"
+ Outputs=".\GeneratedFiles\qrc_$(InputName).cpp"
+ />
+ </FileConfiguration>
+ </File>
+ </Filter>
+ <Filter
+ Name="Generated Files"
+ Filter="moc;h;cpp"
+ UniqueIdentifier="{71ED8ED8-ACB9-4CE9-BBE1-E00B30144E11}"
+ SourceControlFiles="false"
+ >
+ <File
+ RelativePath=".\GeneratedFiles\qrc_Filter.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="0"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="0"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath=".\generatedfiles\ui_FTNoIR_FilterControls.h"
+ >
+ </File>
+ <Filter
+ Name="Release"
+ Filter="cpp;moc"
+ SourceControlFiles="false"
+ >
+ <File
+ RelativePath=".\GeneratedFiles\Release\moc_FTNoIR_Filter_dz1.cpp"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
+ </File>
+ </Filter>
+ <Filter
+ Name="Debug"
+ Filter="cpp;moc"
+ SourceControlFiles="false"
+ >
+ <File
+ RelativePath=".\GeneratedFiles\Debug\moc_FTNoIR_Filter_dz1.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
+ </File>
+ </Filter>
+ </Filter>
+ </Files>
+ <Globals>
+ <Global
+ Name="lupdateOnBuild"
+ Value="0"
+ />
+ <Global
+ Name="MocDir"
+ Value=".\GeneratedFiles\$(ConfigurationName)"
+ />
+ <Global
+ Name="MocOptions"
+ Value=""
+ />
+ <Global
+ Name="QtVersion Win32"
+ Value="$(DefaultQtVersion)"
+ />
+ <Global
+ Name="RccDir"
+ Value=".\GeneratedFiles"
+ />
+ <Global
+ Name="UicDir"
+ Value=".\GeneratedFiles"
+ />
+ </Globals>
+</VisualStudioProject>
diff --git a/FTNoIR_Filter_DZ1/Filter.qrc b/FTNoIR_Filter_DZ1/Filter.qrc
new file mode 100644
index 00000000..e64ec35a
--- /dev/null
+++ b/FTNoIR_Filter_DZ1/Filter.qrc
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource prefix="/">
+ <file>images/filter-16.png</file>
+ </qresource>
+</RCC>
diff --git a/FTNoIR_Filter_DZ1/ftnoir_filter_dz1.cpp b/FTNoIR_Filter_DZ1/ftnoir_filter_dz1.cpp
new file mode 100644
index 00000000..ce1b4063
--- /dev/null
+++ b/FTNoIR_Filter_DZ1/ftnoir_filter_dz1.cpp
@@ -0,0 +1,251 @@
+/********************************************************************************
+* 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 <http://www.gnu.org/licenses/>. *
+* *
+********************************************************************************/
+#include "ftnoir_filter_DZ1.h"
+#include "math.h"
+#include <QDebug>
+
+//#define LOG_OUTPUT
+
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// EWMA Filter: Exponentially Weighted Moving Average filter with dynamic smoothing parameter
+//
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+FTNoIR_Filter::FTNoIR_Filter()
+{
+ //populate the description strings
+ filterFullName = "Deadzone Filter Mk1";
+ filterShortName = "DZ1";
+ filterDescription = "Deadzone Filter";
+
+ first_run = true;
+ loadSettings(); // Load the Settings
+
+}
+
+FTNoIR_Filter::~FTNoIR_Filter()
+{
+
+}
+
+void FTNoIR_Filter::Release()
+{
+ delete this;
+}
+
+void FTNoIR_Filter::Initialize()
+{
+ qDebug() << "FTNoIR_Filter::Initialize says: Starting ";
+ loadSettings();
+ return;
+}
+
+//
+// Load the current Settings from the currently 'active' INI-file.
+//
+void FTNoIR_Filter::loadSettings() {
+ qDebug() << "FTNoIR_Filter::loadSettings says: Starting ";
+ 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;
+
+ //
+ // The EWMA2-filter-settings are in the Tracking group: this is because they used to be on the Main Form of FaceTrackNoIR
+ //
+ iniFile.beginGroup ( "Filter_DZ1" );
+ kCameraHz = iniFile.value ( "cameraHz", 30 ).toInt();
+ kDeadZone = iniFile.value ( "DeadZone", 0.1f ).toFloat();
+ kMoveLast = (iniFile.value ( "MoveLast", 24 ).toFloat()) / 100; // Convert from int to float percentage
+ kMaxDiff = iniFile.value ( "MaxDiff", 1.75f ).toFloat();
+ kMoveSaved = ((iniFile.value ( "MoveSaved", 35 ).toFloat()) / 100) / kCameraHz; // Convert from int to float percentage and divide by Hz
+ iniFile.endGroup ();
+
+}
+
+void FTNoIR_Filter::FilterHeadPoseData(THeadPoseData *current_camera_position, THeadPoseData *target_camera_position, THeadPoseData *new_camera_position, bool newTarget)
+{
+ //non-optimised version for clarity
+ double target[6];
+ double prev_output[6];
+ double scale[]={3.0, 3.0, 3.0, 3.0, 3.0, 3.0};
+// static double deadzones[] = { DEADZONE, DEADZONE, DEADZONE, DEADZONE, DEADZONE, DEADZONE };
+ float output[6];
+ int i=0, j=0;
+
+ //find out how far the head has moved
+ 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)
+ {
+ //on the first run, output=target
+ for (i=0;i<6;i++)
+ {
+ last_positions[i] = target[i];
+ saved_positions[i] = target[i];
+ prev_positions[i] = target[i];
+ smooth_remember[i] = 0;
+ smoothing[i] = false;
+ smooth_speed[i] = -1.0;
+ }
+
+ 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;
+
+ //we can bail
+ return;
+ } else if (!newTarget) {
+ int i;
+ for (i = 0; i < 6; i++) {
+ output[i] = prev_positions[i];
+ }
+ goto end;
+ }
+
+ for (i=0;i<6;i++)
+ {
+ double e2 = target[i];
+ bool slowp = fabs(last_positions[i] - e2) < kDeadZone && fabs(e2 - saved_positions[i]) < kMaxDiff; // DeadZone and MAXDIFF from INI-file
+ if (smoothing[i] || !slowp) {
+ double start = smooth_start[i];
+ double vec = e2 - start;
+ int sign = vec < 0 ? -1 : 1;
+ int sign2 = e2 < 0 ? -1 : 1;
+ if (sign != sign2)
+ sign2 = -sign2;
+ double diff = (kCameraHz / REMEMBER_SMOOTHNESS) - smooth_remember[i];
+ smooth_speed[i] *= -(diff * diff) / (double) ((kCameraHz / REMEMBER_SMOOTHNESS) * (kCameraHz / REMEMBER_SMOOTHNESS)) + 1.001;
+ if (smooth_speed[i] < INITIAL_SMOOTH_SPEED)
+ smooth_speed[i] = INITIAL_SMOOTH_SPEED;
+ vec = fabs(vec);
+ double iter = vec * SMOOTH_FACTOR / (double) kCameraHz;
+ smooth_speed[i] += iter;
+ double bleh = smooth_speed[i] * sign;
+ double foo = smooth_start[i] + bleh;
+ bool done = sign2 > 0 ? foo > e2 : foo < e2;
+ smooth_remember[i] = (kCameraHz / REMEMBER_SMOOTHNESS);
+ if (done) {
+ smoothing[i] = false;
+ output[i] = e2;
+ saved_positions[i] = e2;
+ last_positions[i] = e2;
+ prev_positions[i] = e2;
+ } else {
+ smoothing[i] = true;
+ prev_positions[i] = output[i] = foo;
+ }
+ } else {
+ if (smooth_remember[i] <= 0) {
+ smooth_speed[i] = -1.0;
+ } else {
+ smooth_remember[i]--;
+ }
+ last_positions[i] = last_positions[i] + (e2 - last_positions[i]) * kMoveLast; // MOVE_LAST from INI-file
+ saved_positions[i] = saved_positions[i] + (e2 - saved_positions[i]) * kMoveSaved; // MOVE_SAVED from INI-file
+ output[i] = prev_positions[i] = prev_positions[i] + (e2 - prev_positions[i]) * (SLOW_SPEED/kCameraHz); // Get CameraHz from INI
+ smooth_start[i] = output[i];
+ smoothing[i] = false;
+#if 0
+ if (i == 3) {
+ FILE* dlog = fopen("debug-log.txt", "a");
+ fprintf(dlog, "slowed=%f frames=%d diff=%f\n", output[i], slow_move_count[i], e1 - last_positions[i]);
+ fclose(dlog);
+ }
+#endif
+ }
+ }
+
+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] * MULT_X;
+ new_camera_position->pitch=output[4] * (output[4] < 0 ? MULT_Y_NEG : MULT_Y_POS) - COCKPIT_PITCH;
+ new_camera_position->roll=output[5];
+
+#if 1
+ //
+ // Also update the 'current' position, for the next iteration.
+ //
+ current_camera_position->x=output[0];
+ current_camera_position->y=output[1];
+ current_camera_position->z=output[2];
+ current_camera_position->yaw=output[3] * MULT_X;
+ current_camera_position->pitch=output[4] * (output[4] < 0 ? MULT_Y_NEG : MULT_Y_POS) + COCKPIT_PITCH;
+ current_camera_position->roll=output[5];
+#endif
+}
+
+void FTNoIR_Filter::getFilterFullName(QString *strToBeFilled)
+{
+ *strToBeFilled = filterFullName;
+};
+
+
+void FTNoIR_Filter::getFilterShortName(QString *strToBeFilled)
+{
+ *strToBeFilled = filterShortName;
+};
+
+
+void FTNoIR_Filter::getFilterDescription(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_DZ1/ftnoir_filter_dz1_dialog.cpp b/FTNoIR_Filter_DZ1/ftnoir_filter_dz1_dialog.cpp
new file mode 100644
index 00000000..88b4b04b
--- /dev/null
+++ b/FTNoIR_Filter_DZ1/ftnoir_filter_dz1_dialog.cpp
@@ -0,0 +1,228 @@
+/********************************************************************************
+* 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 <http://www.gnu.org/licenses/>. *
+* *
+********************************************************************************/
+#include "ftnoir_filter_DZ1.h"
+#include "math.h"
+#include <QDebug>
+
+//*******************************************************************************************************
+// FaceTrackNoIR Filter Settings-dialog.
+//*******************************************************************************************************
+//
+// Constructor for server-settings-dialog
+//
+FilterControls::FilterControls() :
+QWidget()
+{
+ ui.setupUi( this );
+
+ //populate the description strings
+ filterFullName = "Deadzone Filter Mk1";
+ filterShortName = "DZ1";
+ filterDescription = "Deadzone Filter";
+
+ 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.slideHz, SIGNAL(valueChanged(int)), this, SLOT(settingChanged(int)));
+ connect(ui.spinDeadZone, SIGNAL(valueChanged(double)), this, SLOT(settingChanged(double)));
+ connect(ui.slideMoveLast, SIGNAL(valueChanged(int)), this, SLOT(settingChanged(int)));
+
+ qDebug() << "FilterControls() says: started";
+
+ // Load the settings from the current .INI-file
+ loadSettings();
+}
+
+//
+// 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() {
+ qDebug() << "FilterControls::loadSettings says: Starting ";
+ 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() << "FilterControls::loadSettings says: iniFile = " << currentFile;
+
+ //
+ // The DZ1-filter-settings
+ //
+ iniFile.beginGroup ( "Filter_DZ1" );
+ ui.slideHz->setValue (iniFile.value ( "cameraHz", 30 ).toInt());
+ ui.spinDeadZone->setValue (iniFile.value ( "DeadZone", 0.1f ).toDouble());
+ ui.slideMoveLast->setValue (iniFile.value ( "MoveLast", 24 ).toInt());
+ ui.spinMaxDiff->setValue (iniFile.value ( "MaxDiff", 1.75f ).toDouble());
+ ui.slideMoveSaved->setValue (iniFile.value ( "MoveSaved", 35 ).toFloat());
+ 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_DZ1" );
+ iniFile.setValue ( "cameraHz", ui.slideHz->value() );
+ iniFile.setValue ( "DeadZone", ui.spinDeadZone->value() );
+ iniFile.setValue ( "MoveLast", ui.slideMoveLast->value() );
+ iniFile.setValue ( "MaxDiff", ui.spinMaxDiff->value() );
+ iniFile.setValue ( "MoveSaved", ui.slideMoveSaved->value() );
+ iniFile.endGroup ();
+
+ settingsDirty = false;
+}
+
+void FilterControls::getFilterFullName(QString *strToBeFilled)
+{
+ *strToBeFilled = filterFullName;
+};
+
+
+void FilterControls::getFilterShortName(QString *strToBeFilled)
+{
+ *strToBeFilled = filterShortName;
+};
+
+
+void FilterControls::getFilterDescription(QString *strToBeFilled)
+{
+ *strToBeFilled = filterDescription;
+};
+
+void FilterControls::getIcon(QIcon *icon)
+{
+ *icon = QIcon(":/images/filter-16.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_DZ1/images/filter-16.png b/FTNoIR_Filter_DZ1/images/filter-16.png
new file mode 100644
index 00000000..ecde6a10
--- /dev/null
+++ b/FTNoIR_Filter_DZ1/images/filter-16.png
Binary files differ
diff --git a/FTNoIR_Filter_EWMA2/FTNoIR_Filter_EWMA2.h b/FTNoIR_Filter_EWMA2/FTNoIR_Filter_EWMA2.h
index feec6f1f..f335eb47 100644
--- a/FTNoIR_Filter_EWMA2/FTNoIR_Filter_EWMA2.h
+++ b/FTNoIR_Filter_EWMA2/FTNoIR_Filter_EWMA2.h
@@ -23,8 +23,8 @@
* *
********************************************************************************/
#pragma once
-#ifndef INCLUDED_FTN_FILTER_EWMA2_H
-#define INCLUDED_FTN_FILTER_EWMA2_H
+#ifndef INCLUDED_FTN_FILTER_H
+#define INCLUDED_FTN_FILTER_H
#include "..\ftnoir_filter_base\ftnoir_filter_base.h"
#include "ui_FTNoIR_FilterControls.h"
@@ -34,11 +34,11 @@
// EWMA Filter: Exponentially Weighted Moving Average filter with dynamic smoothing parameter
//
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-class FTNoIR_Filter_EWMA2 : public IFilter
+class FTNoIR_Filter : public IFilter
{
public:
- FTNoIR_Filter_EWMA2();
- ~FTNoIR_Filter_EWMA2();
+ FTNoIR_Filter();
+ ~FTNoIR_Filter();
void Release();
void Initialize();
@@ -49,8 +49,6 @@ public:
void getFilterShortName(QString *strToBeFilled);
void getFilterDescription(QString *strToBeFilled);
- bool setParameterValue(const int index, const float newvalue);
-
private:
void loadSettings(); // Load the settings from the INI-file
THeadPoseData newHeadPose; // Structure with new headpose
@@ -62,25 +60,14 @@ private:
float alpha[6];
float smoothed_alpha[6];
- //parameter list for the filter-function(s)
- enum
- {
- kMinSmoothing=0,
- kMaxSmoothing,
- kSmoothingScaleCurve,
- kNumFilterParameters // Indicate number of parameters used
- };
+ float kMinSmoothing;
+ float kMaxSmoothing;
+ float kSmoothingScaleCurve;
QString filterFullName; // Filters' name and description
QString filterShortName;
QString filterDescription;
- QList<float> parameterValueAsFloat;
- QList<std::pair<float,float>> parameterRange;
- QList<float> parameterSteps;
- QList<QString> parameterNameAsString;
- QList<QString> parameterValueAsString;
- QList<QString> parameterUnitsAsString;
};
//*******************************************************************************************************
@@ -102,6 +89,7 @@ public:
void getFilterFullName(QString *strToBeFilled);
void getFilterShortName(QString *strToBeFilled);
void getFilterDescription(QString *strToBeFilled);
+ void getIcon(QIcon *icon);
private:
Ui::UICFilterControls ui;
@@ -123,6 +111,6 @@ private slots:
void settingChanged( int ) { settingsDirty = true; };
};
-#endif //INCLUDED_FTN_FILTER_EWMA2_H
+#endif //INCLUDED_FTN_FILTER_H
//END
diff --git a/FTNoIR_Filter_EWMA2/FTNoIR_Filter_EWMA2.vcproj b/FTNoIR_Filter_EWMA2/FTNoIR_Filter_EWMA2.vcproj
index 3f501218..918f8b28 100644
--- a/FTNoIR_Filter_EWMA2/FTNoIR_Filter_EWMA2.vcproj
+++ b/FTNoIR_Filter_EWMA2/FTNoIR_Filter_EWMA2.vcproj
@@ -253,6 +253,32 @@
UniqueIdentifier="{D9D6E242-F8AF-46E4-B9FD-80ECBC20BA3E}"
ParseFiles="false"
>
+ <File
+ RelativePath=".\Filter.qrc"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Rcc&apos;ing $(InputFileName)..."
+ CommandLine="&quot;$(QTDIR)\bin\rcc.exe&quot; -name &quot;$(InputName)&quot; -no-compress &quot;$(InputPath)&quot; -o .\GeneratedFiles\qrc_$(InputName).cpp&#x0D;&#x0A;"
+ AdditionalDependencies="$(InputPath);.\images\Settings16.png;.\images\SettingsOpen16.png;.\UIElements\Donate.png;.\UIElements\Curves.png;.\images\rotation_DOFs.png;.\images\translation_DOFs.png;.\images\FlightGear.ico;.\images\330px-6DOF_en.png;.\images\Freetrack.ico;.\images\FaceTrackNoIR.ico;.\images\SeeingMachines.ico;.\images\Mouse.ico;.\images\FS9.ico;.\images\FSX.ico;.\images\PPJoy.ico;.\images\TrackIR.ico;.\UIElements\aboutFaceTrackNoIR.png"
+ Outputs=".\GeneratedFiles\qrc_$(InputName).cpp"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Rcc&apos;ing $(InputFileName)..."
+ CommandLine="&quot;$(QTDIR)\bin\rcc.exe&quot; -name &quot;$(InputName)&quot; -no-compress &quot;$(InputPath)&quot; -o .\GeneratedFiles\qrc_$(InputName).cpp&#x0D;&#x0A;"
+ AdditionalDependencies="$(InputPath);.\images\Settings16.png;.\images\SettingsOpen16.png;.\UIElements\Donate.png;.\UIElements\Curves.png;.\images\rotation_DOFs.png;.\images\translation_DOFs.png;.\images\FlightGear.ico;.\images\330px-6DOF_en.png;.\images\Freetrack.ico;.\images\FaceTrackNoIR.ico;.\images\SeeingMachines.ico;.\images\Mouse.ico;.\images\FS9.ico;.\images\FSX.ico;.\images\PPJoy.ico;.\images\TrackIR.ico;.\UIElements\aboutFaceTrackNoIR.png"
+ Outputs=".\GeneratedFiles\qrc_$(InputName).cpp"
+ />
+ </FileConfiguration>
+ </File>
</Filter>
<Filter
Name="Generated Files"
@@ -261,6 +287,26 @@
SourceControlFiles="false"
>
<File
+ RelativePath=".\GeneratedFiles\qrc_Filter.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="0"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="0"
+ />
+ </FileConfiguration>
+ </File>
+ <File
RelativePath=".\generatedfiles\ui_FTNoIR_FilterControls.h"
>
</File>
diff --git a/FTNoIR_Filter_EWMA2/ftnoir_filter_ewma2.cpp b/FTNoIR_Filter_EWMA2/ftnoir_filter_ewma2.cpp
index 7034a152..179db04c 100644
--- a/FTNoIR_Filter_EWMA2/ftnoir_filter_ewma2.cpp
+++ b/FTNoIR_Filter_EWMA2/ftnoir_filter_ewma2.cpp
@@ -22,7 +22,7 @@
* with this program; if not, see <http://www.gnu.org/licenses/>. *
* *
********************************************************************************/
-#include "ftnoir_filter_EWMA2.h"
+#include "ftnoir_filter_ewma2.h"
#include "math.h"
#include <QDebug>
@@ -34,65 +34,32 @@
//
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-FTNoIR_Filter_EWMA2::FTNoIR_Filter_EWMA2()
+FTNoIR_Filter::FTNoIR_Filter()
{
//populate the description strings
filterFullName = "EWMA Filter Mk2";
filterShortName = "EWMA";
filterDescription = "Exponentially Weighted Moving Average filter with dynamic smoothing parameter";
- //allocate memory for the parameters
- parameterValueAsFloat.clear();
- parameterRange.clear();
- parameterSteps.clear();
- parameterNameAsString.clear();
- parameterValueAsString.clear();
- parameterUnitsAsString.clear();
-
- //set up parameters
- parameterNameAsString.append("MinSmoothing");
- parameterUnitsAsString.append("Frames");
- parameterRange.append(std::pair<float,float>(1.0f,100.0f));
- parameterSteps.append(1.0f);
- parameterValueAsFloat.append(0.0f);
- parameterValueAsString.append("");
- setParameterValue(kMinSmoothing,10.0f);
-
- parameterNameAsString.append("MaxSmoothing");
- parameterUnitsAsString.append("Frames");
- parameterRange.append(std::pair<float,float>(1.0f,100.0f));
- parameterSteps.append(1.0f);
- parameterValueAsFloat.append(0.0f);
- parameterValueAsString.append("");
- setParameterValue(kMaxSmoothing,50.0f);
-
- parameterNameAsString.append("SmoothingScaleCurve");
- parameterUnitsAsString.append("Power");
- parameterRange.append(std::pair<float,float>(0.25f,10.0f));
- parameterSteps.append(0.0f);
- parameterValueAsFloat.append(0.0f);
- parameterValueAsString.append("");
- setParameterValue(kSmoothingScaleCurve,10.0f);
-
first_run = true;
alpha_smoothing = 0.02f; // this is a constant for now, might be a parameter later
loadSettings(); // Load the Settings
}
-FTNoIR_Filter_EWMA2::~FTNoIR_Filter_EWMA2()
+FTNoIR_Filter::~FTNoIR_Filter()
{
}
-void FTNoIR_Filter_EWMA2::Release()
+void FTNoIR_Filter::Release()
{
delete this;
}
-void FTNoIR_Filter_EWMA2::Initialize()
+void FTNoIR_Filter::Initialize()
{
- qDebug() << "FTNoIR_Filter_EWMA2::Initialize says: Starting ";
+ qDebug() << "FTNoIR_Filter::Initialize says: Starting ";
loadSettings();
return;
}
@@ -100,27 +67,27 @@ void FTNoIR_Filter_EWMA2::Initialize()
//
// Load the current Settings from the currently 'active' INI-file.
//
-void FTNoIR_Filter_EWMA2::loadSettings() {
- qDebug() << "FTNoIR_Filter_EWMA2::loadSettings says: Starting ";
+void FTNoIR_Filter::loadSettings() {
+ qDebug() << "FTNoIR_Filter::loadSettings says: Starting ";
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_EWMA2::loadSettings says: iniFile = " << currentFile;
+ qDebug() << "FTNoIR_Filter::loadSettings says: iniFile = " << currentFile;
//
// The EWMA2-filter-settings are in the Tracking group: this is because they used to be on the Main Form of FaceTrackNoIR
//
iniFile.beginGroup ( "Tracking" );
- setParameterValue(0, iniFile.value ( "minSmooth", 15 ).toInt());
- setParameterValue(1, iniFile.value ( "maxSmooth", 50 ).toInt());
- setParameterValue(2, iniFile.value ( "powCurve", 10 ).toInt());
+ kMinSmoothing = iniFile.value ( "minSmooth", 15 ).toInt();
+ kMaxSmoothing = iniFile.value ( "maxSmooth", 50 ).toInt();
+ kSmoothingScaleCurve = iniFile.value ( "powCurve", 10 ).toInt();
iniFile.endGroup ();
}
-void FTNoIR_Filter_EWMA2::FilterHeadPoseData(THeadPoseData *current_camera_position, THeadPoseData *target_camera_position, THeadPoseData *new_camera_position, bool newTarget)
+void FTNoIR_Filter::FilterHeadPoseData(THeadPoseData *current_camera_position, THeadPoseData *target_camera_position, THeadPoseData *new_camera_position, bool newTarget)
{
//non-optimised version for clarity
float prev_output[6];
@@ -195,13 +162,13 @@ void FTNoIR_Filter_EWMA2::FilterHeadPoseData(THeadPoseData *current_camera_posit
// if (newTarget) {
for (i=0;i<6;i++)
{
- alpha[i]=1.0f/(parameterValueAsFloat[kMinSmoothing]+((1.0f-pow(norm_output_delta[i],parameterValueAsFloat[kSmoothingScaleCurve]))*smoothing_frames_range));
+ alpha[i]=1.0f/(kMinSmoothing+((1.0f-pow(norm_output_delta[i],kSmoothingScaleCurve))*smoothing_frames_range));
smoothed_alpha[i]=(alpha_smoothing*alpha[i])+((1.0f-alpha_smoothing)*prev_alpha[i]);
}
// }
- //qDebug() << "FTNoIR_Filter_EWMA2::FilterHeadPoseData() smoothing frames = " << smoothing_frames_range;
- //qDebug() << "FTNoIR_Filter_EWMA2::FilterHeadPoseData() alpha[3] = " << alpha[3];
+ //qDebug() << "FTNoIR_Filter::FilterHeadPoseData() smoothing frames = " << smoothing_frames_range;
+ //qDebug() << "FTNoIR_Filter::FilterHeadPoseData() alpha[3] = " << alpha[3];
//use the same (largest) smoothed alpha for each channel
//NB: larger alpha = *less* lag (opposite to what you'd expect)
@@ -259,43 +226,23 @@ void FTNoIR_Filter_EWMA2::FilterHeadPoseData(THeadPoseData *current_camera_posit
return;
}
-void FTNoIR_Filter_EWMA2::getFilterFullName(QString *strToBeFilled)
+void FTNoIR_Filter::getFilterFullName(QString *strToBeFilled)
{
*strToBeFilled = filterFullName;
};
-void FTNoIR_Filter_EWMA2::getFilterShortName(QString *strToBeFilled)
+void FTNoIR_Filter::getFilterShortName(QString *strToBeFilled)
{
*strToBeFilled = filterShortName;
};
-void FTNoIR_Filter_EWMA2::getFilterDescription(QString *strToBeFilled)
+void FTNoIR_Filter::getFilterDescription(QString *strToBeFilled)
{
*strToBeFilled = filterDescription;
};
-bool FTNoIR_Filter_EWMA2::setParameterValue(const int index, const float newvalue)
-{
- if ((index >= 0) && (index < parameterValueAsFloat.size()))
- {
- parameterValueAsFloat[index]=std::min(std::max(newvalue,parameterRange[index].first),parameterRange[index].second);
-// updateParameterString(index);
-
- if (index==kMinSmoothing || index==kMaxSmoothing)
- {
- smoothing_frames_range=parameterValueAsFloat[kMaxSmoothing]-parameterValueAsFloat[kMinSmoothing];
- }
- return true;
- }
- else
- {
- return false;
- }
-};
-
-
////////////////////////////////////////////////////////////////////////////////
// Factory function that creates instances if the Filter object.
@@ -307,5 +254,5 @@ bool FTNoIR_Filter_EWMA2::setParameterValue(const int index, const float newvalu
FTNOIR_FILTER_BASE_EXPORT FILTERHANDLE __stdcall GetFilter()
{
- return new FTNoIR_Filter_EWMA2;
+ return new FTNoIR_Filter;
}
diff --git a/FTNoIR_Filter_EWMA2/ftnoir_filter_ewma2_dialog.cpp b/FTNoIR_Filter_EWMA2/ftnoir_filter_ewma2_dialog.cpp
index f2523145..fd24d552 100644
--- a/FTNoIR_Filter_EWMA2/ftnoir_filter_ewma2_dialog.cpp
+++ b/FTNoIR_Filter_EWMA2/ftnoir_filter_ewma2_dialog.cpp
@@ -204,6 +204,11 @@ void FilterControls::getFilterDescription(QString *strToBeFilled)
*strToBeFilled = filterDescription;
};
+void FilterControls::getIcon(QIcon *icon)
+{
+ *icon = QIcon(":/images/filter-16.png");
+};
+
////////////////////////////////////////////////////////////////////////////////
// Factory function that creates instances if the Filter-settings dialog object.
diff --git a/FaceTrackNoIR/FaceTrackNoIR.cpp b/FaceTrackNoIR/FaceTrackNoIR.cpp
index 73d201c3..7e7800bf 100644
--- a/FaceTrackNoIR/FaceTrackNoIR.cpp
+++ b/FaceTrackNoIR/FaceTrackNoIR.cpp
@@ -153,6 +153,7 @@ void FaceTrackNoIR::setupFaceTrackNoIR() {
connect(ui.iconcomboProfile, SIGNAL(currentIndexChanged(int)), this, SLOT(profileSelected(int)));
connect(ui.iconcomboTrackerSource, SIGNAL(currentIndexChanged(int)), this, SLOT(trackingSourceSelected(int)));
connect(ui.iconcomboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(setIcon(int)));
+ connect(ui.iconcomboFilter, SIGNAL(currentIndexChanged(int)), this, SLOT(filterSelected(int)));
//Setup the timer for automatically minimizing after StartTracker.
timMinimizeFTN = new QTimer(this);
@@ -332,9 +333,6 @@ void FaceTrackNoIR::save() {
iniFile.setValue ( "invertY", ui.chkInvertY->isChecked() );
iniFile.setValue ( "invertZ", ui.chkInvertZ->isChecked() );
iniFile.setValue ( "useEWMA", ui.chkUseEWMA->isChecked() );
- //iniFile.setValue ( "minSmooth", ui.minSmooth->value() );
- //iniFile.setValue ( "powCurve", ui.powCurve->value() );
- //iniFile.setValue ( "maxSmooth", ui.maxSmooth->value() );
iniFile.endGroup ();
iniFile.beginGroup ( "GameProtocol" );
@@ -453,9 +451,6 @@ void FaceTrackNoIR::loadSettings() {
ui.chkInvertZ->setChecked (iniFile.value ( "invertZ", 0 ).toBool());
ui.chkUseEWMA->setChecked (iniFile.value ( "useEWMA", 1 ).toBool());
- //ui.minSmooth->setValue (iniFile.value ( "minSmooth", 15 ).toInt());
- //ui.maxSmooth->setValue (iniFile.value ( "maxSmooth", 50 ).toInt());
- //ui.powCurve->setValue (iniFile.value ( "powCurve", 10 ).toInt());
iniFile.endGroup ();
iniFile.beginGroup ( "GameProtocol" );
@@ -468,6 +463,22 @@ void FaceTrackNoIR::loadSettings() {
trackingSourceSelected( ui.iconcomboTrackerSource->currentIndex() );
iniFile.endGroup ();
+ //
+ // Read the currently selected Filter from the INI-file.
+ //
+ iniFile.beginGroup ( "Filter" );
+ QString selectedFilterName = iniFile.value ( "Selection", "FTNoIR_Filter_EWMA2.dll" ).toString();
+ qDebug() << "createIconGroupBox says: selectedFilterName = " << selectedFilterName;
+ iniFile.endGroup ();
+
+ disconnect(ui.iconcomboFilter, SIGNAL(currentIndexChanged(int)), this, SLOT(filterSelected(int)));
+ for ( int i = 0; i < filterFileList.size(); i++) {
+ if (filterFileList.at(i) == selectedFilterName) {
+ ui.iconcomboFilter->setCurrentIndex( i );
+ }
+ }
+ connect(ui.iconcomboFilter, SIGNAL(currentIndexChanged(int)), this, SLOT(filterSelected(int)));
+
settingsDirty = false;
}
@@ -1005,6 +1016,7 @@ void FaceTrackNoIR::createIconGroupBox()
importGetFilterDialog getIT;
QLibrary *filterLib;
QString *filterName;
+QIcon *filterIcon;
QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // Registry settings (in HK_USER)
@@ -1029,14 +1041,6 @@ QString *filterName;
//
- // Read the currently selected Filter from the INI-file.
- //
- iniFile.beginGroup ( "Filter" );
- QString selectedFilterName = iniFile.value ( "Selection", "FTNoIR_Filter_EWMA2.dll" ).toString();
- qDebug() << "createIconGroupBox says: selectedFilterName = " << selectedFilterName;
- iniFile.endGroup ();
-
- //
// Get a List of all the Filter-DLL-files in the Program-folder.
//
QDir settingsDir( QCoreApplication::applicationDirPath() );
@@ -1064,6 +1068,7 @@ QString *filterName;
// Show the appropriate Protocol-server Settings
filterLib = new QLibrary(filterFileList.at(i));
filterName = new QString("");
+ filterIcon = new QIcon();
getIT = (importGetFilterDialog) filterLib->resolve("GetFilterDialog");
if (getIT) {
@@ -1072,6 +1077,7 @@ QString *filterName;
{
pFilterDialog = ptrXyz;
pFilterDialog->getFilterFullName( filterName );
+ pFilterDialog->getIcon( filterIcon );
qDebug() << "FaceTrackNoIR::showServerControls GetFilterDialog Function Resolved!";
}
else {
@@ -1082,16 +1088,10 @@ QString *filterName;
QMessageBox::warning(0,"FaceTrackNoIR Error", "DLL not loaded",QMessageBox::Ok,QMessageBox::NoButton);
}
- ui.iconcomboFilter->addItem(QIcon(":/images/Settings16.png"), *filterName );
- if (filterFileList.at(i) == selectedFilterName) {
- ui.iconcomboFilter->setItemIcon(i, QIcon(":/images/SettingsOpen16.png"));
- ui.iconcomboFilter->setCurrentIndex( i );
- }
+ ui.iconcomboFilter->addItem(*filterIcon, *filterName );
}
connect(ui.iconcomboFilter, SIGNAL(currentIndexChanged(int)), this, SLOT(filterSelected(int)));
-// qDebug() << "loadSettings says: iniFile = " << currentFile;
-
}
//
@@ -1222,7 +1222,7 @@ void FaceTrackNoIR::profileSelected(int index)
QFileInfo pathInfo ( currentFile );
//
- // Get a List of all the INI-files in the (currently active) Settings-folder.
+ // Save the name of the INI-file in the Registry.
//
settings.setValue ("SettingsFile", pathInfo.absolutePath() + "/" + iniFileList.at(ui.iconcomboProfile->currentIndex()));
loadSettings();
@@ -1233,18 +1233,19 @@ void FaceTrackNoIR::profileSelected(int index)
//
void FaceTrackNoIR::filterSelected(int index)
{
- ////
- //// Read the current INI-file setting, to get the folder in which it's located...
- ////
- //QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // Registry settings (in HK_USER)
- //QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString();
- // QFileInfo pathInfo ( currentFile );
-
- ////
- //// Get a List of all the INI-files in the (currently active) Settings-folder.
- ////
- //settings.setValue ("SettingsFile", pathInfo.absolutePath() + "/" + iniFileList.at(ui.iconcomboProfile->currentIndex()));
- //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)
+
+ //
+ // Save the name of the filter in the INI-file. Do this immediately, so the Tracker can just read it from the INI-file to load the filter.
+ //
+ iniFile.beginGroup ( "Filter" );
+ iniFile.setValue ( "Selection", filterFileList.at(ui.iconcomboFilter->currentIndex()) );
+ iniFile.endGroup ();
+
+ ui.btnShowFilterControls->setEnabled ( true );
}
//
diff --git a/FaceTrackNoIR/FaceTrackNoIR.h b/FaceTrackNoIR/FaceTrackNoIR.h
index 93403be7..f39062bc 100644
--- a/FaceTrackNoIR/FaceTrackNoIR.h
+++ b/FaceTrackNoIR/FaceTrackNoIR.h
@@ -93,8 +93,6 @@ private:
/** Widget variables **/
QVBoxLayout *l;
-// QWidget *_engine_controls;
-// QWidget *_server_controls;
QWidget *_preferences;
QWidget *_keyboard_shortcuts;
QWidget *_curve_config;
diff --git a/FaceTrackNoIR/tracker.cpp b/FaceTrackNoIR/tracker.cpp
index 70754a1c..cb3a5b79 100644
--- a/FaceTrackNoIR/tracker.cpp
+++ b/FaceTrackNoIR/tracker.cpp
@@ -255,8 +255,19 @@ QFrame *video_frame;
//
// Load the DLL with the filter-logic and retrieve a pointer to the Filter-class.
- //
- filterLib = new QLibrary("FTNoIR_Filter_EWMA2.dll");
+ // The name of the filter can be found in the INI-file...
+ libName.clear();
+ 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" );
+ libName = iniFile.value ( "Selection", "FTNoIR_Filter_EWMA2.dll" ).toString();
+ qDebug() << "Tracker::Tracker() says: selectedFilterName = " << libName;
+ iniFile.endGroup ();
+
+ filterLib = new QLibrary(libName);
getFilter = (importGetFilter) filterLib->resolve("GetFilter");
if (getFilter) {