Skip to content

Commit c8a5a9a

Browse files
authored
Merge pull request #168 from luxonis/camera_video_example
Camera video example
2 parents 35af5d7 + 48c09e1 commit c8a5a9a

File tree

5 files changed

+63
-3
lines changed

5 files changed

+63
-3
lines changed

docs/source/index.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,16 @@ Now, pick a tutorial or code sample and start utilizing Gen2 capabilities
9191
samples/17_video_mobilenet.rst
9292
samples/18_rgb_encoding_mobilenet.rst
9393
samples/21_mobilenet_decoding_on_device.rst
94-
samples/22_1_tiny_tolo_v3_decoding_on_device.rst
95-
samples/22_2_tiny_tolo_v4_decoding_on_device.rst
94+
samples/22_1_tiny_yolo_v3_decoding_on_device.rst
95+
samples/22_2_tiny_yolo_v4_decoding_on_device.rst
9696
samples/23_autoexposure_roi.rst
9797
samples/24_opencv_support.rst
9898
samples/25_system_information.rst
9999
samples/26_1_spatial_mobilenet.rst
100100
samples/26_2_spatial_mobilenet_mono.rst
101101
samples/26_3_spatial_tiny_yolo.rst
102102
samples/27_spatial_location_calculator.rst
103+
samples/28_camera_video_example.rst
103104

104105
.. toctree::
105106
:maxdepth: 1

docs/source/samples/22_1_tiny_yolo_v3_decoding_on_device.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
21 - RGB & TinyYoloV3 decoding on device
1+
22.1 - RGB & TinyYoloV3 decoding on device
22
==========================================
33

44
This example shows how to run TinyYoloV3 on the RGB input frame, and how to display both the RGB
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
28 - Camera video high resolution
2+
=================================
3+
4+
This example shows how to use high resolution video at low latency. Compared to :ref:`01 - RGB Preview`, this demo outputs NV12 frames whereas
5+
preview frames are BGR and are not suited for larger resoulution (eg. 2000x1000). Preview is more suitable for either NN or visualization purposes.
6+
7+
Setup
8+
#####
9+
10+
.. include:: /includes/install_from_pypi.rst
11+
12+
Source code
13+
###########
14+
15+
Also `available on GitHub <https://github.com/luxonis/depthai-python/blob/develop/examples/28_camera_video_example.py>`__
16+
17+
.. literalinclude:: ../../../examples/28_camera_video_example.py
18+
:language: python
19+
:linenos:
20+
21+
.. include:: /includes/footer-short.rst
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/usr/bin/env python3
2+
3+
import cv2
4+
import depthai as dai
5+
import numpy as np
6+
7+
# Start defining a pipeline
8+
pipeline = dai.Pipeline()
9+
10+
# Define a source - color camera
11+
colorCam = pipeline.createColorCamera()
12+
colorCam.setBoardSocket(dai.CameraBoardSocket.RGB)
13+
colorCam.setResolution(dai.ColorCameraProperties.SensorResolution.THE_1080_P)
14+
colorCam.setVideoSize(1920, 1080)
15+
16+
# Create output
17+
xoutVideo = pipeline.createXLinkOut()
18+
xoutVideo.setStreamName("video")
19+
20+
colorCam.video.link(xoutVideo.input)
21+
22+
# Pipeline defined, now the device is connected to
23+
with dai.Device(pipeline) as device:
24+
# Start pipeline
25+
device.startPipeline()
26+
video = device.getOutputQueue(name="video", maxSize=1, blocking=False)
27+
28+
while True:
29+
# Get preview and video frames
30+
videoIn = video.get()
31+
32+
# Get BGR frame from NV12 encoded video frame to show with opencv
33+
# Visualizing the frame on slower hosts might have overhead
34+
cv2.imshow("video", videoIn.getCvFrame())
35+
36+
if cv2.waitKey(1) == ord('q'):
37+
break

examples/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,3 +136,4 @@ add_python_example(26_2_spatial_mobilenet_mono 26_2_spatial_mobilenet_mono.py "$
136136
add_python_example(26_3_spatial_tiny_yolo_v3 26_3_spatial_tiny_yolo.py "${tiny_yolo_v3_blob}")
137137
add_python_example(26_3_spatial_tiny_yolo_v4 26_3_spatial_tiny_yolo.py "${tiny_yolo_v4_blob}")
138138
add_python_example(27_spatial_location_calculator 27_spatial_location_calculator.py)
139+
add_python_example(28_camera_video_example 28_camera_video_example.py)

0 commit comments

Comments
 (0)