Detect color in an area with Pyautogui

Asked

Viewed 252 times

0

I wonder if there is any way to detect a certain color in a predefined area with Pyautogui using Python. Something like pixelMatchesColor, but to detect color in an area not at a point.

1 answer

1


Currently there is no functionality to detect the color of an area with Pyautogui, but there are some solutions using existing functions. If your goal is to identify the predominant color of a certain area, you can average the RGB values displayed with the function, pyautogui.pixel(x,y). Now if the goal is just to check if in a certain area there is a pixel with the requested color, you will need to use the own pixelMatchesColor() to identify, placing it inside a loop of repetition where the coordinates X and Y increase and decrease to form the desired area (recommend a rectangle even).

  • I was already making a print of the area and detecting if a color existed between the detected colors, however I will test your solution, will probably have a better response time, thanks.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.