'commit'
This commit is contained in:
@@ -9,7 +9,7 @@ import logging
|
||||
import base64
|
||||
from openai import AsyncOpenAI, BadRequestError
|
||||
from Apps.XinDianTu.Kit import (
|
||||
read_image, save_image, detect_rabbit_ad_close
|
||||
read_image, save_image, detect_rabbit_ad_close, detect_price_info_container_cv
|
||||
)
|
||||
from Config.Config import (
|
||||
ALY_LLM_API_KEY, VL_MODEL_NAME, VL_MODEL_NAME_AD, TEMP_IMAGE_DIR
|
||||
@@ -77,6 +77,28 @@ class ReadImageKit:
|
||||
"严格返回纯JSON格式。"
|
||||
)
|
||||
|
||||
@classmethod
|
||||
async def find_price_entrance_ocr(cls, image_path):
|
||||
"""
|
||||
使用 OCR 在详情页寻找价格入口 (全部时段 >)
|
||||
"""
|
||||
container_norm = detect_price_info_container_cv(image_path)
|
||||
if container_norm:
|
||||
# 找到矩形框 [x1, y1, x2, y2]
|
||||
x1, y1, x2, y2 = container_norm
|
||||
# 计算中心点
|
||||
center_x = (x1 + x2) // 2
|
||||
center_y = (y1 + y2) // 2
|
||||
|
||||
return {
|
||||
"found": True,
|
||||
"reason": "OCR 精准定位到价格入口关键字 '全部时段'",
|
||||
"point": [center_x, center_y]
|
||||
}
|
||||
|
||||
logger.warning(f"⚠️ [OCR识别失败] 在图片中未发现价格入口关键字 (全部时段): {image_path}")
|
||||
return {"found": False}
|
||||
|
||||
@classmethod
|
||||
async def detect_ad_popup(cls, image_path: str, device_info=None):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user