Open hayashi7w opened 1 year ago
Is opencv installed? If it is not installed, it is illogical.
Yes, OpenCV is installed.
I confirm the bug. With version 1.0.29 the code given by hayashi7w works. With version 1.0.30 we get the error message mentioned if the image is not found.
Yes, I have the same problem, I had to return to the previous version 0.1.29
Between the lack of git tags and commit message indication, the versioning is unclear. But there aren't that many commits, I checked based on the date and it turns out it's literally the last commit https://github.com/asweigart/pyscreeze/commit/eeca245a135cf171c163b3691300138518efa64e
I too am experiencing this issue and when trying to use "locateAllOnScreen" with PyAutogui, it hits an exception. Thing is, a try/catch block doesn't catch it. Pyscreeze will still error out.
I created https://github.com/aentwist/gamedriver to replace all image matching PyScreeze does. There were several important reasons for it, one of which was the interesting behavior around "confidence".
The error message indicated a high confidence level (0.999) in locating the image, but the image could not be found.
What is confidence?
Both our libraries use OpenCV template matching. It is not machine learning, but rather a 2D convolution. There is no confidence involved. There is only a threshold value that determines whether potential matches are "good enough" to be considered matches. In other words how close a match is, not how confident we are either in a match or that we matched. In some roundabout way, the "confidence" here is that threshold value. I cannot tell you exactly what it does after reading the source code. Just understand that increasing the "confidence" makes matching more strict - you'll be able to be very confident that any matches that do occur are correct. But with a "confidence" of 0.999, those matches probably won't occur at all; unless they are extremely precise it will result in a miss. It is no surprise that with such a high number matches are being missed.
As for the actual regression here, anyone can dig through the commit I linked, no further comment on that. Feel free to try out my library for matching purposes.
Version Information:
pyscreeze version: 0.1.30 (Problematic), 0.1.29 (Problem Solved) Operating System: Windows 10 Python Version: 3.12.0 Detailed Description of the Issue: I encountered an issue with pyscreeze version 0.1.30 where it consistently threw an ImageNotFoundException despite the image being present on the screen. The error message indicated a high confidence level (0.999) in locating the image, but the image could not be found. After downgrading to pyscreeze version 0.1.29, the issue was resolved and the image was correctly identified.
Code Snippet to Reproduce the Issue:
Error Message and Stack Trace:
Additional Context: The same code and image file work perfectly with pyscreeze version 0.1.29. The issue seems specific to version 0.1.30. Any insights or resolutions would be greatly appreciated.