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

Bug in opencv locateAll #97

Open
lucaswiman opened this issue May 25, 2023 · 0 comments
Open

Bug in opencv locateAll #97

lucaswiman opened this issue May 25, 2023 · 0 comments

Comments

@lucaswiman
Copy link

This bug appears to have been introduced in version 0.1.29. When opencv is installed the locateAll methods don't work correctly, failing to find the needle image, even though it is in pixel-for-pixel present at position (0,0) in the haystack.

How to reproduce

  • Haystack: screenshot
  • Needle:
    corner-icon

The pillow version finds it, but the cv2 version does not:

>>> import pyscreeze
>>> list(pyscreeze._locateAll_pillow(needleImage='corner-icon.png', haystackImage='./screenshot.png'))
[Box(left=0, top=0, width=16, height=16)]
>>> list(pyscreeze._locateAll_opencv(needleImage='corner-icon.png', haystackImage='./screenshot.png'))
[]

But the image is present in the upper left corner:

>>> import cv2
>>> needle = cv2.imread('corner-icon.png')
>>> haystack = cv2.imread('screenshot.png')
>>> (haystack[:16,:16] == needle).all()
True

System information

# python --version
Python 3.8.16
# pip freeze
EasyProcess==1.1
entrypoint2==1.1
jeepney==0.8.0
mss==9.0.1
numpy==1.24.3
opencv-python-headless==4.7.0.72
Pillow==9.5.0
pyscreenshot==3.1
PyScreeze==0.1.29
# head -n 2 /etc/os-release
NAME="Ubuntu"
VERSION="18.04.6 LTS (Bionic Beaver)"

This also reproduced on MacOS (Python 3.9.12).

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

1 participant