How to reproduce your problem? Theappsink
works as expected.
The following patch is based on /opt/nvidia/deepstream/deepstream/sources/apps/sample_apps/deepstream-appsrc-test
diff --git a/sources/apps/sample_apps/deepstream-appsrc-test/deepstream_appsrc_test_app.c b/sources/apps/sample_apps/deepstream-appsrc-test/deepstream_appsrc_test_app.c
index 1c441ed..4539ca6 100644
--- a/sources/apps/sample_apps/deepstream-appsrc-test/deepstream_appsrc_test_app.c
+++ b/sources/apps/sample_apps/deepstream-appsrc-test/deepstream_appsrc_test_app.c
@@ -83,6 +83,11 @@ new_sample (GstElement * sink, gpointer * data)
l_obj = l_obj->next) {
obj_meta = (NvDsObjectMeta *) (l_obj->data);
if (obj_meta->class_id == PGIE_CLASS_ID_VEHICLE) {
+ printf("left %.2f top %.2f width %.2f height %.2f \n",
+ obj_meta->tracker_bbox_info.org_bbox_coords.left,
+ obj_meta->tracker_bbox_info.org_bbox_coords.top,
+ obj_meta->tracker_bbox_info.org_bbox_coords.width,
+ obj_meta->tracker_bbox_info.org_bbox_coords.height);
vehicle_count++;
num_rects++;
}
@@ -210,6 +215,132 @@ usage(const char *bin)
"<format(I420, NV12, RGBA)>\n", bin);
}
+/* Tracker config parsing */
+#define CHECK_ERROR(error) \
+ if (error) { \
+ g_printerr ("Error while parsing config file: %s\n", error->message); \
+ goto done; \
+ }
+
+#define CONFIG_GROUP_TRACKER "tracker"
+#define CONFIG_GROUP_TRACKER_WIDTH "tracker-width"
+#define CONFIG_GROUP_TRACKER_HEIGHT "tracker-height"
+#define CONFIG_GROUP_TRACKER_LL_CONFIG_FILE "ll-config-file"
+#define CONFIG_GROUP_TRACKER_LL_LIB_FILE "ll-lib-file"
+#define CONFIG_GPU_ID "gpu-id"
+
+#define TRACKER_CONFIG_FILE "dstest2_tracker_config.txt"
+#define MAX_TRACKING_ID_LEN 16
+
+static gchar *
+get_absolute_file_path (gchar *cfg_file_path, gchar *file_path)
+{
+ gchar abs_cfg_path[PATH_MAX + 1];
+ gchar *abs_file_path;
+ gchar *delim;
+
+ if (file_path && file_path[0] == '/') {
+ return file_path;
+ }
+
+ if (!realpath (cfg_file_path, abs_cfg_path)) {
+ g_free (file_path);
+ return NULL;
+ }
+
+ // Return absolute path of config file if file_path is NULL.
+ if (!file_path) {
+ abs_file_path = g_strdup (abs_cfg_path);
+ return abs_file_path;
+ }
+
+ delim = g_strrstr (abs_cfg_path, "/");
+ *(delim + 1) = '\0';
+
+ abs_file_path = g_strconcat (abs_cfg_path, file_path, NULL);
+ g_free (file_path);
+
+ return abs_file_path;
+}
+
+static gboolean
+set_tracker_properties (GstElement *nvtracker)
+{
+ gboolean ret = FALSE;
+ GError *error = NULL;
+ gchar **keys = NULL;
+ gchar **key = NULL;
+ GKeyFile *key_file = g_key_file_new ();
+
+ if (!g_key_file_load_from_file (key_file, TRACKER_CONFIG_FILE, G_KEY_FILE_NONE,
+ &error)) {
+ if (error) {
+ g_printerr ("Failed to load config file: %s\n", error->message);
+ g_error_free (error);
+ } else {
+ g_printerr ("Failed to load config file.\n");
+ }
+ return FALSE;
+ }
+
+ keys = g_key_file_get_keys (key_file, CONFIG_GROUP_TRACKER, NULL, &error);
+ CHECK_ERROR (error);
+
+ for (key = keys; *key; key++) {
+ if (!g_strcmp0 (*key, CONFIG_GROUP_TRACKER_WIDTH)) {
+ gint width =
+ g_key_file_get_integer (key_file, CONFIG_GROUP_TRACKER,
+ CONFIG_GROUP_TRACKER_WIDTH, &error);
+ CHECK_ERROR (error);
+ g_object_set (G_OBJECT (nvtracker), "tracker-width", width, NULL);
+ } else if (!g_strcmp0 (*key, CONFIG_GROUP_TRACKER_HEIGHT)) {
+ gint height =
+ g_key_file_get_integer (key_file, CONFIG_GROUP_TRACKER,
+ CONFIG_GROUP_TRACKER_HEIGHT, &error);
+ CHECK_ERROR (error);
+ g_object_set (G_OBJECT (nvtracker), "tracker-height", height, NULL);
+ } else if (!g_strcmp0 (*key, CONFIG_GPU_ID)) {
+ guint gpu_id =
+ g_key_file_get_integer (key_file, CONFIG_GROUP_TRACKER,
+ CONFIG_GPU_ID, &error);
+ CHECK_ERROR (error);
+ g_object_set (G_OBJECT (nvtracker), "gpu_id", gpu_id, NULL);
+ } else if (!g_strcmp0 (*key, CONFIG_GROUP_TRACKER_LL_CONFIG_FILE)) {
+ char* ll_config_file = get_absolute_file_path (TRACKER_CONFIG_FILE,
+ g_key_file_get_string (key_file,
+ CONFIG_GROUP_TRACKER,
+ CONFIG_GROUP_TRACKER_LL_CONFIG_FILE, &error));
+ CHECK_ERROR (error);
+ g_object_set (G_OBJECT (nvtracker), "ll-config-file", ll_config_file, NULL);
+ g_free(ll_config_file);
+ } else if (!g_strcmp0 (*key, CONFIG_GROUP_TRACKER_LL_LIB_FILE)) {
+ char* ll_lib_file = get_absolute_file_path (TRACKER_CONFIG_FILE,
+ g_key_file_get_string (key_file,
+ CONFIG_GROUP_TRACKER,
+ CONFIG_GROUP_TRACKER_LL_LIB_FILE, &error));
+ CHECK_ERROR (error);
+ g_object_set (G_OBJECT (nvtracker), "ll-lib-file", ll_lib_file, NULL);
+ g_free(ll_lib_file);
+ } else {
+ g_printerr ("Unknown key '%s' for group [%s]", *key,
+ CONFIG_GROUP_TRACKER);
+ }
+ }
+
+ ret = TRUE;
+done:
+ if (error) {
+ g_error_free (error);
+ }
+ if (keys) {
+ g_strfreev (keys);
+ }
+ if (!ret) {
+ g_printerr ("%s failed", __func__);
+ }
+ return ret;
+}
+
int
main (int argc, char *argv[])
{
@@ -354,6 +485,14 @@ main (int argc, char *argv[])
return -1;
}
+ /* We need to have a tracker to track the identified objects */
+ GstElement *nvtracker = gst_element_factory_make ("nvtracker", "tracker");
+ /* Set necessary properties of the tracker element. */
+ if (!set_tracker_properties(nvtracker)) {
+ g_printerr ("Failed to set tracker properties. Exiting.\n");
+ return -1;
+ }
+
/* Use convertor to convert from NV12 to RGBA as required by nvdsosd */
nvvidconv2 =
gst_element_factory_make ("nvvideoconvert", "nvvideo-converter2");
@@ -445,7 +584,7 @@ main (int argc, char *argv[])
/* Set up the pipeline */
/* we add all elements into the pipeline */
gst_bin_add_many (GST_BIN (pipeline),
- data.app_source, nvvidconv1, caps_filter, streammux, pgie,
+ data.app_source, nvvidconv1, caps_filter, streammux, pgie, nvtracker,
nvvidconv2, nvosd, tee, sink, appsink, NULL);
GstPad *sinkpad, *srcpad;
@@ -478,12 +617,12 @@ main (int argc, char *argv[])
if (!gst_element_link_many (data.app_source, nvvidconv1, caps_filter, NULL) ||
!gst_element_link_many (nvosd, sink, NULL) ||
- !gst_element_link_many (streammux, pgie, nvvidconv2, tee, NULL)) {
+ !gst_element_link_many (streammux, pgie, nvtracker, nvvidconv2, tee, NULL)) {
g_printerr ("Elements could not be linked: Exiting.\n");
return -1;
}
-/* Manually link the Tee, which has "Request" pads.
+ /* Manually link the Tee, which has "Request" pads.
* This tee, in case of multistream usecase, will come before tiler element. */
tee_source_pad1 = gst_element_request_pad_simple (tee, "src_0");
osd_sink_pad = gst_element_get_static_pad (nvosd, "sink");
diff --git a/sources/apps/sample_apps/deepstream-appsrc-test/dstest2_tracker_config.txt b/sources/apps/sample_apps/deepstream-appsrc-test/dstest2_tracker_config.txt
new file mode 100644
index 0000000..7a315a5
--- /dev/null
+++ b/sources/apps/sample_apps/deepstream-appsrc-test/dstest2_tracker_config.txt
@@ -0,0 +1,29 @@
+################################################################################
+# SPDX-FileCopyrightText: Copyright (c) 2018-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+# SPDX-License-Identifier: LicenseRef-NvidiaProprietary
+#
+# NVIDIA CORPORATION, its affiliates and licensors retain all intellectual
+# property and proprietary rights in and to this material, related
+# documentation and any modifications thereto. Any use, reproduction,
+# disclosure or distribution of this material and related documentation
+# without an express license agreement from NVIDIA CORPORATION or
+# its affiliates is strictly prohibited.
+################################################################################
+
+# Mandatory properties for the tracker:
+# tracker-width, tracker-height: needs to be multiple of 32 for NvDCF and NvDeepSORT
+# gpu-id
+# ll-lib-file: path to low-level tracker lib
+# ll-config-file: required to set different tracker types
+#
+[tracker]
+tracker-width=960
+tracker-height=544
+gpu-id=0
+ll-lib-file=/opt/nvidia/deepstream/deepstream/lib/libnvds_nvmultiobjecttracker.so
+# ll-config-file required to set different tracker types
+# ll-config-file=../../../../samples/configs/deepstream-app/config_tracker_IOU.yml
+# ll-config-file=../../../../samples/configs/deepstream-app/config_tracker_NvSORT.yml
+ll-config-file=../../../../samples/configs/deepstream-app/config_tracker_NvDCF_perf.yml
+# ll-config-file=../../../../samples/configs/deepstream-app/config_tracker_NvDCF_accuracy.yml
+# ll-config-file=../../../../samples/configs/deepstream-app/config_tracker_NvDeepSORT.yml
diff --git a/sources/apps/sample_apps/deepstream-appsrc-test/dstest_appsrc_config.txt b/sources/apps/sample_apps/deepstream-appsrc-test/dstest_appsrc_config.txt
index 2f73b0a..0c811bb 100644
--- a/sources/apps/sample_apps/deepstream-appsrc-test/dstest_appsrc_config.txt
+++ b/sources/apps/sample_apps/deepstream-appsrc-test/dstest_appsrc_config.txt
@@ -57,7 +57,7 @@ int8-calib-file=../../../../samples/models/Primary_Detector/cal_trt.bin
batch-size=1
network-mode=1
num-detected-classes=4
-interval=0
+interval=5
gie-unique-id=1
#scaling-filter=0
#scaling-compute-hw=0
There is a known issue here, nvtracker
with appsink
will get stuck in the last frame, this problem will be fixed in the next version