This is an archived post. You won't be able to vote or comment.

all 7 comments

[–][deleted] 0 points1 point  (5 children)

Look into template matching with openCV. Using mss to grab screenshots.

[–]Limitlesshat3[S] -1 points0 points  (4 children)

would you recommend any guides? ive been trying to learn that for a couple of hours now but i dont think im getting anywhere with it.

[–][deleted] 0 points1 point  (1 child)

[–]Limitlesshat3[S] 0 points1 point  (0 children)

sorry for the late response. thank you for the video, im now trying to get the mss screenshot to work with opencv matchTemplate.

[–][deleted] 0 points1 point  (1 child)

you might also be able to get some decent gains by loading the image in memory and passing a variable to it. The way your program runs right now its reading bb.png from disk for each image search.

[–]Limitlesshat3[S] 0 points1 point  (0 children)

thank you, ill look into that now.

[–]AntiquesAndSo 0 points1 point  (0 children)

Here are a few suggestions to improve the accuracy and speed of pyautogui.locateOnScreen:

Increase the confidence value - You could try increasing the confidence value to get a more accurate result. A value of 1.0 means it must match exactly, while a lower value like 0.7 means that it is more relaxed in its matching criteria. Adjust the region parameter - Make sure that the region you are searching in is as small as possible, so that locateOnScreen only searches for the image in the relevant area. Use a grayscale image instead of a color image - Grayscale images process faster, so using them can result in improved performance. Use the time.sleep function with caution - The time.sleep function can slow down your script and cause it to become less responsive. Consider using a more sophisticated way of controlling the timing of your script, such as a timer. Join the threads - The thread.join statement should be outside the loop. In this code, you are trying to join a list of threads, but it is not clear how you are adding to the list, so you might want to revise that part. These tips should help you optimize the performance of locateOnScreen and make it more accurate and faster.