Merge:'feat/Agent-RedDot'| 专用红点识别器替代模板#294
Conversation
(cherry picked from commit df96a84)
初步测试较为优秀。 HIGHLIGHT:红点特征识别,稳健性极高,且高度复用。
1280/1281:隐式Rec=SubName已被废止,声明子识别会被忽略。
📝 WalkthroughWalkthrough新增模块级 HSV 工具与连通域标注;在 agent/recognition/binarymatch.py 中实现 RedDotDetector 自定义识别器;在多个 pipeline JSON 中将模板/颜色识别替换为 RedDotDetector 或复合识别,并新增预设与全局识别节点。 走查PR 实现了基于 HSV 的红点检测自定义识别器 RedDotDetector,通过模块级工具函数替换原有的 HSVShapeMatching 类方法,并将游戏全流程的红点识别方式从模板匹配统一迁移到该新识别器,同时大幅重构流程节点的识别条件与控制逻辑,采用复合识别(And/Or)和节点引用模式以降低配置重复性。 变更红点检测器核心实现
预设配置与全局识别节点
游戏流水线识别迁移(示例)
评估🎯 4 (Complex) | ⏱️ ~60 分钟 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Reviewer's Guide基于 HSV 颜色 + 拓扑分析,引入独立的 RedDotDetector 自定义识别器,将通用 HSV 工具函数从 HSVShapeMatching 中抽取为模块级辅助方法,并更新 pipeline JSON 定义以支持新的 OCR/场景识别以及红色检测。 RedDotDetector analyze 预设模式 vs 独立流水线的流程图flowchart TD
A[analyze] --> B{params contains preset}
B -- yes --> C[_run_preset]
C --> D[context.run_recognition preset_node]
D --> E{detail and detail.hit}
E -- yes --> F[adjust box with roi offset]
F --> G[return AnalyzeResult]
E -- no --> H[return None]
B -- no --> I[_run_standalone]
I --> J[read hsv_ranges, red_area, inner_v_min, inner_s_max, gap_ratio]
J --> K[apply roi to argv.image]
K --> L[convert work_bgr to HSV]
L --> M[_compute_hsv_mask]
M --> N[_label_blobs on red_mask]
N --> O{for each blob in area range}
O --> P[compute blob bbox]
P --> Q[extract box_red, box_hsv]
Q --> R[_label_blobs on non_red_crop]
R --> S[compute enclosed & inner_bright]
S --> T{any inner_bright pixels}
T -- no --> O
T -- yes --> U[_has_exclamation]
U --> V{has exclamation}
V -- no --> O
V -- yes --> W[compose result_box with roi offset]
W --> X[return AnalyzeResult]
O -->|no more blobs| Y[return None]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your Experience访问你的 dashboard 以:
Getting HelpOriginal review guide in EnglishReviewer's GuideIntroduces a dedicated RedDotDetector custom recognizer based on HSV color + topology analysis, factors common HSV utilities out of HSVShapeMatching into module‑level helpers, and updates pipeline JSON definitions to support new OCR/scene recognition and red-color checks. Flow diagram for RedDotDetector analyze preset vs standalone pipelineflowchart TD
A[analyze] --> B{params contains preset}
B -- yes --> C[_run_preset]
C --> D[context.run_recognition preset_node]
D --> E{detail and detail.hit}
E -- yes --> F[adjust box with roi offset]
F --> G[return AnalyzeResult]
E -- no --> H[return None]
B -- no --> I[_run_standalone]
I --> J[read hsv_ranges, red_area, inner_v_min, inner_s_max, gap_ratio]
J --> K[apply roi to argv.image]
K --> L[convert work_bgr to HSV]
L --> M[_compute_hsv_mask]
M --> N[_label_blobs on red_mask]
N --> O{for each blob in area range}
O --> P[compute blob bbox]
P --> Q[extract box_red, box_hsv]
Q --> R[_label_blobs on non_red_crop]
R --> S[compute enclosed & inner_bright]
S --> T{any inner_bright pixels}
T -- no --> O
T -- yes --> U[_has_exclamation]
U --> V{has exclamation}
V -- no --> O
V -- yes --> W[compose result_box with roi offset]
W --> X[return AnalyzeResult]
O -->|no more blobs| Y[return None]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - 我发现了两个问题,并给出了一些整体反馈:
- 在
_label_blobs中使用了deque,但在当前 diff 中没有看到相应的导入;请确认在模块级别添加from collections import deque(或等效导入),以避免运行时出现 NameError。 - 在
RedDotDetector._run_preset和_run_standalone中,你使用了裸print来输出命中日志;为了与模块其他部分保持一致并更好地控制日志输出,建议改用mfaalog.debug/info等日志函数。
给 AI Agent 的提示
Please address the comments from this code review:
## Overall Comments
- In `_label_blobs` you use `deque` but there is no corresponding import in the shown diff; ensure `from collections import deque` (or equivalent) is present at module level to avoid a runtime NameError.
- In `RedDotDetector._run_preset` and `_run_standalone` you use bare `print` for hit logs; for consistency with the rest of the module and better log control, consider replacing these with `mfaalog.debug/info` calls.
## Individual Comments
### Comment 1
<location path="agent/recognition/binarymatch.py" line_range="620-622" />
<code_context>
+ print(f"[RedDotDetector] [preset:{preset_node}] 命中 → {adjusted}")
</code_context>
<issue_to_address>
**suggestion:** 避免使用裸 `print` 进行日志输出,请改用已有的日志设施。
使用 `print` 会创建一个未配置的日志通道,绕过我们的日志配置,并可能在生产环境中过度输出到 stdout。请通过 `mfaalog`(例如 `mfaalog.info`/`debug`)来记录日志,以保持一致性并实现集中控制。
```suggestion
adjusted = (bx + rx, by + ry, bw, bh)
mfaalog.debug(f"[RedDotDetector] [preset:{preset_node}] 命中 → {adjusted}")
return CustomRecognition.AnalyzeResult(box=adjusted, detail={"preset": preset_node})
```
</issue_to_address>
### Comment 2
<location path="agent/recognition/binarymatch.py" line_range="606-611" />
<code_context>
+ """
+ preset_node = params["preset"]
+ roi = argv.roi
+ if roi is not None:
+ rx, ry, rw, rh = roi.x, roi.y, roi.w, roi.h
+ else:
+ rx = ry = rw = rh = 0
+
+ if rw > 0 and rh > 0:
+ cropped = argv.image[ry:ry + rh, rx:rx + rw]
+ else:
</code_context>
<issue_to_address>
**issue:** 建议将 ROI 坐标限制在图像边界内,以避免出现负数或越界索引。
由于 `_run_preset` 和 `_run_standalone` 使用 `ry:ry+rh` / `rx:rx+rw` 对 `argv.image` 进行切片,如果从 JSON 中加载的 ROI 含有负值或超出尺寸的数值,将会依赖 NumPy 的索引环绕/截断行为,这可能导致隐蔽的误检测。将 `rx, ry, rw, rh` 约束在 `[0, w/h]` 范围后再进行切片(并在裁剪结果为空时及早返回)会让这种行为更加明确且更安全。
</issue_to_address>帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据这些反馈改进之后的 Review。
Original comment in English
Hey - I've found 2 issues, and left some high level feedback:
- In
_label_blobsyou usedequebut there is no corresponding import in the shown diff; ensurefrom collections import deque(or equivalent) is present at module level to avoid a runtime NameError. - In
RedDotDetector._run_presetand_run_standaloneyou use bareprintfor hit logs; for consistency with the rest of the module and better log control, consider replacing these withmfaalog.debug/infocalls.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `_label_blobs` you use `deque` but there is no corresponding import in the shown diff; ensure `from collections import deque` (or equivalent) is present at module level to avoid a runtime NameError.
- In `RedDotDetector._run_preset` and `_run_standalone` you use bare `print` for hit logs; for consistency with the rest of the module and better log control, consider replacing these with `mfaalog.debug/info` calls.
## Individual Comments
### Comment 1
<location path="agent/recognition/binarymatch.py" line_range="620-622" />
<code_context>
+ print(f"[RedDotDetector] [preset:{preset_node}] 命中 → {adjusted}")
</code_context>
<issue_to_address>
**suggestion:** Avoid using bare `print` for logging and use the existing logging facility instead.
Using `print` creates an unconfigured logging path that bypasses our logging setup and can spam stdout in production. Please route this through `mfaalog` (e.g. `mfaalog.info`/`debug`) for consistency and centralized control.
```suggestion
adjusted = (bx + rx, by + ry, bw, bh)
mfaalog.debug(f"[RedDotDetector] [preset:{preset_node}] 命中 → {adjusted}")
return CustomRecognition.AnalyzeResult(box=adjusted, detail={"preset": preset_node})
```
</issue_to_address>
### Comment 2
<location path="agent/recognition/binarymatch.py" line_range="606-611" />
<code_context>
+ """
+ preset_node = params["preset"]
+ roi = argv.roi
+ if roi is not None:
+ rx, ry, rw, rh = roi.x, roi.y, roi.w, roi.h
+ else:
+ rx = ry = rw = rh = 0
+
+ if rw > 0 and rh > 0:
+ cropped = argv.image[ry:ry + rh, rx:rx + rw]
+ else:
</code_context>
<issue_to_address>
**issue:** Consider clamping ROI coordinates to image bounds to avoid negative or out-of-range indexing.
Since `_run_preset` and `_run_standalone` slice `argv.image` with `ry:ry+rh` / `rx:rx+rw`, an ROI loaded from JSON with negative or oversized values will rely on NumPy’s index wrapping/truncation, which can cause subtle mis-detections. Clamping `rx, ry, rw, rh` to `[0, w/h]` before slicing (and early-returning if the clamped crop is empty) would make this behavior explicit and safer.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
There was a problem hiding this comment.
Actionable comments posted: 5
🧹 Nitpick comments (4)
assets/resource/base/pipeline/Global.json (1)
727-744: 💤 Low value红色色相仅覆盖单段 0–10,可能漏检环绕段红色。
HSV 色相空间中红色横跨 0 与 180 两端。本节点
lower:[0,150,230]/upper:[10,255,255]只覆盖低色相段,而同 PR 的RedDot_Preset红色阈值是 0–12 与 165–180 双段。若目标红色文字/背景偏向高色相段,会被漏检。如确认目标红仅落在 0–10,可忽略;否则建议补一段高色相判定(ColorMatch 单节点无法同时覆盖两段,可拆为Or复合两段色核)。🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@assets/resource/base/pipeline/Global.json` around lines 727 - 744, The Sub_Ocr_Red_Clr ColorMatch node only covers red hue 0–10 and may miss red hues near 165–180; update the pipeline so red is matched in both hue ranges by either splitting Sub_Ocr_Red_Clr into two ColorMatch nodes (one for 0–10 and one for 165–180) and combine them with an Or node, or mirror the approach used by RedDot_Preset (dual-range thresholds); ensure the new nodes keep the same roi "OCR", method, connected/count settings and that the combined result replaces the original Sub_Ocr_Red_Clr output.assets/resource/base/pipeline/Daily.json (1)
113-141: ⚡ Quick win建议澄清/清理
Daily_UnionBack的target(不要直接补Click)
Daily_UnionBack未配置action,默认按 DoNothing 执行,因此target: [120, 35]不会触发点击;其返回主页实际依赖next跳转到Global_ToHomePage_Enter/Global_ToHomePage,而Global.json中Global_ToHomePage_HomeButton、Global_ToHomePage_Reset才包含action: "Click"来完成返回。建议删除该无用target(或补注释说明由 Global 承担),避免误加action: "Click"导致重复/误触。🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@assets/resource/base/pipeline/Daily.json` around lines 113 - 141, The Daily_UnionBack node declares a target ([120,35]) but has no action so it defaults to DoNothing and that target is misleading; either remove the target entry or add a comment clarifying that navigation is handled by next -> Global_ToHomePage_Enter/Global_ToHomePage and that the actual Click actions live in Global_ToHomePage_HomeButton and Global_ToHomePage_Reset; do not add action:"Click" here (would duplicate/trigger unintended clicks).agent/recognition/binarymatch.py (2)
621-621: ⚡ Quick win命中日志建议统一走
mfaalog,而非本文件其余位置(含异常、调试图保存)均使用
mfaalog,而预设模式(Line 621)与独立模式(Line 716)的“命中”成功日志却用了♻️ 统一日志
- print(f"[RedDotDetector] [preset:{preset_node}] 命中 → {adjusted}") + mfaalog.info(f"[RedDotDetector] [preset:{preset_node}] 命中 → {adjusted}")- print(f"[RedDotDetector] 命中: box={result_box}, red_area={area}") + mfaalog.info(f"[RedDotDetector] 命中: box={result_box}, red_area={area}")Also applies to: 716-716
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@agent/recognition/binarymatch.py` at line 621, Replace the direct print calls that log hits with the project logger: change the print in the RedDotDetector hit path (the statement printing f"[RedDotDetector] [preset:{preset_node}] 命中 → {adjusted}") and the similar print in the independent mode branch to use mfaalog (e.g. mfaalog.info) with the same message/variables so the hit messages go through the standard logging pipeline and retain consistent formatting and levels; keep the message text unchanged and reuse existing mfaalog import/usages in this module for consistency.
617-622: 调整:detail.box的解包大概率是可行的,不应按“重大静默失效”处理公开的 MaaFramework Python 绑定里
Rect表示[x, y, w, h],并且仓库内也已有对box[0]、box[2]这类下标访问的实际用法(如agent/fishing_agent.py),因此把bx, by, bw, bh = detail.box直接认定为Rect不可解包从而导致预设模式“恒返回 None”的判断依据不足。可保留当前写法;仅建议为一致性把红点检测处的 box 访问风格与roi.x/roi.y/roi.w/roi.h(或其它 box 用法)统一。🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@agent/recognition/binarymatch.py` around lines 617 - 622, The current change treats unpacking detail.box as unsafe and causes presets to always return None; instead keep treating detail.box as a Rect and make the access style consistent with the rest of the code: in the RedDotDetector matching block (where detail = context.run_recognition(preset_node, cropped) and you currently use bx, by, bw, bh = detail.box and return CustomRecognition.AnalyzeResult), either retain the tuple unpacking or switch to explicit index access (detail.box[0], detail.box[1], detail.box[2], detail.box[3]) so it matches other usages like roi.x/roi.y/roi.w/roi.h and agent/fishing_agent.py; ensure the adjusted box is constructed the same way (e.g., (bx + rx, by + ry, bw, bh)) and return the AnalyzeResult as before.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@agent/recognition/binarymatch.py`:
- Around line 339-343: The comment's documented default for red_area is
inconsistent with the actual default used in _run_standalone; update the comment
to match the code by changing the red_area default from [50, 1200] to [30,
1200], and optionally mention that _run_standalone reads params.get("red_area",
[30, 1200]) so callers not passing red_area will get 30 as the min; keep
references to hsv_ranges and red_area in the same comment block so readers see
both parameter purposes and the corrected default.
In `@assets/interface.json`:
- Around line 411-436: The "风" and "光" entries have an incorrect nested
pipeline_override: they wrap QuickHunt_StoneSelect_* entries inside
QuickHunt_FastBattleTouch_StoneSelect, which treats them as fields rather than
node overrides; remove the QuickHunt_FastBattleTouch_StoneSelect wrapper so
pipeline_override is a flat mapping keyed directly by node names
(QuickHunt_StoneSelect_Fire, QuickHunt_StoneSelect_Wind for 风 and
QuickHunt_StoneSelect_Fire, QuickHunt_StoneSelect_Light for 光) and set the
correct enabled values (Fire: false, Wind/Light: true) to match the working
pattern used by the "水" and "暗" entries.
In `@assets/resource/base/pipeline/Battle.json`:
- Around line 792-808: The QuickHunt_StoneSelect_Wind node is missing the
"action":"Click" field so it never triggers a click like its siblings
QuickHunt_StoneSelect_Fire/Water/Light/Duck; update the
QuickHunt_StoneSelect_Wind JSON object to include "action": "Click" (placed
after "expected") so that when "风之洞穴" is recognized the automation performs the
click and proceeds, preserving the same behavior described by the node's desc
("圣石选属性.Loc分离").
- Around line 1069-1078: The replace mapping in
QuickHunt_CollectMap_Initialize_Out_Ty2 currently contains a no-op entry
["跡","跡"] which prevents OCR normalization to simplified Chinese; update the
second tuple in the "replace" array for the handler
QuickHunt_CollectMap_Initialize_Out_Ty2 to map "跡" to "迹" (i.e., ["跡","迹"]) so
OCR outputs like "哥布林遺跡" are normalized to "哥布林遗迹" and downstream
match/next/all_of checks (e.g., QuickHunt_CollectMap_Initialize_Out_Ty1,
QuickHunt_CollectMapAdventureRouteDoubleCk2No_ToCentral_CK,
QuickHunt_CrystalCave_End, QuickHunt_CollectMap_SwipLeft,
QuickHunt_CollectMap_SwipNoth) will work correctly.
In `@assets/resource/base/pipeline/Global.json`:
- Around line 877-889: The regex in the Rec_Reward_Ocr entry uses character
classes like [点击画面] which match individual characters rather than the full
phrases; replace those with phrase lookaheads so OCR must contain the full
substrings—for example change the "expected" value to use
(?=.*点击画面)(?=.*即可)(?=.*返回).{4,12}$ (ensure any JSON escaping needed for
backslashes is applied in the file) so the key "Rec_Reward_Ocr" and its
"expected" field require the whole phrases instead of single characters.
---
Nitpick comments:
In `@agent/recognition/binarymatch.py`:
- Line 621: Replace the direct print calls that log hits with the project
logger: change the print in the RedDotDetector hit path (the statement printing
f"[RedDotDetector] [preset:{preset_node}] 命中 → {adjusted}") and the similar
print in the independent mode branch to use mfaalog (e.g. mfaalog.info) with the
same message/variables so the hit messages go through the standard logging
pipeline and retain consistent formatting and levels; keep the message text
unchanged and reuse existing mfaalog import/usages in this module for
consistency.
- Around line 617-622: The current change treats unpacking detail.box as unsafe
and causes presets to always return None; instead keep treating detail.box as a
Rect and make the access style consistent with the rest of the code: in the
RedDotDetector matching block (where detail =
context.run_recognition(preset_node, cropped) and you currently use bx, by, bw,
bh = detail.box and return CustomRecognition.AnalyzeResult), either retain the
tuple unpacking or switch to explicit index access (detail.box[0],
detail.box[1], detail.box[2], detail.box[3]) so it matches other usages like
roi.x/roi.y/roi.w/roi.h and agent/fishing_agent.py; ensure the adjusted box is
constructed the same way (e.g., (bx + rx, by + ry, bw, bh)) and return the
AnalyzeResult as before.
In `@assets/resource/base/pipeline/Daily.json`:
- Around line 113-141: The Daily_UnionBack node declares a target ([120,35]) but
has no action so it defaults to DoNothing and that target is misleading; either
remove the target entry or add a comment clarifying that navigation is handled
by next -> Global_ToHomePage_Enter/Global_ToHomePage and that the actual Click
actions live in Global_ToHomePage_HomeButton and Global_ToHomePage_Reset; do not
add action:"Click" here (would duplicate/trigger unintended clicks).
In `@assets/resource/base/pipeline/Global.json`:
- Around line 727-744: The Sub_Ocr_Red_Clr ColorMatch node only covers red hue
0–10 and may miss red hues near 165–180; update the pipeline so red is matched
in both hue ranges by either splitting Sub_Ocr_Red_Clr into two ColorMatch nodes
(one for 0–10 and one for 165–180) and combine them with an Or node, or mirror
the approach used by RedDot_Preset (dual-range thresholds); ensure the new nodes
keep the same roi "OCR", method, connected/count settings and that the combined
result replaces the original Sub_Ocr_Red_Clr output.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 8eb0b41e-3329-4bb3-8a5f-d384fafbd0bb
⛔ Files ignored due to path filters (18)
.gitignoreis excluded by none and included by noneassets/resource/PC/model/.gitignoreis excluded by none and included by noneassets/resource/base/image/ActiveGe.pngis excluded by!**/*.png,!**/*.pngand included by noneassets/resource/base/image/ActivePeerGe.pngis excluded by!**/*.png,!**/*.pngand included by noneassets/resource/base/image/FreeGacha.pngis excluded by!**/*.png,!**/*.pngand included by noneassets/resource/base/image/GACHA_Free.ReservedRights_Red_GE.pngis excluded by!**/*.png,!**/*.pngand included by noneassets/resource/base/image/GACHA_ListFull2_GE.pngis excluded by!**/*.png,!**/*.pngand included by noneassets/resource/base/image/GACHA_ListFull3.pngis excluded by!**/*.png,!**/*.pngand included by noneassets/resource/base/image/GACHA_ListFull_GE.pngis excluded by!**/*.png,!**/*.pngand included by noneassets/resource/base/image/GACHA_PoolSort.pngis excluded by!**/*.png,!**/*.pngand included by noneassets/resource/base/image/GACHA_Special.ReservedRights_Red_GE.pngis excluded by!**/*.png,!**/*.pngand included by noneassets/resource/base/image/GaChaEquRDGE.pngis excluded by!**/*.png,!**/*.pngand included by noneassets/resource/base/image/Gacha-homepage.pngis excluded by!**/*.png,!**/*.pngand included by noneassets/resource/base/image/MailAtMainRedGe.pngis excluded by!**/*.png,!**/*.pngand included by noneassets/resource/base/image/MailRedPr.pngis excluded by!**/*.png,!**/*.pngand included by noneassets/resource/base/image/MissionsGE.pngis excluded by!**/*.png,!**/*.pngand included by noneassets/resource/base/image/Pass.pngis excluded by!**/*.png,!**/*.pngand included by noneassets/resource/base/image/pass1.pngis excluded by!**/*.png,!**/*.pngand included by none
📒 Files selected for processing (14)
agent/recognition/binarymatch.pyassets/interface.jsonassets/resource/base/pipeline/Activities.jsonassets/resource/base/pipeline/Battle.jsonassets/resource/base/pipeline/Daily.jsonassets/resource/base/pipeline/Dummy.jsonassets/resource/base/pipeline/GACHA.jsonassets/resource/base/pipeline/GACHA_ADV.jsonassets/resource/base/pipeline/Global.jsonassets/resource/base/pipeline/Mail.jsonassets/resource/base/pipeline/Pass.jsonassets/resource/base/pipeline/QuestList.jsonassets/resource/base/pipeline/StartGame.jsonassets/resource/base/pipeline/Test.json
There was a problem hiding this comment.
🧹 Nitpick comments (2)
agent/recognition/binarymatch.py (2)
566-623: 💤 Low value建议统一使用
mfaalog替代print()Line 621 使用
print()输出命中信息,与文件其他位置使用mfaalog.info()/mfaalog.debug()风格不一致。生产环境下print()输出可能不会被日志系统捕获。♻️ 建议修改
- print(f"[RedDotDetector] [preset:{preset_node}] 命中 → {adjusted}") + mfaalog.info(f"[RedDotDetector] [preset:{preset_node}] 命中 → {adjusted}")🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@agent/recognition/binarymatch.py` around lines 566 - 623, The preset branch in RedDotDetector._run_preset currently logs hits via print(f"[RedDotDetector] [preset:{preset_node}] 命中 → {adjusted}") which is inconsistent with the module logging; replace that print call with an mfaalog logging call (e.g., mfaalog.info or mfaalog.debug) and include the same message and variables (preset_node and adjusted) so hits are captured by the logging system.
629-722: 💤 Low value同上,建议统一日志输出方式
Line 716 同样使用
print()而非mfaalog。♻️ 建议修改
- print(f"[RedDotDetector] 命中: box={result_box}, red_area={area}") + mfaalog.info(f"[RedDotDetector] 命中: box={result_box}, red_area={area}")🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@agent/recognition/binarymatch.py` around lines 629 - 722, The final hit logging in _run_standalone uses print(...) instead of the project's logger; replace the print call inside _run_standalone that outputs "[RedDotDetector] 命中: box=..." with a mfaalog logging call (e.g., mfaalog.info or mfaalog.debug to match surrounding messages) and include the same context (result_box and red area) in the formatted log string so it follows the same logging conventions as the other messages in this function.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@agent/recognition/binarymatch.py`:
- Around line 566-623: The preset branch in RedDotDetector._run_preset currently
logs hits via print(f"[RedDotDetector] [preset:{preset_node}] 命中 → {adjusted}")
which is inconsistent with the module logging; replace that print call with an
mfaalog logging call (e.g., mfaalog.info or mfaalog.debug) and include the same
message and variables (preset_node and adjusted) so hits are captured by the
logging system.
- Around line 629-722: The final hit logging in _run_standalone uses print(...)
instead of the project's logger; replace the print call inside _run_standalone
that outputs "[RedDotDetector] 命中: box=..." with a mfaalog logging call (e.g.,
mfaalog.info or mfaalog.debug to match surrounding messages) and include the
same context (result_box and red area) in the formatted log string so it follows
the same logging conventions as the other messages in this function.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: d7663e83-3263-4a4f-b22d-9c73e1b38b8a
📒 Files selected for processing (1)
agent/recognition/binarymatch.py
Summary by Sourcery
引入专用的红点通知检测器并共享 HSV 工具,同时扩展用于新 UI 状态的 OCR/颜色匹配流水线节点。
新特性:
RedDotDetector自定义识别模块,使用 HSV 与形状/拓扑分析检测带有内部感叹号的红色通知小圆点。增强:
HSVShapeMatching中重构为模块级辅助函数,以便其他检测器复用。Original summary in English
Summary by Sourcery
Introduce a dedicated red-dot notification detector and share HSV utilities while expanding OCR/color-match pipeline nodes for new UI states.
New Features:
Enhancements:
Summary by CodeRabbit
发布说明
新功能
功能优化
功能调整