Skip to content

Commit

Permalink
fix: 修复站点名称文字不一,导致识别不完整
Browse files Browse the repository at this point in the history
  • Loading branch information
Night-stars-1 committed Feb 4, 2025
1 parent 51545ad commit 24aef97
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
4 changes: 2 additions & 2 deletions core/ocr.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
"""
Author: Night-stars-1 nujj1042633805@gmail.com
Date: 2024-04-01 21:40:57
LastEditTime: 2025-02-04 23:04:09
LastEditTime: 2025-02-04 23:40:25
LastEditors: Night-stars-1 nujj1042633805@gmail.com
"""

from pathlib import Path
from typing import Tuple, Union

from loguru import logger
import numpy as np
from cnocr import CnOcr
from loguru import logger
from PIL import Image

from core.image import show_image
Expand Down
15 changes: 8 additions & 7 deletions core/preset/presets.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
Author: Night-stars-1 nujj1042633805@gmail.com
Date: 2024-04-05 17:24:47
LastEditTime: 2025-02-04 23:33:08
LastEditTime: 2025-02-04 23:39:11
LastEditors: Night-stars-1 nujj1042633805@gmail.com
"""

Expand Down Expand Up @@ -81,16 +81,17 @@ def click_station(name: str):
if name == city:
logger.info("已在目标站点")
return STATION(True, is_destine=True)
# 点击地图
input_tap((1201, 666))
# 等待地图打开
time.sleep(0.5)
wait_static(threshold=6000000)

if name not in STATION_NAME2PNG:
raise ValueError(f"未找到站点 {name} 的图片")
city_differences = STATION_DIFFERENCES.get((city, name))
if city_differences:
# 点击地图
input_tap((1201, 666))
# 等待地图打开
time.sleep(0.5)
wait_static(threshold=6000000)

source_x = 640
source_y = 360
# 如果有路线则进行寻找
Expand Down Expand Up @@ -288,7 +289,7 @@ def get_city():
go_home()
input_tap((1170, 493))
time.sleep(1.0)
reslut = predict(screenshot(), cropped_pos1=(166, 520), cropped_pos2=(470, 560))
reslut = predict(screenshot(), cropped_pos1=(166, 520), cropped_pos2=(470, 600))
if len(reslut) == 0:
raise ValueError("未识别到当前城市")
logger.info(f"当前站点: {reslut[0]['text']}")
Expand Down
4 changes: 2 additions & 2 deletions demo.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
Author: Night-stars-1 nujj1042633805@gmail.com
Date: 2024-04-04 17:56:16
LastEditTime: 2025-02-04 23:21:37
LastEditTime: 2025-02-04 23:36:58
LastEditors: Night-stars-1 nujj1042633805@gmail.com
"""

Expand Down Expand Up @@ -77,4 +77,4 @@

# start()

click_station("修格里城")
click_station("曼德矿场")

0 comments on commit 24aef97

Please sign in to comment.