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

which detection is assigned to a given track_id and which one are not #1809

Open
1 task done
fenaux opened this issue Feb 6, 2025 · 2 comments
Open
1 task done
Labels
question Further information is requested

Comments

@fenaux
Copy link

fenaux commented Feb 6, 2025

Search before asking

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

Question

Thanks for this repo

In one frame I have 10 boxes for persons lets say they have corresponding indexes 0 for first box, 1 for second ....9 for the 10th.
I only have 7 tracks

Is there a way to know directly
the index of the box that is assigned to a given track_id
the indexes of the boxes that are not assigned to any track (could be track "-1" like values not in a cluster for sckilt learn dbscan)

Thanks for your help

@fenaux fenaux added the question Further information is requested label Feb 6, 2025
@mikel-brostrom
Copy link
Owner

mikel-brostrom commented Feb 7, 2025

The index given to each bbox depends on the association rounds of each tracking algorithm. The assigned IDs are generated in ascending order. When a track ID is lost it can be recovered for a limited period of time, in order not to flood the memory with lost tracks, otherwise it is lost forever.

@fenaux
Copy link
Author

fenaux commented Feb 9, 2025

Thanks for answering me.
But I must admit I could not figure how to find which box is assigned to which track from it

So here is the way I do it now

while True:
    ret, im = vid.read()
    if not ret: break

    # substitute by your object detector, output has to be N X (x, y, x, y, conf, cls)
    in_this_frame = np.where(in_frame == i_frame)[0]
    dets = boxes[in_this_frame]

    tracker.update(dets, im) # --> M X (x, y, x, y, id, conf, cls, ind)
    tracker.plot_results(im, show_trajectories=True)

    new_boxes = []
    new_ids = []
    for a in tracker.active_tracks:
                if a.history_observations:
                    if len(a.history_observations) > 2:
                        box = a.history_observations[-1]
                        new_boxes.append(box)
                        new_ids.append(a.id)
                        new_obs = np.hstack((i_frame,box, a.id))
                        if len(all_tracks) == 0: all_tracks = new_obs.copy()
                        else: all_tracks = np.row_stack((all_tracks, new_obs))

    video_writer.write(im)

    pairdist = distance.cdist(dets, new_boxes, 'euclidean')
    pairs = np.where(pairdist == 0)  # this line give the assignment  between dets and new_ids
 
    i_frame += 1

With DeepOcSort
And other thing surprised me, quiet often, they are more boxes in new_boxes (i.e. boxes corresponding to active tracks) than boxes in dets in my case on average 10% more.
And is clear in the tracker video that some boxes are false positive (aka ids 29 and 76 in image). https://drive.google.com/file/d/1hBBVOYyZkLEaNC348jbI-NDNi6QCCul7/view?usp=sharing
An option to plot boxes only corresponding to "dets" would make sense. May be det_id is what I am looking for ?

With BotSort
Behavior is different in my case I always got len(new_boxes) < len(dets)
and all new_boxes are close to on det

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

No branches or pull requests

2 participants