• DepthAI-v3
  • How to sync frame's timestamp with host clock, converting it to host's epoch?

I have two questions:

  1. How to sync camera's clock with host clock?
  2. I have a frame timestamp, which is a delta since camera's last boot, how do I convert it to camera's epoch time/host's epoch time?

My camera is OAKD POE with 3 lens (rgb, mono left, mono right).

Thanks a lot.

Hi,
Yes, OAK-D's clock is already synced with the host. You can use getTimestampDevice() to get the frame timestamp in a format that is already synchronized with the host time (and then convert it to epoch time if wanted).

For more, check this .

Thanks for your reply. However my question is still unsolved.
I got this from getTimestampDevice() from a frame,
rgb frame #: 66, ts: 0:00:11.117680

I want the ts value to be a value in clock of the host. That value of 0:00:11.117680 appears to be a delta not an actual clock. Am I doing wrong?

Thanks.

Hi,

you are correct getTimestampDevice() is a relative time since the camera's last boot. To convert it to host clock time (epoch time):

  1. Record the host system time (epoch format) when the camera starts.
  2. For each frame, add the frame's relative timestamp to this host start time.

This aligns frame timestamps with the host clock.

Thanks for your reply. I still have the question. Especially your #1, exactly. "Record the host system time (epoch format) when the camera starts.".

What is camera starts? is it the device(pipeline) statement? Should I run the time.time() right after device(pipeline)? Is the device(pipeline) meaning "camera starts"?

I am using depthai python.

Thanks.

    jkchen46033
    getTimestampDevice is time from when device boots up and is ready to run. dai.Device() is a constructor that initializes the device - when initialized, an internal steady clock starts running. You can access it using time.monotonic().
    If you want to convert the device timestamp to host timestamp (dai.clock.now()) you can use getTimestamp() which is the timedelta from your PC boot.

    Thanks
    Jaka