'commit'
This commit is contained in:
@@ -10,7 +10,7 @@ if project_root not in sys.path:
|
||||
sys.path.append(project_root)
|
||||
|
||||
from Util.VLMKit import VLMKit
|
||||
from Apps.TeLaiDian.Kit import draw_rectangles, detect_cards_cv, setup_logger, read_image
|
||||
from Apps.TeLaiDian.Kit import draw_rectangles, detect_cards_cv, setup_logger, read_image, detect_wide_rounded_card_cv
|
||||
from Apps.TeLaiDian.Config.Setting import SAFE_EXCLUDE_RATIO, BOTTOM_SAFE_EXCLUDE_RATIO
|
||||
|
||||
# 初始化日志
|
||||
@@ -40,6 +40,17 @@ class ReadImageKit:
|
||||
}
|
||||
"""
|
||||
try:
|
||||
cv_bboxes = detect_wide_rounded_card_cv(image_path, min_width_ratio=0.8, min_y_ratio=0.5)
|
||||
if cv_bboxes:
|
||||
img = read_image(image_path)
|
||||
if img is not None:
|
||||
h, w = img.shape[:2]
|
||||
bx1, by1, bx2, by2 = cv_bboxes[0]
|
||||
cx = (bx1 + bx2) // 2
|
||||
cy = (by1 + by2) // 2
|
||||
draw_rectangles(image_path, bboxes=[cv_bboxes[0]], click_points=[[cx, cy]])
|
||||
return {"found": True, "reason": "cv", "point": [int(cx * 1000 / w), int(cy * 1000 / h)], "type": "price_card"}
|
||||
|
||||
res_text = await self.vlm.analyze_image(image_path, prompt)
|
||||
json_str = self.vlm.extract_json(res_text)
|
||||
data = json.loads(json_str)
|
||||
|
||||
Reference in New Issue
Block a user