diff --git a/mm_agents/accessibility_tree_wrap/heuristic_retrieve.py b/mm_agents/accessibility_tree_wrap/heuristic_retrieve.py index ccb4886..7ab439f 100644 --- a/mm_agents/accessibility_tree_wrap/heuristic_retrieve.py +++ b/mm_agents/accessibility_tree_wrap/heuristic_retrieve.py @@ -2,6 +2,7 @@ import xml.etree.ElementTree as ET from PIL import Image, ImageDraw, ImageFont +from typing import Tuple def find_leaf_nodes(xlm_file_str): if not xlm_file_str: @@ -105,15 +106,20 @@ def draw_bounding_boxes(nodes, image_file_path, output_image_file_path): # Draw index number at the bottom left of the bounding box with black background text_position = (coords[0], bottom_right[1]) # Adjust Y to be above the bottom right - draw.rectangle([text_position, (text_position[0] + 25, text_position[1] + 18)], fill='black') - draw.text(text_position, str(index), font=font, fill="white") + text_bbox: Tuple[int, int ,int ,int] = draw.textbbox(text_position, str(index), font=font, anchor="lb") + #offset: int = bottom_right[1]-text_bbox[3] + #text_bbox = (text_bbox[0], text_bbox[1]+offset, text_bbox[2], text_bbox[3]+offset) + + #draw.rectangle([text_position, (text_position[0] + 25, text_position[1] + 18)], fill='black') + draw.rectangle(text_bbox, fill='black') + draw.text(text_position, str(index), font=font, anchor="lb", fill="white") index += 1 # each mark is an x, y, w, h tuple marks.append([coords[0], coords[1], size[0], size[1]]) drew_nodes.append(_node) - except ValueError as e: + except ValueError: pass # Save the result diff --git a/requirements.txt b/requirements.txt index b494102..23e6a27 100644 --- a/requirements.txt +++ b/requirements.txt @@ -38,3 +38,4 @@ pydrive fastdtw openai +func-timeout