Fix reindex shifting ottrk frame numbers to the first detection#529
Open
Sebastian-Gerken wants to merge 2 commits into
Open
Fix reindex shifting ottrk frame numbers to the first detection#529Sebastian-Gerken wants to merge 2 commits into
Sebastian-Gerken wants to merge 2 commits into
Conversation
FinishedTracksExporter.reindex() rebased detection frame numbers by the minimum frame number that has a detection. If the first detection of a file occurs after frame 1, all frame numbers in the written .ottrk are shifted towards 1 while occurrence timestamps keep wall clock time, so frame and occurrence disagree by the time of the file's first detection. In OTAnalytics the track overlay then renders too early in the video (observed shifts of up to several minutes on low-traffic recordings). Rebase by the chunk's first frame number instead (chunk frames include frames without detections), so written frame numbers always match the source video's frame numbering. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Bug
FinishedTracksExporter.reindex()rebases detection frame numbers using the minimum frame number that has a detection:If the first detection of a video occurs after frame 1, every frame number in the written
.ottrkis shifted towards 1, whileoccurrencekeeps correct wall clock time —frameandoccurrencethen disagree by exactly the time of the file's first detection.Impact
number_of_framesmetadata no longer matches the maximum written frame number.Fix
Rebase by the chunk's first frame number (chunk frames include frames without detections), so written frame numbers always match the source video's frame numbering:
get_first_frame_no(container)onFinishedTracksExporterFinishedChunkTrackExporterimplements it asmin(frame.no for frame in container.frames)reindex(det_dicts, first_frame_no)uses it instead of the per-detection minimumTests
tests/track/test_track_exporter.py:mainwith[1, 2] != [2, 3], passes with the fix)tests/tracksuite green;mypy,black,isort,flake8clean.🤖 Generated with Claude Code