diff options
Diffstat (limited to 'ftnoir_filter_accela/ftnoir_filter_accela.h')
-rw-r--r-- | ftnoir_filter_accela/ftnoir_filter_accela.h | 60 |
1 files changed, 26 insertions, 34 deletions
diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.h b/ftnoir_filter_accela/ftnoir_filter_accela.h index b5d0995c..98e5cf1f 100644 --- a/ftnoir_filter_accela/ftnoir_filter_accela.h +++ b/ftnoir_filter_accela/ftnoir_filter_accela.h @@ -1,53 +1,42 @@ #pragma once #include "ui_ftnoir_accela_filtercontrols.h" #include "opentrack/plugin-api.hpp" +#include <atomic> #include <QMutex> - -#define ACCELA_SMOOTHING_ROTATION 60.0 -#define ACCELA_SMOOTHING_TRANSLATION 40.0 -#define ACCELA_SECOND_ORDER_ALPHA 100.0 -#define ACCELA_THIRD_ORDER_ALPHA 180.0 +#include <QTimer> #include "opentrack/options.hpp" using namespace options; +#include "opentrack/timer.hpp" struct settings { pbundle b; - value<double> rotation_alpha, - translation_alpha, - second_order_alpha, - third_order_alpha, - rot_deadzone, - trans_deadzone, - expt; + value<int> rot_threshold, trans_threshold, ewma; settings() : b(bundle("Accela")), - rotation_alpha(b, "rotation-alpha", ACCELA_SMOOTHING_ROTATION), - translation_alpha(b, "translation-alpha", ACCELA_SMOOTHING_TRANSLATION), - second_order_alpha(b, "second-order-alpha", ACCELA_SECOND_ORDER_ALPHA), - third_order_alpha(b, "third-order-alpha", ACCELA_THIRD_ORDER_ALPHA), - rot_deadzone(b, "rotation-deadband", 0), - trans_deadzone(b, "translation-deadband", 0), - expt(b, "exponent", 2) + rot_threshold(b, "rotation-threshold", 30), + trans_threshold(b, "translation-threshold", 50), + ewma(b, "ewma", 2) {} }; class FTNoIR_Filter : public IFilter { public: - FTNoIR_Filter(); - void filter(const double* target_camera_position, double *new_camera_position); - void reset() { - first_run = true; - } - void receiveSettings() { - s.b->reload(); - } - + FTNoIR_Filter(); + void filter(const double* input, double *output); private: settings s; - bool first_run; - double last_output[3][6]; + bool first_run; + double last_output[6]; + double smoothed_input[6]; + Timer t; + static double f(double vec, double thres); + + static constexpr double high_thres_c = 4; + static constexpr double high_thres_out = 500; + + static constexpr double low_thres_mult = 100; }; class FilterControls: public IFilterDialog @@ -60,17 +49,20 @@ public: private: Ui::AccelaUICFilterControls ui; void discard(); - void save(); + void save(); FTNoIR_Filter* accela_filter; settings s; private slots: - void doOK(); - void doCancel(); + void doOK(); + void doCancel(); + void update_ewma_display(int value); + void update_rot_display(int value); + void update_trans_display(int value); }; class FTNoIR_FilterDll : public Metadata { public: QString name() { return QString("Accela"); } - QIcon icon() { return QIcon(":/images/filter-16.png"); } + QIcon icon() { return QIcon(":/images/filter-16.png"); } }; |