Please provide complete information as applicable to your setup.
• Hardware Platform (Jetson / GPU) Jetson Orin AGX • DeepStream Version 6.2 • JetPack Version (valid for Jetson only) 5.1.1 • TensorRT Version • NVIDIA GPU Driver Version (valid for GPU only) • Issue Type( questions, new requirements, bugs) question • How to reproduce the issue ? (This is for bugs. Including which sample app is using, the configuration files content, the command line used and other details for reproducing) • Requirement details( This is for new requirement. Including the module name-for which plugin or for which sample application, the function description)
I want to get the latency of a (or multiple) component(s) of my pipeline. My code is in python, using the python bindings.
I understand that in C++, we would use the function nvds_measure_buffer_latency(), but since there is no binding in python for it, I am trying to get NVDS_LATENCY_MEASUREMENT_META user meta from NvDsMetaType, as explained by Fiona.Chen here : How to get the latency from deepstream python apps - #13 by Fiona.Chen
def latency_measurement_probe(self,pad, info, u_data):
buffer = info.get_buffer()
if not buffer:
self.logger.info('Unable to get GstBuffer')
return
batch_meta = pyds.gst_buffer_get_nvds_batch_meta(hash(buffer))
l_user = batch_meta.batch_user_meta_list
while l_user is not None:
try:
user_meta=pyds.NvDsUserMeta.cast(l_user.data)
except StopIteration:
break
if(user_meta and user_meta.base_meta.meta_type == pyds.NvDsMetaType.NVDS_LATENCY_MEASUREMENT_META):
try:
latency_meta = pyds.NvDsFrameLatencyInfo.cast(user_meta.user_meta_data)
#or latency_meta = pyds.NvDsMetaCompLatency.cast(user_meta.user_meta_data)
except StopIteration:
break
latency_ms = latency_meta.latency
print("Latency :",latency_ms,"ms")
return Gst.PadProbeReturn.OK
But neither NvDsFrameLatencyInfo nor NvDsMetaCompLatency exist in the binding. So the question is how can I access latency informations that are in the user metadata in python ?
Thank you for the answer. I followed the guide to create binding for the NvDsFrameLatencyInfo struct, but when i look at the latency I get an absurd value (1.145327…93e+243). Am I missing something with my probe code ?
I see, but currently my variable latency_meta is non iterable, maybe i’m casting it wrong ?
here is my binding code (I also added binding for the nvds_measure_buffer_latency function but didn’t get more success with it, I just don’t get how to call the function in python)
void bindnvds_latency_meta(py::module &m) {
py::class_<NvDsFrameLatencyInfo>(m, "NvDsFrameLatencyInfo",
pydsdoc::nvds_latency_metadoc::NvDsFrameLatencyInfoDoc::descr)
.def(py::init<>()) // Constructor wrapper, empty for struct
.def_readwrite("source_id", &NvDsFrameLatencyInfo::source_id)
.def_readwrite("frame_num", &NvDsFrameLatencyInfo::frame_num)
.def_readwrite("comp_in_timestamp", &NvDsFrameLatencyInfo::comp_in_timestamp)
.def_readwrite("latency", &NvDsFrameLatencyInfo::latency)
.def("cast",
[](void *data) { // Function definition
return (NvDsFrameLatencyInfo *) data; // Cast void* to NvDsLatencyInfo*
},
py::return_value_policy::reference, // Ownership of return object must remain with C++
pydsdoc::nvds_latency_metadoc::NvDsFrameLatencyInfoDoc::cast); // Docstring
m.def("nvds_measure_buffer_latency",
&nvds_measure_buffer_latency,
"buf"_a,
"latency_info"_a,
py::return_value_policy::reference,
pydsdoc::methodsDoc::nvds_measure_buffer_latency);
} // Define the bindings function declared in the header file
Hi there, I came across this thread when I was looking for a method to get latency info for the pipeline in python, I wanted to ask is there any update on the availability of the feature anytime soon? @yuweiw
There is no update from you for a period, assuming this is not an issue anymore. Hence we are closing this topic. If need further support, please open a new one. Thanks