Hi,
i have seen "gen2-seq-num-sync" NOW my question is would it be possible to have multiple devices syncronised with each other, as this code only lets one camera synced together?
cheers
Hi,
i have seen "gen2-seq-num-sync" NOW my question is would it be possible to have multiple devices syncronised with each other, as this code only lets one camera synced together?
cheers
Hello CodingArcher,
another great question So this experiment uses sequence numbers of the frames to sync them. For multiple devices, instead of using
packet.getInstanceNum()
, you should use packet.getTimestamp()
, as all devices have their time synced with the host computer, so it would be possible to sync all frames of all devices that way. I will actually add this to a TODO, as I believe it would be really useful for users with multiple cameras (such as yourself).
Thanks, Erik
Hi erik ,
thank you so much for the prompt feedback.
That actually makes so much sense to use the host timestamp to sync them all together.
I was getting bit confused as the new updated version on github now has 3 cameras enabled but now the code it much more complicated then prior with two.
Also i am certain that it should be possible to be able to detect is the device is a OAK-D or OAK-1 as one has 3 cameras and the other only 1 thus the code would need to be able to adjust to this and not break due to uncertain circumstances?
Cheers,
Markus
Hello CodingArcher, glad to help! It depends on the use-case; if using only 1 device, it's easier to sync by the sequence number, if using multiples timestamp is the way to go. And yes, you can get available cameras of the device (device.getConnectedCameras()
), so you can check beforehand if you can simplify syncing.
Thanks, Erik
Hi erik ,
you are truly a wise man. Thank you for sharingall of your knowledge and helping em get to the right direction
cheers,
markus
hi @erik ,
i had some testing and this is how far i have gotten sofar with getting multiple cameras connected with sync. Sadly it hasnt been far as im yet to understand how the getTimestamp
has to be implemented for each camera to know the precise time...
import cv2
import depthai as dai
import contextlib
# Start defining a pipeline
pipeline = dai.Pipeline()
cam_list = ['left', 'rgb', 'right']
cam_socket_opts = {
'rgb' : dai.CameraBoardSocket.RGB,
'left' : dai.CameraBoardSocket.LEFT,
'right': dai.CameraBoardSocket.RIGHT,
}
cam_instance = {
'rgb' : 0,
'left' : 1,
'right': 2,
}
cam = {}
xout = {}
for c in cam_list:
xout[c] = pipeline.createXLinkOut()
xout[c].setStreamName(c)
if c == 'rgb':
cam[c] = pipeline.createColorCamera()
cam[c].setResolution(dai.ColorCameraProperties.SensorResolution.THE_1080_P)
cam[c].setIspScale(720, 1080) # 1920x1080 -> 1280x720
cam[c].isp.link(xout[c].input)
else:
cam[c] = pipeline.createMonoCamera()
cam[c].setResolution(dai.MonoCameraProperties.SensorResolution.THE_720_P)
cam[c].out.link(xout[c].input)
cam[c].setBoardSocket(cam_socket_opts[c])
cam[c].setFps(30)
# https://docs.python.org/3/library/contextlib.html#contextlib.ExitStack
with contextlib.ExitStack() as stack:
for device_info in dai.Device.getAllAvailableDevices():
device = stack.enter_context(dai.Device(pipeline, device_info))
print("Conected to " + device_info.getMxId())
while True:
if cv2.waitKey(1) == ord('q'):
break
Hello CodingArcher ,
I would suggest looking at timestamp sync class from deeplab-demo experiment. It syncs streams based on timestamp, but it's not as configurable yet. Hopefully, this will get you started!
hi erik ,
thats amazing. thanks for the link. ill check it out. looking forward to see how someone else implements it also
Hi @Bruno ,
Yep, we have demos here:
luxonis/depthai-experimentstree/master/gen2-syncing#message-syncing
Also timestamp syncing should be there. Thoughts?