Created
February 27, 2023 15:00
-
-
Save Erol444/0138af63378dc8de5b3f7d80db1ea1a5 to your computer and use it in GitHub Desktop.
[DepthAI] Externally trigger FSYNC on OAK cameras
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import depthai as dai | |
import cv2 | |
import time | |
pipeline = dai.Pipeline() | |
camRgb = pipeline.create(dai.node.ColorCamera) | |
camRgb.setColorOrder(dai.ColorCameraProperties.ColorOrder.RGB) | |
camRgb.setIspScale(2,3) | |
camRgb.initialControl.setFrameSyncMode(dai.CameraControl.FrameSyncMode.INPUT) | |
camRgb.initialControl.setExternalTrigger(4,3) | |
xoutRgb = pipeline.create(dai.node.XLinkOut) | |
xoutRgb.setStreamName("color") | |
camRgb.isp.link(xoutRgb.input) | |
monoLeft = pipeline.create(dai.node.MonoCamera) | |
monoLeft.setResolution(dai.MonoCameraProperties.SensorResolution.THE_720_P) | |
monoLeft.setBoardSocket(dai.CameraBoardSocket.LEFT) | |
monoLeft.initialControl.setFrameSyncMode(dai.CameraControl.FrameSyncMode.INPUT) | |
monoLeft.initialControl.setExternalTrigger(4,3) | |
xoutLeft = pipeline.create(dai.node.XLinkOut) | |
xoutLeft.setStreamName("left") | |
monoLeft.out.link(xoutLeft.input) | |
monoRight = pipeline.createMonoCamera() | |
monoRight.setResolution(dai.MonoCameraProperties.SensorResolution.THE_720_P) | |
monoRight.setBoardSocket(dai.CameraBoardSocket.RIGHT) | |
monoRight.initialControl.setFrameSyncMode(dai.CameraControl.FrameSyncMode.INPUT) | |
monoRight.initialControl.setExternalTrigger(4,3) | |
xoutRight = pipeline.create(dai.node.XLinkOut) | |
xoutRight.setStreamName("right") | |
monoRight.out.link(xoutRight.input) | |
# Connect to device with pipeline | |
with dai.Device(pipeline) as device: | |
arr = ['left', 'right', 'color'] | |
queues = {} | |
frames = {} | |
for name in arr: | |
queues[name] = device.getOutputQueue(name) | |
print("Starting...") | |
while True: | |
for name in arr: | |
if queues[name].has(): | |
frames[name]=queues[name].get().getCvFrame() | |
for name, frame in frames.items(): | |
cv2.imshow(name, frame) | |
key = cv2.waitKey(1) | |
if key == ord('q'): | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment