Skip to content

Commit

Permalink
Change the sync node to work on buffers
Browse files Browse the repository at this point in the history
  • Loading branch information
Matevz Morato committed Dec 14, 2023
1 parent 2eb3bdd commit dca4106
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
2 changes: 1 addition & 1 deletion depthai-core
43 changes: 43 additions & 0 deletions examples/Sync/sync_left_right.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env python3

import cv2
import depthai as dai
import numpy as np


# Create pipeline
pipeline = dai.Pipeline()

# Define sources and outputs
monoLeft = pipeline.create(dai.node.MonoCamera)
monoRight = pipeline.create(dai.node.MonoCamera)
xoutLeft = pipeline.create(dai.node.XLinkOut)
xoutRight = pipeline.create(dai.node.XLinkOut)
syncNode = pipeline.create(dai.node.Sync)

xoutLeft.setStreamName("left")
xoutRight.setStreamName("right")


# Properties
monoLeft.setResolution(dai.MonoCameraProperties.SensorResolution.THE_720_P)
monoLeft.setBoardSocket(dai.CameraBoardSocket.LEFT)
monoRight.setResolution(dai.MonoCameraProperties.SensorResolution.THE_720_P)
monoRight.setBoardSocket(dai.CameraBoardSocket.RIGHT)

monoLeft.out.link(syncNode.inputs["left"])
monoRight.out.link(syncNode.inputs["right"])
syncNode.outputs["left"].link(xoutLeft.input)
syncNode.outputs["right"].link(xoutRight.input)

with dai.Device(pipeline) as device:
qLeft = device.getOutputQueue(name="left", maxSize=4, blocking=False)
qRight = device.getOutputQueue(name="right", maxSize=4, blocking=False)
while True:
inLeft = qLeft.get()
inRight = qRight.get()

cv2.imshow("left", inLeft.getCvFrame())
cv2.imshow("right", inRight.getCvFrame())
if cv2.waitKey(1) == ord('q'):
break

0 comments on commit dca4106

Please sign in to comment.