Getting TRAILS from ObjectTracker - need help!

Hello!

And one more question…

In general my task is to count passangeers in city bus.

So I use Object Tracker for this purpose.

As shown in DOC -

  • Unique ID assignment: Provides a unique ID for each object and maintains that ID across frames.

  • Class filtering: Ignores detections whose class is not in the specified class_list.

  • Track retention buffer: Continues to track objects for track_buffer frames after they disappear.

  • Trajectory history: Keeps a history of each object’s movement up to trail_depth frames long.

  • Overlay support: Can overlay track IDs and trails on frames for visualization.

As I can see I can take the trails from this tracker.

But I cannot fint any method to achive this.

My code is:

model_spec = ModelSpec(
        model_name=model, 
        #zoo_url="sergio_suslov/models",
        #inference_host_address="@cloud",
        zoo_url = zooUrl ,
        inference_host_address = infHost,  
        model_properties={
            "device_type": ["HAILORT/HAILO8L"],
            "overlay_show_labels": True,
            "overlay_show_probabilities": True,
            "overlay_line_width": 2,
            "overlay_color": [(0, 255, 0)],
        },
    )
  tracker = ObjectTracker(
        class_list=class_list,
        track_thresh=0.35,
        track_buffer=100,
        match_thresh=0.9999,
        trail_depth=200,
        anchor_point=AnchorPoint.CENTER,
    )
model = model_spec.load_model()
attach_analyzers(model, [tracker])
 with Display("AI Camera") as output_display:
        for inference_result in predict_stream(model, video_source):
            #output_display.show(inference_result.image_overlay)
            wr.write(inference_result.image_overlay)
            
            for item in  inference_result.results:
                if 'bbox' and 'track_id' in item:
                    pprint(inference_result.results)


And a result in terminal is

{'bbox': [506.2614820816784,
           76.20756754344882,
           639.3501858334043,
           222.4267020968905],
  'category_id': 0,
  'label': 'Persone',
  'score': 0.8943927884101868,
  'track_id': 4}]

As I understand from DOCs - Analyser attached to model runs after each frame automatically and augments detections results. So, I can see track_id attachet to standard results, but NO trails

Please help - haow can I get this trails…

You will find two dictionaries in inference_result.trails and inference_result.trail_classes. They are not in inference_result.results. Each dictionary uses the track id as the key and will return a list of bboxes or the class respectively.

For example, to get the bounding boxes of the trails for track id 1, you would do

trackid_1_history = inference_results.trails[1]

Thank you so much.

It works!

I think you had no doubts…

1 Like

@zoomrenew we’re so glad this works! Would you mind marking the response with the solution (checkbox icon) so others can easily find the answer?