Tracking Unique Id in Pose Estimation

I’m running this pipeline

gst-launch-1.0 \
    v4l2src name=src_0 ! \
    decodebin ! \
    videoscale ! \
    video/x-raw, pixel-aspect-ratio=1/1 ! \
    videoconvert ! \
    queue leaky=no max-size-buffers=30 max-size-bytes=0 max-size-time=0 ! \
    hailonet hef-path=/home/vk/Downloads/centerpose_regnetx_1.6gf_fpn.hef ! \
    queue leaky=no max-size-buffers=30 max-size-bytes=0 max-size-time=0 ! \
    hailotracker name=hailo_pose_tracker_pre class-id=-1 kalman-dist-thr=0.7 iou-thr=0.8 init-iou-thr=0.9 \
        keep-new-frames=2 keep-tracked-frames=6 keep-lost-frames=8 keep-past-metadata=true qos=false ! \
    queue leaky=no max-size-buffers=30 max-size-bytes=0 max-size-time=0 ! \
    hailofilter so-path=/home/vk/tappas_v3.30.0/apps/h8/gstreamer/libs/post_processes/libcenterpose_post.so ! \
    queue leaky=no max-size-buffers=30 max-size-bytes=0 max-size-time=0 ! \
    hailotracker name=hailo_pose_tracker_post class-id=-1 kalman-dist-thr=0.7 iou-thr=0.8 init-iou-thr=0.9 \
        keep-new-frames=2 keep-tracked-frames=6 keep-lost-frames=8 keep-past-metadata=true qos=false ! \
    hailooverlay qos=false ! \
    videoconvert ! \
    fpsdisplaysink video-sink=xvimagesink name=hailo_display sync=false text-overlay=false


and in this i want to include my custom element that takes input from HailoTracker (Tracking Id )and then i’ll do further processing with it .
or
It would be great if i get that Tracking id in Hailofilter( centrePose)

hey @UHailo ,

You can modify your pipeline to retrieve tracking IDs directly in the HailoFilter element, allowing for further processing without introducing a new custom element. Here’s how this can be achieved:

  1. Modify HailoFilter to Access Metadata from HailoTracker

    • Update the shared library used in the HailoFilter (e.g., libcenterpose_post.so) to retrieve metadata from the buffer passed through the pipeline.

    • Use GStreamer’s GstMeta API to access the HailoTracker metadata:

      GstBuffer *buffer;
      // Access the tracking metadata
      HailoTrackerMeta *meta = gst_buffer_get_hailotracker_meta(buffer);
      if (meta) {
          g_print("Tracking ID: %d\n", meta->tracking_id);
          // Add your custom processing logic here
      }
      
  2. Update Pipeline Configuration
    Modify the pipeline to ensure that metadata is passed along the pipeline without being stripped by intermediate elements:

    gst-launch-1.0 \
        v4l2src name=src_0 ! \
        decodebin ! \
        videoscale ! \
        video/x-raw, pixel-aspect-ratio=1/1 ! \
        videoconvert ! \
        queue leaky=no max-size-buffers=30 max-size-bytes=0 max-size-time=0 ! \
        hailonet hef-path=/path/to/centerpose_regnetx_1.6gf_fpn.hef ! \
        queue leaky=no max-size-buffers=30 max-size-bytes=0 max-size-time=0 ! \
        hailotracker name=hailo_pose_tracker_pre class-id=-1 kalman-dist-thr=0.7 iou-thr=0.8 init-iou-thr=0.9 \
            keep-new-frames=2 keep-tracked-frames=6 keep-lost-frames=8 keep-past-metadata=true qos=false ! \
        queue leaky=no max-size-buffers=30 max-size-bytes=0 max-size-time=0 ! \
        hailofilter so-path=/path/to/libcenterpose_post.so ! \  # Add logic to process metadata
        queue leaky=no max-size-buffers=30 max-size-bytes=0 max-size-time=0 ! \
        hailotracker name=hailo_pose_tracker_post class-id=-1 kalman-dist-thr=0.7 iou-thr=0.8 init-iou-thr=0.9 \
            keep-new-frames=2 keep-tracked-frames=6 keep-lost-frames=8 keep-past-metadata=true qos=false ! \
        hailooverlay qos=false ! \
        videoconvert ! \
        fpsdisplaysink video-sink=xvimagesink name=hailo_display sync=false text-overlay=false
    
  3. Rebuild and Test the Updated HailoFilter

    • Rebuild the shared library (libcenterpose_post.so) with the modified logic to extract tracking IDs.
    • Test the updated pipeline to ensure tracking IDs are correctly retrieved and processed by the HailoFilter.

Update Notice:
This enhancement is planned for inclusion in upcoming releases of the Hailo Raspberry Pi examples, providing out-of-the-box support for accessing HailoTracker metadata in HailoFilter. This update will allow developers to easily integrate tracking logic directly into their post-processing workflows on Raspberry Pi devices.

Let me know if you need help modifying the libcenterpose_post.so library or testing the changes on your Raspberry Pi!

Best Regards,
Omria

Thanks Omria!

now we are able to get tracking id (unique id) in libcenterpose_post.so.

void filter(HailoROIPtr roi)
{
    for (const auto& obj : roi->get_objects())
    {
        if (obj->get_type() == HAILO_DETECTION)
        {
            auto detection = std::dynamic_pointer_cast<HailoDetection>(obj);
            for (const auto& inner_obj : detection->get_objects())
            {
                if (inner_obj->get_type() == HAILO_UNIQUE_ID)
                {
                    auto id = std::dynamic_pointer_cast<HailoUniqueID>(inner_obj);
                    std::cout << "[CENTERPOSE] TARUNA -----------unique_id: " << id->get_id() << std::endl;
                }
            }
        }
    }
    centerpose(roi);
}