diff options
-rw-r--r-- | ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui | 29 | ||||
-rw-r--r-- | ftnoir_filter_accela/ftnoir_filter_accela.cpp | 21 | ||||
-rw-r--r-- | ftnoir_filter_accela/ftnoir_filter_accela.h | 3 | ||||
-rw-r--r-- | ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp | 9 |
4 files changed, 50 insertions, 12 deletions
diff --git a/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui b/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui index 1d3e95ef..5ba33614 100644 --- a/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui +++ b/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui @@ -286,6 +286,35 @@ background:none;</string> </property> </widget> </item> + <item row="4" column="0"> + <widget class="QLabel" name="label_10"> + <property name="text"> + <string>Exponent</string> + </property> + </widget> + </item> + <item row="4" column="1"> + <widget class="QDoubleSpinBox" name="expt"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="decimals"> + <number>3</number> + </property> + <property name="minimum"> + <double>0.050000000000000</double> + </property> + <property name="maximum"> + <double>100.000000000000000</double> + </property> + <property name="singleStep"> + <double>0.050000000000000</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 63c82722..73a9dd8f 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela.cpp @@ -38,21 +38,23 @@ void FTNoIR_Filter::loadSettings() { deadzone = iniFile.value("deadzone", 0.0).toDouble();
// bigger means less filtering
static const double init_scaling[] = {
- 1.5, // X
- 1.5, // Y
+ 1, // X
+ 1, // Y
1, // Z
- 0.8, // Yaw
- 0.9, // Pitch
- 1.25 // Roll
+ 1, // Yaw
+ 1, // Pitch
+ 1 // Roll
};
for (int i = 0; i < 6; i++)
{
scaling[i] = iniFile.value(QString("axis-%1").arg(QString::number(i)), init_scaling[i]).toDouble();
}
+ expt = iniFile.value("exponent", 2.0).toDouble();
+
iniFile.endGroup();
}
-void FTNoIR_Filter::receiveSettings(double rot, double trans, double zoom_fac, double dz)
+void FTNoIR_Filter::receiveSettings(double rot, double trans, double zoom_fac, double dz, double exponent)
{
QMutexLocker foo(&mutex);
@@ -60,12 +62,13 @@ void FTNoIR_Filter::receiveSettings(double rot, double trans, double zoom_fac, d translation_alpha = trans;
zoom_factor = zoom_fac;
deadzone = dz;
+ expt = exponent;
}
-static inline double parabola(const double a, const double x, const double dz)
+static inline double parabola(const double a, const double x, const double dz, const double expt)
{
const double a1 = 1./a;
- return a1 * pow(std::max<double>(x - dz, 1e-3), 1.975);
+ return a1 * pow(std::max<double>(x - dz, 1e-3), expt);
}
void FTNoIR_Filter::FilterHeadPoseData(const double* target_camera_position,
@@ -93,7 +96,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], deadzone) * reduction;
+ const double velocity = parabola(a, x * scaling[i], deadzone, expt) * 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 1808e026..8c770df9 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, double deadzone);
+ void receiveSettings(double rot, double trans, double zoom_fac, double deadzone, double expt);
private:
QMutex mutex;
void loadSettings();
@@ -56,6 +56,7 @@ private: double current_camera_position[6];
double scaling[6];
double deadzone;
+ double expt;
};
//*******************************************************************************************************
diff --git a/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp b/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp index ca3377e1..88c0a794 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp +++ b/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp @@ -63,6 +63,8 @@ FilterControls::FilterControls() : connect(boxen[i], SIGNAL(valueChanged(double)), this, SLOT(settingChanged(double))); } + connect(ui.expt, SIGNAL(valueChanged(double)), this, SLOT(settingChanged(double))); + qDebug() << "FilterControls() says: started"; } @@ -184,6 +186,8 @@ void FilterControls::loadSettings() { boxen[i]->setValue(iniFile.value(QString("axis-%1").arg(QString::number(i)), init_scaling[i]).toDouble()); } + ui.expt->setValue(iniFile.value("exponent", 2.0).toDouble()); + iniFile.endGroup(); settingsDirty = false; @@ -200,13 +204,14 @@ void FilterControls::save() { qDebug() << "FTNoIR_Filter::save() says: iniFile = " << currentFile; - double rot, trans, zoom, deadzone; + double rot, trans, zoom, deadzone, expt; 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.setValue("deadzone", deadzone = ui.deadzone->value()); + iniFile.setValue("exponent", expt = ui.expt->value()); QDoubleSpinBox* boxen[] = { ui.doubleSpinBox, @@ -226,7 +231,7 @@ void FilterControls::save() { settingsDirty = false; if (accela_filter) - accela_filter->receiveSettings(rot, trans, zoom, deadzone); + accela_filter->receiveSettings(rot, trans, zoom, deadzone, expt); } //////////////////////////////////////////////////////////////////////////////// |