supervision icon indicating copy to clipboard operation
supervision copied to clipboard

Meaning of `lost_track_buffer` in `ByteTrack`

Open amaletzk opened this issue 1 year ago β€’ 2 comments

Search before asking

  • [x] I have searched the Supervision issues and found no similar feature requests.

Question

Hi,

I do not understand the precise meaning of lost_track_buffer in the ByteTrack class. It is only used to initialize max_time_lost, which, however, seems to refer to a number of frames rather than a time (and so is a misnomer, IMHO). Furthermore, that variable is initialized as

self.max_time_lost = int(frame_rate / 30.0 * lost_track_buffer)

which does not make sense to me: why is there a division by 30?

Instead, I would understand either of the following possibilities:

  • Remove the division by 30. In that case, lost_frame_buffer refers to the time (in seconds) a track is retained.
  • Initialize max_time_lost with int(lost_track_buffer). In that case, lost_track_buffer refers to the number of frames directly, in agreement with the current docstring.

Thanks for clarifying this, and thanks for your great work!

Additional

No response

amaletzk avatar Mar 21 '25 10:03 amaletzk

🎯 Clarification on max_time_lost and Frame Rate Normalization

Hi, you are correct in your understanding: max_time_lost represents the number of frames a track can be lost before it's removed.


βš™οΈ How Frame Rate Normalization Works

The logic behind:

self.max_time_lost = int(frame_rate / 30.0 * lost_track_buffer)

...is to make the tracker's behavior consistent regardless of the video's frame rate.

  • lost_track_buffer is defined relative to a 30 FPS baseline.
  • You can think of it as β€œthe number of frames to wait in a 30 FPS video.”
  • The frame_rate / 30.0 part creates a scaling factor that adjusts this baseline to your video’s actual frame rate.

βœ… Example in Action

If you set lost_track_buffer = 30 (which corresponds to 1 second at 30 FPS), the formula ensures the time duration remains consistent:

  • For a 60 FPS video:
    max_time_lost = int(60 / 30.0 * 30)  # ➜ 60 frames
    
  • For a 15 FPS video:
    max_time_lost = int(15 / 30.0 * 30)  # ➜ 15 frames
    

πŸ• In both cases, the track is kept for 1 second of real time.
This allows you to use the same lost_track_buffer value and get consistent time-based tracking behavior across different videos.


πŸ’‘ Naming Suggestion

Your observation about the naming is valid. It could certainly be clearer, and perhaps renaming it to something like:

max_frames_lost

...would be a good improvement for clarity in the future.


Hope this helps clarify things!

JESUSROYETH avatar Jul 03 '25 12:07 JESUSROYETH

Hi @amaletzk, closing this PR since https://github.com/roboflow/supervision/issues/1805#issuecomment-3032146107 seems to answer the question; please feel free to reopen the issue if you want to continue the conversation.

soumik12345 avatar Jul 04 '25 10:07 soumik12345