On a Jetson AGX Xavier with a Leopard Imaging IMX577 MIPI camera, I am running the following script:
$ v4l2-ctl -V --set-ctrl sensor_mode=3 --set-ctrl bypass_mode=0,preferred_stride=0 --set-fmt-video=width=1920,height=1080,pixelformat=RG10 --stream-mmap --stream-count=10 -d /dev/video0 --verbose; python3 -c 'import time; print(time.monotonic_ns()/1.0e9);'
The output is the following:
VIDIOC_QUERYCAP: ok
VIDIOC_S_EXT_CTRLS: ok
VIDIOC_G_FMT: ok
VIDIOC_S_FMT: ok
Format Video Capture:
Width/Height : 1920/1080
Pixel Format : 'RG10' (10-bit Bayer RGRG/GBGB)
Field : None
Bytes per Line : 3840
Size Image : 4147200
Colorspace : sRGB
Transfer Function : Default (maps to sRGB)
YCbCr/HSV Encoding: Default (maps to ITU-R 601)
Quantization : Default (maps to Full Range)
Flags :
VIDIOC_G_FMT: ok
Format Video Capture:
Width/Height : 1920/1080
Pixel Format : 'RG10' (10-bit Bayer RGRG/GBGB)
Field : None
Bytes per Line : 3840
Size Image : 4147200
Colorspace : sRGB
Transfer Function : Default (maps to sRGB)
YCbCr/HSV Encoding: Default (maps to ITU-R 601)
Quantization : Default (maps to Full Range)
Flags :
VIDIOC_REQBUFS returned 0 (Success)
VIDIOC_QUERYBUF returned 0 (Success)
VIDIOC_QUERYBUF returned 0 (Success)
VIDIOC_QUERYBUF returned 0 (Success)
VIDIOC_QUERYBUF returned 0 (Success)
VIDIOC_QBUF returned 0 (Success)
VIDIOC_QBUF returned 0 (Success)
VIDIOC_QBUF returned 0 (Success)
VIDIOC_QBUF returned 0 (Success)
VIDIOC_STREAMON returned 0 (Success)
cap dqbuf: 0 seq: 0 bytesused: 4147200 ts: 8172.406825 (ts-monotonic, ts-src-eof)
cap dqbuf: 1 seq: 1 bytesused: 4147200 ts: 8172.423487 delta: 16.662 ms (ts-monotonic, ts-src-eof)
cap dqbuf: 2 seq: 2 bytesused: 4147200 ts: 8172.440149 delta: 16.662 ms (ts-monotonic, ts-src-eof)
cap dqbuf: 3 seq: 3 bytesused: 4147200 ts: 8172.456811 delta: 16.662 ms (ts-monotonic, ts-src-eof)
cap dqbuf: 0 seq: 4 bytesused: 4147200 ts: 8172.473473 delta: 16.662 ms fps: 60.02 (ts-monotonic, ts-src-eof)
cap dqbuf: 1 seq: 5 bytesused: 4147200 ts: 8172.490135 delta: 16.662 ms fps: 60.02 (ts-monotonic, ts-src-eof)
cap dqbuf: 2 seq: 6 bytesused: 4147200 ts: 8172.506798 delta: 16.663 ms fps: 60.02 (ts-monotonic, ts-src-eof)
cap dqbuf: 3 seq: 7 bytesused: 4147200 ts: 8172.523460 delta: 16.662 ms fps: 60.02 (ts-monotonic, ts-src-eof)
cap dqbuf: 0 seq: 8 bytesused: 4147200 ts: 8172.540122 delta: 16.662 ms fps: 60.02 (ts-monotonic, ts-src-eof)
cap dqbuf: 1 seq: 9 bytesused: 4147200 ts: 8172.556784 delta: 16.662 ms fps: 60.02 (ts-monotonic, ts-src-eof)
8150.812663562
The timestamp printed by Python is printed immediately after the last buffer from v4l2 is received, the delay of starting the Python interpreter and getting the time is a maximum of 100ms, probably more like 10ms.
Given this, we can see that the timestamps on the v4l2 raw driver are roughly 22 seconds in the “future” compared to the Linux CLOCK_MONOTONIC clock.
Because of this, I can only assume that the v4l2 driver samples its timestamps from a different clock tha the Linux CLOCK_MONOTONIC clock.
I need to accurately synchronize sensor measurements on my device, with image information.
All the sensor measurements are accurately timestamped with the Linux CLOCK_MONOTONIC clock.
Questions:
- What clock does the nvidia v4l2 driver use?
- How can I translate its timestamps to other clocks?