Skip to content

Always set detection age even when not kept in past_detections. - #338

Closed
cpruijsen wants to merge 1 commit into
tryolabs:masterfrom
cpruijsen:fix/issue-317
Closed

cpruijsen wants to merge 1 commit into
tryolabs:masterfrom
cpruijsen:fix/issue-317

Conversation

@cpruijsen

Copy link
Copy Markdown

Always set detection.age in _conditionally_add_to_past_detections, including when the sample is skipped and when past_detections_length is 0.

Fixes #317.

Detection.age was only written when a match was stored in
TrackedObject.past_detections. hit() still assigns that same detection to
last_detection, so once the buffer was full (or past_detections_length
was 0) last_detection.age stayed None.

The reporter (nmichlo) asked that age be set even when the detection is
discarded, "because this affects the last_detection."

What I chose and the alternative

The keep path already overwrote age in _conditionally_add_to_past_detections,
which is the site the reporter pointed at.

Alternative: set age in hit() only, so ReID merge() would not rewrite ages
of detections it does not keep. Also considered asserting age is unset.
Did not add that assert: merge() re-adds detections that already have age.

Can move the stamp to hit() instead.

Test plan

  • tests/test_tracker.py::test_detection_age_always_set fails without
    the fix and passes with it (past_detections_length 0, 2, and 4)
  • tests/ (unit tests) pass

last_detection is the same object as a discarded detection, so skipping
the age stamp left last_detection.age as None.
@cpruijsen

Copy link
Copy Markdown
Author

Going to close this. Not planning to keep it rebased.

@cpruijsen cpruijsen closed this Oct 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Detection age not always set

1 participant