1
0
Fork 0

luxonis opencv viewer

master
jebba 2021-07-15 12:56:54 -06:00
parent 5fa2d197e3
commit d66ba0d97a
1 changed files with 44 additions and 0 deletions

44
opencv_support.py 100755
View File

@ -0,0 +1,44 @@
#!/usr/bin/env python3
import cv2
import depthai as dai
# Create pipeline
pipeline = dai.Pipeline()
# Define source and outputs
camRgb = pipeline.createColorCamera()
xoutVideo = pipeline.createXLinkOut()
xoutPreview = pipeline.createXLinkOut()
xoutVideo.setStreamName("video")
xoutPreview.setStreamName("preview")
# Properties
camRgb.setPreviewSize(300, 300)
camRgb.setBoardSocket(dai.CameraBoardSocket.RGB)
camRgb.setResolution(dai.ColorCameraProperties.SensorResolution.THE_1080_P)
camRgb.setInterleaved(True)
camRgb.setColorOrder(dai.ColorCameraProperties.ColorOrder.BGR)
# Linking
camRgb.video.link(xoutVideo.input)
camRgb.preview.link(xoutPreview.input)
# Connect to device and start pipeline
with dai.Device(pipeline) as device:
video = device.getOutputQueue('video')
preview = device.getOutputQueue('preview')
while True:
videoFrame = video.get()
previewFrame = preview.get()
# Get BGR frame from NV12 encoded video frame to show with opencv
cv2.imshow("video", videoFrame.getCvFrame())
# Show 'preview' frame as is (already in correct format, no copy is made)
cv2.imshow("preview", previewFrame.getFrame())
if cv2.waitKey(1) == ord('q'):
break