Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify frame skipping logic #304

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Simplify frame skipping logic #304

wants to merge 3 commits into from

Conversation

aguscas
Copy link
Collaborator

@aguscas aguscas commented Feb 23, 2024

In norfair, whenever you skip frames, the hit_counter of each TrackedObjects gets decreased by one. Therefore, when you skip more frames than the value of the hit_counter, then the object gets destroyed, even though you didn’t even use the detector! That is undesirable. Also, the period variable doesn't seem intuitive on what is doing.

The way it works in this PR is:

  • The Tracker.update method doesn't have the period argument, but instead it has a hit_counter_jump variable (which defaults to None) telling you by how much will the hit_counter get increased or decreased if the frame is not skipped.
  • When you call the Tracker.update method, if you pass the argument detections=None, then norfair assumes you skipped that frame, and sets hit_counter_jump=0. If detections is a list, then Norfair assumes you didn’t skip that frame, and (by default, if hit_counter_jump is None) sets hit_counter_jump to one plus the amount of frames that were previously skipped (so if no frames were skipped, then hit_counter_jump=1)
  • Doing this, whenever you skip a frame, the hit_counters are not touched. Objects that were alive will still be alive at least until the next time you use the detector.
  • Whenever you don’t skip a frame, then hit_counters get increased or decreased by hit_counter_jump (depending if they matched or not with a detection).
  • When a TrackedObject instance is created, it's initial hit_counter is set to 1.

@aguscas aguscas marked this pull request as draft February 23, 2024 14:27
@aguscas aguscas marked this pull request as ready for review March 1, 2024 16:58
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.

None yet

1 participant