允许 HHD 下采样率不同的标定保持兼容
按实际运行上下文核对其余处理参数,保留文件指纹与设备身份校验。115 项标定及运行时检查通过。
This commit is contained in:
@@ -4,6 +4,7 @@ from __future__ import annotations
|
||||
|
||||
import hashlib
|
||||
import json
|
||||
from copy import deepcopy
|
||||
from pathlib import Path
|
||||
|
||||
import numpy as np
|
||||
@@ -11,6 +12,29 @@ import numpy as np
|
||||
from .calibration import filters_fingerprint
|
||||
|
||||
|
||||
def _feature_signature(identity) -> str:
|
||||
encoded = json.dumps(identity, sort_keys=True, separators=(",", ":"), allow_nan=False)
|
||||
return hashlib.sha256(encoded.encode("utf-8")).hexdigest()
|
||||
|
||||
|
||||
class CalibrationContext(dict):
|
||||
"""Actual pipeline fields plus the runtime inputs needed to compare HHD settings.
|
||||
|
||||
JSON serialization contains only the actual fields. Retaining the signature
|
||||
inputs lets old files differ in downsample without ignoring other hashed settings.
|
||||
"""
|
||||
|
||||
def __init__(self, fields, feature_identity):
|
||||
super().__init__(fields)
|
||||
self._feature_identity = deepcopy(feature_identity)
|
||||
|
||||
def signature_for_downsample(self, downsample: int) -> str:
|
||||
"""Recompute the runtime identity with only the requested HHD resolution."""
|
||||
identity = deepcopy(self._feature_identity)
|
||||
identity["tracker"]["hhd_downsample"] = downsample
|
||||
return _feature_signature(identity)
|
||||
|
||||
|
||||
def sha256_file(path) -> str:
|
||||
return hashlib.sha256(Path(path).read_bytes()).hexdigest()
|
||||
|
||||
@@ -70,6 +94,5 @@ def build_context(config, filters=None, *, geometry_sha256=None, source_scale=No
|
||||
"source_scale": source_scale,
|
||||
"preprocessing": preprocessing or {},
|
||||
}
|
||||
encoded = json.dumps(effective, sort_keys=True, separators=(",", ":"), allow_nan=False)
|
||||
result["feature_signature_sha256"] = hashlib.sha256(encoded.encode("utf-8")).hexdigest()
|
||||
return result
|
||||
result["feature_signature_sha256"] = _feature_signature(effective)
|
||||
return CalibrationContext(result, effective)
|
||||
|
||||
Reference in New Issue
Block a user