Skip to content

Commit 6fd203d

Browse files
committed
Added example that will sync all available camera streams
1 parent 15f6847 commit 6fd203d

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

examples/Sync/sync_all_cameras.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env python3
2+
3+
import cv2
4+
import depthai as dai
5+
6+
with dai.Device() as device:
7+
pipeline = dai.Pipeline()
8+
cams = device.getConnectedCameraFeatures()
9+
sync = pipeline.create(dai.node.Sync)
10+
for cam in cams:
11+
print(str(cam), str(cam.socket), cam.socket)
12+
cam_node = pipeline.create(dai.node.Camera)
13+
cam_node.setBoardSocket(cam.socket)
14+
cam_node.isp.link(sync.inputs[str(cam.socket)])
15+
16+
xout = pipeline.create(dai.node.XLinkOut)
17+
xout.setStreamName('sync')
18+
sync.out.link(xout.input)
19+
20+
# Start pipeline
21+
device.startPipeline(pipeline)
22+
q = device.getOutputQueue('sync', maxSize=10, blocking=False)
23+
while not device.isClosed():
24+
msgs = q.get()
25+
for (name, imgFrame) in msgs:
26+
print(f'Cam {name}, seq {imgFrame.getSequenceNum()}, tiemstamp {imgFrame.getTimestamp()}')
27+
cv2.imshow(name, imgFrame.getCvFrame())
28+
print('----')
29+
30+
if cv2.waitKey(1) == ord('q'):
31+
break

0 commit comments

Comments
 (0)