• Community
  • OAK-SoM sync image timestamp to external host clock

Hi,
Does the OAK-SoM have a time synchronization protocol to synchronize time to the host processor, for example the PPS (pulse per second) seen in GPS devices? I am looking into using the OAK-SoM (with stereo cameras) connected to a Linux host system that will host other type of sensors. The host system will be timestamping data from the other sensor and acquiring the timestamped OAK-SoM data. There is a need to correlate the time of the two datasets from the host and OAK-SoM systems.

From the OAK-SoM datasheet, I see it outputs the 24 MHz camera clock reference. This is a start as it can drive a clock on the host system side, but I don't see any other signals to help correlate to system clocks.

Thanks,
Mike E

  • erik replied to this.

    Hi meaton ,
    I believe OAK cameras sync their internal clock to hosts std::chrono::steady_clock (also accessible on Python via dai.Clock.now()). So you could also compare eg. frame timestamp (imgFrame.getTimestamp()) with this host timestamp to calculate time-to-host (from camera) delay as described here. Thoughts?
    Thanks, Erik

      Thanks for the quick reply! The information you provided is very useful. I also realized I can route the COM_AUX_IO2 (Frame Sync Input) output signal to the host system to timestamp events on a common clock.

      a year later

      erik I have a follow up question on this.

      1. With the recent v2.23 release, it is said that `Timesync - improved synchronization with tweaks to XLink`. May I know how should we quantify the improvement? What is the jitter / error of the synchronisation between oak device time and host steady_clock time? 5ms? 1ms? sub-1ms?
      2. Again on the idea of PPS. I am planning to add a feature for oak device (SoM-Pro) to receive PPS signal through GPIO, and send out a depthai Message when it is being received. I understand the interrupt can be configured in script, like here Script — DepthAI documentation | Luxonis.
        However, how should i encode the PPS signal GPIO interrupt into a message, that contain timestamps (device time), and let sync automatically happen at host side? Something like a empty ImgFrame message?
      • erik replied to this.

        erik Gotcha. For Buffer, from what I read, I will need to encode the timestamp into string / json, and decode it at the host. Am I right?

          erik That would be an issue though. The encoded timestamp in the script would be oak device time. No auto conversion from device time to host time would happen. How to make the conversion work? Would ImgFrame message from script output, get conversion automatically? Perhaps that's the only viable way?

          • erik replied to this.

            Hi Huimin ,
            Inside Script node, you can either get Device or Host clock:

            script.setScript("""
            import time
            while True:
                time.sleep(1)
                node.warn(f"Device clock: {Clock.now()}, Host-synced clock: {Clock.nowHost()}, Offset to host clock: {Clock.offsetToHost()}")
            """)