Skip to content

Commit 6d85b61

Browse files
committed
handle case where find_image returns None + add start_button_text3.en.png
1 parent f391525 commit 6d85b61

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

bot.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,12 @@ def run():
9494
max_image_file = None
9595
max_coords = None
9696
for image_file, img_template in template_images.items():
97-
val, coords = image_service.find_image(img_screenshot, img_template)
97+
result = image_service.find_image(img_screenshot, img_template)
98+
if result:
99+
val, coords = result
100+
else:
101+
# handle case where find_image returns None
102+
val, coords = 0, None
98103

99104
# Update the maximum value and corresponding image file and coordinates if necessary
100105
if val > max_val:

image_service.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ def convert_to_greyscale(img_to_convert):
1313

1414

1515
def find_image(img_large, img_small):
16+
if img_large is None:
17+
print("Image large is none")
18+
return
19+
20+
if img_small is None:
21+
print("Image small is none")
22+
return
23+
1624
# Convert the images to grayscale
1725
gray_large = convert_to_greyscale(img_large)
1826
gray_small = convert_to_greyscale(img_small)

images/start_button_text3.en.png

5.7 KB
Loading

0 commit comments

Comments
 (0)