diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2013-10-27 08:06:47 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2013-10-27 08:06:47 +0100 |
commit | ab38255154ec19b2167511911c703337edbc6b06 (patch) | |
tree | c79ec3f3d7a8c12caf9e30394a9f983a034f30de /ftnoir_filter_accela | |
parent | aaed9e3cdc4f3e7bb2a6d9b039d05bf395e1e046 (diff) |
Accela: customizable deadzone
Signed-off-by: Stanislaw Halik <sthalik@misaki.pl>
Diffstat (limited to 'ftnoir_filter_accela')
-rw-r--r-- | ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui | 57 | ||||
-rw-r--r-- | ftnoir_filter_accela/ftnoir_filter_accela.cpp | 13 | ||||
-rw-r--r-- | ftnoir_filter_accela/ftnoir_filter_accela.h | 3 | ||||
-rw-r--r-- | ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp | 12 |
4 files changed, 70 insertions, 15 deletions
diff --git a/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui b/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui index c7bd2808..1d3e95ef 100644 --- a/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui +++ b/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui @@ -229,6 +229,63 @@ background:none;</string> </property> </widget> </item> + <item row="3" column="0"> + <widget class="QLabel" name="lblSensYaw_6"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Expanding"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>25</width> + <height>0</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>150</width> + <height>16777215</height> + </size> + </property> + <property name="styleSheet"> + <string notr="true">color:#0; +background:none;</string> + </property> + <property name="text"> + <string>Deadzone</string> + </property> + </widget> + </item> + <item row="3" column="1"> + <widget class="QDoubleSpinBox" name="deadzone"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Maximum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="alignment"> + <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> + </property> + <property name="decimals"> + <number>3</number> + </property> + <property name="minimum"> + <double>0.000000000000000</double> + </property> + <property name="maximum"> + <double>3.000000000000000</double> + </property> + <property name="singleStep"> + <double>0.050000000000000</double> + </property> + <property name="value"> + <double>0.000000000000000</double> + </property> + </widget> + </item> </layout> </widget> </item> diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.cpp b/ftnoir_filter_accela/ftnoir_filter_accela.cpp index 1168004f..63c82722 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela.cpp @@ -34,9 +34,8 @@ void FTNoIR_Filter::loadSettings() { zoom_factor = iniFile.value("zoom-slowness", ACCELA_ZOOM_SLOWNESS).toDouble();
rotation_alpha = iniFile.value("rotation-alpha", ACCELA_SMOOTHING_ROTATION).toDouble();
translation_alpha = iniFile.value("translation-alpha", ACCELA_SMOOTHING_TRANSLATION).toDouble();
- iniFile.endGroup ();
- iniFile.beginGroup("Accela-Scaling");
+ deadzone = iniFile.value("deadzone", 0.0).toDouble();
// bigger means less filtering
static const double init_scaling[] = {
1.5, // X
@@ -50,23 +49,23 @@ void FTNoIR_Filter::loadSettings() { {
scaling[i] = iniFile.value(QString("axis-%1").arg(QString::number(i)), init_scaling[i]).toDouble();
}
-
iniFile.endGroup();
}
-void FTNoIR_Filter::receiveSettings(double rot, double trans, double zoom_fac)
+void FTNoIR_Filter::receiveSettings(double rot, double trans, double zoom_fac, double dz)
{
QMutexLocker foo(&mutex);
rotation_alpha = rot;
translation_alpha = trans;
zoom_factor = zoom_fac;
+ deadzone = dz;
}
-static inline double parabola(const double a, const double x)
+static inline double parabola(const double a, const double x, const double dz)
{
const double a1 = 1./a;
- return a1 * pow(std::max<double>(x - 0.175, 1e-5), 2.2);
+ return a1 * pow(std::max<double>(x - dz, 1e-3), 1.975);
}
void FTNoIR_Filter::FilterHeadPoseData(const double* target_camera_position,
@@ -94,7 +93,7 @@ void FTNoIR_Filter::FilterHeadPoseData(const double* target_camera_position, const double x = fabs(vec);
const double a = i >= 3 ? rotation_alpha : translation_alpha;
const double reduction = 1. / std::max(1., 1. + zoom_factor * -last_post_filter_values[TZ] / 1000);
- const double velocity = parabola(a, x * scaling[i]) * reduction;
+ const double velocity = parabola(a, x * scaling[i], deadzone) * reduction;
const double result = current_camera_position[i] + velocity * sign;
const bool done = sign > 0 ? result >= target_camera_position[i] : result <= target_camera_position[i];
new_camera_position[i] = current_camera_position[i] = done ? target_camera_position[i] : result;
diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.h b/ftnoir_filter_accela/ftnoir_filter_accela.h index 512b4576..1808e026 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.h +++ b/ftnoir_filter_accela/ftnoir_filter_accela.h @@ -47,7 +47,7 @@ public: void Initialize() {
first_run = true;
}
- void receiveSettings(double rot, double trans, double zoom_fac);
+ void receiveSettings(double rot, double trans, double zoom_fac, double deadzone);
private:
QMutex mutex;
void loadSettings();
@@ -55,6 +55,7 @@ private: double rotation_alpha, translation_alpha, zoom_factor;
double current_camera_position[6];
double scaling[6];
+ double deadzone;
};
//*******************************************************************************************************
diff --git a/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp b/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp index 559b9d4d..ca3377e1 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp @@ -158,9 +158,8 @@ void FilterControls::loadSettings() { ui.spinZoom->setValue(iniFile.value("zoom-slowness", ACCELA_ZOOM_SLOWNESS).toInt()); ui.rotation_alpha->setValue(iniFile.value("rotation-alpha", ACCELA_SMOOTHING_ROTATION).toDouble()); ui.translation_alpha->setValue(iniFile.value("translation-alpha", ACCELA_SMOOTHING_TRANSLATION).toDouble()); - iniFile.endGroup (); + ui.deadzone->setValue(iniFile.value("deadzone", 0).toDouble()); - iniFile.beginGroup("Accela-Scaling"); // bigger means less filtering static const double init_scaling[] = { 1.5, // X @@ -184,6 +183,7 @@ void FilterControls::loadSettings() { { boxen[i]->setValue(iniFile.value(QString("axis-%1").arg(QString::number(i)), init_scaling[i]).toDouble()); } + iniFile.endGroup(); settingsDirty = false; @@ -200,15 +200,13 @@ void FilterControls::save() { qDebug() << "FTNoIR_Filter::save() says: iniFile = " << currentFile; - double rot, trans, zoom; + double rot, trans, zoom, deadzone; iniFile.beginGroup ( "Accela" ); iniFile.setValue("rotation-alpha", rot = ui.rotation_alpha->value()); iniFile.setValue("translation-alpha", trans = ui.translation_alpha->value()); iniFile.setValue("zoom-slowness", zoom = ui.spinZoom->value()); - iniFile.endGroup (); - - iniFile.beginGroup("Accela-Scaling"); + iniFile.setValue("deadzone", deadzone = ui.deadzone->value()); QDoubleSpinBox* boxen[] = { ui.doubleSpinBox, @@ -228,7 +226,7 @@ void FilterControls::save() { settingsDirty = false; if (accela_filter) - accela_filter->receiveSettings(rot, trans, zoom); + accela_filter->receiveSettings(rot, trans, zoom, deadzone); } //////////////////////////////////////////////////////////////////////////////// |