diff options
author | Wim Vriend <facetracknoir@gmail.com> | 2012-01-15 16:56:28 +0000 |
---|---|---|
committer | Wim Vriend <facetracknoir@gmail.com> | 2012-01-15 16:56:28 +0000 |
commit | 671a0a2fb81830b364d708a3f6123e44f88042cf (patch) | |
tree | 36331bc575835e513bbc772fa112534a5c28c72d /FTNoIR_Filter_EWMA2 | |
parent | d6086d8203ae4f4b45f3d97960788d603fc78e16 (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_EWMA2')
-rw-r--r-- | FTNoIR_Filter_EWMA2/FTNoIR_Filter_EWMA2.h | 32 | ||||
-rw-r--r-- | FTNoIR_Filter_EWMA2/FTNoIR_Filter_EWMA2.vcproj | 46 | ||||
-rw-r--r-- | FTNoIR_Filter_EWMA2/ftnoir_filter_ewma2.cpp | 93 | ||||
-rw-r--r-- | FTNoIR_Filter_EWMA2/ftnoir_filter_ewma2_dialog.cpp | 5 |
4 files changed, 81 insertions, 95 deletions
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'ing $(InputFileName)..."
+ CommandLine=""$(QTDIR)\bin\rcc.exe" -name "$(InputName)" -no-compress "$(InputPath)" -o .\GeneratedFiles\qrc_$(InputName).cpp
"
+ 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'ing $(InputFileName)..."
+ CommandLine=""$(QTDIR)\bin\rcc.exe" -name "$(InputName)" -no-compress "$(InputPath)" -o .\GeneratedFiles\qrc_$(InputName).cpp
"
+ 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.
|