Appearance
视觉识别插件族
模块登记信息
json
{
"id": "plugins-common.vision",
"domain": "plugins-common",
"name": "视觉识别插件族",
"status": "reviewed",
"owners": [
"packages/controller_plugins/src/controller_plugins/vision/"
],
"related": [
{
"id": "plugins-common.catalog",
"reason": "视觉能力属于公共插件目录之一;总索引见 catalog"
},
{
"id": "desktop.debug-window",
"reason": "调试窗口调用视觉能力;结果表格规则在 debug-window 已核对"
}
]
}职责与边界
提供找图、OCR、组合识别等通用视觉能力,供任务与调试窗口调用。不负责凡修专用回首页等业务插件(见 game_fanxiu_plugins)。不负责调试结果 UI(见 desktop.debug-window)。
功能与规则
- 插件目录(已核对):须遵守
AGENTS.md「自定义插件目录规则」——功能目录内存放、目录内详细说明、同级PLUGIN_SUMMARY.md与注册顺序一致;新增/移动视觉插件时同步 SUMMARY 与注册。 - 调试展示归属(已核对):调试结果必须用公共结果表格(AGENTS「调试结果展示规则」);实现与核对范围在已 reviewed 的
desktop.debug-window,本卡不实现结果表。 - OCR 引擎(已核对):文字识别只使用随包 ONNX 模型,经 ONNX Runtime 在 CPU 上推理。初始化失败直接让本次识别失败。帧缓存只在图像字节完全一致时命中。
CONTROLLER_OCR_REFINE默认开启扩边复识别,CONTROLLER_OCR_THREADS默认 1(显式正整数优先,不按 CPU 数放大),CONTROLLER_OCR_FRAME_CACHE默认开启。CONTROLLER_OCR_REC_CACHE默认开启引擎内的识别批次缓存,仅复用完整张量内容摘要、形状与类型均相同的解码结果,容量 16;保持原批次顺序、填充宽度及全图检测和复识别。wait_any_text每一轮只识别一次。以上范围见OCR_RECOGNITION.md与tests/test_ocr_engine_selector.py、tests/test_ocr_onnx_engine.py。 - 文字点击计时(已核对):基础
base_text_click()保留布尔结果和原等待逻辑,在last_text_click_metrics记录首次截图至点击返回的分段耗时,通过可选metric_recorder上报。crop_ms单列任务坐标换算、边界检查和区域裁剪,与ocr_ms不重叠;重试和点击前等待计入总耗时,失败、超预算或首次模型加载不标记达标。配置区域的受保护等待另以「区域文字受保护等待」记录同类指标,保存在last_guarded_wait_metrics和返回值metrics,不把等待命中标记为完成点击。计时上下文隔离并吞掉指标接收器异常。测试见tests/test_text_click_pipeline.py、tests/test_ocr_regions.py。真实模型对照见tests/test_ocr_performance.py,只覆盖内存图片回放与模拟点击,不代表 Windows 设备链路已低于 1000 毫秒。 - 任务区域 OCR(已核对):任务层文字查找、等待、点击、候选文字等待和批量文本目标可指定 540×960 基准
region=(左, 上, 右, 下),按本轮完整截图宽高分别换算后裁剪;截图接口和任务全图尺寸不变,命中中心与边界框还原到全图。底层插件region保持实际像素语义。无效或截图内为空的区域报中文错误,区域业务未命中不回退全图查找;点击前复核使用同一区域。验证见tests/test_ocr_regions.py。 - 任务受保护匹配门面(已核对):调用方
controller_tasks.capability_mixin每轮共享一次截图,同一实际区域的目标共享一次 OCR,不同区域和全图分别识别。没有业务区域配置时保留原一次全图 OCR、业务/干扰优先顺序及停止行为。只要业务文本配置区域,步骤明确采用业务优先(含 V2 稳定确认轮次):保留全部业务命中顺序与索引,有命中时跳过干扰,全部未命中才复用原截图完整检查全屏干扰,处理后下一轮重新截图。V2 稳定确认次数、超时和重试间隔不变。验证见tests/test_task_quick_match_targets.py、tests/test_guarded_execution_v2.py、tests/test_ocr_regions.py,不宣称 Windows 设备识别耗时已验证。 - 匹配算法(未宣称已核):阈值、包含或严格匹配、方向优先级和模板路径的其余行为仍待确认;改前读对应插件文档与测试,禁止仅凭目录名推断。有测试覆盖 ≠ 本卡已核对全部算法行为。
验证与待确认
- 已核对范围:插件目录/SUMMARY 规则;调试结果展示归属 debug-window。
- 自动测试候选:
tests/test_ocr_recognition_plugin.py、tests/test_controller_plugins.py(有覆盖但不作为算法全核依据)。 - 人工验收:Windows 下调试找图/OCR;本环境未启动 Qt。
自动索引
本页由
uv run python -m tools.living_docs generate自动生成。请勿手改;人工规则写在模块卡正文。
代码归属
packages/controller_plugins/src/controller_plugins/vision/
归属文件(扫描)
- packages/controller_plugins/src/controller_plugins/vision/init.py
- packages/controller_plugins/src/controller_plugins/vision/composite/init.py
- packages/controller_plugins/src/controller_plugins/vision/composite/matcher.py
- packages/controller_plugins/src/controller_plugins/vision/image_recognition.py
- packages/controller_plugins/src/controller_plugins/vision/ocr/init.py
- packages/controller_plugins/src/controller_plugins/vision/ocr/model_paths.py
- packages/controller_plugins/src/controller_plugins/vision/ocr/ocr_recognition.py
- packages/controller_plugins/src/controller_plugins/vision/ocr/onnx_engine.py
直接依赖
- packages/controller_core/src/controller_core/plugin_runtime/init.py
- packages/controller_plugins/src/controller_plugins/runtime/support.py
- packages/controller_plugins/src/controller_plugins/runtime/telemetry/wait_metrics.py
- packages/controller_plugins/src/controller_plugins/vision/composite/matcher.py
- packages/controller_plugins/src/controller_plugins/vision/image_recognition.py
- packages/controller_plugins/src/controller_plugins/vision/ocr/init.py
- packages/controller_plugins/src/controller_plugins/vision/ocr/model_paths.py
- packages/controller_plugins/src/controller_plugins/vision/ocr/ocr_recognition.py
- packages/controller_plugins/src/controller_plugins/vision/ocr/onnx_engine.py
直接调用方
- packages/controller_plugins/src/controller_plugins/plugin_registry.py
- packages/controller_plugins/src/controller_plugins/vision/init.py
- packages/controller_plugins/src/controller_plugins/vision/composite/init.py
- packages/controller_plugins/src/controller_plugins/vision/ocr/init.py
- packages/controller_plugins/src/controller_plugins/vision/ocr/ocr_recognition.py
- packages/controller_plugins/src/controller_plugins/vision/ocr/onnx_engine.py
- packages/controller_tasks/src/controller_tasks/capability_mixin.py
- packages/game_fanxiu/src/game_fanxiu/runtime/common_entry.py
- packages/game_fanxiu/src/game_fanxiu/runtime/native_ops_adapter.py
- packages/game_fanxiu/src/game_fanxiu/runtime/purchase.py
- tests/test_common_entry.py
- tests/test_controller_plugins.py
- tests/test_image_scale_and_batch_matching.py
- tests/test_ocr_engine_selector.py
- tests/test_ocr_onnx_engine.py
- tests/test_ocr_performance.py
- tests/test_ocr_recognition_plugin.py
- tests/test_ocr_regions.py
- tests/test_task_quick_match_targets.py
- tests/test_text_click_pipeline.py
关联测试候选
以下按导入链与命名启发推导,可能扩大范围;需阅读测试断言确认覆盖。
- tests/test_common_entry.py
- tests/test_controller_plugins.py
- tests/test_image_scale_and_batch_matching.py
- tests/test_ocr_engine_selector.py
- tests/test_ocr_onnx_engine.py
- tests/test_ocr_performance.py
- tests/test_ocr_recognition_plugin.py
- tests/test_ocr_regions.py
- tests/test_task_quick_match_targets.py
- tests/test_text_click_pipeline.py