Skip to content

Detection age not always set #317

@nmichlo

Description

@nmichlo

Describe the bug

Age is not set on all newly added detections.

To Reproduce

Set past_detections_length to some low number, and add more detections than this. The detection age will not be set after being "added" when discarded.

Expected behavior

Even when discarded, the detection age should still be set after being added, because this affects the last_detection.

norfair/norfair/tracker.py

Lines 700 to 715 in 009a1b1

def _conditionally_add_to_past_detections(self, detection):
"""Adds detections into (and pops detections away) from `past_detections`
It does so by keeping a fixed amount of past detections saved into each
TrackedObject, while maintaining them distributed uniformly through the object's
lifetime.
"""
if self.past_detections_length == 0:
return
if len(self.past_detections) < self.past_detections_length:
detection.age = self.age
self.past_detections.append(detection)
elif self.age >= self.past_detections[0].age * self.past_detections_length:
self.past_detections.pop(0)
detection.age = self.age
self.past_detections.append(detection)

Seems like the above lines should always set the detection age. It should also probably assert that the age has not already been set / added to a tracker.

Screenshots or videos
N/A

Environment (please complete the following information):

  • OS: [e.g. Ubuntu 20.04]
  • Python version: [e.g. 3.9.10]
  • Norfair version: [e.g. 1.0.0]

Additional context
N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions