完善 Autocal 多测点标定流程及会话复核
统一测点坐标、保持窗口和试验目录,补齐逐点初步分析。定向测试与真实视频闭环通过;两项轮询失败在修改前版本同样复现。
This commit is contained in:
@@ -288,3 +288,39 @@ if __name__ == "__main__": # pragma: no cover - manual runner
|
||||
print(f" FAIL {name}: {type(exc).__name__}: {exc}")
|
||||
print(f"failures: {failures}")
|
||||
raise SystemExit(1 if failures else 0)
|
||||
|
||||
|
||||
def test_named_trial_directory_is_safe_and_never_overwritten(tmp_path):
|
||||
recorder = ExperimentRecorder(RecordConfig(video=False))
|
||||
for value in ("../trial", "a/b", "..", "C:\\trial"):
|
||||
with pytest.raises(ValueError):
|
||||
recorder.start(root=tmp_path, session_id=1, metadata={}, directory_name=value)
|
||||
directory = recorder.start(root=tmp_path, session_id=1, metadata={}, directory_name="trial-001")
|
||||
recorder.on_packet(_packet(0))
|
||||
recorder.stop(wait=True)
|
||||
assert directory == tmp_path / "trial-001"
|
||||
with pytest.raises(FileExistsError):
|
||||
recorder.start(root=tmp_path, session_id=1, metadata={}, directory_name="trial-001")
|
||||
assert (directory / "session.json").is_file()
|
||||
|
||||
|
||||
@pytest.mark.parametrize("preserve", [False, True])
|
||||
def test_calibration_can_keep_burst_frames_without_changing_default_pacing(tmp_path, preserve):
|
||||
from dataclasses import replace
|
||||
|
||||
recorder = ExperimentRecorder(RecordConfig(fps=30, preserve_all_frames=preserve))
|
||||
directory = recorder.start(root=tmp_path, session_id=1, metadata={})
|
||||
for index in range(10):
|
||||
recorder.on_packet(replace(_packet(index), mono_t=index / 300.0))
|
||||
report = recorder.stop(wait=True)
|
||||
assert report.stats.frames == 10
|
||||
if preserve:
|
||||
assert report.stats.video_frames == 10
|
||||
assert report.stats.resampled_video == 0
|
||||
assert report.ok
|
||||
else:
|
||||
assert report.stats.video_frames < 10
|
||||
assert report.stats.resampled_video > 0
|
||||
with (directory / "frames.csv").open(encoding="utf-8") as handle:
|
||||
rows = list(csv.DictReader(handle))
|
||||
assert sum(row["in_video"] == "1" for row in rows) == report.stats.video_frames
|
||||
|
||||
Reference in New Issue
Block a user