42 lines
1.3 KiB
Python
42 lines
1.3 KiB
Python
import os
|
|
|
|
import numpy as np
|
|
import pytest
|
|
|
|
|
|
@pytest.mark.slow
|
|
def test_vnormal_longrun_no_outlier_jumps(sensor_factory, available_backends):
|
|
preferred = os.getenv("ORISYS_LONGRUN_BACKEND", "cupy")
|
|
backend = preferred if preferred in available_backends else "cpu"
|
|
|
|
frames = int(os.getenv("ORISYS_LONGRUN_FRAMES", "1200"))
|
|
ratio_limit = float(os.getenv("ORISYS_LONGRUN_MAX_P99_P95_RATIO", "6.0"))
|
|
|
|
sensor = sensor_factory(backend=backend)
|
|
deltas = []
|
|
prev = None
|
|
try:
|
|
for _ in range(frames):
|
|
img = sensor.get_img()
|
|
assert img is not None
|
|
sensor.compute_deformation(check_motion=False)
|
|
(vnormal,) = sensor.read_info(sensor.info.VNORMAL)
|
|
assert np.isfinite(vnormal).all()
|
|
|
|
if prev is not None:
|
|
deltas.append(float(np.mean(np.abs(vnormal - prev))))
|
|
prev = vnormal.copy()
|
|
finally:
|
|
sensor.disconnect()
|
|
|
|
if len(deltas) < 30:
|
|
pytest.skip("Not enough frames to evaluate stability.")
|
|
|
|
p95 = float(np.percentile(deltas, 95))
|
|
p99 = float(np.percentile(deltas, 99))
|
|
ratio = p99 / (p95 + 1e-9)
|
|
assert ratio < ratio_limit, (
|
|
f"Long-run jump risk detected on {backend}: p99/p95={ratio:.3f} "
|
|
f"(limit={ratio_limit})."
|
|
)
|