merge: coarse_stride

This commit is contained in:
2026-05-04 15:41:57 +02:00
2 changed files with 88 additions and 11 deletions
+6 -2
View File
@@ -573,6 +573,7 @@ class LineShapeMatcher:
verify_ncc: bool = True,
verify_threshold: float = 0.4,
coarse_angle_factor: int = 2,
coarse_stride: int = 1,
scale_penalty: float = 0.0,
search_roi: tuple[int, int, int, int] | None = None,
) -> list[Match]:
@@ -665,13 +666,16 @@ class LineShapeMatcher:
end = min(n, i + half + 1)
neighbor_map[vi_c] = vi_sorted[start:end]
# Pruning varianti via top-level (parallelizzato) - solo coarse
# Pruning varianti via top-level (parallelizzato) - solo coarse.
# coarse_stride > 1: valuta solo 1 pixel ogni stride, ~stride² speed-up.
cs = max(1, int(coarse_stride))
def _top_score(vi: int) -> tuple[int, float]:
var = self.variants[vi]
lvl = var.levels[min(top, len(var.levels) - 1)]
score = _jit_score_bitmap_rescored(
spread_top, lvl.dx, lvl.dy, lvl.bin, bit_active_top,
bg_cache_top[var.scale],
bg_cache_top[var.scale], stride=cs,
)
return vi, float(score.max()) if score.size else -1.0