Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 452810b67a | |||
| 8c46a6ca9b | |||
| d335f866a3 |
@@ -1305,8 +1305,9 @@ class LineShapeMatcher:
|
||||
if t is None:
|
||||
return 1.0
|
||||
h, w = t.shape
|
||||
cx_t = (w - 1) / 2.0
|
||||
cy_t = (h - 1) / 2.0
|
||||
# Coerente con training (center = diag / 2.0, no -1)
|
||||
cx_t = w / 2.0
|
||||
cy_t = h / 2.0
|
||||
|
||||
# Bounding box del template ruotato/scalato attorno a (cx, cy)
|
||||
diag = int(np.ceil(np.hypot(w, h) * scale)) + 8
|
||||
|
||||
+9
-5
@@ -168,7 +168,10 @@ def _draw_matches(scene: np.ndarray, matches: list[Match],
|
||||
if template_gray is not None and matcher is not None:
|
||||
t = template_gray
|
||||
th, tw = t.shape
|
||||
cx_t = (tw - 1) / 2.0; cy_t = (th - 1) / 2.0
|
||||
# Centro template coerente col training: in train si usa
|
||||
# `center = (diag / 2.0, diag / 2.0)` (no -1). Usare (tw-1)/2
|
||||
# introduceva uno shift di 0.5px per template di lato pari.
|
||||
cx_t = tw / 2.0; cy_t = th / 2.0
|
||||
M = cv2.getRotationMatrix2D((cx_t, cy_t), m.angle_deg, m.scale)
|
||||
M[0, 2] += m.cx - cx_t
|
||||
M[1, 2] += m.cy - cy_t
|
||||
@@ -181,10 +184,11 @@ def _draw_matches(scene: np.ndarray, matches: list[Match],
|
||||
warped_mask = cv2.warpAffine(
|
||||
mask_src, M, (W_scene, H_scene),
|
||||
flags=cv2.INTER_NEAREST, borderValue=0)
|
||||
# Erode di spread_radius per scartare la fascia di transizione
|
||||
# bordo che produce gradient spurio
|
||||
er_k = max(3, 2 * matcher.spread_radius + 1)
|
||||
kernel_er = np.ones((er_k, er_k), np.uint8)
|
||||
# Erode minimo (3x3) per togliere SOLO artefatti border-padding
|
||||
# (~1px di bordo nero da warpAffine borderValue=0). Erode piu'
|
||||
# grande spostava visualmente l'edge verso l'interno e creava
|
||||
# apparente "traslazione fissa" rispetto al bordo del pezzo.
|
||||
kernel_er = np.ones((3, 3), np.uint8)
|
||||
warped_mask = cv2.erode(warped_mask, kernel_er)
|
||||
mag, _ = matcher._gradient(warped_gray)
|
||||
if matcher.weak_grad < matcher.strong_grad:
|
||||
|
||||
Reference in New Issue
Block a user