Skip to content

feat: 地图定位匹配&附加层显示高价值品位置&其他一些优化 - #1324

Open
9268 wants to merge 49 commits into
ok-oldking:masterfrom
9268:master
Open

feat: 地图定位匹配&附加层显示高价值品位置&其他一些优化#1324
9268 wants to merge 49 commits into
ok-oldking:masterfrom
9268:master

Conversation

@9268

@9268 9268 commented May 31, 2026

Copy link
Copy Markdown

介绍

通过ocr及图像特征匹配,定位玩家所处位置。
通过玩家位置查询周围奇藏&高价值品,通过附加层实时显示在游戏ui上。
可以显示库洛大地图上的路线标点,并追踪路线标点,在小地图上显示追踪点方向

拼接地图脚本、特征提取脚本请参考此仓库:https://github.com/9268/wuwa-map
完整的资源下载(assets.zip):https://github.com/9268/wuwa-map/releases
请将该压缩包解压在项目 assets 目录

高价值物品模式:左键显示介绍,右键标记完成,已完成的在小地图不显示,在大地图透明化
22KI 7A 5JIWX4U LGPWK`O
K)GY ~F(%B8T0VE9_0W9K3N

路径模式:显示特定路径,左键显示位置名,双击追踪目标,右键取消追踪,追踪后可在小地图上显示目标方向
%6C3HEJRBS 1WE146DJPPUY
K}K0(93@P{(G_U(}P)XKC2M

当前完成:

  • 前期准备:高价值品数据采集、地图拼接&预处理、单例测试验证
  • ocr识别坐标
  • 小地图附加层初步实现
  • 大地图附加层初步实现
  • 地图拼接、预处理、特征采集相关脚本整理及发布:https://github.com/9268/wuwa-map
  • 实机确定后续具体使用算法及匹配参数:使用分片sift算法,无需特殊依赖
  • (bugfix)小地图实装地图id定位;修复目前显示其他地图宝箱问题。
  • (bug)大地图物品搜索范围未跟随地图缩放修改
  • (feature)支持显示路线,包括小地图和大地图。
  • (feature)支持从库街区导入已完成的物品,已完成物品不再显示;支持直接触发大地图物品完成,省的再切地图点完成。

待完成:

  • (feature)路径点图标使用路径参数里的图标(当前固定图标)
  • (feature)(待定)路线从url读取或离线部分路线放数据库
  • (feature)(待定)常驻的信息展示(右下角放一个文本区域):锁定的坐标、地图、地图比例,展示追踪目标信息等
  • (feature)快捷键、设置项、操作等细节优化
  • (feature)(待定)已完成物品导入导出,从bbs导入导出
  • (feature)(待定)特征文件分发问题,随ok分发或按钮触发相关资源下载放置 (需要帮助协调)
  • (perf?)大地图比例尺较小时,一定概率无法定位,需要优化特征提取算法
  • more?

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Core Changes

  • Introduced MapOverlayTask for real-time player positioning and high-value item overlays.
  • Added PositionDetector which utilizes OCR to parse coordinates from the game's coordinate UI.
  • Implemented SiftEngine and SurfEngine for feature-based map matching to identify player location when OCR is unavailable (e.g., Big Map view).
  • Added a SQLite-backed overlay system (MapItemOverlay) to render nearby collectibles on the game's minimap.

⚠️ Concerns

  • Manual NPY Serialization: The implementation of _build_npy_bytes and save_npz in common.py manually constructs the NumPy .npy file format. This is brittle and over-complicated; using standard numpy.save with a buffer is safer.
  • OpenCV Contrib Dependency: SurfEngine relies on cv2.xfeatures2d, which is not available in standard opencv-python or opencv-python-headless packages. It requires opencv-contrib-python. Using SURF might cause runtime crashes if the environment isn't strictly controlled.

Code review performed by GOOGLE - gemini-3-flash-preview.

Comment thread src/match_engine/common.py Outdated
Comment thread src/match_engine/surf.py
Comment thread src/task/MapOverlayTask.py
Comment thread src/utils/positionDetector.py
Comment thread src/utils/positionDetector.py

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 核心变更

  • 角色逻辑优化:为 Chisa(千咲)增加了 DPS 模式支持,并优化了支援模式下切换角色后 buff 的保留逻辑。
  • 日常任务流程增强:重构了 DailyTask,使其能够根据配置自动包含“梦魇巢穴”任务(用于完成每日声骸指标或全刷),并优化了菜单导航效率。
  • 稳定性提升:在 AutoRogueTask 中增加了对角色死亡复活的处理,避免流程中断。
  • 配置与国际化:统一了按键配置项名称,并为 GUI 配置增加了图标显示。

⚠️ 注意事项

  • 实例方法篡改:在 DailyTask.py 中使用了动态替换 NightmareNestTask 实例方法的做法(Monkey Patch)。虽然在 finally 中有恢复逻辑,但如果在执行梦魇期间发生掉线,被禁用的 ensure_main 会导致程序失去自我恢复能力。建议长期方案考虑在任务基类中通过参数控制 UI 退出行为。

Verdict: Approve


Code review performed by GOOGLE - gemini-3-flash-preview.

Note: Some line comments were omitted due to technical limitations.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 核心变更

  • 重构特征缓存序列化:删除了手动实现 .npy 文件头和 struct 打包的复杂逻辑,改用标准的 numpy.savez_compressednumpy.load,大幅提升了代码的简洁性和可靠性。
  • 新增 CLI 工具支持:在 common.py 中添加了 extract(特征提取)和 match(匹配测试)两个命令行子命令,方便进行离线数据预处理和算法验证。
  • 兼容性保障:在 load_npz 中实现了双重读取逻辑,优先尝试标准 numpy.load,失败后回退至旧版手动打包格式的读取流程。

⚠️ 注意事项

  • 资源管理:使用 np.load 读取 .npz 文件时未显式关闭,建议使用上下文管理器以避免潜在的文件句柄泄漏。
  • CLI 输出干扰extract 命令将进度日志打印到了 stdout,这会导致最终输出的 JSON 结果无法被直接通过管道解析。

Code review performed by GOOGLE - gemini-3-flash-preview.

Comment thread src/match_engine/common.py Outdated
Comment thread src/match_engine/common.py Outdated
Comment thread src/match_engine/common.py Outdated

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 核心变更

  • 动态比例尺计算:通过单应性矩阵(Homography)计算局部 Jacobian 行列式,实现了大地图缩放时附加层的实时适配 (map_scale)。
  • 坐标平滑处理:引入加权滑动窗口平滑算法 (_smooth_game_center),显著减少了大地图定位时的视觉抖动。
  • 分层过滤逻辑:在数据库查询中增加了 state_id 过滤,解决了“地下”与“地面”物品在大地图上同时显示的逻辑冲突。
  • 匹配质量优化:在 _try_map_match 中增加了对“慢速地图”的权重排序,并对匹配点数量增加了最小阈值限制 (match_count >= 10),提升了误匹配的过滤能力。

Verdict: Approve


Code review performed by GOOGLE - gemini-3-flash-preview.

Comment thread src/task/MapOverlayTask.py Outdated
Comment thread src/task/MapOverlayTask.py Outdated
@9268
9268 marked this pull request as ready for review June 14, 2026 07:59
9268 and others added 4 commits June 14, 2026 16:04
# Conflicts:
#	i18n/es_ES/LC_MESSAGES/ok.mo
#	i18n/es_ES/LC_MESSAGES/ok.po
#	i18n/ja_JP/LC_MESSAGES/ok.mo
#	i18n/ja_JP/LC_MESSAGES/ok.po
#	i18n/ko_KR/LC_MESSAGES/ok.mo
#	i18n/ko_KR/LC_MESSAGES/ok.po
#	i18n/zh_CN/LC_MESSAGES/ok.mo
#	i18n/zh_CN/LC_MESSAGES/ok.po
#	i18n/zh_TW/LC_MESSAGES/ok.mo
#	i18n/zh_TW/LC_MESSAGES/ok.po
# Conflicts:
#	i18n/es_ES/LC_MESSAGES/ok.po
#	i18n/ja_JP/LC_MESSAGES/ok.po
#	i18n/ko_KR/LC_MESSAGES/ok.po
#	i18n/zh_CN/LC_MESSAGES/ok.po
#	i18n/zh_TW/LC_MESSAGES/ok.po

@staticmethod
def load(json_path):
with open(json_path, 'r') as f:
from .params import ParamSet, SURF, SIFT, SIFTGZ, SurfParams, SiftParams, SiftGzParams

def _load_json(path):
with open(path, 'r', encoding='utf-8') as f:
return json.load(f)

def _save_json(path, data):
with open(path, 'w', encoding='utf-8') as f:
return len(sel_kps), h, w

def _cmd_extract(args):
os.makedirs(args.out, exist_ok=True)
print(json.dumps({"error": "--setting and --param-set cannot be used together"}), file=sys.stderr)
sys.exit(1)

png_files = _glob.glob(os.path.join(args.dir, "*.png"))
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
11.8% Duplication on New Code (required ≤ 3%)
C Security Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

9268 added 2 commits August 15, 2026 23:08
# Conflicts:
#	config.py
#	i18n/es_ES/LC_MESSAGES/ok.mo
#	i18n/es_ES/LC_MESSAGES/ok.po
#	i18n/ja_JP/LC_MESSAGES/ok.mo
#	i18n/ja_JP/LC_MESSAGES/ok.po
#	i18n/ko_KR/LC_MESSAGES/ok.mo
#	i18n/ko_KR/LC_MESSAGES/ok.po
#	i18n/zh_CN/LC_MESSAGES/ok.mo
#	i18n/zh_CN/LC_MESSAGES/ok.po
#	i18n/zh_TW/LC_MESSAGES/ok.mo
#	i18n/zh_TW/LC_MESSAGES/ok.po
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants