Created
June 17, 2022 10:44
-
-
Save Erol444/7b364236b0c3f8bd2bd17ca3c76244a0 to your computer and use it in GitHub Desktop.
DepthAI OAK-D-Lite 120FPS 2x400P mono frames
This file contains hidden or 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 cv2 | |
import depthai as dai | |
from depthai_sdk import FPSHandler | |
# Create pipeline | |
pipeline = dai.Pipeline() | |
pipeline.setXLinkChunkSize(0) | |
# 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) | |
xoutLeft.setStreamName('left') | |
xoutRight.setStreamName('right') | |
# Properties | |
monoLeft.setBoardSocket(dai.CameraBoardSocket.LEFT) | |
monoLeft.setFps(120) | |
monoLeft.setResolution(dai.MonoCameraProperties.SensorResolution.THE_400_P) | |
monoRight.setBoardSocket(dai.CameraBoardSocket.RIGHT) | |
monoRight.setFps(120) | |
monoRight.setResolution(dai.MonoCameraProperties.SensorResolution.THE_400_P) | |
# Linking | |
monoRight.out.link(xoutRight.input) | |
monoLeft.out.link(xoutLeft.input) | |
# Connect to device and start pipeline | |
with dai.Device(pipeline) as device: | |
# Output queues will be used to get the grayscale frames from the outputs defined above | |
qLeft = device.getOutputQueue(name="left", maxSize=30, blocking=False) | |
qRight = device.getOutputQueue(name="right", maxSize=30, blocking=False) | |
fps = FPSHandler() | |
while True: | |
# Instead of get (blocking), we use tryGet (non-blocking) which will return the available data or None otherwise | |
inLeft = qLeft.tryGet() | |
inRight = qRight.tryGet() | |
if inLeft is not None: | |
fps.nextIter() | |
print(fps.fps()) | |
cv2.imshow("left", inLeft.getCvFrame()) | |
if inRight is not None: | |
cv2.imshow("right", inRight.getCvFrame()) | |
if cv2.waitKey(1) == ord('q'): | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment