RPi 5 GStreamer - How can I get tracker ids using python?

Hi, all!
I’m working in a project with RPi 5 with H8L for object tracking using Python. I successfully integrated the tracker on the pipeline, but I don’t know how to get the tracker data (objects ids) on the app callback.
There is any documentation about that?

Thank you!

1 Like

Hey @diulhio,

Great work! I’m happy to hear that.

Can you please provide more context or some of your code so I can better assist you?

In the meantime, I can suggest you take a look at our detection with tracker example: Hailo-Application-Code-Examples/runtime/python/detection_with_tracker at main · hailo-ai/Hailo-Application-Code-Examples · GitHub

Let me know if you have any other questions!
Best Regards

Hi @omria ,
Thank you for the fast reply!

I used the RPi 5 detection example as development basis.
The GStreamer pipeline definition:

pipeline_string = (
            source_element            
            + QUEUE("queue_hailonet")
            + "videoconvert n-threads=3 ! "
            f"hailonet hef-path={self.hef_path} batch-size={self.batch_size} {self.thresholds_str} force-writable=true ! "
            + QUEUE("queue_hailofilter")
            + f"hailofilter so-path={self.default_postprocess_so} {self.labels_config} qos=false ! "
            + "queue leaky=no max-size-buffers=30 max-size-bytes=0 max-size-time=0 ! "
            + "hailotracker name=hailo_tracker keep-past-metadata=true kalman-dist-thr=.5 iou-thr=.6 keep-tracked-frames=2 keep-lost-frames=2 ! "
            + QUEUE("queue_hailo_python")
            + QUEUE("queue_user_callback")
            + "identity name=identity_callback ! "
            + QUEUE("queue_hailooverlay")
            + "hailooverlay ! "
            + QUEUE("queue_videoconvert")
            + "videoconvert n-threads=3 qos=false ! "
            + QUEUE("queue_hailo_display")
            + f"fpsdisplaysink video-sink={self.video_sink} name=hailo_display sync={self.sync} text-overlay={self.options_menu.show_fps} signal-fps-measurements=true "
        )

And on the identity callback, I’m getting the detections using:

detections = roi.get_objects_typed(hailo.HAILO_DETECTION)

I tried to change the parameter to hailo.HAILO_UNIQUE_ID, but it didn’t work.

I saw that you recommended me a HailoRT example. Should I move my efforts to HailoRT usage?
To be honest I take a look on your documentation and I’m confused if I should use HailoRT or GStreamer on the development. What is your recommendation?

Best regards.

@omria any update about this issue?

@omria even I am developing a very similar project. I used the pose estimation example from rpi-example-codes as a basis. Even i would like some suggestions or help on this. Thank you

Hi! Maybe I can help with your choice.

I studied the Hailo documentation and conducted some experiments, leading to a few conclusions. pyHailoRT is very good, fast, and easy to implement, but in my experiments, it was slower than GStreamer. Especially if you are performing inference on camera streaming, this makes a difference. In my case, I need to use just one Hailo8L to process streaming from 8 cameras with YOLOv8, so I need the fastest option possible. For my case, GStreamer is the answer. :blush:

About the problem with tracker ids, I was using this on the wrong way, the GStreamer pipeline was correct, but the callback was wrong!
On this example, the show how use the tracker: Car Detection and Tracking System for Toll Plazas - Raspberry Pi AI Kit | Expert Projects

1 Like

Thanks @diulhio for the help! I will try out this

In the link you provided, it asks us to download dataflow compiler(dfc) but in rpi5, which is aarchx64, dfc is not available right? So is there a workaround for this??

Hey @prajwalshenoy

The DFC is for creating the models and should be run on the pc or virtual machine , For more info please check the docs at : https://hailo.ai/developer-zone/