I 've tried with this code and I reached a precision of about 15-20milliseconds between images on the same raspberryPi5 (server-client setup of the cameras), using video mode and half resolution. If I use full res at 5 fps in video mode the difference is 120-140ms. In still mode is worse. Less resolution or higher framerate in video mode doesn't reduce the ms.
I still have to try to connect another pi5 with two client cameras and see what happens in general, but in the meanwhile my question is why we're so far from the "several tens of microseconds" we can in theory reach? I mean I don't need that extremely precision, my target would be 1-2ms. I didn't use the loop you suggested because I'm not sure it'll work in a multi-Pi setup, but only locally on each Pi, maybe generating more offset between them.
Thanks,
I still have to try to connect another pi5 with two client cameras and see what happens in general, but in the meanwhile my question is why we're so far from the "several tens of microseconds" we can in theory reach? I mean I don't need that extremely precision, my target would be 1-2ms. I didn't use the loop you suggested because I'm not sure it'll work in a multi-Pi setup, but only locally on each Pi, maybe generating more offset between them.
Thanks,
Code:
from picamera2 import Picamera2from libcamera import controlsfrom PIL import Imageimport timeimport osFPS = 10SHUTTER_TIME_US = 10000ANALOG_GAIN = 5.0AWB_MODE = controls.AwbModeEnum.Tungstendesktop_path = os.path.expanduser("~/Desktop")cam0 = Picamera2(0) # Servercam1 = Picamera2(1) # Clientcontrols_cam0 = { "FrameRate": FPS, "SyncMode": controls.rpi.SyncModeEnum.Server, "ExposureTime": SHUTTER_TIME_US, "AnalogueGain": ANALOG_GAIN, "AwbMode": AWB_MODE}controls_cam1 = { "FrameRate": FPS, "SyncMode": controls.rpi.SyncModeEnum.Client, "ExposureTime": SHUTTER_TIME_US, "AnalogueGain": ANALOG_GAIN, "AwbMode": AWB_MODE}main_res = (2028, 1520) config0 = cam0.create_video_configuration(controls=controls_cam0, main={"size": main_res})config1 = cam1.create_video_configuration(controls=controls_cam1, main={"size": main_res})cam0.configure(config0)cam1.configure(config1)cam1.start()time.sleep(0.2)cam0.start()time.sleep(2) input("Press ENTER to shoot...")req0 = cam0.capture_request()req1 = cam1.capture_request()img0 = Image.fromarray(req0.make_array("main")).convert("RGB")img1 = Image.fromarray(req1.make_array("main")).convert("RGB")path0 = os.path.join(desktop_path, "cam0.jpg")path1 = os.path.join(desktop_path, "cam1.jpg")img0.save(path0)img1.save(path1)ts0 = req0.get_metadata()["SensorTimestamp"] / 1_000ts1 = req1.get_metadata()["SensorTimestamp"] / 1_000delta = abs(ts0 - ts1)req0.release()req1.release()print(f"Images saved in:\n - {path0}\n - {path1}")print(f"Delta timestamp: {delta:.3f} ms")Statistics: Posted by fede7890 — Tue May 20, 2025 9:17 pm