Home > Enterprise >  Is there an equivalent to cv2.minMaxLoc in pyautogui?
Is there an equivalent to cv2.minMaxLoc in pyautogui?

Time:09-17

OpenCV has a function cv2.minMaxLoc(). This function allows you to return the max_val which is the pixel with the best match to whatever image you're searching for.

You can print(max_val) to see how close a match your image actually is, even if doesn't find a match, it'll still return the closest possible match as a decimal.

pyautogui has documentation that shows that you can use the confidence parameter if OpenCV is installed which seems similar to how threshold matching works with OpenCV.

Is there an equivalent for pyautogui? I can't seem to find one.

CodePudding user response:

I looked in the source code, and there is no confidence parameter without OpenCV. pyautogui uses pyscreeze for all of the locate functions. pyscreeze autodetects if OpenCV is installed. If installed, it calls cv2.matchTemplate using the cv2.TM_CCOEFF_NORMED match mode. If not installed, they use their own function (_locateAll_python)that I don't fully understand but I think it looks for a perfect match (confidence 1.000000...)

If you don't mind having OpenCV dependency, but just don't want code that directly calls OpenCV, you can either

  1. talk maintainer into modifying _locateAll_opencv in pyscreeze to return actual confidence

or

  1. hack your own local copy of pyscreeze so that it returns actual confidence.

CodePudding user response:

According to libhunt :

PyAutoGUI alternatives and similar packages

  • Selenium. 9.8 9.9 L2 PyAutoGUI VS Selenium. A browser automation framework and ecosystem.
  • locust. 9.5 9.4 L3 PyAutoGUI VS locust. Scalable user load testing tool written in Python.
  • splinter. 7.1 8.1 L5 PyAutoGUI VS splinter. ...
  • sixpack. 6.1 0.0 L4 PyAutoGUI VS sixpack

Here is the link : https://python.libhunt.com/pyautogui-alternatives

  • Related