fix: robustezza web/gui/legacy (lock matcher, LRU cache, clamp ROI, overlay)
- server: lock globale matcher (race nel threadpool FastAPI), LRU su _IMG_CACHE e _RECIPE_MATCHERS (leak), clamp ROI in tutti gli endpoint (400/422 invece di crash 500, check train senza varianti), filtro_fp=off disabilita davvero il verify NCC, fallback FILTRO_FP_MAP = medio, verify_threshold ricetta allineato a 0.4, _draw_matches su crop locale (era warp+Sobel full-frame per ogni match), spread_radius default 5->4 - gui: centro overlay edge (W-1)/2 -> W/2 (coerenza col train), spread_radius 5->4 - matcher legacy: _angle_list include estremo, cap candidati top-level, save/load persiste template_gray - auto_tune: ref centrato fuori dal loop angoli - test_suite: check imread con errore chiaro Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
+7
-3
@@ -196,8 +196,10 @@ def _warp_template_edges_to_scene(
|
||||
edge = cv2.Canny(template_gray, canny_low, canny_high)
|
||||
# Matrice affine: scala + rotazione attorno al centro template, poi traslazione
|
||||
Ht, Wt = h, w
|
||||
cx_t = (Wt - 1) / 2.0
|
||||
cy_t = (Ht - 1) / 2.0
|
||||
# Centro coerente con la convenzione train (center = w / 2.0, no -1):
|
||||
# (Wt-1)/2 introduceva uno shift di 0.5px per template di lato pari.
|
||||
cx_t = Wt / 2.0
|
||||
cy_t = Ht / 2.0
|
||||
M = cv2.getRotationMatrix2D((cx_t, cy_t), angle_deg, scale)
|
||||
# Traslazione per portare centro template a (cx, cy) della scena
|
||||
M[0, 2] += cx - cx_t
|
||||
@@ -492,7 +494,9 @@ def run(
|
||||
num_features: int = 96,
|
||||
weak_grad: float = 30.0,
|
||||
strong_grad: float = 60.0,
|
||||
spread_radius: int = 5,
|
||||
# 4 allineato col default del matcher: raggio 5 peggiora la precisione
|
||||
# di rotazione (spread troppo largo appiattisce il picco angolare).
|
||||
spread_radius: int = 4,
|
||||
pyramid_levels: int = 3,
|
||||
min_score: float = 0.55,
|
||||
max_matches: int = 25,
|
||||
|
||||
Reference in New Issue
Block a user