'commit'
This commit is contained in:
@@ -179,37 +179,6 @@ class ReadImageKit:
|
||||
logger.warning(f"[OCR] 未能在顶部区域定位到‘价格’标签")
|
||||
return {"found": False}
|
||||
|
||||
async def find_price_tab_ocr(self, image_path):
|
||||
"""
|
||||
使用 OCR 在详情页寻找顶部“价格”标签
|
||||
"""
|
||||
img = read_image(image_path)
|
||||
if img is None:
|
||||
return {"found": False}
|
||||
h, w = img.shape[:2]
|
||||
|
||||
from Util.EasyOcrKit import get_easyocr_reader
|
||||
reader = get_easyocr_reader(gpu=True)
|
||||
|
||||
# 顶部标签栏通常在屏幕上部 10%-30% 区域
|
||||
# 我们先识别所有文字,然后过滤出“价格”
|
||||
results = reader.read_text(img)
|
||||
for (quad, text, prob) in results:
|
||||
if "价格" in text and prob > 0.3:
|
||||
# 获取中心点
|
||||
rect = reader.get_normalized_rect(quad, w, h)
|
||||
center_x = (rect[0] + rect[2]) // 2
|
||||
center_y = (rect[1] + rect[3]) // 2
|
||||
|
||||
# 校验位置:必须在屏幕上半部分
|
||||
if center_y < 500:
|
||||
logger.info(f"[OCR] 找到顶部价格标签: '{text}', 置信度: {prob:.4f}, 坐标: [{center_x}, {center_y}]")
|
||||
return {
|
||||
"found": True,
|
||||
"point": [center_x, center_y]
|
||||
}
|
||||
|
||||
return {"found": False}
|
||||
|
||||
async def find_price_entrance_ocr(self, image_path):
|
||||
"""
|
||||
@@ -239,7 +208,8 @@ class ReadImageKit:
|
||||
"point": [center_x, center_y]
|
||||
}
|
||||
|
||||
logger.warning(f"[OCR] 未能在页面中定位到‘全部时段’")
|
||||
# 记录警告日志
|
||||
logger.warning(f"⚠️ [OCR识别失败] 在图片中未发现‘全部时段’关键字: {image_path}")
|
||||
return {"found": False}
|
||||
|
||||
async def find_close_button_vlm(self, image_path):
|
||||
@@ -424,18 +394,31 @@ class ReadImageKit:
|
||||
|
||||
async def analyze_detail_basic_info(self, image_path):
|
||||
"""
|
||||
分析详情页首屏截图,提取场站名称和精确地址
|
||||
分析详情页首屏截图,提取场站名称、精确地址以及电桩状态信息
|
||||
"""
|
||||
prompt = """
|
||||
分析这张充电站详情页首屏截图,提取:
|
||||
1. 场站名称 (通常在页面中部,大字体)
|
||||
2. 详细地址 (通常在名称下方或页面下半部分,伴有地址图标)
|
||||
3. 电桩状态信息:寻找包含“快充”、“慢充”、“空闲”、“总数”或类似描述的区域。
|
||||
- 提取快充桩的总数和空闲数
|
||||
- 提取慢充桩的总数和空闲数
|
||||
- 计算总桩数 (total_piles) 和总空闲数 (free_piles)
|
||||
4. 停车费信息:寻找“停车费”、“停车减免”、“免费停车”等相关描述。
|
||||
|
||||
输出格式为 JSON:
|
||||
{
|
||||
"name": "xxx充电站",
|
||||
"address": "xxx省xxx市xxx区xxx路xxx号"
|
||||
"address": "xxx省xxx市xxx区xxx路xxx号",
|
||||
"total_piles": 10,
|
||||
"free_piles": 5,
|
||||
"piles_detail": [
|
||||
{"type": "快充", "total": 6, "free": 3},
|
||||
{"type": "慢充", "total": 4, "free": 2}
|
||||
],
|
||||
"parking_info": "前2小时免费,之后5元/小时"
|
||||
}
|
||||
注意:如果无法确定某个数值,请设为 null。
|
||||
"""
|
||||
try:
|
||||
res_text = await self.vlm.analyze_image(image_path, prompt)
|
||||
|
||||
Reference in New Issue
Block a user