Hello,
I downloaded the source code of nvarguscamerasrc and I would like to get the timestamp of each frame and add it as a buffer metadata to the GstBuffer.
I understand that I need to use getSensorTimestamp() but I don’t really know where to start and where I should use this function.
Thanks for the help,
I believe that this snippet should be used in the bool StreamConsumer::threadExecute(GstNvArgusCameraSrc *src) function. Is that right ?
Thanks for the help,
When I try to get the ICaptureMetadata interface it fails :
Error generated. gstnvarguscamerasrc.cpp, threadExecute:631 Failed to get ICaptureMetadata interface.
Error generated. gstnvarguscamerasrc.cpp, threadFunction:247 (propagating)
And here’s the snippet of code I am using right now :
(It comes from the yuvJpeg sample)
// --------
// Print out some capture metadata from the frame.
IArgusCaptureMetadata *iArgusCaptureMetadata = interface_cast<IArgusCaptureMetadata>(frame);
if (!iArgusCaptureMetadata)
ORIGINATE_ERROR("Failed to get IArgusCaptureMetadata interface.");
CaptureMetadata *metadata = iArgusCaptureMetadata->getMetadata();
ICaptureMetadata *iMetadata = interface_cast<ICaptureMetadata>(metadata);
if (!iMetadata)
ORIGINATE_ERROR("Failed to get ICaptureMetadata interface.");
// --------
iCaptureMetadata->getSensorTimestamp() return the kernel timestamp.
TSC it’s the HW capture timestamp, VI drivers to capture frame and store the timestamp with TSC.
please refer to Topic 159220 for the explanation.
thanks
Thanks, @JerryChang for the answer, but I think I still need some help,
I use the following code to get the sensor timestamp :
// Print out some capture metadata from the frame.
IArgusCaptureMetadata *iArgusCaptureMetadata = interface_cast<IArgusCaptureMetadata>(frame);
if (!iArgusCaptureMetadata) {
ORIGINATE_ERROR("Failed to get IArgusCaptureMetadata interface.");
}
CaptureMetadata *metadata = iArgusCaptureMetadata->getMetadata();
ICaptureMetadata *iMetadata = interface_cast<ICaptureMetadata>(metadata);
if (!iMetadata) {
ORIGINATE_ERROR("Failed to get ICaptureMetadata interface.");
}
unsigned long sensorTimestamp = static_cast<unsigned long>(iMetadata->getSensorTimestamp());
CONSUMER_PRINT("\tsensorTimestamp : %lu\n",
sensorTimestamp
);
And it gives me this value : 5502998961000 (in ns)
Which according to the documentation is :
Returns the kernel (SOF) timestamp for the sensor (in nanoseconds).
This is the time that the first data from this capture arrives from the sensor.
I don’t understand what cycle_ns(TSC), or offset_ns has to do with any of that. Could you give a detailed explanation ? Because the link you sent doesn’t explain that.
please convert the units from nanosecond to seconds, use the same unit as kernel. for example, please check the timestamp in $ dmesg.
TSC is hardware timestamp, that’s captured by RCE. don’t bother that if you’re using Argus APIs.