fixed studio dd02 live cannot work problem
This commit is contained in:
@@ -129,6 +129,61 @@ def test_a_zeroing_is_applied_by_the_worker_and_reported_with_its_frame():
|
||||
assert events == [(42, 1.4, 2)]
|
||||
|
||||
|
||||
def test_a_live_zeroing_is_queued_on_the_pipeline():
|
||||
"""The stream path must not reset the tracker on the consumer thread.
|
||||
|
||||
The flow stage is indexing the tracker's frame queue at the same time.
|
||||
Clearing it here is the ``list index out of range`` that ends the session.
|
||||
"""
|
||||
events: list[tuple] = []
|
||||
worker = _worker(on_reset_applied=lambda *args: events.append(args))
|
||||
sensor = _Sensor()
|
||||
queued: list[int] = []
|
||||
|
||||
class _Pipeline:
|
||||
def reset(self) -> None:
|
||||
queued.append(sensor.resets)
|
||||
|
||||
worker._session_id = 2
|
||||
worker.reset()
|
||||
worker._consume_pending_reset(
|
||||
sensor, frame_id=42, mono_t=1.4, pipeline=_Pipeline()
|
||||
)
|
||||
assert sensor.resets == 0, "the live zeroing ran on the consumer thread"
|
||||
assert queued == [0]
|
||||
assert events == [(42, 1.4, 2)]
|
||||
|
||||
|
||||
def test_a_live_finger_zeroing_is_queued_on_the_pipeline():
|
||||
from orisys_app_shared.acquisition.finger_worker import FingerAcquisitionWorker
|
||||
|
||||
events: list[tuple] = []
|
||||
worker = FingerAcquisitionWorker(on_reset_applied=lambda *args: events.append(args))
|
||||
tactile_resets: list[int] = []
|
||||
|
||||
class _Tactile:
|
||||
def reset(self) -> None:
|
||||
tactile_resets.append(1)
|
||||
|
||||
class _Runtime:
|
||||
tactile = _Tactile()
|
||||
|
||||
queued: list[int] = []
|
||||
|
||||
class _Pipeline:
|
||||
def reset(self) -> None:
|
||||
queued.append(len(tactile_resets))
|
||||
|
||||
worker._session_id = 3
|
||||
worker.reset()
|
||||
worker._consume_pending_reset(
|
||||
_Runtime(), frame_id=7, mono_t=0.2, pipeline=_Pipeline()
|
||||
)
|
||||
assert tactile_resets == [], "the finger zeroing ran on the consumer thread"
|
||||
assert queued == [0]
|
||||
assert events == [(7, 0.2, 3)]
|
||||
|
||||
|
||||
def test_a_started_session_drops_a_stale_zeroing_request():
|
||||
root = _root()
|
||||
events: list[tuple] = []
|
||||
|
||||
@@ -416,3 +416,32 @@ def test_a_failed_chain_marks_the_frame_rather_than_claiming_its_forces():
|
||||
assert packet.contact.centroid_uv_xy is None
|
||||
finally:
|
||||
_restore(saved)
|
||||
|
||||
|
||||
def test_the_finger_producer_reports_the_camera_rate(monkeypatch):
|
||||
"""The first live frame asks the producer for ``capture_fps``.
|
||||
|
||||
That call is what ended a finger session with
|
||||
``'_FingerProducer' object has no attribute 'capture_fps'``. A file has no
|
||||
delivered-frame counter, so it reports nothing; a live source reports the
|
||||
frames its counter advanced over the wall-clock between two reads.
|
||||
"""
|
||||
from orisys_app_shared.acquisition import finger_worker
|
||||
|
||||
clock = {"t": 1000.0}
|
||||
monkeypatch.setattr(finger_worker.time, "perf_counter", lambda: clock["t"])
|
||||
|
||||
file_source = types.SimpleNamespace(running=False, status=types.SimpleNamespace(last_seq=0))
|
||||
file_runtime = types.SimpleNamespace(capture_source=file_source)
|
||||
file_producer = finger_worker._FingerProducer(file_runtime, is_file=True)
|
||||
assert file_producer.capture_fps() == 0.0
|
||||
|
||||
status = types.SimpleNamespace(last_seq=10, dropped_frames=0)
|
||||
live = types.SimpleNamespace(running=True, status=status)
|
||||
producer = finger_worker._FingerProducer(
|
||||
types.SimpleNamespace(capture_source=live), is_file=False
|
||||
)
|
||||
assert producer.capture_fps() == 0.0
|
||||
clock["t"] = 1001.0
|
||||
producer.capture_seq = 40
|
||||
assert producer.capture_fps() == pytest.approx(30.0)
|
||||
|
||||
Reference in New Issue
Block a user