Customizing frame-drawing using the Hailo 8L chip on a Raspberry Pi 5

I’m working on a Raspberry Pi 5 project using the Hailo 8L chip, where I currently have a YOLO model tracking people. I’d like to implement some additional features related to “drawing on frames,” such as:

  1. Deciding my own bounding box colors for each object.
  2. Drawing static lines on the frame.
  3. Applying my own clustering algorithm to group people into clusters and drawing the cluster boundaries.
  4. Enhancing the current tracking logic (I’m using hailo_tracker, but it’s not customizable enough for my needs).

Are there tools compatible with the Hailo 8L that allow these enhancements without retraining the model? Any suggestions or examples would be greatly appreciated!

This is my pipeline:

    pipeline = (
        f"{SOURCE_PIPELINE('rpi')} "
        f"{INFERENCE_PIPELINE(self.config['paths']['model']['hef_path'], self.config['paths']['model']['post_process_path'], batch_size=1, additional_params=inference_params)} ! "
        f"{TRACKER_PIPELINE()} ! "
        f"{USER_CALLBACK_PIPELINE()} ! "
        f"{DISPLAY_PIPELINE(video_sink='xvimagesink', sync='false', show_fps='true')}"
    )

and this is the tracker_pipeline:

tracker_pipeline = (
    f'{QUEUE(name=f"{name}_q")} ! '
    f'hailotracker name={name} '
    'keep-tracked-frames=30 '     # Keep track for ~1 sec at 30fps
    'keep-new-frames=15 '         # Half second to confirm new track
    'keep-lost-frames=5 '        # Half second before considering track lost
)

I think you dont need a retrain model. Maybe yes but not at beginning at project, and not for changing detection of boxes. I see you use classic pipeline from example of Hailo.

Changing boxes size will be able do in USER_CALLBACK_PIPELINE(in user_data.use_frame), but I find GStreamer rewrite some output at DISPLAY_PIPELINE.I find the user_data.use_frame is false. So I think that part never run. I dont find yet where to change.

So making some logic after detection can change your boxes.

I actually have simular problem I want change boxes text from person to some action. Like sitting, standing. I can write to console but not in frame directly. I want use for demonstration.

@user701 @Yoav_Schwammenthal

No need for use_frame or direct frame drawing. The hailooverlay element renders whatever metadata is attached to the detection objects. You can modify that metadata in your callback, which runs before overlay:

The pipeline order is:
… → hailonet (inference) → YOUR CALLBACK → hailooverlay → display

To add custom text to a detection box, attach a HailoClassification child object:

def app_callback(pad, info, user_data):
    buffer = info.get_buffer()
    if buffer is None:
        return Gst.PadProbeReturn.OK

    roi = hailo.get_roi_from_buffer(buffer)
    detections = roi.get_objects_typed(hailo.HAILO_DETECTION)

    for detection in detections:
        if detection.get_label() == "person":
            # Your custom logic here
            action = "sitting"  # or compute from pose, position, etc.

            # Add as a child classification — hailooverlay renders it below the box label
            classification = hailo.HailoClassification(
                type="action", label=action, confidence=1.0
            )
            detection.add_object(classification)

    return Gst.PadProbeReturn.OK

Notes:

  • hailooverlay renders both - it draws the detection label and also renders any child classifications below/inside the box, showing the label and confidence.
  • use_frame is only needed if you want to draw custom graphics (circles, lines, etc.) directly on the frame with OpenCV. For adding text to boxes, it’s unnecessary.
  • The callback runs before hailooverlay, so any modifications to detection objects — adding classifications, removing detections, etc. — are reflected in the final display.

Thanks,

1 Like

Hii Thanks for help.

I it is not functional. Becouse using destection.set_label(“sitting“) say set_label not defined. But I find I can add new label over existing it is not best sollution

new_label = "sitting"
hailo.HailoDetection(bbox=bbox, label=new_label, confidence=confidence)
roi.add_object(new_det)

And about OpenCV that work good (for circle, lines, text). I don’t know before I need use –use-frame as parametr to use it.

Thanks @user701 I’ve edited my answer.