Tracker_id mixedover similar objects

Hi! first time working with Supervision.
I have the following problem: I am tracking cans over a conveyor. Cans are exactly the same, one behind the other. When i perform tracking, i get printed the id’s and i get:

[1,2] in one frame
[2,1] in the next one
[1,2] in the following one.

This leads to identifying later wrongly.

Has anyone happened this or got any clues how to solve this ? (i am thinking in the usual way, re-match the array when same values come in different order frame by frame).

Thank you!

Hi @Martin_Riveros :wave:

Great to have you here!

Generally tracking for similar objects can be tricky. However, if they’re moving at a constant speed, in the same direction and the frame rate is good enough, the tracker should work. Are you able to share a few pictures of correct and incorrect cases?

Alternatively, a quick video that’s either annotated or together with the code you’re running would be even better.

Hello Linas! i will try to state my problem (i just show relevant sentences):

TRACK_ACTIVATION_TRESHOLD = 0.4
slected_classes = [‘41’]
tracker = ByteTrack(track_activation_threshold=TRACK_ACTIVATION_TRESHOLD,
minimum_matching_threshold=0.6,
lost_track_buffer = 20
)
results = model(frame, agnostic_nms = True, verbose=False)[0]
detections = Detections.from_ultralytics(results)

if any(class_id in selected_classes for class_id in detections.class_id):

 detections = detections[np.isin(detections.class_id, selected_classes)]
 
 if all(conf>TRACK_ACTIVATION_TRESHOLD for conf in detections.confidence):
                
                detections = tracker.update_with_detections(detections)
            
                print('DETECTIONS', detections)
                print("DETECTIONS.CLASS_ID ", detections.class_id)
                print("DETECTIONS.TRACKER_ID", detections.tracker_id)

-------------Here is the output-----------------

DETECTIONS Detections(xyxy=array([[ 0, 4.9233, 154.46, 678.54]], dtype=float32), mask=None, confidence=array([ 0.4089], dtype=float32), class_id=array([41]), tracker_id=array(, dtype=int32), data={‘class_name’: array([‘cup’], dtype=‘<U12’)})
DETECTIONS.CLASS_ID [41]
DETECTIONS.TRACKER_ID

Problem: tracker does not assign a track_id

Hope this helps…

Hi @Martin_Riveros

There are a few issues with ByteTrack in supervision release 0.20.0 If you switch to using the pre-released version supervision=0.21.0rc3, it should solve the issue.

Hope this helps!

1 Like