RGB video
This example shows how to use high resolution video at low latency. Compared to RGB Preview, this demo outputs NV12 frames whereas preview frames are BGR and are not suited for larger resolution (eg. 1920x1080). Preview is more suitable for either NN or visualization purposes.Similar samples:
- RGB Preview (lower resolution)
Demo
Setup
Please run the install script to download all required dependencies. Please note that this script must be ran from git context, so you have to download the depthai-python repository first and then run the scriptCommand Line
1git clone https://github.com/luxonis/depthai-python.git
2cd depthai-python/examples
3python3 install_requirements.py
Source code
Python
C++
Python
PythonGitHub
1#!/usr/bin/env python3
2
3import cv2
4import depthai as dai
5
6# Create pipeline
7pipeline = dai.Pipeline()
8
9# Define source and output
10camRgb = pipeline.create(dai.node.ColorCamera)
11xoutVideo = pipeline.create(dai.node.XLinkOut)
12
13xoutVideo.setStreamName("video")
14
15# Properties
16camRgb.setBoardSocket(dai.CameraBoardSocket.CAM_A)
17camRgb.setResolution(dai.ColorCameraProperties.SensorResolution.THE_1080_P)
18camRgb.setVideoSize(1920, 1080)
19
20xoutVideo.input.setBlocking(False)
21xoutVideo.input.setQueueSize(1)
22
23# Linking
24camRgb.video.link(xoutVideo.input)
25
26# Connect to device and start pipeline
27with dai.Device(pipeline) as device:
28
29 video = device.getOutputQueue(name="video", maxSize=1, blocking=False)
30
31 while True:
32 videoIn = video.get()
33
34 # Get BGR frame from NV12 encoded video frame to show with opencv
35 # Visualizing the frame on slower hosts might have overhead
36 cv2.imshow("video", videoIn.getCvFrame())
37
38 if cv2.waitKey(1) == ord('q'):
39 break
Pipeline
Need assistance?
Head over to Discussion Forum for technical support or any other questions you might have.