fix(Task): get_target_rect 对所有 target 类型处理 offset 引入的负宽高#1373
Open
ocsin1 wants to merge 1 commit into
Open
Conversation
此前 target_offset 的负宽高仅 Region 类型通过 normalize_rect 间接 支持。Self/PreTask/Anchor 类型的 offset 若含负宽高,会直接被 std::clamp 夹为 0,导致 cv::Rect::empty() 命中,动作报 "failed to get target rect" 错误。 对 offset 应用后的负宽高按 ROI 语义(取绝对值并反向调整 x/y)处理, 该逻辑对所有 target 类型生效。不直接调 normalize_rect,因为其负 x/y 的"从边缘算起"语义对 offset 不适用,x/y 仍由 clamp 裁剪。
Contributor
There was a problem hiding this comment.
Hey - 我已经审查了你的修改,一切看起来都很棒!
帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈改进后续的评审。
Original comment in English
Hey - I've reviewed your changes and they look great!
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
此前 target_offset 的负宽高仅 Region 类型通过 normalize_rect 间接 支持。Self/PreTask/Anchor 类型的 offset 若含负宽高,会直接被
std::clamp 变为 0,导致 cv::Rect::empty() 命中,动作报 "failed to get target rect" 错误。
示例:
{ "1": { "roi": [ 790, 308, 154, 18 ], "action": "Click",// 这样会报错 "target_offset": [ 0, -50, 0, -30 ] }, "2": { "roi": [ 790, 258, 154, -12 ] // 直接点击偏移后结果这样不会 } }对 offset 应用后的负宽高按 ROI 语义(取绝对值并反向调整 x/y)处理,
该逻辑对所有 target 类型生效。不直接调 normalize_rect,因为其负 x/y
的"从边缘算起"语义对 offset 不适用,x/y 仍由 clamp 裁剪。(因为这样是原逻辑,而且更有用)
Summary by Sourcery
错误修复:
get_target_rect,使其在出现导致宽度/高度为负的偏移量时,像 ROI 一样进行归一化处理,而不是直接钳制为零,从而防止出现空矩形以及在所有目标类型上发生的“failed to get target rect”错误。Original summary in English
Summary by Sourcery
Bug Fixes: