Files
detections/e2e/tests/test_tiling.py
Roman Meshko c9aeed3dd9
ci/woodpecker/push/02-build-push Pipeline was successful
ci/woodpecker/manual/02-build-push Pipeline was successful
ci/woodpecker/manual/01-test Pipeline failed
Added camera config
2026-05-15 09:31:23 +03:00

49 lines
1.3 KiB
Python

import json
import pytest
_TILING_TIMEOUT = 120
_GSD = {
"camera_config": {
"focal_length": 24,
"sensor_width": 23.5,
"current_zoom": 1,
"current_angle": 90,
"current_height": 400,
}
}
_DUP_THRESHOLD = 0.01
def _assert_coords_normalized(detections):
for d in detections:
for k in ("centerX", "centerY", "width", "height"):
v = d[k]
assert 0.0 <= v <= 1.0
def _assert_no_same_label_near_duplicate_centers(detections):
by_label = {}
for d in detections:
label = d["label"]
cx, cy = d["centerX"], d["centerY"]
prev = by_label.setdefault(label, [])
for pcx, pcy in prev:
assert not (
abs(cx - pcx) < _DUP_THRESHOLD and abs(cy - pcy) < _DUP_THRESHOLD
), f"near-duplicate centers for label {label!r}: ({pcx},{pcy}) vs ({cx},{cy})"
prev.append((cx, cy))
@pytest.mark.slow
def test_ft_p04_p16_gsd_tiling_and_deduplication(image_detect, image_large, warm_engine):
# Assert
body, _ = image_detect(
image_large, "img.jpg",
config=json.dumps({**_GSD, "big_image_tile_overlap_percent": 20}),
timeout=_TILING_TIMEOUT,
)
assert isinstance(body, list)
_assert_coords_normalized(body)
_assert_no_same_label_near_duplicate_centers(body)