Skip to content

Commit

Permalink
make action_event a required parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
AvidEslami committed May 31, 2023
1 parent 376cc66 commit df80ac0
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions openadapt/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,23 +274,15 @@ def take_screenshot(cls):
screenshot = Screenshot(sct_img=sct_img)
return screenshot

def crop_active_window(self, action_event=None):
if action_event:
action_event_to_use = action_event
elif self.action_event:
action_event_to_use = self.action_event
else:
logger.info("No action event to use for cropping, image will not be cropped")
return

window_event = action_event_to_use.window_event
def crop_active_window(self, action_event):
window_event = action_event.window_event
width_ratio, height_ratio = utils.get_scale_ratios(action_event)

x0 = window_event.left * width_ratio
y0 = window_event.top * height_ratio
x1 = x0 + window_event.width * width_ratio
y1 = y0 + window_event.height * height_ratio

box = (x0, y0, x1, y1)
self._image = self._image.crop(box)

Expand Down

0 comments on commit df80ac0

Please sign in to comment.