Unable to retrieve detected object ID - Hailo8 + RPI5

Hello everyone,

I’m working on a project using a Yolov8l model on a Raspberry Pi5 with the Hailo 8 coprocessor. I successfully trained and tested the model on my PC, and I can retrieve the detected object ID using the following code:

model = YOLO("yolo8l.pt")
model.predict(frame)
track_ids = results[0].boxes.id.int().cpu().tolist()

I then converted the model to the .hef format following the instructions provided in hailo-rpi5-examples. While I can successfully perform inference on the converted model, I’m unable to retrieve the object ID. I can access the detected object label, but there seems to be no clear way to get the ID.

I’ve searched for solutions online but haven’t found anything definitive. Can anyone provide some guidance on how to access the object ID after conversion to the .hef model?

Expected Behavior:

I expect the code to return a list containing the IDs of the detected objects, similar to the output on my PC.

Any help would be greatly appreciated!

Hardware: RPI5 + Hailo8
Model: Yolov8l

Hey @aameralshamy3,

To solve the tracking ID issue when moving from YOLOv8 on your PC to a .hef model, consider these key points:

  1. Metadata Differences:

    • YOLOv8 on PC likely includes tracking, but the .hef model only has object detection.
    • Tracking IDs are usually added in post-processing, not the .hef pipeline.
  2. GStreamer Pipeline:

    • Use HailoTracker to generate tracking metadata:

      gst-launch-1.0 \
          v4l2src device=/dev/video0 ! \
          decodebin ! \
          videoscale ! \
          video/x-raw, format=RGB, width=640, height=480, framerate=30/1 ! \
          hailonet hef-path=/path/to/yolov8l.hef ! \
          hailotracker 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 qos=false ! \
          hailooverlay qos=false ! \
          videoconvert ! \
          fpsdisplaysink video-sink=xvimagesink sync=false text-overlay=false
      
  3. Python Code Changes:

    • Update the callback function to retrieve tracking IDs from buffer metadata:

      tracking_id = detection.get_metadata("tracking_id") if detection.has_metadata("tracking_id") else None
      
    • Annotate frames with bounding boxes and tracking IDs using OpenCV.

  4. Output:

    • The updated pipeline and code will display bounding boxes and tracking IDs on the video stream.
    • Tracking IDs and detection details will be printed to the console.

Let me know if you need any help testing or customizing the solution further!

Best Regards,
Omria