'commit'
This commit is contained in:
@@ -20,6 +20,34 @@ class ReadImageKit:
|
||||
def __init__(self):
|
||||
self.vlm = VLMKit()
|
||||
|
||||
async def find_price_entrance_vlm(self, image_path):
|
||||
"""
|
||||
使用 VLM 在详情页寻找价格入口(如:1.1556元/度 的卡片或价格信息按钮)
|
||||
"""
|
||||
prompt = """
|
||||
分析这张充电站详情页截图,找到进入“分时电价详情”的点击入口。
|
||||
入口特征:
|
||||
1. 包含价格数字的卡片,例如 "1.1556元/度"。
|
||||
2. 或者标有 "价格信息"、"电价详情" 字样的按钮。
|
||||
|
||||
请判断该入口是否存在,并给出其中心坐标。
|
||||
输出格式为 JSON:
|
||||
{
|
||||
"found": true/false,
|
||||
"reason": "为什么认为这是入口",
|
||||
"point": [x, y], // 归一化坐标 [0-1000],例如 [500, 600] 代表屏幕中心偏下
|
||||
"type": "price_card" / "button"
|
||||
}
|
||||
"""
|
||||
try:
|
||||
res_text = await self.vlm.analyze_image(image_path, prompt)
|
||||
json_str = self.vlm.extract_json(res_text)
|
||||
data = json.loads(json_str)
|
||||
return data
|
||||
except Exception as e:
|
||||
logger.error(f"VLM 寻找价格入口失败: {e}")
|
||||
return {"found": False}
|
||||
|
||||
async def analyze_detail_price(self, image_path):
|
||||
"""
|
||||
分析详情页截图,提取电价信息,包括优惠价、PLUS价和挂牌价
|
||||
|
||||
Reference in New Issue
Block a user