gather_data
最后更新
depthai_nodes.node.gather_data类
GatherData
- reference_input:参考消息(例如,检测),它们定义了分组键(时间戳)并确定应为该参考收集多少数据项。
- data_input:要为相机 FPS 派生的容差范围内最近的参考时间戳收集的消息。
wait_count_fn(reference)。一旦准备就绪,它会发出一个 depthai_nodes.GatheredData 消息,其中包含参考消息和收集到的项。默认的 wait_count_fn 使用 len(reference.detections),这对于公开 detections 属性的消息(例如 dai.ImgDetections)开箱即用。注意
- 时间戳匹配使用
Buffer.getTimestamp().total_seconds()和1 / (camera_fps * FPS_TOLERANCE_DIVISOR)的容差。 - 如果
wait_count_fn(reference) == 0,则节点会立即为该参考发出(带有一个空的项目列表)。 - 节点以
camera_fps和INPUT_CHECKS_PER_FPS派生的速率使用tryGet()定期轮询输入。
_data_input : dai.Node.Input:要收集的数据消息流(类型TGathered)。_reference_input : dai.Node.Input:用于分组和决定收集多少项的参考消息流(类型TReference)。
out : dai.Node.Output:发出depthai_nodes.GatheredData对象,其中包含:reference_data(匹配的参考)和items(数据列表)。
方法
init
Python
1def __init__(self):build
Python
1def build(cameraFps: int, inputData: dai.Node.Output, inputReference: dai.Node.Output, waitCountFn: Callable[[TReference], int] | None = None) -> GatherData[TReference, TGathered]:cameraFps(int):用于派生时间戳匹配容差和轮询间隔的相机帧率。inputData(dai.Node.Output):生成要收集的数据消息的上游输出。inputReference(dai.Node.Output):生成参考消息的上游输出。waitCountFn(Callable[[TReference], int] | None):可选回调,返回给定参考预期的数据消息数量。如果省略,则默认为 len(reference.detections)。
GatherData[TReference, TGathered]:配置好的节点实例。
run
Python
1def run(self):setCameraFps
Python
1def setCameraFps(fps: int):fps(int):用于匹配容差和轮询的正相机帧率。
ValueError:如果帧率不是正数。
setWaitCountFn
Python
1def setWaitCountFn(fn: Callable[[TReference], int]):fn(Callable[[TReference], int]):接受参考消息并返回要等待的项数的回调。计数为零会立即发出一个空组。
属性
FPS_TOLERANCE_DIVISOR
INPUT_CHECKS_PER_FPS
1 / (INPUT_CHECKS_PER_FPS * camera_fps)。