supervision icon indicating copy to clipboard operation
supervision copied to clipboard

Fix external track ids

Open rolson24 opened this issue 1 year ago • 2 comments

Description

This fix is for issue #1355. The tracker is skipping ID's for a few reasons. First off when the minimum_consecutive_frames is set to 1, each track gets assigned a new external id when it is created in activate() is called. This is an issue because not all of these tracks make it through the next frame where they get matched with a new detection and update() gets called. That means we are assigning an external track id to tracks that never are real tracks. I fixed this by getting rid of the external track id assignment in activate() (except for the first frame of the video) and instead just using the external id assignment in the update() function, which is how we do the assignment when minimum_consecutive_frames > 1.

The second reason the tracker is skipping ID's is because in the removed_duplicate_tracks() function, there is an overlap threshold to determine if two tracks are the same. In the current release this threshold is set at 0.15 which is relatively high because two tracks could be passing by each other and if they overlap more than 85% one would get removed. I lowered the threshold to 0.05 to reduce this.

Type of change

Please delete options that are not relevant.

  • [x] Bug fix (non-breaking change which fixes an issue)

How has this change been tested, please provide a testcase or example of how you tested the change?

This fix was tested with this notebook

Here you can see that in the old version external id 4 was skipped, but in the new version its not

Output from old version:

Current Frame: 38
New Track ids: set()
Track ids are consecutive: True
Current Frame: 39
New Track ids: set()
Track ids are consecutive: True
Current Frame: 40
New Track ids: set()
Track ids are consecutive: True
Current Frame: 41
New Track ids: {3, 5}
Track ids are consecutive: False
Current Frame: 42
New Track ids: set()
Track ids are consecutive: False
Current Frame: 43
New Track ids: set()
Track ids are consecutive: False
Current Frame: 44
New Track ids: set()

Image

Output from fixed version:

Current Frame: 38
New Track ids: set()
Track ids are consecutive: True
Current Frame: 39
New Track ids: set()
Track ids are consecutive: True
Current Frame: 40
New Track ids: set()
Track ids are consecutive: True
Current Frame: 41
New Track ids: {3, 4}
Track ids are consecutive: True
Current Frame: 42
New Track ids: set()
Track ids are consecutive: True
Current Frame: 43
New Track ids: set()
Track ids are consecutive: True
Current Frame: 44
New Track ids: set()
Track ids are consecutive: True

Image

Any specific deployment considerations

For example, documentation changes, usability, usage/costs, secrets, etc.

Docs

  • [ ] Docs updated? What were the changes:

rolson24 avatar Jul 15 '24 19:07 rolson24

Hi @rolson24 👋🏻, we have two issues related to tracking that were submitted recently:

  • https://github.com/roboflow/supervision/issues/1355
  • https://github.com/roboflow/supervision/issues/1320

IS it related to both of them or only https://github.com/roboflow/supervision/issues/1355?

SkalskiP avatar Jul 17 '24 10:07 SkalskiP

Yea it is also related to #1320, sorry about that.

On Wed, Jul 17, 2024 at 6:19 AM Piotr Skalski @.***> wrote:

Hi @rolson24 https://github.com/rolson24 👋🏻, we have two issues related to tracking that were submitted recently:

IS it related to both of them or only #1355 https://github.com/roboflow/supervision/issues/1355?

— Reply to this email directly, view it on GitHub https://github.com/roboflow/supervision/pull/1364#issuecomment-2232955855, or unsubscribe https://github.com/notifications/unsubscribe-auth/AX2EJPCWDV7PAKR24CQNY2LZMZAKDAVCNFSM6AAAAABK5FT73OVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMZSHE2TKOBVGU . You are receiving this because you were mentioned.Message ID: @.***>

rolson24 avatar Jul 17 '24 11:07 rolson24