From dca4106959b48c6c03aa49434fab54227136fda1 Mon Sep 17 00:00:00 2001 From: Matevz Morato Date: Thu, 14 Dec 2023 14:12:35 +0000 Subject: [PATCH] Change the sync node to work on buffers --- depthai-core | 2 +- examples/Sync/sync_left_right.py | 43 ++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 examples/Sync/sync_left_right.py diff --git a/depthai-core b/depthai-core index df44897e1..7890a60fc 160000 --- a/depthai-core +++ b/depthai-core @@ -1 +1 @@ -Subproject commit df44897e10d2b897ad3821e43b98952d4b07eab8 +Subproject commit 7890a60fcce1f34ab8039d5329bb4be54d1ef74d diff --git a/examples/Sync/sync_left_right.py b/examples/Sync/sync_left_right.py new file mode 100644 index 000000000..2bbd2a1ac --- /dev/null +++ b/examples/Sync/sync_left_right.py @@ -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 \ No newline at end of file