Setup
Source code
Python
C++
Python
PythonGitHub
1#!/usr/bin/env python3
2
3import argparse
4import cv2
5import depthai as dai
6
7
8parser = argparse.ArgumentParser()
9parser.add_argument(
10 "--fps_limit", type=float, default=3.0, help="Limit output FPS (float, optional)"
11)
12args = parser.parse_args()
13
14# Create pipeline
15with dai.Pipeline() as pipeline:
16 # Define source and output
17 cam = pipeline.create(dai.node.Camera).build()
18 videoOutput = cam.requestOutput((640, 400), fps=30)
19 videoQueue = videoOutput.createOutputQueue()
20
21 pipeline.build()
22
23 # Optionally update internal settings
24 # Note: xlink bridges are only generated after pipeline.build() is called
25 xlinkBridge = videoOutput.getXLinkBridge()
26 assert xlinkBridge is not None
27 assert isinstance(xlinkBridge, dai.node.internal.XLinkOutBridge)
28 xlinkBridge.xLinkOut.setFpsLimit(args.fps_limit)
29
30 # Connect to device and start pipeline
31 pipeline.start()
32 while pipeline.isRunning():
33 videoIn = videoQueue.get()
34 assert isinstance(videoIn, dai.ImgFrame)
35 cv2.imshow("video", videoIn.getCvFrame())
36
37 if cv2.waitKey(1) == ord("q"):
38 breakNeed assistance?
Head over to Discussion Forum for technical support or any other questions you might have.