为采集帧绑定主机时间与来源信息
采集时间随图像穿过处理队列,并修正未读帧的丢帧计数。通过采集与流水线针对性测试。
This commit is contained in:
+25
-1
@@ -8,7 +8,7 @@ import time
|
||||
import numpy as np
|
||||
import pytest
|
||||
|
||||
from orisys import FrameSnapshot, StreamPipeline
|
||||
from orisys import FrameSnapshot, ProducedFrame, StreamPipeline
|
||||
|
||||
|
||||
class FakeSensor:
|
||||
@@ -149,6 +149,30 @@ def test_on_frame_receives_every_frame_in_order():
|
||||
assert pipe.stats.published == 12
|
||||
|
||||
|
||||
def test_producer_metadata_stays_with_its_image_through_the_queues():
|
||||
sensor = FakeSensor(flow_delay=0.002)
|
||||
frames = []
|
||||
produced = 0
|
||||
|
||||
def produce():
|
||||
nonlocal produced
|
||||
if produced == 12:
|
||||
return None
|
||||
value = produced
|
||||
produced += 1
|
||||
return ProducedFrame(sensor.make_frame(value), {"source_seq": value})
|
||||
|
||||
pipe = StreamPipeline(sensor, produce, on_frame=frames.append)
|
||||
pipe.start()
|
||||
deadline = time.perf_counter() + 10.0
|
||||
while len(frames) < 12 and time.perf_counter() < deadline:
|
||||
time.sleep(0.001)
|
||||
pipe.stop()
|
||||
assert len(frames) == 12
|
||||
for snap in frames:
|
||||
assert snap.source_metadata["source_seq"] == int(snap.image[0, 0])
|
||||
|
||||
|
||||
def test_forces_come_from_the_matching_frame():
|
||||
"""Each snapshot must carry the forces computed from its own frame's flow."""
|
||||
sensor = FakeSensor()
|
||||
|
||||
Reference in New Issue
Block a user