fix: template matching sur fenêtre active + seuil 0.90
Template matching des icônes limité à la fenêtre active (window.png) pour éviter les faux positifs sur le full screen. Seuil relevé de 0.70 à 0.90. Coordonnées fenêtre converties en coordonnées écran. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -5200,14 +5200,31 @@ def _resolve_target_sync(
|
||||
return grounding_result
|
||||
|
||||
if not by_text_strict or by_text_source != "ocr":
|
||||
# Template matching sur la fenêtre active si disponible (évite les faux positifs)
|
||||
window_capture = target_spec.get("window_capture", {})
|
||||
window_rect = window_capture.get("rect")
|
||||
from pathlib import Path as _Path
|
||||
_full = _Path(screenshot_path)
|
||||
_win = _full.parent / _full.name.replace("_full.png", "_window.png")
|
||||
tm_path = str(_win) if _win.is_file() and window_rect else screenshot_path
|
||||
tm_screen_w = (window_rect[2] - window_rect[0]) if window_rect and _win.is_file() else screen_width
|
||||
tm_screen_h = (window_rect[3] - window_rect[1]) if window_rect and _win.is_file() else screen_height
|
||||
|
||||
result = _resolve_by_template_matching(
|
||||
screenshot_path=screenshot_path,
|
||||
screenshot_path=tm_path,
|
||||
anchor_image_b64=anchor_image_b64,
|
||||
screen_width=screen_width,
|
||||
screen_height=screen_height,
|
||||
confidence_threshold=0.70,
|
||||
screen_width=tm_screen_w,
|
||||
screen_height=tm_screen_h,
|
||||
confidence_threshold=0.90,
|
||||
)
|
||||
if result and result.get("score", 0) >= 0.70:
|
||||
if result and result.get("score", 0) >= 0.90:
|
||||
x_tm, y_tm = result["x_pct"], result["y_pct"]
|
||||
# Convertir coordonnées fenêtre → écran si nécessaire
|
||||
if window_rect and _win.is_file():
|
||||
abs_x = window_rect[0] + x_tm * tm_screen_w
|
||||
abs_y = window_rect[1] + y_tm * tm_screen_h
|
||||
result["x_pct"] = round(abs_x / screen_width, 6)
|
||||
result["y_pct"] = round(abs_y / screen_height, 6)
|
||||
logger.info(
|
||||
"Strict resolve TEMPLATE : icon match (score=%.3f)",
|
||||
result.get("score", 0),
|
||||
|
||||
Reference in New Issue
Block a user