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

Keep track of detection index #299

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

abaybektursun
Copy link

@abaybektursun abaybektursun commented Dec 24, 2022

Addresses #195 and unanswered question in #5:
Currently, after updating ByteTrack object, some of the bounding boxes will be dropped, and it's not possible to figure out the original bounding box index form the tracker. For example

boxes, scores, classes, .... = some_detection_model.inference(frame)
boxes_scores = np.concatenate([boxes, scores.reshape(-1,1), ], axis=1)
# In this step len(online_targets) <= len(boxes)
online_targets = tracker.update(boxes_scores, [frame.shape[0], frame.shape[1]], [frame.shape[0], frame.shape[1]])
# Since we are missing some of the boxes, there is no way figuring out relevant information of the boxes like class.
# I did bbox matching method to figure out the original index, but that's inefficient (N^2) 

With the solution in this PR you can track index directly using tracker.update(..., track_det_idx=True):

boxes, scores, classes, .... = some_detection_model.inference(image)
det_idxs_orig = np.array(list(range(post_boxes.shape[0]))).reshape(-1,1)
boxes_scores = np.concatenate([boxes, scores.reshape(-1,1), det_idxs_orig], axis=1)
online_targets = tracker.update(boxes_scores, [frame.shape[0], frame.shape[1]], [frame.shape[0], frame.shape[1]], track_det_idx=True)

for track_i, an_online_target in enumerate(online_targets):
            track_xyxy = utils.tlwh_to_xyxy(an_online_target.tlwh)
            det_i = an_online_target.det_idx
            tracked_obj_class = classes[int(det_i)]

@abaybektursun
Copy link
Author

@ifzhang?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant