1 Star 3 Fork 4

OAKChina/depthai-python

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
mono_full_resolution_saver.py 1.30 KB
一键复制 编辑 原始数据 按行查看 历史
#!/usr/bin/env python3
from pathlib import Path
import cv2
import depthai as dai
import time
# Create pipeline
pipeline = dai.Pipeline()
# Define source and output
monoRight = pipeline.create(dai.node.MonoCamera)
xoutRight = pipeline.create(dai.node.XLinkOut)
xoutRight.setStreamName("right")
# Properties
monoRight.setCamera("right")
monoRight.setResolution(dai.MonoCameraProperties.SensorResolution.THE_720_P)
# Linking
monoRight.out.link(xoutRight.input)
# Connect to device and start pipeline
with dai.Device(pipeline) as device:
# Output queue will be used to get the grayscale frames from the output defined above
qRight = device.getOutputQueue(name="right", maxSize=4, blocking=False)
dirName = "mono_data"
Path(dirName).mkdir(parents=True, exist_ok=True)
while True:
inRight = qRight.get() # Blocking call, will wait until a new data has arrived
# Data is originally represented as a flat 1D array, it needs to be converted into HxW form
# Frame is transformed and ready to be shown
cv2.imshow("right", inRight.getCvFrame())
# After showing the frame, it's being stored inside a target directory as a PNG image
cv2.imwrite(f"{dirName}/{int(time.time() * 1000)}.png", inRight.getFrame())
if cv2.waitKey(1) == ord('q'):
break
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/oakchina/depthai-python.git
git@gitee.com:oakchina/depthai-python.git
oakchina
depthai-python
depthai-python
main

搜索帮助