I'm building a bot a to play the following game called Sushi Go Round. I was using function locateAllOnScreen to locate the orders.
The code is like following:
import pyautogui
onigiri = pyautogui.locateAllOnScreen('onigiri.png')
print(onigiri)
The onigiri.png was cropped out from the third customer. locateAllOnScreen
could only locate the third customer's order but not the forth customer's even though their images (orders) were exactly the same.
Why didn't the function locate all images even though the images were the same?
Or were the images actually different?
I'm frustrated. Please help. Thank you very much!
Sushi Go Round
onigiri.png
For us (humans) images seem identical but for computer they are different if even single pixel is different.
If I use confidence=0.9
then it finds two items.
import pyautogui
onigiri = pyautogui.locateAllOnScreen('onigiri.png', confidence=0.9)
for item in onigiri:
print(item)
Result:
Box(left=849, top=400, width=55, height=53)
Box(left=988, top=400, width=55, height=53)
Doc Screenshot:
The optional "confidence" keyword argument specifies the accuracy with
which the function should locate the image on screen. This is helpful
in case the function is not able to locate an image due to negligible
pixel differences:
For other users:
Programming a Bot to Play the "Sushi Go Round" Flash Game - The Invent with Python Blog