1 Star 3 Fork 4

OAKChina/depthai-python

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
mono_preview.py 1.41 KB
一键复制 编辑 原始数据 按行查看 历史
#!/usr/bin/env python3
import cv2
import depthai as dai
# 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)
xoutLeft.setStreamName('left')
xoutRight.setStreamName('right')
# Properties
monoLeft.setCamera("left")
monoLeft.setResolution(dai.MonoCameraProperties.SensorResolution.THE_720_P)
monoRight.setCamera("right")
monoRight.setResolution(dai.MonoCameraProperties.SensorResolution.THE_720_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=4, blocking=False)
qRight = device.getOutputQueue(name="right", maxSize=4, blocking=False)
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:
cv2.imshow("left", inLeft.getCvFrame())
if inRight is not None:
cv2.imshow("right", inRight.getCvFrame())
if cv2.waitKey(1) == ord('q'):
break
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/oakchina/depthai-python.git
git@gitee.com:oakchina/depthai-python.git
oakchina
depthai-python
depthai-python
main

搜索帮助