# NvdsTracker API sample

**URL:** <https://forums.developer.nvidia.com/t/nvdstracker-api-sample/79757>\
**Category:** DeepStream SDK\
**Created:** [August 12, 2019, 9:36am UTC](https://forums.developer.nvidia.com/t/nvdstracker-api-sample/79757 "2019-08-12T09:36:43Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![sathiez](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@sathiez](https://forums.developer.nvidia.com/u/sathiez)\
**Post date:** [August 12, 2019, 9:36am UTC](https://forums.developer.nvidia.com/t/nvdstracker-api-sample/79757/1 "2019-08-12T09:36:43Z")

</div>

Hi,  
Is there any sample which explains using tracker in c++ prog. [url][NVIDIA DeepStream SDK API Reference: Main Page](https://docs.nvidia.com/metropolis/deepstream/4.0/dev-guide/DeepStream_Development_Guide/baggage/group__NvDsTrackerApi.html%5B/url%5D) in deepstream 4.0.

---

<div class="post-metadata">

**Author:** ![ChrisDing](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/chrisding/32/14043_2.png) [@ChrisDing](https://forums.developer.nvidia.com/u/ChrisDing)\
**Post date:** [August 13, 2019, 3:02am UTC](https://forums.developer.nvidia.com/t/nvdstracker-api-sample/79757/2 "2019-08-13T03:02:10Z")

</div>

We don’t have tracker api sample now.

---

<div class="post-metadata">

**Author:** ![sathiez](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@sathiez](https://forums.developer.nvidia.com/u/sathiez)\
**Post date:** [August 13, 2019, 1:41pm UTC](https://forums.developer.nvidia.com/t/nvdstracker-api-sample/79757/3 "2019-08-13T13:41:17Z")

</div>

To get NvDsBatchMeta we have gst\_buffer\_get\_nvds\_batch\_meta() function, similarly is there any function to get NvMOTTrackedObj details in prog? or else how can we get it?

---

<div class="post-metadata">

**Author:** ![ChrisDing](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/chrisding/32/14043_2.png) [@ChrisDing](https://forums.developer.nvidia.com/u/ChrisDing)\
**Post date:** [August 14, 2019, 6:40am UTC](https://forums.developer.nvidia.com/t/nvdstracker-api-sample/79757/4 "2019-08-14T06:40:17Z")

</div>

I think it can’t get NvMOTTrackerObj directly. The tracker result is in metadata.  
You can refer to [url][https://docs.nvidia.com/metropolis/deepstream/4.0/DeepStream\_Plugin\_Manual.pdf#[{“num”%3A68%2C"gen"%3A0}%2C{“name”%3A"XYZ"}%2C106%2C506%2C0][/url]](https://docs.nvidia.com/metropolis/deepstream/4.0/DeepStream_Plugin_Manual.pdf#%5B%7B%22num%22%3A68%2C%22gen%22%3A0%7D%2C%7B%22name%22%3A%22XYZ%22%7D%2C106%2C506%2C0%5D%5B/url%5D)  
2.2 gst-nvtracker  
2.2.6 NvDCF Low-Level Tracker

---

<div class="post-metadata">

**Author:** ![sathiez](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@sathiez](https://forums.developer.nvidia.com/u/sathiez)\
**Post date:** [August 16, 2019, 9:16am UTC](https://forums.developer.nvidia.com/t/nvdstracker-api-sample/79757/5 "2019-08-16T09:16:57Z")

</div>

I went through the docs but I couldn’t find any answer. How can I get object tracker meta data? can you help me?

---

<div class="post-metadata">

**Author:** ![sathiez](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@sathiez](https://forums.developer.nvidia.com/u/sathiez)\
**Post date:** [August 16, 2019, 2:13pm UTC](https://forums.developer.nvidia.com/t/nvdstracker-api-sample/79757/6 "2019-08-16T14:13:18Z")

</div>

Hi,

In section 2.2.1 (Tracker) ,

Output  
● Gst Buffer (provided as an input)  
● NvDsBatchMeta (Updated by Gst-nvtrackerwith tracked object coordinates  
and object IDs)

when I print object-id, it remains the same for all objects.

```auto
obj_id = 18446744073709551615
rect = 48	255	387	774	
class_id = 2
unique_id = 2
obj_id = 18446744073709551615
rect = 1416	216	252	756	
class_id = 2
unique_id = 2
obj_id = 18446744073709551615
rect = 1527	178	387	897

```

My config file,

```auto
[tracker]
enable=1
tracker-width=640
tracker-height=368
ll-lib-file=/opt/nvidia/deepstream/deepstream-4.0/lib/libnvds_nvdcf.so
gpu-id=0
enable-batch-process=1
ll-config-file=tracker_config.yml

```

tracker\_config.yml,

```auto
%YAML:1.0

NvDCF:
  useBufferedOutput: 0

  maxTargetsPerStream: 100 # Max number of targets to track per stream. Recommended to set >10. Note: this value should account for the targets being tracked in shadow mode as well. Max value depends on the GPU memory capacity

  filterLr: 0.11 # learning rate for DCF filter in exponential moving average. Valid Range: [0.0, 1.0]
  gaussianSigma: 0.75 # Standard deviation for Gaussian for desired response when creating DCF filter
  minDetectorConfidence: 0.0 # If the confidence of a detector bbox is lower than this, then it won't be considered for tracking
  minTrackerConfidence: 0.6 # If the confidence of an object tracker is lower than this on the fly, then it will be tracked in shadow mode. Valid Range: [0.0, 1.0]
  featureImgSizeLevel: 1 # Size of a feature image. Valid range: {1, 2, 3, 4, 5}, from the smallest to the largest
  SearchRegionPaddingScale: 3 # Search region size. Determines how large the search region should be scaled from the target bbox. Valid range: {1, 2, 3}, from the smallest to the largest
  maxShadowTrackingAge: 9 # Max length of shadow tracking (the shadow tracking age is incremented when (1) there's detector input yet no match or (2) tracker confidence is lower than minTrackerConfidence). Once reached, the tracker will be terminated.
  probationAge: 12 # Once the tracker age (incremented at every frame) reaches this, the tracker is considered to be valid
  earlyTerminationAge: 2 # Early termination age (in terms of shadow tracking age) during the probation period
  minVisibiilty4Tracking: 0.1 # If the visibility of the bbox of a tracker gets lower, then it will be terminated

```

How to get correct object id’s?

---

<div class="post-metadata">

**Author:** ![sathiez](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@sathiez](https://forums.developer.nvidia.com/u/sathiez)\
**Post date:** [August 20, 2019, 2:31pm UTC](https://forums.developer.nvidia.com/t/nvdstracker-api-sample/79757/7 "2019-08-20T14:31:47Z")

</div>

Hi,

any update on this?

---

<div class="post-metadata">

**Author:** ![ChrisDing](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/chrisding/32/14043_2.png) [@ChrisDing](https://forums.developer.nvidia.com/u/ChrisDing)\
**Post date:** [August 21, 2019, 1:30am UTC](https://forums.developer.nvidia.com/t/nvdstracker-api-sample/79757/8 "2019-08-21T01:30:08Z")

</div>

How do you get your object-id ?

---

<div class="post-metadata">

**Author:** ![ChrisDing](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/chrisding/32/14043_2.png) [@ChrisDing](https://forums.developer.nvidia.com/u/ChrisDing)\
**Post date:** [August 21, 2019, 1:59am UTC](https://forums.developer.nvidia.com/t/nvdstracker-api-sample/79757/9 "2019-08-21T01:59:33Z")

</div>

Can you check DeepStream\_Plugin\_Manual.pdf - 2.2.4 Custom Low-Level Library

---

<div class="post-metadata">

**Author:** ![sathiez](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@sathiez](https://forums.developer.nvidia.com/u/sathiez)\
**Post date:** [August 21, 2019, 3:36am UTC](https://forums.developer.nvidia.com/t/nvdstracker-api-sample/79757/10 "2019-08-21T03:36:11Z")

</div>

> [@ChrisDing](#):
>
> How do you get your object-id ?

```auto
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);
			 const std::type_info& r2 = typeid(obj_meta);
		
			std::cout<<"obj_id = "<<<b>obj_meta->object_id</b><<std::endl;
}

```

---

<div class="post-metadata">

**Author:** ![sumityadav](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@sumityadav](https://forums.developer.nvidia.com/u/sumityadav)\
**Post date:** [August 25, 2019, 5:53am UTC](https://forums.developer.nvidia.com/t/nvdstracker-api-sample/79757/11 "2019-08-25T05:53:41Z")

</div>

I was facing the same issue with object-id, the mistake i made was i added the probe in source pad of nvinfer element. But object-id is set by nvtracker element so i should add the probe in source pad of nvtracker or other elements that are downstream to nvtracker.  
you can resolve it by changing this code

```auto
infer_src_pad = gst_element_get_static_pad (pgie, "src");
  if (!infer_src_pad)
    g_print ("Unable to get source pad\n");
  else
    gst_pad_add_probe (infer_src_pad, GST_PAD_PROBE_TYPE_BUFFER,
        nvinfer_src_pad_buffer_probe, NULL, NULL);

```

to this code.

```auto
infer_src_pad = gst_element_get_static_pad (nvtracker, "src");
  if (!infer_src_pad)
    g_print ("Unable to get source pad\n");
  else
    gst_pad_add_probe (infer_src_pad, GST_PAD_PROBE_TYPE_BUFFER,
        nvinfer_src_pad_buffer_probe, NULL, NULL);

```

> [@](#):
>
> > [@ChrisDing](#):
> >
> > How do you get your object-id ?
> 
> ```auto
> 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);
> const std::type_info& r2 = typeid(obj_meta);
> 		
> std::cout<<"obj_id = "<<<b>obj_meta->object_id</b><<std::endl;
> }
> 
> ```

---

<div class="post-metadata">

**Author:** ![sumityadav](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@sumityadav](https://forums.developer.nvidia.com/u/sumityadav)\
**Post date:** [August 25, 2019, 6:25am UTC](https://forums.developer.nvidia.com/t/nvdstracker-api-sample/79757/12 "2019-08-25T06:25:50Z")

</div>

Is there any option to detect all objects but track only Persons in deepstream-app (means tracking only particular gie class-id’s)?

---

<div class="post-metadata">

**Author:** ![bcao](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/bcao/32/14043_2.png) [@bcao](https://forums.developer.nvidia.com/u/bcao)\
**Post date:** [September 16, 2019, 5:48am UTC](https://forums.developer.nvidia.com/t/nvdstracker-api-sample/79757/13 "2019-09-16T05:48:26Z")

</div>

Hey sumityadav,  
May I know what is your use case and the benefit if only tracking a special object?

---

<div class="post-metadata">

**Author:** ![yelei](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/yelei/32/23955_2.png) [@yelei](https://forums.developer.nvidia.com/u/yelei)\
**Post date:** [July 15, 2020, 8:07pm UTC](https://forums.developer.nvidia.com/t/nvdstracker-api-sample/79757/14 "2020-07-15T20:07:00Z")

</div>

Thank you, @sumityadav! It worked also on Python DeepStream 5.0 API.  
No problems were found when using NvDCF Tracker, but when I changed to IOU (and KLT, I guess), I was getting the same result as you in obj\_id.
