Simplify frame skipping logic #304
Open
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.
In norfair, whenever you skip frames, the
hit_counterof 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, theperiodvariable doesn't seem intuitive on what is doing.The way it works in this PR is:
periodargument, but instead it has ahit_counter_jumpvariable (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_jumpto one plus the amount of frames that were previously skipped (so if no frames were skipped, thenhit_counter_jump=1)TrackedObjectinstance is created, it's initialhit_counteris set to 1.