Repository navigation
[scanner] Extract motion event state machine from MotionScanner.scan() - #292
Draft
Breakthrough wants to merge 1 commit into
Draft
Breakthrough wants to merge 1 commit into
Breakthrough wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Followup refactor stacked on #287 (retarget to
mainonce #287 merges).Extract the motion event detection state machine out of
MotionScanner.scan()into a pure-PythonMotionEventTrackerclass (plusCompletedEventandEventStep) insidedvr_scan/scanner.py— strictly behavior-preserving, with no new submodules and no changes tovideo_input.py,wallclock.py, or_offset_lock(lock cleanup deferred to a separate followup PR).Summary of Changes
dvr_scan/scanner.py:MotionEventTracker,CompletedEvent, andEventStepwith zero threading, OpenCV, or video I/O dependencies so event-detection logic can be unit-tested directly with synthetic(timecode, score, frame)sequences.min_event_len, pre/post/merge-tail frame buffering, single_padded_end()calculation (replacing all 3 duplicated formulas), decoupledmerge_window/time_post_eventhandling,max_event_lensplitting (_split_event_if_needed),max_eventsearly stop, per-eventhigh_score/high_frametracking & reset, explicit buffer release (clear_buffers()infinish(), onmax_events, and inscan()'sfinally:), andfinish()EOF flush.MotionScanner.scan()to focus on thread lifecycle, detector/filter/overlay execution, progress bar updates, and queue I/O, using a shared_enqueue_frames()helper and guardinghandle_completed_event()against asynchronous cancellation.tests/test_event_tracker.py:min_event_len, exact threshold boundaries, pre/post padding & clamping, decoupledmerge_window,max_event_lensplitting,max_eventsearly stop, VFR non-uniform timestamps,frame_skip, highscore tracking/reset, EOF flushing, and buffer release.Verification
ruff format dvr_scan/ tests/andruff check dvr_scan/ tests/pass.python scripts/check_ascii.pypasses.python -m pytest -x -vv: 458 passed, 4 skipped.issue-285/8d490b9) confirmed zero event-span/ordering regressions; all flagged issues (post-scan frame buffer retention, mid-frame cancellation guard, copy-on-readevents, docstring/helper/test polish) were fixed before pushing.