mirror of
https://github.com/azaion/detections.git
synced 2026-04-22 08:46:32 +00:00
8baa96978b
- Updated the detection image endpoint to require a channel ID for event streaming. - Introduced a new endpoint for streaming detection events, allowing clients to receive real-time updates. - Enhanced the internal buffering mechanism for detection events to manage multiple channels. - Refactored the inference module to support the new event handling structure. Made-with: Cursor
50 lines
1.4 KiB
Python
50 lines
1.4 KiB
Python
import json
|
|
|
|
import pytest
|
|
|
|
_TILING_TIMEOUT = 120
|
|
_GSD = {"altitude": 400, "focal_length": 24, "sensor_width": 23.5}
|
|
_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_p_04_gsd_based_tiling_ac1(image_detect, image_large, warm_engine):
|
|
body, _ = image_detect(
|
|
image_large, "img.jpg",
|
|
config=json.dumps(_GSD),
|
|
timeout=_TILING_TIMEOUT,
|
|
)
|
|
assert isinstance(body, list)
|
|
_assert_coords_normalized(body)
|
|
|
|
|
|
@pytest.mark.slow
|
|
def test_ft_p_16_tile_boundary_deduplication_ac2(image_detect, image_large, warm_engine):
|
|
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_no_same_label_near_duplicate_centers(body)
|