Skip to content

fix: 修复 And 识别器引用多结果 ROI 时 Or 子识别未按候选框短路的问题 fix #1313#1349

Open
overflow65537 wants to merge 2 commits into
mainfrom
fix/AndReco
Open

fix: 修复 And 识别器引用多结果 ROI 时 Or 子识别未按候选框短路的问题 fix #1313#1349
overflow65537 wants to merge 2 commits into
mainfrom
fix/AndReco

Conversation

@overflow65537
Copy link
Copy Markdown
Member

@overflow65537 overflow65537 commented May 30, 2026

Summary by Sourcery

改进复合识别逻辑,以正确处理带有 ROI 依赖的 AND/OR 组合,以及推测性子识别结果缓存。

Bug Fixes:

  • 修复 AND 识别器:当某个子识别返回多个候选 ROI 时,后续的 OR 子识别仍能正确进行短路,而不会将失败分支的结果泄漏到运行时缓存中。

Enhancements:

  • 抽取通用的子识别执行逻辑为可复用的辅助函数,由 AND 和 OR 组合器共同使用。
  • 引入对识别参数的递归分析,以检测依赖特定 ROI 目标的嵌套 AND/OR 子识别,从而在 AND 分支中更好地指导候选框的传递。
  • 添加带显式刷新机制的推测性子识别结果缓冲,避免将失败 AND 分支的中间结果写入正式缓存,同时仍能登记成功子节点的详细结果。
Original summary in English

Summary by Sourcery

Improve composite recognition logic to correctly handle AND/OR combinations with ROI dependencies and speculative sub-recognition caching.

Bug Fixes:

  • Fix AND recognizer so that when a sub-recognition returns multiple candidate ROIs, subsequent OR sub-recognitions still short-circuit correctly without leaking failed branch results into the runtime cache.

Enhancements:

  • Factor out shared sub-recognition execution into a reusable helper used by both AND and OR combinators.
  • Introduce recursive analysis of recognition parameters to detect nested AND/OR sub-recognitions that depend on specific ROI targets, guiding candidate box propagation in AND branches.
  • Add speculative sub-recognition result buffering with explicit flushing to avoid committing intermediate results from failed AND branches while still registering successful sub-node details.

Bug 修复:

  • 确保 And 识别器在某个子识别返回多个候选 ROI 时,能够正确评估各分支,同时在包含 Or 子识别和 ROI 依赖关系的情况下,仍然保持短路求值行为。

增强功能:

  • 提取通用的子识别调用逻辑到一个共享的辅助方法中,由 And 和 Or 组合器共同使用。
  • 引入对识别参数的递归分析,以检测嵌套的 And/Or 子识别之间的 ROI 目标依赖关系,从而防止错误的候选框传播。
Original summary in English

Summary by Sourcery

改进复合识别逻辑,以正确处理带有 ROI 依赖的 AND/OR 组合,以及推测性子识别结果缓存。

Bug Fixes:

  • 修复 AND 识别器:当某个子识别返回多个候选 ROI 时,后续的 OR 子识别仍能正确进行短路,而不会将失败分支的结果泄漏到运行时缓存中。

Enhancements:

  • 抽取通用的子识别执行逻辑为可复用的辅助函数,由 AND 和 OR 组合器共同使用。
  • 引入对识别参数的递归分析,以检测依赖特定 ROI 目标的嵌套 AND/OR 子识别,从而在 AND 分支中更好地指导候选框的传递。
  • 添加带显式刷新机制的推测性子识别结果缓冲,避免将失败 AND 分支的中间结果写入正式缓存,同时仍能登记成功子节点的详细结果。
Original summary in English

Summary by Sourcery

Improve composite recognition logic to correctly handle AND/OR combinations with ROI dependencies and speculative sub-recognition caching.

Bug Fixes:

  • Fix AND recognizer so that when a sub-recognition returns multiple candidate ROIs, subsequent OR sub-recognitions still short-circuit correctly without leaking failed branch results into the runtime cache.

Enhancements:

  • Factor out shared sub-recognition execution into a reusable helper used by both AND and OR combinators.
  • Introduce recursive analysis of recognition parameters to detect nested AND/OR sub-recognitions that depend on specific ROI targets, guiding candidate box propagation in AND branches.
  • Add speculative sub-recognition result buffering with explicit flushing to avoid committing intermediate results from failed AND branches while still registering successful sub-node details.

@overflow65537 overflow65537 linked an issue May 30, 2026 that may be closed by this pull request
Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

你好——我已经查看了你的修改,看起来很棒!


Sourcery 对开源项目免费——如果你喜欢我们的代码审查,请考虑分享 ✨
帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈改进之后的审查。
Original comment in English

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@overflow65537 overflow65537 marked this pull request as draft May 30, 2026 13:18
@overflow65537 overflow65537 marked this pull request as ready for review May 30, 2026 13:52
Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey - 我在这里给出了一些总体反馈:

  • and_ 中围绕 cache_sub_results_/pending_sub_results_ 的猜测性缓存逻辑,在多个返回路径上都涉及手动快照和对 resize 的调用;建议把这部分封装进一个 RAII 辅助工具中(例如,一个在作用域结束时自动回滚或提交的 guard),以减少将来新增早返回路径时忘记恢复状态的风险。
  • recognition_param_uses_roi_target 中,requires { value.roi_target; } 这个检查有些脆弱,它依赖于参数变体上一个不明显的隐式接口;你可能需要改成对已知、具有 roi_target 的参数类型进行显式处理,从而让依赖分析更加健壮,也更易于维护。
给 AI Agent 的提示
Please address the comments from this code review:

## Overall Comments
- The speculative caching logic around `cache_sub_results_`/`pending_sub_results_` in `and_` involves manual snapshots and `resize` calls on multiple return paths; consider encapsulating this in an RAII helper (e.g., a guard that automatically rolls back or flushes) to reduce the risk of future early-return paths forgetting to restore state.
- In `recognition_param_uses_roi_target`, the `requires { value.roi_target; }` check is somewhat brittle and relies on a non-obvious implicit interface of param variants; you may want to replace this with explicit handling of the known param types that have `roi_target` to make the dependency analysis more robust and easier to maintain.

Sourcery 对开源项目是免费的——如果你觉得我们的评审有帮助,欢迎分享 ✨
帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈改进后续的评审。
Original comment in English

Hey - I've left some high level feedback:

  • The speculative caching logic around cache_sub_results_/pending_sub_results_ in and_ involves manual snapshots and resize calls on multiple return paths; consider encapsulating this in an RAII helper (e.g., a guard that automatically rolls back or flushes) to reduce the risk of future early-return paths forgetting to restore state.
  • In recognition_param_uses_roi_target, the requires { value.roi_target; } check is somewhat brittle and relies on a non-obvious implicit interface of param variants; you may want to replace this with explicit handling of the known param types that have roi_target to make the dependency analysis more robust and easier to maintain.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The speculative caching logic around `cache_sub_results_`/`pending_sub_results_` in `and_` involves manual snapshots and `resize` calls on multiple return paths; consider encapsulating this in an RAII helper (e.g., a guard that automatically rolls back or flushes) to reduce the risk of future early-return paths forgetting to restore state.
- In `recognition_param_uses_roi_target`, the `requires { value.roi_target; }` check is somewhat brittle and relies on a non-obvious implicit interface of param variants; you may want to replace this with explicit handling of the known param types that have `roi_target` to make the dependency analysis more robust and easier to maintain.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

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.

And识别器中的Or识别器结果不符合预期

1 participant