How to get the exact image capture timestamp using v4l2 driver in user space

when i use v4l2_buffer timestamp as image capture timestamp in user space ,it affected by CPU load performance.
how to get the exact image capture timestamp which were not affected by CPU load performance.
i want to get the exact image capture timestamp for sensor fusion.
thanks

JetPack release is Jetpack 4.4 [L4T 32.4.3]

Have a reference to the open source of the v4l2-ctl tools

please tell me more details

when in v4l2 framework,i get the image capture timestamp in xioctl(fd_video,VIDIOC_DQBUF,buf),as follow:

struct timeval ts;
ts.tv_sec = buf.timestamp.tv_sec;
ts.tv_usec = buf.timestamp.tv_usec;

is this timestamp the exact actual capture timestamp?

Yes, did you use mmap instead of userptr?

yes ,i use mmap
when the CPU load perfance is heavy,the gap between every frame is not uniform,in other word,time fluctuation is relatively large.is this reasonablely?and is the timestamp of dequene buffer reliable?

Could you verify below command to check if can get consistency result with CPU high loading.

v4l2-ctl --stream-mmap --stream-count=500 -d /dev/video0
Can check the timestamp by below command
v4l2-ctl --stream-mmap --stream-count=500 -d /dev/video0 --verbose
1 Like

The result seem correct to run this command, the gap between every frame is uniform with high CPU load
but in my APP, the gap between every frame is not uniform with high CPU load,it seem to lost a frame,and how to fix it or how to get the exact image capture timestamp?

Get the v4l2-ctl source to reference and implement your APP.

YEAH,my APP is based on v4l-utils/capture-example.c at 2d35de61ac90b030fe15439809b807014e9751fe · gjasny/v4l-utils · GitHub
and in my APP,also covent yuyv to rgb with GPU,display video with OpenGL.

That tell the convert and GPU process block the buffer cause the issue.
You may need to break down which stage cause the problem to fix it.