web UI added and refactoring done

This commit is contained in:
Ayzen
2026-06-06 00:06:30 +03:00
parent 3c30a12d4a
commit af6005d68f
65 changed files with 3630 additions and 4720 deletions
+49
View File
@@ -65,3 +65,52 @@ def gpr_object_rows(collection: ResultCollection) -> np.ndarray:
return centers[:, :3]
return np.zeros((0, 3), dtype=np.float32)
def apply_object_draw_limits(
rows: np.ndarray,
limits: tuple[int, int] | None,
) -> np.ndarray:
"""Apply the object count/top-M drawing rules to already-filtered `[x, z, score]` rows.
`limits` is `(max_detected_objects, draw_top_objects)`, or `None` to disable
(legacy GPR). When more than ``max_detected_objects`` survive, ALL are hidden
(the scene is too cluttered to be meaningful); otherwise the top ``draw_top_objects``
rows are kept (rows arrive already sorted by score descending).
"""
if limits is None or rows.size == 0:
return rows
max_detected_objects, draw_top_objects = limits
if rows.shape[0] > int(max_detected_objects):
return np.zeros((0, rows.shape[1]), dtype=rows.dtype)
return rows[: max(0, int(draw_top_objects))]
def filter_object_rows(
rows: np.ndarray,
*,
min_score: float,
x_bounds: tuple[float, float],
z_bounds: tuple[float, float],
draw_limits: tuple[int, int] | None,
) -> np.ndarray:
"""Filter `[x_m, z_m, score]` object rows for display/broadcast.
Drops non-finite rows, rows below ``min_score`` (the caller passes the mode's own
threshold — a normalized float for coherent GPR, a pair count for legacy GPR; the
comparison is identical either way), and rows outside the visible X/Z window, then
applies ``draw_limits``. Mode-agnostic: all semantics enter through the parameters.
"""
if rows.size == 0:
return rows
x_min, x_max = x_bounds
z_min, z_max = z_bounds
visible_mask = (
np.all(np.isfinite(rows[:, :3]), axis=1)
& (rows[:, 2] >= min_score)
& (rows[:, 0] >= x_min)
& (rows[:, 0] <= x_max)
& (rows[:, 1] >= z_min)
& (rows[:, 1] <= z_max)
)
return apply_object_draw_limits(rows[visible_mask], draw_limits)