'commit'
This commit is contained in:
@@ -102,7 +102,7 @@ class ReadImageKit:
|
||||
@classmethod
|
||||
async def detect_ad_popup(cls, image_path: str, device_info=None):
|
||||
"""
|
||||
使用 VL 模型 + 图形学算法检测是否存在弹窗广告,并返回关闭按钮坐标
|
||||
使用 VL 模型检测是否存在弹窗广告,并返回关闭按钮坐标
|
||||
"""
|
||||
if not os.path.exists(image_path):
|
||||
return None
|
||||
@@ -195,26 +195,6 @@ class ReadImageKit:
|
||||
except Exception as e:
|
||||
logger.error(f"Failed to detect ad popup with VL model: {e}")
|
||||
|
||||
cv_rabbit_point = detect_rabbit_ad_close(image_path, debug_dir=TEMP_IMAGE_DIR)
|
||||
if cv_rabbit_point:
|
||||
logger.info(f">>> 图形学算法捕捉到兔子广告关闭按钮: {cv_rabbit_point}")
|
||||
norm_point = cv_rabbit_point
|
||||
x = int(norm_point[0] * primary_width)
|
||||
y = int(norm_point[1] * primary_height)
|
||||
try:
|
||||
os.makedirs(TEMP_IMAGE_DIR, exist_ok=True)
|
||||
img = Image.open(image_path).convert("RGB")
|
||||
draw = ImageDraw.Draw(img)
|
||||
r = max(6, int(primary_height * 0.012))
|
||||
draw.ellipse((x - r, y - r, x + r, y + r), outline="red", width=4)
|
||||
base = os.path.basename(image_path)
|
||||
debug_path = os.path.join(TEMP_IMAGE_DIR, f"debug_click_{base}")
|
||||
img.save(debug_path)
|
||||
logger.info(f"保存广告关闭按钮点击预览图(CV): {debug_path}")
|
||||
except Exception as e:
|
||||
logger.warning(f"保存广告关闭按钮点击预览图(CV)失败: {e}")
|
||||
return {"x": x, "y": y, "ad_type": "rabbit"}
|
||||
|
||||
return None
|
||||
|
||||
@staticmethod
|
||||
|
||||
Reference in New Issue
Block a user