From e7f09e2ecefe8c38ec2fffdba6743a5a2638b747 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Thu, 16 Oct 2025 20:51:39 -0400 Subject: [PATCH] Fix first reading. --- Outputs/CRT/Internals/RectAccumulator.hpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Outputs/CRT/Internals/RectAccumulator.hpp b/Outputs/CRT/Internals/RectAccumulator.hpp index 83465a00c..e4c738516 100644 --- a/Outputs/CRT/Internals/RectAccumulator.hpp +++ b/Outputs/CRT/Internals/RectAccumulator.hpp @@ -22,7 +22,8 @@ struct RectAccumulator { stable_filter_.push_back(rect); if(stable_filter_.full() && stable_filter_.stable(stability_threshold_)) { - candidates_.push_back(stable_filter_.join()); + first_reading_ = stable_filter_.join(); + candidates_.push_back(*first_reading_); stable_filter_.reset(); if(candidates_.full()) { @@ -33,15 +34,12 @@ struct RectAccumulator { } std::optional first_reading() { - if( - did_first_read_ || - !stable_filter_.full() || - !stable_filter_.stable(stability_threshold_) - ) { + if(did_first_read_) { return std::nullopt; } - did_first_read_ = true; - return stable_filter_.join(); + + did_first_read_ = first_reading_.has_value(); + return first_reading_; } void set_stability_threshold(const float stability_threshold) { @@ -111,6 +109,8 @@ private: // At startup, look for a small number of sequential but consistent frames. static constexpr int StableFilterSize = 4; RectHistory stable_filter_; + + std::optional first_reading_; bool did_first_read_ = false; float stability_threshold_ = 0.0f;