OK, let's rewind back to the basics again. You've got two Pi 5s, each with 2 HQ cams attached. Is that right? Let's check, without Flask, that they are all synchronising together properly.
Let's designate one of your Pi 5s as the "server" Pi, and the other as the "client" Pi. On the server Pi, use this script exactly as given:and on the client Pi use the same script, but make camera zero a client too.
Now start the script on the client Pi first, then on the server Pi. What output do you get?
I see the following. On the server:and on the client:So the frames can come out in slightly different orders, and it's even technically possible (though very rare) that they don't all start on the same frame. But the important point is that the cameras are synchronised, and every timestamp that we expect is being produced.
Can you confirm that you get the same behaviour? Once this is known to be working, we can start to think about Flask, whether the wallclocks on the Pis are synchronised, and so on. Thanks!
Let's designate one of your Pi 5s as the "server" Pi, and the other as the "client" Pi. On the server Pi, use this script exactly as given:
Code:
from threading import Threadfrom picamera2 import Picamera2from libcamera import controlsdef run_camera(num, client_server): cam = Picamera2(num) main = {'size': (4056, 2280)} lores = {'size': (640, 480)} controls = {'FrameRate': 5, 'SyncMode': client_server} config = cam.create_video_configuration(main, lores=lores, controls=controls, buffer_count=3) cam.configure(config) cam.start() request = cam.capture_sync_request() request.release() for _ in range(5): md = cam.capture_metadata() wallclock = md['FrameWallClock'] wallclock = int(wallclock / 10000) / 100 print(f"{num}: {wallclock}")thread0 = Thread(target=run_camera, args=(0, controls.rpi.SyncModeEnum.Server))thread1 = Thread(target=run_camera, args=(1, controls.rpi.SyncModeEnum.Client))thread1.start()thread0.start()thread0.join()thread1.join()Now start the script on the client Pi first, then on the server Pi. What output do you get?
I see the following. On the server:
Code:
1: 1750061002.210: 1750061002.211: 1750061002.410: 1750061002.411: 1750061002.610: 1750061002.611: 1750061002.810: 1750061002.811: 1750061003.010: 1750061003.01Code:
1: 1750061002.210: 1750061002.211: 1750061002.410: 1750061002.410: 1750061002.611: 1750061002.611: 1750061002.810: 1750061002.811: 1750061003.010: 1750061003.01Can you confirm that you get the same behaviour? Once this is known to be working, we can start to think about Flask, whether the wallclocks on the Pis are synchronised, and so on. Thanks!
Statistics: Posted by therealdavidp — Mon Jun 16, 2025 8:13 am