Skip to content

Commit

Permalink
Added example that will sync all available camera streams
Browse files Browse the repository at this point in the history
  • Loading branch information
Erol444 committed Aug 14, 2024
1 parent 15f6847 commit 6fd203d
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions examples/Sync/sync_all_cameras.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env python3

import cv2
import depthai as dai

with dai.Device() as device:
pipeline = dai.Pipeline()
cams = device.getConnectedCameraFeatures()
sync = pipeline.create(dai.node.Sync)
for cam in cams:
print(str(cam), str(cam.socket), cam.socket)
cam_node = pipeline.create(dai.node.Camera)
cam_node.setBoardSocket(cam.socket)
cam_node.isp.link(sync.inputs[str(cam.socket)])

xout = pipeline.create(dai.node.XLinkOut)
xout.setStreamName('sync')
sync.out.link(xout.input)

# Start pipeline
device.startPipeline(pipeline)
q = device.getOutputQueue('sync', maxSize=10, blocking=False)
while not device.isClosed():
msgs = q.get()
for (name, imgFrame) in msgs:
print(f'Cam {name}, seq {imgFrame.getSequenceNum()}, tiemstamp {imgFrame.getTimestamp()}')
cv2.imshow(name, imgFrame.getCvFrame())
print('----')

if cv2.waitKey(1) == ord('q'):
break

0 comments on commit 6fd203d

Please sign in to comment.