Draw tracking id on deepstream-test-5 DeepStream 5.0

Please provide complete information as applicable to your setup.

• Hardware Platform (Jetson / GPU)
• DeepStream Version: 5.0
• JetPack Version (valid for Jetson only)
• TensorRT Version
• NVIDIA GPU Driver Version (valid for GPU only)
Hi @Guys,
How can I draw tracking id on deepstream-test-5?
I have 4 input videos, I want to draw tracking id on the output video

I have tried to update overlay_graphic function

static gboolean
overlay_graphics (AppCtx * appCtx, GstBuffer * buf,
NvDsBatchMeta * batch_meta, guint index)
{
NvDsObjectMeta *obj_meta = NULL;
NvDsMetaList *l_frame = NULL;
NvDsMetaList *l_obj = NULL;
NvDsDisplayMeta *display_meta = NULL;

    static gchar* font_name = "Serif";
    for (l_frame = batch_meta->frame_meta_list; l_frame != NULL;
        l_frame = l_frame->next)
    {
            int idx = 0;
            NvDsFrameMeta *frame_meta = (NvDsFrameMeta *)(l_frame->data);
            display_meta = nvds_acquire_display_meta_from_pool(batch_meta);
            for (l_obj = frame_meta->obj_meta_list; l_obj != NULL;
                     l_obj = l_obj->next)
            {
                    obj_meta = (NvDsObjectMeta *)(l_obj->data);
                    int object_id = obj_meta->object_id;
                    float x = obj_meta->rect_params.left;
                    float y = obj_meta->rect_params.top;
                    float width = obj_meta->rect_params.width;
                    float height = obj_meta->rect_params.height;

// g_print(“%d %f %f %f %f\n”, object_id, x, y, width, height);
NvOSD_TextParams *text_params = &display_meta->text_params[idx];
//g_print(“%d %f %f %f %f\n”, object_id, x, y, width, height);
text_params->display_text = (char *)g_malloc0(MAX_DISPLAY_LEN);
snprintf(text_params->display_text, MAX_DISPLAY_LEN, “%d”, object_id);
// text_params->display_text=“a”;
text_params->x_offset = (unsigned int) x;
text_params->y_offset = (unsigned int) y - 10;
//g_print(“%s %d %d %f %d %f %f %f\n”, text_params->display_text ,object_id, text_params->x_offset, x, text_params->y_offset, y, width, height);
text_params->set_bg_clr = 1;
text_params->text_bg_clr = (NvOSD_ColorParams) {
0, 0, 0, 1};
// Font face, size and color
text_params->font_params.font_name = font_name;
text_params->font_params.font_size = 11;
text_params->font_params.font_color = (NvOSD_ColorParams) {
1, 1, 1, 1};
idx++;
g_print(“%d”, idx);
}
g_print(“new %d\n”, MAX_ELEMENTS_IN_DISPLAY_META);
display_meta->num_labels=idx;
nvds_add_display_meta_to_frame(frame_meta, display_meta);
}
return TRUE;
}

but the deepstream-test-5 is crashed

corrupted size vs. prev_size
Aborted (core dumped)

After you enable tracker, tracker ID will be shown on output.

Hi @Amycao,
I have enabled tracker. This is my config file:

Copyright (c) 2018-2020 NVIDIA Corporation. All rights reserved.

NVIDIA Corporation and its licensors retain all intellectual property

and proprietary rights in and to this software, related documentation

and any modifications thereto. Any use, reproduction, disclosure or

distribution of this software and related documentation without an express

license agreement from NVIDIA Corporation is strictly prohibited.

[application]
enable-perf-measurement=1
perf-measurement-interval-sec=5

[tiled-display]
enable=1
rows=2
columns=2
width=1280
height=720
gpu-id=0
nvbuf-memory-type=0

[source0]
enable=1
type=3
uri = file:///opt/nvidia/deepstream/deepstream-5.0/sources/apps/sample_apps/deepstream-test5-overhead/scam6_5mins.mp4
num-sources=1
gpu-id=0
nvbuf-memory-type=0

[source1]
enable=1
type=3
#uri = file:///opt/nvidia/deepstream/deepstream-5.0/sources/apps/sample_apps/deepstream-test5-overhead/cam1_1hour.mp4
uri=file:///opt/nvidia/deepstream/deepstream-5.0/sources/apps/sample_apps/deepstream-test5-overhead/scam5_5mins.mp4
#uri=file:///root/shared_data/cam6_5mins_2304_1296_bitrate_8500k.mp4
num-sources=1
gpu-id=0
nvbuf-memory-type=0

[source2]
enable=1
type=3
uri=file:///opt/nvidia/deepstream/deepstream-5.0/sources/apps/sample_apps/deepstream-test5-overhead/scam1_5mins.mp4
num-sources=1
gpu-id=0
nvbuf-memory-type=0

[source3]
enable=1
type=3
uri=file:///opt/nvidia/deepstream/deepstream-5.0/sources/apps/sample_apps/deepstream-test5-overhead/scam2_5mins.mp4
num-sources=1
gpu-id=0
nvbuf-memory-type=0

[sink0]
enable=0
#Type - 1=FakeSink 2=EglSink 3=File 4=RTSPStreaming 5=Overlay
type=4
codec=2
enc-type=0
sync=0
source-id=0
bitrate=12000000
rtsp-port=8554
udp-port=5400
width=1280
height=720

[sink1]
enable=1
#Type - 1=FakeSink 2=EglSink 3=File 4=UDPSink 5=nvoverlaysink 6=MsgConvBroker
type=6
msg-conv-config=dstest5_msgconv_sample_config.txt
#(0): PAYLOAD_DEEPSTREAM - Deepstream schema payload
#(1): PAYLOAD_DEEPSTREAM_MINIMAL - Deepstream schema payload minimal
#(256): PAYLOAD_RESERVED - Reserved type
#(257): PAYLOAD_CUSTOM - Custom schema payload
msg-conv-payload-type=0
msg-broker-proto-lib=/opt/nvidia/deepstream/deepstream-5.0/lib/libnvds_kafka_proto.so
#Provide your msg-broker-conn-str here
msg-broker-conn-str=54.255.25.224;9092;test
topic=test
#Optional:
msg-broker-config=…/…/deepstream-test4/cfg_kafka.txt

[sink2]
enable=1
type=3
container=2
codec=1
sync=0
bitrate=12000000
output-file=cam_0_5min.mkv
source-id=0
width=960
height=540

[message-converter]
enable=0
msg-conv-config=dstest5_msgconv_sample_config.txt
#(0): PAYLOAD_DEEPSTREAM - Deepstream schema payload
#(1): PAYLOAD_DEEPSTREAM_MINIMAL - Deepstream schema payload minimal
#(256): PAYLOAD_RESERVED - Reserved type
#(257): PAYLOAD_CUSTOM - Custom schema payload
msg-conv-payload-type=0
[message-consumer0]
enable=0
proto-lib=/opt/nvidia/deepstream/deepstream-5.0/lib/libnvds_kafka_proto.so
conn-str=;
config-file=
subscribe-topic-list=;;

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

[streammux]
gpu-id=0
##Boolean property to inform muxer that sources are live
live-source=0
batch-size=4
##time out in usec, to wait after the first buffer is available
##to push the batch even if the complete batch is not formed
batched-push-timeout=30000
width=1280
height=960
enable-padding=1
nvbuf-memory-type=0

[primary-gie]
enable=1
gpu-id=0
#Required to display the PGIE labels, should be added even when using config-file
#property
batch-size=4
#Required by the app for OSD, not a plugin property
bbox-border-color0=1;0;0;1
bbox-border-color1=0;1;1;1
bbox-border-color2=0;0;1;1
bbox-border-color3=0;1;0;1
interval=0
#Required by the app for SGIE, when used along with config-file property
gie-unique-id=1
nvbuf-memory-type=0
#tlt-encoded-model=…/…/…/…/…/samples/models/trt_models/peoplenet/resnet18_detector.etlt
labelfile-path=…/…/…/…/…/samples/models/trt_models/peoplenet/labels.txt
#tlt-model-key=tlt_encode
#int8-calib-file=…/…/…/…/…/samples/models/trt_models/peoplenet/calibration.bin
config-file=…/…/…/…/…/samples/configs/tlt_pretrained_models/config_infer_primary_peoplenet_overhead.txt
#infer-raw-output-dir=…/…/…/…/…/samples/primary_detector_raw_output/

[tracker]
enable=1
tracker-width=1280
tracker-height=960
ll-lib-file=/opt/nvidia/deepstream/deepstream-5.0/lib/libnvds_nvdcf.so
#ll-config-file required for DCF/IOU only
ll-config-file=/opt/nvidia/deepstream/deepstream-5.0/samples/configs/deepstream-app/tracker_config2.yml
#ll-config-file=iou_config.txt
gpu-id=0
#enable-batch-process applicable to DCF only
enable-batch-process=1

#[secondary-gie0]
#enable=0
#gpu-id=0
#gie-unique-id=4
#operate-on-gie-id=1
#operate-on-class-ids=0;
#batch-size=16
#config-file=…/…/…/…/…/samples/configs/deepstream-app/config_infer_secondary_vehicletypes.txt
#labelfile-path=…/…/…/…/…/samples/models/Secondary_VehicleTypes/labels.txt
#model-engine-file=…/…/…/…/…/samples/models/Secondary_VehicleTypes/resnet18.caffemodel_b16_gpu0_int8.engine

[secondary-gie0]
enable=1
gpu-id=0
gie-unique-id=4
operate-on-gie-id=1
operate-on-class-ids=0;
batch-size=64
config-file=/opt/nvidia/deepstream/deepstream-5.0/sources/apps/sample_apps/deepstream_overhead_emb-extract/configs/secondary_feature_extraction_test.txt
#labelfile-path=…/…/…/…/…/samples/models/Secondary_VehicleTypes/labels.txt
##model-engine-file=…/…/…/…/…/samples/models/Secondary_VehicleTypes/resnet18.caffemodel_b16_gpu0_int8.engine

[secondary-gie1]
enable=0
gpu-id=0
gie-unique-id=5
operate-on-gie-id=1
operate-on-class-ids=0;
batch-size=16
config-file=…/…/…/…/…/samples/configs/deepstream-app/config_infer_secondary_carcolor.txt
labelfile-path=…/…/…/…/…/samples/models/Secondary_CarColor/labels.txt
model-engine-file=…/…/…/…/…/samples/models/Secondary_CarColor/resnet18.caffemodel_b16_gpu0_int8.engine

[secondary-gie2]
enable=0
gpu-id=0
gie-unique-id=6
operate-on-gie-id=1
operate-on-class-ids=0;
batch-size=16
config-file=…/…/…/…/…/samples/configs/deepstream-app/config_infer_secondary_carmake.txt
labelfile-path=…/…/…/…/…/samples/models/Secondary_CarMake/labels.txt
model-engine-file=…/…/…/…/…/samples/models/Secondary_CarMake/resnet18.caffemodel_b16_gpu0_int8.engine

[tests]
file-loop=0

You do not need to add your change, by default if tracker enabled, tracking id will be shown. please add -t option when you run sample.