Showing confidence in the bounding box details

Please provide complete information as applicable to your setup.

• Hardware Platform (Jetson / GPU) Jetson Xavier AGX
• DeepStream Version 6.0.1
• JetPack Version (valid for Jetson only) 4.6
• TensorRT Version 8.2.1

I am trying to the object detection confidence to the bounding box detection from the tracking sample gpubootcamp/Introduction_to_Multi-DNN_pipeline.ipynb at a647a2c3fc75828cbbf1cbd5ab29f865c491a35c · openhackathons-org/gpubootcamp · GitHub . The labels show the object class and the tracking ID, but I don’t understand how this information gets there. See image bellow:

I see that osd_sink_pad_buffer_probe(pad,info,u_data) displays the information on the image frame, but I can’t see where it states that class and tracker id must be placed at the top of the bounding box. And I want to include the object confidence.

I know I can get the confidence from object in this loop, by accessing obj_meta.confidence

while l_obj is not None:
        # Casting to pyds.NvDsObjectMeta
        obj_meta = pyds.NvDsObjectMeta.cast(
    except StopIteration:
    obj_counter[obj_meta.class_id] += 1
    obj_meta.rect_params.border_color.set(0.0, 0.0, 1.0, 1.0)
    obj_meta.text_params.font_params.font_color.set(1.0, 1.0, 1.0, 1.0)
    obj_meta.text_params.text_bg_clr.set(0.0, 0.0, 1.0, 1.0)
    # Can get confidence by accessing obj_meta.confidence
        l_obj =
    except StopIteration:

Therefore, how I can define what is shown in the bounding box text?

Thanks in advance,

Flávio Mello

Hi @flavio.mello

Something like this should do the trick:

        batch_meta = pyds.gst_buffer_get_nvds_batch_meta(hash(buf))
        frame_meta_list = batch_meta.frame_meta_list
        while frame_meta_list:
            frame_meta = pyds.NvDsFrameMeta.cast(
            obj_meta_list = frame_meta.obj_meta_list
            while obj_meta_list:
                object_meta = pyds.NvDsObjectMeta.cast(
                confidence = object_meta.confidence
                display_text = pyds.get_string(object_meta.text_params.display_text)
                object_meta.text_params.display_text = display_text + " " + str(confidence)
                obj_meta_list =
            frame_meta_list =

I’m not sure if the python version works, because I perform most of the meta manipulation on C.


The C++ tip helped a lot. This is the python code:

obj_display_text = pyds.get_string(obj_meta.text_params.display_text) + ' {:.2f}%'.format(obj_meta.confidence * 100)
obj_meta.text_params.display_text = obj_display_text

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.