feat: pass fps dynamically

This commit is contained in:
2026-05-19 22:36:24 +02:00
parent d4e0241590
commit 58ed5df87c
10 changed files with 71 additions and 50 deletions

View File

@@ -79,7 +79,7 @@ TEST(HelloTest, Filter_Delta_U) {
// NOTE: later SSF must be fed -u, not u
TEST(HelloTest, Filter_SSF) {
SsfFilter f_ssf(3);
SsfFilter f_ssf(FPS * 3/4); // target upslope_width = 3
std::vector x { 1.0, 3.0, 2.0, 5.0, 1.0, 1.5 };
// du { 1.0, 2.0, -1.0, 3.0, -4.0, 0.5 }
// duc { 1.0, 2.0, 0.0, 3.0, 0.0, 0.5 }
@@ -116,8 +116,7 @@ TEST(HelloTest, Zong_SSF_Stage2) {
auto y_neg = apply_filter(f_neg, y);
// Stage 2: sum slope function
const size_t upslope_width = 4;
SsfFilter f_ssf(upslope_width);
SsfFilter f_ssf(FPS);
auto ssf = apply_filter(f_ssf, y_neg);
npy_save("test2/ssf_t2_ssf.npy", ssf);
@@ -148,22 +147,20 @@ TEST(HelloTest, Zong_SSF_Stage3) {
//std::cerr << "before stage 2" << std::endl;
// Stage 2: sum slope function
const size_t upslope_width = 4;
SsfFilter f_ssf(upslope_width);
SsfFilter f_ssf(FPS);
auto ssf = apply_filter(f_ssf, y_neg);
//std::cerr << "before stage 3" << std::endl;
// Stage 3: threshold detection
const size_t len_refr = (size_t) (FPS / (MAX_BPM / 60));
DebugSsfStepDetectorThreshold f_ssd_thr(len_refr);
DebugSsfStepDetectorThreshold f_ssd_thr(FPS);
auto ssf_threshold = apply_filter(f_ssd_thr, ssf);
//std::cerr << "before writing results 1 and doing step detection" << std::endl;
npy_save("test2/ssf_t2_ssf_threshold.npy", ssf_threshold);
SsfStepDetector f_ssd(len_refr);
SsfStepDetector f_ssd(FPS);
auto steps = apply_filter(f_ssd, ssf);
//std::cerr << "before writing results 2" << std::endl;

View File

@@ -174,22 +174,20 @@ TEST(SignalTest, RunningQuality_t2) {
//std::cerr << "before stage 2" << std::endl;
// Stage 2: sum slope function
const size_t upslope_width = 4;
SsfFilter f_ssf(upslope_width);
SsfFilter f_ssf(FPS);
auto ssf = apply_filter(f_ssf, y_neg);
//std::cerr << "before stage 3" << std::endl;
// Stage 3: threshold detection
const size_t len_refr = (size_t) (FPS / (MAX_BPM / 60));
DebugSsfStepDetectorThreshold f_ssd_thr(len_refr);
DebugSsfStepDetectorThreshold f_ssd_thr(FPS);
auto ssf_threshold = apply_filter(f_ssd_thr, ssf);
//std::cerr << "before writing results 1 and doing step detection" << std::endl;
npy_save("test2/ssf_t3_ssf_threshold.npy", ssf_threshold);
SsfStepDetector f_ssd(len_refr);
SsfStepDetector f_ssd(FPS);
auto steps = apply_filter(f_ssd, ssf);
//std::cerr << "before writing results 2" << std::endl;

View File

@@ -13,12 +13,12 @@ TEST(StepDetector, t1_sub_sample_resolution) {
std::vector<double> signal = fetch_y_axis(s);
const size_t N = signal.size();
const size_t N_INIT = SsfStepDetector::initial_samples();
const size_t N_INIT = SsfStepDetector::initial_samples(FPS);
StepDetector det(nullptr, true);
StepDetector det(FPS, nullptr, true);
// initialize: feed for priming the filters
det.primeFilters(signal);
det.primeFilters(FPS, signal);
// feed for actual test
for (size_t i = 0; i < N; i++) {

View File

@@ -40,15 +40,13 @@ TEST(HelloTest, Zong_SSF_Test5_a1) {
//std::cerr << "before stage 2" << std::endl;
// Stage 2: sum slope function
const size_t upslope_width = 4;
SsfFilter f_ssf(upslope_width);
SsfFilter f_ssf(FPS);
auto ssf = apply_filter(f_ssf, y_neg);
//std::cerr << "before stage 3" << std::endl;
// Stage 3: threshold detection
const size_t len_refr = (size_t) (FPS / (MAX_BPM / 60));
DebugSsfStepDetectorThreshold f_ssd_thr(len_refr);
DebugSsfStepDetectorThreshold f_ssd_thr(FPS);
auto ssf_threshold = apply_filter(f_ssd_thr, ssf);
//std::cerr << "before writing results 1 and doing step detection" << std::endl;
@@ -57,7 +55,7 @@ TEST(HelloTest, Zong_SSF_Test5_a1) {
npy_save("test5/ssf_a1_ssf.npy", ssf);
npy_save("test5/ssf_a1_ssf_threshold.npy", ssf_threshold);
SsfStepDetector f_ssd(len_refr);
SsfStepDetector f_ssd(FPS);
auto steps = apply_filter(f_ssd, ssf);
//std::cerr << "before writing results 2" << std::endl;

View File

@@ -46,7 +46,7 @@ std::vector<double> fetch_y_axis(npy::npy_data<double>& acc, int dim) {
return signal;
}
DebugSsfStepDetectorThreshold::DebugSsfStepDetectorThreshold(size_t len_refr) : SsfStepDetector(len_refr) {}
DebugSsfStepDetectorThreshold::DebugSsfStepDetectorThreshold(double fps) : SsfStepDetector(fps) {}
double DebugSsfStepDetectorThreshold::filter(double val) {
this->SsfStepDetector::filter(val);
return peek_threshold();

View File

@@ -27,7 +27,7 @@ std::vector<double> fetch_y_axis(npy::npy_data<double>& acc, int dim = 1);
/** Returns the ssf_threshold as the filter output for debugging. */
class DebugSsfStepDetectorThreshold : public SsfStepDetector {
public:
DebugSsfStepDetectorThreshold(size_t len_refr);
DebugSsfStepDetectorThreshold(double fps);
double filter(double val);
};