添加按设备 ID 选择和校验标定文件

避免多台传感器误用默认标定,缺文件时保持 raw。已通过 SDK 回归测试和文档检查。
This commit is contained in:
ykcheungab
2026-10-05 12:21:04 +08:00
parent 230b04a79d
commit 80f7da5a20
6 changed files with 261 additions and 10 deletions
+31
View File
@@ -1,4 +1,5 @@
from pathlib import Path
from types import SimpleNamespace
import numpy as np
import pytest
@@ -159,6 +160,36 @@ def test_finger_runtime_get_img_returns_none_on_capture_failure():
assert runtime.get_img() is None
def test_finger_open_selects_device_calibration_before_capture(monkeypatch, tmp_path):
import orisys.finger.runtime as runtime_mod
selected = {}
geometry = SimpleNamespace(
export_paths=SimpleNamespace(as_tuple=lambda: ("mesh", "intrinsics", "pose")),
map_cache="cache", source_K=np.eye(3), source_width=2, source_height=2,
out_width=2, out_height=2, edge_expand=1.0, source_scale=1.0,
config={"camera": {}},
)
monkeypatch.setattr(runtime_mod, "resolve_finger_geometry", lambda **_: geometry)
monkeypatch.setattr(
runtime_mod, "build_or_load_domain",
lambda *args, **kwargs: SimpleNamespace(
remap=SimpleNamespace(ensure_fast_maps=lambda: None)
),
)
monkeypatch.setattr(runtime_mod, "Sensor", lambda *args, **kwargs: selected.update(kwargs))
monkeypatch.setattr(runtime_mod.CaptureConfig, "from_camera_dict", lambda *args, **kwargs: None)
def stop_before_capture(*args, **kwargs):
assert selected["calibration_dir"] == tmp_path
assert selected["device_id"] == "FINGER-001"
raise RuntimeError("capture reached")
monkeypatch.setattr(runtime_mod, "open_capture", stop_before_capture)
with pytest.raises(RuntimeError, match="capture reached"):
runtime_mod.FingerRuntime.open(calibration_dir=tmp_path, device_id="FINGER-001")
def test_finger_runtime_get_img_returns_unrolled_frame_on_success():
from orisys.finger.runtime import FingerRuntime