12345678910111213141516171819202122232425262728293031323334353637 |
- import cv2
- import depthai as dai
- # Create pipeline
- pipeline = dai.Pipeline()
- # Define source and output
- camRgb = pipeline.create(dai.node.ColorCamera)
- xoutVideo = pipeline.create(dai.node.XLinkOut)
- xoutVideo.setStreamName("video")
- # Properties
- camRgb.setBoardSocket(dai.CameraBoardSocket.RGB)
- camRgb.setResolution(dai.ColorCameraProperties.SensorResolution.THE_1080_P)
- camRgb.setVideoSize(1280, 720)
- xoutVideo.input.setBlocking(False)
- xoutVideo.input.setQueueSize(1)
- # Linking
- camRgb.video.link(xoutVideo.input)
- # Connect to device and start pipeline
- with dai.Device(pipeline) as device:
- video = device.getOutputQueue(name="video", maxSize=1, blocking=False)
- while True:
- videoIn = video.get()
- # Get BGR frame from NV12 encoded video frame to show with opencv
- # Visualizing the frame on slower hosts might have overhead
- cv2.imshow("video", videoIn.getCvFrame())
- if cv2.waitKey(1) == 27:
- break
|