Benchmark Camera
This example showcases how the BenchmarkIn node works. It measures the FPS and latency of some message stream, in this case, the video stream from the camera.By default, the node will aggregate 50 messages and then print (firmware warning) the FPS and latency. In our case, that's33.3ms (30fps) * 50 messages = 1.665 seconds
.Demo
Command Line
1Benchmark $ python3.9 benchmark_camera.py
2[18443010211F850E00] [1.1] [3.367] [BenchmarkIn(1)] [warning] FPS: 30.019516
3[18443010211F850E00] [1.1] [3.367] [BenchmarkIn(1)] [warning] Messages took 1.6655831 s
4[18443010211F850E00] [1.1] [3.367] [BenchmarkIn(1)] [warning] Average latency: 0.010152339 s
5[18443010211F850E00] [1.1] [5.067] [BenchmarkIn(1)] [warning] FPS: 30.000103
6[18443010211F850E00] [1.1] [5.067] [BenchmarkIn(1)] [warning] Messages took 1.6666609 s
7[18443010211F850E00] [1.1] [5.067] [BenchmarkIn(1)] [warning] Average latency: 0.010102791 s
8[18443010211F850E00] [1.1] [6.767] [BenchmarkIn(1)] [warning] FPS: 30.000868
Setup
This example requires the DepthAI v3 API, see installation instructions.Pipeline
Source code
Python
C++
Python
PythonGitHub
1#!/usr/bin/env python3
2import depthai as dai
3import time
4
5# Create pipeline
6with dai.Pipeline() as pipeline:
7 # Create the nodes
8 cam = pipeline.create(dai.node.Camera).build()
9 benchmarkIn = pipeline.create(dai.node.BenchmarkIn)
10 # benchmarkIn.setRunOnHost(True) # The node can also run on host and include the transfer limitation, default is False
11 output = cam.requestFullResolutionOutput()
12 output.link(benchmarkIn.input)
13
14 pipeline.start()
15 while pipeline.isRunning():
16 time.sleep(1) # Let the logger print out the FPS
Need assistance?
Head over to Discussion Forum for technical support or any other questions you might have.