summaryrefslogtreecommitdiffhomepage
path: root/FTNoIR_Filter_DZ1
diff options
context:
space:
mode:
authorWim Vriend <facetracknoir@gmail.com>2012-01-15 16:56:28 +0000
committerWim Vriend <facetracknoir@gmail.com>2012-01-15 16:56:28 +0000
commit671a0a2fb81830b364d708a3f6123e44f88042cf (patch)
tree36331bc575835e513bbc772fa112534a5c28c72d /FTNoIR_Filter_DZ1
parentd6086d8203ae4f4b45f3d97960788d603fc78e16 (diff)
Finished making the Filter a plug-in and implemented the DZ1 filter.
First attempt though... git-svn-id: svn+ssh://svn.code.sf.net/p/facetracknoir/code@100 19e81ba0-9b1a-49c3-bd6c-561e1906d5fb
Diffstat (limited to 'FTNoIR_Filter_DZ1')
-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
7 files changed, 1780 insertions, 0 deletions
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