Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated that under human demonstration, the image resolution is adapted to the screen and placed on top of the screen. #47

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion scripts/step_recorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from and_controller import list_all_devices, AndroidController, traverse_tree
from config import load_config
from utils import print_with_color, draw_bbox_multi
from utils import print_with_color, draw_bbox_multi, get_screen_size

arg_desc = "AppAgent - Human Demonstration"
parser = argparse.ArgumentParser(formatter_class=argparse.RawDescriptionHelpFormatter, description=arg_desc)
Expand Down Expand Up @@ -72,6 +72,7 @@
print_with_color("ERROR: Invalid device size!", "red")
sys.exit()
print_with_color(f"Screen resolution of {device}: {width}x{height}", "yellow")
_, screen_height = get_screen_size()

print_with_color("Please state the goal of your following demo actions clearly, e.g. send a message to John", "blue")
task_desc = input()
Expand Down Expand Up @@ -109,6 +110,9 @@
elem_list.append(elem)
labeled_img = draw_bbox_multi(screenshot_path, os.path.join(labeled_ss_dir, f"{demo_name}_{step}.png"), elem_list,
True)
cv2.namedWindow('image', cv2.WINDOW_NORMAL)
cv2.setWindowProperty('image', cv2.WND_PROP_TOPMOST, 1)
cv2.resizeWindow('image', int(screen_height * width / height), screen_height)
cv2.imshow("image", labeled_img)
cv2.waitKey(0)
cv2.destroyAllWindows()
Expand Down
9 changes: 9 additions & 0 deletions scripts/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import pyshine as ps

from colorama import Fore, Style
from tkinter import Tk


def print_with_color(text: str, color=""):
Expand Down Expand Up @@ -98,3 +99,11 @@ def get_unit_len(n):
def encode_image(image_path):
with open(image_path, "rb") as image_file:
return base64.b64encode(image_file.read()).decode('utf-8')


def get_screen_size():
root = Tk()
width = root.winfo_screenwidth()
height = root.winfo_screenheight()
root.destroy()
return width, height