'commit'
This commit is contained in:
@@ -9,6 +9,7 @@ import uiautomator2 as u2
|
||||
|
||||
from Apps.XinDianTu.Kit import take_screenshot, detect_black_agree_button, detect_any_ad_close, \
|
||||
detect_bottom_close_circle, is_background_dimmed, click_image_template
|
||||
from Apps.XinDianTu.ReadImageKit import ReadImageKit
|
||||
from Config.Config import TEMP_IMAGE_DIR
|
||||
|
||||
# pip install adbutils
|
||||
@@ -87,7 +88,28 @@ async def check_and_close_ad(d):
|
||||
os.remove(screenshot_path)
|
||||
return True
|
||||
|
||||
logger.info(f"本地图形学检测完成,未发现已知广告。")
|
||||
# 3. 视觉大模型检测方案 (VL Model) - 作为兜底
|
||||
logger.info("本地图形学检测未发现广告,尝试调用视觉大模型检测...")
|
||||
try:
|
||||
window_size = d.window_size()
|
||||
device_info = {
|
||||
"width": window_size[0],
|
||||
"height": window_size[1],
|
||||
"productName": d.info.get('productName', 'unknown')
|
||||
}
|
||||
|
||||
ad_result = await ReadImageKit.detect_ad(screenshot_path, device_info=device_info)
|
||||
if ad_result.get("has_ad") and ad_result.get("uia_center_x") is not None:
|
||||
x, y = ad_result["uia_center_x"], ad_result["uia_center_y"]
|
||||
logger.info(f"通过视觉大模型检测到广告关闭按钮: ({x}, {y})")
|
||||
d.click(x, y)
|
||||
if os.path.exists(screenshot_path):
|
||||
os.remove(screenshot_path)
|
||||
return True
|
||||
except Exception as e:
|
||||
logger.error(f"视觉大模型广告检测异常: {e}")
|
||||
|
||||
logger.info(f"本地图形学和 VL 检测完成,未发现已知广告。")
|
||||
|
||||
# 清理本地截图
|
||||
if os.path.exists(screenshot_path):
|
||||
|
||||
Reference in New Issue
Block a user