ff7614a6a0
保留旧格式和 cal_path,校验 SN、特征身份及坐标附件,按帧返回逐轴状态。相关测试 263 项通过,已核对存量预测并实测 180 帧录像。
60 lines
2.4 KiB
Python
60 lines
2.4 KiB
Python
"""Feature identities use effective measurement settings, never display metadata."""
|
|
|
|
from copy import deepcopy
|
|
|
|
import numpy as np
|
|
import pytest
|
|
|
|
from orisys.calibration_context import build_context, domain_fingerprint
|
|
|
|
|
|
def config():
|
|
return {"camera": {"resolution_raw": [1280, 720], "resolution_stitch": [700, 750]},
|
|
"tracker": {"dis_mode": 4}}
|
|
|
|
|
|
@pytest.mark.parametrize("raw,expected", [(None, 1), ("bad", 1), (0, 1), (-3, 1), ("3", 3), (3.7, 3)])
|
|
def test_hhd_uses_actual_sensor_normalization(raw, expected):
|
|
data = config()
|
|
data["tracker"]["hhd_downsample"] = raw
|
|
assert build_context(data)["hhd_downsample"] == expected
|
|
|
|
|
|
def test_default_values_equal_explicit_effective_settings():
|
|
implicit = build_context(config())
|
|
data = config()
|
|
data["tracker"]["hhd_downsample"] = 1
|
|
explicit = build_context(data, {"flow_ema_alpha": 1.0})
|
|
assert implicit["hhd_downsample"] == 1
|
|
assert implicit["filters"]["measurement"] == {"flow_ema_alpha": 1.0}
|
|
assert implicit["feature_signature_sha256"] == explicit["feature_signature_sha256"]
|
|
|
|
|
|
def test_measurement_filters_change_identity_but_readout_and_paths_do_not():
|
|
data = config()
|
|
original = build_context(data)
|
|
assert build_context(data, {"flow_ema_alpha": 0.5})["feature_signature_sha256"] != original["feature_signature_sha256"]
|
|
data.update(name="other", video="D:/other.mp4", cal_path="E:/calibration.json")
|
|
assert build_context(data, {"force_median_window": 7, "force_lowpass_cutoff_hz": 2}) == original
|
|
|
|
|
|
def test_explicit_empty_filter_mapping_overrides_config_defaults():
|
|
data = config()
|
|
data["filters"] = {"flow_ema_alpha": 0.5}
|
|
assert build_context(data, {})["filters"]["measurement"] == {"flow_ema_alpha": 1.0}
|
|
|
|
|
|
def test_source_scale_numeric_types_have_identical_identity():
|
|
assert build_context(config(), source_scale=1) == build_context(config(), source_scale=1.0)
|
|
|
|
|
|
def test_domain_fingerprint_binds_map_content_not_only_dimensions():
|
|
domain = {"map_x": np.zeros((2, 3)), "map_y": np.zeros((2, 3)),
|
|
"valid_mask": np.ones((2, 3), dtype=bool), "world_xyz": np.zeros((2, 3, 3))}
|
|
original = domain_fingerprint(domain)
|
|
for key in domain:
|
|
changed = deepcopy(domain)
|
|
changed[key].flat[0] = not changed[key].flat[0] if key == "valid_mask" else 1
|
|
assert domain_fingerprint(changed) != original
|
|
assert domain_fingerprint({key: value.copy() for key, value in domain.items()}) == original
|