agrobot_base/Python/OAK/OAK-1-Lite-W.py

30 lines
873 B
Python

import depthai as dai
import cv2
# Cria um pipeline para capturar imagens da câmera
pipeline = dai.Pipeline()
# Configuração do nó da câmera
cam_rgb = pipeline.create(dai.node.ColorCamera)
cam_rgb.setPreviewSize(1280, 720) # Resolução HD
cam_rgb.setBoardSocket(dai.CameraBoardSocket.RGB)
cam_rgb.setInterleaved(False)
# Criar um XLinkOut para exibir o vídeo no PC
xout = pipeline.create(dai.node.XLinkOut)
xout.setStreamName("video")
cam_rgb.preview.link(xout.input)
# Inicia o pipeline
with dai.Device(pipeline) as device:
video_queue = device.getOutputQueue(name="video", maxSize=4, blocking=False)
while True:
frame = video_queue.get().getCvFrame() # Obtém o frame da câmera
cv2.imshow("OAK-1 Lite W - Preview", frame)
if cv2.waitKey(1) == ord('q'): # Pressione 'q' para sair
break
cv2.destroyAllWindows()