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

sv.Detections has exactly N of each member, except for tracker_id. #1092

Closed
2 tasks done
LinasKo opened this issue Apr 4, 2024 · 4 comments · Fixed by #1214
Closed
2 tasks done

sv.Detections has exactly N of each member, except for tracker_id. #1092

LinasKo opened this issue Apr 4, 2024 · 4 comments · Fixed by #1214
Assignees
Labels
bug Something isn't working

Comments

@LinasKo
Copy link
Collaborator

LinasKo commented Apr 4, 2024

Search before asking

  • I have searched the Supervision issues and found no similar bug report.

Bug

Found in: #1044, #1076.

This is a sub-issue of #943 and should be solved before starting that one.

sv.Detections has a list of numpy arrays as its members: xyxy, mask, confidence, class_id, trackier_id When N detections are made, all of these except tracker_id will have a shape (N, ...).

For example: When there are no tracks, update_with_detections will return detections, with detections.tracker_id set to [].

BUT, a few lines above, it only returns those detections where tracker_id was not -1. Many places in the codebase, e.g. the TraceAnnotator expect len(tracker_id) to match len(detections). There's many zips in examples, zipping with tracker_id.

So there's 2 paradigms:

  1. Make the tracker ID length always match the length of other members by having a special value such as -1, already used in some places.
  2. Make tracker_id different than other members of sv.Detections, keep the current implementation, but root out incorrect usage.

Are you willing to submit a PR?

  • Yes I'd like to help by submitting a PR!
@LinasKo LinasKo added the bug Something isn't working label Apr 4, 2024
@LinasKo
Copy link
Collaborator Author

LinasKo commented Apr 4, 2024

I'm heavily in favour of 1. The steps for this would be:

  • Find, learn of all places where tracker_id is used.
  • Modify the core of ByteTrack - if there is a detection but there's no tracker - instead of returning nothing, return -1. Make sure the length of tracker_id matches the length of detections being returned.
  • Think a bit how this affects case where we deliberately hide uncertain trackers - this would be introduced as part of add minimum_consecutive_frames to bytetrack #1076.
  • Propagate the changes in the core of ByteTrack, to the uses by various components - annotators, examples
  • Some tests would be good to have.

This would be a draft PR until #1076 is merged. This PR new should remove the Detections.empty call from it.

@LinasKo
Copy link
Collaborator Author

LinasKo commented May 17, 2024

Example: line_zone.py:trigger() checks if iterating over tracker_id array produces None

Related: Test case in #1206 checks it too.

@LinasKo
Copy link
Collaborator Author

LinasKo commented May 17, 2024

Example: smoother.py:update_with_detections() checks if iterating over tracker_id array produces None

@LinasKo LinasKo self-assigned this May 20, 2024
@LinasKo LinasKo linked a pull request May 21, 2024 that will close this issue
4 tasks
@LinasKo
Copy link
Collaborator Author

LinasKo commented May 21, 2024

I was wrong about the -1 case - the only issues that exist are unnecessary None checks.

When the related PR is merged, this can be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant