How to get the latency from deepstream python apps

Is there any inbuilt utility to get latency measurement in deepstream python apps?

************BATCH-NUM = 279**************
Comp name = nvosd0 in_system_timestamp = 1638786455453.705078 out_system_timestamp = 1638786455458.547119               component latency= 4.842041
Comp name = osd_conv in_system_timestamp = 1638786455452.995117 out_system_timestamp = 1638786455453.216064               component latency= 0.220947
Comp name = tiled_display_tiler in_system_timestamp = 1638786455350.739990 out_system_timestamp = 1638786455351.545898               component latency= 0.805908
Comp name = tracking_tracker in_system_timestamp = 1638786455224.802002 out_system_timestamp = 1638786455226.194092               component latency= 1.392090
Comp name = primary_gie in_system_timestamp = 1638786455221.758057 out_system_timestamp = 1638786455224.792969               component latency= 3.034912
Comp name = nvstreammux-src_bin_muxer source_id = 0 pad_index = 0 frame_num = 279               in_system_timestamp = 1638786455193.233887 out_system_timestamp = 1638786455221.726074               component_latency = 28.492188
Comp name = nvv4l2decoder0 in_system_timestamp = 1638786455020.454102 out_system_timestamp = 1638786455193.197998               component latency= 172.743896
Source id = 0 Frame_num = 279 Frame latency = 1638786455551.444092 (ms) 

You may need to generate python binding for nvds_measure_buffer_latency() first according to the instruction deepstream_python_apps/bindings at master · NVIDIA-AI-IOT/deepstream_python_apps · GitHub

And then you can use this API to enable latency function as DeepStream SDK FAQ - #12 by bcao

And what about : [Link]
(NvDsMetaType — Deepstream Python ##DeepStream_VERSION## documentation)

How we can access NVDS_LATENCY_MEASUREMENT_META : metadata type to be set for latency measurement ?

The enviroment setting and a probe function with getting user meta of NVDS_LATENCY_MEASUREMENT_META type are still needed.

Sorry I couldn’t get this…

in this case we don’t need to write the python bindings for nvds_measure_buffer_latency() api?

we can get the latency info in the probe by accessing NVDS_LATENCY_MEASUREMENT_META?
Because it’s part of NvDsMeta, so in the PGIE probe can we get this info in l_frame?

Yes. You can access NVDS_LATENCY_MEASUREMENT_META type user meta to get latency info if you don’t want to use nvds_measure_buffer_latency() API. The proper place of the probe function has been shown in DeepStream SDK FAQ - Intelligent Video Analytics / DeepStream SDK - NVIDIA Developer Forums

You can access NVDS_LATENCY_MEASUREMENT_META type user meta to get latency info if you don’t want to use nvds_measure_buffer_latency() API.

num_sources_in_batch = nvds_measure_buffer_latency(buf, latency_info);
again this can’t be replicated to python right?

No, there is no binding for it now.

Is there some sample reference to start with writing bindings from deepstream C api to python api?

[https://forums.developer.nvidia.com/t/deepstream-sdk-faq/80236/12?u=imsk](DeepStream SDK FAQ - #12 by bcao)

@Fiona.Chen
In this one a separate probe latency_measurement_buf_prob() is created.

What I am asking is can’t we get NVDS_LATENCY_MEASUREMENT_META from usermeta from gst_buffer in any of the probe function like other batchmeta, framemeta etc?
Without using nvds_measure_buffer_latency() api??

because NVDS_LATENCY_MEASUREMENT_META is already there in NvDsMetaType.

I think I have shared the sample. deepstream_python_apps/bindings at master · NVIDIA-AI-IOT/deepstream_python_apps (github.com)

Yes. You can get NVDS_LATENCY_MEASUREMENT_META user meta from NvDsMetaType. But it should be in the probe function. This special meta will collect the latency information for most deepstream component, the information is time related, so it is meaningful after the data pass through the whole pipeline. If you collect the latency in different place and different time, some component may be missed. Please following the sample.

I saw below mentioned code in /deepstream-5.1/sources/apps/sample_apps/deepstream-nvdsanalytics-test/deepstream_app_main.c.

Here I haven’t seen nvds_measure_buffer_latency() API called anywhere.

  
NvDsFrameLatencyInfo *latency_info = NULL;
NvDsDisplayMeta *display_meta =
  nvds_acquire_display_meta_from_pool (batch_meta);


if(nvds_enable_latency_measurement) {
    g_mutex_lock (&appCtx->latency_lock);
    latency_info = &appCtx->latency_info[index];
    display_meta->num_labels++;
    display_meta->text_params[1].display_text = g_strdup_printf ("Latency: %lf",
        latency_info->latency);
    g_mutex_unlock (&appCtx->latency_lock);

You can get NVDS_LATENCY_MEASUREMENT_META user meta from NvDsMetaType. But it should be in the probe function. This special meta will collect the latency information for most deepstream component

@Fiona.Chen
@mchi
can you share the structure for the same (to access NVDS_LATENCY_MEASUREMENT_META from user meta)?

We have shown you the recommanded interface is nvds_measure_buffer_latency() and the c/c++ sample DeepStream SDK FAQ - Intelligent Video Analytics / DeepStream SDK - NVIDIA Developer Forums

Please read the Makefile.ds carefully. This app should be build with the following source codes:

SRCS:= $(wildcard ../../apps-common/src/*.c)
SRCS+= $(wildcard ../deepstream-app/deepstream_app.c ../deepstream-app/deepstream_app_config_parser.c)

Have you searched all the codes?

How much do you know about c/c++ programming? I think it is not a deepstream issue. We have provided enough document and samples. Please study the code and sample carefully.

Please study the code and sample carefully.
Yeah, I am going through the documentation. C/C++ : beginner stage.

Thanks for the help!!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.