RGB Preview
Similar samples:
- RGB Video (higher resolution)
- Mono Preview
- Depth Preview
Demo
Setup
Command Line
1git clone https://github.com/luxonis/depthai-python.git
2cd depthai-python/examples
3python3 install_requirements.pySource 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)
11xoutRgb = pipeline.create(dai.node.XLinkOut)
12
13xoutRgb.setStreamName("rgb")
14
15# Properties
16camRgb.setPreviewSize(300, 300)
17camRgb.setInterleaved(False)
18camRgb.setColorOrder(dai.ColorCameraProperties.ColorOrder.RGB)
19
20# Linking
21camRgb.preview.link(xoutRgb.input)
22
23# Connect to device and start pipeline
24with dai.Device(pipeline) as device:
25
26 print('Connected cameras:', device.getConnectedCameraFeatures())
27 # Print out usb speed
28 print('Usb speed:', device.getUsbSpeed().name)
29 # Bootloader version
30 if device.getBootloaderVersion() is not None:
31 print('Bootloader version:', device.getBootloaderVersion())
32 # Device name
33 print('Device name:', device.getDeviceName(), ' Product name:', device.getProductName())
34
35 # Output queue will be used to get the rgb frames from the output defined above
36 qRgb = device.getOutputQueue(name="rgb", maxSize=4, blocking=False)
37
38 while True:
39 inRgb = qRgb.get() # blocking call, will wait until a new data has arrived
40
41 # Retrieve 'bgr' (opencv format) frame
42 cv2.imshow("rgb", inRgb.getCvFrame())
43
44 if cv2.waitKey(1) == ord('q'):
45 breakPipeline
Need assistance?
Head over to Discussion Forum for technical support or any other questions you might have.