This commit is contained in:
HuangHai
2026-01-14 10:28:53 +08:00
parent 7080584e2c
commit d4a0065f8a
2 changed files with 14 additions and 5 deletions

View File

@@ -10,7 +10,7 @@ if project_root not in sys.path:
sys.path.append(project_root)
from Util.VLMKit import VLMKit
from Apps.TeLaiDian.Kit import draw_rectangles, detect_cards_cv, setup_logger
from Apps.TeLaiDian.Kit import draw_rectangles, detect_cards_cv, setup_logger, read_image
from Apps.TeLaiDian.Config.Setting import SAFE_EXCLUDE_RATIO, BOTTOM_SAFE_EXCLUDE_RATIO
# 初始化日志
@@ -224,16 +224,25 @@ class ReadImageKit:
for res in vlm_list:
p = res.get("point")
if p and len(p) == 2:
# 如果坐标小于 1000认为是归一化坐标需要转换
# 1. 坐标转换逻辑
actual_p = p
if p[0] <= 1000 and p[1] <= 1000:
if w == 0:
import cv2
img = cv2.imread(image_path)
img = read_image(image_path)
if img is not None:
h, w = img.shape[:2]
else:
w, h = 1080, 2400 # 兜底
res["point"] = [int(p[0] * w / 1000), int(p[1] * h / 1000)]
actual_p = [int(p[0] * w / 1000), int(p[1] * h / 1000)]
# 2. 坐标安全过滤:忽略页面上半部分的误点击(通常是 Logo 或广告)
# 即使 VLM 没听话,我们也在这里硬性过滤
y_threshold = h * 0.4 if h > 0 else 800
if actual_p[1] < y_threshold:
logger.warning(f"过滤掉可能的误点击点 (y={actual_p[1]} < {y_threshold}): {res.get('name')}")
continue
res["point"] = actual_p
final_stations.append(res)
return final_stations