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

locateAllOnScreen raises pyscreeze.ImageNotFoundException #864

Open
eight04 opened this issue Jun 12, 2024 · 1 comment
Open

locateAllOnScreen raises pyscreeze.ImageNotFoundException #864

eight04 opened this issue Jun 12, 2024 · 1 comment

Comments

@eight04
Copy link

eight04 commented Jun 12, 2024

>>> list(pyautogui.locateAllOnScreen("test.png"))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\eight04\dev\valkyrie-connect-auto\.venv\Lib\site-packages\pyscreeze\__init__.py", line 257, in _locateAll_opencv
    raise ImageNotFoundException('Could not locate the image (highest confidence = %.3f)' % result.max())
pyscreeze.ImageNotFoundException: Could not locate the image (highest confidence = 0.178)

While locateOnScreen raises pyautogui.ImageNotFoundException correctly:

>>> pyautogui.locateOnScreen("test.png")
Traceback (most recent call last):
  File "C:\Users\eight04\dev\valkyrie-connect-auto\.venv\Lib\site-packages\pyautogui\__init__.py", line 172, in wrapper
    return wrappedFunction(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\eight04\dev\valkyrie-connect-auto\.venv\Lib\site-packages\pyautogui\__init__.py", line 210, in locateOnScreen
    return pyscreeze.locateOnScreen(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\eight04\dev\valkyrie-connect-auto\.venv\Lib\site-packages\pyscreeze\__init__.py", line 405, in locateOnScreen
    retVal = locate(image, screenshotIm, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\eight04\dev\valkyrie-connect-auto\.venv\Lib\site-packages\pyscreeze\__init__.py", line 383, in locate
    points = tuple(locateAll(needleImage, haystackImage, **kwargs))
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\eight04\dev\valkyrie-connect-auto\.venv\Lib\site-packages\pyscreeze\__init__.py", line 257, in _locateAll_opencv
    raise ImageNotFoundException('Could not locate the image (highest confidence = %.3f)' % result.max())
pyscreeze.ImageNotFoundException: Could not locate the image (highest confidence = 0.167)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\eight04\dev\valkyrie-connect-auto\.venv\Lib\site-packages\pyautogui\__init__.py", line 174, in wrapper
    raise ImageNotFoundException  # Raise PyAutoGUI's ImageNotFoundException.
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pyautogui.ImageNotFoundException

I guess the problem is that locateAll returns a generator, hence you have to wrap its __next__ method to catch the error, or use yield from.

@matthewjerome
Copy link

It looks like this is an issue related to pyscreeze - please try to install pyscreeze at the version 0.1.29 as described in this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants