move_detect/tests/test_smoothing.py

22 lines
688 B
Python

from edge.models import Keypoint
from edge.smoothing import OneEuroFilter, KeypointSmoother
def test_one_euro_first_sample_returns_input():
f = OneEuroFilter(min_cutoff=1.0, beta=0.0)
assert f.filter(5.0, t=0.0) == 5.0
def test_one_euro_attenuates_jitter():
f = OneEuroFilter(min_cutoff=0.5, beta=0.0)
f.filter(0.0, t=0.0)
out = f.filter(10.0, t=0.1) # big jump at low cutoff -> damped below input
assert 0.0 < out < 10.0
def test_keypoint_smoother_preserves_conf_and_length():
s = KeypointSmoother()
kps = [Keypoint(float(i), float(i), 0.8) for i in range(17)]
out = s.smooth(kps, t=0.0)
assert len(out) == 17
assert out[3].conf == 0.8