How to show tracking id in out.mp4 - DeepStream4.0

Hi, I can run the deepstream app and get the output file as out.mp4, but there are only bboxs shown, I cannot figure out how to show the tracking id.

the config file is

source4_1080p_dec_infer-resnet_tracker_sgie_tiled_display_int8_gpu1.txt

I enable this sink only

[sink1]
enable=1
type=3
#1=mp4 2=mkv
container=1
#1=h264 2=h265
codec=3
sync=0
bitrate=2000000
output-file=out.mp4
source-id=0
gpu-id=0

and the osd is

[osd]
enable=1
gpu-id=0
border-width=1
text-size=15
text-color=1;1;1;1;
text-bg-color=0.3;0.3;0.3;1
font=Serif
show-clock=1
clock-x-offset=800
clock-y-offset=820
clock-text-size=12
clock-color=1;0;0;0
nvbuf-memory-type=0

How to display the tracking id?
Can someone help me?

And also, when I enable the sink blow

[sink0]
enable=1
#Type - 1=FakeSink 2=EglSink 3=File
type=2
sync=1
source-id=0
gpu-id=0
nvbuf-memory-type=0

I get a black window with this error:

(deepstream-app:868): GLib-GObject-WARNING **: 09:59:34.062: g_object_set_is_valid_property: object class 'avenc_mpeg4' has no property named 'iframeinterval'

(deepstream-app:868): GLib-GObject-WARNING **: 09:59:34.062: g_object_set_is_valid_property: object class 'avenc_mpeg4' has no property named 'bufapi-version'
libEGL warning: DRI3: failed to query the version
libEGL warning: DRI2: failed to authenticate
Creating LL OSD context new
gstnvtracker: Loading low-level lib at /opt/nvidia/deepstream/deepstream-4.0/lib/libnvds_mot_klt.so
gstnvtracker: Optional NvMOT_RemoveStreams not implemented
gstnvtracker: Batch processing is OFF

Runtime commands:
	h: Print this help
	q: Quit

	p: Pause
	r: Resume

NOTE: To expand a source in the 2D tiled display and view object details, left-click on the source.
      To go back to the tiled display, right-click anywhere on the window.

** INFO: <bus_callback:163>: Pipeline ready

**PERF: FPS 0 (Avg)	FPS 1 (Avg)	FPS 2 (Avg)	FPS 3 (Avg)	
**PERF: 0.00 (0.00)	0.00 (0.00)	0.00 (0.00)	0.00 (0.00)	
Creating LL OSD context new
cuGraphicsGLRegisterBuffer failed with error(219) gst_eglglessink_cuda_init texture = 1
** INFO: <bus_callback:149>: Pipeline running

KLT Tracker Init
KLT Tracker Init
KLT Tracker Init
KLT Tracker Init
**PERF: 20.75 (20.75)	20.75 (20.75)	17.77 (17.77)	17.77 (17.77)	
**PERF: 0.00 (20.75)	0.00 (20.75)	0.00 (17.77)	0.00 (17.77)	
**PERF: 0.00 (20.75)	0.00 (20.75)	0.00 (17.77)	0.00 (17.77)	
**PERF: 0.00 (20.75)	0.00 (20.75)	0.00 (17.77)	0.00 (17.77)	
**PERF: 0.00 (20.75)	0.00 (20.75)	0.00 (17.77)	0.00 (17.77)	
ERROR from secondary_gie_bin_queue: Internal data stream error.
Debug info: gstqueue.c(988): gst_queue_handle_sink_event (): /GstPipeline:pipeline/GstBin:secondary_gie_bin/GstQueue:secondary_gie_bin_queue:
streaming stopped, reason not-negotiated (-4)
Quitting
ERROR from sink_bin_queue: Internal data stream error.
Debug info: gstqueue.c(988): gst_queue_handle_sink_event (): /GstPipeline:pipeline/GstBin:processing_bin_0/GstBin:sink_bin/GstQueue:sink_bin_queue:
streaming stopped, reason not-negotiated (-4)
App run failed

Can you try deepstream-test2 ? Modify the code in function “osd_sink_pad_buffer_probe()”
Add “NvDsObjectMeta->object_id” to “txt_params->display_text”

Thank you for your reply. I can do it in deepstream-app now.

Thank you yuanyue1168 and ChrisDing for raising this question and I am glad you got the solution.

Can some one help me with adding “NvDsObjectMeta->object_id” to “txt_params->display_text” in deepstream-test2?..

static GstPadProbeReturn
osd_sink_pad_buffer_probe (GstPad * pad, GstPadProbeInfo * info,
gpointer u_data)
{
GstBuffer *buf = (GstBuffer *) info->data;
guint num_rects = 0;
NvDsObjectMeta *obj_meta = NULL;
guint vehicle_count = 0;
guint person_count = 0;
NvDsMetaList * l_frame = NULL;
NvDsMetaList * l_obj = NULL;
NvDsDisplayMeta *display_meta = NULL;

NvDsBatchMeta *batch_meta = gst_buffer_get_nvds_batch_meta (buf);

for (l_frame = batch_meta->frame_meta_list; l_frame != NULL;
  l_frame = l_frame->next) {
    NvDsFrameMeta *frame_meta = (NvDsFrameMeta *) (l_frame->data);
    int offset = 0;
    for (l_obj = frame_meta->obj_meta_list; l_obj != NULL;
            l_obj = l_obj->next) {
        obj_meta = (NvDsObjectMeta *) (l_obj->data);
        if (obj_meta->class_id == PGIE_CLASS_ID_VEHICLE) {
            vehicle_count++;
            num_rects++;
        }
            if (obj_meta->class_id == PGIE_CLASS_ID_PERSON) {
            person_count++;
            num_rects++;
        }
    }
    display_meta = nvds_acquire_display_meta_from_pool(batch_meta);
    NvOSD_TextParams *txt_params  = &display_meta->text_params[0];
    display_meta->num_labels = 1;
    txt_params->display_text = g_malloc0 (MAX_DISPLAY_LEN);

//Add “NvDsObjectMeta->object_id” to “txt_params->display_text”

offset = snprintf(txt_params->display_text, MAX_DISPLAY_LEN, "Person = %d ", person_count);
offset = snprintf(txt_params->display_text + offset , MAX_DISPLAY_LEN, "Vehicle = %d ", vehicle_count);

    /* Now set the offsets where the string should appear */
    txt_params->x_offset = 10;
    txt_params->y_offset = 12;

    /* Font , font-color and font-size */
    txt_params->font_params.font_name = "Serif";
    txt_params->font_params.font_size = 10;
    txt_params->font_params.font_color.red = 1.0;
    txt_params->font_params.font_color.green = 1.0;
    txt_params->font_params.font_color.blue = 1.0;
    txt_params->font_params.font_color.alpha = 1.0;

    /* Text background color */
    txt_params->set_bg_clr = 1;
    txt_params->text_bg_clr.red = 0.0;
    txt_params->text_bg_clr.green = 0.0;
    txt_params->text_bg_clr.blue = 0.0;
    txt_params->text_bg_clr.alpha = 1.0;

nvds_add_display_meta_to_frame(frame_meta, display_meta);
}

g_print ("Frame Number = %d Number of objects = %d "
        "Vehicle Count = %d Person Count = %d\n",
        frame_number, num_rects, vehicle_count, person_count);
frame_number++;
return GST_PAD_PROBE_OK;

}

For anyone who came searching for this…

go to main
Replace osd_sink_pad = gst_element_get_static_pad (nvosd, “sink”);

by osd_sink_pad = gst_element_get_static_pad (nvtracker, “src”); in DStest2 file

and you should get Tracking ID in output with object label…

This is explained by @NvCJR with source code…
https://devtalk.nvidia.com/default/topic/1062677/whats-means-in-nvtracker-/?offset=2

thank you

Hello I am kind of new with this and what i understand is you want to display the IDs but in my case I need to get them so that i can apply them to my algorithm. How can I get the “List of Id with their coordinates”

I try to debug the when the code enters the pipe is hard to debug so i just print debug but couldn’t find the the Ids and coordinates (x, y).

Could you please address me to a document or a function call?