延迟测量
延迟测量
ImgFrame 的 .getTimestamp() 函数结合 dai.Clock.now() 来测量图像从捕获(更准确地说,是从 ISP 处理并附加时间戳)到在主机上接收到帧之间的时间延迟。如果您想了解更多关于低延迟的信息,请参阅文档页面 此处。演示
isp 1080P 输出(YUV420 编码帧)的延迟。我们获得了 大约 33 毫秒,这与 优化延迟 文档页面中的测量值相 同。Command Line
1UsbSpeed.SUPER
2Latency: 33.49 ms, Average latency: 33.49 ms, Std: 0.00
3Latency: 34.92 ms, Average latency: 34.21 ms, Std: 0.71
4Latency: 33.23 ms, Average latency: 33.88 ms, Std: 0.74
5Latency: 33.70 ms, Average latency: 33.84 ms, Std: 0.65
6Latency: 33.94 ms, Average latency: 33.86 ms, Std: 0.58
7Latency: 34.18 ms, Average latency: 33.91 ms, Std: 0.54设置
Command Line
1git clone https://github.com/luxonis/depthai-python.git
2cd depthai-python/examples
3python3 install_requirements.py源代码
Python
PythonGitHub
1import depthai as dai
2import numpy as np
3# Create pipeline
4pipeline = dai.Pipeline()
5# This might improve reducing the latency on some systems
6pipeline.setXLinkChunkSize(0)
7
8# Define source and output
9camRgb = pipeline.create(dai.node.ColorCamera)
10camRgb.setFps(60)
11camRgb.setResolution(dai.ColorCameraProperties.SensorResolution.THE_1080_P)
12
13xout = pipeline.create(dai.node.XLinkOut)
14xout.setStreamName("out")
15camRgb.isp.link(xout.input)
16
17# Connect to device and start pipeline
18with dai.Device(pipeline) as device:
19 print(device.getUsbSpeed())
20 q = device.getOutputQueue(name="out")
21 diffs = np.array([])
22 while True:
23 imgFrame = q.get()
24 # Latency in miliseconds
25 latencyMs = (dai.Clock.now() - imgFrame.getTimestamp()).total_seconds() * 1000
26 diffs = np.append(diffs, latencyMs)
27 print('Latency: {:.2f} ms, Average latency: {:.2f} ms, Std: {:.2f}'.format(latencyMs, np.average(diffs), np.std(diffs)))
28
29 # Not relevant for this example
30 # cv2.imshow('frame', imgFrame.getCvFrame())Pipeline
需要帮助?
请前往 Discussion Forum 获取技术支持或提出您可能有的任何其他问题。