summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2014-06-13 07:29:39 +0200
committerStanislaw Halik <sthalik@misaki.pl>2014-06-13 07:36:06 +0200
commit794f4619f707240e90ccb0c3f861d2d0aa4c3307 (patch)
treeb2c118a81e1bff8a58b4cd4dd010e80f4d92b154
parent5a5c6c3b539371d46ba3e492ca1bd61617cf0084 (diff)
ewma: don't filter twice with same input value
-rw-r--r--ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp b/ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp
index 8f20da13..1a09cee3 100644
--- a/ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp
+++ b/ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp
@@ -77,6 +77,24 @@ void FTNoIR_Filter::FilterHeadPoseData(const double *target_camera_position,
return;
}
+ bool new_frame = false;
+
+ for (int i = 0; i < 6; i++)
+ {
+ if (target_camera_position[i] != current_camera_position[i])
+ {
+ new_frame = true;
+ break;
+ }
+ }
+
+ if (!new_frame)
+ {
+ for (int i = 0; i < 6; i++)
+ new_camera_position[i] = current_camera_position[i];
+ return;
+ }
+
// Calculate the new camera position.
for (int i=0;i<6;i++) {
// Calculate the current and smoothed delta.