Modify the code and configuration file as follows then recompile.
diff --git a/sources/apps/sample_apps/deepstream-test4/deepstream_test4_app.c b/sources/apps/sample_apps/deepstream-test4/deepstream_test4_app.c
index b292853..cbaae99 100755
--- a/sources/apps/sample_apps/deepstream-test4/deepstream_test4_app.c
+++ b/sources/apps/sample_apps/deepstream-test4/deepstream_test4_app.c
@@ -535,13 +535,14 @@ osd_sink_pad_buffer_image_probe (GstPad * pad, GstPadProbeInfo * info,
START_PROFILE;
encoded_data = g_base64_encode(enc_jpeg_image->outBuffer, enc_jpeg_image->outLen);
generate_ts_rfc3339 (ts, MAX_TIME_STAMP_LEN);
+ gchar *anomaly_object = g_strdup_printf("%s", "your struct to string like broken fence... ");
width = g_strdup_printf("%f", obj_meta->detector_bbox_info.org_bbox_coords.width);
height = g_strdup_printf("%f", obj_meta->detector_bbox_info.org_bbox_coords.height);
/* Image message fields are separated by ";".
* Specific Format: "image;image_format;image_widthximage_height;time;encoded data;"
* For Example: "image;jpg;640x480;2023-07-31T10:20:13;xxxxxxxxxxx"
*/
- message_data = g_strconcat("image;jpg;", width, "x", height, ";", ts, ";", encoded_data, ";", NULL);
+ message_data = g_strconcat(anomaly_object, ";", "image;jpg;", width, "x", height, ";", ts, ";", encoded_data, ";", NULL);
STOP_PROFILE("Base64 Encode Time ");
msg_custom_meta->size = strlen(message_data);
msg_custom_meta->message = g_strdup(message_data);
@@ -571,6 +572,7 @@ osd_sink_pad_buffer_image_probe (GstPad * pad, GstPadProbeInfo * info,
}
g_free(decoded_data);
#endif
+ g_free(anomaly_object);
g_free(encoded_data);
g_free(message_data);
g_free(width);
diff --git a/sources/apps/sample_apps/deepstream-test4/dstest4_config.yml b/sources/apps/sample_apps/deepstream-test4/dstest4_config.yml
index e5ce843..abdf349 100755
--- a/sources/apps/sample_apps/deepstream-test4/dstest4_config.yml
+++ b/sources/apps/sample_apps/deepstream-test4/dstest4_config.yml
@@ -21,14 +21,15 @@ streammux:
msgconv:
#If you want to send images, please set the "payload-type: 1" and "msg2p-newapi: 1"
- payload-type: 0
- msg2p-newapi: 0
- frame-interval: 30
+ payload-type: 1
+ msg2p-newapi: 1
+ frame-interval: 3
msgbroker:
+ enable: 1
proto-lib: /opt/nvidia/deepstream/deepstream/lib/libnvds_kafka_proto.so
- conn-str: <host>;<port>
- topic: <topic>
+ conn-str: localhost;9092;quick-test
+ topic: quick-test
sync: 0
sink:
start kafka server , create topic and monitor the topic.
docker run --rm --name kafka-test -p 9092:9092 apache/kafka:3.7.0
docker exec -it kafka-test /opt/kafka/bin/kafka-topics.sh --create --topic quick-test --bootstrap-server localhost:9092
docker exec -it kafka-test /opt/kafka/bin/kafka-console-consumer.sh --topic quick-test --from-beginning --bootstrap-server localhost:9092
deepstream-test4 sent the expected data,including base64-encoded image and custom structure
"18446744073709551615|843.888|476.3|1067.2|606.403|car",
"18446744073709551615|555.11|438.81|643.408|525.774|car",
"18446744073709551615|1142.21|489.083|1424.63|612.898|car",
"18446744073709551615|617.661|479.333|717.363|562.078|car"
],
"customMessage" : [
"your struct to string like broken fence... ;image;jpg;19.804108x32.191082;2025-01-24T10:06:36.234Z;/9j/2wCEAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODwwQFxQYGBcUFhYaHSUfGhsjHBYWICwgIyYnKSopGR8tMC0oMCUoKSgBBwcHCggKEwoKEygaFhooKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKP/EAaIAAAEFAQEBAQEBAAAAAAAAAAABAgMEBQYHCAkKCxAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6AQADAQEBAQEBAQEBAAAAAAAAAQIDBAUGBwgJCgsRAAIBAgQEAwQHBQQEAAECdwABAgMRBAUhMQYSQVEHYXETIjKBCBRCkaGxwQkjM1LwFWJy0QoWJDThJfEXGBkaJicoKSo1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoKDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uLj5OXm5+jp6vLz9PX29/j5+v/AABEIACAAFAMAIgABEQECEQH/2gAMAwAAARECEQA/AO2aE7svOxx/DT2C7gydfellUg9MVGNx6Y/E0rFtWHMZCckZNNw/92omW7z8k8Kr6Gk23v8Az8wflT5RXBbeK+t45p2kDFedrYqhPotruJ+1TID28w/41XtdS0vXZ5Gu3NkYv3ZiJx0Bo/svSJ5NscryqRnIPFXym1Wzegp0WwB+a8lJ/wCup/xpP7F0/wD5+5f+/p/xp3/CGac/zFp+fQ0f8IVpv964/OixiP/Z;"
]
}