From 6fd203d8429b9f2382bf73c02d705be4ff4b3621 Mon Sep 17 00:00:00 2001 From: Erol444 Date: Wed, 14 Aug 2024 15:31:49 +0200 Subject: [PATCH] Added example that will sync all available camera streams --- examples/Sync/sync_all_cameras.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 examples/Sync/sync_all_cameras.py diff --git a/examples/Sync/sync_all_cameras.py b/examples/Sync/sync_all_cameras.py new file mode 100755 index 000000000..2c0a2aefa --- /dev/null +++ b/examples/Sync/sync_all_cameras.py @@ -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