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.
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 thehit_counter
, then the object gets destroyed, even though you didn’t even use the detector! That is undesirable. Also, theperiod
variable doesn't seem intuitive on what is doing.The way it works in this PR is:
period
argument, but instead it has ahit_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.hit_counter_jump=0
. If detections is a list, then Norfair assumes you didn’t skip that frame, and (by default, ifhit_counter_jump is None
) setshit_counter_jump
to one plus the amount of frames that were previously skipped (so if no frames were skipped, thenhit_counter_jump=1
)TrackedObject
instance is created, it's initialhit_counter
is set to 1.