Skip to content

Fix: Correct TargetInfo rect format assumption in IOU calculation - #274

Merged
vyokky merged 1 commit into
microsoft:mainfrom
Finn758089:fix/iou-rect-format
Dec 26, 2025
Merged

Fix: Correct TargetInfo rect format assumption in IOU calculation#274
vyokky merged 1 commit into
microsoft:mainfrom
Finn758089:fix/iou-rect-format

Conversation

@Finn758089

Copy link
Copy Markdown
Contributor
# UFO\ufo\automator\ui_control\screenshot.py: 1060-1079
    def target_info_iou(target1: "TargetInfo", target2: "TargetInfo") -> float:
        """
        Calculate the IOU overlap between two TargetInfo objects.
        :param target1: The first target.
        :param target2: The second target.
        :return: The IOU overlap.
        """
        # Check if both targets have valid rect information
        if not target1.rect or not target2.rect:
            return 0.0

        # TargetInfo rect format: [left, top, width, height] <-this is not correct, should be [[left, top, right, bottom]
        # Convert to [left, top, right, bottom] for calculation <- this calculation should be fixed
        rect1_left, rect1_top, rect1_width, rect1_height = target1.rect
        rect1_right = rect1_left + rect1_width
        rect1_bottom = rect1_top + rect1_height

        rect2_left, rect2_top, rect2_width, rect2_height = target2.rect
        rect2_right = rect2_left + rect2_width
        rect2_bottom = rect2_top + rect2_height
...

The target_info_iou function incorrectly assumed TargetInfo.rect format was [left, top, width, height], but it's actually [left, top, right, bottom]. This caused incorrect IOU calculations when merging control lists, leading to improper duplicate detection.
@vyokky
vyokky merged commit d39fec2 into microsoft:main Dec 26, 2025
1 check passed
@Finn758089
Finn758089 deleted the fix/iou-rect-format branch December 29, 2025 06:56
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