Time stamping the image

Hello,

I need to store the time that image was recived by the pipeline (in micro seconds accuracy) from camera and atach that data to image, and after detection and classifications, extract that time data in order to send comands based on the classification results and the time that imag was taken to a microcontroler. How can I do that? Thanks!

• Hardware Platform (Jetson / GPU) Jetson AGX Xavier
• DeepStream Version 5
• JetPack Version (valid for Jetson only) 4.2

Hi,
For getting timestamp of each frame, please refer to
struct NvDsFrameMeta, what is "guint64 buf_pts"? - #2 by DaneLLL
How to extract timestamp associated with every frame in video - #6 by DaneLLL

Thanks! I need to opatin the difference between current time and buf-pts after classifications are done. What is the current time flag to get the current time and differnce it from the buf-pts?

Hi,
buf_pts is generated in gstreamer framework. If you use nvarguscamerasrc plugin, you can get the timestamp while frames are being captured in kernel. The information is in

typedef struct AuxiliaryData {
  gint64 frame_num;
  gint64 timestamp;
} AuxData;

We have nvarguscamerasrc open source. You can look at the source code for more information. This may be more accurate and can be applied in your usecase.

Is there anyway to get the time that gstreamer uses to stamp buf_pts? I mean the current time on that clock at any time. I can use the current time to see the time paased between buf-pts and classifications done(current time).

Hi,
We don’t have much knowledge about how timestamps are generated in gstreamer. You may refer to online document for more detail:
Clocks and synchronization in GStreamer

And may try to disable do-timestamp property and fill in the value with your own logic. You can add prob function in source pad of nvarguscamerasrc and fill in pts.

Thanks!
Could you give me the code lines and whre to put them to disale the timestamp and filling pts for each frame from two sources with custom time (g_get_monotonic_time ())?
Also, where I can find the nvarguscamerasrc source code?
Thanks!

Hi,
Here is the pseudo code of generating buf_pts:

  GstClock *clock = NULL;
  GstClockTime current_time, base_time;

  clock = gst_element_get_clock (element);

  current_time = gst_clock_get_time (clock);
  gst_object_unref (clock);

  base_time = gst_element_get_base_time (element);

  buf_pts = current_time - base_time;

So timestamp of the frame is

current_time = base_time + buf_pts;

Please check this and see if you can implement the function based on it.

The source code of nvarguscamerasrc is in
https://developer.nvidia.com/embedded/l4t/r32_release_v5.1/r32_release_v5.1/sources/t186/public_sources.tbz2

2 Likes